101 lines
1.9 KiB
C
101 lines
1.9 KiB
C
#ifndef PKG_H_
|
|
#define PKG_H_
|
|
|
|
#define _POSIX_C_SOURCE 200809L
|
|
#define _XOPEN_SOURCE 700
|
|
|
|
#include <libconfig.h>
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <sys/stat.h>
|
|
|
|
#include "common.h"
|
|
|
|
typedef struct {
|
|
int maj;
|
|
int min;
|
|
int pat;
|
|
char *tag;
|
|
}
|
|
semver_t;
|
|
|
|
typedef struct {
|
|
char *dep_name;
|
|
semver_t dep_ver;
|
|
}
|
|
dep_t;
|
|
|
|
typedef struct {
|
|
char *conf_name;
|
|
semver_t conf_ver;
|
|
}
|
|
conf_t;
|
|
|
|
typedef struct {
|
|
char *pkg_name;
|
|
semver_t pkg_ver;
|
|
char *pkg_desc;
|
|
char *pkg_maint;
|
|
char *pkg_copyright;
|
|
char *pkg_repo;
|
|
dep_t *pkg_dependencies;
|
|
conf_t *pkg_conflicts;
|
|
}
|
|
gl_pkg_t;
|
|
|
|
semver_t gl_parse_semver(const char *str);
|
|
void gl_free_semver(semver_t *v);
|
|
void gl_free_pkg(gl_pkg_t *pkg);
|
|
|
|
typedef enum {
|
|
GL_CONF_OK = 0,
|
|
GL_CONF_ERR_READ = 1,
|
|
GL_CONF_ERR_MISSING = 2,
|
|
GL_CONF_ERR_TYPE = 3,
|
|
GL_CONF_ERR_INVALID = 4,
|
|
GL_CONF_ERR_SPACE = 5
|
|
} gl_conf_status_t;
|
|
|
|
|
|
gl_conf_status_t gl_conf_get_int(const char *path, const char *key, int *out);
|
|
gl_conf_status_t gl_conf_repo_keys(const char *path, const char *repo,
|
|
char *out, size_t outlen);
|
|
gl_conf_status_t gl_conf_repos(const char *path, char *out, size_t outlen);
|
|
|
|
/* A repository index (REPO_DESIGN.txt section 4), as gl_index_parse
|
|
* reads it. deps/confs are "NAME VER\n" lines ("" for none). */
|
|
typedef struct {
|
|
char *name;
|
|
char *ver;
|
|
char *file;
|
|
char *sha256;
|
|
int64_t size;
|
|
char *deps;
|
|
char *confs;
|
|
} gl_index_pkg_t;
|
|
|
|
typedef struct {
|
|
char *repo;
|
|
int64_t serial;
|
|
int64_t valid_until;
|
|
size_t npkgs;
|
|
gl_index_pkg_t *pkgs;
|
|
} gl_index_t;
|
|
|
|
typedef enum {
|
|
GL_INDEX_OK = 0,
|
|
GL_INDEX_ERR_FORMAT = 1,
|
|
GL_INDEX_ERR_REPO = 2,
|
|
GL_INDEX_ERR_NOMEM = 3
|
|
} gl_index_status_t;
|
|
|
|
gl_index_status_t gl_index_parse(const char *text, size_t len,
|
|
const char *repo, gl_index_t *out);
|
|
void gl_index_free(gl_index_t *idx);
|
|
|
|
bool gl_valid_pkg_ident(const char *s);
|
|
int gl_gpm2gpkg(const char *filename, gl_pkg_t *pkg);
|
|
|
|
#endif
|