home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / wp_dtp / xdme1820.lha / XDME / keyaddes.c < prev    next >
C/C++ Source or Header  |  1993-02-05  |  3KB  |  137 lines

  1. /******************************************************************************
  2.  
  3.     MODUL
  4.     keyaddes.c
  5.  
  6.     DESCRIPTION
  7.     additional keyboard support commands, which do
  8.     not need keyhashes.c
  9.  
  10.     NOTES
  11.     we only import keycodes.c
  12.  
  13.     BUGS
  14.  
  15.     TODO
  16.     (better) filtering commands
  17.  
  18.     EXAMPLES
  19.  
  20.     SEE ALSO
  21.  
  22.     INDEX
  23.  
  24.     HISTORY
  25.     16 Dec 1992 b_null created
  26.  
  27. ******************************************************************************/
  28.  
  29. /**************************************
  30.         Includes
  31. **************************************/
  32. #include "defs.h"
  33. extern int a2iqual (char *, long *); /* keycodes.c */
  34.  
  35.  
  36. /**************************************
  37.         Globale Variable
  38. **************************************/
  39. Prototype long ext_qualifiers;
  40. Prototype int  qualifier (char *);
  41.  
  42.  
  43. /**************************************
  44.       Interne Defines & Strukturen
  45. **************************************/
  46.  
  47.  
  48. /**************************************
  49.         Interne Variable
  50. **************************************/
  51. long ext_qualifiers = 0;
  52.  
  53.  
  54. /**************************************
  55.        Interne Prototypes
  56. **************************************/
  57.  
  58.  
  59. /*****************************************************************************
  60.  
  61.     NAME
  62.     qualifier
  63.  
  64.     PARAMETER
  65.     char * string
  66.  
  67.     RESULT
  68.     success
  69.  
  70.     RETURN
  71.     int
  72.  
  73.     DESCRIPTION
  74.     manually set some (additional) qualifiers without
  75.     respect to the keyboard;
  76.     it is possible to set/add/remove/AND/XOR some quals
  77.     due to the 1st char of string
  78.  
  79.     NOTES
  80.     make sure unused qualifiers do not disturb keycontrol.c
  81.  
  82.     BUGS
  83.     using ^ may cause definition of nused qualifiers,
  84.     but that should really not cause errors
  85.  
  86.     EXAMPLES
  87.  
  88.     SEE ALSO
  89.     keycodes.c/a2iqual
  90.  
  91.     INTERNALS
  92.  
  93.     HISTORY
  94.     16 Dec 1992 b_null created
  95.  
  96. ******************************************************************************/
  97.  
  98. int qualifier (char * string)
  99. {
  100.     long newquals = 0;
  101.     char mode      = 0;
  102.  
  103.     if (!string) {
  104.     return (0);
  105.     } /* if */
  106.  
  107.     switch (*string) {
  108.     case '+': mode =  1; string++; break;  /* add some additional quals */
  109.     case '-': mode =  2; string++; break;  /* remove some additional quals */
  110.     case '*': mode =  3; string++; break;  /* AND some additional quals */
  111.     case '/': mode =  4; string++; break;  /* XOR some additional quals */
  112.     default:  mode =  0;       break;  /* overwrite the old quals */
  113.     } /* switch */
  114.  
  115.     if (!a2iqual(string, &newquals)) {
  116.      return (0);
  117.     } /* if */
  118.  
  119.     switch (mode) { /* see above */
  120.     case 0: ext_qualifiers  =  newquals; break;
  121.     case 1: ext_qualifiers |=  newquals; break;
  122.     case 2: ext_qualifiers &= ~newquals; break;
  123.     case 3: ext_qualifiers &=  newquals; break;
  124.     case 4: ext_qualifiers ^=  newquals; break; /* highly dangerous: we may define unused bits */
  125.     } /* switch */
  126.  
  127.     return (1);
  128. } /* qualifier */
  129.  
  130.  
  131.  
  132.  
  133. /******************************************************************************
  134. *****  ENDE keyaddes.c
  135. ******************************************************************************/
  136.  
  137.