simplifications.
/* the following code is shared between printing and piping */
-static int _mutt_pipe_message (HEADER * h, char *cmd,
- int decode, int print, int split, char *sep)
+static int _mutt_pipe_message(HEADER * h, char *cmd, int decode, int print,
+ int split, const char *sep)
{
int i, rc = 0;
void mutt_display_address (ENVELOPE * env)
{
- char *pfx = NULL;
+ const char *pfx = NULL;
char buf[SHORT_STRING];
ADDRESS *adr = NULL;
- adr = mutt_get_address (env, &pfx);
+ adr = mutt_get_address(env, &pfx);
if (!adr)
return;
/* print the current time to avoid spoofing of the signature output */
-void crypt_current_time (STATE * s, char *app_name)
+void crypt_current_time (STATE * s, const char *app_name)
{
time_t t;
char p[STRING], tmp[STRING];
* SLcurses_waddnstr() can't take a "const char *", so this is only
* declared "static" (sigh)
*/
-static char *EditorHelp = N_("\
+static const char *EditorHelp = N_("\
~~ insert a line begining with a single ~\n\
~b users add users to the Bcc: field\n\
~c users add users to the Cc: field\n\
static void enriched_puts (const char *s, struct enriched_state *stte)
{
- char *c;
+ const char *p;
if (stte->buff_len < stte->buff_used + str_len (s)) {
stte->buff_len += LONG_STRING;
mem_realloc (&stte->buffer, stte->buff_len + 1);
}
- c = s;
- while (*c) {
- stte->buffer[stte->buff_used++] = *c;
- c++;
+
+ p = s;
+ while (*p) {
+ stte->buffer[stte->buff_used++] = *p++;
}
}
if (istext) {
if (s->flags & M_CHARCONV) {
- char *charset = mutt_get_parameter ("charset", b->parameter);
+ const char *charset = mutt_get_parameter ("charset", b->parameter);
if (!option (OPTSTRICTMIME) && !charset)
charset = mutt_get_first_charset (AssumedCharset);
* data data to associate with `key'
* allow_dup if nonzero, duplicate keys are allowed in the table
*/
-int hash_insert (HASH * table, const char *key, const void *data, int allow_dup)
+int hash_insert (HASH * table, const char *key, void *data, int allow_dup)
{
struct hash_elem *ptr;
int h;
HASH *hash_create (int nelem);
int hash_string (const unsigned char *s, int n);
-int hash_insert (HASH * table, const char *key, const void *data, int allow_dup);
+int hash_insert (HASH * table, const char *key, void *data, int allow_dup);
HASH *hash_resize (HASH * table, int nelem);
void *hash_find_hash (const HASH * table, int hash, const char *key);
void hash_delete_hash (HASH * table, int hash, const char *key,
* return 1. Otherwise, simply return 0.
*/
static int
-check_for_mailing_list (ADDRESS * adr, char *pfx, char *buf, int buflen)
+check_for_mailing_list (ADDRESS * adr, const char *pfx, char *buf, int buflen)
{
for (; adr; adr = adr->next) {
if (mutt_is_subscribed_list (adr)) {
{
char t[_POSIX_PATH_MAX];
char buf[SHORT_STRING];
- char *desc;
+ const char *desc;
FILE *f;
struct binding_t *funcs;
h->cur = h->last; /* reset to the last entry */
}
-char *mutt_history_next (history_class_t hclass)
+const char *mutt_history_next (history_class_t hclass)
{
int next;
struct history *h = &History[hclass];
return (h->hist[h->cur] ? h->hist[h->cur] : "");
}
-char *mutt_history_prev (history_class_t hclass)
+const char *mutt_history_prev (history_class_t hclass)
{
int prev;
struct history *h = &History[hclass];
void mutt_init_history (void);
void mutt_history_add (history_class_t, const char *);
-char *mutt_history_next (history_class_t);
-char *mutt_history_prev (history_class_t);
+const char *mutt_history_next (history_class_t);
+const char *mutt_history_prev (history_class_t);
#endif
static void num_to_string (char* dst, size_t dstlen,
struct option_t* option) {
/* XXX puke */
- const char* fmt = (str_cmp (option->option, "umask") == 0) ?
+ const char* fmt = (str_cmp (option->option, "umask") == 0) ?
"%s=%04o" : "%s=%d";
snprintf (dst, dstlen, fmt, option->option,
*((short*) option->data));
* if name starts with $folder, just strip it to keep hierarchy
* $folder=imap://host, path=imap://host/inbox/b -> inbox/b
*/
- if (Maildirlength > 0 && str_ncmp (CurrentFolder, Maildir,
- Maildirlength) == 0 &&
+ if (Maildirlength > 0 && str_ncmp (CurrentFolder, Maildir,
+ Maildirlength) == 0 &&
str_len (CurrentFolder) > Maildirlength) {
val = CurrentFolder + Maildirlength;
if (Maildir[strlen(Maildir)-1]!='/')
static void sort_to_string (char* dst, size_t dstlen,
struct option_t* option) {
const struct mapping_t *map = get_sortmap (option);
- char* p = NULL;
+ const char *p = NULL;
if (!map) {
snprintf (dst, sizeof (dst), "%s=unknown", option->option);
return;
}
- p = mutt_getnamebyvalue (*((short *) option->data) & SORT_MASK,
- map);
+ p = mutt_getnamebyvalue(*((short *)option->data) & SORT_MASK, map);
snprintf (dst, dstlen, "%s=%s%s%s", option->option,
(*((short *) option->data) & SORT_REVERSE) ?
if (!buf->data || *buf->data == '\0')
continue;
-
+
a = mem_malloc(sizeof(ATTACH_MATCH));
-
+
/* some cheap hacks that I expect to remove */
if (!str_casecmp(buf->data, "any"))
a->major = str_dup("*/.*");
a->major = str_dup("cheap_hack/this_should_never_match");
else
a->major = str_dup(buf->data);
-
+
if ((p = strchr(a->major, '/'))) {
*p = '\0';
++p;
tmpminor[0] = '^';
tmpminor[len+1] = '$';
tmpminor[len+2] = '\0';
-
+
a->major_int = mutt_check_mime_type(a->major);
regcomp(&a->minor_rx, tmpminor, REG_ICASE|REG_EXTENDED);
-
+
mem_free (&tmpminor);
debug_print (5, ("parse_attach_list: added %s/%s [%d]\n",
do {
mutt_extract_token (buf, s, 0);
-
+
if (!str_casecmp(buf->data, "any"))
tmp = str_dup("*/.*");
else if (!str_casecmp(buf->data, "none"))
tmp = str_dup("cheap_hack/this_should_never_match");
else
tmp = str_dup(buf->data);
-
+
if ((minor = strchr(tmp, '/'))) {
*minor = '\0';
++minor;
minor = "unknown";
}
major = mutt_check_mime_type(tmp);
-
+
/* We must do our own walk here because remove_from_list() will only
* remove the LIST->data, not anything pointed to by the LIST->data. */
lastp = NULL;
a->major, a->minor, a->major_int));
regfree(&a->minor_rx);
mem_free(&a->major);
-
+
/* Relink backward */
if (lastp)
lastp->next = lp->next;
else
*ldata = lp->next;
-
+
newlp = lp->next;
mem_free(&lp->data); /* same as a */
mem_free(&lp);
lp = newlp;
continue;
}
-
+
lastp = lp;
lp = lp->next;
}
}
while (MoreArgs (s));
-
+
mem_free (&tmp);
_attachments_clean();
return 0;
((ATTACH_MATCH *)lp->data)->minor);
lp = lp->next;
}
-
+
return 0;
}
static int parse_attachments (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) {
char op, *category;
LIST **listp;
-
+
mutt_extract_token(buf, s, 0);
if (!buf->data || *buf->data == '\0') {
strfcpy(err->data, _("attachments: no disposition"), err->dsize);
return -1;
}
-
+
category = buf->data;
op = *category++;
-
+
if (op == '?') {
mutt_endwin (NULL);
fflush (stdout);
strfcpy(err->data, _("attachments: invalid disposition"), err->dsize);
return -1;
}
-
+
return parse_attach_list(buf, s, listp, err);
}
static int parse_unattachments (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) {
char op, *p;
LIST **listp;
-
+
mutt_extract_token(buf, s, 0);
if (!buf->data || *buf->data == '\0') {
strfcpy(err->data, _("unattachments: no disposition"), err->dsize);
return -1;
}
-
+
p = buf->data;
op = *p++;
if (op != '+' && op != '-') {
strfcpy(err->data, _("unattachments: invalid disposition"), err->dsize);
return -1;
}
-
+
return parse_unattach_list(buf, s, listp, err);
}
mutt_extract_token (tmp, s, M_TOKEN_EQUAL);
/* resolve synonyms */
- if ((option = hash_find (ConfigOptions, tmp->data)) != NULL &&
+ if ((option = hash_find (ConfigOptions, tmp->data)) != NULL &&
DTYPE (option->type == DT_SYN)) {
struct option_t* newopt = hash_find (ConfigOptions, (char*) option->data);
syn_add (newopt, option);
#define NUMVARS (sizeof (MuttVars)/sizeof (MuttVars[0]))
#define NUMCOMMANDS (sizeof (Commands)/sizeof (Commands[0]))
-/* initial string that starts completion. No telling how much crap
+/* initial string that starts completion. No telling how much crap
* the user has typed so far. Allocate LONG_STRING just to be sure! */
char User_typed[LONG_STRING] = { 0 };
int Num_matched = 0; /* Number of matches for completion */
char Completed[STRING] = { 0 }; /* completed string (command or variable) */
-char *Matches[MAX (NUMVARS, NUMCOMMANDS) + 1]; /* all the matches + User_typed */
+const char *Matches[MAX (NUMVARS, NUMCOMMANDS) + 1]; /* all the matches + User_typed */
/* helper function for completion. Changes the dest buffer if
necessary/possible to aid completion.
snprintf (tmp, sizeof (tmp), "%d", (*((short *) option->data)));
else if (DTYPE (option->type) == DT_SORT) {
const struct mapping_t *map;
- char *p;
+ const char *p;
switch (option->type & DT_SUBTYPE_MASK) {
case DT_SORT_ALIAS:
map = SortMethods;
break;
}
- p =
- mutt_getnamebyvalue (*((short *) option->data) & SORT_MASK,
- map);
- snprintf (tmp, sizeof (tmp), "%s%s%s",
- (*((short *) option->data) & SORT_REVERSE) ?
- "reverse-" : "",
- (*((short *) option->data) & SORT_LAST) ? "last-" :
- "", p);
- }
+ p = mutt_getnamebyvalue(*((short *) option->data) & SORT_MASK, map);
+ snprintf(tmp, sizeof (tmp), "%s%s%s",
+ (*((short *)option->data) & SORT_REVERSE) ? "reverse-" : "",
+ (*((short *)option->data) & SORT_LAST) ? "last-" : "", p);
+ }
else if (DTYPE (option->type) == DT_MAGIC) {
const char *p;
switch (DefaultMagic) {
err.data = error;
err.dsize = sizeof (error);
- /* use 3*sizeof(muttvars) instead of 2*sizeof()
+ /* use 3*sizeof(muttvars) instead of 2*sizeof()
* to have some room for $user_ vars */
ConfigOptions = hash_create (sizeof (MuttVars) * 3);
for (i = 0; MuttVars[i].option; i++) {
DT_SYS, 0), 0);
}
- /*
+ /*
* XXX - use something even more difficult to predict?
*/
snprintf (AttachmentMarker, sizeof (AttachmentMarker),
if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r"))) {
buffer[0] = '\0';
fgets (buffer, sizeof (buffer), f);
- p = (char*)&buffer;
+ p = buffer;
SKIPWS (p);
- q = p;
+ q = (char*)p;
while (*q && !isspace(*q))
q++;
*q = '\0';
/*
- *
+ *
* BIG FAT WARNING
- *
+ *
* When changing the code which looks for a configuration file,
* please also change the corresponding code in muttbug.sh.in.
- *
- *
+ *
+ *
*/
return -1;
}
-static int parsekeys (char *str, keycode_t * d, int max)
+static int parsekeys (const char *str, keycode_t * d, int max)
{
int n, len = max;
char buff[SHORT_STRING];
return OP_NULL;
}
-static char *get_func (struct binding_t *bindings, int op)
+static const char *get_func (struct binding_t *bindings, int op)
{
int i;
char *km_keyname (int c)
{
static char buf[10];
- char *p;
+ const char *p;
if ((p = mutt_getnamebyvalue (c, KeyNames)))
return p;
/*-- crypt.c --*/
/* Print the current time. */
-void crypt_current_time (STATE * s, char *app_name);
+void crypt_current_time (STATE * s, const char *app_name);
/* Check out the type of encryption used and set the cached status
values if there are any. */
sasldata->saslconn = saslconn;
/* get ssf so we know whether we have to (en|de)code read/write */
- sasl_getprop (saslconn, SASL_SSF, (const void **) &sasldata->ssf);
+ sasl_getprop (saslconn, SASL_SSF, (const void **)(void *)&sasldata->ssf);
debug_print (3, ("SASL protection strength: %u\n", *sasldata->ssf));
/* Add SASL SSF to transport SSF */
conn->ssf += *sasldata->ssf;
sasl_getprop (saslconn, SASL_MAXOUTBUF,
- (const void **) &sasldata->pbufsize);
+ (const void **)(void *)&sasldata->pbufsize);
debug_print (3, ("SASL protection buffer size: %u\n", *sasldata->pbufsize));
/* clear input buffer */
if (option (OPTPGPCHECKTRUST) &&
(!pgp_id_is_valid (KeyTable[menu->current])
|| !pgp_id_is_strong (KeyTable[menu->current]))) {
- char *s = "";
+ const char *s = "";
char buff[LONG_STRING];
if (KeyTable[menu->current]->flags & KEYFLAG_CANTUSE)
int op;
int i, j;
- char *t;
+ const char *t;
if (!(type2_list = mix_type2_list (&ttll))) {
mutt_error _("Can't get mixmaster's type2.list!");
encoder_t encoder;
char *tocode1 = 0;
const char *tocode;
- char *icode = "UTF-8";
+ const char *icode = "UTF-8";
/* Try to convert to UTF-8. */
if (convert_string (d, dlen, fromcode, icode, &u, &ulen)) {
{
char *e;
size_t elen;
- char *charsets;
+ const char *charsets;
if (!Charset || !*pd)
return;
}
if (mode == 0 && !privacy && option (OPTXMAILER) && !has_agent) {
- struct utsname un;
- char *os;
+ const char *os;
if (OperatingSystem != NULL) {
os = OperatingSystem;
- }
- else {
- if (uname (&un) == -1) {
- os = "UNIX";
- }
- else {
- os = un.sysname;
- }
+ } else {
+ struct utsname un;
+ os = (uname(&un) == -1) ? "UNIX" : un.sysname;
}
/* Add a vanity header */
fprintf (fp, "User-Agent: %s (%s)\n", mutt_make_version (0), os);
return (args);
}
-static char **add_option(char **args, size_t * argslen, size_t * argsmax,
+static char **add_option(const char **args, size_t * argslen, size_t * argsmax,
const char *s)
{
if (*argslen == *argsmax) {
{
smime_id *Table = (smime_id *) menu->data;
smime_id this = Table[num];
- char *truststate;
+ const char *truststate;
switch (this.trust) {
case 't':
#include "xterm.h"
#include "lib/str.h"
-void mutt_xterm_set_title (char *title) {
+void mutt_xterm_set_title (const char *title) {
fputs ("\033]2;", stdout);
fputs (NONULL (title), stdout);
fputs ("\007", stdout);
fflush (stdout);
}
-void mutt_xterm_set_icon (char *name) {
+void mutt_xterm_set_icon (const char *name) {
fputs ("\033]1;", stdout);
fputs (NONULL (name), stdout);
fputs ("\007", stdout);
#define MUTT_XTERM_H
/* sets the current xterm's title */
-void mutt_xterm_set_title (char *title);
+void mutt_xterm_set_title(const char *title);
/* sets the current xterm's icon */
-void mutt_xterm_set_icon (char *name);
+void mutt_xterm_set_icon(const char *name);
#endif /* !MUTT_XTERM_H */