O2S C Library
1.8.2
Provide high-level data-structures and other fundamental tools for C projects
Loading...
Searching...
No Matches
file_input_stream.h
Go to the documentation of this file.
1
#pragma once
2
3
/* ************************************************************************** */
4
/* ____ _ _____ ____ _ _ _ _____ _ _ ____ ____ */
5
/* / ___| / \ | ___| _ \ / \ | \ | | |_ _| || | | _ \/ ___| */
6
/* \___ \ / _ \ | |_ | |_) | / _ \ | \| | | | | || |_| | | \___ \ */
7
/* ___) / ___ \| _| | _ < / ___ \| |\ | | | |__ _| |_| |___) | */
8
/* |____/_/ \_|_| |_| \_/_/ \_|_| \_| |_| |_| |____/|____/ */
9
/* */
16
/* ************************************************************************** */
17
18
#include "
o2s/input_stream.h
"
19
20
#include <signal.h>
// siginfo_t
21
#include <stdbool.h>
// bool
22
#include <stdint.h>
// uint*_t
23
#include <stdio.h>
// ssize_t
24
26
typedef
struct
file_input_stream
27
{
28
istream_t
stream
;
29
int
descriptor
;
30
bool
opened
;
31
}
ifstream_t
;
32
35
ifstream_t
file_open
(
const
char
* file_name,
int
flags);
36
ifstream_t
file_from_descriptor
(
int
descriptor);
37
void
file_close
(
ifstream_t
* file);
39
42
ssize_t
file_single_read
(
ifstream_t
* file);
43
bool
file_accumulate
(
ifstream_t
* file,
size_t
count);
44
bool
file_accumulate_infinite
(
ifstream_t
* file,
size_t
count);
45
46
void
file_stop_reading
(
void
);
47
void
file_resume_reading
(
void
);
49
50
void
file_default_signal_handler
(
int
, siginfo_t*,
void
*);
51
68
#define FileInputStream __attribute__((cleanup(file_close))) ifstream_t
file_default_signal_handler
void file_default_signal_handler(int, siginfo_t *, void *)
Default signal handler.
Definition
read.c:112
file_close
void file_close(ifstream_t *file)
Release resources to the system.
Definition
close.c:30
file_resume_reading
void file_resume_reading(void)
Resume calling read in this thread.
Definition
read.c:106
file_stop_reading
void file_stop_reading(void)
Prevent the accumulate function from calling read in this thread.
Definition
read.c:100
file_accumulate_infinite
bool file_accumulate_infinite(ifstream_t *file, size_t count)
If possible, accumulate count bytes before returning.
Definition
read.c:69
file_from_descriptor
ifstream_t file_from_descriptor(int descriptor)
Construct a file input stream from an externally managed file descriptor.
Definition
open.c:54
file_open
ifstream_t file_open(const char *file_name, int flags)
Construct a file input stream : Open the file and allocate the buffer.
Definition
open.c:35
file_accumulate
bool file_accumulate(ifstream_t *file, size_t count)
If possible, accumulate count bytes before returning.
Definition
read.c:87
file_single_read
ssize_t file_single_read(ifstream_t *file)
Read as much as possible.
Definition
read.c:38
input_stream.h
Buffered input streams.
ifstream_t
File Input Stream.
Definition
file_input_stream.h:27
ifstream_t::opened
bool opened
Is this file still open ?
Definition
file_input_stream.h:30
ifstream_t::descriptor
int descriptor
Underlying file.
Definition
file_input_stream.h:29
ifstream_t::stream
istream_t stream
Inherit from input stream.
Definition
file_input_stream.h:28
istream_t
Input Stream.
Definition
input_stream.h:28
include
o2s
file_input_stream.h
Generated on
for O2S C Library by
1.14.0