Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_html.h
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
32#ifndef __NILOREA_HTML_HEADER
33#define __NILOREA_HTML_HEADER
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39#include "nilorea/n_list.h"
40#include "nilorea/n_str.h"
41
42#include <stddef.h>
43
45typedef struct N_FORM_FIELD {
46 char* name;
47 char* type;
48 char* value;
51
53typedef struct N_HTML_FORM {
54 char* method;
55 char* action;
56 char* enctype;
59
61LIST* n_html_extract_links(const char* html, size_t len);
63LIST* n_html_extract_forms(const char* html, size_t len);
65LIST* n_sitemap_extract_urls(const char* xml, size_t len);
67LIST* n_html_extract_js_urls(const char* js, size_t len);
69LIST* n_html_extract_scripts(const char* html, size_t len);
71N_STR* n_html_to_text(const char* html, size_t len);
73void n_html_links_free(LIST** links);
75void n_html_forms_free(LIST** forms);
76
77#ifdef __cplusplus
78}
79#endif
80
81#endif /* __NILOREA_HTML_HEADER */
Structure of a generic LIST container.
Definition n_list.h:59
A box including a string and his lenght.
Definition n_str.h:61
char * action
action attribute (may be "" for self)
Definition n_html.h:55
void n_html_links_free(LIST **links)
free a list returned by n_html_extract_links or n_sitemap_extract_urls
Definition n_html.c:979
LIST * fields
list of N_FORM_FIELD*
Definition n_html.h:57
LIST * n_html_extract_js_urls(const char *js, size_t len)
extract URL/path tokens from JavaScript source (quoted string literals that look like an http(s) URL,...
Definition n_html.c:915
LIST * n_sitemap_extract_urls(const char *xml, size_t len)
extract <loc> URLs from a sitemap.xml as a LIST of N_STR*; free with n_html_links_free
Definition n_html.c:456
LIST * n_html_extract_scripts(const char *html, size_t len)
extract the inline <script> bodies (those without a src attribute) from an HTML document as a LIST of...
Definition n_html.c:941
char * value
default value attribute, or ""
Definition n_html.h:48
N_STR * n_html_to_text(const char *html, size_t len)
render HTML to readable plain text: drop tags, skip script/style, decode common entities,...
Definition n_html.c:627
char * type
field type (lowercased), default "text"
Definition n_html.h:47
char * name
field name attribute, or ""
Definition n_html.h:46
void n_html_forms_free(LIST **forms)
free a list returned by n_html_extract_forms
Definition n_html.c:984
int required
1 when the required attribute is present
Definition n_html.h:49
char * enctype
lower-case enctype, default "application/x-www-form-urlencoded"
Definition n_html.h:56
char * method
upper-case method, default "GET"
Definition n_html.h:54
LIST * n_html_extract_links(const char *html, size_t len)
extract link URLs (a/href, form/action, img/src, script/src, link/href, iframe/src) as a LIST of N_ST...
Definition n_html.c:360
LIST * n_html_extract_forms(const char *html, size_t len)
extract forms as a LIST of N_HTML_FORM*; free with n_html_forms_free
Definition n_html.c:392
a single form field (input, select, textarea, button)
Definition n_html.h:45
a parsed HTML form with its fields
Definition n_html.h:53
List structures and definitions.
N_STR and string function declaration.