refactor: Add original .c package files by Jef.
This commit is contained in:
parent
f376aedaee
commit
c2313fe0be
6 changed files with 376 additions and 0 deletions
19
include/dynarray.h
Normal file
19
include/dynarray.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef VIETER_DYNARRAY
|
||||
#define VIETER_DYNARRAY
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct dyn_array DynArray;
|
||||
|
||||
DynArray *dynarray_init(size_t initial_capacity);
|
||||
void dynarray_add(DynArray *da, const char * s);
|
||||
void dynarray_free(DynArray *da);
|
||||
|
||||
/**
|
||||
* Convert a DynArray into an array by freeing all its surrounding components
|
||||
* and returning the underlying array pointer.
|
||||
*/
|
||||
char **dynarray_convert(DynArray *da);
|
||||
|
||||
#endif
|
||||
26
include/package.h
Normal file
26
include/package.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef VIETER_PACKAGE
|
||||
#define VIETER_PACKAGE
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "archive.h"
|
||||
#include "archive_entry.h"
|
||||
|
||||
#include "package_info.h"
|
||||
#include "dynarray.h"
|
||||
|
||||
typedef struct pkg {
|
||||
char *path;
|
||||
PkgInfo *info;
|
||||
DynArray *files;
|
||||
int compression;
|
||||
} Pkg;
|
||||
|
||||
Pkg *package_read_archive(const char *pkg_path);
|
||||
void package_free(Pkg ** ptp);
|
||||
char *package_to_description(Pkg *pkg);
|
||||
|
||||
#endif
|
||||
39
include/package_info.h
Normal file
39
include/package_info.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef VIETER_PACKAGE_INFO
|
||||
#define VIETER_PACKAGE_INFO
|
||||
|
||||
#define FREE_STRING(sp) if (sp != NULL) free(sp)
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "dynarray.h"
|
||||
|
||||
typedef struct pkg_info {
|
||||
char *name;
|
||||
char *base;
|
||||
char *version;
|
||||
char *description;
|
||||
int64_t size;
|
||||
int64_t csize;
|
||||
char *url;
|
||||
char *arch;
|
||||
int64_t build_date;
|
||||
char *packager;
|
||||
char *pgpsig;
|
||||
int64_t pgpsigsize;
|
||||
|
||||
DynArray *groups;
|
||||
DynArray *licenses;
|
||||
DynArray *replaces;
|
||||
DynArray *depends;
|
||||
DynArray *conflicts;
|
||||
DynArray *provides;
|
||||
DynArray *optdepends;
|
||||
DynArray *makedepends;
|
||||
DynArray *checkdepends;
|
||||
} PkgInfo;
|
||||
|
||||
PkgInfo *package_info_init();
|
||||
int package_info_parse(PkgInfo *pkg_info, char *pkg_info_str);
|
||||
void package_info_free(PkgInfo *pkg_info);
|
||||
|
||||
#endif
|
||||
Reference in a new issue