|
|
@ -111,14 +111,14 @@ int main(int argc, char* argv[]) {
|
|
|
|
FILE* file = fopen(filename, "r");
|
|
|
|
FILE* file = fopen(filename, "r");
|
|
|
|
if (file == NULL) {
|
|
|
|
if (file == NULL) {
|
|
|
|
perror("fopen");
|
|
|
|
perror("fopen");
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fseek(file, 0, SEEK_END);
|
|
|
|
fseek(file, 0, SEEK_END);
|
|
|
|
long file_length = ftell(file);
|
|
|
|
long file_length = ftell(file);
|
|
|
|
if (file_length == -1) {
|
|
|
|
if (file_length == -1) {
|
|
|
|
perror("ftell");
|
|
|
|
perror("ftell");
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fseek(file, 0, SEEK_SET);
|
|
|
|
fseek(file, 0, SEEK_SET);
|
|
|
|
|
|
|
|
|
|
|
@ -126,7 +126,7 @@ int main(int argc, char* argv[]) {
|
|
|
|
if (fread(data, 1, file_length, file) != (size_t)file_length) {
|
|
|
|
if (fread(data, 1, file_length, file) != (size_t)file_length) {
|
|
|
|
fprintf(stderr, "couldn't read entire file\n");
|
|
|
|
fprintf(stderr, "couldn't read entire file\n");
|
|
|
|
free(data);
|
|
|
|
free(data);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
http_parser_settings settings;
|
|
|
|
http_parser_settings settings;
|
|
|
@ -149,8 +149,12 @@ int main(int argc, char* argv[]) {
|
|
|
|
"Error: %s (%s)\n",
|
|
|
|
"Error: %s (%s)\n",
|
|
|
|
http_errno_description(HTTP_PARSER_ERRNO(&parser)),
|
|
|
|
http_errno_description(HTTP_PARSER_ERRNO(&parser)),
|
|
|
|
http_errno_name(HTTP_PARSER_ERRNO(&parser)));
|
|
|
|
http_errno_name(HTTP_PARSER_ERRNO(&parser)));
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fail:
|
|
|
|
|
|
|
|
fclose(file);
|
|
|
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|