]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/hexdecoct.h
hwdb: Add support for HP ZBook Studio G5 keyboard (#17525)
[thirdparty/systemd.git] / src / basic / hexdecoct.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include <stdbool.h>
5 #include <stddef.h>
6 #include <stdio.h>
7 #include <sys/types.h>
8
9 #include "macro.h"
10
11 char octchar(int x) _const_;
12 int unoctchar(char c) _const_;
13
14 char decchar(int x) _const_;
15 int undecchar(char c) _const_;
16
17 char hexchar(int x) _const_;
18 int unhexchar(char c) _const_;
19
20 char *hexmem(const void *p, size_t l);
21 int unhexmem_full(const char *p, size_t l, bool secure, void **mem, size_t *len);
22 static inline int unhexmem(const char *p, size_t l, void **mem, size_t *len) {
23 return unhexmem_full(p, l, false, mem, len);
24 }
25
26 char base32hexchar(int x) _const_;
27 int unbase32hexchar(char c) _const_;
28
29 char base64char(int x) _const_;
30 int unbase64char(char c) _const_;
31
32 char *base32hexmem(const void *p, size_t l, bool padding);
33 int unbase32hexmem(const char *p, size_t l, bool padding, void **mem, size_t *len);
34
35 ssize_t base64mem(const void *p, size_t l, char **out);
36 int base64_append(char **prefix, int plen,
37 const void *p, size_t l,
38 int margin, int width);
39 int unbase64mem_full(const char *p, size_t l, bool secure, void **mem, size_t *len);
40 static inline int unbase64mem(const char *p, size_t l, void **mem, size_t *len) {
41 return unbase64mem_full(p, l, false, mem, len);
42 }
43
44 void hexdump(FILE *f, const void *p, size_t s);