summaryrefslogtreecommitdiff
path: root/src/fileserv.h
blob: 95021440bd95306d6c22b3ba26391040bd08a830 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* This file is part of fileserv.
   Copyright (C) 2017 Sergey Poznyakoff

   Fileserv is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   Fileserv is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with fileserv.  If not, see <http://www.gnu.org/licenses/>. */
#include <sys/types.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <stdarg.h>

#ifndef SIZE_T_MAX
# define SIZE_T_MAX ((size_t)-1)
#endif

extern char *progname;
extern char *pidfile;

void error(char const *fmt, ...);
void info(char const *fmt, ...);
void syslog_enable(void);
void set_log_facility(char const *arg);

void fileserv_logger(void *arg, const char *fmt, va_list ap);

void xmalloc_fail(void);
void *xmalloc(size_t s);
void *xcalloc(size_t nmemb, size_t size);
void *xrealloc(void *ptr, size_t size);
char *xstrdup(char const *str);

void runas(char const *runas_user, char const *runas_group);

#if HAVE_LIBWRAP
int fileserv_acl(void *cls, const struct sockaddr *addr, socklen_t addrlen);
#else
# define fileserv_acl NULL
#endif

void pidfile_remove(void);
void pidfile_create(void);
void pidfile_check(void);

typedef struct fileserv_dirconfig {
	int follow:1;            /* Follow symbolic links */
	int listing:1;           /* Show directory listing, if a directory
				    is requested and no index file exists */
	int list_unreadable:1;   /* List unreadable files */
	char **index_files;      /* Names of index files */
} DIRCONFIG;

#define DIRCONFIG_INITIALIZER { 0, 0, 1, NULL }

DIRCONFIG *dirconfig(char const *path, size_t prefix_len);
void dirconfig_parse(const char *file, DIRCONFIG *conf);
DIRCONFIG *dirconfig_init(void);
void dirconfig_free(DIRCONFIG *conf);

char *catfile_n(char const *dir, size_t len, char const *file);
char *catfile(char const *dir, char const *file);

Return to:

Send suggestions and report system problems to the System administrator.