diff options
Diffstat (limited to 'src/gmutil.c')
-rw-r--r-- | src/gmutil.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/gmutil.c b/src/gmutil.c index 0caadd32..4b49e1d0 100644 --- a/src/gmutil.c +++ b/src/gmutil.c | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | #include <the_Foundation/regexp.h> | 3 | #include <the_Foundation/regexp.h> |
4 | #include <the_Foundation/object.h> | 4 | #include <the_Foundation/object.h> |
5 | #include <the_Foundation/path.h> | ||
5 | 6 | ||
6 | void init_Url(iUrl *d, const iString *text) { | 7 | void init_Url(iUrl *d, const iString *text) { |
7 | iRegExp *absPat = | 8 | iRegExp *absPat = |
@@ -142,6 +143,13 @@ const iString *absoluteUrl_String(const iString *d, const iString *urlMaybeRelat | |||
142 | return absolute; | 143 | return absolute; |
143 | } | 144 | } |
144 | 145 | ||
146 | iString *makeFileUrl_String(const iString *localFilePath) { | ||
147 | iString *url = cleaned_Path(localFilePath); | ||
148 | replace_Block(&url->chars, '\\', '/'); /* in case it's a Windows path */ | ||
149 | prependCStr_String(url, "file://"); | ||
150 | return url; | ||
151 | } | ||
152 | |||
145 | void urlEncodeSpaces_String(iString *d) { | 153 | void urlEncodeSpaces_String(iString *d) { |
146 | for (;;) { | 154 | for (;;) { |
147 | const size_t pos = indexOfCStr_String(d, " "); | 155 | const size_t pos = indexOfCStr_String(d, " "); |
@@ -166,6 +174,10 @@ static const struct { | |||
166 | "Failed to Open File", | 174 | "Failed to Open File", |
167 | "The requested file does not exist or is inaccessible. " | 175 | "The requested file does not exist or is inaccessible. " |
168 | "Please check the file path." } }, | 176 | "Please check the file path." } }, |
177 | { invalidLocalResource_GmStatusCode, | ||
178 | { 0, | ||
179 | "Invalid Resource", | ||
180 | "The requested resource does not exist." } }, | ||
169 | { unsupportedMimeType_GmStatusCode, | 181 | { unsupportedMimeType_GmStatusCode, |
170 | { 0x1f47d, /* alien */ | 182 | { 0x1f47d, /* alien */ |
171 | "Unsupported MIME Type", | 183 | "Unsupported MIME Type", |
@@ -178,7 +190,7 @@ static const struct { | |||
178 | "Perhaps the server is malfunctioning or you tried to contact a " | 190 | "Perhaps the server is malfunctioning or you tried to contact a " |
179 | "non-Gemini server." } }, | 191 | "non-Gemini server." } }, |
180 | { invalidRedirect_GmStatusCode, | 192 | { invalidRedirect_GmStatusCode, |
181 | { 0, /* */ | 193 | { 0x27a0, /* dashed arrow */ |
182 | "Invalid Redirect", | 194 | "Invalid Redirect", |
183 | "The server responded with a redirect but did not provide a valid destination URL. " | 195 | "The server responded with a redirect but did not provide a valid destination URL. " |
184 | "Perhaps the server is malfunctioning." } }, | 196 | "Perhaps the server is malfunctioning." } }, |
@@ -226,7 +238,7 @@ static const struct { | |||
226 | { 0x1f44e, /* thumbs down */ | 238 | { 0x1f44e, /* thumbs down */ |
227 | "Bad Request", | 239 | "Bad Request", |
228 | "The server was unable to parse your request, presumably due to the " | 240 | "The server was unable to parse your request, presumably due to the " |
229 | "request being malformed. Likely a bug in Lagrange." } }, | 241 | "request being malformed." } }, |
230 | { clientCertificateRequired_GmStatusCode, | 242 | { clientCertificateRequired_GmStatusCode, |
231 | { 0x1f511, /* key */ | 243 | { 0x1f511, /* key */ |
232 | "Certificate Required", | 244 | "Certificate Required", |