betaur

[WIP] A better AUR helper written in C

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 
#ifndef __BETAUR_DEPENDENCY_H
#define __BETAUR_DEPENDENCY_H
#include <stddef.h>
#include <stdbool.h>

#include "aur/package.h"

typedef enum {
	BETAUR_ANY,
	BETAUR_EQ,
	BETAUR_GE,
	BETAUR_GT,
	BETAUR_LE,
	BETAUR_LT,
} betaur_mod;

typedef struct betaur_dependency {
	char* depstring;
	size_t name_len;
	char* name;
	size_t version_len;
	char* version;
	betaur_mod mod;
} betaur_dependency_t;

/*
 * Create a memory that should be destroyed by the caller
 * The returned struct is 'view' and does not create a memory for contents
 * The input string should not have leading or trailing white spaces
*/
betaur_dependency_t* betaur_dependency_create(size_t depstring_len, char* depstring);

bool betaur_satisfied_by_version(betaur_dependency_t* bdep, const char* version);

// TODO pass 'candidate' by reference as the parcel is huge
bool betaur_satisfied_by(betaur_package_t candidate);
#endif