commit 2c3810687f0c8b7c14897618c5a3147f949df408 from: Omar Polo date: Sat Jul 01 18:41:46 2023 UTC change log_request to take the code and meta unpacked don't know what i was smoking when I wrote log_request() like that... commit - 2247b66842be7049e4dbfe099781bd3d2f69fbe9 commit + 2c3810687f0c8b7c14897618c5a3147f949df408 blob - 57a02afd9009e99d9b20a7a6c7287a07c1a2bfe3 blob + d80bc112e38dbb325de8ba8dad6c380c656c5a98 --- ge.c +++ ge.c @@ -40,7 +40,7 @@ static const struct option opts[] = { }; void -log_request(struct client *c, char *meta, size_t l) +log_request(struct client *c, int code, const char *meta) { char b[GEMINI_URL_LEN]; const char *t; @@ -70,11 +70,8 @@ log_request(struct client *c, char *meta, size_t l) strlcpy(b, t, sizeof(b)); } - if ((t = memchr(meta, '\r', l)) == NULL) - t = meta + l; - - fprintf(stderr, "%s:%s GET %s %.*s\n", c->rhost, c->rserv, b, - (int)(t-meta), meta); + fprintf(stderr, "%s:%s GET %s %d %s\n", c->rhost, c->rserv, b, + code, meta); } void blob - b59c5a9a341e938df94e506abdd52f42331ce864 blob + 663de426bfd7c13107510938e06c320df759965f --- gmid.c +++ gmid.c @@ -81,7 +81,7 @@ usage(void) /* used by the server process, defined here so gg can provide its own impl. */ void -log_request(struct client *c, char *meta, size_t l) +log_request(struct client *c, int code, const char *meta) { struct conf *conf = c->conf; char b[GEMINI_URL_LEN]; @@ -114,11 +114,8 @@ log_request(struct client *c, char *meta, size_t l) strlcpy(b, t, sizeof(b)); } - if ((t = memchr(meta, '\r', l)) == NULL) - t = meta + l; - - ec = asprintf(&fmted, "%s:%s GET %s %.*s", c->rhost, c->rserv, b, - (int)(t-meta), meta); + ec = asprintf(&fmted, "%s:%s GET %s %d %s", c->rhost, c->rserv, b, + code, meta); if (ec == -1) fatal("asprintf"); blob - 770deeae94340a541a8e2827b2574e8d371488e2 blob + 7ba92d68ca2c29df6d2390e6d3c8270835461222 --- gmid.h +++ gmid.h @@ -365,7 +365,7 @@ char *data_dir(void); void load_local_cert(struct vhost*, const char*, const char*); /* gmid.c / ge.c */ -void log_request(struct client *, char *, size_t); +void log_request(struct client *, int, const char *); /* config.c */ struct conf *config_new(void); blob - 235aa6e28e3656f661ed14b31162f73db13211bd blob + d63f3022c0606dd3e98e113372f6962200c9ec9d --- server.c +++ server.c @@ -1167,8 +1167,7 @@ start_reply(struct client *c, int code, const char *me bufferevent_write(c->bev, "\r\n", 2); if (!vhost_disable_log(c->host, c->iri.path)) - log_request(c, (char *)EVBUFFER_DATA(evb), - EVBUFFER_LENGTH(evb)); + log_request(c, code, meta); if (code != 20) c->type = REQUEST_DONE;