Add get_dir_mode
This commit is contained in:
12
src/client.c
12
src/client.c
@ -28,6 +28,16 @@ char *get_webroot(const char *http_host) {
|
||||
return path_is_directory(webroot) ? webroot : NULL;
|
||||
}
|
||||
|
||||
int get_dir_mode(const char *webroot) {
|
||||
char buf[256];
|
||||
struct stat statbuf;
|
||||
sprintf(buf, "%s/.necronda-server/dir_mode_info", webroot);
|
||||
if (stat(buf, &statbuf) == 0) return URI_DIR_MODE_INFO;
|
||||
sprintf(buf, "%s/.necronda-server/dir_mode_list", webroot);
|
||||
if (stat(buf, &statbuf) == 0) return URI_DIR_MODE_LIST;
|
||||
return URI_DIR_MODE_FORBIDDEN;
|
||||
}
|
||||
|
||||
void client_terminate() {
|
||||
server_keep_alive = 0;
|
||||
}
|
||||
@ -122,7 +132,7 @@ int client_request_handler(sock *client, unsigned long client_num, unsigned int
|
||||
goto respond;
|
||||
}
|
||||
|
||||
dir_mode = URI_DIR_MODE_INFO;
|
||||
dir_mode = get_dir_mode(webroot);
|
||||
http_uri uri;
|
||||
ret = uri_init(&uri, webroot, req.uri, dir_mode);
|
||||
if (ret != 0) {
|
||||
|
Reference in New Issue
Block a user