26typedef enum : uint16_t {
32typedef enum : uint16_t {
38typedef enum : uint8_t {
44typedef enum : uint8_t {
201 *
mdl_robots_fetch_fn)(
void* ctx,
const char* robots_url,
char* buf,
size_t cap,
size_t* out_len);
239 const char* ua_token,
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.
mdl_robots_limits_t
Fixed capacities for one parsed robots.txt group.
@ k_mdl_robots_max_rules
Max Allow/Disallow rules retained.
@ k_mdl_robots_path_max
Max bytes per rule path pattern.
mdl_robots_rule_kind_t
Whether a rule permits or forbids a matching path.
@ k_mdl_rule_disallow
A Disallow rule.
@ k_mdl_rule_allow
An Allow rule.
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.
bool mdl_robots_allows(const mdl_robots_t *robots, const char *path)
Decide whether path is allowed by a parsed robots group.
mdl_robots_fetch_result_t
Outcome class of a robots.txt fetch, per RFC 9309 convention.
@ k_mdl_robots_fetch_absent
Absent / transport error: allow all.
@ k_mdl_robots_fetch_denied
5xx status: disallow all.
@ k_mdl_robots_fetch_ok
A body was retrieved to parse.
mdl_robots_cache_limits_t
Fixed capacities for the per-host robots cache.
@ k_mdl_robots_host_max
Max host string bytes.
@ k_mdl_robots_max_hosts
Distinct hosts cached per run.
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.
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.
One host's cached robots.txt outcome.
char scheme[6]
Lower-case http or https.
bool used
Entry is populated.
mdl_robots_t rules
Parsed rules for our UA.
char host[k_mdl_robots_host_max]
Host this entry describes.
bool disallow_all
5xx convention: refuse all.
Fixed-size per-host robots.txt cache for one run.
mdl_robots_cache_entry_t overflow
Full-cache scratch entry.
mdl_robots_cache_entry_t hosts[k_mdl_robots_max_hosts]
Cached hosts.
One Allow/Disallow rule from the selected group.
mdl_robots_rule_kind_t kind
Allow or disallow.
char path[k_mdl_robots_path_max]
Path pattern.
uint16_t len
Pattern length in bytes.
Rules and crawl-delay for the group matching our user-agent.
bool have_crawl_delay
A Crawl-delay was seen.
bool valid
False if input exceeded a bound.
uint32_t crawl_delay_ms
Crawl-delay in ms.
mdl_robots_rule_t rules[k_mdl_robots_max_rules]
Selected group's rules.
size_t count
Number of valid rules.