pkin/pkin/pkin.h
2026-09-04 19:59:24 +02:00

65 lines
1.4 KiB
C

#ifndef PKIN_REPO_H
#define PKIN_REPO_H
/*
* each repo is a directory with a repo-index json file.
*/
#include <libowfat/stralloc.h>
#include <libowfat/array.h>
#include <libowfat/buffer.h>
#include <limits.h>
#include <jansson.h>
#define PKIN_PKGMETA_NAME_MAX 128
#define PKIN_PKGMETA_DESCR_MAX 256
#define PKIN_PKGMETA_VERSION_MAX 256
#define PKIN_PKGMETA_URL_MAX 2048
extern int pkin_verbose;
extern array pkin_repos; /* of char * */
typedef struct {
char name[PKIN_PKGMETA_NAME_MAX];
char descr[PKIN_PKGMETA_DESCR_MAX];
char version[PKIN_PKGMETA_VERSION_MAX];
char url[PKIN_PKGMETA_URL_MAX]; /* url to download binary package from */
} pkin_pkgmeta;
typedef struct {
buffer b;
int fd;
char buf[4096];
stralloc line;
size_t repos_i;
size_t repos_len;
} pkin_repo_iter;
/* parlallel querying would be nice */
/*
* initialize a pkin_repo_query.
*/
void pkin_repo_iter_init(pkin_repo_iter *);
/*
* gets the next pkgmeta.
* return: 1 if found, 0 if no next
*/
int pkin_repo_iter_read(pkin_repo_iter *, pkin_pkgmeta *res);
typedef struct {
buffer writeb;
char writebuf[1024];
int pipefd[2];
} pkin_fetch_queue;
int pkin_fetch_prepare(pkin_fetch_queue *queue);
void pkin_fetch_add(pkin_fetch_queue *queue, char *url, char *output);
/*
* downloads the binary package from url to the given
* directory and writes the resulting path to rest
*/
int pkin_fetch_start(pkin_fetch_queue *queue);
#endif