一段看了半天的C代码
今天看了一下mini_httpd的代码,有一行代码怎么就是看不明白,最后查来查去,自己调试了以下才总算明白,特地记下,主要是没一开始真没想到012是八进制数,其实0开头的就是表示是八进制,c和java都是这样的path = strpbrk( method_str, " \t\012\015" );//找到四个字符出现的第一个位子 *path++ = '\0';//置为空 path += strspn( path, " \t\012\015" );//跳过这些字符// \012 = \n// \015 = \r
附上从http请求中读一行数据的代码
static char*get_request_line( void ) { int i; char c; for ( i = request_idx; request_idx < request_len; ++request_idx ){c = request;if ( c == '\012' || c == '\015' ) { request = '\0'; ++request_idx; if ( c == '\015' && request_idx < request_len && request == '\012' ){request = '\0';++request_idx;} return &(request); }} return (char*) 0; }
页:
[1]