From 3950ffe2a485479f6561c27364d3d7df5a21d124 Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Sun, 24 Jun 2012 22:28:35 +0000 Subject: Imported Upstream version 93u+ --- src/lib/libast/include/error.h | 182 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 src/lib/libast/include/error.h (limited to 'src/lib/libast/include/error.h') diff --git a/src/lib/libast/include/error.h b/src/lib/libast/include/error.h new file mode 100644 index 0000000..0253e4d --- /dev/null +++ b/src/lib/libast/include/error.h @@ -0,0 +1,182 @@ +/*********************************************************************** +* * +* This software is part of the ast package * +* Copyright (c) 1985-2011 AT&T Intellectual Property * +* and is licensed under the * +* Eclipse Public License, Version 1.0 * +* by AT&T Intellectual Property * +* * +* A copy of the License is available at * +* http://www.eclipse.org/org/documents/epl-v10.html * +* (with md5 checksum b35adb5213ca9657e911e9befb180842) * +* * +* Information and Software Systems Research * +* AT&T Research * +* Florham Park NJ * +* * +* Glenn Fowler * +* David Korn * +* Phong Vo * +* * +***********************************************************************/ +#pragma prototyped +/* + * Glenn Fowler + * AT&T Research + * + * option, error and message formatter external definitions + */ + +#ifndef _ERROR_H +#define _ERROR_H + +#include +#include +#include + +#define ERROR_VERSION 20070319L + +#if !defined(errno) && defined(__DYNAMIC__) +#define errno __DYNAMIC__(errno) +#endif + +#define ERROR_debug(n) (-(n)) +#define ERROR_exit(n) ((n)+ERROR_ERROR) +#define ERROR_system(n) (((n)+ERROR_ERROR)|ERROR_SYSTEM) +#define ERROR_usage(n) ((((n)?2:0)+ERROR_ERROR)|ERROR_USAGE) +#define ERROR_warn(n) (ERROR_WARNING) + +#ifndef ERROR_catalog +#define ERROR_catalog(t) t +#endif +#ifndef ERROR_dictionary +#define ERROR_dictionary(t) t +#endif + +#ifndef ERROR_translate +#define ERROR_translating() (error_info.translate&&(ast.locale.set&(1<= ERROR_ERROR count */ \ + int flags; /* context flags */ \ + int line; /* input|output line number */ \ + int warnings; /* ERROR_WARNING count */ \ + char* file; /* input|output file name */ \ + char* id; /* command id */ + +struct Error_context_s /* context stack element */ +{ + ERROR_CONTEXT +}; + +struct Error_info_s /* error state */ +{ + int fd; /* write(2) fd */ + + void (*exit)(int); /* error exit */ + ssize_t (*write)(int, const void*, size_t); /* error output */ + + /* the rest are implicitly initialized */ + + int clear; /* default clear ERROR_* flags */ + int core; /* level>=core -> core dump */ + int indent; /* debug trace indent level */ + int init; /* initialized */ + int last_errno; /* last reported errno */ + int mask; /* multi level debug trace mask */ + int set; /* default set ERROR_* flags */ + int trace; /* debug trace level */ + + char* version; /* ERROR_SOURCE command version */ + + int (*auxilliary)(Sfio_t*, int, int); /* aux info to append */ + + ERROR_CONTEXT /* top of context stack */ + + Error_context_t empty; /* empty context stack element */ + + unsigned long time; /* debug time trace */ + + char* (*translate)(const char*, const char*, const char*, const char*); /* format translator */ + + const char* catalog; /* message catalog */ +}; + +#ifndef errno +extern int errno; /* system call error status */ +#endif + +#if _BLD_ast && defined(__EXPORT__) +#define extern extern __EXPORT__ +#endif +#if !_BLD_ast && defined(__IMPORT__) +#define extern extern __IMPORT__ +#endif + +extern Error_info_t* _error_infop_; + +#define error_info (*_error_infop_) + +#undef extern + +#if _BLD_ast && defined(__EXPORT__) +#define extern __EXPORT__ +#endif + +extern void error(int, ...); +extern int errormsg(const char*, int, ...); +extern int errorf(void*, void*, int, ...); +extern void errorv(const char*, int, va_list); +#ifndef errorx +extern char* errorx(const char*, const char*, const char*, const char*); +#endif +extern Error_info_t* errorctx(Error_info_t*, int, int); + +#undef extern + +#endif -- cgit v1.2.3