blob: 494bff298abbe3fa3aa5224e47969be9e35b6d2a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#ifndef INCLUDED_FILE_SCANNER_H
#define INCLUDED_FILE_SCANNER_H
#include <liburing.h>
#include "scanner.h"
#define READ_SIZE (128 << 10)
#define RING_SIZE 4
#define IO_URING_SIZE 16 // 4K 4K 8K 16K 32K 64K 128K 128K 128K
struct file_scanner {
struct scanner scanner;
size_t to_mark_as_scanned;
size_t input_size;
size_t input_submitted;
size_t input_scanned;
int input_fd;
int memfd;
enum file_scanner__state {
FILE_SCANNER__STATE__NO_END,
FILE_SCANNER__STATE__READ_END,
FILE_SCANNER__STATE__REACHED_END,
} state;
struct io_uring io_uring;
char *buffer;
};
void file_scanner__init (struct file_scanner *, int fd);
void file_scanner__deinit (struct file_scanner *);
bool file_scanner__reached_end (struct file_scanner *);
void file_scanner__skip_until (struct file_scanner *, char);
void file_scanner__skip_over (struct file_scanner *, char);
void file_scanner__skip_until_one_of (struct file_scanner *, char *);
void file_scanner__skip_n (struct file_scanner *, size_t);
struct string_view file_scanner__get_until (struct file_scanner *, char);
struct string_view file_scanner__get_until_one_of (struct file_scanner *, char *);
struct string_view file_scanner__get_n (struct file_scanner *, size_t);
uint64_t file_scanner__get_uint64 (struct file_scanner *);
int64_t file_scanner__get_int64 (struct file_scanner *);
#endif // INCLUDED_FILE_SCANNER_H
|