From f1ab65244b4cfb173b91d48794137dd7507f564d Mon Sep 17 00:00:00 2001 From: John Kohl Date: Wed, 20 Mar 1991 17:19:26 +0000 Subject: [PATCH] Initial revision git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1926 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/popper/popper.c | 103 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 src/appl/popper/popper.c diff --git a/src/appl/popper/popper.c b/src/appl/popper/popper.c new file mode 100644 index 000000000..4c2130b45 --- /dev/null +++ b/src/appl/popper/popper.c @@ -0,0 +1,103 @@ +/* + * Copyright (c) 1989 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; +static char SccsId[] = "@(#)popper.c 1.7 7/13/90"; +#endif not lint + +#include +#include +#include "popper.h" + +extern state_table * pop_get_command(); + +/* + * popper: Handle a Post Office Protocol version 3 session + */ +main (argc, argv) +int argc; +char ** argv; +{ + POP p; + state_table * s; + char message[MAXLINELEN]; + + /* Start things rolling */ + pop_init(&p,argc,argv); + + /* Tell the user that we are listenting */ + pop_msg(&p,POP_SUCCESS, + "UCB Pop server (version %s) with Kerberos (TM) at %s starting.", + VERSION,p.myhost); + + /* State loop. The POP server is always in a particular state in + which a specific suite of commands can be executed. The following + loop reads a line from the client, gets the command, and processes + it in the current context (if allowed) or rejects it. This continues + until the client quits or an error occurs. */ + + for (p.CurrentState=auth1;p.CurrentState!=halt&&p.CurrentState!=error;) { + + /* Obtain a line from the client */ + if (fgets(message,MAXLINELEN,p.input) == NULL) { + p.CurrentState = error; + pop_msg(&p,POP_FAILURE,"POP server at %s signing off.",p.myhost); + } + else { + /* Search for the command in the command/state table */ + if ((s = pop_get_command(&p,message)) == NULL) continue; + /* Call the function associated with this command in + the current state */ + if (s->function) p.CurrentState = s->result[(*s->function)(&p)]; + + /* Otherwise assume NOOP and send an OK message to the client */ + else { + p.CurrentState = s->success_state; + pop_msg(&p,POP_SUCCESS,NULL); + } + } + } + + + /* Say goodbye to the client */ + pop_msg(&p,POP_SUCCESS,"Pop server at %s signing off.",p.myhost); + + /* Log the end of activity */ + pop_log(&p,POP_DEBUG, + "%s: (v%s) Ending request from \"%s\".\n",p.ipaddr,VERSION,p.client); + + /* Stop logging */ + closelog(); + + return(0); +} + +#ifdef STRNCASECMP +/* + * Perform a case-insensitive string comparision + */ +#include +strncasecmp(str1,str2,len) +register char * str1; +register char * str2; +register int len; +{ + register int i; + char a, + b; + + for (i=len-1;i>=0;i--){ + a = str1[i]; + b = str2[i]; + if (isupper(a)) a = tolower(str1[i]); + if (isupper(b)) b = tolower(str2[i]); + if (a > b) return (1); + if (a < b) return(-1); + } + return(0); +} +#endif STRNCASECMP -- 2.26.2