home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pine / ccmd / cmchar.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-19  |  1.7 KB  |  85 lines

  1. /*
  2.  Author: Howie Kaye
  3.  
  4.  Columbia University Center for Computing Activities, July 1986.
  5.  Copyright (C) 1986, 1987, Trustees of Columbia University in the City
  6.  of New York.  Permission is granted to any individual or institution
  7.  to use, copy, or redistribute this software so long as it is not sold
  8.  for profit, provided this copyright notice is retained.
  9. */
  10.  
  11.  
  12. /*
  13.  * cmchar
  14.  *
  15.  * This module contains a parse for a single character.
  16.  * it is trivial.  May be used when a single character of input is 
  17.  * required.
  18.  */
  19.  
  20. #define    CHARERR                /* char error table allocated here */
  21.  
  22. #include "ccmdlib.h"            /* get standard symbols */
  23. #include "cmfncs.h"            /* and internal symbols */
  24.  
  25. /*
  26.  * forward declare parse functions.
  27.  */
  28. int char_parse(), char_help(), char_cplt();
  29.  
  30. #define charbrk  cmallbk        /* break on everything. */
  31.  
  32. ftspec ft_char = { char_parse, char_help, char_cplt, 0, &charbrk };
  33.  
  34. /*
  35.  * char_parse:
  36.  * parse a single character.
  37.  */
  38. PASSEDSTATIC int
  39. char_parse(text, textlen, fdbp, parselen, value)
  40. char *text;
  41. int textlen;
  42. fdb *fdbp;
  43. int *parselen;
  44. pval *value;
  45. {
  46.   *parselen = 0;
  47.   if (textlen <= 1) return(CMxINC);    /* no data, no parse */
  48.   *parselen = 1;
  49.   value->_pvchr = text[0];
  50.   return(CMxOK);
  51. }
  52.  
  53. /*
  54.  * give a help message
  55.  */
  56.  
  57. PASSEDSTATIC int
  58. char_help(text, textlen, fdbp, cust)
  59. char *text;
  60. int textlen,cust;
  61. fdb *fdbp;
  62. {
  63.   if (!cust)
  64.     cmxputs("a character\n");    /* then print the token string */
  65.   return(CMxOK);
  66. }
  67.  
  68. /*
  69.  * character completion.  complete if one character
  70.  */
  71. PASSEDSTATIC int
  72. char_cplt(text,textlen,fdbp,full,cplt,cpltlen)
  73. char *text,**cplt;
  74. int textlen,full,*cpltlen;
  75. fdb *fdbp;
  76. {
  77.   *cplt = NULL; *cpltlen = 0;
  78.   if (textlen == 1) 
  79.     return(CMP_GO | CMP_SPC);
  80.   if (textlen == 0)
  81.     return(CMP_BEL);
  82.   else 
  83.     return(CMP_GO);
  84. }
  85.