1 /** 2 * @file 3 * Keep track when processing files 4 * 5 * @authors 6 * Copyright (C) 2017 Richard Russon <rich@flatcap.org> 7 * 8 * @copyright 9 * This program is free software: you can redistribute it and/or modify it under 10 * the terms of the GNU General Public License as published by the Free Software 11 * Foundation, either version 2 of the License, or (at your option) any later 12 * version. 13 * 14 * This program is distributed in the hope that it will be useful, but WITHOUT 15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 * details. 18 * 19 * You should have received a copy of the GNU General Public License along with 20 * this program. If not, see <http://www.gnu.org/licenses/>. 21 */ 22 23 #ifndef MUTT_STATE_H 24 #define MUTT_STATE_H 25 26 #include <stdint.h> 27 #include <stdio.h> 28 #include <wchar.h> 29 30 typedef uint8_t StateFlags; ///< Flags for State->flags, e.g. #MUTT_DISPLAY 31 #define MUTT_STATE_NO_FLAGS 0 ///< No flags are set 32 #define MUTT_DISPLAY (1 << 0) ///< Output is displayed to the user 33 #define MUTT_VERIFY (1 << 1) ///< Perform signature verification 34 #define MUTT_PENDINGPREFIX (1 << 2) ///< Prefix to write, but character must follow 35 #define MUTT_WEED (1 << 3) ///< Weed headers even when not in display mode 36 #define MUTT_CHARCONV (1 << 4) ///< Do character set conversions 37 #define MUTT_PRINTING (1 << 5) ///< Are we printing? - MUTT_DISPLAY "light" 38 #define MUTT_REPLYING (1 << 6) ///< Are we replying? 39 #define MUTT_FIRSTDONE (1 << 7) ///< The first attachment has been done 40 41 /** 42 * struct State - Keep track when processing files 43 */ 44 struct State 45 { 46 FILE *fp_in; ///< File to read from 47 FILE *fp_out; ///< File to write to 48 char *prefix; ///< String to add to the beginning of each output line 49 StateFlags flags; ///< Flags, e.g. #MUTT_DISPLAY 50 int wraplen; ///< Width to wrap lines to (when flags & #MUTT_DISPLAY) 51 }; 52 53 #define state_set_prefix(state) ((state)->flags |= MUTT_PENDINGPREFIX) 54 #define state_reset_prefix(state) ((state)->flags &= ~MUTT_PENDINGPREFIX) 55 #define state_puts(STATE, STR) fputs(STR, (STATE)->fp_out) 56 #define state_putc(STATE, STR) fputc(STR, (STATE)->fp_out) 57 58 void state_attach_puts (struct State *s, const char *t); 59 void state_mark_attach (struct State *s); 60 void state_mark_protected_header(struct State *s); 61 void state_prefix_put (struct State *s, const char *buf, size_t buflen); 62 void state_prefix_putc (struct State *s, char c); 63 int state_printf (struct State *s, const char *fmt, ...); 64 int state_putws (struct State *s, const wchar_t *ws); 65 66 const char *state_attachment_marker(void); 67 const char *state_protected_header_marker(void); 68 69 #endif /* MUTT_STATE_H */ 70