1 // SPDX-FileCopyrightText: 2025 Lady <https://www.ladys.computer/about/#lady>
2 // SPDX-License-Identifier: GPL-2.0-only
4 #ifndef CGIRLS_REQUEST_H
5 #define CGIRLS_REQUEST_H
8 The following constant expressions provide recognized media type
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
] = {
26 The following constant expressions provide recognized action verbs.
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
] = {
52 constexpr size_t cgirls_n·parsable·vbs
= 2;
53 static cgirls_vb
const cgirls_parsable·vbs
[cgirls_n·parsable·vbs
] = {
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
64 typedef struct cgirls_req cgirls_req
;
66 cgirls_vb cgirls_action
;
67 cgirls_mtype cgirls_type
;
70 char** cgirls_subpath
;
72 cgirls_req_status cgirls_status
;
76 Frees up any dynamically‐allocated memory which was allocated by
79 void cgirls_freereq (cgirls_req req
);
82 Converts the provided “path info” string into a `cgirls_req´ struct
83 and returns the result.
85 This struct contains dynamically‐allocated strings which must be freed
86 by calling `cgirls_freereq´.
88 Maximally, a “path info” string has the following form :—
90 {project}/{action}/{baseid}..{id}/{subpath}
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.
98 cgirls_req
cgirls_path2req(char const*const pathinfo
);
101 Returns the canonical “path info” string which represents the provided
104 Note that if `cgirls_req.cgirls_project´ is the null pointer, the
105 canonical “path info” string is always the empty string.
107 char* cgirls_req2path(cgirls_req
);
109 #endif /* CGIRLS_REQUEST_H */