From bf805585db7bfe8440063dd635c00c0057369b91 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Fri, 8 Nov 1996 22:20:54 +0000 Subject: [PATCH] poplib.c, mailquery.c: Cleaned up gcc -Wall warnings poplib.c (pop_init): Check the error return from krb5_init_context(), and print an error message if necessary. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9342 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/mailquery/ChangeLog | 11 +++++++ src/appl/mailquery/mailquery.c | 19 ++++++----- src/appl/mailquery/pop.h | 2 ++ src/appl/mailquery/poplib.c | 58 ++++++++++++++++------------------ 4 files changed, 52 insertions(+), 38 deletions(-) diff --git a/src/appl/mailquery/ChangeLog b/src/appl/mailquery/ChangeLog index 06098b267..7d6322905 100644 --- a/src/appl/mailquery/ChangeLog +++ b/src/appl/mailquery/ChangeLog @@ -1,3 +1,14 @@ +Fri Nov 8 17:01:28 1996 Theodore Ts'o + + * poplib.c: + * mailquery.c: Cleaned up gcc -Wall warnings. + +Thu Nov 7 15:20:25 1996 Theodore Ts'o + + * poplib.c (reserved;): Check the error return from + krb5_init_context(), and print an error message if + necessary. + Tue Sep 10 14:08:06 1996 Tom Yu * mailquery.M: remove ".so man1/header.doc" diff --git a/src/appl/mailquery/mailquery.c b/src/appl/mailquery/mailquery.c index 40859bc83..a2946f484 100644 --- a/src/appl/mailquery/mailquery.c +++ b/src/appl/mailquery/mailquery.c @@ -23,30 +23,34 @@ * -v - print result * -e - exec this command if there is mail. */ -#include -#include -#include #include -#include #ifdef HAVE_UNISTD_H #include #endif +#ifdef HAVE_STDLIB_H +#include +#endif +#include +#include +#include +#include #ifdef HESIOD #include #endif #include "pop.h" - extern int pop_debug; int verbose = 0; char *exec_cmd; +int mailquery(); + void usage() { fprintf(stderr, "usage: mailquery [-d] [-v] [-e cmd] [user[@host]]\n"); } -main(argc, argv) +int main(argc, argv) int argc; char *argv[]; { @@ -55,7 +59,6 @@ main(argc, argv) char *mhost = NULL, *mhp; char *user = 0; struct passwd * pwd; - char response[128]; char c; extern int optind; extern char *optarg; @@ -139,7 +142,7 @@ main(argc, argv) } -mailquery(mhost, user) +int mailquery(mhost, user) char *mhost; char *user; { diff --git a/src/appl/mailquery/pop.h b/src/appl/mailquery/pop.h index 158becaf5..d2f9071a3 100644 --- a/src/appl/mailquery/pop.h +++ b/src/appl/mailquery/pop.h @@ -28,6 +28,8 @@ char *get_errmsg(); int pop_command(); int pop_stat(); int pop_retr(); +int pop_query(); char *concat(); +void fatal(), error(), pfatal_with_name(); extern char Errmsg[]; diff --git a/src/appl/mailquery/poplib.c b/src/appl/mailquery/poplib.c index 423d9af85..fe54ba54d 100644 --- a/src/appl/mailquery/poplib.c +++ b/src/appl/mailquery/poplib.c @@ -17,6 +17,9 @@ /* * Poplib - library routines for speaking POP */ +#include +#include +#include #include #include #include @@ -25,8 +28,6 @@ #include #include #include -#include -#include #if defined(KRB4) && defined(KRB5) error You cannot define both KRB4 and KRB5 #endif @@ -53,6 +54,7 @@ extern char *malloc(); #include "pop.h" void *xmalloc(); +int getline(), multiline(), putline(); char Errmsg[80]; /* to return error messages */ int pop_debug; @@ -60,13 +62,15 @@ int pop_debug; static FILE *sfi = 0; static FILE *sfo = 0; -pop_init(host, reserved) +int pop_init(host, reserved) char *host; int reserved; { register struct hostent *hp; register struct servent *sp; +#ifndef KPOP int lport = IPPORT_RESERVED - 1; +#endif struct sockaddr_in sin; int s; char *get_errmsg(); @@ -84,7 +88,6 @@ int reserved; krb5_ccache ccdef; krb5_principal client = NULL, server = NULL; krb5_error *err_ret = NULL; - register char *cp; krb5_auth_context auth_context; #endif #endif @@ -164,32 +167,27 @@ int reserved; } #endif /* KRB4 */ #ifdef KRB5 - krb5_init_context(&context); - krb5_init_ets(context); - + retval = krb5_init_context(&context); + if (retval) { + com_err("pop_init", retval, "while initializing krb5"); + close(s); + return(NOTOK); + } routine = "krb5_cc_default"; - if (retval = krb5_cc_default(context, &ccdef)) { + if ((retval = krb5_cc_default(context, &ccdef))) { krb5error: sprintf(Errmsg, "%s: krb5 error: %s", routine, error_message(retval)); close(s); return(NOTOK); } routine = "krb5_cc_get_principal"; - if (retval = krb5_cc_get_principal(context, ccdef, &client)) { + if ((retval = krb5_cc_get_principal(context, ccdef, &client))) { goto krb5error; } -#if 0 - /* lower-case to get name for "instance" part of service name */ - for (cp = hp->h_name; *cp; cp++) - if (isupper(*cp)) - *cp = tolower(*cp); -#endif - routine = "krb5_sname_to_principal"; - if (retval = krb5_sname_to_principal(context, hp->h_name, "pop", - KRB5_NT_UNKNOWN, - &server)) { + if ((retval = krb5_sname_to_principal(context, hp->h_name, "pop", + KRB5_NT_UNKNOWN, &server))) { goto krb5error; } @@ -235,7 +233,7 @@ int reserved; return(OK); } -pop_command(fmt, a, b, c, d) +int pop_command(fmt, a, b, c, d) char *fmt; char *a, *b, *c, *d; { @@ -260,7 +258,7 @@ char *a, *b, *c, *d; } } -pop_query(nbytes, user) +int pop_query(nbytes, user) int *nbytes; char *user; { @@ -290,7 +288,7 @@ pop_query(nbytes, user) } } -pop_stat(nmsgs, nbytes) +int pop_stat(nmsgs, nbytes) int *nmsgs, *nbytes; { char buf[1024]; @@ -313,7 +311,7 @@ int *nmsgs, *nbytes; } } -pop_retr(msgno, action, arg) +int pop_retr(msgno, action, arg) int msgno; int (*action)(); char *arg; /* is this always FILE*??? -- XXX */ @@ -354,14 +352,14 @@ char *arg; /* is this always FILE*??? -- XXX */ } } -pop_getline(buf, n) +int pop_getline(buf, n) char *buf; int n; { return getline(buf, n, sfi); } -getline(buf, n, f) +int getline(buf, n, f) char *buf; register int n; FILE *f; @@ -389,7 +387,7 @@ FILE *f; return(OK); } -multiline(buf, n, f) +int multiline(buf, n, f) char *buf; register int n; FILE *f; @@ -428,7 +426,7 @@ get_errmsg() return(s); } -putline(buf, err, f) +int putline(buf, err, f) char *buf; char *err; FILE *f; @@ -445,7 +443,7 @@ FILE *f; /* Print error message and exit. */ -fatal (s1, s2) +void fatal (s1, s2) char *s1, *s2; { error (s1, s2); @@ -454,7 +452,7 @@ fatal (s1, s2) /* Print error message. `s1' is printf control string, `s2' is arg for it. */ -error (s1, s2, s3) +void error (s1, s2, s3) char *s1, *s2, *s3; { printf ("poplib: "); @@ -462,7 +460,7 @@ error (s1, s2, s3) printf ("\n"); } -pfatal_with_name (name) +void pfatal_with_name (name) char *name; { char *s = concat ("", strerror(errno), " for %s"); -- 2.26.2