- // The portion of the pathinfo which follows the first slash but
- // precedes the second gives the verb of the request. If there is no
- // second slash, the verb extends to the end of the string. If the
- // verb is not present, or is the empty string, it is treated as
- // `"index"´, unless the second slash is present, in which case it is
- // treated as `"unknown"´.
- //
- // Verbs may be suffixed with one of a small number of extensions to
- // request a specific type of response.
- //
- // Only a few verbs are recognized (corresponding to the `cgirls_vb´
- // constants). If a verb is present, but unrecognized, it is assigned
- // the special value `cgirls_vb_unknown´, which should generally be
- // interpreted as an error.
- char const* eovb = strchr(sont, '/');
- if (!eovb) {
- eovb = eopi;
- }
- char const*const eove = eovb;
- char* verb = nullptr;
- if (eovb - sont > 4) {
- // If the verb is at least 5 characters, extract the extension if
- // present (it will be the last 4), and then set the end of the
- // verb to the start of the extension.
- char const* exts = eovb - 4;
- do {
- // This “loop” encapsulates extension checking for readability.
- // If an extension matches, `eovb´ is re·assigned to point to the
- // beginning of the extension. Otherwise, the loop exits early
- // and `eovb´ keeps pointing at the end of the string.
- if (strncmp(exts, ".txt", 4) == 0) {
- req.cgirls_type = cgirls_mediatype_txt;
- } else if (strncmp(exts, ".htm", 4) == 0) {
- req.cgirls_type = cgirls_mediatype_htm;
- } else if (strncmp(exts, ".xml", 4) == 0) {
- req.cgirls_type = cgirls_mediatype_xml;
- } else if (strncmp(exts, ".rdf", 4) == 0) {
- req.cgirls_type = cgirls_mediatype_rdf;
- } else {
- break; // do not re·assign `eovb´
+ // The portion of the pathinfo which follows the first slash but
+ // precedes the second gives the action of the request. If there is
+ // no second slash, the action extends to the end of the string. If
+ // the action is not present, or is the empty string, it is treated
+ // as `"index"´, unless the second slash is present, in which case it
+ // is treated as `"unknown"´.
+ //
+ // Actions consist of verbs optionally suffixed with one of a small
+ // number of extensions to request a specific type of response.
+ //
+ // Only a few verbs are recognized (corresponding to the `cgirls_vb´
+ // constants). If a verb is present, but unrecognized, it is assigned
+ // the special value `cgirls_vb_unknown´, which should generally be
+ // interpreted as an error.
+ char* soa = cgirls_gobblepath(ndx, end);
+ if (soa) {
+ char*const eoa = strchr(soa, 0);
+ if (eoa - soa > 4) {
+ // If the verb is at least 5 characters, extract the extension if
+ // present (it will be the last 4). Then set the first character
+ // of the extension to null, effectively trimming the verb.
+ char* ext = eoa - 4;
+ for (size_t i = 0; i < cgirls_n·mtypes; ++i) {
+ cgirls_mtype ixt = cgirls_mtypes[i];
+ if (strncmp(ext, ixt, 4) == 0) {
+ req.cgirls_type = ixt;
+ ext[0] = 0;
+ break;
+ }
+ }
+ }
+ for (size_t i = 0; i < cgirls_n·parsable·vbs; ++i) {
+ cgirls_vb ivb = cgirls_parsable·vbs[i];
+ if (strcmp(soa, ivb) == 0) {
+ req.cgirls_action = ivb;
+ break;