完成HTTP请求侧解析调试,可以解析请求的URL。

* 增加插件管理功能(简单实现),可以调用解析层插件;
* 调整HTTP请求侧解析回调函数实现;
* 增加hexdump工具函数;
This commit is contained in:
Lu Qiuwen
2018-09-07 17:27:23 +08:00
parent e31ecbb8db
commit b6a2250786
12 changed files with 273 additions and 84 deletions

View File

@@ -84,3 +84,35 @@ char* tfe_strdup(const char* s);
#define TFE_PTR_SUB(ptr, x) ((void*)((uintptr_t)ptr - (x)))
#define TFE_PTR_DIFF(ptr1, ptr2) ((uintptr_t)(ptr1) - (uintptr_t)(ptr2))
#define TFE_DIM(x) (sizeof (x) / sizeof ((x)[0]))
#include <stdio.h>
static inline void tfe_hexdump(FILE *f, const char * title, const void * buf, unsigned int len)
{
unsigned int i, out, ofs;
const unsigned char *data = (const unsigned char *)buf;
#define LINE_LEN 80
char line[LINE_LEN]; /* space needed 8+16*3+3+16 == 75 */
fprintf(f, "%s at [%p], len=%u\n", (title)? title : " Dump data", data, len);
ofs = 0;
while (ofs < len) {
/* format the line in the buffer, then use printf to output to screen */
out = snprintf(line, LINE_LEN, "%08X:", ofs);
for (i = 0; ((ofs + i) < len) && (i < 16); i++)
out += snprintf(line+out, LINE_LEN - out, " %02X", (data[ofs+i] & 0xff));
for(; i <= 16; i++)
out += snprintf(line+out, LINE_LEN - out, " | ");
for(i = 0; (ofs < len) && (i < 16); i++, ofs++) {
unsigned char c = data[ofs];
if ( (c < ' ') || (c > '~'))
c = '.';
out += snprintf(line+out, LINE_LEN - out, "%c", c);
}
fprintf(f, "%s\n", line);
}
fflush(f);
#undef LINE_LEN
}