refactor: started a codestyle
This commit is contained in:
parent
65d67b2c01
commit
3b4a56bd89
11 changed files with 128 additions and 120 deletions
19
include/cieter_dynarray.h
Normal file
19
include/cieter_dynarray.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef CIETER_DYNARRAY
|
||||
#define CIETER_DYNARRAY
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct dyn_array CieterDynArray;
|
||||
|
||||
CieterDynArray *cieter_dynarray_init(size_t initial_capacity);
|
||||
void cieter_dynarray_add(CieterDynArray *da, const char * s);
|
||||
void cieter_dynarray_free(CieterDynArray *da);
|
||||
|
||||
/**
|
||||
* Convert a DynArray into an array by freeing all its surrounding components
|
||||
* and returning the underlying array pointer.
|
||||
*/
|
||||
char **cieter_dynarray_convert(CieterDynArray *da);
|
||||
|
||||
#endif
|
||||
26
include/cieter_package.h
Normal file
26
include/cieter_package.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef CIETER_PACKAGE
|
||||
#define CIETER_PACKAGE
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "archive.h"
|
||||
#include "archive_entry.h"
|
||||
|
||||
#include "cieter_package_info.h"
|
||||
#include "cieter_dynarray.h"
|
||||
|
||||
typedef struct pkg {
|
||||
char *path;
|
||||
CieterPkgInfo *info;
|
||||
CieterDynArray *files;
|
||||
int compression;
|
||||
} CieterPkg;
|
||||
|
||||
CieterPkg *package_read_archive(const char *pkg_path);
|
||||
void package_free(CieterPkg ** ptp);
|
||||
char *package_to_description(CieterPkg *pkg);
|
||||
|
||||
#endif
|
||||
39
include/cieter_package_info.h
Normal file
39
include/cieter_package_info.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef CIETER_PACKAGE_INFO
|
||||
#define CIETER_PACKAGE_INFO
|
||||
|
||||
#define FREE_STRING(sp) if (sp != NULL) free(sp)
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cieter_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;
|
||||
|
||||
CieterDynArray *groups;
|
||||
CieterDynArray *licenses;
|
||||
CieterDynArray *replaces;
|
||||
CieterDynArray *depends;
|
||||
CieterDynArray *conflicts;
|
||||
CieterDynArray *provides;
|
||||
CieterDynArray *optdepends;
|
||||
CieterDynArray *makedepends;
|
||||
CieterDynArray *checkdepends;
|
||||
} CieterPkgInfo;
|
||||
|
||||
CieterPkgInfo *package_info_init();
|
||||
int package_info_parse(CieterPkgInfo *pkg_info, char *pkg_info_str);
|
||||
void package_info_free(CieterPkgInfo *pkg_info);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
#ifndef CIETER_DYNARRAY
|
||||
#define CIETER_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
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#ifndef CIETER_PACKAGE
|
||||
#define CIETER_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
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
#ifndef CIETER_PACKAGE_INFO
|
||||
#define CIETER_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