Author: adrian.chadd
Date: Mon Feb 2 11:49:00 2009
New Revision: 13787
Modified:
branches/LUSCA_HEAD/src/ftp.c
Log:
Eliminate strBuf() calls
Modified: branches/LUSCA_HEAD/src/ftp.c
==============================================================================
--- branches/LUSCA_HEAD/src/ftp.c (original)
+++ branches/LUSCA_HEAD/src/ftp.c Mon Feb 2 11:49:00 2009
@@ -360,7 +360,10 @@
wordlist *w;
char *dirup;
int i, j, k;
- const char *title = strBuf(ftpState->title_url);
+ const char *title;
+
+ title = stringDupToC(&ftpState->title_url);
+
storeAppendPrintf(e, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n");
storeAppendPrintf(e, "<!-- HTML listing generated by Squid %s -->\n",
version_string);
@@ -417,6 +420,7 @@
dirup = ftpHtmlifyListEntry("<internal-dirup>", ftpState);
storeAppend(e, dirup, strlen(dirup));
ftpState->flags.html_header_sent = 1;
+ safe_free(title);
}
static void
@@ -1146,8 +1150,10 @@
}
ftpCheckUrlpath(ftpState);
ftpBuildTitleUrl(ftpState);
- debug(9, 5) ("ftpStart: host=%s, path=%s, user=%s, passwd=%s\n",
- ftpState->request->host, strBuf(ftpState->request->urlpath),
+ debug(9, 5) ("ftpStart: host=%s, path=%.*s, user=%s, passwd=%s\n",
+ ftpState->request->host,
+ strLen2(ftpState->request->urlpath),
+ strBuf2(ftpState->request->urlpath),
ftpState->user, ftpState->password);
ftpState->state = BEGIN;
ftpState->ctrl.last_command = xstrdup("Connect to server");
@@ -1486,7 +1492,7 @@
ftpSendType(FtpStateData * ftpState)
{
int i;
- const char *filename;
+ const char *filename = NULL;
char mode;
/*
* Ref section 3.2.2 of RFC 1738
@@ -1504,10 +1510,11 @@
} else {
i = strRChr(&ftpState->request->urlpath, '/');
if (i < 0)
- filename = strBuf(ftpState->request->urlpath);
+ filename = stringDupToC(&ftpState->request->urlpath);
else
- filename = strBuf(ftpState->request->urlpath) + i + 1;
+ filename = stringDupToCOffset(&ftpState->request->urlpath,
i + 1);
mode = mimeGetTransferMode(filename);
+ safe_free(filename);
}
break;
}
@@ -1714,9 +1721,10 @@
ftpUnhack(ftpState);
ftpState->size = strto_off_t(ftpState->ctrl.last_reply, NULL, 10);
if (ftpState->size == 0) {
- debug(9, 2) ("ftpReadSize: SIZE reported %s on %s\n",
+ debug(9, 2) ("ftpReadSize: SIZE reported %s on %.*s\n",
ftpState->ctrl.last_reply,
- strBuf(ftpState->title_url));
+ strLen2(ftpState->title_url),
+ strBuf2(ftpState->title_url));
ftpState->size = -1;
}
} else if (code < 0) {
@@ -2565,9 +2573,9 @@
storeBuffer(e); /* released when done processing current data
payload
*/
i = strRChr(&urlpath, '/');
if (i < 0)
- filename = strBuf(urlpath);
+ filename = stringDupToC(&urlpath);
else
- filename = strBuf(urlpath) + i + 1;
+ filename = stringDupToCOffset(&urlpath, i + 1);
if (ftpState->flags.isdir) {
mime_type = "text/html";
} else {
@@ -2585,6 +2593,7 @@
break;
}
}
+ safe_free(filename);
httpReplyReset(reply);
/* set standard stuff */
if (ftpState->restarted_offset) {
@@ -2647,13 +2656,14 @@
*t = '\0';
strcat(loginbuf, "@");
}
- snprintf(buf, MAX_URL, "%s://%s%s%s%s%s",
+ snprintf(buf, MAX_URL, "%s://%s%s%s%s%.*s",
ProtocolStr[request->protocol],
loginbuf,
request->host,
portbuf,
"/%2f",
- strBuf(request->urlpath));
+ strLen2(request->urlpath),
+ strBuf2(request->urlpath));
if ((t = strchr(buf, '?')))
*t = '\0';
return buf;
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---