Compare commits

..

No commits in common. "5392d6c936d6e7be12b20c71f300beeaea5245f6" and "25d4b373ce5afacc27baf6642ea61ad252e21b07" have entirely different histories.

2 changed files with 5 additions and 12 deletions

View File

@ -5,8 +5,8 @@
#include "include/curl.h"
#define API_URL "https://openlibrary.org/search.json?page=1&q="
#define API_URL_LEN 45
#define API_URL "https://openlibrary.org/search.json?q="
#define API_URL_LEN 38
static void setup_api_link(const char* isbn, char** buf)
{

View File

@ -7,7 +7,6 @@
#include "include/json.h"
struct flags {
char* isbn;
bool json, db, print;
};
@ -18,8 +17,8 @@ const char* argp_program_bug_address = "supernovaa41@gmx.com";
static char doc[] = "Lookup details of a book from the ISBN. Using OpenLibrary API.";
static char args_doc[] = "<ISBN>";
static struct argp_option options[] = {
{"json", 'j', 0, 0, "output to json", 0},
{"db", 'd', 0, 0, "output to sqlite3 database", 0},
{0, 'j', "json", 0, "output to json", 0},
{0, 'd', "db", 0, "output to sqlite3 database", 0},
{0, 'p', 0, 0, "print the full json response", 0},
{0}
};
@ -45,12 +44,7 @@ static error_t parse_opt(int key, char* arg, struct argp_state* state)
case 'p':
flags->print = true;
break;
case ARGP_KEY_ARG:
flags->isbn = arg;
break;
case ARGP_KEY_END:
if (state->arg_num < 1)
argp_usage(state);
break;
default:
return ARGP_ERR_UNKNOWN;
@ -69,8 +63,7 @@ int main(int argc, char* argv[])
init_flags(&flags);
argp_parse(&argp, argc, argv, 0, 0, &flags);
//book_api_call("9780762437818", &resp);
book_api_call(flags.isbn, &resp);
book_api_call("9780762437818", &resp);
if (flags.print)
puts(resp.buf);