#include <h/tws.h>
#include <pwd.h>
-#ifdef POP
-# include <h/popsbr.h>
-#endif
-
-#ifndef POP
-# define POPminc(a) (a)
-#else
-# define POPminc(a) 0
-#endif
+#include <h/popsbr.h>
#ifndef CYRUS_SASL
# define SASLminc(a) (a)
# define SASLminc(a) 0
#endif
-static struct swit switches[] = {
-#define DATESW 0
- { "date", 0 },
-#define NDATESW 1
- { "nodate", 0 },
-#define NOTESW 2
- { "notify type", 0 },
-#define NNOTESW 3
- { "nonotify type", 0 },
-#define HOSTSW 4
- { "host hostname", POPminc (-4) },
-#define USERSW 5
- { "user username", POPminc (-4) },
-#define PORTSW 6
- { "port name/number", POPminc(-4) },
-#define VERSIONSW 7
- { "version", 0 },
-#define HELPSW 8
- { "help", 0 },
-#define SNOOPSW 9
- { "snoop", -5 },
-#define SASLSW 10
- { "sasl", SASLminc(-4) },
-#define SASLMECHSW 11
- { "saslmech", SASLminc(-5) },
-#define PROXYSW 12
- { "proxy command", POPminc(-5) },
- { NULL, 0 }
-};
+#define MSGCHK_SWITCHES \
+ X("date", 0, DATESW) \
+ X("nodate", 0, NDATESW) \
+ X("notify type", 0, NOTESW) \
+ X("nonotify type", 0, NNOTESW) \
+ X("host hostname", 0, HOSTSW) \
+ X("user username", 0, USERSW) \
+ X("port name/number", 0, PORTSW) \
+ X("version", 0, VERSIONSW) \
+ X("help", 0, HELPSW) \
+ X("snoop", -5, SNOOPSW) \
+ X("sasl", SASLminc(-4), SASLSW) \
+ X("saslmech", SASLminc(-5), SASLMECHSW) \
+ X("proxy command", 0, PROXYSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MSGCHK);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MSGCHK, switches);
+#undef X
/*
* Maximum numbers of users we can check (plus
*/
static int donote (char *, int);
static int checkmail (char *, char *, int, int, int);
-
-#ifdef POP
static int remotemail (char *, char *, char *, char *, int, int, int, int,
char *);
-#endif
int
char **argp, **arguments, *vec[MAXVEC];
struct passwd *pw;
-#ifdef HESIOD
- struct hes_postoffice *po;
- char *tmphost;
-#endif
-
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
arguments = getarguments (invo_name, argc, argv, 1);
argp = arguments;
-#ifdef POP
- if ((cp = getenv ("MHPOPDEBUG")) && *cp)
- snoop++;
-#endif
-
while ((cp = *argp++)) {
if (*cp == '-') {
switch (smatch (++cp, switches)) {
snprintf (buf, sizeof(buf), "%s [switches] [users ...]",
invo_name);
print_help (buf, switches, 1);
- done (1);
+ done (0);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done (0);
case DATESW:
datesw++;
vec[vecp++] = cp;
}
-#ifdef POP
/*
* If -host is not specified by user
*/
}
if (!host || !*host)
host = NULL;
-#endif /* POP */
if (vecp != 0)
vec[vecp] = NULL;
-#ifdef POP
if (host) {
if (vecp == 0) {
status = remotemail (host, port, user, proxy, notifysw, 1,
snoop, sasl, saslmech);
}
} else {
-#endif /* POP */
if (vecp == 0) {
char *home;
advise (NULL, "no such user as %s", vec[vecp]);
}
}
-#ifdef POP
} /* host == NULL */
-#endif
done (status);
return 1;
}
-static struct swit ntswitches[] = {
-#define NALLSW 0
- { "all", 0 },
-#define NMAISW 1
- { "mail", 0 },
-#define NNMAISW 2
- { "nomail", 0 },
- { NULL, 0 }
-};
+#define NOTE_SWITCHES \
+ X("all", 0, NALLSW) \
+ X("mail", 0, NMAISW) \
+ X("nomail", 0, NNMAISW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(NOTE);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(NOTE, ntswitches);
+#undef X
static int
}
-#ifdef POP
extern char response[];
static int
return status;
}
-#endif /* POP */