ucx/utils.h

changeset 94
57ea041df22f
parent 92
7625a8efcc97
child 103
08018864fb91
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ucx/utils.h	Wed Feb 27 11:48:29 2013 +0100
     1.3 @@ -0,0 +1,103 @@
     1.4 +#ifndef COMPARATOR_H
     1.5 +#define	COMPARATOR_H
     1.6 +
     1.7 +#ifdef	__cplusplus
     1.8 +extern "C" {
     1.9 +#endif
    1.10 +
    1.11 +#include "ucx.h"
    1.12 +#include <string.h>
    1.13 +
    1.14 +/**
    1.15 + * Copies a string.
    1.16 + * @param s the string to copy
    1.17 + * @param data omitted
    1.18 + * @return a pointer to a copy of s1 that can be passed to free(void*)
    1.19 + */
    1.20 +void *ucx_strcpy(void *s, void *data);
    1.21 +
    1.22 +/**
    1.23 + * Copies a memory area.
    1.24 + * @param m a pointer to the memory area
    1.25 + * @param n a pointer to the size_t containing the size of the memory area
    1.26 + * @return a pointer to a copy of the specified memory area that can
    1.27 + * be passed to free(void*)
    1.28 + */
    1.29 +void *ucx_memcpy(void *m, void *n);
    1.30 +
    1.31 +/**
    1.32 + * Wraps the strcmp function.
    1.33 + * @param s1 string one
    1.34 + * @param s2 string two
    1.35 + * @param data omitted
    1.36 + * @return the result of strcmp(s1, s2)
    1.37 + */
    1.38 +int ucx_strcmp(void *s1, void *s2, void *data);
    1.39 +
    1.40 +/**
    1.41 + * Wraps the strncmp function.
    1.42 + * @param s1 string one
    1.43 + * @param s2 string two
    1.44 + * @param n a pointer to the size_t containing the third strncmp parameter
    1.45 + * @return the result of strncmp(s1, s2, *n)
    1.46 + */
    1.47 +int ucx_strncmp(void *s1, void *s2, void *n);
    1.48 +
    1.49 +/**
    1.50 + * Compares two integers of type int.
    1.51 + * @param i1 pointer to integer one
    1.52 + * @param i2 pointer to integer two
    1.53 + * @param data omitted
    1.54 + * @return -1, if *i1 is less than *i2, 0 if both are equal,
    1.55 + * 1 if *i1 is greater than *i2
    1.56 + */
    1.57 +
    1.58 +int ucx_intcmp(void *i1, void *i2, void *data);
    1.59 +
    1.60 +/**
    1.61 + * Compares two real numbers of type float.
    1.62 + * @param f1 pointer to float one
    1.63 + * @param f2 pointer to float two
    1.64 + * @param if provided: a pointer to precision (default: 1e-6f)
    1.65 + * @return -1, if *f1 is less than *f2, 0 if both are equal,
    1.66 + * 1 if *f1 is greater than *f2
    1.67 + */
    1.68 +
    1.69 +int ucx_floatcmp(void *f1, void *f2, void *data);
    1.70 +
    1.71 +/**
    1.72 + * Compares two real numbers of type double.
    1.73 + * @param f1 pointer to double one
    1.74 + * @param f2 pointer to double two
    1.75 +* @param if provided: a pointer to precision (default: 1e-14)
    1.76 + * @return -1, if *d1 is less than *d2, 0 if both are equal,
    1.77 + * 1 if *d1 is greater than *d2
    1.78 + */
    1.79 +
    1.80 +int ucx_doublecmp(void *d1, void *d2, void *data);
    1.81 +
    1.82 +/**
    1.83 + * Compares two pointers.
    1.84 + * @param ptr1 pointer one
    1.85 + * @param ptr2 pointer two
    1.86 + * @param data omitted
    1.87 + * @return -1 if ptr1 is less than ptr2, 0 if both are equal,
    1.88 + * 1 if ptr1 is greater than ptr2
    1.89 + */
    1.90 +int ucx_ptrcmp(void *ptr1, void *ptr2, void *data);
    1.91 +
    1.92 +/**
    1.93 + * Compares two memory areas.
    1.94 + * @param ptr1 pointer one
    1.95 + * @param ptr2 pointer two
    1.96 + * @param n a pointer to the size_t containing the third parameter for memcmp
    1.97 + * @return the result of memcmp(ptr1, ptr2, *n)
    1.98 + */
    1.99 +int ucx_memcmp(void *ptr1, void *ptr2, void *n);
   1.100 +
   1.101 +#ifdef	__cplusplus
   1.102 +}
   1.103 +#endif
   1.104 +
   1.105 +#endif	/* COMPARATOR_H */
   1.106 +

mercurial