tpm2-tss 4.0.1
TPM Software stack 2.0 TCG spec compliant implementation
ifapi_io.h
1/* SPDX-License-Identifier: BSD-2-Clause */
2/*******************************************************************************
3 * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4 * All rights reserved.
5 ******************************************************************************/
6
7#ifndef IFAPI_IO_H
8#define IFAPI_IO_H
9
10#include <stdio.h>
11#include <stdbool.h>
12#include "tss2_common.h"
13#include "tss2_fapi.h"
14
15typedef struct IFAPI_IO {
16 FILE *stream;
17 short pollevents;
18 const char *char_buffer;
19 char *char_rbuffer;
20 size_t buffer_length;
21 size_t buffer_idx;
22} IFAPI_IO;
23
24#ifdef TEST_FAPI_ASYNC
25#define _IFAPI_IO_RETRIES 1
26#else /* TEST_FAPI_ASYNC */
27#define _IFAPI_IO_RETRIES 0
28#endif /* TEST_FAPI_ASYNC */
29
30static int _ifapi_io_retry __attribute__((unused)) = _IFAPI_IO_RETRIES;
31
32#define IFAPI_IO_STREAM context->io.stream
33#define IFAPI_IO_BUFF context->io.char_buffer
34#define IFAPI_IO_RBUFF context->io.char_rbuffer
35#define IFAPI_IO_BUFFLEN context->io.buffer_length
36#define IFAPI_IO_BUFFIDX context->io.buffer_idx
37
38TSS2_RC
39ifapi_io_read_async(
40 struct IFAPI_IO *io,
41 const char *filename);
42
43TSS2_RC
44ifapi_io_read_finish(
45 struct IFAPI_IO *io,
46 uint8_t **buffer,
47 size_t *length);
48
49TSS2_RC
50ifapi_io_write_async(
51 struct IFAPI_IO *io,
52 const char *filename,
53 const uint8_t *buffer,
54 size_t length);
55
56TSS2_RC
57ifapi_io_write_finish(
58 struct IFAPI_IO *io);
59
60TSS2_RC
61ifapi_io_check_file_writeable(
62 const char *file);
63
64TSS2_RC
65ifapi_io_check_create_dir(
66 const char *dirname, int mode);
67
68TSS2_RC
69ifapi_io_remove_file(
70 const char *file);
71
72TSS2_RC
73ifapi_io_remove_directories(
74 const char *dirname,
75 const char *keystore_path,
76 const char *sub_dir);
77
78TSS2_RC
79ifapi_io_dirfiles(
80 const char *dirname,
81 char ***files,
82 size_t *numfiles);
83
84TSS2_RC
85ifapi_io_dirfiles_all(
86 const char *searchPath,
87 char ***pathlist,
88 size_t *numPaths);
89
90bool
91ifapi_io_path_exists(const char *path);
92
93TSS2_RC
94ifapi_io_poll(IFAPI_IO * io);
95
96TSS2_RC
97ifapi_io_poll_handles(IFAPI_IO *io, FAPI_POLL_HANDLE **handles, size_t *num_handles);
98
99#endif /* IFAPI_IO_H */
Definition ifapi_io.h:15