home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c023 / 1.img / PROGRAMS / CALLTYPE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1987-11-05  |  3.0 KB  |  122 lines

  1. /* (C) Copyright 1984,85,86,87 Walter L. Peacock   All Rights Reserved   */
  2. /****************************************************************************
  3.  *
  4.  *   calltype.c  --   get CBTREE call type
  5.  *
  6.  */
  7.  
  8. #include "cbtree.h"
  9.  
  10. #if AmigaDOS & LC
  11. #define printf iprintf
  12. #endif
  13.  
  14. #define TYPE_Y 7   /* cursor coordinates for prompt */
  15. #define TYPE_X 0
  16.  
  17. calltype()
  18. {
  19.    extern long atol();
  20. #if CI
  21. #else
  22.    extern int   atoi();
  23. #endif
  24.    extern int   strcmp();
  25.    extern int   strlen();
  26.    int calltype;
  27.    char callchar[8];
  28.    char *cp;
  29.    static struct
  30.    {
  31.       char *op_name;
  32.       int   op_value;
  33.    }
  34.    optypes[] =
  35.    {
  36.       {   "DELETE"   ,  DELETE   },   /* SORTED Alpa order */
  37.       {   "DELTKY"   ,  DELTKY   },
  38.       {   "GETALL"   ,  GETALL   },
  39.       {   "GETFRST" ,   GETFRST   },
  40.       {   "GETGE"   ,   GETGE   },
  41.       {   "GETGT"   ,   GETGT   },
  42.       {   "GETKEYS" ,   GETKEYS   },
  43.       {   "GETLAST" ,   GETLAST   },
  44.       {   "GETLE"   ,   GETLE   },
  45.       {   "GETLT"   ,   GETLT   },
  46.       {   "GETNXT"   ,  GETNXT   },
  47.       {   "GETPAR"   ,  GETPAR   },
  48.       {   "GETPRV"   ,  GETPRV   },
  49.       {   "GETREC"   ,  GETREC   },
  50.       {   "GETSEQ"   ,  GETSEQ   },
  51.       {   "INSERT"   ,  INSERT   },
  52.       {   "ISRTKY"   ,  ISRTKY   },
  53.       {   "NEWLOC"   ,  NEWLOC   },
  54.       {   "NEWIDX"  ,   0         }
  55.    };
  56.    int numtypes = sizeof(optypes)/sizeof(*optypes);   /* # optypes in array */
  57.    int i;
  58.  
  59. /*   scr_clr();   clear screen   */
  60.  
  61.    scr_curs(3, 0);
  62.    printf("     GETFRST    GETLAST    GETPRV     GETNXT     GETSEQ     GETREC\n");
  63.    printf("     GETPAR     GETALL     GETKEYS    GETLT      GETLE      GETGT \n");
  64.    printf("     GETGE      INSERT     ISRTKY     DELETE     DELTKY     NEWLOC     NEWIDX\n");
  65.  
  66.    scr_curs(7, 0);
  67.    printf("Enter CBTREE Call Type: NEWIDX_ ");
  68.  
  69.    /*** always get an optype ***/
  70.  
  71.    repeat
  72.    {
  73.       scr_curs(7, 24);
  74.       printf("NEWIDX_\b\b\b\b\b\b\b");
  75.       gets(callchar);
  76.       scr_curs(7, 24 + strlen(callchar));
  77.  
  78.       /* force to upper for match */
  79.       cp = callchar;
  80.       while ((*cp = toupper(*cp)) != NUL)
  81.          ++cp;
  82.  
  83.       /* cleanup the residue on entry line */
  84.       if (*callchar != NUL)   /* if something was entered */
  85.       {
  86.          printf("      \r");                  /* left overs */
  87.          if (*callchar == 'X')
  88.          {
  89.             calltype = 99;
  90.             break;
  91.          }
  92.       }
  93.       else
  94.       {
  95.          printf("NEWIDX \r");   /* refresh */
  96.          calltype = 0;               /* default to GETNXT */
  97.          break;
  98.       }
  99.  
  100.       for (i = 0; i < numtypes; ++i)
  101.       {
  102.          if (strcmp(callchar, optypes[i].op_name) == 0)
  103.             break;
  104.       }
  105.  
  106.       if (i < numtypes)
  107.          calltype = optypes[i].op_value;
  108.       else
  109.       {
  110.          calltype = 0;
  111.          continue;      /* error try again */
  112.       }
  113.  
  114.       if (calltype == 99)   /* exit */
  115.          break;
  116.    }
  117.    until( calltype >= 1   &&   calltype <= GETLE );
  118.  
  119.    return(calltype);
  120. }
  121.  
  122.