TransferSrv_2017/TransferSrv/TransferSrv.cpp

79 lines
1.5 KiB
C++

// TransferSrv.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "TransferSrv.h"
#include "sock_sv.h"
#include "AppClasSrv.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#include "PideFile.h"
#include "FileTransferFiller.h"
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
return nRetCode;
}
//AfxSocketInit();
if(argc==1)
{
//modo servidor
Csock_svThread sc;
sc.escucha = &App;
char ip[128];
int port;
FileTransferFiller::Get()->getConf(ip, &port);
if(sc.liseningThread(port,ip))
{
C_log::log("_tmain", "Servidor activo");
App.runApp();
}
}
else if(argc==7)
{
App.log.path[0]=0;
PideFile pf;
strcpy(pf.ip, argv[1]);
pf.puerto = atoi( argv[2]);
strcpy(pf.usu, argv[3]);
strcpy(pf.key, argv[4]);
strcpy(pf.orig, argv[5]);
strcpy(pf.dst, argv[6]);
pf.run();
system("pause");
}
else
{
_tprintf("argumentos no validos\n");
_tprintf("arg1 -> ip\n");
_tprintf("arg2 -> puerto\n");
_tprintf("arg3 -> usuario\n");
_tprintf("arg4 -> key\n");
_tprintf("arg5 -> path orig\n");
_tprintf("arg6 -> path dst\n");
system("pause");
}
return nRetCode;
}