ucx/utils.h

Wed, 27 Feb 2013 11:48:29 +0100

author
Mike Becker <universe@uap-core.de>
date
Wed, 27 Feb 2013 11:48:29 +0100
changeset 94
57ea041df22f
parent 92
ucx/comparator.h@7625a8efcc97
child 103
08018864fb91
permissions
-rw-r--r--

renamed comparator to utils module and added copy functions

universe@89 1 #ifndef COMPARATOR_H
universe@89 2 #define COMPARATOR_H
universe@89 3
universe@89 4 #ifdef __cplusplus
universe@89 5 extern "C" {
universe@89 6 #endif
universe@89 7
universe@89 8 #include "ucx.h"
universe@89 9 #include <string.h>
universe@89 10
universe@89 11 /**
universe@94 12 * Copies a string.
universe@94 13 * @param s the string to copy
universe@94 14 * @param data omitted
universe@94 15 * @return a pointer to a copy of s1 that can be passed to free(void*)
universe@94 16 */
universe@94 17 void *ucx_strcpy(void *s, void *data);
universe@94 18
universe@94 19 /**
universe@94 20 * Copies a memory area.
universe@94 21 * @param m a pointer to the memory area
universe@94 22 * @param n a pointer to the size_t containing the size of the memory area
universe@94 23 * @return a pointer to a copy of the specified memory area that can
universe@94 24 * be passed to free(void*)
universe@94 25 */
universe@94 26 void *ucx_memcpy(void *m, void *n);
universe@94 27
universe@94 28 /**
universe@89 29 * Wraps the strcmp function.
universe@89 30 * @param s1 string one
universe@89 31 * @param s2 string two
universe@89 32 * @param data omitted
universe@89 33 * @return the result of strcmp(s1, s2)
universe@89 34 */
universe@89 35 int ucx_strcmp(void *s1, void *s2, void *data);
universe@89 36
universe@89 37 /**
universe@89 38 * Wraps the strncmp function.
universe@89 39 * @param s1 string one
universe@89 40 * @param s2 string two
universe@89 41 * @param n a pointer to the size_t containing the third strncmp parameter
universe@89 42 * @return the result of strncmp(s1, s2, *n)
universe@89 43 */
universe@89 44 int ucx_strncmp(void *s1, void *s2, void *n);
universe@89 45
universe@89 46 /**
universe@89 47 * Compares two integers of type int.
universe@89 48 * @param i1 pointer to integer one
universe@89 49 * @param i2 pointer to integer two
universe@89 50 * @param data omitted
universe@89 51 * @return -1, if *i1 is less than *i2, 0 if both are equal,
universe@89 52 * 1 if *i1 is greater than *i2
universe@89 53 */
universe@89 54
universe@89 55 int ucx_intcmp(void *i1, void *i2, void *data);
universe@89 56
universe@89 57 /**
universe@92 58 * Compares two real numbers of type float.
universe@92 59 * @param f1 pointer to float one
universe@92 60 * @param f2 pointer to float two
universe@92 61 * @param if provided: a pointer to precision (default: 1e-6f)
universe@92 62 * @return -1, if *f1 is less than *f2, 0 if both are equal,
universe@92 63 * 1 if *f1 is greater than *f2
universe@92 64 */
universe@92 65
universe@92 66 int ucx_floatcmp(void *f1, void *f2, void *data);
universe@92 67
universe@92 68 /**
universe@92 69 * Compares two real numbers of type double.
universe@92 70 * @param f1 pointer to double one
universe@92 71 * @param f2 pointer to double two
universe@92 72 * @param if provided: a pointer to precision (default: 1e-14)
universe@92 73 * @return -1, if *d1 is less than *d2, 0 if both are equal,
universe@92 74 * 1 if *d1 is greater than *d2
universe@92 75 */
universe@92 76
universe@92 77 int ucx_doublecmp(void *d1, void *d2, void *data);
universe@92 78
universe@92 79 /**
universe@89 80 * Compares two pointers.
universe@89 81 * @param ptr1 pointer one
universe@89 82 * @param ptr2 pointer two
universe@89 83 * @param data omitted
universe@89 84 * @return -1 if ptr1 is less than ptr2, 0 if both are equal,
universe@89 85 * 1 if ptr1 is greater than ptr2
universe@89 86 */
universe@89 87 int ucx_ptrcmp(void *ptr1, void *ptr2, void *data);
universe@89 88
universe@91 89 /**
universe@91 90 * Compares two memory areas.
universe@91 91 * @param ptr1 pointer one
universe@91 92 * @param ptr2 pointer two
universe@91 93 * @param n a pointer to the size_t containing the third parameter for memcmp
universe@91 94 * @return the result of memcmp(ptr1, ptr2, *n)
universe@91 95 */
universe@91 96 int ucx_memcmp(void *ptr1, void *ptr2, void *n);
universe@91 97
universe@89 98 #ifdef __cplusplus
universe@89 99 }
universe@89 100 #endif
universe@89 101
universe@89 102 #endif /* COMPARATOR_H */
universe@89 103

mercurial