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[] = "@(#)@(#)pop_get_command.c	2.1  2.1 3/18/91";
  10: #endif not lint
  11: 
  12: #include <stdio.h>
  13: #include <sys/types.h>
  14: #include <strings.h>
  15: #include "popper.h"
  16: 
  17: /*
  18:  *  get_command:    Extract the command from an input line form a POP client
  19:  */
  20: 
  21: static state_table states[] = {
  22:         auth1,  "user", 1,  1,  pop_user,   {auth1, auth2},
  23:         auth2,  "pass", 1,  1,  pop_pass,   {auth1, trans},
  24: #ifdef RPOP
  25:         auth2,  "rpop", 1,  1,  pop_rpop,   {auth1, trans},
  26: #endif RPOP
  27:         auth1,  "quit", 0,  0,  pop_quit,   {halt,  halt},
  28:         auth2,  "quit", 0,  0,  pop_quit,   {halt,  halt},
  29:         trans,  "stat", 0,  0,  pop_stat,   {trans, trans},
  30:         trans,  "list", 0,  1,  pop_list,   {trans, trans},
  31:         trans,  "retr", 1,  1,  pop_send,   {trans, trans},
  32:         trans,  "dele", 1,  1,  pop_dele,   {trans, trans},
  33:         trans,  "noop", 0,  0,  NULL,       {trans, trans},
  34:         trans,  "rset", 0,  0,  pop_rset,   {trans, trans},
  35:         trans,  "top",  2,  2,  pop_send,   {trans, trans},
  36:         trans,  "last", 0,  0,  pop_last,   {trans, trans},
  37:         trans,  "xtnd", 1,  99, pop_xtnd,   {trans, trans},
  38:         trans,  "quit", 0,  0,  pop_updt,   {halt,  halt},
  39:         (state) 0,  NULL,   0,  0,  NULL,       {halt,  halt},
  40: };
  41: 
  42: state_table *pop_get_command(p,mp)
  43: POP             *   p;
  44: register char   *   mp;         /*  Pointer to unparsed line
  45:                                     received from the client */
  46: {
  47:     state_table     *   s;
  48:     char                buf[MAXMSGLINELEN];
  49: 
  50:     /*  Save a copy of the original client line */
  51: #ifdef DEBUG
  52:     if(p->debug) strcpy (buf,mp);
  53: #endif DEBUG
  54: 
  55:     /*  Parse the message into the parameter array */
  56:     if ((p->parm_count = pop_parse(p,mp)) < 0) return(NULL);
  57: 
  58:     /*  Do not log cleartext passwords */
  59: #ifdef DEBUG
  60:     if(p->debug){
  61:         if(strcmp(p->pop_command,"pass") == 0)
  62:             pop_log(p,POP_DEBUG,"Received: \"%s xxxxxxxxx\"",p->pop_command);
  63:         else {
  64:             /*  Remove trailing <LF> */
  65:             buf[strlen(buf)-2] = '\0';
  66:             pop_log(p,POP_DEBUG,"Received: \"%s\"",buf);
  67:         }
  68:     }
  69: #endif DEBUG
  70: 
  71:     /*  Search for the POP command in the command/state table */
  72:     for (s = states; s->command; s++) {
  73: 
  74:         /*  Is this a valid command for the current operating state? */
  75:         if (strcmp(s->command,p->pop_command) == 0
  76:              && s->ValidCurrentState == p->CurrentState) {
  77: 
  78:             /*  Were too few parameters passed to the command? */
  79:             if (p->parm_count < s->min_parms)
  80:                 return((state_table *)pop_msg(p,POP_FAILURE,
  81:                     "Too few arguments for the %s command.",p->pop_command));
  82: 
  83:             /*  Were too many parameters passed to the command? */
  84:             if (p->parm_count > s->max_parms)
  85:                 return((state_table *)pop_msg(p,POP_FAILURE,
  86:                     "Too many arguments for the %s command.",p->pop_command));
  87: 
  88:             /*  Return a pointer to the entry for this command in
  89:                 the command/state table */
  90:             return (s);
  91:         }
  92:     }
  93:     /*  The client command was not located in the command/state table */
  94:     return((state_table *)pop_msg(p,POP_FAILURE,
  95:         "Unknown command: \"%s\".",p->pop_command));
  96: }

Defined functions

pop_get_command defined in line 42; used 2 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: 2891
Valid CSS Valid XHTML 1.0 Strict