home *** CD-ROM | disk | FTP | other *** search
/ Serving the Web / ServingTheWeb1995.disc1of1.iso / linux / slacksrce / d / libc / libc-4.6 / libc-4 / libc-linux / bsd / psignal.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-25  |  2.0 KB  |  70 lines

  1. /* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. #include <ansidecl.h>
  20. #include <stdio.h>
  21. #include <signal.h>
  22.  
  23.  
  24. #if !defined(HAVE_GNU_LD) && !defined (__ELF__)
  25. #define    _sys_siglist    sys_siglist
  26. #endif
  27.  
  28. #if NLS
  29. #include "nl_types.h"
  30. #endif
  31.  
  32. #ifndef linux
  33. /* Defined in sys_siglist.c.  */
  34. extern CONST char *CONST _sys_siglist[];
  35. #endif
  36.  
  37. /* Print out on stderr a line consisting of the test in S, a colon, a space,
  38.    a message describing the meaning of the signal number SIG and a newline.
  39.    If S is NULL or "", the colon and space are omitted.  */
  40. void
  41. DEFUN(psignal, (sig, s), int sig AND register CONST char *s)
  42. {
  43.   CONST char *colon;
  44.  
  45. #if NLS
  46.   libc_nls_init();
  47. #endif
  48.  
  49.   if (s == NULL || s == '\0')
  50.     s = colon = "";
  51.   else
  52.     colon = ": ";
  53.  
  54.   if (sig >= 0 && sig < NSIG)
  55. #if NLS
  56.     (void) fprintf(stderr, "%s%s%s\n", s, colon,
  57.        catgets(_libc_cat, SignalListSet, sig +1, (char *) _sys_siglist[sig]));
  58. #else
  59.     (void) fprintf(stderr, "%s%s%s\n", s, colon, _sys_siglist[sig]);
  60. #endif
  61.   else
  62. #if NLS
  63.     (void) fprintf(stderr, "%s%s%s %d\n", s, colon,
  64.            catgets(_libc_cat, SignalListSet, 1,  "Unknown signal"),
  65.            sig);
  66. #else
  67.     (void) fprintf(stderr, "%s%s%s %d\n", s, colon, "Unknown signal", sig);
  68. #endif
  69. }
  70.