mirror of https://github.com/omar-polo/gmid.git
add ends_with
This commit is contained in:
parent
d1ca3911d2
commit
f77a8c867e
18
gmid.c
18
gmid.c
|
@ -162,6 +162,24 @@ starts_with(const char *str, const char *prefix)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ends_with(const char *str, const char *sufx)
|
||||||
|
{
|
||||||
|
size_t i, j;
|
||||||
|
|
||||||
|
i = strlen(str);
|
||||||
|
j = strlen(sufx);
|
||||||
|
|
||||||
|
if (j > i)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
i -= j;
|
||||||
|
for (j = 0; str[i] != '\0'; i++, j++)
|
||||||
|
if (str[i] != sufx[j])
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
filesize(int fd)
|
filesize(int fd)
|
||||||
{
|
{
|
||||||
|
|
1
gmid.h
1
gmid.h
|
@ -150,6 +150,7 @@ void log_request(struct client*, char*, size_t);
|
||||||
|
|
||||||
void sig_handler(int);
|
void sig_handler(int);
|
||||||
int starts_with(const char*, const char*);
|
int starts_with(const char*, const char*);
|
||||||
|
int ends_with(const char*, const char*);
|
||||||
ssize_t filesize(int);
|
ssize_t filesize(int);
|
||||||
char *absolutify_path(const char*);
|
char *absolutify_path(const char*);
|
||||||
void yyerror(const char*);
|
void yyerror(const char*);
|
||||||
|
|
Loading…
Reference in New Issue