home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR3 / KA9Q212.ZIP / DEVPARAM.C < prev    next >
C/C++ Source or Header  |  1993-07-16  |  2KB  |  79 lines

  1. /****************************************************************************
  2. *    $Id: devparam.c 1.2 93/07/16 11:43:35 ROOT_DOS Exp $
  3. *    14 Jul 93    1.2        GT    Fix warnings.                                    *
  4. ****************************************************************************/
  5.  
  6. #include <string.h>
  7. #include <ctype.h>
  8. #include "global.h"
  9. #include "devparam.h"
  10.  
  11. struct param {
  12.     int number;
  13.     char *name;
  14. };
  15. static struct param Parms[] = {
  16.     { PARAM_DATA,    "Data" },
  17.     { PARAM_TXDELAY,    "TxDelay" },
  18.     { PARAM_PERSIST,    "Persist" },
  19.     { PARAM_SLOTTIME,    "SlotTime" },
  20.     { PARAM_TXTAIL,    "TxTail" },
  21.     { PARAM_FULLDUP,    "FullDup" },
  22.     { PARAM_HW,    "Hardware" },
  23.     { PARAM_MUTE,    "TxMute" },
  24.     { PARAM_DTR,    "DTR" },
  25.     { PARAM_RTS,    "RTS" },
  26.     { PARAM_SPEED,    "Speed" },
  27.     { PARAM_ENDDELAY,    "EndDelay" },
  28.     { PARAM_GROUP,    "Group" },
  29.     { PARAM_IDLE,    "Idle" },
  30.     { PARAM_MIN,    "Min" },
  31.     { PARAM_MAXKEY,    "MaxKey" },
  32.     { PARAM_WAIT,    "Wait" },
  33.     { PARAM_DOWN,    "Down" },
  34.     { PARAM_UP,    "Up" },
  35.     { PARAM_BLIND,    "Blind" },
  36.     { PARAM_RETURN,    "Return" },
  37.     { -1,        NULLCHAR },
  38. };
  39.     
  40. /* Convert a packet radio interface control token into a number
  41.  * Used by the various ioctl routines and by KISS TNC commands
  42.  */
  43. int
  44. devparam(s)
  45. char *s;
  46. {
  47.     int len;
  48.     struct param *sp;
  49.  
  50.     len = strlen(s);
  51.     if(isdigit(s[0]))
  52.         return atoi(s);
  53.  
  54.     sp = &Parms[0];
  55.     while(sp->number != -1){
  56.         if(strnicmp(s,sp->name,len) == 0)
  57.             return sp->number;
  58.         sp++;
  59.     }        
  60.     return -1;
  61. }
  62.  
  63. char *
  64. parmname(n)
  65. int n;
  66. {
  67.     struct param *sp;
  68.  
  69.     sp = &Parms[0];
  70.     while(sp->number != -1){
  71.         if(sp->number == n)
  72.             return sp->name;
  73.         sp++;
  74.     }        
  75.     return NULLCHAR;
  76. }
  77.  
  78.  
  79.