]> diplodocus.org Git - nmh/blob - h/prototypes.h
529842c07cfa6996659299488c9d795f09650574
[nmh] / h / prototypes.h
1 /* prototypes.h -- various prototypes
2 *
3 * If you modify functions here, please document their current behavior
4 * as much as practical.
5 */
6
7 /*
8 * prototype from config.h
9 */
10 char *etcpath(char *) NONNULL(1);
11
12 /*
13 * prototypes from the nmh subroutine library
14 */
15
16 struct msgs_array;
17
18 char *concat (const char *, ...) ENDNULL;
19
20 /*
21 * Print null-terminated PROMPT to and flush standard output. Read answers from
22 * standard input until one matches an entry in SWITCHES. When one matches,
23 * return its swret field. Return 0 on EOF.
24 */
25 int read_switch(const char *PROMPT, const struct swit *SWITCHES);
26
27 /*
28 * If standard input is not a tty, return 1 without printing anything. Else,
29 * print null-terminated PROMPT to and flush standard output. Read answers from
30 * standard input until one is "yes" or "no", returning 1 for "yes" and 0 for
31 * "no". Also return 0 on EOF.
32 */
33 int read_yes_or_no_if_tty(const char *PROMPT);
34
35 /*
36 * Print null-terminated PROMPT to and flush standard output. Read multi-word
37 * answers from standard input until a first word matches an entry in SWITCHES.
38 * When one matches, return a pointer to an array of pointers to the words.
39 * Return NULL on EOF, interrupt, or other error.
40 */
41 char **read_switch_multiword(const char *PROMPT, const struct swit *SWITCHES);
42
43 /*
44 * Same as read_switch_multiword but using readline(3) for input.
45 */
46 #ifdef READLINE_SUPPORT
47 char **read_switch_multiword_via_readline (char *, struct swit *);
48 #endif /* READLINE_SUPPORT */
49
50 char **getarguments (char *, int, char **, int);
51
52 m_getfld_state_t m_getfld_state_init(FILE *iob);
53 void m_getfld_state_reset (m_getfld_state_t *);
54 void m_getfld_state_destroy (m_getfld_state_t *);
55 void m_getfld_track_filepos (m_getfld_state_t *, FILE *);
56 void m_getfld_track_filepos2(m_getfld_state_t *);
57 int m_getfld (m_getfld_state_t *, char[NAMESZ], char *, int *, FILE *);
58 int m_getfld2(m_getfld_state_t *, char[NAMESZ], char *, int *);
59 int m_gmprot (void) PURE;
60 char *m_name (int);
61
62 void m_unknown(m_getfld_state_t *, FILE *);
63 void m_unknown2(m_getfld_state_t *);
64
65 char *nmh_getpass(const char *);
66 int pidwait (pid_t, int);
67 char *r1bindex(char *, int) PURE;
68 int refile (char **, char *);
69
70 /*
71 * Read our credentials file and (optionally) ask the user for anything
72 * missing.
73 *
74 * Arguments:
75 *
76 * host - Hostname (to scan credentials file)
77 * aname - Pointer to filled-in username
78 * apass - Pointer to filled-in password
79 * flags - One or more of RUSERPASS_NO_PROMPT_USER,
80 * RUSERPASS_NO_PROMPT_PASSWORD
81 */
82 void ruserpass (const char *host, char **aname, char **apass, int flags);
83 #define RUSERPASS_NO_PROMPT_USER 0x01
84 #define RUSERPASS_NO_PROMPT_PASSWORD 0x02
85
86 int remdir (char *);
87 void scan_detect_mbox_style (FILE *);
88 void scan_finished(void);
89
90 /*
91 * Read the sequence files for the folder referenced in the given
92 * struct msgs and populate the sequence entries in the struct msgs.
93 *
94 * Arguments:
95 *
96 * mp - Folder structure to add sequence entries to
97 * lockflag - If true, obtain a write lock on the sequence file.
98 * Additionally, the sequence file will remain open
99 * and a pointer to the filehandle will be stored in
100 * folder structure, where it will later be used by
101 * seq_save().
102 *
103 * Return values:
104 * OK - successfully read the sequence files, or they don't exist
105 * NOTOK - failed to lock sequence file
106 */
107 int seq_read (struct msgs * mp, int lockflag);
108 void seq_save (struct msgs *);
109 void seq_setcur (struct msgs *, int);
110 void seq_setprev (struct msgs *);
111 void seq_setunseen (struct msgs *, int);
112 int showfile (char **, char *);
113 int smatch(const char *, const struct swit *) PURE;
114
115 /*
116 * Convert a set of bit flags to printable format.
117 *
118 * Arguments:
119 *
120 * buffer - Buffer to output string to.
121 * size - Size of buffer in bytes. Buffer is always NUL terminated.
122 * flags - Binary flags to output
123 * bitfield - Textual representation of bits to output. This string
124 * is in the following format:
125 *
126 * Option byte 0x01 STRING1 0x02 STRING2 ....
127 *
128 * The first byte is an option byte to snprintb(). Currently the only option
129 * supported is 0x08, which indicates that the flags should be output in
130 * octal format; if the option byte is any other value, the flags will be
131 * output in hexadecimal.
132 *
133 * After the option bytes are series of text strings, prefixed by the number
134 * of the bit they correspond to. For example, the bitfield string:
135 *
136 * "\020\01FLAG1\02FLAG2\03FLAG3\04FLAG4"
137 *
138 * will output the following string if "flags" is set to 0x09:
139 *
140 * 0x2<FLAG1,FLAG4>
141 *
142 * You don't have to use octal in the bitfield string, that's just the
143 * convention currently used by the nmh code. The order of flags in the
144 * bitfield string is not significant, but again, general convention is
145 * from least significant bit to most significant.
146 */
147 char *snprintb (char *buffer, size_t size, unsigned flags, char *bitfield);
148
149 /*
150 * prototypes for some routines in uip
151 */
152 int annotate (char *, char *, char *, bool, bool, int, bool);
153 void annolist(char *, char *, char *, int);
154 void annopreserve(int);
155 int mhl(int, char **);
156 int mhlsbr(int, char **, FILE *(*)(char *));
157 int distout (char *, char *, char *);
158 int sendsbr (char **, int, char *, char *, struct stat *, int, const char *);
159 int what_now (char *, int, int, char *, char *,
160 int, struct msgs *, char *, int, char *, int);
161 int WhatNow(int, char **) NORETURN;