aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2023-07-01 18:41:46 +0000
committerOmar Polo <op@omarpolo.com>2023-07-01 18:41:46 +0000
commit2c3810687f0c8b7c14897618c5a3147f949df408 (patch)
tree0c1a806a390a78088f0cd8625e30bd61d71c8e80
parent2247b66842be7049e4dbfe099781bd3d2f69fbe9 (diff)
change log_request to take the code and meta unpacked
don't know what i was smoking when I wrote log_request() like that...
-rw-r--r--ge.c9
-rw-r--r--gmid.c9
-rw-r--r--gmid.h2
-rw-r--r--server.c3
4 files changed, 8 insertions, 15 deletions
diff --git a/ge.c b/ge.c
index 57a02af..d80bc11 100644
--- a/ge.c
+++ b/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
diff --git a/gmid.c b/gmid.c
index b59c5a9..663de42 100644
--- a/gmid.c
+++ b/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");
diff --git a/gmid.h b/gmid.h
index 770deea..7ba92d6 100644
--- a/gmid.h
+++ b/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);
diff --git a/server.c b/server.c
index 235aa6e..d63f302 100644
--- a/server.c
+++ b/server.c
@@ -1167,8 +1167,7 @@ start_reply(struct client *c, int code, const char *meta)
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;