-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1264 from i12momal/rama10
Replace bin in medium tests
- Loading branch information
Showing
25 changed files
with
1,874 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* errors.c -- error message handlers. | ||
Copyright (C) 1998 Robert Stone <[email protected]> | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2, or (at your option) | ||
any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | ||
|
||
#include <stdarg.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include <errno.h> | ||
#include "errors.h" | ||
#include "config.h" | ||
|
||
|
||
/* compatibility section */ | ||
#ifdef HAVE_SYSLOG_H | ||
# include <syslog.h> | ||
#else /* HAVE_SYSLOG_H */ | ||
#warning no syslog facility? Errors will go to stderr. | ||
# define syslog(x,y,z) | ||
# define LOG_DEBUG 7 | ||
# define LOG_WARNING 4 | ||
# define LOG_ERR 3 | ||
#endif | ||
|
||
#ifndef HAVE_VPRINTF | ||
#error no vprintf? not ANSI C3.159-1989 (``ANSI C'') compliant? | ||
#endif | ||
|
||
#ifndef HAVE_STRERROR | ||
#define strerror(x) "system error" | ||
#endif | ||
/* end compatibility section */ | ||
|
||
static char *progname = NULL; | ||
|
||
static int show_status = 0; | ||
static int use_syslog = 0; | ||
|
||
static int message(int, const char *); | ||
|
||
int initerrors(char *pn, int type, int stat) { | ||
#ifdef HAVE_SYSLOG_H | ||
if(type == 0 || type == 1) use_syslog = type; | ||
#endif /* HAVE_SYSLOG_H */ | ||
if(pn != NULL) progname = pn; | ||
if(stat == 0 || stat == 1) show_status = stat; | ||
return(0); | ||
} | ||
|
||
int status(const char *fmt, ...) { | ||
static char buf[1024]; | ||
va_list args; | ||
|
||
if(!show_status) return(0); | ||
va_start(args, fmt); | ||
vsprintf(buf, fmt, args); | ||
va_end(args); | ||
return(message(LOG_DEBUG, buf)); | ||
} | ||
|
||
int warn(const char *fmt, ...) { | ||
static char buf[1024]; | ||
va_list args; | ||
|
||
va_start(args, fmt); | ||
vsprintf(buf, fmt, args); | ||
va_end(args); | ||
return(message(LOG_WARNING, buf)); | ||
} | ||
|
||
int panic(const char *fmt, ...) { | ||
static char buf[1024]; | ||
va_list args; | ||
|
||
va_start(args, fmt); | ||
vsprintf(buf, fmt, args); | ||
va_end(args); | ||
message(LOG_ERR, buf); | ||
exit(1); | ||
} | ||
|
||
int message(int priority, const char *msg) { | ||
char buf[1024]; | ||
|
||
/* only handle errno if this is not an informational message */ | ||
if(errno && priority < 5) { | ||
sprintf(buf, "%s: %s", msg, strerror(errno)); | ||
errno = 0; | ||
} else strcpy(buf, msg); | ||
if(use_syslog) syslog(priority, "%s", buf); | ||
else fprintf(stderr, "%s: %s\n", progname, buf); | ||
return(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* errors.h -- error message handlers. | ||
Copyright (C) 1998 Robert Stone <[email protected]> | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2, or (at your option) | ||
any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | ||
|
||
#ifndef _HAVE_ERRORS_H | ||
#define _HAVE_ERRORS_H | ||
|
||
/* call initerrors before using these other functions | ||
* | ||
* these functions seem pretty straightforward to me, the messaging | ||
* functions take sprintf formatted strings and have a limit of | ||
* 1024 byte long error messages. | ||
* progname should be set to argv[0] | ||
* if progname is NULL, it is unchanged | ||
* type == 0 for stderr | ||
* type == 1 for syslog | ||
* otherwise type is unchanged | ||
* stat == 0 to skip status reporting | ||
* stat == 1 to print status messages | ||
* otherwise stat is unchanged | ||
* defaults: progname = NULL, type = 0, stat = 0 */ | ||
int initerrors(char *progname, int type, int stat); | ||
|
||
int status(const char *fmt, ...); | ||
/* print a status message */ | ||
|
||
int warn(const char *fmt, ...); | ||
/* print a warning message */ | ||
|
||
int panic(const char *fmt, ...); | ||
/* print an error and exit */ | ||
#endif |
Oops, something went wrong.