| 1 |
/** BEGIN COPYRIGHT BLOCK |
| 2 |
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission. |
| 3 |
* Copyright (C) 2005 Red Hat, Inc. |
| 4 |
* All rights reserved. |
| 5 |
* |
| 6 |
* License: GPL (version 3 or any later version). |
| 7 |
* See LICENSE for details. |
| 8 |
* END COPYRIGHT BLOCK **/ |
| 9 |
|
| 10 |
#ifdef HAVE_CONFIG_H |
| 11 |
#include <config.h> |
| 12 |
#endif |
| 13 |
|
| 14 |
#ifndef PUBLIC_NSACL_NSERRDEF_H |
| 15 |
#define PUBLIC_NSACL_NSERRDEF_H |
| 16 |
|
| 17 |
/* |
| 18 |
* Type: NSEFrame_t |
| 19 |
* |
| 20 |
* Description: |
| 21 |
* |
| 22 |
* This type describes the structure of an error frame. An error |
| 23 |
* frame contains the following items: |
| 24 |
* |
| 25 |
* ef_retcode - This is a copy of the traditional error code, |
| 26 |
* as might be returned as a function value to |
| 27 |
* indicate an error. The purpose of the error |
| 28 |
* code is to provide the caller of a function |
| 29 |
* with sufficient information to determine how |
| 30 |
* to process the error. That is, it does not |
| 31 |
* need to identify a specific error, but only |
| 32 |
* has to distinguish between classes of errors |
| 33 |
* as needed by the caller to respond differently. |
| 34 |
* Usually this should be a small number of values. |
| 35 |
* |
| 36 |
* ef_errorid - This is an integer identifier which uniquely |
| 37 |
* identifies errors in a module or library. |
| 38 |
* That is, there should be only one place in |
| 39 |
* the source code of the module or library which |
| 40 |
* generates a particular error id. The error id |
| 41 |
* is used to select an error message in an error |
| 42 |
* message file. |
| 43 |
* |
| 44 |
* ef_program - This is a pointer to a string which identifies |
| 45 |
* the module or library context of ef_errorid. |
| 46 |
* The string is used to construct the name of |
| 47 |
* the message file in which an error message for |
| 48 |
* ef_errorid can be found. |
| 49 |
* |
| 50 |
* ef_errc - This is the number of values stored in ef_errc[] |
| 51 |
* for the current error id. |
| 52 |
* |
| 53 |
* ef_errv - This is an array of strings which are relevant |
| 54 |
* to a particular error id. These strings can |
| 55 |
* be included in an error message retrieved from |
| 56 |
* a message file. The strings in a message file |
| 57 |
* can contain "%s" sprintf() format codes. The |
| 58 |
* ef_errv[] strings are passed to sprintf() along |
| 59 |
* with the error message string. |
| 60 |
*/ |
| 61 |
|
| 62 |
#define NSERRMAXARG 8 /* size of ef_errv[] */ |
| 63 |
|
| 64 |
typedef struct NSEFrame_s NSEFrame_t; |
| 65 |
struct NSEFrame_s |
| 66 |
{ |
| 67 |
NSEFrame_t *ef_next; /* next error frame on NSErr_t list */ |
| 68 |
long ef_retcode; /* error return code */ |
| 69 |
long ef_errorid; /* error unique identifier */ |
| 70 |
const char *ef_program; /* context for ef_errorid */ |
| 71 |
int ef_errc; /* number of strings in ef_errv[] */ |
| 72 |
char *ef_errv[NSERRMAXARG]; /* arguments for formatting error message */ |
| 73 |
}; |
| 74 |
|
| 75 |
/* |
| 76 |
* Description (NSErr_t) |
| 77 |
* |
| 78 |
* This type describes the structure of a header for a list of |
| 79 |
* error frames. The header contains a pointer to the first |
| 80 |
* and last error frames on the list. The first error frame |
| 81 |
* is normally the one most recently generated, which usually |
| 82 |
* represents the highest-level interpretation available for an |
| 83 |
* error that is propogating upward in a call chain. These |
| 84 |
* structures are generally allocated as automatic or static |
| 85 |
* variables. |
| 86 |
*/ |
| 87 |
|
| 88 |
typedef struct NSErr_s NSErr_t; |
| 89 |
struct NSErr_s |
| 90 |
{ |
| 91 |
NSEFrame_t *err_first; /* first error frame */ |
| 92 |
NSEFrame_t *err_last; /* last error frame */ |
| 93 |
NSEFrame_t *(*err_falloc)(NSErr_t *errp); /* error frame allocator */ |
| 94 |
void (*err_ffree)(NSErr_t *errp, |
| 95 |
NSEFrame_t *efp); /* error frame deallocator */ |
| 96 |
}; |
| 97 |
|
| 98 |
/* Define an initializer for an NSErr_t */ |
| 99 |
#define NSERRINIT \ |
| 100 |
{ \ |
| 101 |
0, 0, 0, 0 \ |
| 102 |
} |
| 103 |
|
| 104 |
#ifndef INTNSACL |
| 105 |
|
| 106 |
#define nserrDispose (*__nsacl_table->f_nserrDispose) |
| 107 |
#define nserrFAlloc (*__nsacl_table->f_nserrFAlloc) |
| 108 |
#define nserrFFree (*__nsacl_table->f_nserrFFree) |
| 109 |
#define nserrGenerate (*__nsacl_table->f_nserrGenerate) |
| 110 |
|
| 111 |
#endif /* !INTNSACL */ |
| 112 |
|
| 113 |
#endif /* !PUBLIC_NSACL_NSERRDEF_H */ |