]> Lady’s Gitweb - CGirls/blob - request.h
Add basic Les·M·L documentation generation
[CGirls] / request.h
1 // SPDX-FileCopyrightText: 2025 Lady <https://www.ladys.computer/about/#lady>
2 // SPDX-License-Identifier: GPL-2.0-only
3
4 #ifndef CGIRLS_REQUEST_H
5 #define CGIRLS_REQUEST_H
6
7 /*
8 The following constant expressions provide recognized media type
9 extensions.
10 */
11 constexpr char* cgirls_mtype_any = nullptr;
12 constexpr char cgirls_mtype_txt[] = ".txt";
13 constexpr char cgirls_mtype_htm[] = ".htm";
14 constexpr char cgirls_mtype_xml[] = ".xml";
15 constexpr char cgirls_mtype_rdf[] = ".rdf";
16 typedef char const* cgirls_mtype;
17 constexpr size_t cgirls_n·mtypes = 4;
18 static cgirls_mtype const cgirls_mtypes[cgirls_n·mtypes] = {
19 cgirls_mtype_txt,
20 cgirls_mtype_htm,
21 cgirls_mtype_xml,
22 cgirls_mtype_rdf,
23 };
24
25 /*
26 The following constant expressions provide recognized action verbs.
27 */
28 // Actions in general:
29 constexpr char cgirls_vb_index[] = "index";
30 constexpr char cgirls_vb_unknown[] = "unknown";
31 // Actions on projects:
32 // constexpr char cgirls_vb_branches[] = "branches";
33 // constexpr char cgirls_vb_tags[] = "tags";
34 // Actions on single objects:
35 constexpr char cgirls_vb_show[] = "show";
36 // constexpr char cgirls_vb_raw[] = "raw";
37 // constexpr char cgirls_vb_blame[] = "blame";
38 // Actions on ranges of commits:
39 // constexpr char cgirls_vb_diff[] = "diff";
40 // Actions on lists of commits:
41 // constexpr char cgirls_vb_log[] = "log";
42 // constexpr char cgirls_vb_shortlog[] = "shortlog";
43 // constexpr char cgirls_vb_atom[] = "atom";
44 // constexpr char cgirls_vb_patch[] = "patch";
45 typedef char const* cgirls_vb;
46 constexpr size_t cgirls_n·vbs = 3;
47 static cgirls_vb const cgirls_vbs[cgirls_n·vbs] = {
48 cgirls_vb_index,
49 cgirls_vb_unknown,
50 cgirls_vb_show,
51 };
52 constexpr size_t cgirls_n·parsable·vbs = 2;
53 static cgirls_vb const cgirls_parsable·vbs[cgirls_n·parsable·vbs] = {
54 cgirls_vb_index,
55 cgirls_vb_show,
56 };
57
58 typedef struct cgirls_req_status cgirls_req_status;
59 struct cgirls_req_status {
60 unsigned short cgirls_code;
61 char* cgirls_message; // if `cgirls_code´ is not ok
62 };
63
64 typedef struct cgirls_req cgirls_req;
65 struct cgirls_req {
66 cgirls_vb cgirls_action;
67 cgirls_mtype cgirls_type;
68 char* cgirls_project;
69 char* cgirls_id;
70 char** cgirls_subpath;
71 char* cgirls_baseid;
72 cgirls_req_status cgirls_status;
73 };
74
75 /*
76 Frees up any dynamically‐allocated memory which was allocated by
77 `cgirls_path2req´.
78 */
79 void cgirls_freereq (cgirls_req req);
80
81 /*
82 Converts the provided “path info” string into a `cgirls_req´ struct
83 and returns the result.
84
85 This struct contains dynamically‐allocated strings which must be freed
86 by calling `cgirls_freereq´.
87
88 Maximally, a “path info” string has the following form :—
89
90 {project}/{action}/{baseid}..{id}/{subpath}
91
92 —: (where subpath can contain additional slashes, and action may
93 optionally include one of a small number of supported extensions).
94 `baseid´ is optional; if omitted, the dots preceding `id´ are also
95 dropped. For all other components, all preceding components must be
96 provided if a given component is provided.
97 */
98 cgirls_req cgirls_path2req(char const*const pathinfo);
99
100 /*
101 Returns the canonical “path info” string which represents the provided
102 `cgirls_req´.
103
104 Note that if `cgirls_req.cgirls_project´ is the null pointer, the
105 canonical “path info” string is always the empty string.
106 */
107 char* cgirls_req2path(cgirls_req);
108
109 #endif /* CGIRLS_REQUEST_H */
This page took 0.301888 seconds and 5 git commands to generate.