atoms.h 2.67 KB
Newer Older
1 2 3 4 5 6 7
#ifndef REPREPRO_ATOMS_H
#define REPREPRO_ATOMS_H

typedef int atom_t;
typedef atom_t architecture_t;
typedef atom_t component_t;
typedef atom_t packagetype_t;
8
typedef atom_t command_t;
9

10
enum atom_type { at_architecture, at_component, at_packagetype, at_command };
11

12
#define atom_unknown ((atom_t)0)
13

14 15 16 17 18 19 20 21 22 23 24 25 26 27
#define architecture_source ((architecture_t)1)
#define architecture_all ((architecture_t)2)

#define component_strange ((component_t)1)

#define pt_dsc ((packagetype_t)1)
#define pt_deb ((packagetype_t)2)
#define pt_udeb ((packagetype_t)3)

#define atom_defined(a) ((a) > (atom_t)0)

extern const char **atomtypes, **atoms_architectures, **atoms_components, **atoms_packagetypes, **atoms_commands;

retvalue atoms_init(int command_count);
28 29 30

retvalue architecture_intern(const char *, /*@out@*/architecture_t *);
architecture_t architecture_find(const char *);
31
architecture_t architecture_find_l(const char *, size_t);
32 33
retvalue component_intern(const char *, /*@out@*/component_t *);
component_t component_find(const char *);
34 35
component_t component_find_l(const char *, size_t);
component_t components_count(void);
36
packagetype_t packagetype_find(const char *);
37
packagetype_t packagetype_find_l(const char *, size_t);
38

39 40 41
atom_t atom_find(enum atom_type, const char *);
retvalue atom_intern(enum atom_type, const char *, /*@out@*/atom_t *);

42
#define limitation_missed(a, b) ((atom_defined(a) && (a) != (b)))
43
#define limitations_missed(a, b) ((a) != NULL && !atomlist_in(a, b))
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62


struct atomlist {
	atom_t *atoms;
	int count, size;
};

void atomlist_init(/*@out@*/struct atomlist *);
void atomlist_done(/*@special@*/struct atomlist *atomlist) /*@releases atomlist->values @*/;

/* add a atom uniquely (not sorted, component guessing might not like it),
 * RET_NOTHING when already there */
retvalue atomlist_add_uniq(struct atomlist *, atom_t);
/* always add to the end */
retvalue atomlist_add(struct atomlist *, atom_t);

/* replace the contents of dest with those from orig, which get emptied */
void atomlist_move(/*@out@*/struct atomlist *, /*@special@*/struct atomlist *orig) /*@releases orig->values @*/;

63
bool atomlist_hasexcept(const struct atomlist *, atom_t);
64 65 66 67
bool atomlist_in(const struct atomlist *, atom_t);
int atomlist_ofs(const struct atomlist *, atom_t);

/* if missing != NULL And subset no subset of atomlist, set *missing to the first missing one */
68
bool atomlist_subset(const struct atomlist *, const struct atomlist * /*subset*/, /*@null@*/atom_t * /*missing*/ );
69 70 71 72

/* print a space separated list of elements */
retvalue atomlist_fprint(FILE *, enum atom_type, const struct atomlist *);

73
retvalue atomlist_filllist(enum atom_type, /*@out@*/struct atomlist *, char * /*string*/, /*@out@*/const char ** /*missing*/);
74
#endif