- 論壇徽章:
- 0
|
1. 本人使用sdk3.2,ubuntu 10 Linux,想開發(fā)一個類似于example 里protocol組件的功能。 根據(jù)http://trafficserver.apache.org/ ... mple-plugin.en.html 指南,用tsxs編譯的時候,出現(xiàn)如下錯誤。thread主要適用example里的thread-pool里的代碼。查看錯誤后,貌似無法編譯thrad.h里的typedef int (*ExecFunc) (TSCont, void *);句子。不知道如何解決這個問題?請指教!謝謝
tc@ubuntu:/usr/compile$ tsxs -o ctxplugin.so -c thread.h thread.c content_plugin.h content_plugin.c
compiling thread.h -> thread.lo
thread.h:36: error: expected ‘)’ before ‘void’
thread.h:42: error: expected specifier-qualifier-list before ‘TSCont’
thread.h:62: error: expected specifier-qualifier-list before ‘TSMutex’
thread.h:77: error: expected ‘)’ before ‘contp’
Compile failed: gcc -I/usr/local/include -march=i586 -g -pipe -Wall -Werror -O3 -feliminate-unused-debug-symbols -fno-strict-aliasing -fpic -c thread.h -o thread.lo
tc@ubuntu:/usr/compile$
2. 對于分析http頭,本人的代碼如下,但貌似不很專業(yè),兄是否有更好的解決方案:
void parse_request(char * request_data, CustomRequest * request) ////////////// general ok
{
TSDebug("protocol", "Entering parse_request");
char *token = NULL;
token = strtok(request_data, "\r\n");
while (token)
{
char * g = strstr(token, "GET");
if (g != NULL)
{
char* get = strstr(g, "/");
char ret[40];
get++;
strncpy ( ret, get, strlen(get)-9 );
ret[strlen(get)-9] = '\0';
request->transfer_id = ret;
}
char * pch = strstr(token, "Ingress-Capacity");
if (pch != NULL)
{
char* ret = strstr(pch, ":");
ret ++ ;
request->ingress_capacity = 0;//num;
}
char * r = strstr(token, "Range");
if (r != NULL)
{
char* ret = strstr(r, "=");
ret ++;
request->range = ret;
}
token = strtok(NULL, "\r\n");
}
TSDebug("protocol", "Exit parse_request");
}
3. 為了測試,需要建立一個server以檢測plugin功能正常,目前計劃用java實現(xiàn),如果方便的話,兄是否有類似解決方案供參考一下。
|
|