Debian Codegraph @

apps/app-internal.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2017 - 2022, Stephan Mueller <[email protected]>
3 *
4 * License: see COPYING file in root directory
5 *
6 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
7 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
8 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
9 * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
10 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
11 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
12 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
13 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
14 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
15 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
16 * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
17 * DAMAGE.
18 */
19
20 #ifndef APP_INTERNAL_H
21 #define APP_INTERNAL_H
22
23 #include <stdint.h>
24
25 #include <kcapi.h>
26
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31
32 #define STDIN_FD 0
33 #define STDOUT_FD 1
34 #define MAX_ALG_PAGES 16
35 #define TMPBUFLEN (4096 * (MAX_ALG_PAGES - 1))
36
37 #define KCAPI_APP_ALIGN 8
38 #define __aligned(x) __attribute__((aligned(x)))
39
40 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
41
42 enum { false, true };
43 typedef _Bool bool;
44
45 void dolog(enum kcapi_verbosity severity, const char *fmt, ...);
46 void dolog_bin(enum kcapi_verbosity severity,
47 const uint8_t *bin, uint32_t binlen, const char *explanation);
48 void set_verbosity(const char *name, enum kcapi_verbosity level);
49 void hex2bin(const char *hex, uint32_t hexlen, uint8_t *bin, uint32_t binlen);
50 int hex2bin_alloc(const char *hex, uint32_t hexlen,
51 uint8_t **bin, uint32_t *binlen);
52 void bin2hex(const uint8_t *bin, size_t binlen,
53 char *hex, size_t hexlen, int u);
54 void bin2print(const uint8_t *bin, size_t binlen,
55 const char *filename, FILE *outfile, uint32_t lfcr);
56 ssize_t read_complete(int fd, uint8_t *buf, size_t buflen);
57 int check_filetype(int fd, struct stat *sb, const char *filename);
58
59 #ifdef __cplusplus
60 }
61 #endif
62
63 #endif /* APP_INTERNAL_H */