rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Toggle main menu visibility
Loading...
Searching...
No Matches
wa_walk.h
Go to the documentation of this file.
1
29
30
#ifndef RCBENCH_WA_WALK_H
31
#define RCBENCH_WA_WALK_H
32
33
#include <stdbool.h>
34
#include <stdint.h>
35
36
#include "wa_text.h"
37
38
#ifdef __cplusplus
39
extern
"C"
{
40
#endif
41
43
#define WA_WALK_DEPTH 16u
44
45
typedef
struct
{
46
char
name[WA_NAME_BYTES];
47
bool
dir;
48
uint64_t
size
;
49
int64_t
mtime
;
50
}
wa_dirent_t
;
51
53
typedef
struct
{
54
void
*(*opendir)(
void
*ctx,
const
char
*path);
56
int (*
readdir
)(
void
*ctx,
void
*dir,
wa_dirent_t
*out);
57
void (*closedir)(
void
*ctx,
void
*dir);
58
void
*(*open)(
void
*ctx,
const
char
*path);
60
int32_t (*
read
)(
void
*ctx,
void
*file, uint8_t *dst, uint32_t len);
61
void (*close)(
void
*ctx,
void
*file);
62
void
*ctx;
65
bool (*
stopped
)(
void
*ctx);
66
}
wa_fs_t
;
67
69
typedef
enum
{
70
WA_WALK_DIR
= 0,
71
WA_WALK_FILE
,
72
WA_WALK_END
,
73
WA_WALK_NO_CARD
,
74
WA_WALK_ERROR
,
75
}
wa_walk_ev_t
;
76
77
typedef
struct
{
78
void
*
dir
;
79
uint32_t
len
;
80
bool
dirs
;
81
}
wa_level_t
;
82
84
typedef
struct
{
85
const
wa_fs_t
*
fs
;
86
unsigned
depth
;
87
wa_level_t
lv
[
WA_WALK_DEPTH
+ 1u];
88
char
path
[WA_PATH_MAX + 1u];
89
wa_dirent_t
ent
;
90
unsigned
long
left_out
;
91
bool
started
;
92
wa_walk_ev_t
last
;
93
bool
over
;
94
}
wa_walk_t
;
95
101
void
wa_walk_begin
(
wa_walk_t
*w,
const
wa_fs_t
*fs);
102
113
wa_walk_ev_t
wa_walk_next
(
wa_walk_t
*w);
114
119
void
wa_walk_end
(
wa_walk_t
*w);
120
121
#ifdef __cplusplus
122
}
123
#endif
124
125
#endif
/* RCBENCH_WA_WALK_H */
wa_dirent_t
Definition
wa_walk.h:45
wa_dirent_t::mtime
int64_t mtime
Definition
wa_walk.h:49
wa_dirent_t::size
uint64_t size
Definition
wa_walk.h:48
wa_fs_t
Definition
wa_walk.h:53
wa_fs_t::readdir
int(*) readdir(void *ctx, void *dir, wa_dirent_t *out)
Definition
wa_walk.h:56
wa_fs_t::stopped
bool(*) stopped(void *ctx)
Whether the walk is to end now, asked before every entry; NULL never.
Definition
wa_walk.h:65
wa_fs_t::read
int32_t(*) read(void *ctx, void *file, uint8_t *dst, uint32_t len)
Definition
wa_walk.h:60
wa_level_t
Definition
wa_walk.h:77
wa_level_t::dir
void * dir
Definition
wa_walk.h:78
wa_level_t::dirs
bool dirs
Definition
wa_walk.h:80
wa_level_t::len
uint32_t len
Definition
wa_walk.h:79
wa_walk_t
A walk under way.
Definition
wa_walk.h:84
wa_walk_t::started
bool started
Definition
wa_walk.h:91
wa_walk_t::path
char path[WA_PATH_MAX+1u]
Definition
wa_walk.h:88
wa_walk_t::fs
const wa_fs_t * fs
Definition
wa_walk.h:85
wa_walk_t::over
bool over
Definition
wa_walk.h:93
wa_walk_t::left_out
unsigned long left_out
Definition
wa_walk.h:90
wa_walk_t::ent
wa_dirent_t ent
Definition
wa_walk.h:89
wa_walk_t::last
wa_walk_ev_t last
Definition
wa_walk.h:92
wa_walk_t::depth
unsigned depth
Definition
wa_walk.h:86
wa_walk_t::lv
wa_level_t lv[WA_WALK_DEPTH+1u]
Definition
wa_walk.h:87
wa_walk_next
wa_walk_ev_t wa_walk_next(wa_walk_t *w)
The next event.
Definition
wa_walk.c:89
wa_walk_end
void wa_walk_end(wa_walk_t *w)
Close every handle that is open; for a walk given up part way.
Definition
wa_walk.c:18
WA_WALK_DEPTH
#define WA_WALK_DEPTH
Definition
wa_walk.h:43
wa_walk_ev_t
wa_walk_ev_t
What wa_walk_next() hands out.
Definition
wa_walk.h:69
WA_WALK_FILE
@ WA_WALK_FILE
Definition
wa_walk.h:71
WA_WALK_DIR
@ WA_WALK_DIR
Definition
wa_walk.h:70
WA_WALK_NO_CARD
@ WA_WALK_NO_CARD
Definition
wa_walk.h:73
WA_WALK_END
@ WA_WALK_END
Definition
wa_walk.h:72
WA_WALK_ERROR
@ WA_WALK_ERROR
Definition
wa_walk.h:74
wa_walk_begin
void wa_walk_begin(wa_walk_t *w, const wa_fs_t *fs)
A walk of fs from its root; nothing is opened yet.
Definition
wa_walk.c:12
shared
webaccess
include
wa_walk.h
Generated by
1.18.0