summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2018-02-13 17:54:02 +0200
committerSergey Poznyakoff <gray@gnu.org>2018-02-13 17:54:02 +0200
commita60c099c902411f27e93d7aac2323b99696d1a92 (patch)
treef7812f228cd121714337dfe7dbbe71c9ea25904d
parentef8f3519f2a26877877a315a967b7d953f3e0a33 (diff)
downloadfileserv-a60c099c902411f27e93d7aac2323b99696d1a92.tar.gz
fileserv-a60c099c902411f27e93d7aac2323b99696d1a92.tar.bz2
Bugfixes
-rw-r--r--src/dirconfig.c2
-rw-r--r--src/fileserv.c13
-rw-r--r--src/fileserv.h3
-rw-r--r--src/idx.c23
4 files changed, 22 insertions, 19 deletions
diff --git a/src/dirconfig.c b/src/dirconfig.c
index 0a2a48e..6cf0a37 100644
--- a/src/dirconfig.c
+++ b/src/dirconfig.c
@@ -141,7 +141,6 @@ set_hidden_files(size_t argc, char **argv, DIRCONFIG *conf,
char const *file, int line)
{
size_t i;
- size_t n = 0;
if (argc < 2)
return bad_argc(file, line, argv[0]);
@@ -168,6 +167,7 @@ set_hidden_files(size_t argc, char **argv, DIRCONFIG *conf,
} else
conf->hidden_files_rxc++;
}
+ return 0;
}
struct dirconfig_keyword {
diff --git a/src/fileserv.c b/src/fileserv.c
index 07e947f..8f18b92 100644
--- a/src/fileserv.c
+++ b/src/fileserv.c
@@ -296,6 +296,12 @@ cfname(char const *fname)
}
+static inline int
+errno_to_http_code(int ec)
+{
+ return ec == ENOENT ? MHD_HTTP_NOT_FOUND : MHD_HTTP_FORBIDDEN;
+}
+
static int
find_index_file(char const *dir, DIRCONFIG *conf, char **index_file,
struct stat *pst)
@@ -322,16 +328,11 @@ find_index_file(char const *dir, DIRCONFIG *conf, char **index_file,
*pst = st;
return MHD_HTTP_OK;
}
+ return errno_to_http_code(lasterr);
}
return MHD_HTTP_FORBIDDEN;
}
-static inline int
-errno_to_http_code(int ec)
-{
- return ec == ENOENT ? MHD_HTTP_NOT_FOUND : MHD_HTTP_FORBIDDEN;
-}
-
typedef struct file_resp {
int fd;
char *file_name;
diff --git a/src/fileserv.h b/src/fileserv.h
index ac8058e..95e01b9 100644
--- a/src/fileserv.h
+++ b/src/fileserv.h
@@ -98,3 +98,6 @@ int index_sort_ord_to_arg(INDEX_SORT_ORD c);
int filename_is_special(char const *name);
int filename_is_hidden(char const *name, DIRCONFIG const *conf);
int filename_is_valid(char const *name);
+
+void parse_template_string(char const *str);
+void parse_template_file(char const *file_name);
diff --git a/src/idx.c b/src/idx.c
index d856dfb..096e0ee 100644
--- a/src/idx.c
+++ b/src/idx.c
@@ -9,6 +9,7 @@
#include <dirent.h>
#include <unistd.h>
#include <time.h>
+#include <ctype.h>
#include "fileserv.h"
#include "mimetypes.h"
#include "wordsplit.h"
@@ -70,9 +71,6 @@ new_text_node(int type, char const *start, size_t len)
static INDEX_NODE *
next_text_node(struct template_state *st)
{
- INDEX_NODE *np;
- size_t len;
-
st->start = st->cur;
while (*st->cur) {
if (*st->cur == '{' && st->cur[1] == '%') {
@@ -197,7 +195,7 @@ parse_template(INDEX_NODE_LIST *nodes, struct template_state *st)
STAILQ_INIT(nodes);
- while (np = next_node(st))
+ while ((np = next_node(st)))
STAILQ_INSERT_TAIL(nodes, np, next);
}
@@ -261,14 +259,14 @@ typedef struct idxlist {
STAILQ_HEAD(, idxent) list;
} IDXLIST;
-void
+static void
idxlist_init(IDXLIST *lst)
{
lst->count = 0;
STAILQ_INIT(&lst->list);
}
-void
+static void
idxlist_free(IDXLIST *lst)
{
IDXENT *ent;
@@ -281,7 +279,7 @@ idxlist_free(IDXLIST *lst)
lst->count = 0;
}
-void
+static void
idxlist_append(IDXLIST *lst, IDXENT *ent)
{
STAILQ_INSERT_TAIL(&lst->list, ent, next);
@@ -484,7 +482,9 @@ node_expr_eval(INDEX_NODE *node, EVAL_ENV *env)
}
return 0;
}
-
+
+static int node_list_eval(INDEX_NODE_LIST *nodes, EVAL_ENV *env);
+
static int
node_cond_eval(INDEX_NODE *node, EVAL_ENV *env)
{
@@ -513,7 +513,7 @@ static int (*eval[])(INDEX_NODE *node, EVAL_ENV *env) = {
[NODE_EXPR] = node_expr_eval
};
-int
+static int
node_list_eval(INDEX_NODE_LIST *nodes, EVAL_ENV *env)
{
INDEX_NODE *node;
@@ -574,7 +574,7 @@ exp_filesize(char **ret, EVAL_ENV *env)
}
static int
-exp_filetype(char **ret, EVAL_ENV *env)
+exp_mimetype(char **ret, EVAL_ENV *env)
{
if (env->ent && env->ent->type) {
*ret = xstrdup(env->ent->type);
@@ -607,6 +607,7 @@ static struct var_dcl var_dcl[] = {
{ "FILENAME", exp_filename },
{ "FILESIZE", exp_filesize },
{ "FILETIME", exp_filetime },
+ { "MIMETYPE", exp_mimetype },
{ NULL }
};
@@ -683,8 +684,6 @@ static int
template_command(char **ret, const char *cmd, size_t len, char **argv,
void *clos)
{
- EVAL_ENV *env = clos;
-
if (strcmp(argv[0], "icon") == 0) {
return cmd_icon(ret, argv, clos);
}

Return to:

Send suggestions and report system problems to the System administrator.