home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: SysTools / SysTools.zip / cimon096.zip / exit.c < prev    next >
C/C++ Source or Header  |  2002-04-05  |  993b  |  41 lines

  1. /* ----------------------------------------------------------------------
  2.    cimon - a UNIX command line client for the fli4l imon daemon.            
  3.  
  4.    Public domain, 2001-2002, Rene Herman <rene.herman@mail.com>         
  5. ---------------------------------------------------------------------- */
  6.  
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include <stdarg.h>
  10. #include <string.h>
  11. #include <errno.h>
  12.  
  13. #include "cimon.h"
  14.  
  15. const char *program_name;
  16.  
  17. void exit_error(const char * const format, ...)
  18. {
  19.     va_list ap;
  20.  
  21.     fprintf(stderr, "%s: ", program_name);  
  22.     va_start(ap, format);
  23.     vfprintf(stderr, format, ap);
  24.     va_end(ap);
  25.     fputc('\n', stderr);
  26.     exit(EXIT_FAILURE);  
  27. }
  28.  
  29. void exit_errno(const char * const msg)
  30. {
  31.     exit_error("%s: %s", msg, strerror(errno));
  32. }
  33.  
  34. void exit_usage (const char * const msg)
  35. {
  36.     if (msg)
  37.         fprintf(stderr, "%s: %s\n", program_name, msg);
  38.     fprintf(stderr, "Try `%s -h' for more information.\n", program_name);
  39.     exit(EXIT_FAILURE);
  40. }
  41.