免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: converse
打印 上一主题 下一主题

lighttpd1.4.18代码分析 [复制链接]

论坛徽章:
0
1 [报告]
发表于 2008-08-26 20:01 |显示全部楼层
我在看array.c, array.h, buffer.h, buffer.c

论坛徽章:
0
2 [报告]
发表于 2008-08-26 22:46 |显示全部楼层
原帖由 xi2008wang 于 2008-8-26 21:51 发表
array.h
看不懂 谁能讲解下面的一个宏是干什么的

#define DATA_UNSET \
        data_type_t type; \
        buffer *key; \
        int is_index_key; /* 1 if key is a array index (autogene ...

看下data_unset的定义。
在data_unset中宏展开成了

  1. typedef struct data_unset {
  2.         data_type_t type; \
  3.         buffer *key; \
  4.         int is_index_key; /* 1 if key is a array index (autogenerated keys) */ \
  5.         struct data_unset *(*copy)(const struct data_unset *src); \
  6.         void (* free)(struct data_unset *p); \
  7.         void (* reset)(struct data_unset *p); \
  8.         int (*insert_dup)(struct data_unset *dst, struct data_unset *src); \
  9.         void (*print)(const struct data_unset *p, int depth);
  10. } data_unset;
复制代码

再看下data_array.c

论坛徽章:
0
3 [报告]
发表于 2008-09-27 12:22 |显示全部楼层
keyvalue.c 中有个 keyvalue_buffer, 用 grep 没查到定义的地方...

论坛徽章:
0
4 [报告]
发表于 2008-09-27 12:27 |显示全部楼层
原帖由 libin1983 于 2008-9-27 12:22 发表
keyvalue.c 中有个 keyvalue_buffer, 用 grep 没查到定义的地方...

找到了:

  1. #define KVB(x) \
  2. typedef struct {\
  3.         x **kv; \
  4.         size_t used;\
  5.         size_t size;\
  6. } x ## _buffer

  7. KVB(keyvalue);
  8. KVB(s_keyvalue);
  9. KVB(httpauth_keyvalue);
  10. KVB(pcre_keyvalue);
复制代码


KVB(keyvalue);
展开变成了:

  1. typedef struct {\
  2.         keyvalue **kv; \
  3.         size_t used;\
  4.         size_t size;\
  5. } keyvalue_buffer
复制代码

论坛徽章:
0
5 [报告]
发表于 2008-09-29 11:35 |显示全部楼层
回楼上, *.c, *.h 里面都有。
宏 KVB 是在 keyvalue.h 中定义的.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP