# HG changeset patch # User Daniel J Sebald # Date 1370292549 18000 # Node ID c2245f69e3e1a5f0244d6287ae468261b4f02dbf # Parent 5a51fb7777a9950502965a043a70bd6ca5e0498b New routine to return all strings associated with system signals. * sig2str.h: Add typedef for char array of field width SIG2STR_MAX. Declare new routine allsigstr() that returns string array for all fields. * sig2str.c (allsigstr): Copy all signal definitions into array and return. diff --git a/lib/sig2str.c b/lib/sig2str.c --- a/lib/sig2str.c +++ b/lib/sig2str.c @@ -245,6 +245,18 @@ #define NUMNAME_ENTRIES (sizeof numname_table / sizeof numname_table[0]) +static char allname[NUMNAME_ENTRIES + 1][SIG2STR_MAX]; + +SigStr const * +allsigstr (void) +{ + unsigned int i; + for (i = 0; i < NUMNAME_ENTRIES; i++) + strcpy (allname[i], numname_table[i].name); + strcpy (allname[NUMNAME_ENTRIES], ""); + return allname; +} + /* ISDIGIT differs from isdigit, as follows: - Its arg may be any int or unsigned int; it need not be an unsigned char or EOF. diff --git a/lib/sig2str.h b/lib/sig2str.h --- a/lib/sig2str.h +++ b/lib/sig2str.h @@ -27,8 +27,16 @@ /* Size of a buffer needed to hold a signal name like "HUP". */ # define SIG2STR_MAX (sizeof "SIGRTMAX" + INT_STRLEN_BOUND (int) - 1) +#ifdef __cplusplus +extern "C" { +#endif int sig2str (int, char *); int str2sig (char const *, int *); +typedef char SigStr[SIG2STR_MAX]; +SigStr const * allsigstr (void); +#ifdef __cplusplus +} +#endif #endif