more error handling
This commit is contained in:
parent
d0427725a6
commit
3dc1ab7722
9
main.c
9
main.c
@ -136,7 +136,7 @@ void parse_json(string* s)
|
|||||||
printf("Author(s): %s\n", authors->valuestring);
|
printf("Author(s): %s\n", authors->valuestring);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Year of Publication: %d\n", cJSON_GetObjectItemCaseSensitive(child, "publish_year")->child->valueint);
|
printf("(First) Year of Publication: %d\n", cJSON_GetObjectItemCaseSensitive(child, "first_publish_year")->valueint);
|
||||||
printf("Page length: %d\n", cJSON_GetObjectItemCaseSensitive(child, "number_of_pages_median")->valueint);
|
printf("Page length: %d\n", cJSON_GetObjectItemCaseSensitive(child, "number_of_pages_median")->valueint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,6 +150,13 @@ int main(int argc, char* argv[])
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t input_len = strlen(argv[1]);
|
||||||
|
if (!(13 == input_len || 10 == input_len)) {
|
||||||
|
fprintf(stderr, "Invalid ISBN submitted!");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We must initialize cURL
|
* We must initialize cURL
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user