commit caa003e08ea18cf81edc2aaad4fa8d6af0afd159
parent e6e026d0df15033218409fee084a97020422b577
Author: Christoph Lohmann <20h@r-36.net>
Date: Thu, 4 Jun 2020 12:45:38 +0200
Change argv0 usage per instance.
Diffstat:
24 files changed, 142 insertions(+), 187 deletions(-)
diff --git a/add.c b/add.c
@@ -21,10 +21,8 @@
#include "flag.h"
#include "inc.h"
-char *argv0;
-
void
-addusage(void)
+addusage(char *argv0)
{
die("usage: %s [-qh] [-c cfg] [-m folder] [-d datetime] [-f flags]"
" [file]\n", argv0);
@@ -35,7 +33,7 @@ addmain(int argc, char *argv[])
{
config_t *cfg;
imap_t *imap;
- char *user, *pass, *netspec, *folder, *flags, *tdate, *filec, *cfgn;
+ char *user, *pass, *netspec, *folder, *flags, *tdate, *filec, *cfgn, *argv0;
int filelen, status;
llist_t *flagl;
inc_t *incs;
@@ -52,24 +50,24 @@ addmain(int argc, char *argv[])
NOARGS = 0x02
};
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'c':
- cfgn = EARGF(addusage());
+ cfgn = EARGF(addusage(argv0));
break;
case 'd':
- tdate = EARGF(addusage());
+ tdate = EARGF(addusage(argv0));
break;
case 'f':
- flags = EARGF(addusage());
+ flags = EARGF(addusage(argv0));
break;
case 'm':
- folder = EARGF(addusage());
+ folder = EARGF(addusage(argv0));
break;
case 'q':
status |= BEQUIET;
break;
default:
- addusage();
+ addusage(argv0);
} ARGEND;
filelen = 0;
diff --git a/arg.h b/arg.h
@@ -6,10 +6,8 @@
#ifndef ARG_H__
#define ARG_H__
-extern char *argv0;
-
/* use main(int argc, char *argv[]) */
-#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
+#define ARGBEGIN(ARGV0) for (ARGV0 = *argv, argv++, argc--;\
argv[0] && argv[0][0] == '-'\
&& argv[0][1];\
argc--, argv++) {\
diff --git a/capability.c b/capability.c
@@ -14,10 +14,8 @@
#include "imap.h"
#include "capability.h"
-char *argv0;
-
void
-capabilityusage(void)
+capabilityusage(char *argv0)
{
fprintf(stderr, "usage: %s [-h] [-c cfg]\n", argv0);
exit(1);
@@ -28,17 +26,17 @@ capabilitymain(int argc, char *argv[])
{
config_t *cfg;
imap_t *imap;
- char *user, *pass, *netspec, *cfgn;
+ char *user, *pass, *netspec, *cfgn, *argv0;
llistelem_t *elem;
cfgn = NULL;
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'c':
- cfgn = EARGF(capabilityusage());
+ cfgn = EARGF(capabilityusage(argv0));
break;
default:
- capabilityusage();
+ capabilityusage(argv0);
} ARGEND;
cfg = config_init(cfgn);
diff --git a/cfg.c b/cfg.c
@@ -22,8 +22,6 @@
#include "path.h"
#include "cfg.h"
-char *argv0;
-
config_t *
config_init(char *cfgn)
{
@@ -184,7 +182,7 @@ configprintelem(llistelem_t *elem, int onlydata)
}
void
-configusage(void)
+configusage(char *argv0)
{
die("usage: %s [-hiqv] [-c cfg] [-e cfg|-l|key"
" [value]]|-d key|-s regex|-n]\n", argv0);
@@ -194,7 +192,7 @@ int
configmain(int argc, char *argv[])
{
int status;
- char *key, *value, *cfgn, *def;
+ char *key, *value, *cfgn, *def, *argv0;
config_t *cfg;
llist_t *results;
llistelem_t *result, *elem;
@@ -216,9 +214,9 @@ configmain(int argc, char *argv[])
cfgn = NULL;
def = NULL;
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'c':
- cfgn = EARGF(configusage());
+ cfgn = EARGF(configusage(argv0));
break;
case 'd':
status |= DODELETE;
@@ -246,7 +244,7 @@ configmain(int argc, char *argv[])
status |= DOSEARCH;
break;
default:
- configusage();
+ configusage(argv0);
} ARGEND;
if (status & DODEFAULT) {
@@ -285,7 +283,7 @@ configmain(int argc, char *argv[])
if (argc > 1)
value = argv[1];
} else {
- configusage();
+ configusage(argv0);
}
if (value != NULL) {
diff --git a/copy.c b/copy.c
@@ -17,10 +17,8 @@
#include "inc.h"
#include "copy.h"
-char *argv0;
-
void
-copyusage(void)
+copyusage(char *argv0)
{
die("usage: %s [-hq] [-c cfg] [-m folder] folder msgs\n", argv0);
}
@@ -38,7 +36,7 @@ copymain(int argc, char *argv[])
config_t *cfg;
imap_t *imap;
int status;
- char *user, *pass, *netspec, *selected, *folder, *cfgn;
+ char *user, *pass, *netspec, *selected, *folder, *cfgn, *argv0;
llist_t *ids;
inc_t *incs;
@@ -56,23 +54,23 @@ copymain(int argc, char *argv[])
if (argc > 0 && argv[0][2] == 'm')
status |= DOMOVE;
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'c':
- cfgn = EARGF(copyusage());
+ cfgn = EARGF(copyusage(argv0));
break;
case 'm':
- selected = EARGF(copyusage());
+ selected = EARGF(copyusage(argv0));
break;
case 'q':
status |= BEQUIET;
break;
case 'h':
default:
- copyusage();
+ copyusage(argv0);
} ARGEND;
if (argc < 2)
- copyusage();
+ copyusage(argv0);
folder = argv[0];
argv++;
argc--;
diff --git a/cur.c b/cur.c
@@ -16,10 +16,8 @@
#include "mark.h"
#include "inc.h"
-char *argv0;
-
void
-curusage(void)
+curusage(char *argv0)
{
die("usage: %s [-h] [-c cfg] [msgid]\n", argv0);
}
@@ -30,17 +28,17 @@ curmain(int argc, char *argv[])
config_t *cfg;
mark_t *marks;
llistelem_t *curseq;
- char *msgss, *selected, *cfgn;
+ char *msgss, *selected, *cfgn, *argv0;
int msgs, setn;
cfgn = NULL;
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'c':
- cfgn = EARGF(curusage());
+ cfgn = EARGF(curusage(argv0));
break;
default:
- curusage();
+ curusage(argv0);
} ARGEND;
cfg = config_init(cfgn);
diff --git a/flag.c b/flag.c
@@ -17,8 +17,6 @@
#include "imap.h"
#include "flag.h"
-char *argv0;
-
llist_t *
flag_sanitize(char *flags)
{
@@ -74,7 +72,7 @@ flagsyntax(void)
}
void
-flagusage(void)
+flagusage(char *argv0)
{
die("usage: %s [-fhu] [-c cfg] [-m folder] [[-s|-d] flag] [msgs]\n"
"Use -f for displaying the flag syntax.\n", argv0);
@@ -86,7 +84,7 @@ flagmain(int argc, char *argv[])
config_t *cfg;
imap_t *imap;
int status;
- char *user, *pass, *netspec, *selected, *cfgn;
+ char *user, *pass, *netspec, *selected, *cfgn, *argv0;
llist_t *ids, *flagl, *flagrl, *flagel;
llistelem_t *elem;
@@ -104,9 +102,9 @@ flagmain(int argc, char *argv[])
selected = NULL;
cfgn = NULL;
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'c':
- cfgn = EARGF(flagusage());
+ cfgn = EARGF(flagusage(argv0));
break;
case 'd':
status |= DODELETE;
@@ -115,7 +113,7 @@ flagmain(int argc, char *argv[])
flagsyntax();
break;
case 'm':
- selected = EARGF(flagusage());
+ selected = EARGF(flagusage(argv0));
break;
case 'q':
status |= BEQUIET;
@@ -127,11 +125,11 @@ flagmain(int argc, char *argv[])
status |= SETSEEN;
break;
default:
- flagusage();
+ flagusage(argv0);
} ARGEND;
if (argc < 1 && !(status & SETSEEN))
- flagusage();
+ flagusage(argv0);
if (status & DOSET || status & DODELETE) {
flagl = flag_sanitize(argv[0]);
@@ -141,7 +139,7 @@ flagmain(int argc, char *argv[])
argv = &argv[1];
}
if (argc < 1 && !(status & SETSEEN))
- flagusage();
+ flagusage(argv0);
cfg = config_init(cfgn);
user = config_checkgetstr(cfg, "imapuser");
diff --git a/folder.c b/folder.c
@@ -14,10 +14,8 @@
#include "folder.h"
#include "imap.h"
-char *argv0;
-
void
-folderusage(void)
+folderusage(char *argv0)
{
die("usage: %s [-qh] [-c cfg] [-l [folder|searchterm]|-n folder|"
"-d folder|-s [folder]|-u folder|-r old new]\n",
@@ -30,7 +28,7 @@ foldermain(int argc, char *argv[])
config_t *cfg;
imap_t *imap;
int status;
- char *user, *pass, *netspec, *cfgn;
+ char *user, *pass, *netspec, *cfgn, *argv0;
llist_t *folders, *results;
llistelem_t *elem;
@@ -49,9 +47,9 @@ foldermain(int argc, char *argv[])
status = 0;
cfgn = NULL;
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'c':
- cfgn = EARGF(folderusage());
+ cfgn = EARGF(folderusage(argv0));
break;
case 'd':
status |= DODELETE;
@@ -75,7 +73,7 @@ foldermain(int argc, char *argv[])
status |= DOUNSUBSCRIBE;
break;
default:
- folderusage();
+ folderusage(argv0);
} ARGEND;
cfg = config_init(cfgn);
@@ -119,7 +117,7 @@ foldermain(int argc, char *argv[])
}
if (status & DOCREATE) {
if (argc < 1)
- folderusage();
+ folderusage(argv0);
if (imap_createfolder(imap, argv[0]))
imap_die(imap, "imap_createfolder");
@@ -129,7 +127,7 @@ foldermain(int argc, char *argv[])
}
if (status & DODELETE) {
if (argc < 1)
- folderusage();
+ folderusage(argv0);
imap_unsubscribe(imap, argv[0]);
if (imap_deletefolder(imap, argv[0]))
@@ -155,7 +153,7 @@ foldermain(int argc, char *argv[])
}
if (status & DOUNSUBSCRIBE) {
if (argc < 1)
- folderusage();
+ folderusage(argv0);
if (imap_unsubscribe(imap, argv[0]))
imap_die(imap, "imap_unsubscribe");
if (!(status & BEQUIET))
@@ -163,7 +161,7 @@ foldermain(int argc, char *argv[])
}
if (status & DORENAME) {
if (argc < 2)
- folderusage();
+ folderusage(argv0);
if (imap_renamefolder(imap, argv[0], argv[1]))
imap_die(imap, "imap_renamefolder");
if (!(status & BEQUIET))
diff --git a/ids.c b/ids.c
@@ -19,10 +19,8 @@
#include "llist.h"
#include "imap.h"
-char *argv0;
-
void
-idsusage(void)
+idsusage(char *argv0)
{
die("usage: %s [-h] [-c cfg] [-m folder] msgs\n", argv0);
}
@@ -31,25 +29,25 @@ int
idsmain(int argc, char *argv[])
{
config_t *cfg;
- char *selected, *idss, *cfgn;
+ char *selected, *idss, *cfgn, *argv0;
llist_t *ids;
selected = NULL;
cfgn = NULL;
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'c':
- cfgn = EARGF(idsusage());
+ cfgn = EARGF(idsusage(argv0));
break;
case 'm':
- selected = EARGF(idsusage());
+ selected = EARGF(idsusage(argv0));
break;
default:
- idsusage();
+ idsusage(argv0);
} ARGEND;
if (argc < 1)
- idsusage();
+ idsusage(argv0);
cfg = config_init(cfgn);
if (selected == NULL) {
diff --git a/inc.c b/inc.c
@@ -20,8 +20,6 @@
#include "inc.h"
#include "path.h"
-char *argv0;
-
inc_t *
inc_init(char *cfgn)
{
@@ -199,7 +197,7 @@ inc_print(char *folder, char *msgs, char *unseen, char *recent)
}
void
-incusage(void)
+incusage(char *argv0)
{
die("usage: %s [-auqnh] [-c cfg] [[-r|] folder]\n", argv0);
}
@@ -211,7 +209,7 @@ incmain(int argc, char *argv[])
imap_t *imap;
inc_t *incs;
int status;
- char *user, *pass, *netspec, *msgs, *recent, *unseen, *ncmd, *cfgn;
+ char *user, *pass, *netspec, *msgs, *recent, *unseen, *ncmd, *cfgn, *argv0;
llist_t *folders, *ffolders;
llistelem_t *folder;
@@ -228,12 +226,12 @@ incmain(int argc, char *argv[])
status = 0;
cfgn = NULL;
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'a':
status |= SHOWALL;
break;
case 'c':
- cfgn = EARGF(incusage());
+ cfgn = EARGF(incusage(argv0));
break;
case 'n':
status |= RUNNOTIFY;
@@ -248,7 +246,7 @@ incmain(int argc, char *argv[])
status |= GENUNSEEN;
break;
default:
- incusage();
+ incusage(argv0);
} ARGEND;
cfg = config_init(cfgn);
diff --git a/mark.c b/mark.c
@@ -20,8 +20,6 @@
#include "imap.h"
#include "path.h"
-char *argv0;
-
mark_t *
mark_init(char *cfgn, char *mailbox)
{
@@ -321,7 +319,7 @@ mark_printelem(llistelem_t *elem, int onlyname, int onlyvalue)
}
void
-markusage(void)
+markusage(char *argv0)
{
die("usage: %s [-hnqv] [-c cfg] [-m folder] [-l|sequence [value ...]]"
"|-d sequence|"
@@ -333,7 +331,7 @@ int
markmain(int argc, char *argv[])
{
int status;
- char *seqname, *str, *selected, *cfgn;
+ char *seqname, *str, *selected, *cfgn, *argv0;
config_t *cfg;
mark_t *marks;
llist_t *results, *values, *sequence;
@@ -359,12 +357,12 @@ markmain(int argc, char *argv[])
selected = NULL;
cfgn = NULL;
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'a':
status |= DOADD;
break;
case 'c':
- cfgn = EARGF(markusage());
+ cfgn = EARGF(markusage(argv0));
break;
case 'd':
status |= DODELETE;
@@ -373,7 +371,7 @@ markmain(int argc, char *argv[])
status |= DOLIST;
break;
case 'm':
- selected = EARGF(markusage());
+ selected = EARGF(markusage(argv0));
break;
case 'n':
status |= ONLYNAMES;
@@ -392,7 +390,7 @@ markmain(int argc, char *argv[])
break;
case 'h':
default:
- markusage();
+ markusage(argv0);
} ARGEND;
if (selected == NULL) {
@@ -497,7 +495,7 @@ markmain(int argc, char *argv[])
sequence = llist_splitstr((char *)result->data, " ");
}
} else {
- markusage();
+ markusage(argv0);
}
values = imap_argv2ids(cfgn, selected, argc, argv);
diff --git a/mime.c b/mime.c
@@ -22,8 +22,6 @@
#include "param.h"
#include "dos.h"
-char *argv0;
-
enum {
HEADER = 0x01,
HEADERVALUE,
diff --git a/parser.c b/parser.c
@@ -77,7 +77,7 @@ parser_read(parser_t *parser, char *buf, int len)
int
parser_readall(parser_t *parser, char *buf, int len)
{
- int r;
+ //int r;
switch(parser->type) {
case PARSER_NET:
diff --git a/part.c b/part.c
@@ -20,8 +20,6 @@
#include "mime.h"
#include "scan.h"
-char *argv0;
-
void
part_printpart(char *id, mime_t *mime)
{
@@ -128,7 +126,7 @@ part_write(char *id, mime_t *mime, llist_t *partl, char *type,
}
void
-partusage(void)
+partusage(char *argv0)
{
die("usage: %s [-hqr] [-c cfg] [-m folder] [-s|-g|-f filename] "
"[-t type|-p part|-a|-l]"
@@ -142,7 +140,7 @@ partmain(int argc, char *argv[])
imap_t *imap;
int status, filelen, retc;
char *user, *pass, *netspec, *selected, *filename, *type,
- *parts, *filec, *cfgn;
+ *parts, *filec, *cfgn, *argv0;
llist_t *ids, *msgs, *partl;
llistelem_t *elem, *msg, *ide;
mime_t *mime;
@@ -165,15 +163,15 @@ partmain(int argc, char *argv[])
selected = NULL;
cfgn = NULL;
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'a':
status |= ALLPARTS;
break;
case 'c':
- cfgn = EARGF(partusage());
+ cfgn = EARGF(partusage(argv0));
break;
case 'f':
- filename = EARGF(partusage());
+ filename = EARGF(partusage(argv0));
break;
case 'g':
status |= GIVENNAME;
@@ -182,10 +180,10 @@ partmain(int argc, char *argv[])
status |= LISTPARTS;
break;
case 'm':
- selected = EARGF(partusage());
+ selected = EARGF(partusage(argv0));
break;
case 'p':
- parts = EARGF(partusage());
+ parts = EARGF(partusage(argv0));
break;
case 'q':
status |= BEQUIET;
@@ -197,11 +195,11 @@ partmain(int argc, char *argv[])
status |= TOSTDOUT;
break;
case 't':
- type = EARGF(partusage());
+ type = EARGF(partusage(argv0));
break;
case 'h':
default:
- partusage();
+ partusage(argv0);
} ARGEND;
filelen = 0;
diff --git a/path.c b/path.c
@@ -16,8 +16,6 @@
#include "ind.h"
#include "path.h"
-char *argv0;
-
enum {
PATH_MKFILE = 0x00,
PATH_MKDIR
@@ -173,7 +171,7 @@ path_mkincfile(char *cfgn)
}
void
-pathusage(void)
+pathusage(char *argv0)
{
die("usage: %s [-bhi] [-c cfg]\n", argv0);
}
@@ -182,7 +180,7 @@ int
pathmain(int argc, char *argv[])
{
int status;
- char *cfgn, *path;
+ char *cfgn, *path, *argv0;
enum {
PRINTBASE = 0x01,
@@ -192,18 +190,18 @@ pathmain(int argc, char *argv[])
status = 0;
cfgn = NULL;
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'b':
status |= PRINTBASE;
break;
case 'c':
- cfgn = EARGF(pathusage());
+ cfgn = EARGF(pathusage(argv0));
break;
case 'i':
status |= INITBASE;
break;
default:
- pathusage();
+ pathusage(argv0);
} ARGEND;
if (status & PRINTBASE) {
@@ -227,7 +225,7 @@ pathmain(int argc, char *argv[])
return 0;
}
- pathusage();
+ pathusage(argv0);
return 0;
}
diff --git a/pick.c b/pick.c
@@ -18,8 +18,6 @@
#include "mark.h"
#include "pick.h"
-char *argv0;
-
enum {
PICK_NONE = 'O',
PICK_STR = 'S',
@@ -327,7 +325,7 @@ pick_printsyntax(void)
}
void
-pickusage(void)
+pickusage(char *argv0)
{
die("usage: %s [-sqdht] [-c cfg] [-m folder] [-o sort criteria]"
" [-e seq] [search syntax]\n"
@@ -341,7 +339,7 @@ pickmain(int argc, char *argv[])
imap_t *imap;
int status;
char *user, *pass, *netspec, *addseq, *sstr, *pstr, *selected,
- *sorts, *talg, *cfgn;
+ *sorts, *talg, *cfgn, *argv0;
llist_t *results, *sortl;
mark_t *marks;
@@ -360,21 +358,21 @@ pickmain(int argc, char *argv[])
selected = NULL;
cfgn = NULL;
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'c':
- cfgn = EARGF(pickusage());
+ cfgn = EARGF(pickusage(argv0));
break;
case 'd':
status |= DRYRUN;
break;
case 'e':
- addseq = EARGF(pickusage());
+ addseq = EARGF(pickusage(argv0));
break;
case 'm':
- selected = EARGF(pickusage());
+ selected = EARGF(pickusage(argv0));
break;
case 'o':
- sorts = EARGF(pickusage());
+ sorts = EARGF(pickusage(argv0));
break;
case 'q':
status |= BEQUIET;
@@ -386,7 +384,7 @@ pickmain(int argc, char *argv[])
status |= DOTHREAD;
break;
default:
- pickusage();
+ pickusage(argv0);
} ARGEND;
if (status & PRINTSYNTAX) {
@@ -395,7 +393,7 @@ pickmain(int argc, char *argv[])
}
if (argc < 1)
- pickusage();
+ pickusage(argv0);
cfg = config_init(cfgn);
user = config_checkgetstr(cfg, "imapuser");
diff --git a/remove.c b/remove.c
@@ -16,10 +16,8 @@
#include "imap.h"
#include "remove.h"
-char *argv0;
-
void
-removeusage(void)
+removeusage(char *argv0)
{
die("usage: %s [-hqdre] [-c cfg] [-m folder] msgs\n", argv0);
}
@@ -30,7 +28,7 @@ removemain(int argc, char *argv[])
config_t *cfg;
imap_t *imap;
int status;
- char *user, *pass, *netspec, *selected, *dispose, *cfgn;
+ char *user, *pass, *netspec, *selected, *dispose, *cfgn, *argv0;
llist_t *ids;
enum {
@@ -46,9 +44,9 @@ removemain(int argc, char *argv[])
selected = NULL;
cfgn = NULL;
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'c':
- cfgn = EARGF(removeusage());
+ cfgn = EARGF(removeusage(argv0));
break;
case 'd':
status |= DODISPOSE;
@@ -57,7 +55,7 @@ removemain(int argc, char *argv[])
status |= DOEXPUNGE;
break;
case 'm':
- selected = EARGF(removeusage());
+ selected = EARGF(removeusage(argv0));
break;
case 'q':
status |= BEQUIET;
@@ -67,11 +65,11 @@ removemain(int argc, char *argv[])
status |= DOREMOVE;
break;
default:
- removeusage();
+ removeusage(argv0);
} ARGEND;
if (argc < 1 && !(status & DOEXPUNGE))
- removeusage();
+ removeusage(argv0);
cfg = config_init(cfgn);
user = config_checkgetstr(cfg, "imapuser");
diff --git a/rohrpost.c b/rohrpost.c
@@ -33,10 +33,8 @@
#include "util.h"
#include "path.h"
-char *argv0;
-
void
-usage(void)
+usage(char *argv0)
{
die("usage: %s [-hil] cmd [args] [range]\n", argv0);
}
@@ -81,7 +79,7 @@ int
main(int argc, char *argv[])
{
int i;
- char *lsl;
+ char *lsl, *argv0;
for (i = 0; i < nelem(cmds); i++) {
lsl = strrchr(argv[0], '/');
@@ -95,7 +93,7 @@ main(int argc, char *argv[])
return cmds[i].main(argc, argv);
}
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'i':
for (i = 0; i < nelem(cmds); i++) {
if (cmds[i].flags & DOINSTALL)
@@ -107,7 +105,7 @@ main(int argc, char *argv[])
printf("%s\n", cmds[i].cmd);
return 0;
default:
- usage();
+ usage(argv0);
} ARGEND;
if (argc > 0) {
@@ -117,7 +115,7 @@ main(int argc, char *argv[])
}
}
- usage();
+ usage(argv0);
return 1;
}
diff --git a/scan.c b/scan.c
@@ -19,8 +19,6 @@
#include "mime.h"
#include "scan.h"
-char *argv0;
-
void
scan_print(char *id, char *date, char *from, char *subject)
{
@@ -28,7 +26,7 @@ scan_print(char *id, char *date, char *from, char *subject)
}
void
-scanusage(void)
+scanusage(char *argv0)
{
die("usage: %s [-h] [-c cfg] [-m folder] msgs\n", argv0);
}
@@ -40,7 +38,7 @@ scanmain(int argc, char *argv[])
imap_t *imap;
int filelen;
char *user, *pass, *netspec, *selected, *date, *subject, *from,
- *id, *filec, *cfgn;
+ *id, *filec, *cfgn, *argv0;
llist_t *ids, *msgs;
llistelem_t *elem, *msg, *datee, *subjecte, *frome, *ide;
mime_t *mime;
@@ -49,15 +47,15 @@ scanmain(int argc, char *argv[])
selected = NULL;
cfgn = NULL;
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'c':
- cfgn = EARGF(scanusage());
+ cfgn = EARGF(scanusage(argv0));
break;
case 'm':
- selected = EARGF(scanusage());
+ selected = EARGF(scanusage(argv0));
break;
default:
- scanusage();
+ scanusage(argv0);
} ARGEND;
filelen = 0;
diff --git a/select.c b/select.c
@@ -14,10 +14,8 @@
#include "llist.h"
#include "select.h"
-char *argv0;
-
void
-selectusage(void)
+selectusage(char *argv0)
{
die("usage: %s [-h] [-c cfg] [mailbox]\n", argv0);
}
@@ -27,16 +25,16 @@ selectmain(int argc, char *argv[])
{
config_t *cfg;
llistelem_t *result;
- char *cfgn;
+ char *cfgn, *argv0;
cfgn = NULL;
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'c':
- cfgn = EARGF(selectusage());
+ cfgn = EARGF(selectusage(argv0));
break;
default:
- selectusage();
+ selectusage(argv0);
} ARGEND;
cfg = config_init(cfgn);
diff --git a/sieve.c b/sieve.c
@@ -20,7 +20,6 @@
#include "base64.h"
#include "pager.h"
-char *argv0;
char *sieverror = NULL;
sieve_t *
@@ -417,7 +416,7 @@ sieve_init(sieve_t *sieve)
}
void
-sieveusage(void)
+sieveusage(char *argv0)
{
die("usage: %s [-h] [-c cfg] [-b|-l|-d|-v script|-p script [file]|"
"-g script [file]|-e script|-t [file]|-a script|"
@@ -428,7 +427,7 @@ int
sievemain(int argc, char *argv[])
{
int status, len;
- char *script, *file, *netspec, *user, *pass, *data, *cfgn;
+ char *script, *file, *netspec, *user, *pass, *data, *cfgn, *argv0;
config_t *cfg;
llistelem_t *elem;
llist_t *results;
@@ -454,7 +453,7 @@ sievemain(int argc, char *argv[])
results = NULL;
cfgn = NULL;
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'a':
status |= DOACTIVATE;
break;
@@ -462,7 +461,7 @@ sievemain(int argc, char *argv[])
status |= DOSHOWCAPABILITIES;
break;
case 'c':
- cfgn = EARGF(sieveusage());
+ cfgn = EARGF(sieveusage(argv0));
break;
case 'd':
status |= DODELETE;
@@ -492,11 +491,11 @@ sievemain(int argc, char *argv[])
status |= DODEACTIVATE;
break;
default:
- sieveusage();
+ sieveusage(argv0);
} ARGEND;
if (!status)
- sieveusage();
+ sieveusage(argv0);
cfg = config_init(cfgn);
netspec = (config_checkget(cfg, "sievenet"))->data;
diff --git a/stats.c b/stats.c
@@ -15,10 +15,8 @@
#include "imap.h"
#include "stats.h"
-char *argv0;
-
void
-statsusage(void)
+statsusage(char *argv0)
{
die("usage: %s [-haru] [-c cfg] [-m folder]\n", argv0);
}
@@ -30,7 +28,7 @@ statsmain(int argc, char *argv[])
imap_t *imap;
int cmsgs, crecent, cunseen, cfolders, domsgs, dorecent, dounseen;
char *user, *pass, *netspec, *msgs, *recent, *unseen, *selected,
- *cfgn;
+ *cfgn, *argv0;
llist_t *folders, *ffolders, *statusl;
llistelem_t *folder, *elem;
@@ -40,15 +38,15 @@ statsmain(int argc, char *argv[])
selected = NULL;
cfgn = NULL;
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'a':
domsgs = 1;
break;
case 'c':
- cfgn = EARGF(statsusage());
+ cfgn = EARGF(statsusage(argv0));
break;
case 'm':
- selected = EARGF(statsusage());
+ selected = EARGF(statsusage(argv0));
break;
case 'r':
dorecent = 1;
@@ -57,7 +55,7 @@ statsmain(int argc, char *argv[])
dounseen = 1;
break;
default:
- statsusage();
+ statsusage(argv0);
} ARGEND;
cfg = config_init(cfgn);
diff --git a/util.c b/util.c
@@ -14,10 +14,8 @@
#include "mime.h"
#include "llist.h"
-char *argv0;
-
void
-utilusage(void)
+utilusage(char *argv0)
{
die("usage: %s [-h] [-e|-d] string\n", argv0);
}
@@ -27,7 +25,7 @@ utilmain(int argc, char *argv[])
{
int status, worklen;
llist_t *workl;
- char *works, *ress;
+ char *works, *ress, *argv0;
enum {
ENCODE = 0x04,
@@ -39,7 +37,7 @@ utilmain(int argc, char *argv[])
status = 0;
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'd':
status |= DECODE;
break;
@@ -51,7 +49,7 @@ utilmain(int argc, char *argv[])
break;
case 'h':
default:
- utilusage();
+ utilusage(argv0);
} ARGEND;
worklen = 0;
@@ -62,7 +60,7 @@ utilmain(int argc, char *argv[])
} else {
workl = llist_splitargv(argc, argv);
if (workl == NULL)
- utilusage();
+ utilusage(argv0);
works = llist_joinstr(workl, " ");
llist_free(workl);
}
@@ -75,7 +73,7 @@ utilmain(int argc, char *argv[])
printf("%s", ress);
} else {
free(works);
- utilusage();
+ utilusage(argv0);
}
free(ress);
free(works);
diff --git a/view.c b/view.c
@@ -24,8 +24,6 @@
#include "scan.h"
#include "mark.h"
-char *argv0;
-
enum {
PRINT_HEADER = 0x01,
PRINT_BODY = 0x02,
@@ -273,7 +271,7 @@ view_print(char *id, mime_t *mime, llist_t *dhdrs, llist_t *partl,
}
void
-viewusage(void)
+viewusage(char *argv0)
{
die("usage: %s [-hbdnrv] [-c cfg] [-e headers] [-m folder]"
" [-p parts] msgs\n", argv0);
@@ -286,7 +284,7 @@ viewmain(int argc, char *argv[])
imap_t *imap;
int status, filelen, printopts, dodebug;
char *user, *pass, *netspec, *selected, *mfilter, *parts, *filec,
- *headers, *cfgn, *id;
+ *headers, *cfgn, *id, *argv0;
llist_t *ids, *msgs, *dhdrs, *partl;
llistelem_t *elem, *msg, *ide;
mime_t *mime;
@@ -308,27 +306,27 @@ viewmain(int argc, char *argv[])
dodebug = 0;
cfgn = NULL;
- ARGBEGIN {
+ ARGBEGIN(argv0) {
case 'b':
printopts |= PRINT_BODY;
break;
case 'c':
- cfgn = EARGF(viewusage());
+ cfgn = EARGF(viewusage(argv0));
break;
case 'd':
dodebug = 1;
break;
case 'e':
- headers = EARGF(viewusage());
+ headers = EARGF(viewusage(argv0));
break;
case 'm':
- selected = EARGF(viewusage());
+ selected = EARGF(viewusage(argv0));
break;
case 'n':
printopts |= PRINT_NOMIME;
break;
case 'p':
- parts = EARGF(viewusage());
+ parts = EARGF(viewusage(argv0));
break;
case 'r':
status |= PRINTRAW;
@@ -337,7 +335,7 @@ viewmain(int argc, char *argv[])
printopts |= PRINT_VALUE;
break;
default:
- viewusage();
+ viewusage(argv0);
} ARGEND;
filelen = 0;