aboutsummaryrefslogtreecommitdiff
blob: 8291daf420f67822922f4875a33a3dbe2a1187dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
 * Copyright 2005-2021 Gentoo Foundation
 * Distributed under the terms of the GNU General Public License v2
 *
 * Copyright 2005-2008 Ned Ludd        - <solar@gentoo.org>
 * Copyright 2005-2016 Mike Frysinger  - <vapier@gentoo.org>
 * Copyright 2019-     Fabian Groffen  - <grobian@gentoo.org>
 */

#ifndef _ATOM_COMPARE_H
#define _ATOM_COMPARE_H 1

typedef enum {
	VER_ALPHA=0, VER_BETA, VER_PRE, VER_RC, VER_NORM, VER_P
} atom_suffixes;
extern const char * const atom_suffixes_str[];

/* slotdeps, := :* :SLOT= */
typedef enum {
	/*   */ ATOM_SD_NONE = 0,
	/* = */ ATOM_SD_ANY_REBUILD,
	/* * */ ATOM_SD_ANY_IGNORE,
} atom_slotdep;
extern const char * const atom_slotdep_str[];

typedef enum {
	/*     */ ATOM_UC_NONE = 0,
	/* !   */ ATOM_UC_NOT,
	/* -   */ ATOM_UC_NEG,
	/* ?   */ ATOM_UC_COND,
	/* =   */ ATOM_UC_EQUAL,
	/* (+) */ ATOM_UC_PREV_ENABLED,
	/* (-) */ ATOM_UC_PREV_DISABLED,
} atom_usecond;
extern const char * const atom_usecond_str[];

typedef enum {
	/*    */ ATOM_BL_NONE = 0,
	/* !  */ ATOM_BL_BLOCK,
	/* !! */ ATOM_BL_BLOCK_HARD,
	/* ^  */ ATOM_BL_ANTISLOT,
} atom_blocker;
extern const char * const atom_blocker_str[];

typedef enum {
	/*    */ ATOM_OP_NONE = 0,
	/* =  */ ATOM_OP_EQUAL,
	/* >  */ ATOM_OP_NEWER,
	/* >= */ ATOM_OP_NEWER_EQUAL,
	/* <  */ ATOM_OP_OLDER,
	/* <= */ ATOM_OP_OLDER_EQUAL,
	/* ~  */ ATOM_OP_PV_EQUAL,
	/* *  */ ATOM_OP_STAR,
	/*    */ ATOM_OP_NEQUAL,
} atom_operator;
extern const char * const atom_op_str[];

typedef struct {
	atom_suffixes suffix;
	uint64_t sint;
} atom_suffix;

typedef struct _atom_usedep {
	struct _atom_usedep *next;
	char *use;
	atom_usecond pfx_cond;
	atom_usecond sfx_cond;
} atom_usedep;

typedef struct {
	atom_blocker blocker;
	atom_operator pfx_op;
	atom_operator sfx_op;
	char *CATEGORY;
	char *PN;
	char *PV;
	char *PF;
	unsigned int PR_int;
	char letter;
	atom_suffix *suffixes;
	char *PVR;
	char *P;
	atom_usedep *usedeps;
	char *SLOT;
	char *SUBSLOT;
	atom_slotdep slotdep;
	char *REPO;
} depend_atom;

extern const char * const booga[];
typedef enum {
	ERROR = 0,
	NOT_EQUAL,
	EQUAL,
	NEWER,
	OLDER
} atom_equality;

/* bitflags to control compare behaviour */
#define ATOM_COMP_DEFAULT    (0<<0)
#define ATOM_COMP_NOREV      (1<<0)
#define ATOM_COMP_NOSLOT     (1<<1)
#define ATOM_COMP_NOSUBSLOT  (1<<2)
#define ATOM_COMP_NOREPO     (1<<3)

depend_atom *atom_explode_cat(const char *atom, const char *cat);
#define atom_explode(A) atom_explode_cat(A, NULL)
depend_atom *atom_clone(depend_atom *atom);
void atom_implode(depend_atom *atom);
atom_equality atom_compare_flg(const depend_atom *a1, const depend_atom *a2, int flags);
#define atom_compare(A,B) atom_compare_flg(A, B, ATOM_COMP_DEFAULT)
atom_equality atom_compare_str(const char * const s1, const char * const s2);
char *atom_to_string_r(char *buf, size_t buflen, depend_atom *a);
char *atom_format_r(char *buf, size_t buflen,
		const char *format, const depend_atom *atom);
char *atom_to_string(depend_atom *a);
char *atom_format(const char *format, const depend_atom *atom);
int atom_compar_cb(const void *l, const void *r);

#endif