摘要:
list链表是双链表,在libnet中的实现同样简单,其借用了linux中list的实现思路,将指针域与数据域分离。要用list也是跟list中一样的。如下是指针域的实现代码——为了方便阅读,我用linux下的风格将语句分开了。/* Linked list code, inspired by Links, but written from scratch. */struct list_head { void *next; void *prev;};#define init_list(L) \ do { \ L.next = L.prev = &L; \ } while (0) #def 阅读全文
摘要:
libnet 是一个小型的接口函数库,主要用C语言写成,提供了低层网络数据报的构造、处理和发送功能(百度百科上有很详细的介绍哦)。貌似我下载的版本与网上教程说的不太一致。我在sf上下载的最新版,但是却是0.10.11版——网上有说1.0版的,我到底该信谁的呢!今天无意中看到该库的循环队列的实现,感觉真是简洁啊!有木有啊!!!/* Queues. */#define QUEUE_SIZE 2048struct queue { unsigned char data[QUEUE_SIZE]; int head, tail;};#define queue_wrap(x) ((x) & (QUE 阅读全文
摘要:
我用gcc编译,有std=c99选项。出现mylist.c:88: warning: implicit declaration of function ‘typeof’mylist.c:88: error: expected expression before ‘)’ tokenmylist.c:88: error: expected expression before ‘)’ tokenmylist.c:91: error: expected expression before ‘)’ tokenmylist.c:91: error: expected expression before ‘ 阅读全文