From beff674887c86d4401f6033c57ab0376a9a62ed6 Mon Sep 17 00:00:00 2001 From: Spoike Date: Tue, 6 Dec 2005 02:22:44 +0000 Subject: [PATCH] Makes the ftp server work a bit better, hopefully. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1675 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/http/ftpclient.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/engine/http/ftpclient.c b/engine/http/ftpclient.c index 02480640c..2df9acc2c 100644 --- a/engine/http/ftpclient.c +++ b/engine/http/ftpclient.c @@ -305,6 +305,8 @@ iwboolean FTP_ClientConnThink (FTPclientconn_t *con) //true to kill con { if (*line == '\n') break; + if (*line == '\r') + break; line++; } if (!*line) //broken message @@ -351,8 +353,13 @@ iwboolean FTP_ClientConnThink (FTPclientconn_t *con) //true to kill con return true; } - sprintf(tempbuff, "CWD %s%s\r\nPORT %s\r\n", con->pathprefix, con->path, adr); + sprintf(tempbuff, "CWD %s%s\r\n", con->pathprefix, con->path); send(con->controlsock, tempbuff, strlen(tempbuff), 0); + + goto usepasv; + sprintf(tempbuff, "PORT %s\r\n", adr); + send(con->controlsock, tempbuff, strlen(tempbuff), 0); + con->stage = 3; } else if (ret == 200) @@ -409,6 +416,7 @@ iwboolean FTP_ClientConnThink (FTPclientconn_t *con) //true to kill con } else { +usepasv: Con_Printf("FTP: Trying passive server mode\n"); msg = va("PASV\r\n"); send(con->controlsock, msg, strlen(msg), 0); @@ -474,7 +482,7 @@ iwboolean FTP_ClientConnThink (FTPclientconn_t *con) //true to kill con if (con->NotifyFunction) { - con->NotifyFunction(con->localfile, false); + con->NotifyFunction(con->localfile, true); con->NotifyFunction = NULL; } @@ -668,6 +676,24 @@ FTPclientconn_t *FTP_FindControl(void) } return NULL; } + +void FTP_FixupPath(char *out) +{ //convert \[ to [ + char *in; + in = out; + while (*in) + { + if (*in == '\\') + { + in++; + if (*in == '\0') + break; + } + *out++ = *in++; + } + *out++ = '\0'; +} + qboolean FTP_Client_Command (char *cmd, void (*NotifyFunction)(char *localfile, qboolean sucess)) { char command[64]; @@ -721,6 +747,9 @@ qboolean FTP_Client_Command (char *cmd, void (*NotifyFunction)(char *localfile, if ((cmd = COM_ParseOut(cmd, server, sizeof(server)))) Q_strncpyz(con->localfile, server, sizeof(con->localfile)); + FTP_FixupPath(con->file); + FTP_FixupPath(con->localfile); + return true; } else if (!stricmp(command, "quit"))