Changeset View
Changeset View
Standalone View
Standalone View
src/secp256k1/include/secp256k1.h
Show First 20 Lines • Show All 241 Lines • ▼ Show 20 Lines | |||||
* the case that this code itself is broken. | * the case that this code itself is broken. | ||||
* | * | ||||
* On the other hand, during debug stage, one would want to be informed about | * On the other hand, during debug stage, one would want to be informed about | ||||
* such mistakes, and the default (crashing) may be inadvisable. | * such mistakes, and the default (crashing) may be inadvisable. | ||||
* When this callback is triggered, the API function called is guaranteed not | * When this callback is triggered, the API function called is guaranteed not | ||||
* to cause a crash, though its return value and output arguments are | * to cause a crash, though its return value and output arguments are | ||||
* undefined. | * undefined. | ||||
* | * | ||||
* When this function has not been called (or called with fn==NULL), then the | |||||
* default handler will be used. The library provides a default handler which | |||||
* writes the message to stderr and calls abort. This default handler can be | |||||
* replaced at link time if the preprocessor macro | |||||
* USE_EXTERNAL_DEFAULT_CALLBACKS is defined, which is the case if the build | |||||
* has been configured with --enable-external-default-callbacks. Then the | |||||
* following two symbols must be provided to link against: | |||||
* - void secp256k1_default_illegal_callback_fn(const char* message, void* data); | |||||
* - void secp256k1_default_error_callback_fn(const char* message, void* data); | |||||
* The library can call these default handlers even before a proper callback data | |||||
* pointer could have been set using secp256k1_context_set_illegal_callback or | |||||
* secp256k1_context_set_illegal_callback, e.g., when the creation of a context | |||||
* fails. In this case, the corresponding default handler will be called with | |||||
* the data pointer argument set to NULL. | |||||
* | |||||
* Args: ctx: an existing context object (cannot be NULL) | * Args: ctx: an existing context object (cannot be NULL) | ||||
* In: fun: a pointer to a function to call when an illegal argument is | * In: fun: a pointer to a function to call when an illegal argument is | ||||
* passed to the API, taking a message and an opaque pointer | * passed to the API, taking a message and an opaque pointer. | ||||
* (NULL restores a default handler that calls abort). | * (NULL restores the default handler.) | ||||
* data: the opaque pointer to pass to fun above. | * data: the opaque pointer to pass to fun above. | ||||
* | |||||
* See also secp256k1_context_set_error_callback. | |||||
*/ | */ | ||||
SECP256K1_API void secp256k1_context_set_illegal_callback( | SECP256K1_API void secp256k1_context_set_illegal_callback( | ||||
secp256k1_context* ctx, | secp256k1_context* ctx, | ||||
void (*fun)(const char* message, void* data), | void (*fun)(const char* message, void* data), | ||||
const void* data | const void* data | ||||
) SECP256K1_ARG_NONNULL(1); | ) SECP256K1_ARG_NONNULL(1); | ||||
/** Set a callback function to be called when an internal consistency check | /** Set a callback function to be called when an internal consistency check | ||||
* fails. The default is crashing. | * fails. The default is crashing. | ||||
* | * | ||||
* This can only trigger in case of a hardware failure, miscompilation, | * This can only trigger in case of a hardware failure, miscompilation, | ||||
* memory corruption, serious bug in the library, or other error would can | * memory corruption, serious bug in the library, or other error would can | ||||
* otherwise result in undefined behaviour. It will not trigger due to mere | * otherwise result in undefined behaviour. It will not trigger due to mere | ||||
* incorrect usage of the API (see secp256k1_context_set_illegal_callback | * incorrect usage of the API (see secp256k1_context_set_illegal_callback | ||||
* for that). After this callback returns, anything may happen, including | * for that). After this callback returns, anything may happen, including | ||||
* crashing. | * crashing. | ||||
* | * | ||||
* Args: ctx: an existing context object (cannot be NULL) | * Args: ctx: an existing context object (cannot be NULL) | ||||
* In: fun: a pointer to a function to call when an internal error occurs, | * In: fun: a pointer to a function to call when an internal error occurs, | ||||
* taking a message and an opaque pointer (NULL restores a default | * taking a message and an opaque pointer (NULL restores the | ||||
* handler that calls abort). | * default handler, see secp256k1_context_set_illegal_callback | ||||
* for details). | |||||
* data: the opaque pointer to pass to fun above. | * data: the opaque pointer to pass to fun above. | ||||
* | |||||
* See also secp256k1_context_set_illegal_callback. | |||||
*/ | */ | ||||
SECP256K1_API void secp256k1_context_set_error_callback( | SECP256K1_API void secp256k1_context_set_error_callback( | ||||
secp256k1_context* ctx, | secp256k1_context* ctx, | ||||
void (*fun)(const char* message, void* data), | void (*fun)(const char* message, void* data), | ||||
const void* data | const void* data | ||||
) SECP256K1_ARG_NONNULL(1); | ) SECP256K1_ARG_NONNULL(1); | ||||
/** Create a secp256k1 scratch space object. | /** Create a secp256k1 scratch space object. | ||||
▲ Show 20 Lines • Show All 404 Lines • Show Last 20 Lines |