blob: cabf51c15699aa9ad9ebb4dab6c4b3e3e4e1e367 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/* 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 <limits.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
|