]>
diplodocus.org Git - nmh/blob - h/prototypes.h
80d0cb6bf838107e837c2d1b2cd9c2ba443cbe7c
1 /* prototypes.h -- various prototypes
3 * If you modify functions here, please document their current behavior
4 * as much as practical.
8 * prototype from config.h
10 char *etcpath(char *) NONNULL(1);
13 * prototypes from the nmh subroutine library
18 void add_profile_entry (const char *, const char *);
19 char **brkstring (char *, char *, char *) NONNULL(1);
22 * Check to see if we can display a given character set natively.
25 * str - Name of character set to check against
26 * len - Length of "str"
28 * Returns 1 if the specified character set can be displayed natively,
32 int check_charset (char *, int);
33 int client(char *, char *, char *, int, int);
35 char *concat (const char *, ...) ENDNULL
;
36 int context_del (char *);
37 char *context_find (const char *) PURE
;
38 char *context_find_by_type (const char *, const char *, const char *);
39 int context_find_prefix(const char *) PURE
;
40 int context_foil (char *);
41 void context_read (void);
42 void context_replace (char *, char *);
43 void context_save (void);
44 char **copyip (char **, char **, int);
45 void cpydata (int, int, const char *, const char *);
46 void cpydgst (int, int, char *, char *);
47 char *cpytrim (const char *);
49 int decode_rfc2047 (char *, char *, size_t);
50 void discard (FILE *);
53 * Decode two characters into their quoted-printable representation.
57 * byte1 - First character of Q-P representation
58 * byte2 - Second character of Q-P representation
60 * Returns the decoded value, -1 if the conversion failed.
62 int decode_qp(unsigned char byte1
, unsigned char byte2
) CONST
;
65 * Encode a message header using RFC 2047 encoding. If the message contains
66 * no non-ASCII characters, then leave the header as-is.
70 * name - Message header name
71 * value - Message header content; must point to allocated memory
72 * (may be changed if encoding is necessary)
73 * encoding - Encoding type. May be one of CE_UNKNOWN (function chooses
74 * the encoding), CE_BASE64 or CE_QUOTED
75 * charset - Charset used for encoding. If NULL, obtain from system
78 * Returns 0 on success, any other value on failure.
81 int encode_rfc2047(const char *name
, char **value
, int encoding
,
84 void escape_display_name (char *, size_t);
85 void escape_local_part (char *, size_t);
86 int ext_hook(char *, char *, char *);
87 int fdcompare (int, int);
88 int folder_addmsg (struct msgs
**, char *, int, int, int, int, char *);
89 int folder_delmsgs (struct msgs
*, int, int);
90 void folder_free (struct msgs
*);
91 int folder_pack (struct msgs
**, int);
94 * Read a MH folder structure and return an allocated "struct msgs"
95 * corresponding to the contents of the folder.
99 * name - Name of folder
100 * lockflag - If true, write-lock (and keep open) metadata files.
101 * See comments for seq_read() for more information.
103 struct msgs
*folder_read (char *name
, int lockflag
);
105 struct msgs
*folder_realloc (struct msgs
*, int, int);
108 * Print null-terminated PROMPT to and flush standard output. Read answers from
109 * standard input until one matches an entry in SWITCHES. When one matches,
110 * return its swret field. Return 0 on EOF.
112 int read_switch(const char *PROMPT
, const struct swit
*SWITCHES
);
115 * If standard input is not a tty, return 1 without printing anything. Else,
116 * print null-terminated PROMPT to and flush standard output. Read answers from
117 * standard input until one is "yes" or "no", returning 1 for "yes" and 0 for
118 * "no". Also return 0 on EOF.
120 int read_yes_or_no_if_tty(const char *PROMPT
);
123 * Print null-terminated PROMPT to and flush standard output. Read multi-word
124 * answers from standard input until a first word matches an entry in SWITCHES.
125 * When one matches, return a pointer to an array of pointers to the words.
126 * Return NULL on EOF, interrupt, or other error.
128 char **read_switch_multiword(const char *PROMPT
, const struct swit
*SWITCHES
);
131 * Same as read_switch_multiword but using readline(3) for input.
133 #ifdef READLINE_SUPPORT
134 char **read_switch_multiword_via_readline (char *, struct swit
*);
135 #endif /* READLINE_SUPPORT */
137 char **getarguments (char *, int, char **, int);
140 * Returns the MIME character set indicated by the current locale setting.
141 * Should be used by routines that want to convert to/from the local
142 * character set, or if you want to check to see if you can display content
143 * in the local character set.
145 char *get_charset(void);
147 /* Return malloc'd copy of str, or of "" if NULL, exit on failure. */
148 char *getcpy(const char *str
);
150 char *get_default_editor(void);
151 char *getfolder(int) PURE
;
153 int m_atoi (char *) PURE
;
154 char *m_backup (const char *);
155 int m_convert (struct msgs
*, char *);
156 char *m_draft (char *, char *, int, int *);
158 m_getfld_state_t
m_getfld_state_init(FILE *iob
);
159 void m_getfld_state_reset (m_getfld_state_t
*);
160 void m_getfld_state_destroy (m_getfld_state_t
*);
161 void m_getfld_track_filepos (m_getfld_state_t
*, FILE *);
162 void m_getfld_track_filepos2(m_getfld_state_t
*);
163 int m_getfld (m_getfld_state_t
*, char[NAMESZ
], char *, int *, FILE *);
164 int m_getfld2(m_getfld_state_t
*, char[NAMESZ
], char *, int *);
165 int m_gmprot (void) PURE
;
168 void m_unknown(m_getfld_state_t
*, FILE *);
169 void m_unknown2(m_getfld_state_t
*);
171 char *nmh_getpass(const char *);
172 int pidwait (pid_t
, int);
173 char *r1bindex(char *, int) PURE
;
174 void readconfig (struct node
**, FILE *, const char *, int);
175 int refile (char **, char *);
178 * Read our credentials file and (optionally) ask the user for anything
183 * host - Hostname (to scan credentials file)
184 * aname - Pointer to filled-in username
185 * apass - Pointer to filled-in password
186 * flags - One or more of RUSERPASS_NO_PROMPT_USER,
187 * RUSERPASS_NO_PROMPT_PASSWORD
189 void ruserpass (const char *host
, char **aname
, char **apass
, int flags
);
190 #define RUSERPASS_NO_PROMPT_USER 0x01
191 #define RUSERPASS_NO_PROMPT_PASSWORD 0x02
194 void scan_detect_mbox_style (FILE *);
195 void scan_finished(void);
198 * Read the sequence files for the folder referenced in the given
199 * struct msgs and populate the sequence entries in the struct msgs.
203 * mp - Folder structure to add sequence entries to
204 * lockflag - If true, obtain a write lock on the sequence file.
205 * Additionally, the sequence file will remain open
206 * and a pointer to the filehandle will be stored in
207 * folder structure, where it will later be used by
211 * OK - successfully read the sequence files, or they don't exist
212 * NOTOK - failed to lock sequence file
214 int 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(const char *, const struct swit
*) PURE
;
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 (const char *, const char *) PURE
;
256 int stringdex (char *, char *) PURE
;
257 char *trimcpy (char *);
259 int uprf (const char *, const char *) PURE
;
260 int vfgets (FILE *, char **);
263 * Output the local character set name, but make sure it is suitable for
266 char *write_charset_8bit (void);
270 * prototypes for some routines in uip
272 int annotate (char *, char *, char *, bool, bool, int, bool);
273 void annolist(char *, char *, char *, int);
274 void annopreserve(int);
275 int mhl(int, char **);
276 int mhlsbr(int, char **, FILE *(*)(char *));
277 int distout (char *, char *, char *);
278 int sendsbr (char **, int, char *, char *, struct stat
*, int, const char *);
279 int what_now (char *, int, int, char *, char *,
280 int, struct msgs
*, char *, int, char *, int);
281 int WhatNow(int, char **) NORETURN
;
284 * credentials management
286 void init_credentials_file(void);
289 * Allocate and return a credentials structure. The credentials structure
290 * is now opaque; you need to use accessors to get inside of it. The
291 * accessors will only prompt the user for missing fields if they are
296 * host - Hostname we're connecting to (used to search credentials file)
297 * user - Username we are logging in as; can be NULL.
299 * Returns NULL on error, otherwise an allocated nmh_creds structure.
301 nmh_creds_t
nmh_get_credentials (const char *host
, const char *user
);
304 * Retrieve the user from a nmh_creds structure. May prompt the user
305 * if one is not defined.
309 * creds - Structure from previous nmh_get_credentials() call
311 * Returns NULL on error, otherwise a NUL-terminated string containing
312 * the username. Points to allocated memory in the credentials structure
313 * that is free()d by nmh_free_credentials().
315 const char *nmh_cred_get_user(nmh_creds_t creds
);
318 * Retrieve the password from an nmh_creds structure. Otherwise identical
319 * to nmh_cred_get_user().
321 const char *nmh_cred_get_password(nmh_creds_t creds
);
324 * Free an allocated nmh_creds structure.
326 void nmh_credentials_free(nmh_creds_t creds
);