home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / c / gnu_c / patches / DeskLib / h / Error < prev    next >
Encoding:
Text File  |  1994-10-03  |  4.0 KB  |  114 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Error.h
  12.     Author:  Copyright © 1992 Jason Williams
  13.              Improved by Philip Colmer
  14.     Version: 1.054(13 Jul 1993)
  15.     Purpose: Centralised error reporting, with hopefully useful routines,
  16.              but which YOU (the user) can change if you want something
  17.              different
  18.     Mods:    7 Apr 1992 - JCW - Added Error_OutOfMemory
  19.             14 Jun 1993 - PJC - Allowed Error_Report(Fatal) to take
  20.                                 variable arguments
  21.             13 Jul 1993 - PJC - Added varargs to "Internal" versions of above
  22. */
  23.  
  24. #ifndef __dl_error_h
  25. #define __dl_error_h
  26.  
  27. #ifndef __kernel_h
  28. #include "kernel.h"
  29. #endif
  30.  
  31. #ifndef __dl_core_h
  32. #include "Core.h"
  33. #endif
  34.  
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38.  
  39.  
  40. /* Error_ReportInternal ----------------------------------------------------
  41.  * This is identical to Error_Report, except it is used for most DeskLib
  42.  * library internal errors. User code should use Error_Report. This allows
  43.  * you to modify the treatment of internal errors, without affecting your
  44.  * own error handling.
  45.  */
  46. extern void Error_ReportInternal(int errornum, char *report, ...);
  47.  
  48.  
  49. /* Error_ReportFatalInternal -----------------------------------------------
  50.  * This does an Error_ReportInternal, and then calls exit()
  51.  */
  52. extern void Error_ReportFatalInternal(int errornum, char *report, ...);
  53.  
  54.  
  55. /* Error_Report ------------------------------------------------------------
  56.  * This is a centralised user-error reporting function.
  57.  * Call it, citing any error number you want, and any error string you want.
  58.  * The current implementation merely invokes Wimp_ReportError, but use it
  59.  * from your code, as then the method by which you report errors can be
  60.  * altered just by changing Error.c
  61.  *
  62.  * The report is a 'printf' style formatting string, optionally followed
  63.  * by arguments just as in printf commands. This saves you from having to
  64.  * pre-assemble strings to pass in.
  65.  * examples:
  66.  *   Error_Report(5, "My VIDC just blew up!");
  67.  *   Error_Report(6, "You can't put the number %d in there!", thenumber);
  68.  */
  69. extern void Error_Report(int errornum, char *report, ...);
  70.  
  71.  
  72. /* Error_ReportFatal -------------------------------------------------------
  73.  * Exactly the same as Error_Report, except after reporting the error, it
  74.  * terminates the program by calling exit()
  75.  *
  76.  * Takes variable arguments a la 'printf'. See Error_Report for more info.
  77.  */
  78. extern void Error_ReportFatal(int errornum, char *report, ...);
  79.  
  80.  
  81. /* Error_Check -------------------------------------------------------------
  82.  * Used to encapsulate an OS call to automatically check for error return.
  83.  * If the OS call returns an error, then it will be reported, and the
  84.  * function returns TRUE.
  85.  * Otherwise, no action is taken, and FALSE is returned
  86.  */
  87. extern BOOL Error_Check(os_error *error);
  88.  
  89.  
  90. /* Error_CheckFatal --------------------------------------------------------
  91.  * Identical to Error_Check, but calls exit() if an error ocurred
  92.  */
  93. extern void Error_CheckFatal(os_error *error);
  94.  
  95.  
  96. /* Error_OutOfMemory -------------------------------------------------------
  97.  * Reports a memory error (e.g. "Unable to claim enough memory for
  98.  * [Messages]"), where you supply just the "place" of the failure
  99.  * (e.g. in this case, in the "Messages" section)
  100.  * if "fatal" is TRUE, Error_ReportFatal is used, else Error_Report is used.
  101.  *
  102.  * This function ALWAYS returns FALSE (== 0 == NULL), so you can use:
  103.  *   if (spritearea == NULL)
  104.  *     return(Error_OutOfMemory(FALSE, "icon sprites"));
  105.  */
  106. extern BOOL Error_OutOfMemory(BOOL fatal, char *place);
  107.  
  108.  
  109. #ifdef __cplusplus
  110.            }
  111. #endif
  112.  
  113. #endif
  114.