diff options
author | Timo Teräs <timo.teras@iki.fi> | 2021-06-07 19:49:15 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2021-06-11 13:35:32 +0300 |
commit | 7c9f001cda932c74164e8aaa6740dcb6d24aa62f (patch) | |
tree | 7f30f0cbfc1d9e6f43f9aff3807f83ab53240ead /src/apk_pathbuilder.h | |
parent | cd9aef8f7cabdb09a7b6e6c4884b8e3db41b0962 (diff) | |
download | apk-tools-7c9f001cda932c74164e8aaa6740dcb6d24aa62f.tar.gz apk-tools-7c9f001cda932c74164e8aaa6740dcb6d24aa62f.tar.bz2 apk-tools-7c9f001cda932c74164e8aaa6740dcb6d24aa62f.tar.xz apk-tools-7c9f001cda932c74164e8aaa6740dcb6d24aa62f.zip |
mkpkg: new applet to create v2 packages with basic functionality
Diffstat (limited to 'src/apk_pathbuilder.h')
-rw-r--r-- | src/apk_pathbuilder.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/apk_pathbuilder.h b/src/apk_pathbuilder.h new file mode 100644 index 0000000..34181db --- /dev/null +++ b/src/apk_pathbuilder.h @@ -0,0 +1,44 @@ +/* apk_pathbuilder.h - Alpine Package Keeper (APK) + * + * Copyright (C) 2021 Timo Teräs <timo.teras@iki.fi> + * All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0-only + */ + +#ifndef APK_PATHBUILDER_H +#define APK_PATHBUILDER_H + +#include "apk_blob.h" + +struct apk_pathbuilder { + uint16_t namelen; + char name[PATH_MAX]; +}; + +int apk_pathbuilder_pushb(struct apk_pathbuilder *pb, apk_blob_t b); +void apk_pathbuilder_pop(struct apk_pathbuilder *pb); + + +static inline int apk_pathbuilder_setb(struct apk_pathbuilder *pb, apk_blob_t b) +{ + pb->namelen = 0; + return apk_pathbuilder_pushb(pb, b); +} + +static inline int apk_pathbuilder_push(struct apk_pathbuilder *pb, const char *name) +{ + return apk_pathbuilder_pushb(pb, APK_BLOB_STR(name)); +} + +static inline const char *apk_pathbuilder_cstr(const struct apk_pathbuilder *pb) +{ + return pb->name; +} + +static inline apk_blob_t apk_pathbuilder_get(const struct apk_pathbuilder *pb) +{ + return APK_BLOB_PTR_LEN((void*)pb->name, pb->namelen); +} + +#endif |