diff options
| author | Xavier Roche <xroche@users.noreply.github.com> | 2013-08-15 12:40:06 +0000 |
|---|---|---|
| committer | Xavier Roche <xroche@users.noreply.github.com> | 2013-08-15 12:40:06 +0000 |
| commit | ffefedefa9543f9bbdbf7d93a8a66fe4a6b96a2f (patch) | |
| tree | bd98d9743a29ee7a70bf9b17981a1e311212d435 /src/htscoremain.c | |
| parent | 84cdc70b4a00a7a2938ff8f3c782cfd78ab069b8 (diff) | |
Added %a option, allowing to define the "Accept:" header line.
Added %X option, to define additional request header lines.
Cleaned up a bit the messy strcat everywhere in the request section (yuk).
Diffstat (limited to 'src/htscoremain.c')
| -rw-r--r-- | src/htscoremain.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/htscoremain.c b/src/htscoremain.c index b91f54c..2e39d61 100644 --- a/src/htscoremain.c +++ b/src/htscoremain.c @@ -1680,7 +1680,7 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) { } break; // - case 'l': + case 'l': // Accept-language if ((na + 1 >= argc) || (argv[na + 1][0] == '-')) { HTS_PANIC_PRINTF ("Option %l needs to be followed by a blank space, and an ISO language code"); @@ -1698,6 +1698,47 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) { } break; // + case 'a': // Accept + if ((na + 1 >= argc) || (argv[na + 1][0] == '-')) { + HTS_PANIC_PRINTF + ("Option %a needs to be followed by a blank space, and a list of formats"); + printf("Example: -%%a \"text/html,*/*;q=0.1\"\n"); + htsmain_free(); + return -1; + } else { + na++; + if (strlen(argv[na]) >= 256) { + HTS_PANIC_PRINTF("Accept list string too long"); + htsmain_free(); + return -1; + } + StringCat(opt->accept, argv[na]); + } + break; + // + case 'X': // HTTP header line + if ((na + 1 >= argc) || (argv[na + 1][0] == '-')) { + HTS_PANIC_PRINTF + ("Option %X needs to be followed by a blank space, and a raw HTTP header line"); + printf("Example: -%%X \"X-Magic: 42\"\n"); + htsmain_free(); + return -1; + } else { + na++; + if (argv[na][0] == '\0') { + HTS_PANIC_PRINTF("Empty string given"); + htsmain_free(); + return -1; + } else if (strlen(argv[na]) >= 256) { + HTS_PANIC_PRINTF("Header line string too long"); + htsmain_free(); + return -1; + } + StringCat(opt->headers, argv[na]); + StringCat(opt->headers, "\r\n"); /* separator */ + } + break; + // case 'F': // footer id if ((na + 1 >= argc) || (argv[na + 1][0] == '-')) { HTS_PANIC_PRINTF |
