commit d98ef734940a49d192d87024e60559b38eb190c9 from: Omar Polo date: Tue Aug 08 15:56:27 2023 UTC move strip_path to utils.c commit - 877b479bcc183e71a6d78cb938548c21ed4303fc commit + d98ef734940a49d192d87024e60559b38eb190c9 blob - 2006513c58a833e6e08a5e597e0b432216de8d8a blob + c05699cf193546f14fedc1b192dee252469e2987 --- gmid.h +++ gmid.h @@ -453,6 +453,7 @@ int puny_decode(const char*, char*, size_t, const ch /* utils.c */ void block_signals(void); void unblock_signals(void); +const char *strip_path(const char *, int); int starts_with(const char*, const char*); int ends_with(const char*, const char*); ssize_t filesize(int); blob - 0fcb49a8d31f2ed33209798266d57cf5a067a44d blob + 4678e3fd586300578164b8eaf40b9d8192dcb6dc --- server.c +++ server.c @@ -53,7 +53,6 @@ void tls_config_use_fake_private_key(struct tls_config static inline int matches(const char*, const char*); static void handle_handshake(int, short, void*); -static const char *strip_path(const char*, int); static void fmtbuf(char *, size_t, const char *, struct client *, const char *); static int apply_block_return(struct client*); @@ -430,23 +429,6 @@ handle_handshake(int fd, short ev, void *d) err: start_reply(c, BAD_REQUEST, "Wrong/malformed host or missing SNI"); -} - -static const char * -strip_path(const char *path, int strip) -{ - char *t; - - while (strip > 0) { - if ((t = strchr(path, '/')) == NULL) { - path = strchr(path, '\0'); - break; - } - path = t; - strip--; - } - - return path; } static void blob - 2a9d4a4cfc0e314f6aa3c51ce2ac5a02e706bab8 blob + a968159ae4eae4677fb35f8dbe4668fad41e712f --- utils.c +++ utils.c @@ -29,6 +29,23 @@ #include "log.h" +const char * +strip_path(const char *path, int strip) +{ + char *t; + + while (strip > 0) { + if ((t = strchr(path, '/')) == NULL) { + path = strchr(path, '\0'); + break; + } + path = t; + strip--; + } + + return path; +} + int starts_with(const char *str, const char *prefix) {