Author: adrian.chadd
Date: Mon Feb 2 10:32:22 2009
New Revision: 13779
Modified:
branches/LUSCA_HEAD/src/gopher.c
Log:
strBuf() -> strBuf2() conversion.
All of this could absolutely do with a conversion to String, but first a
whole lot
of support routines would need to be converted to use String instead of
const char *.
Oh well, one day..
Modified: branches/LUSCA_HEAD/src/gopher.c
==============================================================================
--- branches/LUSCA_HEAD/src/gopher.c (original)
+++ branches/LUSCA_HEAD/src/gopher.c Mon Feb 2 10:32:22 2009
@@ -178,25 +178,33 @@
}
/* Parse a gopher request into components. By Anawat. */
+/*
+ * XXX ugly; it should really created substrings of a String and throw
+ * XXX that around!
+ */
static void
gopher_request_parse(const request_t * req, char *type_id, char *request)
{
- const char *path = strBuf(req->urlpath);
+ const char *path_str = strBuf2(req->urlpath);
+ int path_len = strLen2(req->urlpath);
if (request)
request[0] = '\0';
- if (path && (*path == '/'))
- path++;
+ if (path_str && (*path_str == '/')) {
+ path_str++;
+ path_len--;
+ }
- if (!path || !*path) {
+ if (!path_str || !*path_str) {
*type_id = GOPHER_DIRECTORY;
return;
}
- *type_id = path[0];
+ *type_id = path_str[0];
if (request) {
- xstrncpy(request, path + 1, MAX_URL);
+ xstrncpy(request, path_str + 1, XMIN(MAX_URL - 1, path_len - 1));
+ request[XMIN(MAX_URL - 1, path_len - 1)] = '\0';
/* convert %xx to char */
url_convert_hex(request, 0);
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---