Top   Types   Functions   Classes   Index   Sources 

include/liberror.h


   1  /* -*- Mode: C -*- */
   2  
   3  /*! section -2: Overview / Features
   4   *
   5   * +---------------+-------------------+
   6   * |! Author       | Henrik Theiling   |
   7   * |! Description  | Message printing  |
   8   * +---------------+-------------------+
   9   *
  10   * Features
  11   * --------
  12   *     - message ids
  13   *         - assigned by a script and stored in a data base in cvs
  14   *     - output streams
  15   *         - different ones for each type of message
  16   *         - multiple streams
  17   *     - counting
  18   *         - different counters per tag, group, subsystem, id
  19   *         - different counters for different events:
  20   *               received, issued, distributed, shown,
  21   *               buffered, printed.
  22   *     - filtering
  23   *         - by type of message (group, subsystem, tag)
  24   *         - by id of message
  25   *         - per stream (also by type & id)
  26   *         - per stream: print messages only once
  27   *         - different levels of filtering:
  28   *              - so that counting is suppressed (-> issue filter)
  29   *              - so that messages are invisible (-> show  filter)
  30   *              - per stream printing decision   (-> print filter)
  31   *     - buffering
  32   *         - for locally suppressing messages
  33   *         - for postponing and re-filtering messages
  34   *     - callbacks
  35   *         - for user extensions
  36   *         - for systems that lack stderr
  37   *         - for graphical environments
  38   *     - styles
  39   *         - customisable by the user
  40   *         - for colour tags, HTML messages, etc.
  41   *     - 'address' resolving:
  42   *         - For 'address' to file, line, pos-mapping, user plug-in
  43   *           may be used
  44   *         - here, 'address' may be any concept of source code
  45   *           location: you can provide your own format function.
  46   *     - C and C++ support
  47   *     - substitute of clib's printf family to have advantages
  48   *       of Erwin format: consistency between platforms, quotation,
  49   *       NULL-handling: %s prints NULL, 0x%Lx etc.
  50   *       FILE* may be NULL to suppress output
  51   *       The family is called *xprintf: fxprintf, vxprintf, snxprintf, etc.
  52   */
  53  
  54  /* err-default scope=project */
  55  
  56  #ifndef HT_LIBERROR_2932_H
  57  #define HT_LIBERROR_2932_H
  58  
  59  #ifndef HAVE_LIBERROR
  60  #define HAVE_LIBERROR 1
  61  #endif
  62  
  63  /*
  64   * Includes */
  65  #include <stdarg.h>
  66  #include <stdio.h>
  67  
  68  #ifdef IN_LIBERROR_COMPILE
  69  #include "error/erwin/defs.h"
  70  #include "error/version.h"
  71  #include "error/symbol.h"
  72  #else
  73  #include <error/erwin/defs.h>
  74  #include <error/version.h>
  75  #include <error/symbol.h>
  76  #endif
  77  
  78  #ifndef ERR_HAVE_STDERR
  79  #  ifdef ERWIN_DOS
  80  #    if defined(SUBSYSTEM_CONSOLE)
  81  #      define ERR_HAVE_STDERR 1
  82         /* we have stderr on the console under Windows. */
  83  #    endif
  84  #  else
  85  #    define ERR_HAVE_STDERR 1
  86       /* assume stderr always exists on other platforms */
  87  #  endif
  88  #endif
  89  
  90  #ifdef IN_LIBERROR_COMPILE
  91  
  92  #  include "error/err-config.h"
  93  #  include "error/erwin/erwin.h"
  94  #  include "error/tags.h"
  95  #  include "error/printf.h"
  96     /* Styles: */
  97  #  include "error/style.h"
  98       /* Plain: */
  99  #    include "error/style-colon.h"
 100  #    include "error/style-quotes.h"
 101  #      include "error/style-plain.h"
 102       /* Qt: */
 103  #    include "error/style-qt.h"
 104  #    include "error/style-qt3.h"
 105     /* Assertions (implementation only): */
 106  #  include "error/assert.h"
 107  
 108  #else
 109  
 110  #  include <error/err-config.h>
 111  #  include <error/erwin/erwin.h>
 112  #  include <error/tags.h>
 113  #  include <error/printf.h>
 114     /* Styles: */
 115  #  include <error/style.h>
 116       /* Plain: */
 117  #    include <error/style-colon.h>
 118  #    include <error/style-quotes.h>
 119  #      include <error/style-plain.h>
 120       /* Qt: */
 121  #    include <error/style-qt.h>
 122  #    include <error/style-qt3.h>
 123  
 124  #endif
 125  
 126  /* Color tags are defined in        <error/tags.h>    */
 127  /* Print functions are defined in   <error/printf.h> */
 128  /* Error style handling is defined  <error/style.h>   */
 129  
 130  #ifdef ERWIN_DOS
 131  
 132  #  define err_crash() abort()
 133  
 134  #else
 135  
 136  #  define err_crash() err_crash_aux()
 137     /* The normal glibc abort() does not seem to produce a stack backtrace
 138      * in the core anymore!?
 139      * An ordinary SIGSEGV, however, does.  So we will abort that way. */
 140  
 141  #endif
 142  
 143  /* ********************************************************************** */
 144  /* Some typical error messages: */
 145  
 146  #define ERR_OPEN_READ       "Unable to open file '%s' for reading.\nReason: %m."
 147  #define ERR_OPEN_WRITE      "Unable to open file '%s' for writing.\nReason: %m."
 148  #define ERR_OPEN_READWRITE  "Unable to open file '%s' for reading and writing.\nReason: %m."
 149  #define ERR_OPEN_APPEND     "Unable to open file '%s' for appending.\nReason: %m."
 150     /* Example of usage:
 151      *
 152      *    : eprintf (C_TAG_ERR, 517, ERR_OPEN_READ, filename);
 153      *
 154      * To trigger an exit(1) automatically, use C_TAG_FATAL:
 155      *
 156      *    : FILE *f= fopen (filename, "rt");
 157      *    : if (!f)
 158      *    :     eprintf (C_TAG_FATAL, 0, ERR_OPEN_READ, filename);
 159      *
 160      * Please don't use FATAL for file open errors inside libraries!
 161      *
 162      * NOTE: The format strings only work with Erwin formatting functions (e.g. all
 163      *       error printing functions of this library), since they contain the GNU
 164      *       extension %m, which Erwin implements, but your LibC is not likely to do
 165      *       unless you have a GLibC.
 166      */
 167  
 168  #ifndef NDEBUG
 169  #define ERR_TRACE  eprintf (C_TAG_DEBUG, 0, __FILE__, __LINE__, "reached.\n")
 170  #else
 171  #define ERR_TRACE
 172  #endif
 173  
 174  /* ********************************************************************** */
 175  /* Declarations */
 176  
 177  #ifdef __cplusplus
 178  extern "C" {
 179  #endif
 180  
 181  extern volatile int err_continue;
 182  
 183  extern char const *err_callbacks_only; /* for compatibility */
 184  #define ERR_CALLBACKS_ONLY "\1"
 185     /* use this format string if you want no message but only
 186      * invocation of the callbacks */
 187  
 188  /* Set-up */
 189  extern void err_init (int *, char ***);
 190     /*
 191      * In contrast to many other libraries that use Erwin, the invocation
 192      * of this function is not needed.  However, the error output is
 193      * improved if you invoke this (e.g., the program name is output).
 194      * If you do not invoke this, then the library also sets up a default
 195      * output stream to stderr.  This is convenient for testing (simply
 196      * link -lerror and there you go).
 197      *
 198      * Furthermore, if you do not invoke err_init(), you are only allowed
 199      * *printf functions, but no other functions from this library.
 200      *
 201      * In total, it is highly advisable to invoke err_init() at the beginning
 202      * of your program.
 203      *
 204      * Typical invocation:
 205      *
 206      *   : err_init (&argc, &argv);
 207      *
 208      * If you want a progname different from the base name in argv[0] (under DOS
 209      * without .exe), then invoke err_set_progname with the desired name.
 210      *
 211      * IMPORTANT NOTE:
 212      *    If you invoke err_init, then by default, no output stream is
 213      *    set, so no error messages are ever seen!  So typically, you
 214      *    will set a default error stream directly after the above
 215      *    invocation.  E.g.:
 216      *
 217      *     : err_add_stream (C_TAG_ALL, stderr, NULL);
 218      *
 219      *    Please only give a non-NULL error style if you know what
 220      *    you are doing.  E.g. if you do set the style here,
 221      *    the user cannot set it from the command line anymore.
 222      *    Usually, plain style is the default, but can be set
 223      *    differently.  err_init() parses part of the command
 224      *    line to check user settings.
 225      */
 226  
 227  extern char const *err_progname (void);
 228     /* Return current setting of progname.  See err_set_progname(). */
 229  
 230  extern void err_set_progname (char const *);
 231     /* Getting and setting the program name that is displayed
 232      *
 233      * You are uncouraged to invoke err_set_progname before err_init,
 234      * but then you must ensure that the string you pass is not
 235      * deallocated.
 236      * (If you invoke the function after err_init, you may do so
 237      * even with temporary strings.)
 238      *
 239      * Invoking err_set_progname before init makes the library
 240      * parse another environment variable ("ERR_OPTIONS_"
 241      * concatenated with the program name in upper case) specific to
 242      * the application.
 243      */
 244  
 245  extern int err_pid (void);
 246     /* Return current setting of pid.  See err_set_pid().
 247      *
 248      * If no PID is known, returns -1.
 249      */
 250  
 251  extern void err_set_pid (int /*pid*/);
 252     /* Getting and setting the PID that is displayed.
 253      *
 254      * Under Unix, the PID that is displayed defaults to the value
 255      * of getpid().  Under Windos, there is currently no PID
 256      * default.  This can be overridden with this function.
 257      *
 258      * Note that there is a command line option 'show-pid' that
 259      * decides whether the PID is displayed.
 260      */
 261  
 262  extern char const *err_config_prefix(void);
 263     /* Return current config prefix.  See err_set_config_prefix(). */
 264  
 265  extern void err_set_config_prefix(char const *);
 266     /* Getting and settings the prefix by which the error library is configured,
 267      * i.e., the prefix for the environment variables it reads from and the
 268      * command line options.  By default, this is "err".  It is converted
 269      * to upper case for the environment variables, thus "ERR" is the default
 270      * there.  Further, if this is non-empty, a "-" is inserted
 271      * in the command line options and a "_" in the environment variables.
 272      * Therefore, the default environment variable is "ERR_OPTIONS" and the
 273      * default prefix for command line options is "--err-".
 274      *
 275      * Setting this is NULL effectively resets the prefix to "msg".
 276      *
 277      * Note: the default used to be "err" in older versions.
 278      *
 279      * Using "msg" is recommended, since this refers to more than errors.
 280      * "err" is merely a historic misnomer.
 281      *
 282      * The prefix must be set before an invocation to err_init(), otherwise,
 283      * it has no effect.
 284      */
 285  
 286  typedef void (*ErrAddressResolver)(int, int, int, err_position_t *);
 287  
 288  extern void err_unset_resolve_address (void);
 289     /* Unsets the current resolver set with err_set_resolve_address() */
 290  
 291  extern void err_set_resolve_address   (ErrAddressResolver);
 292     /* Sets a user-provided callback for resolving addresses, i.e.,
 293      * to look up to which source code location an address corresponds.
 294      *
 295      * If you have several address spaces, you should use the number, subsystem or
 296      * group mechanism to pass through information about memory space to this
 297      * function.
 298      *
 299      * An alternative to this look-up mechanism is to provide a resolve function
 300      * for an overloaded extended address (err_ext_address_t).  This way, the
 301      * resolver is invoked depending on the type of extended address.
 302      */
 303  
 304  /* err-renumber */
 305  extern err_location_t const *err_resolve_address (
 306      int tag, int /*orig_tag*/, int number, err_location_t const *);
 307     /* A function that resolves, if possible, an address to a
 308      * source code location.
 309      *
 310      * In case anything changes, this function returns a pointer to a statically
 311      * allocated err_location_t.  Otherwise, the original pointer is returned.
 312      *
 313      * The user provided callback is only invoked if the file
 314      * is unset and the address is valid.
 315      */
 316  
 317  extern void err_set_next_location (err_location_t const *);
 318     /* If this is invoked, the error location will be used in the
 319      * next eprintf command regardless of a possibly given location.
 320      *
 321      * Note that only the last location set this way will have an
 322      * effect.
 323      *
 324      * Further note that an eprintf with the C_TAG_PREFIX tag and
 325      * a given location also invokes this function if the next
 326      * location is not set.  Therefore, calling this function is
 327      * equivalent to C_TAG_PREFIX with a location and an empty
 328      * format string when the next location is unset.  However, use
 329      * this err_set_next_location() for clarity.
 330      *
 331      * The function err_erase_prefix() deletes this location.  If
 332      * you set a location whose file and address are invalid, this
 333      * is also equal to erasing the location.
 334      */
 335  
 336  extern void err_erase_prefix (void);
 337  extern void err_erase_suffix (void);
 338     /* Erases a buffered prefix (suffix) that has been printed with
 339      * C_TAG_PREFIX (C_TAG_SUFFIX). */
 340  
 341  extern void err_add_stream    (
 342      int /*tags*/, FILE * /*stream*/, err_style_t const * ERWIN_IF_CXX (= NULL));
 343      /* If the stream already exists for the given file, the style will not
 344       * be changed.  This is to allow the user to change the style explicitly
 345       *
 346       * The streams stderr and stdout automatically get the names "stderr"
 347       * and "stdout".
 348       *
 349       * Use err_stream_set_style for changing a stream style (remember to use
 350       * this AFTER err_stream_set_name since that function also likes to change
 351       * the error style if it has settings for that name, so it would again
 352       * reset the style.).  */
 353  
 354  extern ERR_BOOL err_stream_set_name (FILE * /*stream*/, char const * /*name*/);
 355     /* When you set this, command line options for styles are enabled for
 356      * the given stream.  (E.g. print filtering (NYI), style settings)
 357      *
 358      * NOTE: When a stream with this name exists and has a file pointer
 359      *       of NULL or equal to the given file, then the current settings
 360      *       will be copied from the named stream to the stream defined
 361      *       by the file pointer.  After that, the two streams will be
 362      *       identified.
 363      *
 364      *       If a stream with the given name exists that has a different file
 365      *       pointer, this routine returns false (= no success).
 366      *
 367      * Note: when you erase a stream with a name, then the settings will be
 368      *       erased, too, together with its name.
 369      */
 370  
 371  extern void err_stream_set_style (FILE * /*stream*/, err_style_t const * /*style*/);
 372     /* Resets the current stream style. */
 373  
 374  extern void err_remove_stream (int /*tags*/, FILE * /*stream*/);
 375     /* Add/remove an stream for error messages.
 376      *
 377      * You can have only one style per FILE*.  If you add a stream for
 378      * a FILE* that is already in use, the style is switched to the
 379      * new style before added the additional stream.  Please note
 380      * the in this case, there are still two streams for this file,
 381      * although only one style.  So if the filtering for both streams
 382      * is not mutually exclusive, some error messages are printed into
 383      * that stream twice per issue.
 384      *
 385      * To change a style, first err_remove_stream() and then add it again.
 386      * Note that filtering rules are stored per file, so you cannot
 387      * reset a stream filter by removing the stream and adding it again.
 388      *
 389      * If you want to reset a stream including its filtering rules, use
 390      * err_reset_stream().
 391      *
 392      * You can set a group of tags by using bit operators for simple
 393      * filtering: E.g.
 394      *      : C_TAG_WARN | C_TAG_ERROR
 395      *      : ~C_TAG_DEBUG
 396      *
 397      * For all tags, use C_TAG_ALL.
 398      *
 399      * The values 0 and -1 for tags are illegal.
 400      *
 401      * By default, there is one stream for the messages, stderr,
 402      * used for all messages.
 403      *
 404      * A stream may be NULL in which case err_style_default will
 405      * be used.
 406      *
 407      * The style must not be NULL!
 408      */
 409  
 410  extern void err_reset_stream (FILE *);
 411     /* Resets a stream to its initial contents: it deletes all
 412      * filters, styles, its.
 413      *
 414      * This also performs err_remove_stream (C_TAG_ALL, file).
 415      */
 416  
 417  extern void err_add_callback2_voidp (
 418      int /*tags*/, int /*priority*/, err_callback2_voidp_t, void *, err_style_t const *);
 419  extern void err_add_callback2_int (
 420      int /*tags*/, int /*priority*/, err_callback2_int_t, int, err_style_t const *);
 421  extern void err_add_callback2 (
 422      int /*tags*/, int /*priority*/, err_callback2_t, err_style_t const *);
 423  
 424  extern void err_add_callback0_voidp (
 425      int /*tags*/, int /*priority*/, err_callback0_voidp_t, void *, err_style_t const *);
 426  extern void err_add_callback0_int (
 427      int /*tags*/, int /*priority*/, err_callback0_int_t, int, err_style_t const *);
 428  extern void err_add_callback0 (
 429      int /*tags*/, int /*priority*/, err_callback0_t, err_style_t const *);
 430  
 431  extern void err_add_callback2_info_voidp (
 432      int /*tags*/, int /*priority*/, err_callback2_info_voidp_t, void *, err_style_t const *);
 433  extern void err_add_callback2_info_int (
 434      int /*tags*/, int /*priority*/, err_callback2_info_int_t, int, err_style_t const *);
 435  extern void err_add_callback2_info (
 436      int /*tags*/, int /*priority*/, err_callback2_info_t, err_style_t const *);
 437  
 438  extern void err_add_callback0_info_voidp (
 439      int /*tags*/, int /*priority*/, err_callback0_info_voidp_t, void *, err_style_t const *);
 440  extern void err_add_callback0_info_int (
 441      int /*tags*/, int /*priority*/, err_callback0_info_int_t, int, err_style_t const *);
 442  extern void err_add_callback0_info (
 443      int /*tags*/, int /*priority*/, err_callback0_info_t, err_style_t const *);
 444  
 445  extern void err_remove_callback (
 446      int /*tags*/, int /*priority*/, void * /*function*/);
 447  
 448  extern void err_remove_callback_function (
 449      int /*tags*/, int /*priority*/, err_function_ptr_t /*function*/);
 450  extern void err_remove_callback_void (
 451      int /*tags*/, int /*priority*/, err_function_ptr_t /*function*/);
 452  extern void err_remove_callback_voidp (
 453      int /*tags*/, int /*priority*/, err_function_ptr_t /*function*/, void * /*user_data*/);
 454  extern void err_remove_callback_int (
 455      int /*tags*/, int /*priority*/, err_function_ptr_t /*function*/, int /*user_data*/);
 456  
 457  extern void err_clear_callback (
 458      int /*tags*/, int /*priority*/);
 459     /*
 460      * A function to call back for every message after filtering and formatting.
 461      *
 462      * Like for err_(add/remove)_stream, you can specify groups of tags.
 463      *
 464      * The callbacks are invoked in the following order:
 465      *    - Before the call to the print function, all priorities > 0
 466      *      are invoked in rising order of the priority (1, 2, 3....)
 467      *      and for the same priority, callbacks added later are invoked
 468      *      later.
 469      *    - After the call to the print function, all priorities < 0
 470      *      are invoked in RISING ORDER OF THE PRIORITY (... -3, -2, -1)
 471      *      and for the same priority, callbacks added later are invoked
 472      *      earlier.
 473      *
 474      * By default, there are the following call backs:
 475      *    : err_add_callback (C_TAG_FATAL,     -1, { exit(1); }, NULL)
 476      *    : err_add_callback (C_TAG_ASSERTION, -1, { abort(); }, NULL)
 477      * So the program will immediately be terminated after an error message
 478      * is issued with C_TAG_FATAL or C_TAG_ASSERTION.
 479      *
 480      * For err_add_callback, a priority of 0 is illegal.
 481      *
 482      * For err_add_callback a callback may be NULL in which case nothing
 483      * is invoked.  However, the error message is formatted with the
 484      * given style, so this may be used for a more complex call back
 485      * mechanism anyway (by providing your own style).
 486      *
 487      * For err_remove_callback and err_clear_callback, if priority is 0,
 488      * the commands perform on all priorities.
 489      *
 490      * err_remove_callback_void removes a callback by its function pointer
 491      * that does not receive any user data.
 492      *
 493      * err_remove_callback_voidp removes a callback by its function pointer
 494      * and the user data.
 495      *
 496      * err_remove_callback_int removes a callback by its function pointer
 497      * and the user data.
 498      *
 499      * err_remove_callback removes a callback by its function pointer.
 500      * Note that on machines were code pointers have a different size that
 501      * data pointers, this currently does not work.  We will have to implement
 502      * something else.  This function is deprecated, please use the other
 503      * alternatives that receive a ErrFunctionPtr.
 504      *
 505      * err_clear_callback() erases all callbacks for a given tag/priority.
 506      * (E.g. this can be used to remove the terminating exit(0) / abort()
 507      * invocations.  However, this is sincerely deprecated!)
 508      *
 509      * If the style is NULL, the pure text of the error message is passed
 510      * to the callback.
 511      *
 512      * [For the behaviour of the old interface, use priority = 1.]
 513      */
 514  
 515  extern void err_exit_1 (
 516      int /*tag*/, int orig_tag, int /*number*/, err_location_t const *, char const * /*text*/);
 517      /* This is a function suitable for ther err_add_callback* function family that
 518       * exits the program with exit(1).  */
 519  
 520  extern void err_abort (
 521      int /*tag*/, int orig_tag, int /*number*/, err_location_t const *, char const * /*text*/);
 522      /* This is a function suitable for ther err_add_callback* function family that
 523       * exits the program with abort(). */
 524  
 525  /* ********************************************************************** */
 526  /* Sub-system handling */
 527  
 528  extern int err_declare_subsystem (char const * /*name*/);
 529     /* Note that this function does not need to be invoked.  You may
 530      * directly use err_subsystem() instead.
 531      *
 532      * Generates a new, unique identifier of a new sub-system with the
 533      * given name.  The returned value can be combined with the C_TAG_...
 534      * constants to generate errors in this sub-system.  E.g.:
 535      *
 536      *    : int lisp_subsystem= err_declare_subsystem ("Lisp");
 537      *    :
 538      *    : ...
 539      *    : eprintf (C_TAG_ERR | lisp_subsystem, 172, "Some error\n");
 540      *
 541      * This is equivalent to:
 542      *
 543      *    : eprintf (C_TAG_ERR | err_subsystem("Lisp"), 172, "Some error\n");
 544      *
 545      * Sub-systems are used for two purposes:
 546      *    a) identification of an error message (the name of the
 547      *       sub-system will be printed with the error message)
 548      *
 549      *    b) redirection of error messages.
 550      *
 551      * b) was mainly introduced to keep old libraries compatible by
 552      * allowing them to set a default callback that prints all their
 553      * error messages into a vector.  (liblisp and libtf14net work
 554      * like this).
 555      *
 556      * To handle the errors with the normal method, use
 557      * err_unset_subsystem_callback() to switch off redirection.
 558      *
 559      * You may specify NULL for name, if the subsystem has no name.
 560      * You can still use the returned number for the following
 561      * functions.
 562      *
 563      * A predefined subsystem is 0, the core subsystem.  You can also
 564      * use 0 for settings callbacks without need of declaration.
 565      */
 566  
 567  extern ATTR_PURE int err_subsystem (char const * /*name*/);
 568     /* Return the identifier of a given subsystem */
 569  
 570  extern void err_set_subsystem_callback2_voidp (
 571      int /*subsystem*/, err_callback2_voidp_t, err_style_t const *, void *);
 572  extern void err_set_subsystem_callback2_int (
 573      int /*subsystem*/, err_callback2_int_t, err_style_t const *, int);
 574  extern void err_set_subsystem_callback2 (
 575      int /*subsystem*/, err_callback2_t, err_style_t const *);
 576  extern void err_set_subsystem_callback0_voidp (
 577      int /*subsystem*/, err_callback0_voidp_t, err_style_t const *, void *);
 578  extern void err_set_subsystem_callback0_int (
 579      int /*subsystem*/, err_callback0_int_t, err_style_t const *, int);
 580  extern void err_set_subsystem_callback0 (
 581      int /*subsystem*/, err_callback0_t, err_style_t const *);
 582      /* For C++, these functions are also accessible via
 583       *     err_set_subsystem_callback
 584       */
 585  
 586  extern void err_unset_subsystem_callback (int /*subsystem*/);
 587     /* This implements a mechanism of filtering sub-systems completely.
 588      *
 589      * A callback for a subsystem overrides all other callback and stream
 590      * settings.
 591      *
 592      * As usual, you can set callback to NULL in order to do the formatting,
 593      * but not invoke anything.
 594      *
 595      * IF the style is NULL, no formatting will be done.  Instead, the
 596      * raw message text string is passed to the callback.
 597      */
 598  
 599  extern char const *err_subsystem_name (int /*tag*/);
 600     /* gets the group name or return NULL */
 601  
 602  #ifdef ERR_SUBSYSTEM_ID
 603  
 604  static int _err_subsystem_cache() ATTR_PURE;
 605  static int _err_subsystem_cache()
 606  {
 607      static int x= 0;
 608      if (!x)
 609          x= err_subsystem(ERR_MODULE);
 610      return x;
 611  }
 612  
 613  #endif
 614  
 615  /* ********************************************************************** */
 616  /* Groups */
 617  
 618  extern ATTR_PURE int err_group (char const * /*name*/);
 619     /* Returns the identifier of a given group.  You need not declare groups,
 620      * but may freely use them directly.  Groups are a bit like subsystems,
 621      * but in contrast, the group is not shown, but instead meant to be
 622      * an additional level of classification of messages.  They are used
 623      * mainly for filtering. */
 624  
 625  extern char const *err_group_name (int /*tag*/);
 626     /* gets the group name or return NULL */
 627  
 628  extern void err_group_set_prefix (int /*tag*/, char const * /*prefix*/);
 629     /* Sets a string to print as a prefix in front of all errors
 630      * printed with the given err_group() in tag.
 631      *
 632      * E.g., you might want to do:
 633      *    err_group_set_prefix (err_group("nyi"), "Not yet implemented:\n");
 634      *
 635      * Then you can:
 636      *    eprintf (C_TAG_ERROR|err_group("nyi"), "Syntax error before ...");
 637      *
 638      * To print:
 639      *    "Not yet implemented:\nSyntax error before ..."
 640      *
 641      * The prefix is added in front of texts added with ERR_PREFIX.
 642      *
 643      * You can set a default prefix for all messages without a group
 644      * by setting tag=0.
 645      *
 646      * You can reset a prefix by setting it to NULL.
 647      */
 648  
 649  extern char const *err_group_get_prefix (int /*tag*/);
 650     /* Returns a prefix set with err_group_set_prefix. */
 651  
 652  /* ********************************************************************** */
 653  /* Buffering */
 654  
 655  
 656  extern void err_buffer_begin (err_buffer_t * /*buffer*/);
 657     /* Start buffering all message into given buffer.
 658      * This locally makes error message issuing quiet.
 659      * Usage may be nested: this pushes an error buffer
 660      * which is then the innermost buffer.
 661      *
 662      * If buffer is NULL, messages are hidden.
 663      *
 664      * When buffering is active, only the innermost buffer
 665      * is filled with messages.   The messages are already
 666      * filtered, but not formatted (apart from the mere
 667      * message).
 668      *
 669      * Note that the buffer combines messages that have the
 670      * C_TAG_MORE with previous messages for convenience.  This
 671      * is reflected in the typedef of err_message_t in
 672      * include/error/decls.h .
 673      *
 674      * Note: Messages with the following tags cannot be gathered in buffers:
 675      *     : C_TAG_ASSERTION
 676      *     : C_TAG_FATAL
 677      */
 678  
 679  extern void err_buffer_end (void);
 680     /* End the buffering set with err_buffer_begin() */
 681  
 682  /* err-renumber */
 683  extern ERR_BOOL err_is_buffered (int tag, int number);
 684     /* whether something is buffered. */
 685  
 686  extern void err_re_issue (err_message_t *);
 687     /* With this function, you can manually re-issue messages from
 688      * an error buffer. */
 689  
 690  extern void err_buffer_re_issue (err_buffer_t * /*buffer*/);
 691     /* Seldom used: issues the messages but keeps them.
 692      * Introduced for debugging and otherwise not useful.
 693      *
 694      * Don't use!
 695      */
 696  
 697  extern void err_buffer_flush (err_buffer_t * /*buffer*/);
 698     /* Re-issue buffered error messages that where gathered
 699      * using err_begin_buffer and err_end_buffer.
 700      *
 701      * Note that this function does not filter the messages,
 702      * because filtering is done before already.
 703      *
 704      * After re-issuing the mesages, the buffer is cleared.
 705      *
 706      * Note that an err_buffer_t is not an Erwin vector.
 707      * Still, many functions are identical to Erwin vectors,
 708      * so you can easily filter it before unbuffering using e.g.
 709      * err_buffur_erase_if etc.  You don't need to take care
 710      * of freeing messages, because this is done by Erwin.
 711      */
 712  
 713  /* ********************************************************************** */
 714  /* Filtering
 715   *
 716   * If a filter rule for a message number is found, then that is used.
 717   *
 718   * Otherwise, if filtering says not to display a rule due to group,
 719   * subsystem or tag number filtering, that message is not displayed.
 720   */
 721  
 722  enum err_decision_t {
 723      ERR_NO,
 724      ERR_YES,
 725      ERR_WEAK_NO,
 726      ERR_WEAK_YES,
 727      ERR_DEFAULT
 728  };
 729  
 730  #ifndef __cplusplus
 731  typedef int err_decision_t;
 732  #endif
 733  
 734  extern char const *err_decision_to_char_p (err_decision_t);
 735     /* Return the a human readable symbol name of the given enum value. */
 736  
 737  /* err-renumber */
 738  extern void err_show_message (int /*number*/, err_decision_t /*show*/);
 739     /* Selection of messages to show/hide.
 740      *
 741      *    +-----------------------+------------------------------------------------+
 742      *    | show == ERR_YES       | show                                           |
 743      *    | show == ERR_NO        | hide                                           |
 744      *    | show == ERR_WEAK_YES  | show if not set otherwise yet                  |
 745      *    | show == ERR_WEAK_NO   | hide if not set otherwise yet                  |
 746      *    | show == ERR_DEFAULT   | use setting for tag (deletes previous setting) |
 747      *    +-----------------------+------------------------------------------------+
 748      *
 749      * Usually an application should stick to the ERR_DEFAULT_(YES,NO)
 750      * values, since this library will soon parse the command line
 751      * and configure itself at the users will.
 752      *
 753      * The default is to use the setting for the given group.
 754      * If you set this, this overrides settings for the group.
 755      *
 756      * Note: Messages with the following tags cannot be filtered,
 757      *       since they have no numbers:
 758      *     :  C_TAG_NONE
 759      *     :  C_TAG_UNCLASSIFIED
 760      *     :  C_TAG_ASSERTION
 761      */
 762  
 763  extern void err_show_devel (int /*tags*/, err_decision_t /*show*/);
 764  extern void err_show       (int /*tags*/, err_decision_t /*show*/);
 765     /* Select filtering a certain group of tags or certain tags
 766      * of subsystems or the like.  Use the ERR_YES,NO, etc. macros
 767      * as with err_show_message().
 768      *
 769      * You can specify groups of tags, 0 means all tags.
 770      *
 771      * You can combine tags and subsystem and group ids to form a narrow
 772      * selection of what is to be filtered.  E.g.,
 773      *    : err_show (C_TAG_WARNING | err_subsystem ("lex"), ERR_NO)
 774      * hides warnings from subsystem lex.
 775      *
 776      * More specific selections override less specific ones.
 777      *
 778      * The default is to hide debug messages (C_TAG_DEBUG) if NDEBUG is #defined
 779      * and to show all others.   If NDEBUG is not #defined, all messages are
 780      * displayed by default.  (Of course, this behaviour can be overriden using
 781      * this function, since that is only the default.  It is even a weaker
 782      * default than can be defined with this function, so you can change it
 783      * with ERR_DEFAULT_YES and ERR_DEFAULT_NO.)
 784      *
 785      * Note than currently, the library has only one table far the settings,
 786      * so the following sequence:
 787      *
 788      *   :  err_show (C_TAG_WARNING, ERR_YES);
 789      *   :  err_show (C_TAG_WARNING, ERR_DEFAULT_NO);
 790      *   :  err_show (C_TAG_WARNING, ERR_DEFAULT);
 791      *
 792      * will let the library show warnings, since the second call has no
 793      * effect, since the value was already set.
 794      *
 795      * No setting can be defined for C_TAG_MORE.  The
 796      * setting of the previous message is used.
 797      */
 798  
 799  /* err-renumber */
 800  extern ERR_ERWIN_BOOL err_is_shown (int tag, int number);
 801     /* Returns 1 if the message would be issued and 0 if not */
 802  
 803  /* err-renumber */
 804  extern void err_print_message (FILE * /*stream*/, int /*number*/, err_decision_t /*print*/);
 805     /* Define that the given error number shall be printed.  See err_print()
 806      * for more details on the difference between printing and showing and
 807      * the filtering thereof. */
 808  
 809  extern void err_print_devel (FILE * /*file*/, int /*tags*/, err_decision_t /*print*/);
 810  extern void err_print       (FILE * /*file*/, int /*tags*/, err_decision_t /*print*/);
 811     /* Like err_show*, but local to a file.
 812      *
 813      * You can set-up filtering rules without actually currently using
 814      * that FILE*.  The next time you err_add_stream(), the filtering
 815      * will be active.
 816      *
 817      * With this function, you can set-up filtering on streams, e.g.,
 818      * have all messages of group 'logfile' go into a special file only.
 819      *
 820      * You can use NULL as a file pointer to set a default behaviour
 821      * for all possible files.  This default behaviour can be reset
 822      * using err_reset_stream (NULL).
 823      */
 824  
 825  /* err-renumber */
 826  extern void err_print_once_message (
 827      FILE *,
 828      int /*number*/,
 829      err_decision_t /*print*/,
 830      err_symtab_t * /*table*/ ERWIN_IF_CXX (= NULL));
 831      /* Defines that the given message be printed only once.  See err_print_once()
 832       * for more details of the one-time issuing */
 833  
 834  extern void err_print_once_devel (
 835      FILE *,
 836      int /*tags*/,
 837      err_decision_t /*print*/,
 838      err_symtab_t * /*table*/ ERWIN_IF_CXX (= NULL));
 839  
 840  extern void err_print_once (
 841      FILE *,
 842      int /*tags*/,
 843      err_decision_t /*print*/,
 844      err_symtab_t * /*table*/ ERWIN_IF_CXX (= NULL));
 845     /* Any message returning YES using the given filtering will only be
 846      * printed once into the given stream.
 847      *
 848      * To accomplish this, the text of every message is stored in
 849      * a hash table.
 850      *
 851      * If 'table' is NULL, an internal global table is used.  Otherwise,
 852      * the given symbol table is used for remembering messages.  If
 853      * you want to, you can give a different table to the system.
 854      * Note: The library never deallocates tables that you give it.
 855      *
 856      * To set a default behaviour for all possible files, use NULL as
 857      * a file pointer.
 858      *
 859      * The only way to remove the filtering per stream is by using
 860      * err_reset_stream ().
 861      *
 862      * You can reset the default values by using err_reset_stream(NULL).
 863      */
 864  
 865  
 866  /* err-renumber */
 867  extern ERR_ERWIN_BOOL err_is_printed (FILE *, int tag, int number);
 868     /* checks the stream filtering for the given file.
 869      *
 870      * Note: even if the FILE* is currently not in use, it's filtering
 871      * rules are still active.
 872      *
 873      * If you want to reset a stream including its filtering rules, use
 874      * err_reset_stream().
 875      *
 876      * Further note: even if a FILE* was never seen by the library, it
 877      * does have filtering rules.  So even without ever using err_add_stream()
 878      * on a new FILE*, this function will return ERR_ERWIN_TRUE if
 879      * the message is issued and shown.
 880      */
 881  
 882  /* err-renumber */
 883  extern ERR_ERWIN_BOOL err_is_seen (int tag, int number);
 884     /* The functions consider all possible filters that prevent
 885      * messages from being printed in to a stream:  issue filters,
 886      * show filters, and buffering.  err_is_seen_in() also considers
 887      * stream filtering.
 888      *
 889      * In short, this functions return whether the user will see
 890      * a message that is produced with an eprintf call in at least
 891      * one of the streams it is printed into.
 892      */
 893  
 894  extern void err_set_quiet_level_devel (int);
 895  extern void err_set_quiet_level (int);
 896     /* Set a typical show/hide behaviour suitable for many programs:
 897      *
 898      *   +-------+------------------------------------------------------+
 899      *   |  <=0 =| every tag is shown.                                  |
 900      *   |    1 =| progress messages are hidden.                        |
 901      *   |    2 =| notes are also hidden.                               |
 902      *   |    3 =| infos are also hidden.                               |
 903      *   |    4 =| warnings are also hidden.                            |
 904      *   |    5 =| errors are also hidden.                              |
 905      *   |  >=6 =| fatal errors and assertion failures are also hidden. |
 906      *   +-------+------------------------------------------------------+
 907      *
 908      * This uses ERR_DEFAULT_YES and ERR_DEFAULT_NO to do the setting,
 909      * so it does not override older settings.
 910      */
 911  
 912  extern void err_stream_set_quiet_level_devel (FILE*, int);
 913  extern void err_stream_set_quiet_level       (FILE*, int);
 914     /* like err_set_quiet_level() for streams.  See err_print() for
 915      * details */
 916  
 917  
 918  /* err-renumber */
 919  extern void err_issue_message (int /*number*/, err_decision_t /*show*/);
 920     /* Define whether a message is issued.  This is a global filter
 921      * that filters by error number.  See err_is_issued() and err_issue(),
 922      * also.
 923      */
 924  
 925  extern void err_issue_devel (int /*tags*/, err_decision_t /*show*/);
 926  extern void err_issue       (int /*tags*/, err_decision_t /*show*/);
 927     /* An issued message is one that is counted.  Those messages
 928      * whose issuing is prevented by a filter will not be seen by
 929      * error buffers and will not be distributed into streams and
 930      * user callbacks, and will also not be shown or printed.
 931      * So this a very hard filtering.  The only counters that
 932      * are increased when a message is filtered from issuing are
 933      * the 'received' counters, which count the number of eprintf
 934      * invocations altogether.
 935      *
 936      * See the ERR_STATUS_* enum for a list of filtering and
 937      * counting levels.
 938      */
 939  
 940  /* err-renumber */
 941  extern ERR_ERWIN_BOOL err_is_issued (int tag, int number);
 942     /* The parameters are the same as for the _show_ family, but
 943      * the effect is that the filtering is done such that the messages
 944      * are not even processed if they are filtered this way.  In
 945      * contrast to only hiding them, this means:
 946      *     - they are not counted
 947      *     - the callbacks are not invoked
 948      *     - they are not stored in buffers.
 949      *
 950      * Note: Messages with the following tags cannot be suppressed:
 951      *     :  C_TAG_ASSERTION
 952      *     :  C_TAG_FATAL
 953      * (But they can be hidden.)
 954      */
 955  
 956  /* ********************************************************************** */
 957  /* Counting */
 958  
 959  #define ERR_STATUS_RECEIVED     (1 << 0)
 960      /* those errors for which an eprintf was invoked */
 961  #define ERR_STATUS_ISSUED       (1 << 1)
 962      /* those errors that passed the initial filtering (err_issue_...) */
 963  #define ERR_STATUS_BUFFERED     (1 << 2)
 964      /* those errors that were written into a buffer. */
 965  #define ERR_STATUS_DISTRIBUTED  (1 << 3)
 966      /* those errors for which callbacks where invoked; that's those
 967       * issued ones that where not buffered and then dropped. */
 968  #define ERR_STATUS_SHOWN        (1 << 4)
 969      /* those that went into a stream */
 970  #define ERR_STATUS_PRINTED      (1 << 5)
 971      /* like _SHOWN, but every stream counts one here, so this
 972       * might count one error more than once */
 973  
 974  #define ERR_STATUS_ALL          (~0)
 975  
 976  typedef int err_status_t;
 977  
 978  /* Due to being the most common case, the following functions accept
 979   * abbreviations:
 980   *     instead of ERR_STATUS_DISTRIBUTED, you may write 0.
 981   *     instead of ERR_COUNTER_TYPE_TAG,   you may write 0.
 982   */
 983  
 984  extern int err_count (
 985     err_status_t ERWIN_IF_CXX (= 0),
 986     int /*tag*/  ERWIN_IF_CXX (= C_TAG_ERRORS));
 987     /* Get the value of a tag counter.
 988      *
 989      * A typical idiom at the end of main is:
 990      *
 991      *   : exit (err_count(0,0) ? EXIT_FAILURE : EXIT_SUCCESS);
 992      *
 993      * You can access different types of counters via this
 994      * function, depending on whether you specify the tag, the group
 995      * or the subsystem.
 996      *
 997      *  +---------------------------+--------------------------------------+
 998      *  |! Counter Type             |! Example for 'tag'                   |
 999      *  |  per tag                  |  C_TAG_ERROR                         |
1000      *  |  per tag and subsystem    |  C_TAG_ERROR + err_subsystem ("lex") |
1001      *  |  per tag and group        |  C_TAG_ERROR + err_group ("lex")     |
1002      *  |  per subsystem            |  err_subsystem ("lex")               |
1003      *  |  per group                |  err_group ("lex")                   |
1004      *  +---------------------------+--------------------------------------+
1005      *
1006      * Furthermore, you may use groups of tags to get the total
1007      * count (the sum of all single counts).  E.g.:
1008      *   :  err_count (ERR_STATUS_DISTRIBUTED,
1009      *   :      C_TAG_ERROR | C_TAG_WARNING | err_subsystem("lex"))
1010      *
1011      * It is (currently) illegal to specify both a subsystem and a group.
1012      *
1013      * You cannot specify groups of statuses (this would make no sense).
1014      *
1015      * If tag is 0, it defaults of C_TAG_ERRORS.  If status is 0, it
1016      * defaults to ERR_STATUS_DISTRIBUTED, so the above is normally
1017      * what you want.
1018      */
1019  
1020  /* err-renumber */
1021  extern int err_message_count (err_status_t, int /*number*/);
1022     /* Get the value of a message counter. */
1023  
1024  /* err-renumber */
1025  extern void err_clear_count (err_status_t, int /*number*/);
1026     /* Set a particular counter to 0 */
1027  
1028  /* err-renumber */
1029  extern void err_clear_message_count (err_status_t, int /*number*/);
1030     /* Set a particular counter to 0 */
1031  
1032  /* err-renumber */
1033  extern void err_set_count (err_status_t, int number, int /*val*/);
1034     /* Set a particular counter to a given value */
1035  
1036  /* err-renumber */
1037  extern void err_add_count (err_status_t, int number, int /*val*/);
1038     /* Add to a particular counter */
1039  
1040  /* err-renumber */
1041  extern void err_set_message_count (err_status_t, int number, int /*val*/);
1042  
1043  /* err-renumber */
1044  extern void err_add_message_count (err_status_t, int number, int /*val*/);
1045     /* For general modification of the counters.
1046      * You may use groups of tags and groups of statuses here.
1047      *
1048      * None of these functions checks the fatal counters.
1049      *
1050      * E.g.
1051      *     :  err_count_dec (
1052      *     :      ERR_STATUS_SHOWN | ERR_STATUS_PRINTED,
1053      *     :      ERR_COUNTER_TYPE_TAG,
1054      *     :      C_TAG_ERROR | C_TAG_WARNING);
1055      *
1056      * Please note:
1057      * If you modify the tag counters manually, it may or
1058      * may not be guaranteed that e.g.
1059      *     : err_count (0, err_subsystem(X)) ==
1060      *     : err_count (0, C_TAG_ALL + err_subsystem(X))
1061      * since the library may or may not use own counters for the
1062      * sums per subsystem/group.
1063      */
1064  
1065  extern void err_clear_all_count (err_status_t);
1066     /* This accepts groups of statuses.
1067      *
1068      * E.g.
1069      *     : err_count_clear_all (ERR_STATUS_ALL);
1070      *
1071      */
1072  
1073  /* err-renumber */
1074  extern void err_do_count (int tag, int number, err_status_t);
1075     /* Counts this error in the internal counters.
1076      *
1077      * This is usually not very interesting to the user, since this
1078      * the function the library uses internally to count.  If the
1079      * user wants to contribute, they can use this.
1080      *
1081      * This function does not generate a fatal error if any of the fatal
1082      * counters is exceeded by the counting.  This checking is only done in
1083      * eprintf functions.
1084      *
1085      * In contrast to err_add_count, you cannot count groups of tags with
1086      * this function.  (The result of trying to do so will be strange.)
1087      */
1088  
1089  /* ********************************************************************** */
1090  /* fatal counts */
1091  
1092  extern void err_set_fatal_count (err_status_t, int /*tag*/, int /*cnt*/);
1093     /* This function let's you define a maximal amount of errors
1094      * that leads to a fatal error.  This is useful if you are
1095      * expecting a large number of errors when you'd start fixing
1096      * at the beginning anyway.
1097      *
1098      * This function sets the counter to a given tag.
1099      */
1100  
1101  extern void err_unset_fatal_count (err_status_t, int /*tag*/);
1102  extern void err_unset_all_fatal_count (err_status_t);
1103     /* Unset a fatal error counter.  See err_set_fatal_count(). */
1104  
1105  /* err-renumber */
1106  extern void
1107  err_set_fatal_message_count (err_status_t, int number, int /*cnt*/);
1108     /* Set err_set_fatal_counter().
1109      *
1110      * This function sets the counter to a given message id.
1111      */
1112  
1113  /* err-renumber */
1114  extern void
1115  err_unset_fatal_message_count (err_status_t, int /*number*/);
1116     /* Unset a fatal error counter.  See err_set_fatal_message_count(). */
1117  
1118  extern void err_unset_all_fatal_message_count (err_status_t);
1119      /* set/unset the amount of times a certain message may occur, that is
1120       * considered to be fatal.  As with the normal message counters,
1121       * you may set/unset this for tags, groups, sub-systems, and messages.
1122       *
1123       * cnt <= 0 is illegal.
1124       *
1125       * As with counters, these functions work with groups of statuses, and
1126       * for ERR_COUNTER_TYPE_TAG, groups of tags.
1127       *
1128       * Please note that these functions do not split the tag into tag,
1129       * subsystem and group.  Instead, the fatal count may be specified
1130       * for any integer value.  To check the fatal count, exactly this
1131       * value will be used to compare to the actual count.  Therefore,
1132       * you can specify a fatal count for the sum of errors and
1133       * warnings, which in turn does not effect any fatal count for
1134       * errors and warnings alone.  Or you could specify a fatal count
1135       * for C_TAG_ERROR of a given subsystem or group only.
1136       *
1137       * This implies that you can only unset fatal counts exactly
1138       * for the tag you specified before.  (So this behaves quite
1139       * differently from err_clear_count().)
1140       */
1141  
1142  /* err-renumber */
1143  extern int err_fatal_count (err_status_t, int number);
1144      /* Query a fatal counter. */
1145  
1146  /* err-renumber */
1147  extern int err_fatal_message_count (err_status_t, int number);
1148      /* Get the amount of times a certain message may occur.  You may
1149       * specify groups of status, in which case, the minimum count will
1150       * be returned.
1151       *
1152       * -1 is returned if any of the matching error counts is unset.
1153       */
1154  
1155  extern ErrFormattedStream *err_get_stream (FILE *);
1156     /* never returns NULL: if the stream does not exist, a new one is
1157      * allocated */
1158  
1159  extern ErrFormattedStream *err_get_stream_by_name (char const *);
1160     /* may return NULL if no such stream is known. */
1161  
1162  
1163  /* ********************************************************************** */
1164  /* Helpers */
1165  
1166  extern void err_flush_buffers(void);
1167      /* For debugging purposes: dump all buffered error messages and clear
1168       * the message buffers. */
1169  
1170  extern ATTR_NORETURN void err_crash_aux(void);
1171      /* use err_crash() macro instead */
1172  
1173  typedef int (*ErrProcessOption) (
1174      char const * /*key*/, char const * /*value*/, ERR_ERWIN_BOOL /*must*/);
1175     /* return value = number of input arguments that were used:
1176      *    0= unknown key
1177      *    1= option without value
1178      *    2= option with value
1179      * An error message is printed by this function if the result
1180      * is 0.
1181      * Value may be NULL.
1182      * must==false defines that value may be used, must==true defines that
1183      * it must be used, or otherwise an error about an illegal argument must
1184      * be produced.
1185      */
1186  
1187  extern void err_get_envvar_global (ErrVChar * /*result*/, char const * /*prefix*/);
1188     /* Returns the name of the global environment variable for a
1189      * given prefix.  E.g. for "msg", this returns "MSG_OPTIONS"
1190      */
1191  
1192  extern void err_get_envvar_local (ErrVChar * /*result*/, char const * /*prefix*/);
1193     /* Returns the name of the local environment variable for a
1194      * given prefix.  This requires err_prognam() to return non-NULL.
1195      * E.g. for a prefix of "msg" and an err_progname() of "exec2crl",
1196      * this returns "MSG_OPTIONS_EXEC2CRL".
1197      *
1198      * If err_progname() returns NULL, this returns "".
1199      */
1200  
1201  extern void err_opt_parse_args (
1202      int *             /*argc_p*/,
1203      char ***          /*argv_p*/,
1204      char const *      /*prefix*/,
1205      ErrProcessOption  /*callback*/);
1206      /* Parses the command line searching for options for the given library
1207       * (defined by the prefix) and calls the callback for each option found.
1208       * The processed options are removed from the command line.
1209       *
1210       * Any dashes around the given prefix will be removed before being used.
1211       */
1212  
1213  extern void err_opt_parse_string (
1214      char const *     /*envstr*/,
1215      ErrProcessOption /*callback*/);
1216      /* Parses an environment string for options and calls the callback for
1217       * each option found.
1218       */
1219  
1220  extern void err_opt_parse (
1221      int *             /*argc_p*/,
1222      char ***          /*argv_p*/,
1223      char const *      /*prefix*/,
1224      ErrProcessOption  /*callback*/);
1225      /* First parses the environment variables for the given prefix,
1226       * then parses the command line args.  This combines err_opt_parse_args()
1227       * and err_opt_parse_string() into one call.
1228       *
1229       * The env.variables checked are derived from the prefix, which is
1230       * taken in upper case with _OPTIONS added, e.g. MSG_OPTIONS.  This
1231       * is the first variable checked.  The second variable, which may override
1232       * the settings, would be <PREFIX>_OPTIONS_<PROGNAME>, e.g.
1233       * MSG_OPTIONS_EXEC2CRL for a prefix of 'msg' and an err_progname() of
1234       * 'exec2crl'.
1235       *
1236       * See err_get_envvar_global() and err_get_envvar_local().
1237       */
1238  
1239  /* ********************************************************************** */
1240  /* stderr redirection (deprecated)*/
1241  
1242  #ifdef ERR_REDIR_STDERR
1243      /* This is deprecated. */
1244  
1245  extern int  err_fprintf_tag (void);
1246  extern void err_fprintf_tag_set (int /*tag*/);
1247     /* The tag to use for messages coming in via fprintf (stderr...)
1248      *
1249      * By default, this is C_TAG_NOCLASS.
1250      */
1251  
1252  #endif
1253  
1254  #ifdef __cplusplus
1255  }
1256  #endif
1257  
1258  #ifdef __cplusplus
1259  
1260  extern void err_add_callback (
1261      int /*tags*/, int /*priority*/, err_style_t const *);
1262  
1263  extern void err_add_callback (
1264      int /*tags*/, int /*priority*/, err_callback2_voidp_t, void *, err_style_t const *);
1265  extern void err_add_callback (
1266      int /*tags*/, int /*priority*/, err_callback2_int_t, int, err_style_t const *);
1267  extern void err_add_callback (
1268      int /*tags*/, int /*priority*/, err_callback2_t, err_style_t const *);
1269  
1270  extern void err_add_callback (
1271      int /*tags*/, int /*priority*/, err_callback0_voidp_t, void *, err_style_t const *);
1272  extern void err_add_callback (
1273      int /*tags*/, int /*priority*/, err_callback0_int_t, int, err_style_t const *);
1274  extern void err_add_callback (
1275      int /*tags*/, int /*priority*/, err_callback0_t, err_style_t const *);
1276  
1277  extern void err_add_callback (
1278      int /*tags*/, int /*priority*/, err_callback2_info_voidp_t, void *, err_style_t const *);
1279  extern void err_add_callback (
1280      int /*tags*/, int /*priority*/, err_callback2_info_int_t, int, err_style_t const *);
1281  extern void err_add_callback (
1282      int /*tags*/, int /*priority*/, err_callback2_info_t, err_style_t const *);
1283  
1284  extern void err_add_callback (
1285      int /*tags*/, int /*priority*/, err_callback0_info_voidp_t, void *, err_style_t const *);
1286  extern void err_add_callback (
1287      int /*tags*/, int /*priority*/, err_callback0_info_int_t, int, err_style_t const *);
1288  extern void err_add_callback (
1289      int /*tags*/, int /*priority*/, err_callback0_info_t, err_style_t const *);
1290  
1291  
1292  extern void err_remove_callback (
1293      int /*tags*/, int /*priority*/, err_callback2_voidp_t /*function*/);
1294  extern void err_remove_callback (
1295      int /*tags*/, int /*priority*/, err_callback2_voidp_t /*function*/, void * /*data*/);
1296  extern void err_remove_callback (
1297      int /*tags*/, int /*priority*/, err_callback0_voidp_t /*function*/);
1298  extern void err_remove_callback (
1299      int /*tags*/, int /*priority*/, err_callback0_voidp_t /*function*/, void * /*data*/);
1300  extern void err_remove_callback (
1301      int /*tags*/, int /*priority*/, err_callback2_info_voidp_t /*function*/);
1302  extern void err_remove_callback (
1303      int /*tags*/, int /*priority*/, err_callback2_info_voidp_t /*function*/, void * /*data*/);
1304  extern void err_remove_callback (
1305      int /*tags*/, int /*priority*/, err_callback0_info_voidp_t /*function*/);
1306  extern void err_remove_callback (
1307      int /*tags*/, int /*priority*/, err_callback0_info_voidp_t /*function*/, void * /*data*/);
1308  
1309  extern void err_remove_callback (
1310      int /*tags*/, int /*priority*/, err_callback2_int_t /*function*/);
1311  extern void err_remove_callback (
1312      int /*tags*/, int /*priority*/, err_callback2_int_t /*function*/, int /*data*/);
1313  extern void err_remove_callback (
1314      int /*tags*/, int /*priority*/, err_callback0_int_t /*function*/);
1315  extern void err_remove_callback (
1316      int /*tags*/, int /*priority*/, err_callback0_int_t /*function*/, int /*data*/);
1317  extern void err_remove_callback (
1318      int /*tags*/, int /*priority*/, err_callback2_info_int_t /*function*/);
1319  extern void err_remove_callback (
1320      int /*tags*/, int /*priority*/, err_callback2_info_int_t /*function*/, int /*data*/);
1321  extern void err_remove_callback (
1322      int /*tags*/, int /*priority*/, err_callback0_info_int_t /*function*/);
1323  extern void err_remove_callback (
1324      int /*tags*/, int /*priority*/, err_callback0_info_int_t /*function*/, int /*data*/);
1325  
1326  extern void err_remove_callback (
1327      int /*tags*/, int /*priority*/, err_callback2_t /*function*/);
1328  extern void err_remove_callback (
1329      int /*tags*/, int /*priority*/, err_callback0_t /*function*/);
1330  extern void err_remove_callback (
1331      int /*tags*/, int /*priority*/, err_callback2_info_t /*function*/);
1332  extern void err_remove_callback (
1333      int /*tags*/, int /*priority*/, err_callback0_info_t /*function*/);
1334  
1335  
1336  extern void err_set_subsystem_callback (
1337      int /*subsystem*/, err_style_t const *);
1338  
1339  extern void err_set_subsystem_callback (
1340      int /*subsystem*/, err_callback2_voidp_t, void *, err_style_t const *);
1341  extern void err_set_subsystem_callback (
1342      int /*subsystem*/, err_callback2_int_t, int, err_style_t const *);
1343  extern void err_set_subsystem_callback (
1344      int /*subsystem*/, err_callback2_t, err_style_t const *);
1345  extern void err_set_subsystem_callback (
1346      int /*subsystem*/, err_callback0_voidp_t, void *, err_style_t const *);
1347  extern void err_set_subsystem_callback (
1348      int /*subsystem*/, err_callback0_int_t, int, err_style_t const *);
1349  extern void err_set_subsystem_callback (
1350      int /*subsystem*/, err_callback0_t, err_style_t const *);
1351  
1352  extern void err_set_subsystem_callback (
1353      int /*subsystem*/, err_callback2_info_voidp_t, void *, err_style_t const *);
1354  extern void err_set_subsystem_callback (
1355      int /*subsystem*/, err_callback2_info_int_t, int, err_style_t const *);
1356  extern void err_set_subsystem_callback (
1357      int /*subsystem*/, err_callback2_info_t, err_style_t const *);
1358  extern void err_set_subsystem_callback (
1359      int /*subsystem*/, err_callback0_info_voidp_t, void *, err_style_t const *);
1360  extern void err_set_subsystem_callback (
1361      int /*subsystem*/, err_callback0_info_int_t, int, err_style_t const *);
1362  extern void err_set_subsystem_callback (
1363      int /*subsystem*/, err_callback0_info_t, err_style_t const *);
1364  
1365  #endif
1366  
1367  #endif /* !defined HT_LIBERROR_2932_H */

Index

Stoppt die Vorratsdatenspeicherung
November 26th, 2007
Comments? Suggestions? Corrections? You can drop me a line.
zpentrabvagiktu@theiling.de
Schwerpunktpraxis