home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff319.lzh / CNewsSrc / cnews.src.lzh / libc / warning.c < prev   
C/C++ Source or Header  |  1980-01-01  |  634b  |  30 lines

  1. /*
  2.  * warning - print best error message possible and clear errno
  3.  */
  4.  
  5. #include <stdio.h>
  6.  
  7. void
  8. warning(s1, s2)
  9. char *s1;
  10. char *s2;
  11. {
  12.     char *cmdname;
  13.     extern int errno, sys_nerr;
  14.     extern char *sys_errlist[];
  15.     extern char *progname;
  16.     extern char *getenv();
  17.  
  18.     (void) fflush(stdout);                /* hack */
  19.     cmdname = getenv("CMDNAME");
  20.     if (cmdname != NULL && *cmdname != '\0')
  21.         fprintf(stderr, "%s:", cmdname);    /* No space after :. */
  22.     if (progname != NULL)
  23.         fprintf(stderr, "%s: ", progname);
  24.     fprintf(stderr, s1, s2);
  25.     if (errno > 0 && errno < sys_nerr)
  26.         fprintf(stderr, " (%s)", sys_errlist[errno]);
  27.     fprintf(stderr, "\n");
  28.     errno = 0;
  29. }
  30.