Base Module =========== This module contains common functions and classes used throughout the rest of the library .. c:macro:: C2P_PROTOCOL_MAJOR_VERSION This macro defines the major version number. A change here indicates a major change or release, and may be breaking. In a scheme x.y.z, it would be x .. c:macro:: C2P_PROTOCOL_MINOR_VERSION This macro defines the minor version number. It refers specifically to minor protocol revisions, and all changes here are API compatible (after 1.0), but not compatbile with other nodes. In a scheme x.y.z, it would be y .. c:macro:: C2P_NODE_VERSION This macro defines the patch version number. It refers specifically to node policies, and all changes here are backwards compatible. In a scheme x.y.z, it would be z .. c:macro:: C2P_VERSION This macro is a string literal. It combines all the above macros into a single string. It will generate whatever a string literal would normally be interpreted as in that context. .. c:macro:: C2P_DEBUG_FLAG This macro indicates whether cp2p should generate debug prints. If you define this as anything it will print .. c:function:: unsigned long getUTC() Returns the current UNIX second in UTC .. c:function:: static void get_user_salt(char result[36]) This generates a uuid4 for use in this library. ``result`` should be of length 36 .. c:function:: static unsigned long long unpack_value(const char *str, size_t len) Unpacks a big-endian binary value into an unsigned long long :param str: The value you'd like to unpack :param len: The length of this value :returns: The value this string contained .. warning:: Integer overflow will not be accounted for .. c:function:: static void pack_value(size_t len, char *arr, unsigned long long i) Packs an unsigned long long into a big-endian binary buffer of length len :param len: The length of the string you'd like to produce :param arr: The buffer you would like to fill :param i: The value you'd like to pack .. warning:: Integer overflow will not be accounted for .. c:function:: static int sanitize_string(char *str, size_t *len, int sizeless) Mutates str to be clean for processing by :c:func:`deserializeInternalMessage`. :param str: The string you wish to mutate :param len: The length of said string :param sizeless: A boolean which indicates whether the string has a standard size header :returns: ``-1`` if str was invalid for processing, ``0`` if all went well .. c:function:: static int decompress_string(char *str, size_t len, char *result, size_t *res_len, char **compressions, size_t *compression_sizes, size_t num_compressions) Puts a decompressed copy of str into result, and updates res_len to contain its length. :param str: The string you wish to decompress :param len: The length of this string :param result: A pointer to the resulting string :param res_len: A pointer to the length of the result :param compressions: The list of possible compression methods :param compression_sizes: The length of each compression method :param num_compressions: The number of compression methods :returns: ``-1`` if decompression failed, ``0`` if all went well .. warning:: If you do not :c:func:`free` ``result`` you will develop a memory leak