]> diplodocus.org Git - nmh/blob - h/utils.h
3a428193fb50618b4973fee1d68fd86dfeee2734
[nmh] / h / utils.h
1
2 /*
3 * utils.h -- utility prototypes
4 */
5
6 /* Call malloc(3), exiting on NULL return. */
7 void *mh_xmalloc(size_t);
8
9 void *mh_xrealloc(void *, size_t);
10 void *mh_xcalloc(size_t, size_t);
11 char *pwd(void);
12 char *add(const char *, char *);
13 char *addlist(char *, const char *);
14 int folder_exists(const char *);
15 void create_folder(char *, int, void (*)(int));
16 int num_digits(int);
17
18 /*
19 * A vector of char array, used to hold a list of string message numbers
20 * or command arguments.
21 */
22
23 struct msgs_array {
24 int max, size;
25 char **msgs;
26 };
27
28 /*
29 * Same as msgs_array, but for a vector of ints
30 */
31
32 struct msgnum_array {
33 int max, size;
34 int *msgnums;
35 };
36
37 /*
38 * Add a argument to the given msgs_array or msgnum_array structure; extend
39 * the array size if necessary
40 */
41
42 void app_msgarg(struct msgs_array *, char *);
43 void app_msgnum(struct msgnum_array *, int);
44
45 int open_form(char **, char *);
46 char *find_str (const char [], size_t, const char *);
47 char *rfind_str (const char [], size_t, const char *);
48 char *nmh_strcasestr (const char *, const char *);
49
50 /*
51 * See if a string contains 8 bit characters (use isascii() for the test).
52 * Arguments include:
53 *
54 * start - Pointer to start of string to test.
55 * end - End of string to test (test will stop before reaching
56 * this point). If NULL, continue until reaching '\0'.
57 *
58 * This function always stops at '\0' regardless of the value of 'end'.
59 * Returns 1 if the string contains an 8-bit character, 0 if it does not.
60 */
61 int contains8bit(const char *start, const char *end);
62
63 /*
64 * See if file has any 8-bit bytes.
65 * Arguments include:
66 *
67 * fd - file descriptor
68 * eightbit - address of result, will be set to 1 if the file contains
69 * any 8-bit bytes, 0 otherwise.
70 *
71 * Returns OK on success, NOTOK on read failure.
72 *
73 */
74 int scan_input (int fd, int *eightbit);
75
76
77 /*
78 * Compares prior version of nmh with current version. Returns 1
79 * if they compare the be the same, 0 if not.
80 *
81 * older - 0 for difference comparison, 1 for only if older
82 */
83 int nmh_version_changed (int older);