NeoMutt  2018-07-16 +952-a2da0a
Teaching an old dog new tricks
DOXYGEN
state.c File Reference

Keep track when processing files. More...

#include "config.h"
#include <limits.h>
#include <stdarg.h>
#include <wchar.h>
#include "mutt/mutt.h"
#include "state.h"
#include "globals.h"
+ Include dependency graph for state.c:

Go to the source code of this file.

Functions

void state_mark_attach (struct State *s)
 Write a unique marker around content. More...
 
void state_attach_puts (const char *t, struct State *s)
 Write a string to the state. More...
 
static int state_putwc (wchar_t wc, struct State *s)
 Write a wide character to the state. More...
 
int state_putws (const wchar_t *ws, struct State *s)
 Write a wide string to the state. More...
 
void state_prefix_putc (char c, struct State *s)
 Write a prefixed character to the state. More...
 
int state_printf (struct State *s, const char *fmt,...)
 Write a formatted string to the State. More...
 
void state_prefix_put (const char *buf, size_t buflen, struct State *s)
 Write a prefixed fixed-string to the State. More...
 

Detailed Description

Keep track when processing files.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file state.c.

Function Documentation

void state_mark_attach ( struct State s)

Write a unique marker around content.

Parameters
sState to write to

Definition at line 41 of file state.c.

42 {
43  if (!s || !s->fpout)
44  return;
45  if ((s->flags & MUTT_DISPLAY) && (mutt_str_strcmp(Pager, "builtin") == 0))
47 }
#define MUTT_DISPLAY
output is displayed to the user
Definition: state.h:40
An email being displayed.
Definition: pager.h:63
FILE * fpout
Definition: state.h:34
int flags
Definition: state.h:36
#define state_puts(x, y)
Definition: state.h:51
WHERE char AttachmentMarker[STRING]
Unique ANSI string to mark PGP messages in an email.
Definition: globals.h:45
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:612

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void state_attach_puts ( const char *  t,
struct State s 
)

Write a string to the state.

Parameters
tText to write
sState to write to

Definition at line 54 of file state.c.

55 {
56  if (!t || !s || !s->fpout)
57  return;
58 
59  if (*t != '\n')
61  while (*t)
62  {
63  state_putc(*t, s);
64  if (*t++ == '\n' && *t)
65  if (*t != '\n')
67  }
68 }
FILE * fpout
Definition: state.h:34
#define state_putc(x, y)
Definition: state.h:52
void state_mark_attach(struct State *s)
Write a unique marker around content.
Definition: state.c:41

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int state_putwc ( wchar_t  wc,
struct State s 
)
static

Write a wide character to the state.

Parameters
wcWide character to write
sState to write to
Return values
0Success
-1Error

Definition at line 77 of file state.c.

78 {
79  char mb[MB_LEN_MAX] = "";
80  int rc;
81 
82  rc = wcrtomb(mb, wc, NULL);
83  if (rc < 0)
84  return rc;
85  if (fputs(mb, s->fpout) == EOF)
86  return -1;
87  return 0;
88 }
FILE * fpout
Definition: state.h:34

+ Here is the caller graph for this function:

int state_putws ( const wchar_t *  ws,
struct State s 
)

Write a wide string to the state.

Parameters
wsWide string to write
sState to write to
Return values
0Success
-1Error

Definition at line 97 of file state.c.

98 {
99  const wchar_t *p = ws;
100 
101  while (p && *p != L'\0')
102  {
103  if (state_putwc(*p, s) < 0)
104  return -1;
105  p++;
106  }
107  return 0;
108 }
static int state_putwc(wchar_t wc, struct State *s)
Write a wide character to the state.
Definition: state.c:77

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void state_prefix_putc ( char  c,
struct State s 
)

Write a prefixed character to the state.

Parameters
cCharacter to write
sState to write to

Definition at line 115 of file state.c.

116 {
117  if (s->flags & MUTT_PENDINGPREFIX)
118  {
120  if (s->prefix)
121  state_puts(s->prefix, s);
122  }
123 
124  state_putc(c, s);
125 
126  if (c == '\n')
127  state_set_prefix(s);
128 }
#define state_reset_prefix(s)
Definition: state.h:50
#define state_set_prefix(s)
Definition: state.h:49
#define MUTT_PENDINGPREFIX
prefix to write, but character must follow
Definition: state.h:42
char * prefix
Definition: state.h:35
#define state_putc(x, y)
Definition: state.h:52
int flags
Definition: state.h:36
#define state_puts(x, y)
Definition: state.h:51

+ Here is the caller graph for this function:

int state_printf ( struct State s,
const char *  fmt,
  ... 
)

Write a formatted string to the State.

Parameters
sState to write to
fmtprintf format string
...Arguments to formatting string
Return values
numNumber of characters written

Definition at line 137 of file state.c.

138 {
139  int rc;
140  va_list ap;
141 
142  va_start(ap, fmt);
143  rc = vfprintf(s->fpout, fmt, ap);
144  va_end(ap);
145 
146  return rc;
147 }
FILE * fpout
Definition: state.h:34

+ Here is the caller graph for this function:

void state_prefix_put ( const char *  buf,
size_t  buflen,
struct State s 
)

Write a prefixed fixed-string to the State.

Parameters
bufString to write
buflenLenth of string
sState to write to

Definition at line 155 of file state.c.

156 {
157  if (s->prefix)
158  {
159  while (buflen--)
160  state_prefix_putc(*buf++, s);
161  }
162  else
163  fwrite(buf, buflen, 1, s->fpout);
164 }
char * prefix
Definition: state.h:35
FILE * fpout
Definition: state.h:34
void state_prefix_putc(char c, struct State *s)
Write a prefixed character to the state.
Definition: state.c:115

+ Here is the call graph for this function:

+ Here is the caller graph for this function: