HTError.h
Upload User: zlh9724
Upload Date: 2007-01-04
Package Size: 1991k
Code Size: 7k
Category:

Browser Client

Development Platform:

Unix_Linux

  1. /*                                                                              Error Manager
  2.                        REPORTING ERRORS AND MESSAGES TO THE CLIENT
  3.                                              
  4.  */
  5. /*
  6. **      (c) COPYRIGHT MIT 1995.
  7. **      Please first read the full copyright statement in the file COPYRIGH.
  8. */
  9. /*
  10.    This is the implementaion of an error message reporting system that reports errors
  11.    occured either in a stream module (structured streams inclusive) or in a protocol
  12.    module. A list of errors are put into the a list which can be bound to a request object
  13.    or to a stream.
  14.    
  15.    This module is implemented by HTError.c, and it is a part of the  W3C Reference
  16.    Library.
  17.    
  18.  */
  19. #ifndef HTERROR_H
  20. #define HTERROR_H
  21. #include "HTReq.h"
  22. /*
  23. Error Codes and Messages
  24.    Note:  All non-HTTP error codes have index numbers > HTERR_HTTP_CODES, and they will
  25.    not be shown in the error-message generated.
  26.    
  27.  */
  28. typedef enum _HTErrorElement {
  29.         HTERR_OK = 0,                                           /* 200 */
  30.         HTERR_CREATED,                                          /* 201 */
  31.         HTERR_ACCEPTED,                                         /* 202 */
  32.         HTERR_PARTIAL,                                          /* 203 */
  33.         HTERR_NO_CONTENT,                                       /* 204 */
  34.         HTERR_MOVED,                                            /* 301 */
  35.         HTERR_FOUND,                                            /* 302 */
  36.         HTERR_METHOD,                                           /* 303 */
  37.         HTERR_NOT_MODIFIED,                                     /* 304 */
  38.         HTERR_BAD_REQUEST,                                      /* 400 */
  39.         HTERR_UNAUTHORIZED,                                     /* 401 */
  40.         HTERR_PAYMENT_REQUIRED,                                 /* 402 */
  41.         HTERR_FORBIDDEN,                                        /* 403 */
  42.         HTERR_NOT_FOUND,                                        /* 404 */
  43.         HTERR_NOT_ALLOWED,                                      /* 405 */
  44.         HTERR_NONE_ACCEPTABLE,                                  /* 406 */
  45.         HTERR_PROXY,                                            /* 407 */
  46.         HTERR_TIMEOUT,                                          /* 408 */
  47.         HTERR_INTERNAL,                                         /* 500 */
  48.         HTERR_NOT_IMPLEMENTED,                                  /* 501 */
  49.         HTERR_BAD_GATE,                                         /* 502 */
  50.         HTERR_DOWN,                                             /* 503 */
  51.         HTERR_GATE_TIMEOUT,                                     /* 504 */
  52.         HTERR_HTTP_CODES_END,    /* Put all non-HTTP status codes after this */
  53.         HTERR_NO_REMOTE_HOST,
  54.         HTERR_NO_HOST,
  55.         HTERR_NO_FILE,
  56.         HTERR_FTP_SERVER,
  57.         HTERR_FTP_NO_RESPONSE,
  58.         HTERR_TIME_OUT,
  59.         HTERR_GOPHER_SERVER,
  60.         HTERR_INTERRUPTED,
  61.         HTERR_CON_INTR,
  62.         HTERR_CSO_SERVER,
  63.         HTERR_HTTP09,
  64.         HTERR_BAD_REPLY,
  65.         HTERR_UNKNOWN_AA,
  66.         HTERR_NEWS_SERVER,
  67.         HTERR_FILE_TO_FTP,
  68.         HTERR_MAX_REDIRECT,
  69.         HTERR_EOF,
  70.         HTERR_WAIS_OVERFLOW,
  71.         HTERR_WAIS_MODULE,
  72.         HTERR_WAIS_NO_CONNECT,
  73.         HTERR_SYSTEM,
  74.         HTERR_CLASS,
  75.         HTERR_ACCESS,
  76.         HTERR_LOGIN,
  77.         HTERR_ELEMENTS                      /* This MUST be the last element */
  78. } HTErrorElement;
  79. /*
  80. Creation and Deletion Methods
  81.   ADD AN ERROR
  82.   
  83.    Add an error message to the error list. `par' and `where' might be set to NULL. If par
  84.    is a string, it is sufficient to let length be unspecified, i.e., 0. If only a part of
  85.    the string is wanted then specify a length inferior to strlen((char *) par).  The
  86.    string is '' terminated automaticly.  See also HTError_addSystem for system errors.
  87.    Returns YES if OK, else NO.
  88.    
  89.  */
  90. typedef struct _HTError HTError;
  91. typedef enum _HTSeverity {
  92.     ERR_FATAL             = 0x1,
  93.     ERR_NON_FATAL         = 0x2,
  94.     ERR_WARN              = 0x4,
  95.     ERR_INFO              = 0x8
  96. } HTSeverity;
  97. extern BOOL HTError_add (HTList *       list,
  98.                          HTSeverity     severity,
  99.                          BOOL           ignore,
  100.                          int            element,
  101.                          void *         par,
  102.                          unsigned int   length,
  103.                          char *         where);
  104. /*
  105.   ADD A SYSTEM ERROR
  106.   
  107.    Add a system error message to the error list. syscall is the name of the system call,
  108.    e.g. "close". The message put to the list is that corresponds to the error number
  109.    passed. See also HTError_add. Returns YES if OK, else NO.
  110.    
  111.  */
  112. extern BOOL HTError_addSystem (HTList *         list,
  113.                                HTSeverity       severity,
  114.                                int              errornumber,
  115.                                BOOL             ignore,
  116.                                char *           syscall);
  117. /*
  118.   DELETE AN ENTIRE ERROR STACK
  119.   
  120.    Deletes all errors in a list.
  121.    
  122.  */
  123. extern BOOL HTError_deleteAll (HTList * list);
  124. /*
  125.   DELETES THE LAST EDDED ENTRY
  126.   
  127.    Deletes the last error entry added to the list. Return YES if OK, else NO
  128.    
  129.  */
  130. extern BOOL HTError_deleteLast (HTList * list);
  131. /*
  132. How Should Errors be Presented
  133.    This variable dictates which errors should be put out when generating the message to
  134.    the user. The first four enumerations make it possible to see `everything as bad or
  135.    worse than' this level, e.g. HT_ERR_SHOW_NON_FATAL shows messages of type
  136.    HT_ERR_SHOW_NON_FATAL and HT_ERR_SHOW_FATAL.
  137.    
  138.    Note: The default value is made so that it only puts a message to stderr if a `real'
  139.    error has occurred. If a separate widget is available for information and error
  140.    messages then probably HT_ERR_SHOW_DETAILED would be more appropriate.
  141.    
  142.  */
  143. typedef enum _HTErrorShow {
  144.     HT_ERR_SHOW_FATAL     = 0x1,
  145.     HT_ERR_SHOW_NON_FATAL = 0x3,
  146.     HT_ERR_SHOW_WARNING   = 0x7,
  147.     HT_ERR_SHOW_INFO      = 0xF,
  148.     HT_ERR_SHOW_PARS      = 0x10,
  149.     HT_ERR_SHOW_LOCATION  = 0x20,
  150.     HT_ERR_SHOW_IGNORE    = 0x40,
  151.     HT_ERR_SHOW_FIRST     = 0x80,
  152.     HT_ERR_SHOW_LINKS     = 0x100,
  153.     HT_ERR_SHOW_DEFAULT   = 0x13,
  154.     HT_ERR_SHOW_DETAILED  = 0x1F,
  155.     HT_ERR_SHOW_DEBUG     = 0x7F
  156. } HTErrorShow;
  157. extern HTErrorShow HTError_show (void);
  158. extern BOOL HTError_setShow (HTErrorShow mask);
  159. /*
  160.   SHOW THE ERROR ENTRY?
  161.   
  162.    Should we show this entry in the list or just continue to the next one?
  163.    
  164.  */
  165. extern BOOL HTError_doShow (HTError * info);
  166. /*
  167. Ignore last Added Error
  168.    Turns on the `ignore' flag for the most recent error entered the error list. Returns
  169.    YES if OK else NO
  170.    
  171.  */
  172. extern BOOL HTError_ignoreLast  (HTList * list);
  173. extern BOOL HTError_setIgnore   (HTError * info);
  174. /*
  175. Methods for Accessing the Error Object
  176.    The definition of the error code and the error message is not part of the core Libray.
  177.    Only the definition of the Error object itself is. This object has an index number
  178.    defined by the HTErrorElement above. The mapping from this index to an erro code and a
  179.    message is for the application to do. The Library provides a default implementation in
  180.    the HTDialog module. These are the methods for accessing the error object:
  181.    
  182.  */
  183. extern int HTError_index                (HTError * info);
  184. extern HTSeverity HTError_severity      (HTError * info);
  185. extern void * HTError_parameter         (HTError * info, int * length);
  186. extern CONST char * HTError_location    (HTError * info);
  187. /*
  188.  */
  189. #endif
  190. /*
  191.    End of Declaration Manager */