1: /*
   2:  * Copyright (c) 1989 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifndef lint
   8: static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
   9: static char SccsId[] = "@(#)@(#)popper.c	2.1  2.1 3/18/91";
  10: #endif not lint
  11: 
  12: #include <stdio.h>
  13: #include <sys/types.h>
  14: #include "popper.h"
  15: 
  16: extern  state_table *   pop_get_command();
  17: 
  18: /*
  19:  *  popper: Handle a Post Office Protocol version 3 session
  20:  */
  21: main (argc, argv)
  22: int         argc;
  23: char    **  argv;
  24: {
  25:     POP                 p;
  26:     state_table     *   s;
  27:     char                message[MAXLINELEN];
  28: 
  29:     /*  Start things rolling */
  30:     pop_init(&p,argc,argv);
  31: 
  32:     /*  Tell the user that we are listenting */
  33:     pop_msg(&p,POP_SUCCESS,
  34:         "UCB Pop server (version %s) at %s starting.",VERSION,p.myhost);
  35: 
  36:     /*  State loop.  The POP server is always in a particular state in
  37:         which a specific suite of commands can be executed.  The following
  38:         loop reads a line from the client, gets the command, and processes
  39:         it in the current context (if allowed) or rejects it.  This continues
  40:         until the client quits or an error occurs. */
  41: 
  42:     for (p.CurrentState=auth1;p.CurrentState!=halt&&p.CurrentState!=error;) {
  43: 
  44:         /*  Obtain a line from the client */
  45:         if (fgets(message,MAXLINELEN,p.input) == NULL) {
  46:             p.CurrentState = error;
  47:             pop_msg(&p,POP_FAILURE,"POP server at %s signing off.",p.myhost);
  48:         }
  49:         else {
  50:             /*  Search for the command in the command/state table */
  51:             if ((s = pop_get_command(&p,message)) == NULL) continue;
  52: 
  53:             /*  Call the function associated with this command in
  54:                 the current state */
  55:             if (s->function) p.CurrentState = s->result[(*s->function)(&p)];
  56: 
  57:             /*  Otherwise assume NOOP and send an OK message to the client */
  58:             else {
  59:                 p.CurrentState = s->success_state;
  60:                 pop_msg(&p,POP_SUCCESS,NULL);
  61:             }
  62:         }
  63:     }
  64: 
  65:     /*  Say goodbye to the client */
  66:     pop_msg(&p,POP_SUCCESS,"Pop server at %s signing off.",p.myhost);
  67: 
  68:     /*  Log the end of activity */
  69:     pop_log(&p,POP_PRIORITY,
  70:         "(v%s) Ending request from \"%s\" at %s\n",VERSION,p.client,p.ipaddr);
  71: 
  72:     /*  Stop logging */
  73:     closelog();
  74: 
  75:     return(0);
  76: }
  77: 
  78: #ifdef STRNCASECMP
  79: /*
  80:  *  Perform a case-insensitive string comparision
  81:  */
  82: #include <ctype.h>
  83: strncasecmp(str1,str2,len)
  84: register char   *   str1;
  85: register char   *   str2;
  86: register int        len;
  87: {
  88:     register int    i;
  89:     char            a,
  90:                     b;
  91: 
  92:     for (i=len-1;i>=0;i--){
  93:         a = str1[i];
  94:         b = str2[i];
  95:         if (isupper(a)) a = tolower(str1[i]);
  96:         if (isupper(b)) b = tolower(str2[i]);
  97:         if (a > b) return (1);
  98:         if (a < b) return(-1);
  99:     }
 100:     return(0);
 101: }
 102: #endif STRNCASECMP

Defined functions

main defined in line 21; never used
strncasecmp defined in line 83; used 1 times

Defined variables

SccsId defined in line 9; never used
copyright defined in line 8; never used
Last modified: 1991-04-04
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1208
Valid CSS Valid XHTML 1.0 Strict