rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Toggle main menu visibility
Loading...
Searching...
No Matches
wa_text.h
1
/*
2
* The text the Wi-Fi page reads and writes: a card path out of a URL
3
* (uniform resource locator), names into HTML (hypertext markup language)
4
* and back into URLs, a form field, a cookie, and a download's file name.
5
*
6
* The path is the part that decides what leaves the card, so it is read by
7
* one rule and everything else is refused (wa_path_decode()). The page only
8
* ever links paths that rule takes.
9
*
10
* Pure C, no ESP-IDF (Espressif Internet-of-Things Development Framework).
11
*
12
* SPDX-License-Identifier: MIT
13
*/
14
15
#ifndef RCBENCH_WA_TEXT_H
16
#define RCBENCH_WA_TEXT_H
17
18
#include <stdbool.h>
19
#include <stddef.h>
20
#include <stdint.h>
21
22
#ifdef __cplusplus
23
extern
"C"
{
24
#endif
25
27
#define WA_PATH_MAX 384u
29
#define WA_NAME_UNITS 255u
31
#define WA_NAME_BYTES (WA_NAME_UNITS * 3u + 1u)
32
33
typedef
enum
{
34
WA_PATH_OK = 0,
35
WA_PATH_EMPTY,
36
WA_PATH_ABSOLUTE,
37
WA_PATH_DOTS,
38
WA_PATH_BACKSLASH,
39
WA_PATH_ENCODED_SLASH,
40
WA_PATH_NUL,
41
WA_PATH_CONTROL,
42
WA_PATH_ESCAPE,
43
WA_PATH_UTF8,
44
WA_PATH_EMPTY_NAME,
45
WA_PATH_NAME_LONG,
46
WA_PATH_LONG,
47
} wa_path_err_t;
48
55
wa_path_err_t wa_path_decode(
const
char
*in,
size_t
n,
char
*out,
size_t
cap);
56
61
long
wa_utf8_units(
const
char
*
s
,
size_t
n);
62
63
/* ----------------------------------------------------------- output */
64
66
typedef
bool (*wa_sink_fn)(
void
*ctx,
const
void
*data,
size_t
n);
67
68
#define WA_OUT_BUF 1024u
69
71
typedef
struct
{
72
wa_sink_fn sink;
73
void
*ctx;
74
char
buf[WA_OUT_BUF];
75
size_t
used;
76
bool
failed
;
77
uint64_t
total
;
78
}
wa_out_t
;
79
80
void
wa_out_init(
wa_out_t
*o, wa_sink_fn sink,
void
*ctx);
81
void
wa_out_raw(
wa_out_t
*o,
const
void
*data,
size_t
n);
82
void
wa_out_str(
wa_out_t
*o,
const
char
*
s
);
84
void
wa_out_html(
wa_out_t
*o,
const
char
*
s
);
93
void
wa_out_js(
wa_out_t
*o,
const
char
*
s
);
95
void
wa_out_url(
wa_out_t
*o,
const
char
*path);
96
void
wa_out_u64(
wa_out_t
*o, uint64_t v);
98
bool
wa_out_flush(
wa_out_t
*o);
99
100
/* ------------------------------------------------------ what comes in */
101
107
bool
wa_form_get(
const
char
*body,
size_t
n,
const
char
*key,
char
*out,
108
size_t
cap);
109
114
bool
wa_cookie_get(
const
char
*header,
const
char
*name,
char
*out,
115
size_t
cap);
116
124
size_t
wa_disposition(
char
*out,
size_t
cap,
const
char
*name);
125
127
typedef
struct
{
128
int
year, month, day, hour, min, sec;
129
}
wa_civil_t
;
130
132
wa_civil_t
wa_civil(int64_t t);
133
135
void
wa_out_time(
wa_out_t
*o, int64_t t);
136
138
const
char
*wa_basename(
const
char
*path);
139
140
#ifdef __cplusplus
141
}
142
#endif
143
144
#endif
/* RCBENCH_WA_TEXT_H */
s
#define s
Short name for esc_stick_s inside the five stick-class files.
Definition
esc_stick_panel_int.h:295
wa_civil_t
Definition
wa_text.h:127
wa_out_t
Definition
wa_text.h:71
wa_out_t::total
uint64_t total
Definition
wa_text.h:77
wa_out_t::failed
bool failed
Definition
wa_text.h:76
shared
webaccess
include
wa_text.h
Generated by
1.18.0