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
7 enum cgirls_mediatype
: unsigned char {
8 // Unspecified media type
9 cgirls_mediatype_any
= 0x00,
11 cgirls_mediatype_txt
= 0x10,
12 cgirls_mediatype_htm
= 0x11,
14 cgirls_mediatype_xml
= 0x20,
15 cgirls_mediatype_rdf
= 0x21,
17 typedef enum cgirls_mediatype cgirls_mediatype
;
19 enum cgirls_vb
: unsigned char {
21 cgirls_vb_index
= 0x00,
22 // Actions on projects
23 cgirls_vb_branches
= 0x10,
24 cgirls_vb_tags
= 0x11,
25 // Actions on single objects
26 cgirls_vb_show
= 0x20,
28 cgirls_vb_blame
= 0x22,
29 // Actions on ranges of objects
31 cgirls_vb_shortlog
= 0x31,
32 cgirls_vb_atom
= 0x32,
33 cgirls_vb_patch
= 0x33,
35 cgirls_vb_unknown
= 0xFF,
37 typedef enum cgirls_vb cgirls_vb
;
39 typedef struct cgirls_req_status cgirls_req_status
;
40 struct cgirls_req_status
{
41 unsigned short cgirls_code
;
42 char* cgirls_message
; // if `cgirls_code´ is not ok
45 typedef struct cgirls_req cgirls_req
;
47 cgirls_vb cgirls_action
;
48 cgirls_mediatype cgirls_type
;
51 char** cgirls_subpath
;
53 cgirls_req_status cgirls_status
;
57 Frees up any dynamically‐allocated memory which was allocated by
60 void cgirls_freereq (cgirls_req req
);
63 Converts the provided “path info” string into a `cgirls_req´ struct
64 and returns the result.
66 This struct contains dynamically‐allocated strings which must be freed
67 by calling `cgirls_freereq´.
69 Maximally, a “path info” string has the following form :—
71 {project}/{action}/{baseid}..{id}/{subpath}
73 —: (where subpath can contain additional slashes, and action may
74 optionally include one of a small number of supported extensions).
75 `baseid´ is optional; if omitted, the dots preceding `id´ are also
76 dropped. For all other components, all preceding components must be
77 provided if a given component is provided.
79 cgirls_req
cgirls_path2req(char const*const pathinfo
);
82 Returns the canonical “path info” string which represents the provided
85 Note that if `cgirls_req.cgirls_project´ is the null pointer, the
86 canonical “path info” string is always the empty string.
88 char* cgirls_req2path(cgirls_req
);
90 #endif /* CGIRLS_REQUEST_H */