home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Mail / qpopper-2.4-MIHS / pop_get_subcommand.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-09-11  |  1.9 KB  |  71 lines

  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. /*
  8.  * Copyright (c) 1997 by Qualcomm Incorporated.
  9.  */
  10.  
  11.  
  12. #include <config.h>
  13. #include <stdio.h>
  14. #include <sys/types.h>
  15. #include <string.h>
  16.  
  17. #if HAVE_STRINGS_H
  18. #include <strings.h>
  19. #endif
  20.  
  21. #include <popper.h>
  22.  
  23. /* 
  24.  *  get_subcommand: Extract a POP XTND subcommand from a client input line
  25.  */
  26.  
  27. static xtnd_table subcommands[] = {
  28.         "xmit",     0,  0,  pop_xmit,
  29.     "xlst",        1,  2,  pop_xlst,
  30.         NULL
  31. };
  32.  
  33. xtnd_table *pop_get_subcommand(p)
  34. POP     *   p;
  35. {
  36.     xtnd_table      *   s;
  37.  
  38.     /*  Search for the POP command in the command/state table */
  39.     for (s = subcommands; s->subcommand; s++) {
  40.  
  41.         if (strcmp(s->subcommand,p->pop_subcommand) == 0) {
  42.  
  43.             /*  Were too few parameters passed to the subcommand? */
  44.             if ((p->parm_count-1) < s->min_parms) {
  45.                 pop_msg(p,POP_FAILURE,
  46.                     "Too few arguments for the %s %s command.",
  47.                         p->pop_command,p->pop_subcommand);
  48.                 return((xtnd_table *)0);
  49.             }
  50.             
  51.  
  52.             /*  Were too many parameters passed to the subcommand? */
  53.             if ((p->parm_count-1) > s->max_parms) {
  54.                 pop_msg(p,POP_FAILURE,
  55.                     "Too many arguments for the %s %s command.",
  56.                         p->pop_command,p->pop_subcommand);
  57.                 return((xtnd_table *)0);
  58.             }
  59.             
  60.  
  61.             /*  Return a pointer to the entry for this subcommand 
  62.                 in the XTND command table */
  63.             return (s);
  64.         }
  65.     }
  66.     /*  The client subcommand was not located in the XTND command table */
  67.     pop_msg(p,POP_FAILURE,
  68.             "Unknown command: \"%s %s\".",p->pop_command,p->pop_subcommand);
  69.     return((xtnd_table *)0);
  70. }
  71.