Linux repositories inspector

cmp(3pub)

Publib
Aliases: cmp_char(3pub), cmp_chararr(3pub), cmp_charptr(3pub), cmp_double(3pub), cmp_float(3pub), cmp_int(3pub), cmp_long(3pub), cmp_long_double(3pub), cmp_schar(3pub), cmp_set_offset(3pub), cmp_short(3pub), cmp_struct(3pub), cmp_uchar(3pub), cmp_uint(3pub), cmp_ulong(3pub), cmp_ushort(3pub)

publib-dev

library of miscellaneous C functions

NAME

cmp_set_offset, cmp_struct, cmp_char, cmp_short, cmp_int, cmp_long, cmp_float, cmp_double, cmp_long_double, cmp_schar, cmp_uchar, cmp_ushort, cmp_uint, cmp_ulong, cmp_charptr, cmp_chararr - comparison functions for qsort, bsearch, and others

SYNOPSIS

#include <cmp.h>
void cmp_set_offset(size_t offset, int (*)(const void *, const void *));
int cmp_struct(const void *, const void *);

int cmp_char(const void *, const void *); int cmp_short(const void *, const void *); int cmp_int(const void *, const void *); int cmp_long(const void *, const void *); int cmp_float(const void *, const void *); int cmp_double(const void *, const void *); int cmp_long_double(const void *, const void *);
int cmp_schar(const void *, const void *);
int cmp_uchar(const void *, const void *); int cmp_ushort(const void *, const void *); int cmp_uint(const void *, const void *); int cmp_ulong(const void *, const void *);
int cmp_charptr(const void *, const void *); int cmp_chararr(const void *, const void *);

DESCRIPTION

The functions declared above, with the exception of cmp_set_offset, compare two array elements of the indicated type when given pointers to them. The functions are designed to work with qsort(3), bsearch(3), and a number of other library functions which all need the same type of comparison function. They all return negative if the value indicated by the first argument is less than the second, 0 if they are the same, and positive otherwise.
cmp_struct compares elements of a structure. It needs to know the offset of the element, and a comparison function suitable for the type of the element. These are set with cmp_set_offset, which should be called before qsort(3). The settings stay in effect until changed.

AUTHOR

Lars Wirzenius ()
⇧ Top