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