aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.in5
-rw-r--r--fetchmail.c58
-rw-r--r--fetchmail.h6
3 files changed, 11 insertions, 58 deletions
diff --git a/Makefile.in b/Makefile.in
index f50aeef7..10eb7ba5 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -77,7 +77,7 @@ ETAGS = etags -tw
CTAGS = ctags -tw
protobjs = rcfile_y.o rcfile_l.o socket.o getpass.o pop2.o pop3.o imap.o \
- etrn.o fetchmail.o options.o daemon.o smtp.o driver.o rfc822.o \
+ etrn.o fetchmail.o env.o options.o daemon.o smtp.o driver.o rfc822.o \
xmalloc.o uid.o mxget.o md5c.o md5ify.o interface.o netrc.o base64.o \
error.o
@@ -85,7 +85,8 @@ objs = $(protobjs) $(extras) $(EXTRAOBJ)
srcs = $(srcdir)/socket.c $(srcdir)/getpass.c $(srcdir)/pop2.c \
$(srcdir)/pop3.c $(srcdir)/imap.c $(srcdir)/etrn.c \
- $(srcdir)/fetchmail.c $(srcdir)/options.c $(srcdir)/daemon.c \
+ $(srcdir)/fetchmail.c $(srcdir)/env.c \
+ $(srcdir)/options.c $(srcdir)/daemon.c \
$(srcdir)/driver.c $(srcdir)/rfc822.c $(srcdir)/smtp.c \
$(srcdir)/xmalloc.c $(srcdir)/uid.c $(srcdir)/mxget.c \
$(srcdir)/md5c.c $(srcdir)/md5ify.c $(srcdir)/interface.c \
diff --git a/fetchmail.c b/fetchmail.c
index e6e27151..3700b0e8 100644
--- a/fetchmail.c
+++ b/fetchmail.c
@@ -90,49 +90,14 @@ int main (int argc, char **argv)
{
int st, bkgd = FALSE;
int parsestatus, implicitmode = FALSE;
- char *home, *tmpdir, tmpbuf[BUFSIZ];
struct passwd *pw;
struct query *ctl;
FILE *lockfp;
netrc_entry *netrc_list;
- char *netrc_file;
+ char *netrc_file, tmpbuf[BUFSIZ];
pid_t pid;
- if ((program_name = strrchr(argv[0], '/')) != NULL)
- ++program_name;
- else
- program_name = argv[0];
-
- if ((user = getenv("USER")) == (char *)NULL)
- user = getenv("LOGNAME");
-
- if ((user == (char *)NULL) || (home = getenv("HOME")) == (char *)NULL)
- {
- if ((pw = getpwuid(getuid())) != NULL)
- {
- user = pw->pw_name;
- home = pw->pw_dir;
- }
- else
- {
- fprintf(stderr,"fetchmail: can't find your name and home directory!\n");
- exit(PS_UNDEFINED);
- }
- }
-
- /* we'll need this for the SMTP forwarding target and error messages */
- if (gethostname(tmpbuf, sizeof(tmpbuf)))
- {
- fprintf(stderr, "fetchmail: can't determine fetchmail's host!");
- exit(PS_IOERR);
- }
- fetchmailhost = xstrdup(tmpbuf);
-
-#define RCFILE_NAME ".fetchmailrc"
- rcfile = (char *) xmalloc(strlen(home)+strlen(RCFILE_NAME)+2);
- strcpy(rcfile, home);
- strcat(rcfile, "/");
- strcat(rcfile, RCFILE_NAME);
+ envquery(argc, argv);
#define IDFILE_NAME ".fetchids"
idfile = (char *) xmalloc(strlen(home)+strlen(IDFILE_NAME)+2);
@@ -722,25 +687,6 @@ void termhook(int sig)
exit(querystatus);
}
-static char *showproto(int proto)
-/* protocol index to protocol name mapping */
-{
- switch (proto)
- {
- case P_AUTO: return("auto"); break;
-#ifdef POP2_ENABLE
- case P_POP2: return("POP2"); break;
-#endif /* POP2_ENABLE */
- case P_POP3: return("POP3"); break;
- case P_IMAP: return("IMAP"); break;
- case P_IMAP_K4: return("IMAP-K4"); break;
- case P_APOP: return("APOP"); break;
- case P_RPOP: return("RPOP"); break;
- case P_ETRN: return("ETRN"); break;
- default: return("unknown?!?"); break;
- }
-}
-
/*
* Sequence of protocols to try when autoprobing, most capable to least.
*/
diff --git a/fetchmail.h b/fetchmail.h
index a903134c..30b848e3 100644
--- a/fetchmail.h
+++ b/fetchmail.h
@@ -166,6 +166,10 @@ extern char tag[TAGLEN];
/* list of hosts assembled from run control file and command line */
extern struct query cmd_opts, *querylist;
+/* what's returned by envquery */
+extern void envquery(int, char **);
+char *user, *home, *fetchmailhost;
+
/* controls the detail level of status/progress messages written to stderr */
extern int outlevel; /* see the O_.* constants above */
extern int yydebug; /* enable parse debugging */
@@ -220,6 +224,7 @@ int doETRN (struct query *);
void reply_hack(char *, const char *);
char *nxtaddr(const char *);
+/* UID support */
void initialize_saved_lists(struct query *, const char *);
struct idlist *save_str(struct idlist **, int, const char *);
void free_str_list(struct idlist **);
@@ -249,6 +254,7 @@ int interface_approve(struct hostdata *);
char *getpassword(char *);
void escapes(const char *, char *);
+char *showproto(int);
void yyerror(const char *);
int yylex(void);