mirror of
https://github.com/ksherlock/gopher.git
synced 2025-08-12 03:25:03 +00:00
outfile parsing.
This commit is contained in:
24
gopher.c
24
gopher.c
@@ -268,6 +268,7 @@ int do_gopher(const char *url, URLComponents *components)
|
|||||||
|
|
||||||
host = URLComponentGetCMalloc(url, components, URLComponentHost);
|
host = URLComponentGetCMalloc(url, components, URLComponentHost);
|
||||||
path = URLComponentGetCMalloc(url, components, URLComponentPath);
|
path = URLComponentGetCMalloc(url, components, URLComponentPath);
|
||||||
|
|
||||||
if (!host)
|
if (!host)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "URL `%s': no host.", url);
|
fprintf(stderr, "URL `%s': no host.", url);
|
||||||
@@ -294,22 +295,12 @@ int do_gopher(const char *url, URLComponents *components)
|
|||||||
|
|
||||||
if (flags._O)
|
if (flags._O)
|
||||||
{
|
{
|
||||||
if (!path)
|
if (path)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "-O flag cannot be used with this URL.\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
filename = strrchr(path + 2, '/');
|
filename = strrchr(path + 2, '/');
|
||||||
if (filename) // *filename == '/'
|
if (filename) // *filename == '/'
|
||||||
{
|
{
|
||||||
filename++;
|
filename++;
|
||||||
if (!filename[0])
|
|
||||||
{
|
|
||||||
// path/ ?
|
|
||||||
fprintf(stderr, "-O flag cannot be used with this URL.\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -317,6 +308,17 @@ int do_gopher(const char *url, URLComponents *components)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!filename || !filename[0])
|
||||||
|
{
|
||||||
|
// path/ ?
|
||||||
|
fprintf(stderr, "-O flag cannot be used with this URL.\n");
|
||||||
|
free(host);
|
||||||
|
free(path);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (filename)
|
if (filename)
|
||||||
{
|
{
|
||||||
file = fopen(filename, "w");
|
file = fopen(filename, "w");
|
||||||
|
Reference in New Issue
Block a user