diff options
| author | 2026-11-10 08:29:58 +0000 | |
|---|---|---|
| committer | 2026-11-10 08:33:56 +0000 | |
| commit | 776276d5c7e67356a880f3e31076d32cdc1c1882 (patch) | |
| tree | cbde131f3d46338adee9c67ac0f988295736bdd4 /src/file-scanner.h | |
| download | coursework-master.tar.gz | |
Diffstat (limited to 'src/file-scanner.h')
| -rw-r--r-- | src/file-scanner.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/file-scanner.h b/src/file-scanner.h new file mode 100644 index 0000000..494bff2 --- /dev/null +++ b/src/file-scanner.h | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | #ifndef INCLUDED_FILE_SCANNER_H | ||
| 2 | #define INCLUDED_FILE_SCANNER_H | ||
| 3 | |||
| 4 | #include <liburing.h> | ||
| 5 | |||
| 6 | #include "scanner.h" | ||
| 7 | |||
| 8 | #define READ_SIZE (128 << 10) | ||
| 9 | #define RING_SIZE 4 | ||
| 10 | #define IO_URING_SIZE 16 // 4K 4K 8K 16K 32K 64K 128K 128K 128K | ||
| 11 | |||
| 12 | struct file_scanner { | ||
| 13 | struct scanner scanner; | ||
| 14 | size_t to_mark_as_scanned; | ||
| 15 | size_t input_size; | ||
| 16 | size_t input_submitted; | ||
| 17 | size_t input_scanned; | ||
| 18 | int input_fd; | ||
| 19 | int memfd; | ||
| 20 | enum file_scanner__state { | ||
| 21 | FILE_SCANNER__STATE__NO_END, | ||
| 22 | FILE_SCANNER__STATE__READ_END, | ||
| 23 | FILE_SCANNER__STATE__REACHED_END, | ||
| 24 | } state; | ||
| 25 | struct io_uring io_uring; | ||
| 26 | char *buffer; | ||
| 27 | }; | ||
| 28 | |||
| 29 | void file_scanner__init (struct file_scanner *, int fd); | ||
| 30 | void file_scanner__deinit (struct file_scanner *); | ||
| 31 | bool file_scanner__reached_end (struct file_scanner *); | ||
| 32 | void file_scanner__skip_until (struct file_scanner *, char); | ||
| 33 | void file_scanner__skip_over (struct file_scanner *, char); | ||
| 34 | void file_scanner__skip_until_one_of (struct file_scanner *, char *); | ||
| 35 | void file_scanner__skip_n (struct file_scanner *, size_t); | ||
| 36 | struct string_view file_scanner__get_until (struct file_scanner *, char); | ||
| 37 | struct string_view file_scanner__get_until_one_of (struct file_scanner *, char *); | ||
| 38 | struct string_view file_scanner__get_n (struct file_scanner *, size_t); | ||
| 39 | uint64_t file_scanner__get_uint64 (struct file_scanner *); | ||
| 40 | int64_t file_scanner__get_int64 (struct file_scanner *); | ||
| 41 | |||
| 42 | #endif // INCLUDED_FILE_SCANNER_H | ||
