]> diplodocus.org Git - nmh/blob - h/prototypes.h
Fix test for inlineonly.
[nmh] / h / prototypes.h
1
2 /*
3 * prototypes.h -- various prototypes
4 *
5 * If you modify functions here, please document their current behavior
6 * as much as practical.
7 */
8
9 /*
10 * prototype from config.h
11 */
12 char *etcpath(char *);
13
14 /*
15 * prototypes from the nmh subroutine library
16 */
17
18 struct msgs_array;
19
20 void add_profile_entry (const char *, const char *);
21 void adios (char *, char *, ...) NORETURN;
22 void admonish (char *, char *, ...);
23 void advertise (char *, char *, char *, va_list);
24 void advise (char *, char *, ...);
25 char **argsplit (char *, char **, int *);
26 void argsplit_msgarg (struct msgs_array *, char *, char **);
27 void argsplit_insert (struct msgs_array *, char *, char **);
28 void arglist_free (char *, char **);
29 void ambigsw (char *, struct swit *);
30 int atooi(char *);
31 char **brkstring (char *, char *, char *);
32 int check_charset (char *, int);
33 int client(char *, char *, char *, int, int);
34 void closefds(int);
35 char *concat (const char *, ...);
36 int context_del (char *);
37 char *context_find (char *);
38 int context_foil (char *);
39 void context_read (void);
40 void context_replace (char *, char *);
41 void context_save (void);
42 char *copy (const char *, char *);
43 char **copyip (char **, char **, int);
44 void cpydata (int, int, char *, char *);
45 void cpydgst (int, int, char *, char *);
46 char *cpytrim (const char *);
47 int decode_rfc2047 (char *, char *, size_t);
48 void discard (FILE *);
49 char *upcase (const char *);
50
51 /*
52 * Decode two characters into their quoted-printable representation.
53 *
54 * Arguments are:
55 *
56 * byte1 - First character of Q-P representation
57 * byte2 - Second character of Q-P representation
58 *
59 * Returns the decoded value, -1 if the conversion failed.
60 */
61 int decode_qp(unsigned char byte1, unsigned char byte2);
62
63 int default_done (int);
64
65 /*
66 * Encode a message header using RFC 2047 encoding. If the message contains
67 * no non-ASCII characters, then leave the header as-is.
68 *
69 * Arguments include:
70 *
71 * name - Message header name
72 * value - Message header content; must point to allocated memory
73 * (may be changed if encoding is necessary)
74 * encoding - Encoding type. May be one of CE_UNKNOWN (function chooses
75 * the encoding), CE_BASE64 or CE_QUOTED
76 * charset - Charset used for encoding. If NULL, obtain from system
77 * locale.
78 *
79 * Returns 0 on success, any other value on failure.
80 */
81
82 int encode_rfc2047(const char *name, char **value, int encoding,
83 const char *charset);
84
85 void escape_display_name (char *, size_t);
86 void escape_local_part (char *, size_t);
87 int ext_hook(char *, char *, char *);
88 int fdcompare (int, int);
89 int folder_addmsg (struct msgs **, char *, int, int, int, int, char *);
90 int folder_delmsgs (struct msgs *, int, int);
91 void folder_free (struct msgs *);
92 int folder_pack (struct msgs **, int);
93
94 /*
95 * Read a MH folder structure and return an allocated "struct msgs"
96 * corresponding to the contents of the folder.
97 *
98 * Arguments include:
99 *
100 * name - Name of folder
101 * lockflag - If true, write-lock (and keep open) metadata files.
102 * See comments for seq_read() for more information.
103 */
104 struct msgs *folder_read (char *name, int lockflag);
105
106 struct msgs *folder_realloc (struct msgs *, int, int);
107 int gans (char *, struct swit *);
108 char **getans (char *, struct swit *);
109 #ifdef READLINE_SUPPORT
110 char **getans_via_readline (char *, struct swit *);
111 #endif /* READLINE_SUPPORT */
112 int getanswer (char *);
113 char **getarguments (char *, int, char **, int);
114 char *get_charset(void);
115 char *getcpy (const char *);
116 char *get_default_editor(void);
117 char *getfolder(int);
118
119 /*
120 * Get a string from the terminfo database for the current terminal.
121 *
122 * Retrieve the specified terminfo capability and return a string that
123 * can be output to the terminal. The string returned has already been
124 * processed by tputs(), so it is safe to output directly. The return
125 * value of this function is valid until the next call.
126 *
127 * Arguments:
128 *
129 * capability - The name of the terminfo capability (see terminfo(5)).
130 *
131 * Returns a tputs-processed string, or NULL if terminal initialization failed
132 * or the capability wasn't found.
133 */
134 char *get_term_stringcap(char *capability);
135
136 /*
137 * Get a parameterized string from the terminfo database for the current
138 * terminal.
139 *
140 * We don't yet have a standardized tparm() that will take a stdarg
141 * argument. Right now we don't want many parameters, so we only
142 * take two. Everything gets passed to tparm() as-is. If we need
143 * a capability with more arguments, we'll just add more later.
144 *
145 * Arguments:
146 *
147 * capability - The name of the terminfo capability (see terminfo(5)).
148 * arg1..argN - Arguments 1-N.
149 *
150 * Returns a tparm and tputs-processed string, or NULL if there was a problem
151 * initializating the terminal or retrieving the capability.
152 */
153 char *get_term_stringparm(char *capability, long arg1, long arg2);
154
155 /*
156 * Get a number from the terminfo database for the current terminal.
157 *
158 * Retrieve the specified terminfo capability and return the numeric
159 * value of that capability from the terminfo database.
160 *
161 * Arguments:
162 *
163 * capability - The name of the terminfo capability (see terminfo(5)).
164 *
165 * Returns the output of tigetnum() for that capability, or -1 if it was
166 * unable to initialize the terminfo database.
167 */
168 int get_term_numcap(char *capability);
169
170 /*
171 * Lock open/close routines.
172 *
173 * The lk[f]opendata() functions are designed to open "data" files (anything
174 * not a mail spool file) using the locking mechanism configured for data
175 * files. The lk[f]openspool() functions are for opening the mail spool
176 * file, which will use the locking algorithm configured for the mail
177 * spool.
178 *
179 * Files opened for reading are locked with a read lock (if possible by
180 * the underlying lock mechanism), files opened for writing are locked
181 * using an exclusive lock. The int * argument is used to indicate failure
182 * to acquire a lock.
183 */
184 int lkclosedata(int, const char *);
185 int lkclosespool(int, const char *);
186 int lkfclosedata(FILE *, const char *);
187 int lkfclosespool(FILE *, const char *);
188 FILE *lkfopendata(const char *, const char *, int *);
189 int lkopendata(const char *, int, mode_t, int *);
190 FILE *lkfopenspool(const char *, const char *);
191 int lkopenspool(const char *, int, mode_t, int *);
192 int m_atoi (char *);
193 char *m_backup (char *);
194 int m_convert (struct msgs *, char *);
195 char *m_draft (char *, char *, int, int *);
196 void m_eomsbr (m_getfld_state_t, int (*)(int));
197 void m_getfld_state_reset (m_getfld_state_t *);
198 void m_getfld_state_destroy (m_getfld_state_t *);
199 void m_getfld_track_filepos (m_getfld_state_t *, FILE *);
200 int m_getfld (m_getfld_state_t *, char[NAMESZ], char *, int *, FILE *);
201 int m_gmprot (void);
202 char *m_maildir (char *);
203 char *m_mailpath (char *);
204 char *m_name (int);
205 int m_putenv (char *, char *);
206 int m_rand (unsigned char *, size_t);
207 char *m_mktemp(const char *, int *, FILE **);
208 char *m_mktemp2(const char *, const char *, int *, FILE **);
209 char *m_mktemps(const char *pfx, const char *suffix, int *, FILE **);
210 char *get_temp_dir();
211
212 /*
213 * Create a subprocess and redirect our standard output to it.
214 *
215 * Arguments are:
216 *
217 * name - Name of process to create
218 * savestdout - If true, will save the current stdout file descriptor and
219 * m_pclose() will close it at the appropriate time.
220 */
221 void m_popen(char *name, int savestdout);
222
223 /*
224 * Wait for the last process opened by m_popen().
225 */
226 void m_pclose(void);
227
228 void m_unknown(m_getfld_state_t *, FILE *);
229 int makedir (char *);
230 char *message_id (time_t, int);
231
232 /*
233 * Return a MIME content-type string for the specified file.
234 *
235 * If the system supports it, will use the "file" command to determine
236 * the appropriate content-type. Otherwise it will try to determine the
237 * content-type from the suffix. If that fails, the file will be scanned
238 * and either assigned a MIME type of text/plain or application/octet-stream
239 * depending if binary content is present.
240 *
241 * Arguments:
242 *
243 * filename - The name of the file to determine the MIME type of.
244 *
245 * Returns a pointer to a content-type string (which may include MIME
246 * parameters, such as charset). Returns a NULL if it cannot determine
247 * the MIME type of the file. Returns allocated storage that must be
248 * free'd.
249 */
250 char *mime_type(const char *filename);
251
252 /*
253 * Clear the screen, using the appropriate entry from the terminfo database
254 */
255 void nmh_clear_screen(void);
256 char *nmh_getpass(const char *);
257 char *norm_charmap(char *);
258 char *new_fs (char *, char *, char *);
259 char *path(char *, int);
260 int peekc(FILE *ib);
261 int pidwait (pid_t, int);
262 int pidstatus (int, FILE *, char *);
263 char *pluspath(char *);
264 void print_help (char *, struct swit *, int);
265 void print_sw (char *, struct swit *, char *, FILE *);
266 void print_version (char *);
267 void push (void);
268 char *pwd (void);
269 char *r1bindex(char *, int);
270 void readconfig (struct node **, FILE *, char *, int);
271 int refile (char **, char *);
272 void ruserpass (char *, char **, char **);
273 int remdir (char *);
274 void scan_detect_mbox_style (FILE *);
275 void scan_finished ();
276 void scan_eom_action (int (*)());
277 void scan_reset_m_getfld_state ();
278 int seq_addmsg (struct msgs *, char *, int, int, int);
279 int seq_addsel (struct msgs *, char *, int, int);
280 char *seq_bits (struct msgs *);
281 int seq_delmsg (struct msgs *, char *, int);
282 int seq_delsel (struct msgs *, char *, int, int);
283 int seq_getnum (struct msgs *, char *);
284 char *seq_list (struct msgs *, char *);
285 int seq_nameok (char *);
286 void seq_print (struct msgs *, char *);
287 void seq_printall (struct msgs *);
288
289 /*
290 * Read the sequence files for the folder referenced in the given
291 * struct msgs and populate the sequence entries in the struct msgs.
292 *
293 * Arguments:
294 *
295 * mp - Folder structure to add sequence entries to
296 * lockflag - If true, obtain a write lock on the sequence file.
297 * Additionally, the sequence file will remain open
298 * and a pointer to the filehandle will be stored in
299 * folder structure, where it will later be used by
300 * seq_save().
301 *
302 * Return values:
303 * OK - successfully read the sequence files, or they don't exist
304 * NOTOK - failed to lock sequence file
305 */
306 int seq_read (struct msgs * mp, int lockflag);
307 void seq_save (struct msgs *);
308 void seq_setcur (struct msgs *, int);
309 void seq_setprev (struct msgs *);
310 void seq_setunseen (struct msgs *, int);
311 int showfile (char **, char *);
312 int smatch(char *, struct swit *);
313
314 /*
315 * Convert a set of bit flags to printable format.
316 *
317 * Arguments:
318 *
319 * buffer - Buffer to output string to.
320 * size - Size of buffer in bytes. Buffer is always NUL terminated.
321 * flags - Binary flags to output
322 * bitfield - Textual representation of bits to output. This string
323 * is in the following format:
324 *
325 * Option byte 0x01 STRING1 0x02 STRING2 ....
326 *
327 * The first byte is an option byte to snprintb(). Currently the only option
328 * supported is 0x08, which indicates that the flags should be output in
329 * octal format; if the option byte is any other value, the flags will be
330 * output in hexadecimal.
331 *
332 * After the option bytes are series of text strings, prefixed by the number
333 * of the bit they correspond to. For example, the bitfield string:
334 *
335 * "\020\01FLAG1\02FLAG2\03FLAG3\04FLAG4"
336 *
337 * will output the following string if "flags" is set to 0x09:
338 *
339 * 0x2<FLAG1,FLAG4>
340 *
341 * You don't have to use octal in the bitfield string, that's just the
342 * convention currently used by the nmh code. The order of flags in the
343 * bitfield string is not significant, but again, general convention is
344 * from least significant bit to most significant.
345 */
346 char *snprintb (char *buffer, size_t size, unsigned flags, char *bitfield);
347 int ssequal (char *, char *);
348 int stringdex (char *, char *);
349 char *trimcpy (char *);
350 int unputenv (char *);
351
352 /*
353 * Remove quotes and quoted-pair sequences from RFC-5322 atoms.
354 *
355 * Currently the actual algorithm is simpler than it technically should
356 * be: any quotes are simply eaten, unless they're preceded by the escape
357 * character (\). This seems to be sufficient for our needs for now.
358 *
359 * Arguments:
360 *
361 * input - The input string
362 * output - The output string; is assumed to have at least as much
363 * room as the input string. At worst the output string will
364 * be the same size as the input string; it might be smaller.
365 *
366 */
367 void unquote_string(const char *input, char *output);
368 int uprf (char *, char *);
369 int vfgets (FILE *, char **);
370 char *write_charset_8bit (void);
371
372
373 /*
374 * some prototypes for address parsing system
375 * (others are in addrsbr.h)
376 */
377 char *LocalName(int);
378 char *SystemName(void);
379
380 /*
381 * prototypes for some routines in uip
382 */
383 int annotate (char *, char *, char *, int, int, int, int);
384 void annolist(char *, char *, char *, int);
385 void annopreserve(int);
386 void m_pclose(void);
387 int make_intermediates(char *);
388 int mhl(int, char **);
389 int mhlsbr(int, char **, FILE *(*)(char *));
390 int distout (char *, char *, char *);
391 void replout (FILE *, char *, char *, struct msgs *, int,
392 int, char *, char *, char *, int);
393 int sc_length(void);
394 int sc_width(void);
395 int build_form (char *, char *, int *, char *, char *, char *, char *,
396 char *, char *);
397 int sendsbr (char **, int, char *, char *, struct stat *, int);
398 int SOprintf (char *, ...);
399 int what_now (char *, int, int, char *, char *,
400 int, struct msgs *, char *, int, char *, int);
401 int WhatNow(int, char **);
402
403 /*
404 * Copy data from one file to another, converting to base64-encoding.
405 *
406 * Arguments include:
407 *
408 * in - Input filehandle (unencoded data)
409 * out - Output filename (base64-encoded data)
410 * crlf - If set, output encoded CRLF for every LF on input.
411 *
412 * Returns OK on success, NOTOK otherwise.
413 */
414 int writeBase64aux(FILE *in, FILE *out, int crlf);
415
416 int writeBase64 (unsigned char *, size_t, unsigned char *);
417 int writeBase64raw (unsigned char *, size_t, unsigned char *);
418
419 /*
420 * credentials management
421 */
422 void init_credentials_file ();
423 int nmh_get_credentials (char *, char *, int, nmh_creds_t);
424
425 /*
426 * temporary file management
427 */
428 int nmh_init(const char *argv0, int read_context);
429 int m_unlink(const char *);
430 void unregister_for_removal(int remove_files);