MCPcopy Create free account
hub / github.com/acl-dev/acl / header_parse

Function header_parse

lib_protocol/samples/http/header/main.c:129–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129static int header_parse(const char* filepath, int max)
130{
131 int i;
132 double n;
133 ACL_VSTREAM* fp;
134 ACL_ITER iter;
135 struct timeval begin, end;
136 char line[1024];
137 ACL_ARGV* tokens = acl_argv_alloc(10);
138
139 fp = acl_vstream_fopen(filepath, O_RDONLY, 0600, 8192);
140 if (fp == NULL)
141 {
142 printf("open file %s error\r\n", filepath);
143 return 0;
144 }
145
146 while (1)
147 {
148 i = acl_vstream_gets_nonl(fp, line, sizeof(line));
149 if (i == 0 || i == ACL_VSTREAM_EOF)
150 break;
151 acl_argv_add(tokens, line, NULL);
152 }
153
154 acl_foreach(iter, tokens)
155 {
156 printf("%s\r\n", (const char*) iter.data);
157 }
158
159 printf("----------------------------------------------------\r\n");
160
161 gettimeofday(&begin, NULL);
162
163#define HDR_RES
164
165 ACL_METER_TIME("begin run");
166 for (i = 0; i < max; i++)
167 {
168#ifdef HDR_RES
169 HTTP_HDR_RES* hdr;
170#else
171 HTTP_HDR_REQ* hdr;
172#endif
173 int j = 0;
174
175#ifdef HDR_RES
176 hdr = http_hdr_res_new();
177#else
178 hdr = http_hdr_req_new();
179#endif
180 acl_foreach(iter, tokens)
181 {
182 HTTP_HDR_ENTRY* entry =
183 http_hdr_entry_new((const char*) iter.data);
184 http_hdr_append_entry(&hdr->hdr, entry);
185 if (++j == 200)
186 break;

Callers 1

mainFunction · 0.85

Calls 14

acl_argv_allocFunction · 0.85
acl_vstream_fopenFunction · 0.85
acl_vstream_gets_nonlFunction · 0.85
acl_argv_addFunction · 0.85
http_hdr_res_newFunction · 0.85
http_hdr_req_newFunction · 0.85
http_hdr_entry_newFunction · 0.85
http_hdr_append_entryFunction · 0.85
http_hdr_res_freeFunction · 0.85
http_hdr_req_freeFunction · 0.85
acl_argv_freeFunction · 0.85
stamp_subFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…