]>
diplodocus.org Git - nmh/blob - h/prototypes.h
3 * prototypes.h -- various prototypes
5 * If you modify functions here, please document their current behavior
6 * as much as practical.
10 * prototype from config.h
12 char *etcpath(char *);
15 * prototypes from the nmh subroutine library
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
*);
31 char **brkstring (char *, char *, char *);
32 int check_charset (char *, int);
33 int client(char *, char *, char *, int, 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 int default_done (int);
52 * Encode a message header using RFC 2047 encoding. If the message contains
53 * no non-ASCII characters, then leave the header as-is.
57 * name - Message header name
58 * value - Message header content; must point to allocated memory
59 * (may be changed if encoding is necessary)
60 * encoding - Encoding type. May be one of CE_UNKNOWN (function chooses
61 * the encoding), CE_BASE64 or CE_QUOTED
62 * charset - Charset used for encoding. If NULL, obtain from system
65 * Returns 0 on success, any other value on failure.
68 int encode_rfc2047(const char *name
, char **value
, int encoding
,
71 void escape_display_name (char *, size_t);
72 void escape_local_part (char *, size_t);
73 int ext_hook(char *, char *, char *);
74 int fdcompare (int, int);
75 int folder_addmsg (struct msgs
**, char *, int, int, int, int, char *);
76 int folder_delmsgs (struct msgs
*, int, int);
77 void folder_free (struct msgs
*);
78 int folder_pack (struct msgs
**, int);
81 * Read a MH folder structure and return an allocated "struct msgs"
82 * corresponding to the contents of the folder.
86 * name - Name of folder
87 * lockflag - If true, write-lock (and keep open) metadata files.
88 * See comments for seq_read() for more information.
90 struct msgs
*folder_read (char *name
, int lockflag
);
92 struct msgs
*folder_realloc (struct msgs
*, int, int);
93 int gans (char *, struct swit
*);
94 char **getans (char *, struct swit
*);
95 #ifdef READLINE_SUPPORT
96 char **getans_via_readline (char *, struct swit
*);
97 #endif /* READLINE_SUPPORT */
98 int getanswer (char *);
99 char **getarguments (char *, int, char **, int);
100 char *get_charset(void);
101 char *getcpy (const char *);
102 char *get_default_editor(void);
103 char *getfolder(int);
106 * Get a string from the terminfo database for the current terminal.
108 * Retrieve the specified terminfo capability and return a string that
109 * can be output to the terminal. The string returned has already been
110 * processed by tputs(), so it is safe to output directly. The return
111 * value of this function is valid until the next call.
115 * capability - The name of a terminfo capability (see terminfo(5)).
117 * Returns a tputs-processed string, or NULL if terminal initialization failed
118 * or the capability wasn't found.
120 char *get_term_stringcap(char *capability
);
123 * Lock open/close routines.
125 * The lk[f]opendata() functions are designed to open "data" files (anything
126 * not a mail spool file) using the locking mechanism configured for data
127 * files. The lk[f]openspool() functions are for opening the mail spool
128 * file, which will use the locking algorithm configured for the mail
131 * Files opened for reading are locked with a read lock (if possible by
132 * the underlying lock mechanism), files opened for writing are locked
133 * using an exclusive lock.
135 int lkclosedata(int, const char *);
136 int lkclosespool(int, const char *);
137 int lkfclosedata(FILE *, const char *);
138 int lkfclosespool(FILE *, const char *);
139 FILE *lkfopendata(const char *, const char *);
140 int lkopendata(const char *, int, mode_t
);
141 FILE *lkfopenspool(const char *, const char *);
142 int lkopenspool(const char *, int, mode_t
);
144 char *m_backup (char *);
145 int m_convert (struct msgs
*, char *);
146 char *m_draft (char *, char *, int, int *);
147 void m_eomsbr (m_getfld_state_t
, int (*)(int));
148 void m_getfld_state_reset (m_getfld_state_t
*);
149 void m_getfld_state_destroy (m_getfld_state_t
*);
150 void m_getfld_track_filepos (m_getfld_state_t
*, FILE *);
151 int m_getfld (m_getfld_state_t
*, char[NAMESZ
], char *, int *, FILE *);
153 char *m_maildir (char *);
154 char *m_mailpath (char *);
156 int m_putenv (char *, char *);
157 int m_rand (unsigned char *, size_t);
158 char *m_mktemp(const char *, int *, FILE **);
159 char *m_mktemp2(const char *, const char *, int *, FILE **);
160 void m_unknown(m_getfld_state_t
*, FILE *);
161 int makedir (char *);
162 char *message_id (time_t, int);
165 * Clear the screen, using the appropriate entry from the terminfo database
167 void nmh_clear_screen(void);
168 char *nmh_getpass(const char *);
169 char *norm_charmap(char *);
170 char *new_fs (char *, char *, char *);
171 char *path(char *, int);
173 int pidwait (pid_t
, int);
174 int pidstatus (int, FILE *, char *);
175 char *pluspath(char *);
176 void print_help (char *, struct swit
*, int);
177 void print_sw (char *, struct swit
*, char *, FILE *);
178 void print_version (char *);
181 char *r1bindex(char *, int);
182 void readconfig (struct node
**, FILE *, char *, int);
183 int refile (char **, char *);
184 void ruserpass (char *, char **, char **);
186 void scan_detect_mbox_style (FILE *);
187 void scan_finished ();
188 void scan_eom_action (int (*)());
189 void scan_reset_m_getfld_state ();
190 int seq_addmsg (struct msgs
*, char *, int, int, int);
191 int seq_addsel (struct msgs
*, char *, int, int);
192 char *seq_bits (struct msgs
*);
193 int seq_delmsg (struct msgs
*, char *, int);
194 int seq_delsel (struct msgs
*, char *, int, int);
195 int seq_getnum (struct msgs
*, char *);
196 char *seq_list (struct msgs
*, char *);
197 int seq_nameok (char *);
198 void seq_print (struct msgs
*, char *);
199 void seq_printall (struct msgs
*);
202 * Read the sequence files for the folder referenced in the given
203 * struct msgs and populate the sequence entries in the struct msgs.
207 * mp - Folder structure to add sequence entries to
208 * lockflag - If true, obtain a write lock on the sequence file.
209 * Additionally, the sequence file will remain open
210 * and a pointer to the filehandle will be stored in
211 * folder structure, where it will later be used by
214 void seq_read (struct msgs
* mp
, int lockflag
);
215 void seq_save (struct msgs
*);
216 void seq_setcur (struct msgs
*, int);
217 void seq_setprev (struct msgs
*);
218 void seq_setunseen (struct msgs
*, int);
219 int showfile (char **, char *);
220 int smatch(char *, struct swit
*);
223 * Convert a set of bit flags to printable format.
227 * buffer - Buffer to output string to.
228 * size - Size of buffer in bytes. Buffer is always NUL terminated.
229 * flags - Binary flags to output
230 * bitfield - Textual representation of bits to output. This string
231 * is in the following format:
233 * Option byte 0x01 STRING1 0x02 STRING2 ....
235 * The first byte is an option byte to snprintb(). Currently the only option
236 * supported is 0x08, which indicates that the flags should be output in
237 * octal format; if the option byte is any other value, the flags will be
238 * output in hexadecimal.
240 * After the option bytes are series of text strings, prefixed by the number
241 * of the bit they correspond to. For example, the bitfield string:
243 * "\020\01FLAG1\02FLAG2\03FLAG3\04FLAG4"
245 * will output the following string if "flags" is set to 0x09:
249 * You don't have to use octal in the bitfield string, that's just the
250 * convention currently used by the nmh code. The order of flags in the
251 * bitfield string is not significant, but again, general convention is
252 * from least significant bit to most significant.
254 char *snprintb (char *buffer
, size_t size
, unsigned flags
, char *bitfield
);
255 int ssequal (char *, char *);
256 int stringdex (char *, char *);
257 char *trimcpy (char *);
258 int unputenv (char *);
261 * Remove quotes and quoted-pair sequences from RFC-5322 atoms.
263 * Currently the actual algorithm is simpler than it technically should
264 * be: any quotes are simply eaten, unless they're preceded by the escape
265 * character (\). This seems to be sufficient for our needs for now.
269 * input - The input string
270 * output - The output string; is assumed to have at least as much
271 * room as the input string. At worst the output string will
272 * be the same size as the input string; it might be smaller.
275 void unquote_string(const char *input
, char *output
);
276 int uprf (char *, char *);
277 int vfgets (FILE *, char **);
278 char *write_charset_8bit (void);
282 * some prototypes for address parsing system
283 * (others are in addrsbr.h)
285 char *LocalName(int);
286 char *SystemName(void);
289 * prototypes for some routines in uip
291 int annotate (char *, char *, char *, int, int, int, int);
292 void annolist(char *, char *, char *, int);
293 void annopreserve(int);
295 int make_intermediates(char *);
296 int mhl(int, char **);
297 int mhlsbr(int, char **, FILE *(*)(char *));
298 int distout (char *, char *, char *);
299 void replout (FILE *, char *, char *, struct msgs
*, int,
300 int, char *, char *, char *, int);
303 int build_form (char *, char *, int *, char *, char *, char *, char *,
305 int sendsbr (char **, int, char *, char *, struct stat
*, int, char *, int);
306 int SOprintf (char *, ...);
307 int what_now (char *, int, int, char *, char *,
308 int, struct msgs
*, char *, int, char *, int);
309 int WhatNow(int, char **);
310 int writeBase64aux(FILE *, FILE *);
311 int writeBase64 (unsigned char *, size_t, unsigned char *);
312 int writeBase64raw (unsigned char *, size_t, unsigned char *);
315 * credentials management
317 void init_credentials_file ();
318 int nmh_get_credentials (char *, char *, int, nmh_creds_t
);