chiark / gitweb /
c2f11013e598be1a882aea177316b9ba3d1e62af
[elogind.git] / src / basic / hexdecoct.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5   This file is part of systemd.
6
7   Copyright 2010 Lennart Poettering
8 ***/
9
10 #include <stdbool.h>
11 #include <stddef.h>
12 #include <stdio.h>
13 #include <sys/types.h>
14
15 #include "macro.h"
16
17 char octchar(int x) _const_;
18 int unoctchar(char c) _const_;
19
20 char decchar(int x) _const_;
21 int undecchar(char c) _const_;
22
23 char hexchar(int x) _const_;
24 int unhexchar(char c) _const_;
25
26 char *hexmem(const void *p, size_t l);
27 int unhexmem(const char *p, size_t l, void **mem, size_t *len);
28
29 char base32hexchar(int x) _const_;
30 int unbase32hexchar(char c) _const_;
31
32 char base64char(int x) _const_;
33 int unbase64char(char c) _const_;
34
35 char *base32hexmem(const void *p, size_t l, bool padding);
36 int unbase32hexmem(const char *p, size_t l, bool padding, void **mem, size_t *len);
37
38 ssize_t base64mem(const void *p, size_t l, char **out);
39 int base64_append(char **prefix, int plen,
40                   const void *p, size_t l,
41                   int margin, int width);
42 int unbase64mem(const char *p, size_t l, void **mem, size_t *len);
43
44 void hexdump(FILE *f, const void *p, size_t s);