printf("Response code is %d\n", status);
}
+void header(struct W3* w3, char* key, char* value){
+ printf("Header: %s is `%s'\n", key, value);
+}
+
int main(int argc, char** argv){
if(argv[1] != NULL && strcmp(argv[1], "--version") == 0){
printf("LibW3 %s\n", LIBW3_VERSION);
W3_Set_Path(w3, argv[2]);
W3_On(w3, "status", (void*)status);
W3_On(w3, "data", (void*)fetch_data);
+ W3_On(w3, "header", (void*)header);
W3_Send_Request(w3);
W3_Free(w3);
}else{
char* data = __W3_Strdup(headers + start);
int k;
for(k = 0; data[k] != 0; k++){
+ if(data[k] == ':'){
+ data[k] = 0;
+ k++;
+ for(; data[k] != 0 && data[k] != ' ' && data[k] != '\t'; k++) data[k] = 0;
+ if(data[k] == ' ' || data[k] == '\t'){
+ void* funcptr = __W3_Get_Event(w3, "header");
+ if(funcptr != NULL){
+ void(*func)(struct W3*, char*, char*) = (void(*)(struct W3*, char*, char*))funcptr;
+ func(w3, data, data + k + 1);
+ }
+ }
+ break;
+ }
}
free(data);
start = incr + 1;