Copy cmdline in main rather than in moldentry - sacc - sacc(omys), simple conso… | |
git clone git://bitreich.org/sacc/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65… | |
Log | |
Files | |
Refs | |
Tags | |
LICENSE | |
--- | |
commit 96fd418befb74178138958e4803b35d2fc06c7a9 | |
parent bbbcf8c9652404e8f9b01ff92e9bbeaf8e3a4bb2 | |
Author: Quentin Rameau <[email protected]> | |
Date: Thu, 22 Jun 2017 14:30:53 +0200 | |
Copy cmdline in main rather than in moldentry | |
We would lose raw when fetching the item, and the logic of having | |
connection data inside the parent is preserved | |
Diffstat: | |
M sacc.c | 31 ++++++++++++++++-------------… | |
1 file changed, 16 insertions(+), 15 deletions(-) | |
--- | |
diff --git a/sacc.c b/sacc.c | |
@@ -375,17 +375,15 @@ delve(Item *hole) | |
} | |
Item * | |
-parseurl(const char *URL) | |
+moldentry(char *url) | |
{ | |
- Item *hole; | |
- char *p, *url, *host, *port = "gopher", *gopherpath = "1"; | |
+ Item *entry; | |
+ char *p, *host = url, *port = "gopher", *gopherpath = "1"; | |
int parsed, ipv6; | |
- host = url = xstrdup(URL); | |
- | |
if (p = strstr(url, "://")) { | |
if (strncmp(url, "gopher", p - url)) | |
- die("Protocol not supported: %.*s (%s)", p - url, url,… | |
+ die("Protocol not supported: %.*s", p - url, url); | |
host = p + 3; | |
} | |
@@ -419,20 +417,19 @@ parseurl(const char *URL) | |
} | |
if (*host == '\0' || *port == '\0' || ipv6) | |
- die("Can't parse url: %s", URL); | |
+ die("Can't parse url"); | |
if (gopherpath[0] > '1') | |
- die("Gopher type not supported: %s (%s)", | |
- typedisplay(gopherpath[0]), URL); | |
- | |
+ die("Gopher type not supported: %s", | |
+ typedisplay(gopherpath[0])); | |
entry = xmalloc(sizeof(Item)); | |
- entry->raw = url; | |
entry->type = gopherpath[0]; | |
entry->username = entry->selector = ++gopherpath; | |
entry->host = host; | |
entry->port = port; | |
entry->entry = entry; | |
+ entry->raw = NULL; | |
entry->dir = NULL; | |
return entry; | |
@@ -441,15 +438,19 @@ parseurl(const char *URL) | |
int | |
main(int argc, char *argv[]) | |
{ | |
- Item *hole; | |
+ Item *entry; | |
+ char *url; | |
if (argc != 2) | |
usage(); | |
- hole = parseurl(argv[1]); | |
+ url = xstrdup(argv[1]); | |
+ | |
+ entry = moldentry(url); | |
+ delve(entry); | |
- delve(hole); | |
- free(hole); /* TODO free all tree recursively */ | |
+ free(entry); /* TODO free all tree recursively */ | |
+ free(url); | |
return 0; | |
} |