ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
mdl_robots.h
Go to the documentation of this file.
1
20#pragma once
21
22#include <stddef.h>
23#include <stdint.h>
24
30
36
42
49
63
81
108void mdl_robots_parse(const char* text, size_t len, const char* ua_token, mdl_robots_t* out);
109
133bool mdl_robots_allows(const mdl_robots_t* robots, const char* path);
134
157const char* mdl_robots_disallow_reason(const mdl_robots_t* robots, const char* path);
158
174
189
201 *mdl_robots_fetch_fn)(void* ctx, const char* robots_url, char* buf, size_t cap, size_t* out_len);
202
237 const char* scheme,
238 const char* host,
239 const char* ua_token,
241 void* ctx,
242 char* scratch,
243 size_t scratch_cap);
mdl_robots_fetch_result_t(* mdl_robots_fetch_fn)(void *ctx, const char *robots_url, char *buf, size_t cap, size_t *out_len)
Fetch-callback type: retrieve robots_url into buf.
Definition mdl_robots.h:201
mdl_robots_limits_t
Fixed capacities for one parsed robots.txt group.
Definition mdl_robots.h:26
@ k_mdl_robots_max_rules
Max Allow/Disallow rules retained.
Definition mdl_robots.h:27
@ k_mdl_robots_path_max
Max bytes per rule path pattern.
Definition mdl_robots.h:28
mdl_robots_rule_kind_t
Whether a rule permits or forbids a matching path.
Definition mdl_robots.h:38
@ k_mdl_rule_disallow
A Disallow rule.
Definition mdl_robots.h:39
@ k_mdl_rule_allow
An Allow rule.
Definition mdl_robots.h:40
void mdl_robots_parse(const char *text, size_t len, const char *ua_token, mdl_robots_t *out)
Parse robots.txt text for the group matching ua_token.
Definition mdl_robots.c:450
bool mdl_robots_allows(const mdl_robots_t *robots, const char *path)
Decide whether path is allowed by a parsed robots group.
Definition mdl_robots.c:578
mdl_robots_fetch_result_t
Outcome class of a robots.txt fetch, per RFC 9309 convention.
Definition mdl_robots.h:44
@ k_mdl_robots_fetch_absent
Absent / transport error: allow all.
Definition mdl_robots.h:46
@ k_mdl_robots_fetch_denied
5xx status: disallow all.
Definition mdl_robots.h:47
@ k_mdl_robots_fetch_ok
A body was retrieved to parse.
Definition mdl_robots.h:45
mdl_robots_cache_limits_t
Fixed capacities for the per-host robots cache.
Definition mdl_robots.h:32
@ k_mdl_robots_host_max
Max host string bytes.
Definition mdl_robots.h:34
@ k_mdl_robots_max_hosts
Distinct hosts cached per run.
Definition mdl_robots.h:33
const char * mdl_robots_disallow_reason(const mdl_robots_t *robots, const char *path)
Return the Disallow pattern that forbids path, or NULL if allowed.
Definition mdl_robots.c:587
const mdl_robots_t * mdl_robots_cache_consult(mdl_robots_cache_t *cache, const char *scheme, const char *host, const char *ua_token, mdl_robots_fetch_fn fetch, void *ctx, char *scratch, size_t scratch_cap)
Return the cached robots rules for host, fetching on first contact.
Definition mdl_robots.c:620
One host's cached robots.txt outcome.
Definition mdl_robots.h:167
char scheme[6]
Lower-case http or https.
Definition mdl_robots.h:168
bool used
Entry is populated.
Definition mdl_robots.h:170
mdl_robots_t rules
Parsed rules for our UA.
Definition mdl_robots.h:172
char host[k_mdl_robots_host_max]
Host this entry describes.
Definition mdl_robots.h:169
bool disallow_all
5xx convention: refuse all.
Definition mdl_robots.h:171
Fixed-size per-host robots.txt cache for one run.
Definition mdl_robots.h:185
mdl_robots_cache_entry_t overflow
Full-cache scratch entry.
Definition mdl_robots.h:187
mdl_robots_cache_entry_t hosts[k_mdl_robots_max_hosts]
Cached hosts.
Definition mdl_robots.h:186
One Allow/Disallow rule from the selected group.
Definition mdl_robots.h:58
mdl_robots_rule_kind_t kind
Allow or disallow.
Definition mdl_robots.h:59
char path[k_mdl_robots_path_max]
Path pattern.
Definition mdl_robots.h:61
uint16_t len
Pattern length in bytes.
Definition mdl_robots.h:60
Rules and crawl-delay for the group matching our user-agent.
Definition mdl_robots.h:74
bool have_crawl_delay
A Crawl-delay was seen.
Definition mdl_robots.h:78
bool valid
False if input exceeded a bound.
Definition mdl_robots.h:77
uint32_t crawl_delay_ms
Crawl-delay in ms.
Definition mdl_robots.h:79
mdl_robots_rule_t rules[k_mdl_robots_max_rules]
Selected group's rules.
Definition mdl_robots.h:75
size_t count
Number of valid rules.
Definition mdl_robots.h:76