1: #include <X/mit-copyright.h>
   2: 
   3: /* Copyright    Massachusetts Institute of Technology    1985	*/
   4: 
   5: #ifndef lint
   6: static char *rcsid_xset_c = "$Header: xset.c,v 10.9 86/02/01 16:04:00 tony Rel $";
   7: #endif
   8: 
   9: #include <X/Xlib.h>
  10: #include <sys/types.h>
  11: #include <stdio.h>
  12: #include <netdb.h>
  13: #include <netinet/in.h>
  14: #include <strings.h>
  15: 
  16: #define TRUE 1
  17: #define FALSE 0
  18: 
  19: main(argc, argv)
  20:     int argc;
  21:     char **argv;
  22: {
  23:     char *disp = NULL;
  24:     register char *arg;
  25:     register int i;
  26:     int click, repeat, lock, bell, acc, thresh, video, timeout, cycle;
  27:     int doclick = FALSE, dorepeat = FALSE, dolock = FALSE;
  28:     int dobell = FALSE, domouse = FALSE, dosaver = FALSE;
  29:     int pixels[512];
  30:     caddr_t colors[512];
  31:     int numpixels = 0;
  32:     Color def;
  33: 
  34:     if (argc == 1)  usage(argv[0]);
  35: 
  36:     for (i = 1; i < argc; ) {
  37:     arg = argv[i];
  38:     i++;
  39:     if (strcmp(arg, "-c") == 0 || strcmp(arg, "-click") == 0) {
  40:         click = 0;
  41:         doclick = TRUE;
  42:     } else if (strcmp(arg, "c") == 0 || strcmp(arg, "click") == 0) {
  43:         click = 6;
  44:         doclick = TRUE;
  45:         if (i >= argc)
  46:         break;
  47:         arg = argv[i];
  48:         if (strcmp(arg, "on") == 0) {
  49:         i++;
  50:         } else if (strcmp(arg, "off") == 0) {
  51:         click = 0;
  52:         i++;
  53:         } else if (*arg >= '0' && *arg <= '8') {
  54:         click = atoi(arg);
  55:         i++;
  56:         }
  57:     } else if (strcmp(arg, "-b") == 0 || strcmp(arg, "-bell") == 0) {
  58:         bell = 0;
  59:         dobell = TRUE;
  60:     } else if (strcmp(arg, "b") == 0 || strcmp(arg, "bell") == 0) {
  61:         bell = 6;
  62:         dobell = TRUE;
  63:         if (i >= argc)
  64:         break;
  65:         arg = argv[i];
  66:         if (strcmp(arg, "on") == 0) {
  67:         i++;
  68:         } else if (strcmp(arg, "off") == 0) {
  69:         bell = 0;
  70:         i++;
  71:         } else if (*arg >= '0' && *arg <= '7') {
  72:         bell = atoi(arg);
  73:         i++;
  74:         }
  75:     } else if (strcmp(arg, "m") == 0 || strcmp(arg, "mouse") == 0) {
  76:         acc = 4;
  77:         thresh = 2;
  78:         domouse = TRUE;
  79:         if (i >= argc)
  80:         break;
  81:         arg = argv[i];
  82:         if (strcmp(arg, "default") == 0) {
  83:         i++;
  84:         } else if (*arg >= '0' && *arg <= '9') {
  85:         acc = atoi(arg);
  86:         i++;
  87:         if (i >= argc)
  88:             break;
  89:         arg = argv[i];
  90:         if (*arg >= '0' && *arg <= '9') {
  91:             thresh = atoi(arg);
  92:             i++;
  93:         }
  94:         }
  95:     } else if (strcmp(arg, "s") == 0 || strcmp(arg, "saver") == 0 ||
  96:            strcmp(arg, "v") == 0 || strcmp(arg, "video") == 0) {
  97:         timeout = 10;
  98:         cycle = 60;
  99:         video = *arg == 's' ? 1 : 0;
 100:         dosaver = TRUE;
 101:         if (i >= argc)
 102:         break;
 103:         arg = argv[i];
 104:         if (strcmp(arg, "default") == 0) {
 105:         i++;
 106:         } else if (*arg >= '0' && *arg <= '9') {
 107:         timeout = atoi(arg);
 108:         i++;
 109:         if (i >= argc)
 110:             break;
 111:         arg = argv[i];
 112:         if (*arg >= '0' && *arg <= '9') {
 113:             cycle = atoi(arg);
 114:             i++;
 115:         }
 116:         }
 117:     } else if (strcmp(arg, "-r") == 0 || strcmp(arg, "-repeat") == 0) {
 118:         repeat = FALSE;
 119:         dorepeat = TRUE;
 120:     } else if (strcmp(arg, "r") == 0 || strcmp(arg, "repeat") == 0) {
 121:         repeat = TRUE;
 122:         dorepeat = TRUE;
 123:         if (i >= argc)
 124:         break;
 125:         arg = argv[i];
 126:         if (strcmp(arg, "on") == 0) {
 127:         i++;
 128:         } else if (strcmp(arg, "off") == 0) {
 129:         repeat = FALSE;
 130:         i++;
 131:         }
 132:     } else if (strcmp(arg, "-l") == 0 || strcmp(arg, "-lock") == 0) {
 133:         lock = FALSE;
 134:         dolock = TRUE;
 135:     } else if (strcmp(arg, "l") == 0 || strcmp(arg, "lock") == 0) {
 136:         lock = TRUE;
 137:         dolock = TRUE;
 138:         if (i >= argc)
 139:         break;
 140:         arg = argv[i];
 141:         if (strcmp(arg, "on") == 0) {
 142:         i++;
 143:         } else if (strcmp(arg, "off") == 0) {
 144:         lock = FALSE;
 145:         i++;
 146:         }
 147:     } else if (strcmp(arg, "p") == 0 || strcmp(arg, "pixel") == 0) {
 148:         if (i + 1 >= argc)
 149:         usage(argv[0]);
 150:         arg = argv[i];
 151:         if (*arg >= '0' && *arg <= '9')
 152:         pixels[numpixels] = atoi(arg);
 153:         else
 154:         usage(argv[0]);
 155:         i++;
 156:         colors[numpixels] = argv[i];
 157:         i++;
 158:         numpixels++;
 159:     } else if (index(arg, ':')) {
 160:         disp = arg;
 161:     } else
 162:         usage(argv[0]);
 163:     }
 164:     if (!doclick && !dorepeat && !dolock && !dobell && !domouse && !dosaver &&
 165:     numpixels == 0)
 166:         usage(argv[0]);
 167: 
 168:     if (XOpenDisplay(disp) == NULL) {
 169:     fprintf(stderr, "%s: No such display %s!\n",argv[0],disp);
 170:     exit(1);
 171:     }
 172:     if (doclick) XKeyClickControl(click);
 173:     if (dolock) {
 174:     if (lock)  XLockToggle();
 175:     else XLockUpDown();
 176:     }
 177:     if (dorepeat) {
 178:     if (repeat) XAutoRepeatOn();
 179:     else XAutoRepeatOff();
 180:     }
 181:     if (dobell) XFeepControl(bell);
 182:     if (domouse) XMouseControl(acc, thresh);
 183:     if (dosaver) XScreenSaver(timeout, cycle, video);
 184:     if (DisplayCells() >= 2) {
 185:     while (--numpixels >= 0) {
 186:         def.pixel = pixels[numpixels];
 187:         if (XParseColor(colors[numpixels], &def))
 188:         XStoreColor(&def);
 189:         else
 190:         fprintf(stderr, "%s: No such color\n", colors[numpixels]);
 191:     }
 192:     }
 193:     XSync(0);
 194:     exit(0);
 195: }
 196: 
 197: usage(prog)
 198:     char *prog;
 199: {
 200:     printf("usage: %s option [option ...] [host:vs]\n", prog);
 201:     printf("    To turn bell off:\n");
 202:     printf("\t-b                b off               b 0\n");
 203:         printf("    To set bell volume:\n");
 204:         printf("\t b [1-7]          b on\n");
 205:         printf("    To turn keyclick off:\n");
 206:         printf("\t-c                c off               c 0\n");
 207:         printf("    To set keyclick volume:\n");
 208:         printf("\t c [1-8]          c on\n");
 209:         printf("    To turn shift-lock key off or on:\n");
 210:         printf("\t-l                l off\n");
 211:         printf("\t l                l on\n");
 212:         printf("    To set mouse acceleration and threshold:\n");
 213:         printf("\t m [acc [thr]]    m default\n");
 214:         printf("    To set pixel colors:\n");
 215:         printf("\t p pixel_value color_name\n");
 216:     printf("    To turn auto-repeat off or on:\n");
 217:         printf("\t-r                r off\n");
 218:         printf("\t r                r on\n");
 219:     printf("    To make the screen-saver display a pattern:\n");
 220:         printf("\t s [timeout [cycle]]  s default\n");
 221:     printf("    To make the screen-saver blank the video:\n");
 222:         printf("\t v [timeout [cycle]]  v default\n");
 223:         exit(0);
 224: }

Defined functions

main defined in line 19; never used
usage defined in line 197; used 5 times

Defined variables

rcsid_xset_c defined in line 6; never used

Defined macros

FALSE defined in line 17; used 10 times
TRUE defined in line 16; used 12 times
Last modified: 1986-02-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 899
Valid CSS Valid XHTML 1.0 Strict