Lutz Behnke wrote:
> 
> Hello OpenSSL developers,
> 
> I am in need of a few extra error codes for my PKCS#11 extension,
> But I am not quite sure that I grasped all the details of
> the error code system.
> 
> What I understand is that
> - the defines for the codes are in the '.err' files in their
>   respective sections of the library.
> - a script generates tables of error codes and the proper lines for
>   the '.h' header.
> - Within the actual library sources the codes are only used by their
>   symbolic names
> 
> What I do not understand is:
> - If the actual numbers are never used, why are they not automaticaly
>   generated, one for each line in the '.err' files, and why are
>   they not in sequence, making inserting new ones a much more risky
>   business.
> 

Since 0.9.3 the .err files have vanished and its all done differently,
just to be awkward :-)

If all you are doing is adding reason and function codes to existing
libraries then you just need to add them in the C source files then type
"make errors" at the top level. Error codes will then be added to the
relevent header file and text generated in the relevant error source
file.

You shouldn't add error codes directly to header files: "make errors"
does that for you keeping the numbers unique.

What it does in detail is this.

1. Scans all the C source files for function and reason codes. 
2. Scans the header file prototypes for function names.
3. Scan the header files for existing function and reason codes.
4. If any new codes are needed they are added starting with one more
than the highest currently used code. Existing codes stay the same.
5. Rewrite the error C source file is any new codes were added, the
function codes are translated to the function names, if possible.

The reason the headers look out of order is that they are sorted
alphabetically but a new code could be added anywhere.

There are a number of reasons for doing things this way. If anyone
actually is taking notice of error numbers then the old ones are
retained. Also it keeps the patch sizes down: if the codes were assigned
numerically then adding one new code could completely re-order the
header file - it used to do this at one point.

There are options to the generation script (util/mkerr.pl) to start from
scratch when assigning codes and various other things as well such as
forcing it to re-write all header and C source files and there is a
config file telling it where to find all the header and source files.

It is also possible to add external error libraries: but that's another
story.

Steve.
-- 
Dr Stephen N. Henson.   http://www.drh-consultancy.demon.co.uk/
Personal Email: [EMAIL PROTECTED] 
Senior crypto engineer, Celo Communications: http://www.celocom.com/
Core developer of the   OpenSSL project: http://www.openssl.org/
Business Email: [EMAIL PROTECTED] PGP key: via homepage.


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to