support of rule, useful for sub domain remapping

This commit is contained in:
Xuan Sang LE
2018-02-04 19:46:47 +01:00
parent 01c32d964e
commit ff3c68ff64
5 changed files with 123 additions and 51 deletions

View File

@ -3,7 +3,7 @@
void set_status(int client,int code,const char* msg)
{
response(client, __s("HTTP/1.0 %d %s", code, msg));
response(client, __s("HTTP/1.1 %d %s", code, msg));
response(client, __s("Server: %s ", SERVER_NAME));
}
void redirect(int client,const char*path)

View File

@ -193,11 +193,11 @@ int is_bin(const char* file)
int match_int(const char* search)
{
return regex_match("^[-+]?[0-9]+$",search);
return regex_match("^[-+]?[0-9]+$",search,0, NULL);
}
int match_float(const char* search)
{
return regex_match("^[+-]?[0-9]*\\.[0-9]+$",search);
return regex_match("^[+-]?[0-9]*\\.[0-9]+$",search,0,NULL);
}
/*
regmatch_t matches[MAX_MATCHES];
@ -206,7 +206,7 @@ if (regexec(&exp, sz, MAX_MATCHES, matches, 0) == 0) {
printf("group1: %s\n", buff);
}
*/
int regex_match(const char* expr,const char* search)
int regex_match(const char* expr,const char* search, int msize, regmatch_t* matches)
{
regex_t regex;
int reti;
@ -220,7 +220,7 @@ int regex_match(const char* expr,const char* search)
}
/* Execute regular expression */
reti = regexec(&regex, search, 0, NULL, 0);
reti = regexec(&regex, search, msize, matches, 0);
if( !reti ){
//LOG("Match");
ret = 1;

View File

@ -84,7 +84,7 @@ char* mime(const char*);
int is_bin(const char*);
int match_int(const char*);
int match_float(const char*);
int regex_match(const char*,const char*);
int regex_match(const char*,const char*, int, regmatch_t*);
char *url_decode(const char *str);
char *url_encode(const char *str);
char from_hex(char ch);