|
|
1.1 ! root 1: #include <ctype.h> ! 2: #include <stdio.h> ! 3: ! 4: main(argc, argv) ! 5: char **argv; ! 6: { ! 7: FILE *f; ! 8: char s[120], c; ! 9: char testmode = 0; ! 10: char action; ! 11: char *strchr(); ! 12: ! 13: if(argc > 1 && !strcmp(argv[1], "-t")) ! 14: testmode = 1, ++argv, --argc; ! 15: ! 16: if(argc != 2) { fprintf(stderr, "usage: sdinit [-t] config_file\n"); exit(1); } ! 17: ! 18: f = fopen(argv[1], "r"); ! 19: if(!f) { ! 20: fprintf(stderr, "sdinit, cannot open %s\n", argv[1]); ! 21: exit(1); ! 22: } ! 23: ! 24: while(fgets(s, 120, f)) { ! 25: c = s[0]; ! 26: if(c == 0 || isspace(c)) continue; ! 27: ! 28: action = 28; /* key binding by default */ ! 29: if(isalpha(c) || isspace(s[1])) ! 30: action = 29; ! 31: if((c|0x20) == 'f' && isdigit(s[1])) ! 32: action = 28; ! 33: if(action == 28 && strchr(s, '<')) action = 31; ! 34: ! 35: s[strlen(s)-1] = 0; ! 36: printf("\33{%c%s\r", action+'@', s); ! 37: ! 38: if(testmode) { ! 39: printf("%s\n", s); ! 40: gets(s); ! 41: } ! 42: } ! 43: } /* main */ ! 44:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.