mirror of https://github.com/omar-polo/gmid.git
move strip_path to utils.c
This commit is contained in:
parent
877b479bcc
commit
d98ef73494
1
gmid.h
1
gmid.h
|
@ -453,6 +453,7 @@ int puny_decode(const char*, char*, size_t, const char**);
|
|||
/* 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);
|
||||
|
|
18
server.c
18
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*);
|
||||
|
@ -432,23 +431,6 @@ 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
|
||||
fmtbuf(char *buf, size_t buflen, const char *fmt, struct client *c,
|
||||
const char *path)
|
||||
|
|
17
utils.c
17
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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue