ReactOS  0.4.14-dev-52-g6116262
comerr.c File Reference
#include <schily/mconfig.h>
#include <schily/unistd.h>
#include <schily/stdio.h>
#include <schily/stdlib.h>
#include <schily/standard.h>
#include <schily/varargs.h>
#include <schily/string.h>
#include <schily/schily.h>
#include <schily/errno.h>
Include dependency graph for comerr.c:

Go to the source code of this file.

Classes

struct  ex
 

Macros

#define silent_error(e)   ((e) < 0)
 

Typedefs

typedef struct ex ex_t
 

Functions

EXPORT int on_comerr __PR ((void(*fun)(int, void *), void *arg))
 
EXPORT void comerr __PR ((const char *,...))
 
EXPORT void xcomerr __PR ((int, const char *,...))
 
EXPORT void xcomerrno __PR ((int, int, const char *,...))
 
EXPORT int _comerr __PR ((FILE *, int, int, int, const char *, va_list))
 
LOCAL int _ex_clash __PR ((int))
 
EXPORT int on_comerr (void *func, void *arg)
 
EXPORT void comerr (char *msg, va_alist)
 
EXPORT void xcomerr (int exc, char *msg, va_alist)
 
EXPORT void comerrno (int err, char *msg, va_alist)
 
EXPORT void xcomerrno (int exc, int err, char *msg, va_alist)
 
EXPORT int errmsg (char *msg, va_alist)
 
EXPORT int errmsgno (int err, char *msg, va_alist)
 
EXPORT int _comerr (FILE *f, int exflg, int exc, int err, const char *msg, va_list args)
 
LOCAL int _ex_clash (int exc)
 
EXPORT void comexit (int err)
 
EXPORT charerrmsgstr (int err)
 

Variables

LOCAL ex_texfuncs
 

Macro Definition Documentation

◆ silent_error

#define silent_error (   e)    ((e) < 0)

Definition at line 256 of file comerr.c.

Typedef Documentation

◆ ex_t

typedef struct ex ex_t

Function Documentation

◆ __PR() [1/6]

EXPORT int on_comerr __PR ( (void(*fun)(int, void *), void *arg )

◆ __PR() [2/6]

EXPORT void comerr __PR ( (const char *,...)  )

◆ __PR() [3/6]

EXPORT void xcomerr __PR ( (int, const char *,...)  )

◆ __PR() [4/6]

EXPORT void xcomerrno __PR ( (int, int, const char *,...)  )

◆ __PR() [5/6]

EXPORT int _comerr __PR ( (FILE *, int, int, int, const char *, va_list )

◆ __PR() [6/6]

LOCAL int _ex_clash __PR ( (int )

◆ _comerr()

EXPORT int _comerr ( FILE f,
int  exflg,
int  exc,
int  err,
const char msg,
va_list  args 
)

Definition at line 259 of file comerr.c.

266 {
267  char errbuf[20];
268  char *errnam;
269  char *prognam = get_progname();
270 
271  if (silent_error(err)) {
272  js_fprintf(f, "%s: %r", prognam, msg, args);
273  } else {
274  errnam = errmsgstr(err);
275  if (errnam == NULL) {
276  (void) js_snprintf(errbuf, sizeof (errbuf),
277  "Error %d", err);
278  errnam = errbuf;
279  }
280  js_fprintf(f, "%s: %s. %r", prognam, errnam, msg, args);
281  }
282  if (exflg) {
283  if (exflg & COMERR_EXCODE)
284  err = exc;
285  else
286  err = _ex_clash(err);
287  comexit(err);
288  /* NOTREACHED */
289  }
290  return (err);
291 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
EXPORT char * errmsgstr(int err)
Definition: comerr.c:352
Definition: match.c:390
EXPORT int js_snprintf(char *buf, unsigned maxcnt, char *form, va_alist)
Definition: jssnprintf.c:62
#define silent_error(e)
Definition: comerr.c:256
smooth NULL
Definition: ftsmooth.c:416
GLfloat f
Definition: glext.h:7540
#define err(...)
EXPORT void comexit(int err)
Definition: comerr.c:331
EXPORT char * get_progname()
Definition: saveargs.c:151
EXPORT int js_fprintf(FILE *file, char *form, va_alist)
Definition: jsprintf.c:71
#define msg(x)
Definition: auth_time.c:54
LOCAL int _ex_clash(int exc)
Definition: comerr.c:294

Referenced by comerr(), comerrno(), errmsg(), errmsgno(), xcomerr(), and xcomerrno().

◆ _ex_clash()

LOCAL int _ex_clash ( int  exc)

Definition at line 294 of file comerr.c.

296 {
297  int exmod = exc % 256;
298 
299  /*
300  * On a recent POSIX System that supports waitid(), siginfo.si_status
301  * holds the exit(2) value as an int. So if waitid() is used to wait
302  * for the process, we do not have problems from folded exit codes.
303  * All other wait*() functions fold the exit code by masking it
304  * with 0377.
305  *
306  * Exit codes used with comerr*()/comexit() are frequently errno values
307  * that have been in the range 0..31 with UNIX.V5 in the mid 1970s and
308  * that now are in the range 0..151 on Solaris. These values do not
309  * cause problems from folding to 8 bits, but "sysexits.h" contains
310  * definitions in the range 64..79 that cause (even unfolded) clashes
311  * with errno values.
312  *
313  * To avoid clashes with errno values, "schily/standard.h" defines
314  * EX_BAD (-1) as default error exit code and
315  * EX_CLASH (-64) as marker for clashes.
316  * Exit codes in the range -2..-63 (254..193 seen as unsigned two's
317  * complement) are available as software specific exit codes.
318  * We map all other negative exit codes to EX_CLASH if they would fold
319  * to -2..-63.
320  */
321  if (exc != exmod && exmod <= 0 && exmod >= EX_CLASH)
322  exc = EX_CLASH;
323  return (exc);
324 }
#define EX_CLASH
Definition: standard.h:63

Referenced by _comerr().

◆ comerr()

EXPORT void comerr ( char msg,
va_alist   
)

Definition at line 84 of file comerr.c.

88 {
89  va_list args;
90 
91 #ifdef PROTOTYPES
92  va_start(args, msg);
93 #else
94  va_start(args);
95 #endif
96  (void) _comerr(stderr, COMERR_EXIT, 0, geterrno(), msg, args);
97  /* NOTREACHED */
98  va_end(args);
99 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
EXPORT int _comerr(FILE *f, int exflg, int exc, int err, const char *msg, va_list args)
Definition: comerr.c:259
Definition: match.c:390
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
EXPORT int geterrno()
Definition: geterrno.c:34
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define msg(x)
Definition: auth_time.c:54
FILE * stderr
#define args
Definition: format.c:66

Referenced by e_malloc(), e_strdup(), errconfig(), fill_boot_desc(), gen_add_list(), genboot_write(), get_graft(), get_ldate(), main(), merge_isofs(), readsecs(), scan_sparc_boot(), scan_sunx86_boot(), sunboot_write(), sunlabel_write(), and xfwrite().

◆ comerrno()

EXPORT void comerrno ( int  err,
char msg,
va_alist   
)

Definition at line 137 of file comerr.c.

142 {
143  va_list args;
144 
145 #ifdef PROTOTYPES
146  va_start(args, msg);
147 #else
148  va_start(args);
149 #endif
150  (void) _comerr(stderr, COMERR_EXIT, 0, err, msg, args);
151  /* NOTREACHED */
152  va_end(args);
153 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
EXPORT int _comerr(FILE *f, int exflg, int exc, int err, const char *msg, va_list args)
Definition: comerr.c:259
Definition: match.c:390
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
#define err(...)
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define msg(x)
Definition: auth_time.c:54
FILE * stderr
#define args
Definition: format.c:66

Referenced by add_CE_entry(), add_hash(), assign_file_addresses(), assign_inodes(), assign_linkcount(), compute_linkcount(), delete_directory(), do_inode(), errflags(), ex_boot_enoent(), file_gen(), fill_boot_desc(), find_or_create_directory(), finish_cl_pl_entries(), finish_cl_pl_for_prev_session(), genboot_size(), generate_joliet_path_tables(), generate_one_joliet_directory(), generate_path_tables(), generate_rr_extension_record(), generate_xa_rr_attributes(), get_723(), get_boot_addr(), get_boot_image(), get_boot_platid(), get_boot_size(), get_session_start(), get_torito_desc(), init_boot_catalog(), ldate_error(), main(), merge_old_directory_into_tree(), merge_previous_session(), parse_errctl(), parse_xa(), read_merging_directory(), scan_directory_tree(), scan_sparc_boot(), scan_sunx86_boot(), size_str_file(), sort_n_finish(), sunlabel_size(), tvd_write(), valid_iso_directory(), and xawrite().

◆ comexit()

EXPORT void comexit ( int  err)

Definition at line 331 of file comerr.c.

333 {
334  while (exfuncs) {
335  ex_t *fp;
336 
337  (*exfuncs->func)(err, exfuncs->arg);
338  fp = exfuncs;
339  exfuncs = exfuncs->next;
340  free(fp);
341  }
342  exit(err);
343  /* NOTREACHED */
344 }
Definition: comerr.c:44
#define free
Definition: debug_ros.c:5
void * arg
Definition: comerr.c:47
#define err(...)
struct ex * next
Definition: comerr.c:45
LOCAL ex_t * exfuncs
Definition: comerr.c:50
void exit(int exitcode)
Definition: _exit.c:33

Referenced by ___malloc(), ___realloc(), _comerr(), errabort(), and main().

◆ errmsg()

EXPORT int errmsg ( char msg,
va_alist   
)

Definition at line 192 of file comerr.c.

196 {
197  va_list args;
198  int ret;
199 
200 #ifdef PROTOTYPES
201  va_start(args, msg);
202 #else
203  va_start(args);
204 #endif
205  ret = _comerr(stderr, COMERR_RETURN, 0, geterrno(), msg, args);
206  va_end(args);
207  return (ret);
208 }
EXPORT int _comerr(FILE *f, int exflg, int exc, int err, const char *msg, va_list args)
Definition: comerr.c:259
Definition: match.c:390
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
EXPORT int geterrno()
Definition: geterrno.c:34
int ret
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define msg(x)
Definition: auth_time.c:54
FILE * stderr
#define args
Definition: format.c:66

Referenced by ___malloc(), ___realloc(), cmd_type(), gen_add_match(), generate_xa_rr_attributes(), get_module_version(), insert_file_entry(), main(), read_rcfile(), scan_directory_tree(), write_one_file(), and xmlFatalErr().

◆ errmsgno()

EXPORT int errmsgno ( int  err,
char msg,
va_alist   
)

Definition at line 219 of file comerr.c.

224 {
225  va_list args;
226  int ret;
227 
228 #ifdef PROTOTYPES
229  va_start(args, msg);
230 #else
231  va_start(args);
232 #endif
233  ret = _comerr(stderr, COMERR_RETURN, 0, err, msg, args);
234  va_end(args);
235  return (ret);
236 }
EXPORT int _comerr(FILE *f, int exflg, int exc, int err, const char *msg, va_list args)
Definition: comerr.c:259
Definition: match.c:390
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
int ret
#define err(...)
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define msg(x)
Definition: auth_time.c:54
FILE * stderr
#define args
Definition: format.c:66

Referenced by _errptr(), add_CE_entry(), assign_file_addresses(), assign_inodes(), check_rr_dates(), check_rr_relocation(), compare_dirs(), dir_nesting_warn(), errabort(), fill_boot_desc(), find_rr_attribute(), gen_add_match(), generate_joliet_path_tables(), generate_one_directory(), generate_one_joliet_directory(), generate_path_tables(), getH(), getL(), getP(), insert_file_entry(), iso9660_check(), joliet_compare_dirs(), joliet_sort_directory(), list_locales(), main(), merge_isofs(), parse_rr(), parse_rrflags(), parse_xa(), scan_directory_tree(), sort_directory(), sort_n_finish(), update_inode(), update_nlink(), write_one_file(), and xfwrite().

◆ errmsgstr()

EXPORT char* errmsgstr ( int  err)

Definition at line 352 of file comerr.c.

354 {
355 #ifdef HAVE_STRERROR
356  /*
357  * POSIX compliance may look strange...
358  */
359  int errsav = geterrno();
360  char *ret;
361 
362  seterrno(0);
363  ret = strerror(err);
364  err = geterrno();
365  seterrno(errsav);
366 
367  if (ret == NULL || err)
368  return (NULL);
369  return (ret);
370 #else
371  if (err < 0 || err >= sys_nerr) {
372  return (NULL);
373  } else {
374  return (sys_errlist[err]);
375  }
376 #endif
377 }
int sys_nerr
const char * strerror(int err)
Definition: compat_str.c:23
smooth NULL
Definition: ftsmooth.c:416
EXPORT int seterrno(int err)
Definition: seterrno.c:34
EXPORT int geterrno()
Definition: geterrno.c:34
int ret
#define err(...)
char * sys_errlist[]

Referenced by _comerr().

◆ on_comerr()

EXPORT int on_comerr ( void func,
void arg 
)

Definition at line 58 of file comerr.c.

61 {
62  ex_t *fp;
63 
64  fp = malloc(sizeof (*fp));
65  if (fp == NULL)
66  return (-1);
67 
68  fp->func = func;
69  fp->arg = arg;
70  fp->next = exfuncs;
71  exfuncs = fp;
72  return (0);
73 }
GLenum func
Definition: glext.h:6028
Definition: comerr.c:44
void * arg
Definition: msvc.h:12
void * arg
Definition: comerr.c:47
smooth NULL
Definition: ftsmooth.c:416
struct ex * next
Definition: comerr.c:45
LOCAL ex_t * exfuncs
Definition: comerr.c:50
#define malloc
Definition: debug_ros.c:4

◆ xcomerr()

EXPORT void xcomerr ( int  exc,
char msg,
va_alist   
)

Definition at line 110 of file comerr.c.

115 {
116  va_list args;
117 
118 #ifdef PROTOTYPES
119  va_start(args, msg);
120 #else
121  va_start(args);
122 #endif
123  (void) _comerr(stderr, COMERR_EXCODE, exc, geterrno(), msg, args);
124  /* NOTREACHED */
125  va_end(args);
126 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
EXPORT int _comerr(FILE *f, int exflg, int exc, int err, const char *msg, va_list args)
Definition: comerr.c:259
Definition: match.c:390
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
EXPORT int geterrno()
Definition: geterrno.c:34
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define msg(x)
Definition: auth_time.c:54
FILE * stderr
#define args
Definition: format.c:66

◆ xcomerrno()

EXPORT void xcomerrno ( int  exc,
int  err,
char msg,
va_alist   
)

Definition at line 164 of file comerr.c.

170 {
171  va_list args;
172 
173 #ifdef PROTOTYPES
174  va_start(args, msg);
175 #else
176  va_start(args);
177 #endif
178  (void) _comerr(stderr, COMERR_EXCODE, exc, err, msg, args);
179  /* NOTREACHED */
180  va_end(args);
181 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
EXPORT int _comerr(FILE *f, int exflg, int exc, int err, const char *msg, va_list args)
Definition: comerr.c:259
Definition: match.c:390
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
#define err(...)
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define msg(x)
Definition: auth_time.c:54
FILE * stderr
#define args
Definition: format.c:66

Variable Documentation

◆ exfuncs

LOCAL ex_t* exfuncs

Definition at line 50 of file comerr.c.

Referenced by comexit().