1e1051a39Sopenharmony_ciAdding new libraries
2e1051a39Sopenharmony_ci====================
3e1051a39Sopenharmony_ci
4e1051a39Sopenharmony_ciWhen adding a new sub-library to OpenSSL, assign it a library number
5e1051a39Sopenharmony_ci`ERR_LIB_XXX`, define a macro `XXXerr()` (both in `err.h`), add its
6e1051a39Sopenharmony_ciname to `ERR_str_libraries[]` (in `crypto/err/err.c`), and add
7e1051a39Sopenharmony_ci`ERR_load_XXX_strings()` to the `ERR_load_crypto_strings()` function
8e1051a39Sopenharmony_ci(in `crypto/err/err_all.c`). Finally, add an entry:
9e1051a39Sopenharmony_ci
10e1051a39Sopenharmony_ci    L      XXX     xxx.h   xxx_err.c
11e1051a39Sopenharmony_ci
12e1051a39Sopenharmony_cito `crypto/err/openssl.ec`, and add `xxx_err.c` to the `Makefile`.
13e1051a39Sopenharmony_ciRunning make errors will then generate a file `xxx_err.c`, and
14e1051a39Sopenharmony_ciadd all error codes used in the library to `xxx.h`.
15e1051a39Sopenharmony_ci
16e1051a39Sopenharmony_ciAdditionally the library include file must have a certain form.
17e1051a39Sopenharmony_ciTypically it will initially look like this:
18e1051a39Sopenharmony_ci
19e1051a39Sopenharmony_ci    #ifndef HEADER_XXX_H
20e1051a39Sopenharmony_ci    #define HEADER_XXX_H
21e1051a39Sopenharmony_ci
22e1051a39Sopenharmony_ci    #ifdef __cplusplus
23e1051a39Sopenharmony_ci    extern "C" {
24e1051a39Sopenharmony_ci    #endif
25e1051a39Sopenharmony_ci
26e1051a39Sopenharmony_ci    /* Include files */
27e1051a39Sopenharmony_ci
28e1051a39Sopenharmony_ci    #include <openssl/bio.h>
29e1051a39Sopenharmony_ci    #include <openssl/x509.h>
30e1051a39Sopenharmony_ci
31e1051a39Sopenharmony_ci    /* Macros, structures and function prototypes */
32e1051a39Sopenharmony_ci
33e1051a39Sopenharmony_ci
34e1051a39Sopenharmony_ci    /* BEGIN ERROR CODES */
35e1051a39Sopenharmony_ci
36e1051a39Sopenharmony_ciThe `BEGIN ERROR CODES` sequence is used by the error code
37e1051a39Sopenharmony_cigeneration script as the point to place new error codes, any text
38e1051a39Sopenharmony_ciafter this point will be overwritten when make errors is run.
39e1051a39Sopenharmony_ciThe closing `#endif` etc will be automatically added by the script.
40e1051a39Sopenharmony_ci
41e1051a39Sopenharmony_ciThe generated C error code file `xxx_err.c` will load the header
42e1051a39Sopenharmony_cifiles `stdio.h`, `openssl/err.h` and `openssl/xxx.h` so the
43e1051a39Sopenharmony_ciheader file must load any additional header files containing any
44e1051a39Sopenharmony_cidefinitions it uses.
45e1051a39Sopenharmony_ci
46e1051a39Sopenharmony_ciAdding new error codes
47e1051a39Sopenharmony_ci======================
48e1051a39Sopenharmony_ci
49e1051a39Sopenharmony_ciInstead of manually adding error codes into `crypto/err/openssl.txt`,
50e1051a39Sopenharmony_ciit is recommended to leverage `make update` for error code generation.
51e1051a39Sopenharmony_ciThe target will process relevant sources and generate error codes for
52e1051a39Sopenharmony_ciany *used* error codes.
53e1051a39Sopenharmony_ci
54e1051a39Sopenharmony_ciIf an error code is added manually into `crypto/err/openssl.txt`,
55e1051a39Sopenharmony_cisubsequent `make update` has no effect.
56