1
0
Fork 0
forked from fte/fteqw

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
This commit is contained in:
Spoike 2005-12-06 02:22:44 +00:00
parent c6b27d0b81
commit beff674887

View file

@ -305,6 +305,8 @@ iwboolean FTP_ClientConnThink (FTPclientconn_t *con) //true to kill con
{ {
if (*line == '\n') if (*line == '\n')
break; break;
if (*line == '\r')
break;
line++; line++;
} }
if (!*line) //broken message if (!*line) //broken message
@ -351,8 +353,13 @@ iwboolean FTP_ClientConnThink (FTPclientconn_t *con) //true to kill con
return true; 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); 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; con->stage = 3;
} }
else if (ret == 200) else if (ret == 200)
@ -409,6 +416,7 @@ iwboolean FTP_ClientConnThink (FTPclientconn_t *con) //true to kill con
} }
else else
{ {
usepasv:
Con_Printf("FTP: Trying passive server mode\n"); Con_Printf("FTP: Trying passive server mode\n");
msg = va("PASV\r\n"); msg = va("PASV\r\n");
send(con->controlsock, msg, strlen(msg), 0); send(con->controlsock, msg, strlen(msg), 0);
@ -474,7 +482,7 @@ iwboolean FTP_ClientConnThink (FTPclientconn_t *con) //true to kill con
if (con->NotifyFunction) if (con->NotifyFunction)
{ {
con->NotifyFunction(con->localfile, false); con->NotifyFunction(con->localfile, true);
con->NotifyFunction = NULL; con->NotifyFunction = NULL;
} }
@ -668,6 +676,24 @@ FTPclientconn_t *FTP_FindControl(void)
} }
return NULL; 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)) qboolean FTP_Client_Command (char *cmd, void (*NotifyFunction)(char *localfile, qboolean sucess))
{ {
char command[64]; 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)))) if ((cmd = COM_ParseOut(cmd, server, sizeof(server))))
Q_strncpyz(con->localfile, server, sizeof(con->localfile)); Q_strncpyz(con->localfile, server, sizeof(con->localfile));
FTP_FixupPath(con->file);
FTP_FixupPath(con->localfile);
return true; return true;
} }
else if (!stricmp(command, "quit")) else if (!stricmp(command, "quit"))