home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / unix / gawk.sit / source / missing.d / strerror.c < prev    next >
Text File  |  1990-07-29  |  1KB  |  46 lines

  1. /*
  2.  * strerror.c --- ANSI C compatible system error routine
  3.  */
  4.  
  5. /* 
  6.  * Copyright (C) 1986, 1988, 1989 the Free Software Foundation, Inc.
  7.  * 
  8.  * This file is part of GAWK, the GNU implementation of the
  9.  * AWK Progamming Language.
  10.  * 
  11.  * GAWK is free software; you can redistribute it and/or modify
  12.  * it under the terms of the GNU General Public License as published by
  13.  * the Free Software Foundation; either version 1, or (at your option)
  14.  * any later version.
  15.  * 
  16.  * GAWK is distributed in the hope that it will be useful,
  17.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19.  * GNU General Public License for more details.
  20.  * 
  21.  * You should have received a copy of the GNU General Public License
  22.  * along with GAWK; see the file COPYING.  If not, write to
  23.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  */
  25.  
  26. extern int sys_nerr;
  27. extern char *sys_errlist[];
  28.  
  29. /* have to get right decl of sprintf early on */
  30. #ifndef BUFSIZ    /* stdio specific definition */
  31. #include <stdio.h>
  32. #endif
  33.  
  34. char *
  35. strerror(n)
  36. int n;
  37. {
  38.     static char mesg[30];
  39.  
  40.     if (n < 0 || n > sys_nerr) {
  41.         sprintf (mesg, "Unknown error (%d)", n);
  42.         return mesg;
  43.     } else
  44.         return sys_errlist[n];
  45. }
  46.