A quick reference for using the srs_alt library.
Functions
srs_add_secret
srs_close
srs_forward
srs_generate_unique_id
srs_geterrormsg
srs_open
srs_reverse
srs_set_db_functions
srs_set_option
srs_set_separator
srs_result srs_add_secret(srs_t *srs, char *secret, uint secret_len);
Adds a secondary secret to the srs handle that is used for verification of hashes. The primary key, set when calling srs_open is used for creating SRS hashes as well as verficication.
Possible return values are SRS_RESULT_OK, SRS_RESULT_BADHANDLE, SRS_RESULT_BADPARAM, and SRS_RESULT_OUTOFMEMORY
srs_result srs_close(srs_t *srs);
Frees any memory associated with an srs handle.
srs_result srs_forward(srs_t *srs, char *orig_sender, char *return_domain,
char *return_path, uint return_path_len);
Performs an SRS forward on the address orig_sender using the domain return_domain as the domain part of the resulting address and places it in return_path.
Possible return values are SRS_RESULT_OK, SRS_RESULT_BADHANDLE, SRS_RESULT_BADPARAM, SRS_RESULT_ADDRESSTOOLONG, SRS_RESULT_BADSRS, SRS_RESULT_INTERNALERROR and SRS_RESULT_BUFFERTOOSMALL
srs_result srs_generate_unique_id(srs_t *srs, char *address, char *id_buffer, uint id_buffer_len);
Intended for use in database insert callback to generate a unique key. Performs a hash on address using srs and returns up to id_buffer_len-1 bytes of the BASE64 encoded version.
Possible return values are SRS_RESULT_OK, SRS_RESULT_BADHANDLE and SRS_RESULT_INTERNALERROR
char *srs_geterrormsg(srs_result result);
Returns error message text for a result code from any srs function.
srs_t *srs_open(char *secret, uint secret_len, uint max_age, uint hash_len, uint hash_min);
This must be called to create and initialise an srs_t structure. The only required parameters are secret and secret_len. secret_len must be between SRS_MAX_SECRET_LENGTH and SRS_MIN_SECRET_LENGTH.
To use deafult settings for other parameters, use 0.
Returns NULL on error.
srs_result srs_reverse(srs_t *srs, char *address, char *destination, uint destination_len);
Performs a reverse SRS on a valid SRS address address using the settings from srs and places it in destination.
Possible return values are SRS_RESULT_OK, SRS_RESULT_BADHANDLE, SRS_RESULT_BADPARAM, SRS_RESULT_NOTSRS, SRS_RESULT_BADSRS, SRS_RESULT_BADHASH, SRS_RESULT_BADTIMESTAMP, SRS_RESULT_TIMESTAMPEXPIRED, SRS_RESULT_CASEBROKEN and SRS_RESULT_BUFFERTOOSMALL
srs_result srs_set_db_functions(srs_t *srs, srs_db_callback *insert_function,
srs_db_callback *lookup_function);
If insert_function and lookup_function are both NULL then the function turns off database fucntionality (as is the case by default).
Otherwise, the functions are used for inserting and lookup of database keys. See Database Callback for more information.
srs_result srs_set_option(srs_t *srs, int option, int value);
Sets option option to value value. Possible options are SRS_OPTION_USETIMESTAMP and SRS_OPTION_USEHASH which both take values of true or false.
Possible return values are SRS_RESULT_OK, SRS_RESULT_BADHANDLE and SRS_RESULT_BADPARAM
srs_result srs_set_separator(srs_t *srs, char separator);
Used to change the SRS separator. The default is '='. Other possibilities are '+' and '-'.