Commit 6d905f99 6d905f99a9dc2aaa69ef49ac7e567d2114fddae1 by Sergey Poznyakoff

Use mu_header_sget to retrieve context and configuration settings. Update all callers.

1 parent e02fabd9
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2003, 2005 Free Software Foundation, Inc.
Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -64,7 +64,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
switch (key)
{
case ARG_FOLDER:
current_folder = arg;
mh_set_current_folder (arg);
break;
case ARG_INPLACE:
......@@ -122,7 +122,7 @@ main (int argc, char **argv)
mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, &index);
mbox = mh_open_folder (current_folder, 0);
mbox = mh_open_folder (mh_current_folder (), 0);
if (!component)
{
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -75,7 +75,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
switch (key)
{
case ARG_FOLDER:
current_folder = arg;
mh_set_current_folder (arg);
break;
case ARG_INPLACE:
......@@ -480,7 +480,7 @@ burst_rename (mh_msgset_t *ms, size_t lastuid)
}
void
msg_copy (size_t num, char *file)
msg_copy (size_t num, const char *file)
{
mu_message_t msg;
mu_attribute_t attr = NULL;
......@@ -545,7 +545,7 @@ main (int argc, char **argv)
int index, rc;
mu_mailbox_t mbox;
mh_msgset_t msgset;
char *tempfolder = mh_global_profile_get ("Temp-Folder", ".temp");
const char *tempfolder = mh_global_profile_get ("Temp-Folder", ".temp");
/* Native Language Support */
mu_init_nls ();
......@@ -557,8 +557,8 @@ main (int argc, char **argv)
argc -= index;
argv += index;
VERBOSE ((_("Opening folder `%s'"), current_folder));
mbox = mh_open_folder (current_folder, 0);
VERBOSE ((_("Opening folder `%s'"), mh_current_folder ()));
mbox = mh_open_folder (mh_current_folder (), 0);
mh_msgset_parse (mbox, &msgset, argc, argv, "cur");
if (inplace)
......@@ -593,7 +593,7 @@ main (int argc, char **argv)
size_t i, next_uid, last_uid;
mh_msgset_t ms;
char *xargv[2];
char *dir;
const char *dir;
burst_map = obstack_finish (&stk);
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -89,7 +89,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
{
case ARGP_KEY_INIT:
wh_env.draftfolder = mh_global_profile_get ("Draft-Folder",
mu_folder_directory ());
mu_folder_directory ());
break;
case ARG_BUILD:
......@@ -105,7 +105,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
break;
case ARG_FOLDER:
current_folder = arg;
mh_set_current_folder (arg);
break;
case ARG_FORM:
......@@ -241,7 +241,7 @@ main (int argc, char **argv)
static mh_msgset_t msgset;
static mu_mailbox_t mbox;
mbox = mh_open_folder (current_folder, 0);
mbox = mh_open_folder (mh_current_folder (), 0);
mh_msgset_parse (mbox, &msgset, argc - index, argv + index, "cur");
if (msgset.count != 1)
{
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2003 Free Software Foundation, Inc.
Copyright (C) 2003, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -29,7 +29,8 @@ static char *default_format_str =
"--------\n";
void
mh_comp_draft (char *formfile, char *defformfile, char *draftfile)
mh_comp_draft (const char *formfile, const char *defformfile,
const char *draftfile)
{
char *s = NULL;
if (formfile)
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2003,
2005, 2006 Free Software Foundation, Inc.
2005, 2006, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -126,10 +126,10 @@ int verbose = 0; /* Verbosely list actions taken */
size_t pack_start; /* Number to be assigned to the first message in packed
folder. 0 means do not change first message number. */
int dry_run; /* Dry run mode */
char *push_folder; /* Folder name to push on stack */
const char *push_folder; /* Folder name to push on stack */
char *mh_seq_name; /* Name of the mh sequence file (defaults to
.mh_sequences) */
const char *mh_seq_name; /* Name of the mh sequence file (defaults to
.mh_sequences) */
int has_folder; /* Folder has been explicitely given */
size_t max_depth = 1; /* Maximum recursion depth (0 means infinity) */
......@@ -168,7 +168,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
if (arg)
{
push_folder = mh_current_folder ();
current_folder = arg;
mh_set_current_folder (arg);
}
break;
......@@ -222,7 +222,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
case ARG_FOLDER:
has_folder = 1;
push_folder = mh_current_folder ();
current_folder = arg;
mh_set_current_folder (arg);
break;
case ARG_LICENSE:
......@@ -283,7 +283,7 @@ read_seq_file (struct folder_info *info, const char *prefix, const char *name)
{
char *pname = NULL;
mh_context_t *ctx;
char *p;
const char *p;
asprintf (&pname, "%s/%s", prefix, name);
if (!pname)
......@@ -316,7 +316,7 @@ _scan (const char *name, size_t depth)
{
if (mh_check_folder (name, create_flag == -1))
{
push_folder = 0;
push_folder = NULL;
return;
}
dir = opendir (name);
......@@ -411,7 +411,7 @@ print_all ()
else
printf ("%s", info->name);
if (strcmp (info->name, current_folder) == 0)
if (strcmp (info->name, mh_current_folder ()) == 0)
printf ("+");
else
printf (" ");
......@@ -472,7 +472,7 @@ action_print ()
}
else
{
char *p = mh_expand_name (NULL, current_folder, 0);
char *p = mh_expand_name (NULL, mh_current_folder (), 0);
_scan (p, 1);
free (p);
}
......@@ -515,9 +515,9 @@ action_print ()
static int
action_list ()
{
char *stack = mh_global_context_get ("Folder-Stack", NULL);
const char *stack = mh_global_context_get ("Folder-Stack", NULL);
printf ("%s", current_folder);
printf ("%s", mh_current_folder ());
if (stack)
printf (" %s", stack);
printf ("\n");
......@@ -528,33 +528,99 @@ action_list ()
/* ************************************************************* */
/* Push & pop */
static char *
make_stack (char *folder, char *old_stack)
static void
get_stack (int *pc, char ***pv)
{
const char *stack = mh_global_context_get ("Folder-Stack", NULL);
if (!stack)
{
*pc = 0;
*pv = NULL;
}
else if (mu_argcv_get (stack, NULL, "#", pc, pv))
{
mu_error (_("Cannot split line %s"), stack);
exit (1);
}
}
static void
set_stack (int c, char **v)
{
char *stack = NULL;
if (old_stack)
asprintf (&stack, "%s %s", folder, old_stack);
char *str;
int status = mu_argcv_string (c, v, &str);
if (status)
{
mu_error ("%s", mu_strerror (status));
exit (1);
}
mu_argcv_free (c, v);
mh_global_context_set ("Folder-Stack", str);
free (str);
}
static void
push_val (int *pc, char ***pv, const char *val)
{
int c = *pc;
char **v = *pv;
c++;
if (c == 1)
{
v = xcalloc (c + 1, sizeof (*v));
}
else
stack = strdup (folder);
return stack;
{
v = xrealloc (v, (c + 1) * sizeof (*v));
memmove (&v[1], &v[0], c * sizeof (*v));
}
v[0] = xstrdup (val);
*pv = v;
*pc = c;
}
static char *
pop_val (int *pc, char ***pv)
{
char *val;
int c;
char **v;
if (*pc == 0)
return NULL;
c = *pc;
v = *pv;
val = v[0];
memmove (&v[0], &v[1], c * sizeof (*v));
c--;
*pc = c;
*pv = v;
return val;
}
static int
action_push ()
{
char *stack = mh_global_context_get ("Folder-Stack", NULL);
char *new_stack = NULL;
int c;
char **v;
get_stack (&c, &v);
if (push_folder)
new_stack = make_stack (push_folder, stack);
else
push_val (&c, &v, push_folder);
else
{
char *s, *p = strtok_r (stack, " ", &s);
new_stack = make_stack (current_folder, stack);
current_folder = p;
char *t = v[0];
v[0] = xstrdup (mh_current_folder ());
mh_set_current_folder (t);
free (t);
}
mh_global_context_set ("Folder-Stack", new_stack);
set_stack (c, v);
action_list ();
mh_global_save_state ();
return 0;
......@@ -563,22 +629,19 @@ action_push ()
static int
action_pop ()
{
char *stack = mh_global_context_get ("Folder-Stack", NULL);
char *s, *p;
int c;
char **v;
if (stack)
{
p = strtok_r (stack, " ", &s);
if (s[0] == 0)
s = NULL;
}
else
get_stack (&c, &v);
if (c)
{
p = current_folder;
s = NULL;
char *p = pop_val (&c, &v);
set_stack (c, v);
mh_set_current_folder (p);
free (p);
}
mh_global_context_set ("Folder-Stack", s);
current_folder = p;
action_list ();
mh_global_save_state ();
return 0;
......@@ -708,7 +771,7 @@ pack_xlate (struct pack_tab *pack_tab, size_t count, size_t n)
}
static int
_fixup (char *name, char *value, struct fixup_data *fd, int flags)
_fixup (const char *name, const char *value, struct fixup_data *fd, int flags)
{
int i, j, argc;
char **argv;
......@@ -735,7 +798,7 @@ _fixup (char *name, char *value, struct fixup_data *fd, int flags)
if (verbose)
{
char *p = mh_seq_read (name, flags);
const char *p = mh_seq_read (name, flags);
fprintf (stderr, "Sequence %s: %s\n", name, p);
}
......@@ -743,13 +806,13 @@ _fixup (char *name, char *value, struct fixup_data *fd, int flags)
}
static int
fixup_global (char *name, char *value, void *data)
fixup_global (const char *name, const char *value, void *data)
{
return _fixup (name, value, data, 0);
}
static int
fixup_private (char *name, char *value, void *data)
fixup_private (const char *name, const char *value, void *data)
{
struct fixup_data *fd = data;
int nlen = strlen (name);
......@@ -760,8 +823,12 @@ fixup_private (char *name, char *value, void *data)
nlen = strlen (name) - strlen (fd->folder_dir);
if (nlen > 0 && strcmp (name + nlen, fd->folder_dir) == 0)
{
name[nlen-1] = 0;
return _fixup (name, value, fd, SEQ_PRIVATE);
int rc;
char *s = xmalloc (nlen);
memcpy (s, name, nlen - 1);
s[nlen-1] = 0;
rc = _fixup (s, value, fd, SEQ_PRIVATE);
free (s);
}
return 0;
}
......@@ -769,8 +836,8 @@ fixup_private (char *name, char *value, void *data)
int
action_pack ()
{
const char *folder_dir = mh_expand_name (NULL, current_folder, 0);
mu_mailbox_t mbox = mh_open_folder (current_folder, 0);
const char *folder_dir = mh_expand_name (NULL, mh_current_folder (), 0);
mu_mailbox_t mbox = mh_open_folder (mh_current_folder (), 0);
struct pack_tab *pack_tab;
size_t i, count, start;
int status;
......@@ -892,7 +959,7 @@ main (int argc, char **argv)
if (argc - index == 1)
{
mu_mailbox_t mbox = mh_open_folder (current_folder, 0);
mu_mailbox_t mbox = mh_open_folder (mh_current_folder (), 0);
mh_msgset_parse (mbox, &msgset, argc - index, argv + index, "cur");
mh_msgset_current (mbox, &msgset, 0);
mh_global_save_state ();
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -167,7 +167,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
break;
case ARG_FOLDER:
current_folder = arg;
mh_set_current_folder (arg);
break;
case ARG_FORM:
......@@ -356,7 +356,7 @@ finish_draft ()
{
mu_url_t url;
const char *mbox_path;
char *p;
const char *p;
size_t i;
mu_mailbox_get_url (mbox, &url);
......@@ -432,7 +432,7 @@ main (int argc, char **argv)
argc -= index;
argv += index;
mbox = mh_open_folder (current_folder, 0);
mbox = mh_open_folder (mh_current_folder (), 0);
mh_msgset_parse (mbox, &msgset, argc, argv, "cur");
if (build_only || !wh_env.draftfolder)
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2003,
2005, 2006 Free Software Foundation, Inc.
2005, 2006, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -77,7 +77,7 @@ static FILE *audit_fp;
static int changecur = -1;
static int truncate_source = -1;
static int quiet = 0;
static char *append_folder;
static const char *append_folder;
static int
opt_handler (int key, char *arg, void *unused, struct argp_state *state)
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -61,7 +61,7 @@ static int seq_flags = 0; /* Create public sequences;
Do not zero the sequence before addition */
static mu_list_t seq_list; /* List of sequence names to operate upon */
static char *mbox_dir;
static const char *mbox_dir;
static void
add_sequence (char *name)
......@@ -80,7 +80,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
switch (key)
{
case ARG_FOLDER:
current_folder = arg;
mh_set_current_folder (arg);
break;
case ARG_SEQUENCE:
......@@ -143,7 +143,7 @@ static int
action_list (void *item, void *data)
{
char *name = item;
char *val;
const char *val;
val = mh_seq_read (name, 0);
if (val)
......@@ -154,7 +154,7 @@ action_list (void *item, void *data)
}
static int
list_private (char *name, char *value, void *data)
list_private (const char *name, const char *value, void *data)
{
int nlen;
......@@ -165,14 +165,14 @@ list_private (char *name, char *value, void *data)
nlen = strlen (name) - strlen (mbox_dir);
if (nlen > 0 && strcmp (name + nlen, mbox_dir) == 0)
{
name[nlen-1] = 0;
printf ("%s (%s): %s\n", name, _("private"), value);
nlen--;
printf ("%*.*s (%s): %s\n", nlen, nlen, name, _("private"), value);
}
return 0;
}
static int
list_public (char *name, char *value, void *data)
list_public (const char *name, const char *value, void *data)
{
printf ("%s: %s\n", name, value);
return 0;
......@@ -198,7 +198,7 @@ main (int argc, char **argv)
mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, &index);
mbox = mh_open_folder (current_folder, 0);
mbox = mh_open_folder (mh_current_folder (), 0);
mu_mailbox_get_url (mbox, &url);
mbox_dir = mu_url_to_string (url);
if (memcmp (mbox_dir, "mh:", 3) == 0)
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005,
2006 Free Software Foundation, Inc.
2006, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -188,7 +188,7 @@ struct mh_builtin
typedef struct
{
char *name;
const char *name;
mu_header_t header;
} mh_context_t;
......@@ -215,8 +215,8 @@ struct mh_whatnow_env /* whatnow shell environment */
char *file; /* The file being processed */
char *msg; /* File name of the original message (if any) */
char *draftfile; /* File to preserve the draft into */
char *draftfolder;
char *editor;
const char *draftfolder;
const char *editor;
char *prompt;
char *anno_field; /* Annotate field to be used */
mu_list_t anno_list; /* List of messages (mu_message_t) to annotate */
......@@ -226,12 +226,12 @@ struct mh_whatnow_env /* whatnow shell environment */
#define DISP_USE 1
#define DISP_REPLACE 2
typedef int (*mh_context_iterator) (char *field, char *value, void *data);
typedef int (*mh_context_iterator) (const char *field, const char *value,
void *data);
#define SEQ_PRIVATE 1
#define SEQ_ZERO 2
extern char *current_folder;
extern size_t current_message;
extern char mh_list_format[];
extern int rcpt_mask;
......@@ -240,16 +240,17 @@ void mh_init (void);
void mh_init2 (void);
void mh_read_profile (void);
int mh_read_formfile (char *name, char **pformat);
mu_message_t mh_file_to_message (const char *folder, char *file_name);
mu_message_t mh_file_to_message (const char *folder, const char *file_name);
mu_message_t mh_stream_to_message (mu_stream_t stream);
void mh_install (char *name, int automode);
char *mh_global_profile_get (char *name, const char *defval);
const char *mh_global_profile_get (const char *name, const char *defval);
int mh_global_profile_set (const char *name, const char *value);
char *mh_global_context_get (const char *name, const char *defval);
const char *mh_global_context_get (const char *name, const char *defval);
int mh_global_context_set (const char *name, const char *value);
char *mh_current_folder (void);
char *mh_global_sequences_get (const char *name, const char *defval);
const char *mh_set_current_folder (const char *val);
const char *mh_current_folder (void);
const char *mh_global_sequences_get (const char *name, const char *defval);
int mh_global_sequences_set (const char *name, const char *value);
void mh_global_save_state (void);
int mh_global_profile_iterate (mh_context_iterator fp, void *data);
......@@ -260,8 +261,8 @@ void mh_global_sequences_drop (void);
int mh_interactive_mode_p (void);
int mh_getyn (const char *fmt, ...);
int mh_getyn_interactive (const char *fmt, ...);
int mh_check_folder (char *pathname, int confirm);
int mh_makedir (char *p);
int mh_check_folder (const char *pathname, int confirm);
int mh_makedir (const char *p);
int mh_format (mh_format_t *fmt, mu_message_t msg, size_t msgno,
size_t width, char **pret);
......@@ -278,11 +279,11 @@ void mh_err_memory (int fatal);
FILE *mh_audit_open (char *name, mu_mailbox_t mbox);
void mh_audit_close (FILE *fp);
mh_context_t *mh_context_create (char *name, int copy);
mh_context_t *mh_context_create (const char *name, int copy);
int mh_context_read (mh_context_t *ctx);
int mh_context_write (mh_context_t *ctx);
char *mh_context_get_value (mh_context_t *ctx, const char *name,
const char *defval);
const char *mh_context_get_value (mh_context_t *ctx, const char *name,
const char *defval);
int mh_context_set_value (mh_context_t *ctx, const char *name,
const char *value);
int mh_context_iterate (mh_context_t *ctx, mh_context_iterator fp, void *data);
......@@ -328,7 +329,7 @@ int mh_usedraft (const char *filename);
int mh_file_copy (const char *from, const char *to);
char *mh_draft_name (void);
char *mh_create_message_id (int);
int mh_whom (char *filename, int check);
int mh_whom (const char *filename, int check);
void mh_set_reply_regex (const char *str);
int mh_decode_2047 (char *text, char **decoded_text);
......@@ -337,7 +338,7 @@ int mh_alias_get (char *name, mu_list_t *return_list);
int mh_alias_get_address (char *name, mu_address_t *addr, int *incl);
int mh_alias_get_alias (char *uname, mu_list_t *return_list);
int mh_read_aliases (void);
int mh_alias_expand (char *str, mu_address_t *paddr, int *incl);
int mh_alias_expand (const char *str, mu_address_t *paddr, int *incl);
typedef int (*mh_alias_enumerator_t) (char *alias, mu_list_t names, void *data);
void mh_alias_enumerate (mh_alias_enumerator_t fun, void *data);
......@@ -355,11 +356,12 @@ int mhl_format_run (mu_list_t fmt, int width, int length, int flags,
mu_message_t msg, mu_stream_t output);
void mhl_format_destroy (mu_list_t *fmt);
void mh_seq_add (char *name, mh_msgset_t *mset, int flags);
int mh_seq_delete (char *name, mh_msgset_t *mset, int flags);
char *mh_seq_read (char *name, int flags);
void mh_seq_add (const char *name, mh_msgset_t *mset, int flags);
int mh_seq_delete (const char *name, mh_msgset_t *mset, int flags);
const char *mh_seq_read (const char *name, int flags);
void mh_comp_draft (char *formfile, char *defformfile, char *draftfile);
void mh_comp_draft (const char *formfile, const char *defformfile,
const char *draftfile);
int check_draft_disposition (struct mh_whatnow_env *wh, int use_draft);
void ali_parse_error (char *fmt, ...);
......
%{
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -509,12 +509,22 @@ unix_passwd_to_list ()
int
mh_read_aliases ()
{
char *p, *sp;
const char *p;
p = mh_global_profile_get ("Aliasfile", NULL);
if (p)
for (p = strtok_r (p, " \t", &sp); p; p = strtok_r (NULL, " \t", &sp))
mh_alias_read (p, 1);
{
int argc;
char **argv;
int rc = mu_argcv_get (p, NULL, NULL, &argc, &argv);
if (rc == 0)
{
int i;
for (i = 0; i < argc; i++)
mh_alias_read (argv[i], 1);
}
mu_argcv_free (argc, argv);
}
mh_alias_read (DEFAULT_ALIAS_FILE, 0);
return 0;
}
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2005,
2006 Free Software Foundation, Inc.
2006, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -104,6 +104,7 @@ mh_argp_parse (int *pargc, char **pargv[],
struct argp argp;
struct mh_argp_data data;
char *p;
const char *val;
int index;
int extra = 0;
......@@ -127,8 +128,8 @@ mh_argp_parse (int *pargc, char **pargv[],
data.doc = argp_doc;
data.errind = -1;
p = mh_global_profile_get (program_invocation_short_name, NULL);
if (p)
val = mh_global_profile_get (program_invocation_short_name, NULL);
if (val)
{
int argc;
char **argv;
......@@ -136,7 +137,7 @@ mh_argp_parse (int *pargc, char **pargv[],
char **xargv;
int i, j;
mu_argcv_get (p, "", NULL, &xargc, &xargv);
mu_argcv_get (val, "", NULL, &xargc, &xargv);
argc = *pargc + xargc;
argv = calloc (argc+1, sizeof *argv);
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2004,
2005, 2006 Free Software Foundation, Inc.
2005, 2006, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -24,7 +24,7 @@
#include <sys/stat.h>
mh_context_t *
mh_context_create (char *name, int copy)
mh_context_create (const char *name, int copy)
{
mh_context_t *ctx;
ctx = malloc (sizeof (*ctx));
......@@ -47,7 +47,7 @@ mh_context_destroy (mh_context_t **pctx)
{
mh_context_t *ctx = *pctx;
free (ctx->name);
free ((char*) ctx->name);
if (ctx->header)
mu_header_destroy (&ctx->header, mu_header_get_owner (ctx->header));
free (ctx);
......@@ -69,14 +69,12 @@ mh_context_merge (mh_context_t *dst, mh_context_t *src)
mu_header_get_field_count (src->header, &count);
for (i = 1; i <= count; i++)
{
char *name = NULL;
char *value = NULL;
const char *name = NULL;
const char *value = NULL;
mu_header_aget_field_name (src->header, i, &name);
mu_header_aget_field_value (src->header, i, &value);
mu_header_sget_field_name (src->header, i, &name);
mu_header_sget_field_value (src->header, i, &value);
mu_header_set_value (dst->header, name, value, 1);
free (name);
free (value);
}
}
}
......@@ -162,24 +160,13 @@ mh_context_write (mh_context_t *ctx)
return 0;
}
/* FIXME: mh_context_get_value returns a pointer to the allocated memory.
Instead, it should return a const pointer to the static storage within
the mu_header_t structure and be declared as
`const char *mh_context_get_value()'. Current implementation of
header_.* functions does not allow that.
This has two drawbacks:
1) The function is declared as returning char * instead of
intended const char *.
2) Ugly typecast when returning defval. */
char *
const char *
mh_context_get_value (mh_context_t *ctx, const char *name, const char *defval)
{
char *p;
const char *p;
if (!ctx || mu_header_aget_value (ctx->header, name, &p))
p = (char *) defval;
if (!ctx || mu_header_sget_value (ctx->header, name, &p))
p = defval;
return p;
}
......@@ -213,13 +200,11 @@ mh_context_iterate (mh_context_t *ctx, mh_context_iterator fp, void *data)
mu_header_get_field_count (ctx->header, &nfields);
for (i = 1; i <= nfields && rc == 0; i++)
{
char *name, *value;
const char *name, *value;
mu_header_aget_field_name (ctx->header, i, &name);
mu_header_aget_field_value (ctx->header, i, &value);
mu_header_sget_field_name (ctx->header, i, &name);
mu_header_sget_field_value (ctx->header, i, &value);
rc = fp (name, value, data);
free (name);
free (value);
}
return rc;
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -20,7 +20,7 @@
#include <mh.h>
char *current_folder = NULL;
static const char *current_folder = NULL;
size_t current_message = 0;
mh_context_t *context;
mh_context_t *profile;
......@@ -30,8 +30,8 @@ int mh_auto_install = 1;
/* Global profile */
char *
mh_global_profile_get (char *name, const char *defval)
const char *
mh_global_profile_get (const char *name, const char *defval)
{
return mh_context_get_value (profile, name, defval);
}
......@@ -52,6 +52,7 @@ void
mh_read_profile ()
{
char *p;
const char *fallback;
p = getenv ("MH");
if (p)
......@@ -72,8 +73,8 @@ mh_read_profile ()
mh_context_read (profile);
mh_set_reply_regex (mh_global_profile_get ("Reply-Regex", NULL));
p = mh_global_profile_get ("Decode-Fallback", NULL);
if (p && mu_set_default_fallback (p))
fallback = mh_global_profile_get ("Decode-Fallback", NULL);
if (fallback && mu_set_default_fallback (fallback))
mu_error (_("Incorrect value for decode-fallback"));
}
......@@ -100,7 +101,7 @@ _mh_init_global_context ()
"inbox"));
}
char *
const char *
mh_global_context_get (const char *name, const char *defval)
{
_mh_init_global_context ();
......@@ -121,19 +122,29 @@ mh_global_context_iterate (mh_context_iterator fp, void *data)
return mh_context_iterate (context, fp, data);
}
char *
const char *
mh_current_folder ()
{
_mh_init_global_context ();
return mh_global_context_get ("Current-Folder",
mh_global_profile_get ("Inbox", "inbox"));
}
const char *
mh_set_current_folder (const char *val)
{
mh_global_context_set ("Current-Folder", val);
current_folder = mh_current_folder ();
return current_folder;
}
/* Global sequences */
void
_mh_init_global_sequences ()
{
char *name, *p, *seq_name;
const char *name;
char *p, *seq_name;
if (sequences)
return;
......@@ -145,10 +156,8 @@ _mh_init_global_sequences ()
free (p);
sequences = mh_context_create (seq_name, 1);
if (mh_context_read (sequences) == 0)
{
p = mh_context_get_value (sequences, "cur", "0");
current_message = strtoul (p, NULL, 10);
}
current_message = strtoul (mh_context_get_value (sequences, "cur", "0"),
NULL, 10);
}
void
......@@ -157,7 +166,7 @@ mh_global_sequences_drop ()
sequences = NULL;
}
char *
const char *
mh_global_sequences_get (const char *name, const char *defval)
{
_mh_init_global_sequences ();
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2003,
2005, 2006 Free Software Foundation, Inc.
2005, 2006, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -177,10 +177,11 @@ mh_is_my_name (const char *name)
rc = 1;
else
{
char *nlist = mh_global_profile_get ("Alternate-Mailboxes", NULL);
const char *nlist = mh_global_profile_get ("Alternate-Mailboxes", NULL);
if (nlist)
{
char *end, *p, *pat;
const char *end, *p;
char *pat;
int len;
for (p = nlist; rc == 0 && *p; p = end)
......@@ -253,12 +254,12 @@ make_dir_hier (const char *p, mode_t perm)
}
int
mh_makedir (char *p)
mh_makedir (const char *p)
{
int rc;
mode_t save_umask;
mode_t perm = 0711;
char *pb = mh_global_profile_get ("Folder-Protect", NULL);
const char *pb = mh_global_profile_get ("Folder-Protect", NULL);
if (pb)
perm = strtoul (pb, NULL, 8);
......@@ -277,9 +278,9 @@ mh_makedir (char *p)
}
int
mh_check_folder (char *pathname, int confirm)
mh_check_folder (const char *pathname, int confirm)
{
char *p;
const char *p;
struct stat st;
if ((p = strchr (pathname, ':')) != NULL)
......@@ -464,16 +465,18 @@ mh_open_folder (const char *folder, int create)
char *
mh_get_dir ()
{
char *mhdir = mh_global_profile_get ("Path", "Mail");
const char *mhdir = mh_global_profile_get ("Path", "Mail");
char *mhcopy;
if (mhdir[0] != '/')
{
char *p = mu_get_homedir ();
asprintf (&mhdir, "%s/%s", p, mhdir);
asprintf (&mhcopy, "%s/%s", p, mhdir);
free (p);
}
else
mhdir = strdup (mhdir);
return mhdir;
mhcopy = strdup (mhdir);
return mhcopy;
}
char *
......@@ -639,7 +642,7 @@ mh_file_copy (const char *from, const char *to)
}
static mu_message_t
_file_to_message (char *file_name)
_file_to_message (const char *file_name)
{
struct stat st;
int rc;
......@@ -670,7 +673,7 @@ _file_to_message (char *file_name)
}
mu_message_t
mh_file_to_message (const char *folder, char *file_name)
mh_file_to_message (const char *folder, const char *file_name)
{
mu_message_t msg;
char *tmp_name = NULL;
......@@ -837,9 +840,9 @@ mh_annotate (mu_message_t msg, char *field, char *text, int date)
char *
mh_draft_name ()
{
char *draftfolder = mh_global_profile_get ("Draft-Folder",
mu_folder_directory ());
return mh_expand_name (draftfolder, "draft", 0);
return mh_expand_name (mh_global_profile_get ("Draft-Folder",
mu_folder_directory ()),
"draft", 0);
}
char *
......@@ -884,7 +887,7 @@ mh_set_reply_regex (const char *str)
int
mh_decode_2047 (char *text, char **decoded_text)
{
char *charset = mh_global_profile_get ("Charset", NULL);
const char *charset = mh_global_profile_get ("Charset", NULL);
if (!charset)
return 1;
......@@ -892,19 +895,22 @@ mh_decode_2047 (char *text, char **decoded_text)
{
/* Try to deduce the charset from LC_ALL variable */
char *tmp = getenv ("LC_ALL");
if (tmp)
char *lc_all = getenv ("LC_ALL");
if (lc_all)
{
char *sp;
char *lang;
char *terr;
char *tmp = strdup (lc_all);
lang = strtok_r (tmp, "_", &sp);
terr = strtok_r (NULL, ".", &sp);
charset = strtok_r (NULL, "@", &sp);
if (!charset)
charset = mu_charset_lookup (lang, terr);
free (tmp);
}
}
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2005, 2006,
2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -237,7 +238,8 @@ expand_user_seq (mu_mailbox_t mbox, mh_msgset_t *msgset, char *arg)
{
int argc;
char **argv;
char *p, *listp;
char *p;
const char *listp;
int rc = 1;
int negate = 0;
......@@ -248,7 +250,7 @@ expand_user_seq (mu_mailbox_t mbox, mh_msgset_t *msgset, char *arg)
if (!listp)
{
int len;
char *neg = mh_global_profile_get ("Sequence-Negation", NULL);
const char *neg = mh_global_profile_get ("Sequence-Negation", NULL);
if (!neg)
return 1;
len = strlen (neg);
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2003, 2005 Free Software Foundation, Inc.
Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -19,19 +19,19 @@
#include <mh.h>
static char *
private_sequence_name (char *name)
private_sequence_name (const char *name)
{
char *p;
char *mbox_dir = mh_expand_name (NULL, current_folder, 0);
char *mbox_dir = mh_expand_name (NULL, mh_current_folder (), 0);
asprintf (&p, "atr-%s-%s", name, mbox_dir);
free (mbox_dir);
return p;
}
char *
mh_seq_read (char *name, int flags)
const char *
mh_seq_read (const char *name, int flags)
{
char *value;
const char *value;
if (flags & SEQ_PRIVATE)
{
......@@ -45,7 +45,7 @@ mh_seq_read (char *name, int flags)
}
static void
write_sequence (char *name, char *value, int private)
write_sequence (const char *name, char *value, int private)
{
if (private)
{
......@@ -58,15 +58,15 @@ write_sequence (char *name, char *value, int private)
}
static void
delete_sequence (char *name, int private)
delete_sequence (const char *name, int private)
{
write_sequence (name, NULL, private);
}
void
mh_seq_add (char *name, mh_msgset_t *mset, int flags)
mh_seq_add (const char *name, mh_msgset_t *mset, int flags)
{
char *value = mh_seq_read (name, flags);
const char *value = mh_seq_read (name, flags);
char *new_value, *p;
const char *buf;
size_t i, len;
......@@ -120,9 +120,10 @@ cmp_msgnum (const void *a, const void *b)
}
int
mh_seq_delete (char *name, mh_msgset_t *mset, int flags)
mh_seq_delete (const char *name, mh_msgset_t *mset, int flags)
{
char *value = mh_seq_read (name, flags);
const char *value = mh_seq_read (name, flags);
char *new_val;
char *p;
int argc, i, count;
char **argv;
......@@ -149,7 +150,8 @@ mh_seq_delete (char *name, mh_msgset_t *mset, int flags)
}
}
p = value;
new_val = xstrdup (value);
p = new_val;
count = 0;
for (i = 0; i < argc; i++)
{
......@@ -162,8 +164,9 @@ mh_seq_delete (char *name, mh_msgset_t *mset, int flags)
}
}
*p = 0;
write_sequence (name, count > 0 ? value : NULL, flags & SEQ_PRIVATE);
write_sequence (name, count > 0 ? new_val : NULL, flags & SEQ_PRIVATE);
mu_argcv_free (argc, argv);
free (new_val);
return 0;
}
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -180,7 +180,7 @@ _help (struct helpdata *helpdata, char *argname)
static void
display_file (const char *name)
{
char *pager = mh_global_profile_get ("moreproc", getenv ("PAGER"));
const char *pager = mh_global_profile_get ("moreproc", getenv ("PAGER"));
if (pager)
mh_spawnp (pager, name);
......@@ -217,7 +217,7 @@ display_file (const char *name)
}
static int
check_exit_status (char *progname, int status)
check_exit_status (const char *progname, int status)
{
if (WIFEXITED (status))
{
......@@ -238,12 +238,12 @@ check_exit_status (char *progname, int status)
}
static int
invoke (char *compname, char *defval, int argc, char **argv,
char *extra0, char *extra1)
invoke (const char *compname, const char *defval, int argc, char **argv,
const char *extra0, const char *extra1)
{
int i, rc;
char **xargv;
char *progname;
const char **xargv;
const char *progname;
int status;
progname = mh_global_profile_get (compname, defval);
......@@ -583,11 +583,13 @@ int
mh_disposition (const char *filename)
{
struct mh_whatnow_env wh;
int rc;
memset (&wh, 0, sizeof (wh));
wh.file = filename;
wh.file = xstrdup (filename);
wh.prompt = _("Disposition?");
return _whatnow (&wh, disp_tab);
rc = _whatnow (&wh, disp_tab);
free (wh.file);
return rc;
}
/* Use draft shell */
......@@ -636,10 +638,11 @@ mh_usedraft (const char *filename)
int rc;
memset (&wh, 0, sizeof (wh));
wh.file = filename;
wh.file = xstrdup (filename);
asprintf (&wh.prompt, _("Use \"%s\"?"), filename);
rc = _whatnow (&wh, usedraft_tab);
free (wh.prompt);
free (wh.file);
return rc;
}
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -52,7 +52,7 @@ ismydomain (char *p)
}
int
mh_alias_expand (char *str, mu_address_t *paddr, int *incl)
mh_alias_expand (const char *str, mu_address_t *paddr, int *incl)
{
size_t argc;
char **argv;
......@@ -119,7 +119,7 @@ mh_alias_expand (char *str, mu_address_t *paddr, int *incl)
static void
scan_addrs (char *str, int isbcc)
scan_addrs (const char *str, int isbcc)
{
mu_address_t addr = NULL;
size_t i, count;
......@@ -153,8 +153,6 @@ scan_addrs (char *str, int isbcc)
addrcp (&network_rcp, buf, isbcc);
}
mu_address_destroy (&addr);
free (str); /* FIXME: This will disappear. Note comment to
mh_context_get_value! */
}
static int
......@@ -218,7 +216,7 @@ _print_local_recipient (void *item, void *data)
}
int
mh_whom (char *filename, int check)
mh_whom (const char *filename, int check)
{
int rc = 0;
mh_context_t *ctx;
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2003 Free Software Foundation, Inc.
Copyright (C) 2003, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -70,7 +70,7 @@ static int mhl_fmt_flags; /* MHL format flags. Controlled by --bell
static int length = 40; /* Length of output page */
static int width = 80; /* Width of output page */
static char *formfile = MHLIBDIR "/mhl.format";
static char *moreproc;
static const char *moreproc;
static int nomoreproc;
static mu_list_t format;
......@@ -81,7 +81,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
switch (key)
{
case ARG_FOLDER:
current_folder = arg;
mh_set_current_folder (arg);
break;
case ARG_BELL:
......
......@@ -247,7 +247,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
switch (key)
{
case ARG_FOLDER:
current_folder = arg;
mh_set_current_folder (arg);
break;
case ARG_FILE:
......@@ -574,10 +574,11 @@ msg_part_subpart (msg_part_t p, int level)
/* *********************** Context file accessors ************************* */
char *
const char *
_mhn_profile_get (char *prefix, char *type, char *subtype, char *defval)
{
char *str, *name;
char *name;
const char *str;
if (subtype)
{
......@@ -599,7 +600,7 @@ _mhn_profile_get (char *prefix, char *type, char *subtype, char *defval)
char *
mhn_compose_command (char *typestr, int *flags, char *file)
{
char *p, *str;
const char *p, *str;
char *type, *subtype, *typeargs;
struct obstack stk;
......@@ -667,13 +668,15 @@ mhn_compose_command (char *typestr, int *flags, char *file)
str = strdup (str);
obstack_free (&stk, NULL);
return str;
return (char*) str;
}
char *
mhn_show_command (mu_message_t msg, msg_part_t part, int *flags, char **tempfile)
mhn_show_command (mu_message_t msg, msg_part_t part, int *flags,
char **tempfile)
{
char *p, *str, *tmp;
const char *p, *str;
char *tmp;
char *typestr, *type, *subtype, *typeargs;
struct obstack stk;
mu_header_t hdr;
......@@ -781,13 +784,14 @@ mhn_show_command (mu_message_t msg, msg_part_t part, int *flags, char **tempfile
str = strdup (str);
obstack_free (&stk, NULL);
return str;
return (char*) str;
}
char *
mhn_store_command (mu_message_t msg, msg_part_t part, char *name)
{
char *p, *str, *tmp;
const char *p, *str;
char *tmp;
char *typestr, *type, *subtype, *typeargs;
struct obstack stk;
mu_header_t hdr;
......@@ -872,7 +876,7 @@ mhn_store_command (mu_message_t msg, msg_part_t part, char *name)
str = strdup (str);
obstack_free (&stk, NULL);
return str;
return (char*) str;
}
......@@ -1277,7 +1281,7 @@ show_internal (mu_message_t msg, msg_part_t part, char *encoding, mu_stream_t ou
}
int
mhn_exec (mu_stream_t *str, char *cmd, int flags)
mhn_exec (mu_stream_t *str, const char *cmd, int flags)
{
int rc = mu_prog_stream_create (str, cmd, MU_STREAM_WRITE);
if (rc)
......@@ -1296,8 +1300,8 @@ mhn_exec (mu_stream_t *str, char *cmd, int flags)
}
int
exec_internal (mu_message_t msg, msg_part_t part, char *encoding, char *cmd,
int flags)
exec_internal (mu_message_t msg, msg_part_t part, char *encoding,
const char *cmd, int flags)
{
int rc;
mu_stream_t tmp;
......@@ -1420,7 +1424,7 @@ show_handler (mu_message_t msg, msg_part_t part, char *type, char *encoding,
if (!cmd)
{
char *pager = mh_global_profile_get ("moreproc", getenv ("PAGER"));
const char *pager = mh_global_profile_get ("moreproc", getenv ("PAGER"));
if (pager)
exec_internal (msg, part, encoding, pager, 0);
else
......@@ -1583,7 +1587,7 @@ store_handler (mu_message_t msg, msg_part_t part, char *type, char *encoding,
int ismime;
int rc;
mu_stream_t out;
char *dir = mh_global_profile_get ("mhn-storage", NULL);
const char *dir = mh_global_profile_get ("mhn-storage", NULL);
if (mu_message_is_multipart (msg, &ismime) == 0 && ismime)
return 0;
......@@ -1611,7 +1615,7 @@ store_handler (mu_message_t msg, msg_part_t part, char *type, char *encoding,
&& argv[i][0] == '='
&& ++i < argc)
{
name = normalize_path (dir, argv[i]);
name = normalize_path (xstrdup (dir), argv[i]);
break;
}
}
......@@ -1635,7 +1639,7 @@ store_handler (mu_message_t msg, msg_part_t part, char *type, char *encoding,
&& argv[i][0] == '='
&& ++i < argc)
{
name = normalize_path (dir, argv[i]);
name = normalize_path (xstrdup (dir), argv[i]);
break;
}
}
......@@ -2793,7 +2797,7 @@ main (int argc, char **argv)
}
else
{
mbox = mh_open_folder (current_folder, 0);
mbox = mh_open_folder (mh_current_folder (), 0);
mh_msgset_parse (mbox, &msgset, argc, argv, "cur");
}
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2003 Free Software Foundation, Inc.
Copyright (C) 2003, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -89,7 +89,7 @@ mhparam_defval (char *comp)
}
int
mhparam_iterator (char *comp, char *value, char *data ARG_UNUSED)
mhparam_iterator (const char *comp, const char *value, void *data ARG_UNUSED)
{
if (display_comp_name)
printf("%s:\t", comp);
......@@ -102,7 +102,7 @@ mhparam (char *comp)
{
if (comp)
{
char *val = mh_global_profile_get (comp, NULL);
const char *val = mh_global_profile_get (comp, NULL);
if (!val)
val = mhparam_defval (comp);
if (!val)
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2002, 2005 Free Software Foundation, Inc.
Copyright (C) 2002, 2005, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -45,7 +45,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
switch (key)
{
case ARG_FOLDER:
current_folder = arg;
mh_set_current_folder (arg);
break;
case ARG_LICENSE:
......@@ -77,7 +77,8 @@ main (int argc, char **argv)
size_t total;
mh_msgset_t msgset;
int status;
const char *current_folder;
/* Native Language Support */
mu_init_nls ();
......@@ -85,6 +86,7 @@ main (int argc, char **argv)
mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, &index);
current_folder = mh_current_folder ();
/* If the only argument is `+', your MH Path is output; this
can be useful is shell scripts. */
if (current_folder[0] == 0)
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -150,7 +150,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
switch (key)
{
case ARG_FOLDER:
current_folder = arg;
mh_set_current_folder (arg);
break;
case ARG_SEQUENCE:
......@@ -354,7 +354,7 @@ main (int argc, char **argv)
if (pick_parse (lexlist))
return 1;
mbox = mh_open_folder (current_folder, 0);
mbox = mh_open_folder (mh_current_folder (), 0);
argc -= index;
argv += index;
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004, 2005, 2006,
2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -170,7 +171,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
break;
case ARG_SOURCE:
current_folder = arg;
mh_set_current_folder (arg);
break;
case ARG_FILE:
......@@ -267,7 +268,7 @@ main (int argc, char **argv)
}
else
{
mbox = mh_open_folder (current_folder, 0);
mbox = mh_open_folder (mh_current_folder (), 0);
mh_msgset_parse (mbox, &msgset, argc, argv, "cur");
status = mh_iterate (mbox, &msgset, refile_iterator, NULL);
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -174,7 +174,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
break;
case ARG_FOLDER:
current_folder = arg;
mh_set_current_folder (arg);
break;
case ARG_FORM:
......@@ -415,7 +415,7 @@ main (int argc, char **argv)
exit (1);
}
mbox = mh_open_folder (current_folder, 0);
mbox = mh_open_folder (mh_current_folder (), 0);
mh_msgset_parse (mbox, &msgset, argc - index, argv + index, "cur");
if (msgset.count != 1)
{
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2002, 2005, 2006, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -177,7 +177,7 @@ rmf (const char *name)
{
if (cur_folder_path && strcmp (name, cur_folder_path) == 0)
{
current_folder = "inbox";
mh_set_current_folder ("inbox");
mh_global_sequences_drop ();
mh_global_save_state ();
printf ("[+inbox now current]\n");
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2002, 2005 Free Software Foundation, Inc.
Copyright (C) 2002, 2005, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -45,7 +45,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
switch (key)
{
case ARG_FOLDER:
current_folder = arg;
mh_set_current_folder (arg);
break;
case ARG_LICENSE:
......@@ -81,7 +81,7 @@ main (int argc, char **argv)
mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
opt_handler, NULL, &index);
mbox = mh_open_folder (current_folder, 0);
mbox = mh_open_folder (mh_current_folder (), 0);
mh_msgset_parse (mbox, &msgset, argc - index, argv + index, "cur");
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2003,
2005, 2006 Free Software Foundation, Inc.
2005, 2006, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -93,7 +93,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
switch (key)
{
case ARG_FOLDER:
current_folder = arg;
mh_set_current_folder (arg);
break;
case ARG_CLEAR:
......@@ -188,7 +188,7 @@ main (int argc, char **argv)
exit (1);
}
mbox = mh_open_folder (current_folder, 0);
mbox = mh_open_folder (mh_current_folder (), 0);
argc -= index;
argv += index;
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -98,7 +98,7 @@ struct mh_option mh_option[] = {
};
static int use_draft; /* Use the prepared draft */
static char *draft_folder; /* Use this draft folder */
static const char *draft_folder; /* Use this draft folder */
static int reformat_recipients; /* --format option */
static int forward_notice; /* Forward the failure notice to the sender,
--forward flag */
......@@ -288,7 +288,7 @@ check_file (char *name)
void
read_mts_profile ()
{
char *p;
const char *p;
char *hostname = NULL;
int rc;
mh_context_t *local_profile;
......@@ -305,7 +305,7 @@ read_mts_profile ()
if ((p = mh_context_get_value (mts_profile, "localname", NULL)))
{
hostname = p;
hostname = xstrdup (p);
mu_set_user_email_domain (p);
}
else if ((rc = mu_get_host_name (&hostname)))
......@@ -336,9 +336,9 @@ read_mts_profile ()
mu_mailer_t
open_mailer ()
{
char *url = mh_context_get_value (mts_profile,
"url",
"sendmail:/usr/sbin/sendmail");
const char *url = mh_context_get_value (mts_profile,
"url",
"sendmail:/usr/sbin/sendmail");
mu_mailer_t mailer;
int status;
......@@ -375,10 +375,10 @@ create_message_id (mu_header_t hdr)
free (p);
}
static char *
static const char *
get_sender_personal ()
{
char *s = mh_global_profile_get ("signature", getenv ("SIGNATURE"));
const char *s = mh_global_profile_get ("signature", getenv ("SIGNATURE"));
if (!s)
{
struct passwd *pw = getpwuid (getuid ());
......@@ -589,7 +589,7 @@ _action_send (void *item, void *data)
{
char *from;
char *email = mu_get_user_email (NULL);
char *pers = get_sender_personal ();
const char *pers = get_sender_personal ();
if (pers)
{
asprintf (&from, "\"%s\" <%s>", pers, email);
......@@ -608,7 +608,8 @@ _action_send (void *item, void *data)
if (mu_header_get_value (hdr, MU_HEADER_X_MAILER, NULL, 0, &n))
{
char *p = mh_context_get_value (mts_profile, "x-mailer", "yes");
const char *p = mh_context_get_value (mts_profile,
"x-mailer", "yes");
if (!strcmp (p, "yes"))
mu_header_set_value (hdr, MU_HEADER_X_MAILER,
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -121,7 +121,7 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state)
switch (key)
{
case ARG_FOLDER:
current_folder = arg;
mh_set_current_folder (arg);
break;
case ARG_DATEFIELD:
......@@ -566,7 +566,7 @@ main (int argc, char **argv)
exit (1);
}
mbox = mh_open_folder (current_folder, 0);
mbox = mh_open_folder (mh_current_folder (), 0);
mu_mailbox_get_url (mbox, &url);
mbox_path = mu_url_to_string (url);
if (memcmp (mbox_path, "mh:", 3) == 0)
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2003 Free Software Foundation, Inc.
Copyright (C) 2003, 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -58,7 +58,7 @@ struct mh_option mh_option[] = {
static int check_recipients;
static int use_draft; /* Use the prepared draft */
static char *draft_folder; /* Use this draft folder */
static const char *draft_folder; /* Use this draft folder */
static int
opt_handler (int key, char *arg, void *unused, struct argp_state *state)
......