* squid-2.3.DEVEL3.ftp_all_messages.patch * Mon Jan 10 23:13:00 CET 2000 Modified Files in squid/src ftp.c Show all multiline server responses from the FTP server, truncated at a successfull CWD command. This makes sure that the FTP server messages are available on the top level directory listing, or in generated error messages upon failure. ----------------------------------------------------------------- Mon Jan 10 23:37:58 CET 2000 Modified Files in squid/src cache_cf.c net_db.c protos.h extended wordlists with a couple of new functions to add or join two wordlists together. This was needed for proper display of multiple FTP multiline responses as one. ----------------------------------------------------------------- Index: squid/src/ftp.c diff -u squid/src/ftp.c:1.1.1.39.2.6 squid/src/ftp.c:1.1.1.39.2.7 --- squid/src/ftp.c:1.1.1.39.2.6 Thu Dec 23 11:08:48 1999 +++ squid/src/ftp.c Mon Jan 10 23:12:59 2000 @@ -1299,11 +1299,15 @@ xmemmove(ftpState->ctrl.buf, ftpState->ctrl.buf + bytes_used, ftpState->ctrl.offset); } - /* Find the last line of the reply message */ + /* Move the last line of the reply message to ctrl.last_reply */ for (W = &ftpState->ctrl.message; (*W)->next; W = &(*W)->next); safe_free(ftpState->ctrl.last_reply); - ftpState->ctrl.last_reply = (*W)->key; - safe_free(*W); + ftpState->ctrl.last_reply = xstrdup((*W)->key); + wordlistDestroy(W); + /* Copy the rest of the message to cwd_message to be printed in + * error messages + */ + wordlistAddWl(&ftpState->cwd_message, ftpState->ctrl.message); debug(9, 8) ("ftpHandleControlReply: state=%d, code=%d\n", ftpState->state, ftpState->ctrl.replycode); FTP_SM_FUNCS[ftpState->state] (ftpState); @@ -1324,10 +1328,6 @@ if (ftpState->ctrl.message) { if (strstr(ftpState->ctrl.message->key, "NetWare")) ftpState->flags.skip_whitespace = 1; - if (ftpState->cwd_message) - wordlistDestroy(&ftpState->cwd_message); - ftpState->cwd_message = ftpState->ctrl.message; - ftpState->ctrl.message = NULL; } ftpSendUser(ftpState); } else if (code == 120) { @@ -1381,12 +1381,6 @@ int code = ftpState->ctrl.replycode; debug(9, 3) ("ftpReadPass\n"); if (code == 230) { - if (ftpState->ctrl.message) { - if (ftpState->cwd_message) - wordlistDestroy(&ftpState->cwd_message); - ftpState->cwd_message = ftpState->ctrl.message; - ftpState->ctrl.message = NULL; - } ftpSendType(ftpState); } else { ftpFail(ftpState); @@ -1512,6 +1506,7 @@ if (code >= 200 && code < 300) { /* CWD OK */ ftpUnhack(ftpState); + /* Reset cwd_message to only include the last message */ if (ftpState->cwd_message) wordlistDestroy(&ftpState->cwd_message); ftpState->cwd_message = ftpState->ctrl.message; @@ -2342,8 +2337,8 @@ err = errorCon(ERR_FTP_FAILURE, HTTP_BAD_GATEWAY); err->xerrno = errno; err->request = requestLink(ftpState->request); - err->ftp.server_msg = ftpState->ctrl.message; - ftpState->ctrl.message = NULL; + err->ftp.server_msg = ftpState->cwd_message; + ftpState->cwd_message = NULL; if (ftpState->old_request) command = ftpState->old_request; else Index: squid/src/cache_cf.c diff -u squid/src/cache_cf.c:1.1.1.35.2.5 squid/src/cache_cf.c:1.1.1.35.2.6 --- squid/src/cache_cf.c:1.1.1.35.2.5 Mon Jan 10 10:36:13 2000 +++ squid/src/cache_cf.c Mon Jan 10 23:37:56 2000 @@ -100,7 +100,7 @@ *list = NULL; } -wordlist * +const char * wordlistAdd(wordlist ** list, const char *key) { while (*list) @@ -108,7 +108,28 @@ *list = memAllocate(MEM_WORDLIST); (*list)->key = xstrdup(key); (*list)->next = NULL; - return *list; + return (*list)->key; +} + +void +wordlistJoin(wordlist ** list, wordlist **wl) +{ + while (*list) + list = &(*list)->next; + *list = *wl; + *wl = NULL; +} + +void +wordlistAddWl(wordlist ** list, wordlist *wl) +{ + while (*list) + list = &(*list)->next; + for(;wl;wl=wl->next, list = &(*list)->next) { + *list = memAllocate(MEM_WORDLIST); + (*list)->key = xstrdup(wl->key); + (*list)->next = NULL; + } } void Index: squid/src/net_db.c diff -u squid/src/net_db.c:1.1.1.32 squid/src/net_db.c:1.1.1.32.2.1 --- squid/src/net_db.c:1.1.1.32 Sat Oct 30 13:25:12 1999 +++ squid/src/net_db.c Mon Jan 10 23:37:57 2000 @@ -60,7 +60,7 @@ static netdbEntry *netdbLookupHost(const char *key); static net_db_peer *netdbPeerByName(const netdbEntry * n, const char *); static net_db_peer *netdbPeerAdd(netdbEntry * n, peer * e); -static char *netdbPeerName(const char *name); +static const char *netdbPeerName(const char *name); static IPH netdbSendPing; static QS sortPeerByRtt; static QS sortByRtt; @@ -467,16 +467,15 @@ count, tvSubMsec(start, current_time)); } -static char * +static const char * netdbPeerName(const char *name) { - wordlist *w; + const wordlist *w; for (w = peer_names; w; w = w->next) { if (!strcmp(w->key, name)) return w->key; } - w = wordlistAdd(&peer_names, name); - return w->key; + return wordlistAdd(&peer_names, name); } static void Index: squid/src/protos.h diff -u squid/src/protos.h:1.1.1.45.2.5 squid/src/protos.h:1.1.1.45.2.6 --- squid/src/protos.h:1.1.1.45.2.5 Fri Jan 7 04:48:24 2000 +++ squid/src/protos.h Mon Jan 10 23:37:57 2000 @@ -99,7 +99,9 @@ extern int parseConfigFile(const char *file_name); extern void intlistDestroy(intlist **); extern int intlistFind(intlist * list, int i); -extern wordlist *wordlistAdd(wordlist **, const char *); +extern const char *wordlistAdd(wordlist **, const char *); +extern void wordlistAddWl(wordlist **, wordlist *); +extern void wordlistJoin(wordlist **, wordlist **); extern wordlist *wordlistDup(const wordlist *); extern void wordlistDestroy(wordlist **); extern void configFreeMemory(void);