Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FSDFtpC::getInstance().UploadFile("ftp.jqe360.com", 21, "updates@jqe360.com", "xbox360", "debug.log", "game:\\");
- above is call; below is function.
- void FSDFtpC::UploadFile(string host, int port, string username, string password, string filename, string path)
- {
- DebugMsg("FSDFtpC", "Starting process");
- netbuf *conn;
- XNDNS* m_pXNDns;
- HANDLE hEvent = CreateEvent(NULL, false, false, NULL);
- INT iErr = XNetDnsLookup(
- host.c_str(), // a string that prepresents the host name
- hEvent, // the event handle from the CreateEvent call
- &m_pXNDns); // the XNDNS structure to receive the IP info for the DNS entry found.
- while (m_pXNDns->iStatus == WSAEINPROGRESS)
- {
- WaitForSingleObject(hEvent, INFINITE);
- }
- CloseHandle(hEvent);
- if (m_pXNDns->cina != 0 && m_pXNDns->iStatus == 0)
- {
- char *buffer;
- XNetInAddrToString(m_pXNDns->aina[0], buffer, 32);
- //host = sprintfaA("%s", buffer);
- XNetDnsRelease(m_pXNDns);
- DebugMsg("FTPTest", "Connecting to %s", buffer);
- if (!FtpConnect(buffer,21, &conn))
- {
- DebugMsg("FTPTest", "Failed to open connection");
- return;
- }
- } else {
- DebugMsg("FTPTest", "Connecting to %s", host.c_str());
- if (!FtpConnect(host.c_str(),21, &conn))
- {
- DebugMsg("FTPTest", "Failed to open connection");
- return;
- }
- }
- DebugMsg("FTPTest", "Logining in");
- DebugMsg("FTPClient", "Username: %s, Password: %s", username.c_str(), password.c_str());
- if (!FtpLogin(username.c_str(), password.c_str(), conn))
- {
- DebugMsg("FTPTest", "Failed to login");
- FtpClose(conn);
- return;
- }
- string localfilename = path + filename;
- string remotefilename = sprintfaA("/%s", filename.c_str());
- if(!FtpPut(localfilename.c_str(), remotefilename.c_str(), FTPLIB_BINARY, conn))
- {
- DebugMsg("FTPTest", "Upload Failed");
- FtpClose(conn);
- return;
- }
- FtpClose(conn);
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement