易截截图软件、单文件、免安装、纯绿色、仅160KB

Linux 系统时间设置、编程总结

未完待续...
设置时间:
date -s "2009/11/08 11:23:00"
硬件时钟与系统时间同步一下:
hwclock --systohc
编程:
#include <cstdlib>
time_t time(time_t *timer)
调用后将当前系统时间与1900年1月1日相差的秒数存入到timer中,timer可看成是一个长整型数
具体描述:
  函数原型:  time_t  time(time_t  *timer)     
  函数用途:  得到机器的日历时间或者设置日历时间     
  头  文  件:  time.h   
  输入参数:  timer:=NULL时,得到机器日历时间,=时间数值时  用于设置日历时间; 
struct tm* localtime(const time_t *timer)
将time()函数调用的结果做为参数传入到localtime()函数中就能得到当前时间和日期,注意得到的年是和1970的差值,月份是和1月的差值
struct tm是一个结构体,定义如下:
struct tm
{
int tm_sec; //当前秒
int tm_min; //当前分钟
int tm_hour; //当前小时
int tm_mday; //当前在本月中的天,如11月1日,则为1
int tm_mon; //当前月,范围是0~11
int tm_year; //当前年和1900的差值,如2006年则为36
int tm_wday; //当前在本星期中的天,范围0~6
int tm_yday; //当前在本年中的天,范围0~365
int tm_isdst; //这个我也不清楚
}
注意:返回的tm* 指向一个static位置,每次调用返回的都是这个静态区域,这也就是不需要delete tm的原因。
求当前时间的示例
int getSystemTime()
{
time_t timer;
struct tm* t_tm;
time(&timer);
t_tm = localtime(&timer);
printf("today is %4d%02d%02d%02d%02d%02d\n", t_tm.tm_year+1900,
t_tm.tm_mon+1, t_tm.tm_mday, t_tm.tm_hour, t_tm.tm_min, t_tm.tm_sec);
return 0;
}
其他时间的函数和结构还有:
timeval结构
#include <include/linux/time.h>
struct timeval
{
time_t tv_sec;
susecond_t tv_usec; //当前妙内的微妙数
};
tms结构
保存着一个进程及其子进程使用的cpu时间
struct tms
{
clock_t tms_utime;
clock_t tms_stime;
clock_t tms_cutime;
clock_t tms_cstime;
}
timer_struct结构
#include <include/linux/timer.h>
struct timer_struct
{
unsigned long expires; //定时器被激活的时


相关文档:

实战Linux Bluetooth编程(六) L2CAP编程实例

例一:发送Signaling Packet:
Signaling Command是2个Bluetooth实体之间的L2CAP层命令传输。所以得Signaling Command使用CID 0x0001.
多个Command可以在一个C-frame(control frame)中发送。
 如果要直接发送Signaling Command.需要建立SOCK_RAW类型的L2CAP连接Socket。这样才有机会自己填充Command Code,Identi ......

实战Linux Bluetooth编程 (七) SDP协议

Service Discovery Protocol(SDP)提供一种能力,让应用程序有方法发现哪种服务可用以及这种服务的特性。
服务发现协议(SDP或Bluetooth SDP)在蓝牙协议栈中对蓝牙环境中的应用程序有特殊的含意,发现哪个服务是可用的和确定这些可用服务的特征。SDP定义了bluetooth client发现可用bluetooth server服务和它们的特征的方法。 ......

在Linux下用buildroot搭建mips/arm的交叉编译平台

 在Linux下用buildroot搭建mips/arm的交叉编译平台
这个编译环境是不能编译for开源无线路由器的程序的,因为内核是2.6的
建议参考这篇: http://www.felix021.com/blog/read.php?1467
前两天买了NetGear WRT614 V9,搭载的是Broadcom的200MHz MIPS处理器。
由于使用的是开源操作系统Linux,所以可以刷网上一些NB的 ......

Linux内存管理之slab分配器分析(续二)

 五:kmem_cache_create()分析
我们以一个例子来跟踪分析一下slab的机制:
下面是一个测试模块的代码:
#include <linux/config.h>
#include <linux/module.h>
#include <linux/slab.h>
 
MODULE_LICENSE("GPL");
MODULE_AUTHOR("ericxiao <xgr178@163.com>");
MODULE_DESCRI ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号