home *** CD-ROM | disk | FTP | other *** search
/ Nebula / nebula.bin / SourceCode / libcs / quit.c < prev    next >
C/C++ Source or Header  |  1990-12-11  |  2KB  |  68 lines

  1. /*
  2.  * Copyright (c) 1990 Carnegie Mellon University
  3.  * All Rights Reserved.
  4.  * 
  5.  * Permission to use, copy, modify and distribute this software and its
  6.  * documentation is hereby granted, provided that both the copyright
  7.  * notice and this permission notice appear in all copies of the
  8.  * software, derivative works or modified versions, and any portions
  9.  * thereof, and that both notices appear in supporting documentation.
  10.  *
  11.  * THE SOFTWARE IS PROVIDED "AS IS" AND CARNEGIE MELLON UNIVERSITY
  12.  * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  13.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO EVENT
  14.  * SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE FOR ANY SPECIAL, DIRECT,
  15.  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  16.  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  17.  * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  18.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  19.  *
  20.  * Users of this software agree to return to Carnegie Mellon any
  21.  * improvements or extensions that they make and grant Carnegie the
  22.  * rights to redistribute these changes.
  23.  *
  24.  * Export of this software is permitted only after complying with the
  25.  * regulations of the U.S. Deptartment of Commerce relating to the
  26.  * Export of Technical Data.
  27.  */
  28. /*
  29.  *  quit  --  print message and exit
  30.  *
  31.  *  Usage:  quit (status,format [,arg]...);
  32.  *    int status;
  33.  *    (... format and arg[s] make up a printf-arglist)
  34.  *
  35.  *  Quit is a way to easily print an arbitrary message and exit.
  36.  *  It is most useful for error exits from a program:
  37.  *    if (open (...) < 0) then quit (1,"Can't open...",file);
  38.  *
  39.  **********************************************************************
  40.  * HISTORY
  41.  * $Log:    quit.c,v $
  42.  * Revision 1.3  90/12/11  17:58:02  mja
  43.  *     Add copyright/disclaimer for distribution.
  44.  * 
  45.  * Revision 1.2  88/12/13  13:52:41  gm0w
  46.  *     Rewritten to use varargs.
  47.  *     [88/12/13            gm0w]
  48.  * 
  49.  **********************************************************************
  50.  */
  51.  
  52. #include <stdio.h>
  53. #include <varargs.h>
  54.  
  55. quit (status, fmt, va_alist)
  56. int status;
  57. char *fmt;
  58. va_dcl
  59. {
  60.     va_list args;
  61.  
  62.     fflush(stdout);
  63.     va_start(args);
  64.     (void) vfprintf(stderr, fmt, args);
  65.     va_end(args);
  66.     exit(status);
  67. }
  68.