#ifndef LOCATION_H
#define LOCATION_H
#include <cx/string.h>
#include <cx/hash_map.h>
#include <regex.h>
#include "../public/nsapi.h"
#include "../config/serverconfig.h"
#include "config.h"
#include "../util/strreplace.h"
#include "../webdav/webdav.h"
#ifdef __cplusplus
extern "C" {
#endif
#define WS_LOCATION_NMATCH 16
typedef struct WSLocation WSLocation;
typedef struct WSLocationConfig WSLocationConfig;
typedef enum WSLocationMatch {
WS_LOCATION_MATCH_EXACT =
0,
WS_LOCATION_MATCH_PREFIX,
WS_LOCATION_MATCH_CS_REGEX,
WS_LOCATION_MATCH_CI_REGEX
} WSLocationMatch;
struct WSLocationConfig {
regmatch_t match[
WS_LOCATION_NMATCH];
WSBool set_dirindex;
WSBool dirindex;
WSBool set_forcetls;
WSBool forcetls;
cxmutstr name;
cxmutstr vfs;
cxmutstr docroot;
StringTemplate *redirect;
regex_t redirect_match;
int redirect_status;
WebdavRepository *dav;
CxList *acls;
};
struct WSLocation {
WSLocationMatch match;
cxmutstr match_string;
regex_t regex;
WSLocationConfig config;
CxList *rewrite;
CxMap *ext_config;
WSLocation *children_begin;
WSLocation *children_end;
WSLocation *prev;
WSLocation *next;
};
WSLocation* cfg_location_get(ServerConfiguration *cfg, ConfigNode *obj);
int location_apply_config(WSLocationConfig *target, WSLocation *loc);
int location_match(WSLocation *loc, cxstring uri,
regmatch_t *match);
WSLocationConfig* location_match_and_get_config(
pool_handle_t *pool, Request *rq, cxstring uri, WSLocation *loc);
WSLocationConfig* cfg_location_match(Session *sn, Request *rq);
#ifdef __cplusplus
}
#endif
#endif