home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / mm / mm-ccmd-0.91-20031009.tar.gz / mm-ccmd-0.91-20031009.tar / work / ccmd / cmcfm.c < prev    next >
C/C++ Source or Header  |  2002-02-18  |  3KB  |  95 lines

  1. /*
  2.  Copyright (c) 1986, 1990 by The Trustees of Columbia University in
  3.  the City of New York.  Permission is granted to any individual or
  4.  institution to use, copy, or redistribute this software so long as it
  5.  is not sold for profit, provided this copyright notice is retained.
  6.  
  7.  Author: Andrew Lowry
  8. */
  9. /* cmcfm
  10. **
  11. ** Code to parse command confirmation.  We succeed iff the next
  12. ** character is a newline.  Action routines for other confirming
  13. ** characters (like carriage return or formfeed) should insert
  14. ** a newline character for confirmation.  There is no completion.
  15. ** Standard break table breaks on every character.   A successful
  16. ** parse does not destroy the atom buffer.
  17. **/
  18.  
  19. #define    CFMERR            /* confirm error table allocated here */
  20.  
  21. #include "ccmdlib.h"        /* get standard symbols */
  22. #include "cmfncs.h"        /* and internal symbols */
  23.  
  24. /* Forward declaration of handler routines */
  25.  
  26. PASSEDSTATIC int cfmprs(), cfmhlp(), cfmcplt();
  27.         
  28. #define cfmbrk    cmallbk        /* std break table breaks on everything */
  29.  
  30. ftspec ft_cfm = { cfmprs, cfmhlp, cfmcplt, FT_DFX, &cfmbrk };
  31.  
  32. /* cfmprs
  33. **
  34. ** Purpose:
  35. **   Attempt to parse a confirmation.  Succeeds if the first character
  36. **   is a newline.  Any other character causes failure.  Returns no
  37. **   value.  A successful parse turns off the CM_CFM flag, as a side-
  38. **   effect.
  39. **/
  40.  
  41. PASSEDSTATIC int
  42. cfmprs(text,textlen,fdbp,parselen,value)
  43. char *text;
  44. int textlen;
  45. fdb *fdbp;
  46. int *parselen;
  47. pval *value;
  48. {
  49.   if (textlen == 0)            /* nothing to parse... */
  50.     return(CMxINC);            /* incomplete */
  51.   else if ((*text & CC_CHR) == NEWLINE) { /* found a newline... */
  52.     *parselen = 1;            /* consume one char */
  53.     cmcsb._cmflg |= CM_NAC;        /* no copy to atom buffer */
  54.     cmcsb._cmflg &= ~(CM_CFM|CM_ACT);    /* no longer confirmed, no pending
  55.                        action */
  56.     return(CMxOK);            /* and return success */
  57.   }
  58.   else
  59.     return(CFMxNOC);            /* anything else... error */
  60. }
  61.  
  62. /* cfmhlp
  63. **
  64. ** Purpose:
  65. **   Give standard help for a confirmation parse... always the same thing.
  66. **/
  67.  
  68. PASSEDSTATIC int
  69. cfmhlp(text,textlen,fdbp,cust,lines)
  70. char *text;
  71. int textlen,cust;
  72. fdb *fdbp;
  73. int lines;
  74. {
  75.   cmxputs("confirm with carriage return");
  76.   return(lines-1);
  77. }
  78.  
  79.  
  80. /* cfmcplt
  81. **
  82. ** Purpose:
  83. **   Completion for confirmation parse.  We always just beep at the user.
  84. **/
  85.  
  86. PASSEDSTATIC int
  87. cfmcplt(text,textlen,fdbp,full,cplt,cpltlen)
  88. char *text,**cplt;
  89. int textlen,full,*cpltlen;
  90. fdb *fdbp;
  91. {
  92.   *cplt = NULL;                /* no completion text */
  93.   return(CMP_BEL);                /* beep, no wakeup */
  94. }
  95.