Changeset 573
- Timestamp:
- May 3, 2004, 6:13:29 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/doc/pslib/psLibSDRS.tex (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/pslib/psLibSDRS.tex
r534 r573 1 %%% $Id: psLibSDRS.tex,v 1. 39 2004-04-28 00:27:24price Exp $1 %%% $Id: psLibSDRS.tex,v 1.40 2004-05-04 04:13:29 price Exp $ 2 2 \documentclass[panstarrs]{panstarrs} 3 3 … … 897 897 \hlabel{psErrorCodes} 898 898 899 The type \code{psErrorCode} is defined by an auxiliary file, conventionally named 900 \file{psErrorCodes.dat}. This file shall consist of a number of lines, each 901 of the form: 902 \begin{verbatim} 903 NAME [ = value ] , STRING 904 \end{verbatim} 905 where \code{[ = value]} is optional, and no spaces are significant except in the 906 STRING. Comments extend from \code{#} to the end of the line (except that a 907 \code{\#} shall be replaced by \code{#} and not taken to start a comment). For example, 899 Both error codes for PSLib and error codes for projects that use PSLib 900 may be registered. In the former case, the error codes shall be 901 registered on initialisation, whereas in the latter case, it is 902 required to explicitly register. 903 904 \paragraph{Registering error codes} 905 906 An array of error codes may be registered with the PSLib error handler 907 using a private function: 908 909 \begin{verbatim} 910 void p_psErrorRegister(const psErrorDescription *errors, ///< register a set of errors 911 int nerror ///< number of errors 912 ); 913 \end{verbatim} 914 915 Where the errors are represented internally as follows: 916 \begin{verbatim} 917 typedef struct { 918 psErrorCode code; // An error code 919 char *descrip; // the associated description 920 } psErrorDescription; 921 \end{verbatim} 922 923 Projects wishing to employ the PSLib error handler should define 924 a function, 925 \begin{verbatim} 926 void prefixErrorRegister(void); 927 \end{verbatim} 928 where \code{prefix} is particular to the project. For example, PSLib 929 should have a function, 930 \begin{verbatim} 931 void psErrorRegister(void); 932 \end{verbatim} 933 In this case (i.e., error codes for PSLib), the function should be 934 called upon initialisation. As another example, MOPS should implement 935 a function, 936 \begin{verbatim} 937 void mopsErrorRegister(void); 938 \end{verbatim} 939 which would be called explicitly when MOPS utilises PSLib. 940 941 It is left to the external project to produce the appropriate 942 \code{prefixErrorRegister()}, but they may find helpful the 943 implementation discussed below for use in PSLib. 944 945 There is a clear need to coordinate the choice of error numbers. It 946 is expected that error code ranges for different projects shall be 947 managed by the Project Office. 948 949 \paragraph{Error Codes for PSLib} 950 951 For ease of maintenance, error codes for PSLib shall be defined by an 952 auxiliary file, conventionally named \file{psErrorCodes.dat}. The 953 format of this file shall consist of a number of lines, each of the 954 form: 955 \begin{verbatim} 956 NAME [ = value ][,] STRING 957 \end{verbatim} 958 where \code{[ = value]} and the comma are optional, and no spaces are 959 significant except in the STRING. Comments extend from \code{#} to 960 the end of the line (except that a \code{\#} shall be replaced by 961 \code{#} and not taken to start a comment). For example, 908 962 \begin{verbatim} 909 963 # … … 913 967 BASE = 256, first value we use; should avoid errno conflicts 914 968 UNKNOWN, unknown error 969 # This is a comment, and is ignored. 915 970 IO, I/O error 916 971 BADFREE, bad argument to psFree() … … 919 974 The values \code{NONE = 0} and {UNKNOWN} must be present. 920 975 921 The \PS{} Makefiles shall 922 generate two files, \file{psErrorCodes.h} and 923 \file{psErrorCodes.c} from the input file \file{psErrorCodes.dat}. 924 \file{psErrorCodes.h} shall define an enumerated type 925 \code{psErrorCode} with elements \code{PS_ERR_NAME} and values as specified 926 in \file{psErrorCodes.dat}, e.g. 976 A script, called from the Makefiles, shall generate two files, 977 \file{psErrorCodes.h} and \file{psErrorCodes.c} from the input file 978 \file{psErrorCodes.dat}. \file{psErrorCodes.h} shall define an 979 enumerated type \code{psErrorCode} with elements \code{PS_ERR_NAME} 980 and values as specified in \file{psErrorCodes.dat}, e.g. 927 981 \begin{verbatim} 928 982 #if !defined(PS_ERROR_CODES_H) … … 938 992 PS_ERR_N_ERR_CLASSES, 939 993 } psErrorCode; 940 941 994 #endif 942 995 \end{verbatim} 996 943 997 Any \code{errorCode}s less then or equal to \code{PS_ERR_BASE} shall be taken 944 998 to be valid values of \code{errno}. 945 999 946 The implementation may add extra fields (e.g. \code{PS_ERR_N_ERR_CLASSES}). 947 948 The latter shall be of the form 949 \begin{verbatim} 950 static struct { 951 psErrorCode code; 952 char *descrip; 953 } errorStrings[] = { 954 { PS_ERR_NONE, "not an error; must be 0"}, 955 { PS_ERR_BASE, "first value we use; should avoid errno conflicts"}, 956 { PS_ERR_UNKNOWN, "unknown error"}, 957 { PS_ERR_IO, "I/O error"}, 958 { PS_ERR_BADFREE, "bad argument to psFree()"}, 959 { PS_ERR_MEMORY_CORRUPTION, "memory corruption detected"}, 960 { PS_ERR_N_ERR_CLASSES, NULL}, 961 }; 962 \end{verbatim} 1000 The implementation may add extra fields (e.g., \code{PS_ERR_N_ERR_CLASSES}). 1001 1002 \file{psErrorCodes.c} shall define the necessary function to register 1003 the error codes. 963 1004 964 1005 \subsubsection{Example}
Note:
See TracChangeset
for help on using the changeset viewer.
