02 2011 档案

摘要:在看 学习shell中练习的代码#!/bin/bash# User can keyin filename to touch 3 new files.PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/gamesexport PATHecho "I will use 'touch' command to create 3 files."read -p "Please input the filename what you want: " fileuse 阅读全文
posted @ 2011-02-23 15:58 lxgeek 阅读(1928) 评论(0) 推荐(0) 编辑
摘要:在linux的源码中对于fd_set结构体是这样定义:#undef __NFDBITS#define __NFDBITS (8 * sizeof(unsigned long))#undef __FD_SETSIZE#define __FD_SETSIZE 1024#undef __FDSET_LONGS#define __FDSET_LONGS (__FD_SETSIZE/__NFDBITS )typedef struct { unsigned long fds_bits [__FDSET_LONGS]; } fd_set;并没有fd_count 和 fd_array,而fd_count和fd 阅读全文
posted @ 2011-02-23 11:13 lxgeek 阅读(1510) 评论(2) 推荐(0) 编辑
摘要:#include <stdio.h>#include <stdlib.h>typedef struct { int a;} abc;struct tcp_server{ struct abc b;};int main( int argc, char** argv ){}用gcc编译的时候会出现:test22.c:11: error: field ‘b’ has incomplete typeabc 本来就是 struct { int a}; 的别名,然后使用的时候又加了struct.所以出现了这个问题。 阅读全文
posted @ 2011-02-23 11:04 lxgeek 阅读(269) 评论(1) 推荐(0) 编辑
摘要:在看别人代码的时候看到了Tail Queues,于是查了 manual,但是还不是很懂,于是查了源码,明白了些。TAILQ_HEAD(HEADNAME, TYPE) head; where HEADNAME is the name of the structure to be defined, and TYPE is the type of the elements to be linked into the tail queue. A pointer to the head of the tail queue.在源码中这样实现:The macro CIRCLEQ_INIT initiali 阅读全文
posted @ 2011-02-11 17:10 lxgeek 阅读(973) 评论(0) 推荐(0) 编辑
摘要:/* malloc a fd_set on the heap, to make it dependent from FD_SETSIZE. make sure fd_count > FD_SETSIZE. */ #define NEW_FD_SET( fd_count ) \ (struct fd_set*) malloc( sizeof( struct fd_set ... 阅读全文
posted @ 2011-02-09 17:17 lxgeek 阅读(1023) 评论(2) 推荐(0) 编辑
摘要:#include #include #include #include char localtm[80]; void getlocaltime() { time_t now; //实例化time_t结构 struct tm *timenow; //实例化tm结构指针 time(&now); //time函数读取现在的时间(国际... 阅读全文
posted @ 2011-02-08 18:06 lxgeek 阅读(1875) 评论(0) 推荐(0) 编辑
摘要:<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->#include <sys/sock 阅读全文
posted @ 2011-02-04 21:47 lxgeek 阅读(580) 评论(0) 推荐(0) 编辑