holy crap there is some old cruft in here I have to rewrite!
[citadel.git] / citadel / modules / network / serv_netmail.c
1 /*
2  * This module handles network mail and mailing list processing.
3  *
4  * Copyright (c) 2000-2021 by the citadel.org team
5  *
6  * This program is open source software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License, version 3.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * ** NOTE **   A word on the S_NETCONFIGS semaphore:
15  * This is a fairly high-level type of critical section.  It ensures that no
16  * two threads work on the netconfigs files at the same time.  Since we do
17  * so many things inside these, here are the rules:
18  *  1. begin_critical_section(S_NETCONFIGS) *before* begin_ any others.
19  *  2. Do *not* perform any I/O with the client during these sections.
20  *
21  */
22
23 /*
24  * Duration of time (in seconds) after which pending list subscribe/unsubscribe
25  * requests that have not been confirmed will be deleted.
26  */
27 #define EXP     259200  /* three days */
28
29 #include "sysdep.h"
30 #include <stdlib.h>
31 #include <unistd.h>
32 #include <stdio.h>
33 #include <fcntl.h>
34 #include <ctype.h>
35 #include <signal.h>
36 #include <pwd.h>
37 #include <errno.h>
38 #include <sys/stat.h>
39 #include <sys/types.h>
40 #include <dirent.h>
41 #include <time.h>
42 #ifdef HAVE_SYSCALL_H
43 # include <syscall.h>
44 #else
45 # if HAVE_SYS_SYSCALL_H
46 #  include <sys/syscall.h>
47 # endif
48 #endif
49
50 #include <sys/wait.h>
51 #include <string.h>
52 #include <limits.h>
53 #include <libcitadel.h>
54 #include "citadel.h"
55 #include "server.h"
56 #include "citserver.h"
57 #include "support.h"
58 #include "config.h"
59 #include "user_ops.h"
60 #include "database.h"
61 #include "msgbase.h"
62 #include "internet_addressing.h"
63 #include "serv_network.h"
64 #include "clientsocket.h"
65 #include "citadel_dirs.h"
66 #include "threads.h"
67 #include "context.h"
68 #include "ctdl_module.h"
69 #include "netspool.h"
70 #include "netmail.h"