errmap.h revision 5e01956f3000408c2a2c5a08c8d0acf2c2a9d8ee
/*
* This file is generated, please don't edit it.
* args: bimap errmap.h NAME=mecherrmap LEFT=OM_uint32 RIGHT=struct mecherror LEFTPRINT=print_OM_uint32 RIGHTPRINT=mecherror_print LEFTCMP=cmp_OM_uint32 RIGHTCMP=mecherror_cmp
* The rest of this file is copied from a template, with
* substitutions. See the template for copyright info.
*/
/* start of t_bimap header template */
/*
* bidirectional mapping table, add-only
*
* Parameters:
* NAME
* LEFT, RIGHT - types
* LEFTCMP, RIGHTCMP - comparison functions
*
* Methods:
* int init() - nonzero is error code, if any possible
* long size()
* void foreach(int (*)(LEFT, RIGHT, void*), void*)
* int add(LEFT, RIGHT) - 0 = success, -1 = allocation failure
* const struct mecherror *findleft(OM_uint32) - null iff not found
* const OM_uint32 *findright(struct mecherror)
* void destroy() - destroys container, doesn't delete elements
*
* initial implementation: flat array of (left,right) pairs
*/
struct mecherrmap__pair {
OM_uint32 l;
struct mecherror r;
};
/* end of t_bimap header template */
/* start of t_array template */
/*
* array type, derived from template
*
* parameters:
* NAME: mecherrmap__pairarray
* TYPE: struct mecherrmap__pair
*
* methods:
* int init() -> nonzero if fail initial allocation
* unsigned long size() -> nonnegative number of values stored
* int grow(newsize) -> negative if fail allocation, memset(,0,) new space
* struct mecherrmap__pair *getaddr(idx) -> aborts if out of range
* void set(idx, value) -> aborts if out of range
* struct mecherrmap__pair get(idx) -> value, or aborts if out of range
*/
#include <stdlib.h>
#include <errno.h>
#include <limits.h>
#include <string.h>
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif
struct mecherrmap__pairarray__header {
struct mecherrmap__pair *elts;
};
typedef struct mecherrmap__pairarray__header mecherrmap__pairarray;
static inline int
{
return ENOMEM;
return 0;
}
static inline long
{
}
static inline long
{
if (upper_bound > LONG_MAX)
return (long) upper_bound;
}
static inline int
{
void *ptr;
return -1;
return 0;
return -1;
return -1;
return 0;
}
static inline struct mecherrmap__pair *
{
abort();
}
static inline void
{
struct mecherrmap__pair *newvalp;
}
static inline struct mecherrmap__pair
{
}
static inline void
{
}
/* end of t_array template */
/* start of t_bimap body template */
/* for use in cases where text substitutions may not work, like putting
"const" before a type that turns out to be "char *" */
typedef OM_uint32 mecherrmap__left_t;
typedef struct mecherror mecherrmap__right_t;
typedef struct {
long nextidx;
} mecherrmap;
static inline int
{
m->nextidx = 0;
return mecherrmap__pairarray_init (&m->a);
}
static inline long
{
return mecherrmap__pairarray_size (&m->a);
}
static inline void
{
long i, sz;
for (i = 0; i < sz; i++) {
struct mecherrmap__pair *pair;
pair = mecherrmap__pairarray_getaddr (&m->a, i);
break;
}
}
static inline int
{
long i, sz;
struct mecherrmap__pair newpair;
int err;
/* Make sure we're not duplicating. */
for (i = 0; i < sz; i++) {
struct mecherrmap__pair *pair;
pair = mecherrmap__pairarray_getaddr (&m->a, i);
if ((*cmp_OM_uint32)(l, pair->l) == 0)
abort();
if ((*mecherror_cmp)(r, pair->r) == 0)
abort();
}
newpair.l = l;
newpair.r = r;
return ENOMEM;
if (err)
return err;
m->nextidx++;
return 0;
}
static inline const mecherrmap__right_t *
{
long i, sz;
sz = mecherrmap_size (m);
for (i = 0; i < sz; i++) {
struct mecherrmap__pair *pair;
pair = mecherrmap__pairarray_getaddr (&m->a, i);
if ((*cmp_OM_uint32)(l, pair->l) == 0)
return &pair->r;
}
return 0;
}
static inline const mecherrmap__left_t *
{
long i, sz;
sz = mecherrmap_size (m);
for (i = 0; i < sz; i++) {
struct mecherrmap__pair *pair;
pair = mecherrmap__pairarray_getaddr (&m->a, i);
if ((*mecherror_cmp)(r, pair->r) == 0)
return &pair->l;
}
return 0;
}
struct mecherrmap__printstat {
FILE *f;
int comma;
};
static inline int
{
struct mecherrmap__printstat *ps = p;
(*print_OM_uint32)(l, ps->f);
(*mecherror_print)(r, ps->f);
return 0;
}
static inline void
{
struct mecherrmap__printstat ps;
ps.f = f;
fprintf(f, "(");
fprintf(f, ")");
}
static inline void
{
mecherrmap__pairarray_destroy (&m->a);
}
/* end of t_bimap body template */