ifapi_io.h
/* SPDX-License-Identifier: BSD-2-Clause */
/*******************************************************************************
* Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
* All rights reserved.
******************************************************************************/
#ifndef IFAPI_IO_H
#define IFAPI_IO_H
#include <stdio.h>
#include <stdbool.h>
#include "tss2_common.h"
#include "tss2_fapi.h"
typedef struct IFAPI_IO {
FILE *stream;
short pollevents;
const char *char_buffer;
char *char_rbuffer;
size_t buffer_length;
size_t buffer_idx;
} IFAPI_IO;
#ifdef TEST_FAPI_ASYNC
#define _IFAPI_IO_RETRIES 1
#else /* TEST_FAPI_ASYNC */
#define _IFAPI_IO_RETRIES 0
#endif /* TEST_FAPI_ASYNC */
static int _ifapi_io_retry __attribute__((unused)) = _IFAPI_IO_RETRIES;
#define IFAPI_IO_STREAM context->io.stream
#define IFAPI_IO_BUFF context->io.char_buffer
#define IFAPI_IO_RBUFF context->io.char_rbuffer
#define IFAPI_IO_BUFFLEN context->io.buffer_length
#define IFAPI_IO_BUFFIDX context->io.buffer_idx
TSS2_RC
ifapi_io_read_async(
struct IFAPI_IO *io,
const char *filename);
TSS2_RC
ifapi_io_read_finish(
struct IFAPI_IO *io,
uint8_t **buffer,
size_t *length);
TSS2_RC
ifapi_io_write_async(
struct IFAPI_IO *io,
const char *filename,
const uint8_t *buffer,
size_t length);
TSS2_RC
ifapi_io_write_finish(
struct IFAPI_IO *io);
TSS2_RC
ifapi_io_check_file_writeable(
const char *file);
TSS2_RC
ifapi_io_check_create_dir(
const char *dirname, int mode);
TSS2_RC
ifapi_io_remove_file(
const char *file);
TSS2_RC
ifapi_io_remove_directories(
const char *dirname,
const char *keystore_path,
const char *sub_dir);
TSS2_RC
ifapi_io_dirfiles(
const char *dirname,
char ***files,
size_t *numfiles);
TSS2_RC
ifapi_io_dirfiles_all(
const char *searchPath,
char ***pathlist,
size_t *numPaths);
bool
ifapi_io_path_exists(const char *path);
TSS2_RC
ifapi_io_poll(IFAPI_IO * io);
TSS2_RC
ifapi_io_poll_handles(IFAPI_IO *io, FAPI_POLL_HANDLE **handles, size_t *num_handles);
#endif /* IFAPI_IO_H */
ifapi_io_dirfiles_all
TSS2_RC ifapi_io_dirfiles_all(const char *searchPath, char ***pathlist, size_t *numPaths)
Definition ifapi_io.c:628
ifapi_io_poll
TSS2_RC ifapi_io_poll(IFAPI_IO *io)
Definition ifapi_io.c:700
ifapi_io_write_finish
TSS2_RC ifapi_io_write_finish(struct IFAPI_IO *io)
Definition ifapi_io.c:270
ifapi_io_dirfiles
TSS2_RC ifapi_io_dirfiles(const char *dirname, char ***files, size_t *numfiles)
Definition ifapi_io.c:476
ifapi_io_write_async
TSS2_RC ifapi_io_write_async(struct IFAPI_IO *io, const char *filename, const uint8_t *buffer, size_t length)
Definition ifapi_io.c:199
ifapi_io_check_file_writeable
TSS2_RC ifapi_io_check_file_writeable(const char *file)
Definition ifapi_io.c:311
ifapi_io_read_finish
TSS2_RC ifapi_io_read_finish(struct IFAPI_IO *io, uint8_t **buffer, size_t *length)
Definition ifapi_io.c:143
ifapi_io_poll_handles
TSS2_RC ifapi_io_poll_handles(IFAPI_IO *io, FAPI_POLL_HANDLE **handles, size_t *num_handles)
Definition ifapi_io.c:730
ifapi_io_remove_file
TSS2_RC ifapi_io_remove_file(const char *file)
Definition ifapi_io.c:363
ifapi_io_read_async
TSS2_RC ifapi_io_read_async(struct IFAPI_IO *io, const char *filename)
Definition ifapi_io.c:43
ifapi_io_path_exists
bool ifapi_io_path_exists(const char *path)
Definition ifapi_io.c:678
IFAPI_IO
Definition ifapi_io.h:15