home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 3 / hamradioversion3.0examsandprograms1992.iso / packet / n17jsrc / devparam.c < prev    next >
C/C++ Source or Header  |  1991-03-16  |  1KB  |  73 lines

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