beans

simple pastebin server
git clone git://git.bitsmanent.org/beans
Log | Files | Refs | LICENSE

commit c6603a0110f8fa52bbc7b967e9039e876785d825
parent 4afe0c3452c5a6c6be1496adc908ce4b4351859a
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Wed,  9 Jan 2019 22:00:34 +0100

Better handling missing base.
Also cleanup some old code.

Diffstat:
Mbeans.c | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/beans.c b/beans.c @@ -104,7 +104,7 @@ main(int argc, char *argv[]) { struct sockaddr_storage conn; socklen_t size; int sd, csd, len, tmpsd; - char tmpfn[64] = {0}, *buf, *p; + char tmpfn[64] = {0}, *buf, *code; ARGBEGIN { case 'd': strncpy(path, EARGF(die("%s: missing path\n", argv0)), sizeof path); break; @@ -137,11 +137,11 @@ main(int argc, char *argv[]) { } if(write(tmpsd, buf, len) == -1) fprintf(stderr, "write(): %s\n", strerror(errno)); - p = strchr(tmpfn, '.'); - if(p && ++p) - sout(csd, "%s/%s\n", base, p); + code = strchr(tmpfn, '.')+1; + if(*base) + sout(csd, "%s%s\n", base, code); else - sout(csd, "Paste error.\n"); + sout(csd, "%s\n", code); close(csd); close(tmpsd); free(buf);