Changeset 3409 for trunk/src/kash/bld_signames.c
- Timestamp:
- Aug 13, 2020, 11:49:06 AM (5 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/bld_signames.c
r3408 r3409 1 /*2 * Fake sys_signame.3 */4 1 5 2 #include "shinstance.h" /* for MSC */ … … 7 4 #include <stdio.h> 8 5 9 static char sys_signame_initialized = 0; 10 char sys_signame[NSIG][16]; 6 int main(int argc, char **argv) 7 { 8 char aszSigName[NSIG][16]; 9 FILE *pFile; 10 int i; 11 11 12 void init_sys_signame(void) 13 { 14 unsigned i; 15 if (sys_signame_initialized) 16 return; 17 for (i = 0; i < NSIG; ++i) 18 sprintf(sys_signame[i], "%d", i); 19 #define SET_SIG_STR(sig) strcpy(sys_signame[SIG##sig], #sig); 12 if (argc != 2 || *argv[1] == '\0') 13 { 14 fprintf(stderr, "syntax error: Expected exactly one parameter, the output-file!\n"); 15 return 2; 16 } 17 18 /* 19 * Populate the name array. 20 */ 21 strcpy(aszSigName[0], "Signal 0"); 22 for (i = 1; i < NSIG; ++i) 23 sprintf(aszSigName[i], "%i", i); 24 25 #define SET_SIG_STR(sig) strcpy(aszSigName[SIG##sig], #sig); 20 26 #ifdef SIGHUP 21 27 SET_SIG_STR(HUP); 22 28 #endif 23 29 #ifdef SIGINT 24 30 SET_SIG_STR(INT); 25 31 #endif 26 32 #ifdef SIGQUIT 27 33 SET_SIG_STR(QUIT); 28 34 #endif 29 35 #ifdef SIGILL 30 36 SET_SIG_STR(ILL); 31 37 #endif 32 38 #ifdef SIGTRAP 33 39 SET_SIG_STR(TRAP); 34 40 #endif 35 41 #ifdef SIGABRT 36 42 SET_SIG_STR(ABRT); 37 43 #endif 38 44 #ifdef SIGIOT 39 45 SET_SIG_STR(IOT); 40 46 #endif 41 47 #ifdef SIGBUS 42 48 SET_SIG_STR(BUS); 43 49 #endif 44 50 #ifdef SIGFPE 45 51 SET_SIG_STR(FPE); 46 52 #endif 47 53 #ifdef SIGKILL 48 54 SET_SIG_STR(KILL); 49 55 #endif 50 56 #ifdef SIGUSR1 51 57 SET_SIG_STR(USR1); 52 58 #endif 53 59 #ifdef SIGSEGV 54 60 SET_SIG_STR(SEGV); 55 61 #endif 56 62 #ifdef SIGUSR2 57 63 SET_SIG_STR(USR2); 58 64 #endif 59 65 #ifdef SIGPIPE 60 66 SET_SIG_STR(PIPE); 61 67 #endif 62 68 #ifdef SIGALRM 63 69 SET_SIG_STR(ALRM); 64 70 #endif 65 71 #ifdef SIGTERM 66 72 SET_SIG_STR(TERM); 67 73 #endif 68 74 #ifdef SIGSTKFLT 69 75 SET_SIG_STR(STKFLT); 70 76 #endif 71 77 #ifdef SIGCHLD 72 78 SET_SIG_STR(CHLD); 73 79 #endif 74 80 #ifdef SIGCONT 75 81 SET_SIG_STR(CONT); 76 82 #endif 77 83 #ifdef SIGSTOP 78 84 SET_SIG_STR(STOP); 79 85 #endif 80 86 #ifdef SIGTSTP 81 87 SET_SIG_STR(TSTP); 82 88 #endif 83 89 #ifdef SIGTTIN 84 90 SET_SIG_STR(TTIN); 85 91 #endif 86 92 #ifdef SIGTTOU 87 93 SET_SIG_STR(TTOU); 88 94 #endif 89 95 #ifdef SIGURG 90 96 SET_SIG_STR(URG); 91 97 #endif 92 98 #ifdef SIGXCPU 93 99 SET_SIG_STR(XCPU); 94 100 #endif 95 101 #ifdef SIGXFSZ 96 102 SET_SIG_STR(XFSZ); 97 103 #endif 98 104 #ifdef SIGVTALRM 99 105 SET_SIG_STR(VTALRM); 100 106 #endif 101 107 #ifdef SIGPROF 102 108 SET_SIG_STR(PROF); 103 109 #endif 104 110 #ifdef SIGWINCH 105 111 SET_SIG_STR(WINCH); 106 112 #endif 107 113 #ifdef SIGIO 108 114 SET_SIG_STR(IO); 109 115 #endif 110 116 #ifdef SIGPWR 111 117 SET_SIG_STR(PWR); 112 118 #endif 113 119 #ifdef SIGSYS 114 120 SET_SIG_STR(SYS); 115 121 #endif 116 122 #ifdef SIGBREAK 117 123 SET_SIG_STR(BREAK); 118 124 #endif 119 125 #undef SET_SIG_STR 120 sys_signame_initialized = 1; 126 127 /* 128 * Write out the list. 129 */ 130 pFile = fopen(argv[1], "w"); 131 if (!pFile) 132 { 133 fprintf(stderr, "error: failed to open '%s' for writing\n", argv[1]); 134 return 1; 135 } 136 fputs("/* autogenerate */\n" 137 "\n" 138 "#include \"shinstance.h\"\n" 139 "\n" 140 "const char * const sys_signame[NSIG] = \n" 141 "{\n" 142 , pFile); 143 for (i = 0; i < NSIG; i++) 144 fprintf(pFile, " \"%s\",\n", aszSigName[i]); 145 fputs("};\n", pFile); 146 147 if (fclose(pFile) != 0) 148 { 149 fprintf(stderr, "error: error writing/closing '%s' after writing it\n", argv[1]); 150 return 1; 151 } 152 return 0; 121 153 } 122 154 123 #if defined(_MSC_VER)124 const char *strsignal(int iSig)125 {126 if (!sys_signame_initialized)127 init_sys_signame();128 if (iSig < NSIG)129 return sys_signame(iSig);130 return NULL;131 }132 #endif133
Note:
See TracChangeset
for help on using the changeset viewer.