summaryrefslogtreecommitdiff
path: root/src/gmutil.h
blob: 6c1b01ad5612b613603d112127baafc5f62bd550 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once

#include <the_Foundation/range.h>
#include <the_Foundation/string.h>

iDeclareType(GmError)
iDeclareType(Url)

/* Response status codes. */
enum iGmStatusCode {
    clientSide_GmStatusCode = -100, /* clientside status codes */
    invalidRedirect_GmStatusCode,
    invalidHeader_GmStatusCode,
    unsupportedMimeType_GmStatusCode,
    failedToOpenFile_GmStatusCode,
    unknownStatusCode_GmStatusCode,
    none_GmStatusCode                      = 0,
    input_GmStatusCode                     = 10,
    sensitiveInput_GmStatusCode            = 11,
    success_GmStatusCode                   = 20,
    redirectTemporary_GmStatusCode         = 30,
    redirectPermanent_GmStatusCode         = 31,
    temporaryFailure_GmStatusCode          = 40,
    serverUnavailable_GmStatusCode         = 41,
    cgiError_GmStatusCode                  = 42,
    proxyError_GmStatusCode                = 43,
    slowDown_GmStatusCode                  = 44,
    permanentFailure_GmStatusCode          = 50,
    notFound_GmStatusCode                  = 51,
    gone_GmStatusCode                      = 52,
    proxyRequestRefused_GmStatusCode       = 53,
    badRequest_GmStatusCode                = 59,
    clientCertificateRequired_GmStatusCode = 60,
    certificateNotAuthorized_GmStatusCode  = 61,
    certificateNotValid_GmStatusCode       = 62,
};

struct Impl_GmError {
    iChar       icon;
    const char *title;
    const char *info;
};

iBool               isDefined_GmError   (enum iGmStatusCode code);
const iGmError *    get_GmError         (enum iGmStatusCode code);

struct Impl_Url {
    iRangecc protocol;
    iRangecc host;
    iRangecc port;
    iRangecc path;
    iRangecc query;
};

void            init_Url                (iUrl *, const iString *text);

iRangecc        urlHost_String          (const iString *);
const iString * absoluteUrl_String      (const iString *, const iString *urlMaybeRelative);
void            urlEncodeSpaces_String  (iString *);