Commit adc04460 adc04460a48cfffbfef2a6ee0fe8c66a331e38a4 by Sergey Poznyakoff

Added mu_argp.h and related stuff

1 parent a436f9a9
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
56 #include <mailutils/error.h> 56 #include <mailutils/error.h>
57 57
58 #include <argcv.h> 58 #include <argcv.h>
59 #include <mu_argp.h>
59 60
60 #ifndef INADDR_NONE 61 #ifndef INADDR_NONE
61 # define INADDR_NONE -1 62 # define INADDR_NONE -1
...@@ -71,6 +72,7 @@ extern time_t overflow_delay_time; ...@@ -71,6 +72,7 @@ extern time_t overflow_delay_time;
71 extern int maxlines; 72 extern int maxlines;
72 extern const char *username; 73 extern const char *username;
73 extern char hostname[]; 74 extern char hostname[];
75 extern struct daemon_param daemon_param;
74 76
75 extern void read_config (const char *config_file); 77 extern void read_config (const char *config_file);
76 int acl_match (struct sockaddr_in *sa_in); 78 int acl_match (struct sockaddr_in *sa_in);
......
...@@ -82,6 +82,8 @@ ...@@ -82,6 +82,8 @@
82 #include <mailutils/stream.h> 82 #include <mailutils/stream.h>
83 #include <mailutils/mutil.h> 83 #include <mailutils/mutil.h>
84 84
85 #include <mu_argp.h>
86
85 #ifdef __cplusplus 87 #ifdef __cplusplus
86 extern "C" { 88 extern "C" {
87 #endif 89 #endif
...@@ -104,10 +106,6 @@ struct imap4d_command ...@@ -104,10 +106,6 @@ struct imap4d_command
104 char *tag; 106 char *tag;
105 }; 107 };
106 108
107 /* Daemon modes. */
108 #define INTERACTIVE 0
109 #define DAEMON 1
110
111 /* Global variables and constants*/ 109 /* Global variables and constants*/
112 #define STATE_NONE (0) 110 #define STATE_NONE (0)
113 #define STATE_NONAUTH (1 << 0) 111 #define STATE_NONAUTH (1 << 0)
...@@ -140,14 +138,13 @@ struct imap4d_command ...@@ -140,14 +138,13 @@ struct imap4d_command
140 138
141 extern struct imap4d_command imap4d_command_table[]; 139 extern struct imap4d_command imap4d_command_table[];
142 extern FILE *ofile; 140 extern FILE *ofile;
143 extern unsigned int timeout;
144 extern mailbox_t mbox; 141 extern mailbox_t mbox;
145 extern char *homedir; 142 extern char *homedir;
146 extern char *rootdir; 143 extern char *rootdir;
147 extern char *maildir;
148 extern int state; 144 extern int state;
149 extern volatile size_t children; 145 extern volatile size_t children;
150 extern int is_virtual; 146 extern int is_virtual;
147 extern struct daemon_param daemon_param;
151 148
152 #ifndef HAVE_STRTOK_R 149 #ifndef HAVE_STRTOK_R
153 extern char *strtok_r __P((char *s, const char *delim, char **save_ptr)); 150 extern char *strtok_r __P((char *s, const char *delim, char **save_ptr));
......
...@@ -386,7 +386,7 @@ imap4d_readline (FILE *fp) ...@@ -386,7 +386,7 @@ imap4d_readline (FILE *fp)
386 line[0] = '\0'; /* start with a empty string. */ 386 line[0] = '\0'; /* start with a empty string. */
387 do 387 do
388 { 388 {
389 alarm (timeout); 389 alarm (daemon_param.timeout);
390 if (fgets (buffer, sizeof (buffer), fp) == NULL) 390 if (fgets (buffer, sizeof (buffer), fp) == NULL)
391 { 391 {
392 imap4d_bye (ERR_NO_OFILE); /* Logout. */ 392 imap4d_bye (ERR_NO_OFILE); /* Logout. */
......
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
72 #include <mailutils/stream.h> 72 #include <mailutils/stream.h>
73 #include <mailutils/mutil.h> 73 #include <mailutils/mutil.h>
74 #include <mu_dbm.h> 74 #include <mu_dbm.h>
75 #include <mu_argp.h>
75 76
76 #ifdef HAVE_MYSQL 77 #ifdef HAVE_MYSQL
77 # include "../MySql/MySql.h" 78 # include "../MySql/MySql.h"
......
...@@ -136,7 +136,7 @@ pop3d_readline (FILE *fp) ...@@ -136,7 +136,7 @@ pop3d_readline (FILE *fp)
136 static char buffer[512]; 136 static char buffer[512];
137 char *ptr; 137 char *ptr;
138 138
139 alarm (timeout); 139 alarm (daemon_param.timeout);
140 ptr = fgets (buffer, sizeof (buffer), fp); 140 ptr = fgets (buffer, sizeof (buffer), fp);
141 alarm (0); 141 alarm (0);
142 142
......
...@@ -117,6 +117,8 @@ ...@@ -117,6 +117,8 @@
117 #include <mailutils/error.h> 117 #include <mailutils/error.h>
118 #include <mailutils/mutil.h> 118 #include <mailutils/mutil.h>
119 119
120 #include <mu_argp.h>
121
120 /* For Berkley DB2 APOP password file */ 122 /* For Berkley DB2 APOP password file */
121 #ifdef HAVE_DB_H 123 #ifdef HAVE_DB_H
122 #include <db.h> 124 #include <db.h>
...@@ -141,9 +143,6 @@ ...@@ -141,9 +143,6 @@
141 #define TRANSACTION 1 143 #define TRANSACTION 1
142 #define UPDATE 2 144 #define UPDATE 2
143 145
144 #define INTERACTIVE 0
145 #define DAEMON 1
146
147 #define OK 0 146 #define OK 0
148 #define ERR_WRONG_STATE 1 147 #define ERR_WRONG_STATE 1
149 #define ERR_BAD_ARGS 2 148 #define ERR_BAD_ARGS 2
...@@ -171,7 +170,6 @@ ...@@ -171,7 +170,6 @@
171 #endif /* __P */ 170 #endif /* __P */
172 171
173 extern mailbox_t mbox; 172 extern mailbox_t mbox;
174 extern unsigned int timeout;
175 extern int state; 173 extern int state;
176 extern char *username; 174 extern char *username;
177 extern char *maildir; 175 extern char *maildir;
...@@ -179,6 +177,7 @@ extern FILE *ifile; ...@@ -179,6 +177,7 @@ extern FILE *ifile;
179 extern FILE *ofile; 177 extern FILE *ofile;
180 extern char *md5shared; 178 extern char *md5shared;
181 extern volatile size_t children; 179 extern volatile size_t children;
180 extern struct daemon_param daemon_param;
182 181
183 extern int pop3d_abquit __P ((int)); 182 extern int pop3d_abquit __P ((int));
184 extern int pop3d_apop __P ((const char *)); 183 extern int pop3d_apop __P ((const char *));
......