binerror.c

来自「linux下将各类格式图片转换工具」· C语言 代码 · 共 143 行

C
143
字号
/* *  error.c:		Error handling * *  Written by:		Stefan Frank *			Ullrich Hafner *   *  Credits:	Modelled after variable argument routines from Jef *		Poskanzer's pbmplus package.  * *  This file is part of FIASCO (獸籸actal 獻籱age 獳籲d 玈籩quence 獵O籨ec) *  Copyright (C) 1994-2000 Ullrich Hafner <hafner@bigfoot.de> *//* *  $Date: 2000/03/20 21:29:59 $ *  $Author: hafner $ *  $Revision: 4.3 $ *  $State: Exp $ */#define _BSD_SOURCE 1   /* Make sure strdup() is in string.h */#define _XOPEN_SOURCE 500  /* Make sure strdup() is in string.h */#define _ERROR_C#include "config.h"#include <stdio.h>#if STDC_HEADERS#	include <stdarg.h>#	define VA_START(args, lastarg) va_start(args, lastarg)#else  /* not STDC_HEADERS */#	include <varargs.h>#	define VA_START(args, lastarg) va_start(args)#endif /* not STDC_HEADERS */#include <string.h>#if HAVE_SETJMP_H#	include <setjmp.h>#endif /* HAVE_SETJMP_H */#include "fiasco.h"#include "binerror.h"/*****************************************************************************			     global variables  *****************************************************************************/int   error_line = 0;const char *error_file = NULL;/*****************************************************************************			     local variables  *****************************************************************************/static const char *executable = "(name not initialized)";/*****************************************************************************			       public code  *****************************************************************************/voidinit_error_handling (const char *name)/* *  Initialize filename of executable. * *  No return value. */{   if (name)      executable = strdup (name);}void_error (const char *format, ...)/* *  Print error message and exit. * *  No return value. */{   va_list	args;   VA_START (args, format);   fprintf (stderr, "%s: %s: line %d:\nError: ",	    executable, error_file, error_line);#if HAVE_VPRINTF   vfprintf (stderr, format, args);#elif HAVE_DOPRNT   _doprnt (format, args, stderr);#endif /* HAVE_DOPRNT */   fputc ('\n', stderr);   va_end(args);   exit (1);}void_file_error (const char *filename)/* *  Print file error message and exit. * *  No return value. */{   fprintf (stderr, "%s: %s: line %d:\nError: ",	    executable, error_file, error_line);   perror (filename);   exit (2);}void _warning (const char *format, ...)/* *  Issue a warning and continue execution. * *  No return value. */{   va_list args;   VA_START (args, format);   fprintf (stderr, "%s: %s: line %d:\nWarning: ",	    executable, error_file, error_line);#if HAVE_VPRINTF   vfprintf (stderr, format, args);#elif HAVE_DOPRNT   _doprnt (format, args, stderr);#endif /* HAVE_DOPRNT */   fputc ('\n', stderr);   va_end (args);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?