From 19abe62f6d4939f3307cf53fa1a57266698bce32 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Mon, 6 Apr 2020 13:05:12 +0200 Subject: [PATCH] compilacion a v2017 partiendo de la v2008 --- .gitignore | 12 + FileTransfer/DescargadorFiles.cpp | 105 ++ FileTransfer/DescargadorFiles.h | 30 + FileTransfer/FileTransfer.cpp | 69 + FileTransfer/FileTransfer.def | 6 + FileTransfer/FileTransfer.h | 27 + FileTransfer/FileTransfer.rc | 140 ++ FileTransfer/FileTransfer.vcproj | 483 +++++ .../FileTransfer.vcproj.NELIAM.Elena.user | 121 ++ .../FileTransfer.vcproj.yandrak.Gerardo.user | 121 ++ FileTransfer/FileTransfer.vcxproj | 277 +++ FileTransfer/FileTransfer.vcxproj.filters | 74 + FileTransfer/FileTransfer.vcxproj.user | 4 + FileTransfer/FileTransferClient.cpp | 192 ++ FileTransfer/FileTransferClient.h | 29 + FileTransfer/FileTransferDef.h | 28 + FileTransfer/FileTransferManager.cpp | 233 +++ FileTransfer/FileTransferManager.h | 27 + FileTransfer/ReadMe.txt | 60 + FileTransfer/Resource.h | 17 + FileTransfer/res/FileTransfer.rc2 | 13 + FileTransfer/stdafx.cpp | 7 + FileTransfer/stdafx.h | 41 + FileTransfer/targetver.h | 26 + TransferSrv.sln | 42 + TransferSrv/AppClasSrv.cpp | 93 + TransferSrv/AppClasSrv.h | 38 + TransferSrv/CppSQLite3.cpp | 1591 +++++++++++++++++ TransferSrv/CppSQLite3.h | 325 ++++ TransferSrv/FileTransferFiller.cpp | 103 ++ TransferSrv/FileTransferFiller.h | 22 + TransferSrv/PideFile.cpp | 49 + TransferSrv/PideFile.h | 15 + TransferSrv/ReadMe.txt | 46 + TransferSrv/Resource.h | 17 + TransferSrv/TransferSrv.cpp | 78 + TransferSrv/TransferSrv.h | 3 + TransferSrv/TransferSrv.rc | 125 ++ TransferSrv/TransferSrv.vcproj | 455 +++++ .../TransferSrv.vcproj.NELIAM.Elena.user | 121 ++ .../TransferSrv.vcproj.yandrak.Gerardo.user | 121 ++ TransferSrv/TransferSrv.vcxproj | 240 +++ TransferSrv/TransferSrv.vcxproj.filters | 71 + TransferSrv/TransferSrv.vcxproj.user | 4 + TransferSrv/stdafx.cpp | 8 + TransferSrv/stdafx.h | 32 + TransferSrv/targetver.h | 24 + data/filetransfer.db | Bin 0 -> 20480 bytes 48 files changed, 5765 insertions(+) create mode 100644 .gitignore create mode 100644 FileTransfer/DescargadorFiles.cpp create mode 100644 FileTransfer/DescargadorFiles.h create mode 100644 FileTransfer/FileTransfer.cpp create mode 100644 FileTransfer/FileTransfer.def create mode 100644 FileTransfer/FileTransfer.h create mode 100644 FileTransfer/FileTransfer.rc create mode 100644 FileTransfer/FileTransfer.vcproj create mode 100644 FileTransfer/FileTransfer.vcproj.NELIAM.Elena.user create mode 100644 FileTransfer/FileTransfer.vcproj.yandrak.Gerardo.user create mode 100644 FileTransfer/FileTransfer.vcxproj create mode 100644 FileTransfer/FileTransfer.vcxproj.filters create mode 100644 FileTransfer/FileTransfer.vcxproj.user create mode 100644 FileTransfer/FileTransferClient.cpp create mode 100644 FileTransfer/FileTransferClient.h create mode 100644 FileTransfer/FileTransferDef.h create mode 100644 FileTransfer/FileTransferManager.cpp create mode 100644 FileTransfer/FileTransferManager.h create mode 100644 FileTransfer/ReadMe.txt create mode 100644 FileTransfer/Resource.h create mode 100644 FileTransfer/res/FileTransfer.rc2 create mode 100644 FileTransfer/stdafx.cpp create mode 100644 FileTransfer/stdafx.h create mode 100644 FileTransfer/targetver.h create mode 100644 TransferSrv.sln create mode 100644 TransferSrv/AppClasSrv.cpp create mode 100644 TransferSrv/AppClasSrv.h create mode 100644 TransferSrv/CppSQLite3.cpp create mode 100644 TransferSrv/CppSQLite3.h create mode 100644 TransferSrv/FileTransferFiller.cpp create mode 100644 TransferSrv/FileTransferFiller.h create mode 100644 TransferSrv/PideFile.cpp create mode 100644 TransferSrv/PideFile.h create mode 100644 TransferSrv/ReadMe.txt create mode 100644 TransferSrv/Resource.h create mode 100644 TransferSrv/TransferSrv.cpp create mode 100644 TransferSrv/TransferSrv.h create mode 100644 TransferSrv/TransferSrv.rc create mode 100644 TransferSrv/TransferSrv.vcproj create mode 100644 TransferSrv/TransferSrv.vcproj.NELIAM.Elena.user create mode 100644 TransferSrv/TransferSrv.vcproj.yandrak.Gerardo.user create mode 100644 TransferSrv/TransferSrv.vcxproj create mode 100644 TransferSrv/TransferSrv.vcxproj.filters create mode 100644 TransferSrv/TransferSrv.vcxproj.user create mode 100644 TransferSrv/stdafx.cpp create mode 100644 TransferSrv/stdafx.h create mode 100644 TransferSrv/targetver.h create mode 100644 data/filetransfer.db diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0f1adff --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +/Debug/* +/FileTransfer/Debug/* +/TransferSrv/Debug/* +/TransferSrv.ncb +/TransferSrv.suo +/FileTransfer/x64/* +/FileTransfer/Release/* +/TransferSrv/Release/* +/TransferSrv/x64/* +/FileTransfer/)x64/* +/FileTransfer/FileTransfer.aps +/TransferSrv/TransferSrv.aps diff --git a/FileTransfer/DescargadorFiles.cpp b/FileTransfer/DescargadorFiles.cpp new file mode 100644 index 0000000..80cb31f --- /dev/null +++ b/FileTransfer/DescargadorFiles.cpp @@ -0,0 +1,105 @@ +#include "StdAfx.h" +#include "DescargadorFiles.h" +#include "_log.h" +#include "dir_manager.h" + +DescargadorFiles::DescargadorFiles(void) +{ + errorMsg[0]=dirDest[0]=srv[0]=key[0]=usu[0]=0; + porcen =0; + puerto =0; + cancela =false; +} + + +DescargadorFiles::~DescargadorFiles(void) +{ + cancela = true; +} + +void DescargadorFiles::run() +{ + FileTransferClient ft; + char orig[256], dst[256]; + Sleep(100); + ft.setLisener(this); + if(!ft.conecta(srv,puerto)) + { + if(lisener) + lisener->finTransfer(false); + C_log::log("PideFile", "Error al conectar a: %s:%ld",srv, puerto); + return; + } + + if(!ft.Presenta(usu, key)) + { + if(lisener) + lisener->finTransfer(false); + C_log::log("PideFile", "Error al presentarse a: %s" ,usu); + return; + } + double porcenFile = 100./files->n_i; + for (int i =0; i< files->n_i && !cancela; i++) + { + porcen = i/porcenFile; + sprintf(dst, "%s%s",dirDest,Cdir_manager::nombre_archivo(files->get(i),orig)); + if(!ft.DescargaFile(files->get(i), dst)) + { + if(lisener) + lisener->finTransfer(false); + C_log::log("PideFile", "Error al descargar orig: %s dest%ld",files->get(i), dst); + return; + } + + } + + if(!ft.desconecta()) + { + C_log::log("PideFile", "Error al desconectar a: %s:%ld",srv, puerto); + + } + else + { + if(lisener) + lisener->finTransfer(true); + C_log::log("PideFile", "final Feliz"); + return; + } +} + +void DescargadorFiles::setServer( char* ip, int puerto, char *key, char* usu ) +{ + strcpy(srv, ip); + strcpy(this->key, key); + strcpy(this->usu, usu); + + this->puerto = puerto; + +} + +bool DescargadorFiles::iniciaDescarga( StrArray *filesOrig,char *dirDest, FileTransferClientLisener *lisener ) +{ + strcpy(this->dirDest, dirDest); + this->lisener = lisener; + files = filesOrig; + porcen =0; + cancela = false; + return lanza() == TRUE; +} + +void DescargadorFiles::cancelaDesc() +{ + cancela= true; + join(); +} + +void DescargadorFiles::setStatus( double porcent ) +{ + if(lisener) + lisener->setStatus(porcent+this->porcen); +} + +void DescargadorFiles::finTransfer( bool finalFeliz ) +{ + +} diff --git a/FileTransfer/DescargadorFiles.h b/FileTransfer/DescargadorFiles.h new file mode 100644 index 0000000..39ce6d3 --- /dev/null +++ b/FileTransfer/DescargadorFiles.h @@ -0,0 +1,30 @@ +#pragma once +#include "th.h" +#include "StrArray.h" +#include "FileTransferClient.h" +class FileTransferClient; + +class FT_EXPORT DescargadorFiles: public Cth, public FileTransferClientLisener +{ + double porcen;//muestra el porcentaje de descargas + char errorMsg[512]; + StrArray *files; + char dirDest[256]; + char srv[256]; + int puerto; + char key[32]; + char usu[32]; + bool cancela; + FileTransferClientLisener *lisener; +public: + DescargadorFiles(void); + ~DescargadorFiles(void); + void setServer(char* ip, int puerto, char *key, char* usu); + bool iniciaDescarga(StrArray *filesOrig,char *dirDest,FileTransferClientLisener *lisener = NULL); + void cancelaDesc(); + virtual void run(); + + virtual void setStatus( double porcent ); + virtual void finTransfer( bool finalFeliz ); + +}; diff --git a/FileTransfer/FileTransfer.cpp b/FileTransfer/FileTransfer.cpp new file mode 100644 index 0000000..9134756 --- /dev/null +++ b/FileTransfer/FileTransfer.cpp @@ -0,0 +1,69 @@ +// FileTransfer.cpp : Defines the initialization routines for the DLL. +// + +#include "stdafx.h" +#include "FileTransfer.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// +//TODO: If this DLL is dynamically linked against the MFC DLLs, +// any functions exported from this DLL which call into +// MFC must have the AFX_MANAGE_STATE macro added at the +// very beginning of the function. +// +// For example: +// +// extern "C" BOOL PASCAL EXPORT ExportedFunction() +// { +// AFX_MANAGE_STATE(AfxGetStaticModuleState()); +// // normal function body here +// } +// +// It is very important that this macro appear in each +// function, prior to any calls into MFC. This means that +// it must appear as the first statement within the +// function, even before any object variable declarations +// as their constructors may generate calls into the MFC +// DLL. +// +// Please see MFC Technical Notes 33 and 58 for additional +// details. +// + +// CFileTransferApp + +BEGIN_MESSAGE_MAP(CFileTransferApp, CWinApp) +END_MESSAGE_MAP() + + +// CFileTransferApp construction + +CFileTransferApp::CFileTransferApp() +{ + // TODO: add construction code here, + // Place all significant initialization in InitInstance +} + + +// The one and only CFileTransferApp object + +CFileTransferApp theApp; + + +// CFileTransferApp initialization + +BOOL CFileTransferApp::InitInstance() +{ + CWinApp::InitInstance(); + + if (!AfxSocketInit()) + { + AfxMessageBox(IDP_SOCKETS_INIT_FAILED); + return FALSE; + } + + return TRUE; +} diff --git a/FileTransfer/FileTransfer.def b/FileTransfer/FileTransfer.def new file mode 100644 index 0000000..ea9cf52 --- /dev/null +++ b/FileTransfer/FileTransfer.def @@ -0,0 +1,6 @@ +; FileTransfer.def : Declares the module parameters for the DLL. + +LIBRARY "FileTransfer" + +EXPORTS + ; Explicit exports can go here diff --git a/FileTransfer/FileTransfer.h b/FileTransfer/FileTransfer.h new file mode 100644 index 0000000..9218165 --- /dev/null +++ b/FileTransfer/FileTransfer.h @@ -0,0 +1,27 @@ +// FileTransfer.h : main header file for the FileTransfer DLL +// + +#pragma once + +#ifndef __AFXWIN_H__ + #error "include 'stdafx.h' before including this file for PCH" +#endif + +#include "resource.h" // main symbols + + +// CFileTransferApp +// See FileTransfer.cpp for the implementation of this class +// + +class CFileTransferApp : public CWinApp +{ +public: + CFileTransferApp(); + +// Overrides +public: + virtual BOOL InitInstance(); + + DECLARE_MESSAGE_MAP() +}; diff --git a/FileTransfer/FileTransfer.rc b/FileTransfer/FileTransfer.rc new file mode 100644 index 0000000..7a0634c --- /dev/null +++ b/FileTransfer/FileTransfer.rc @@ -0,0 +1,140 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#ifndef APSTUDIO_INVOKED +#include "targetver.h" +#endif +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "Narvaling" + VALUE "FileDescription", "Librería para transferencia de archivos" + VALUE "FileVersion", "1.0.0.1" + VALUE "InternalName", "FileTransfer.dll" + VALUE "LegalCopyright", "(c) Narvaling All rights reserved." + VALUE "OriginalFilename", "FileTransfer.dll" + VALUE "ProductName", "FileTransfer" + VALUE "ProductVersion", "1.0.0.1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// Spanish resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ESN) +#ifdef _WIN32 +LANGUAGE LANG_SPANISH, SUBLANG_SPANISH_MODERN +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#ifndef APSTUDIO_INVOKED\r\n" + "#include ""targetver.h""\r\n" + "#endif\r\n" + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" + "LANGUAGE 9, 1\r\n" + "#pragma code_page(1252)\r\n" + "#include ""res\\FileTransfer.rc2"" // non-Microsoft Visual C++ edited resources\r\n" + "#include ""afxres.rc"" // Standard components\r\n" + "#endif\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // Spanish resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE 9, 1 +#pragma code_page(1252) +#include "res\FileTransfer.rc2" // non-Microsoft Visual C++ edited resources +#include "afxres.rc" // Standard components +#endif + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/FileTransfer/FileTransfer.vcproj b/FileTransfer/FileTransfer.vcproj new file mode 100644 index 0000000..a34c291 --- /dev/null +++ b/FileTransfer/FileTransfer.vcproj @@ -0,0 +1,483 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FileTransfer/FileTransfer.vcproj.NELIAM.Elena.user b/FileTransfer/FileTransfer.vcproj.NELIAM.Elena.user new file mode 100644 index 0000000..c756d5e --- /dev/null +++ b/FileTransfer/FileTransfer.vcproj.NELIAM.Elena.user @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + diff --git a/FileTransfer/FileTransfer.vcproj.yandrak.Gerardo.user b/FileTransfer/FileTransfer.vcproj.yandrak.Gerardo.user new file mode 100644 index 0000000..2d1426a --- /dev/null +++ b/FileTransfer/FileTransfer.vcproj.yandrak.Gerardo.user @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + diff --git a/FileTransfer/FileTransfer.vcxproj b/FileTransfer/FileTransfer.vcxproj new file mode 100644 index 0000000..bf02173 --- /dev/null +++ b/FileTransfer/FileTransfer.vcxproj @@ -0,0 +1,277 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {149E3D49-90F8-44E6-A4F9-BDEE84F65A70} + FileTransfer + MFCDLLProj + + + + DynamicLibrary + v141 + Dynamic + Unicode + true + + + DynamicLibrary + v141 + Dynamic + Unicode + + + DynamicLibrary + v141 + Dynamic + MultiByte + true + + + DynamicLibrary + v141 + Dynamic + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>15.0.28127.55 + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + true + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + false + + + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + + + + _DEBUG;%(PreprocessorDefinitions) + false + + + Disabled + ..\..\utiles;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + Level3 + EditAndContinue + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + $(IntDir);%(AdditionalIncludeDirectories) + + + utiles.lib;%(AdditionalDependencies) + ..\..\..\lib\$(Configuration);%(AdditionalLibraryDirectories) + .\FileTransfer.def + true + Windows + MachineX86 + + + copy $(OutDir)$(TargetFileName) ..\..\bin\$(IntDir) +copy $(OutDir)FileTransfer.lib ..\..\lib\$(IntDir) + + + + + + _DEBUG;%(PreprocessorDefinitions) + false + X64 + + + Disabled + ..\..\utiles;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + Level3 + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + $(IntDir);%(AdditionalIncludeDirectories) + + + utiles.lib;%(AdditionalDependencies) + ..\..\..\lib\x64\$(Configuration);%(AdditionalLibraryDirectories) + .\FileTransfer.def + true + Windows + MachineX64 + + + copy $(OutDir)$(TargetFileName) ..\..\bin\$(IntDir) +copy $(OutDir)FileTransfer.lib ..\..\lib\$(IntDir) + + + + + + NDEBUG;%(PreprocessorDefinitions) + false + + + MaxSpeed + true + ..\..\utiles;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Use + Level3 + ProgramDatabase + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + $(IntDir);%(AdditionalIncludeDirectories) + + + utiles.lib;%(AdditionalDependencies) + ..\..\..\lib\$(Configuration);%(AdditionalLibraryDirectories) + .\FileTransfer.def + true + Windows + true + true + MachineX86 + + + copy $(OutDir)$(TargetFileName) ..\..\bin\$(IntDir) +copy $(OutDir)FileTransfer.lib ..\..\lib\$(IntDir) + + + + + + NDEBUG;%(PreprocessorDefinitions) + false + X64 + + + MaxSpeed + true + ..\..\utiles;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Use + Level3 + ProgramDatabase + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + $(IntDir);%(AdditionalIncludeDirectories) + + + utiles.lib;%(AdditionalDependencies) + ..\..\..\lib\x64\$(Configuration);%(AdditionalLibraryDirectories) + .\FileTransfer.def + true + Windows + true + true + MachineX64 + + + copy $(OutDir)$(TargetFileName) ..\..\bin\$(IntDir) +copy $(OutDir)FileTransfer.lib ..\..\lib\$(IntDir) + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + + {aa58c828-7025-4a4c-868e-76b8902af6bb} + false + + + + + + \ No newline at end of file diff --git a/FileTransfer/FileTransfer.vcxproj.filters b/FileTransfer/FileTransfer.vcxproj.filters new file mode 100644 index 0000000..68cbe70 --- /dev/null +++ b/FileTransfer/FileTransfer.vcxproj.filters @@ -0,0 +1,74 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Source Files + + + Resource Files + + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/FileTransfer/FileTransfer.vcxproj.user b/FileTransfer/FileTransfer.vcxproj.user new file mode 100644 index 0000000..be25078 --- /dev/null +++ b/FileTransfer/FileTransfer.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/FileTransfer/FileTransferClient.cpp b/FileTransfer/FileTransferClient.cpp new file mode 100644 index 0000000..fc5642d --- /dev/null +++ b/FileTransfer/FileTransferClient.cpp @@ -0,0 +1,192 @@ +#include "StdAfx.h" +#include "FileTransferClient.h" +#include "Csock_cl.h" +//*********************************************************************************** +FileTransferClient::FileTransferClient(void) +{ + sc = NULL; + lisener =0; +} +//*********************************************************************************** + +FileTransferClient::~FileTransferClient(void) +{ + if(sc) + delete sc; +} +//*********************************************************************************** + +bool FileTransferClient::conecta( char* ip, int puerto ) +{ + if(sc) + delete sc; + sc = new Csock_cl(); + if( sc->conectar(ip,puerto)) + return false; + return enviaOk(); +} +//*********************************************************************************** + +bool FileTransferClient::Presenta( char *user, char *key ) +{ + if(!sc) + return false; + int *id; + id =(int*)buff; + Usuario_conx_0 *usu = (Usuario_conx_0*)&((int*)buff)[1]; + strcpy(usu->nombre,user); + strcpy(usu->clave,key); + + *id=PETICION_GENERAL_PRESENTA; + if(!sc->envia_package((BYTE*)buff, sizeof(int)+ sizeof(Usuario_conx_0))) + return false; + int nv =10; + + while(!sc->recibe_package(0)) + { + nv--; + if(nv<0) + return false; + } + + return (*(int*)sc->buf)== PETICION_GENERAL_OK; +} +//*********************************************************************************** + +bool FileTransferClient::DescargaFile( char *pathOrig, char *pathDest ) +{ + porcentOld =0; + if(lisener) + lisener->setStatus(0); + if(!sc) + { + if(lisener) + lisener->finTransfer(false); + return false; + } + int *id; + id =(int*)buff; + char *str = (char*)&((int*)buff)[1]; + if(!sc) + { + if(lisener) + lisener->finTransfer(false); + return false; + } + if(!dt.setData(sc,&f) || !dt.setMode(DataTransfer::MODE_RECEIVE)) + { + if(lisener) + lisener->finTransfer(false); + return false; + } + if(!f.abre(pathDest,2,TRUE)) + { + if(lisener) + lisener->finTransfer(false); + return false; + } + strcpy(str,pathOrig); + *id = PETICION_GENERAL_OK; + if(!sc->envia_package((BYTE*)buff, sizeof(int)+ 256)) + { + if(lisener) + lisener->finTransfer(false); + return false; + } + + if(!sc->recibe_package(0)) + { + if(lisener) + lisener->finTransfer(false); + return false; + } + if(sc->nbbuf)!= PETICION_GENERAL_OK) + { + if(lisener) + lisener->finTransfer(false); + return false; + } + if(!dt.start()) + { + if(lisener) + lisener->finTransfer(false); + return false; + } + while(dt.currando()) + { + if(lisener) + { + if(lisener->cancelTransfer()) + { + dt.cancel(); + continue; + } + + double status= dt.getStatus(); + //C_log::log("FileTransferClient","Porcent: %lf" status); + if(porcentOldsetStatus(porcentOld); + } + } + + Sleep(10); + } + if(lisener) + lisener->finTransfer(!dt.isCanceled()); + + return !dt.isCanceled(); +} +//*********************************************************************************** + +bool FileTransferClient::DescargaDir( char *dirOrig, char *dirDest ) +{ + if(!sc) + return false; + return false; +} +//*********************************************************************************** + +bool FileTransferClient::desconecta() +{ + if(!sc) + return false; + int *id =(int*)buff; + *id = PETICION_GENERAL_FIN; + if(!sc->envia_package((BYTE*)buff, sizeof(int))) + return false; + + delete sc; + sc = NULL; + return true; +} +//*********************************************************************************** + +bool FileTransferClient::enviaOk() +{ + if(!sc) + return false; + int *id =(int*)buff; + *id = PETICION_GENERAL_NO; + if(!sc->envia_package((BYTE*)buff, sizeof(int))) + return false; + if(!sc->recibe_package(0)) + return false; + return sc->nb==sizeof(int) &&(*(int*)sc->buf)== PETICION_GENERAL_OK; +} +//*********************************************************************************** +double FileTransferClient::getPorcen() +{ + if(dt.isCanceled() || !dt.currando()) + return 100.; + return dt.getStatus(); + +} +//*********************************************************************************** +void FileTransferClient::setLisener( FileTransferClientLisener*lis ) +{ + lisener = lis; +} +//*********************************************************************************** + diff --git a/FileTransfer/FileTransferClient.h b/FileTransfer/FileTransferClient.h new file mode 100644 index 0000000..a80522a --- /dev/null +++ b/FileTransfer/FileTransferClient.h @@ -0,0 +1,29 @@ +#pragma once +#ifndef FileTransferClient_H +#define FileTransferClient_H +#include "FileTransferDef.h" +#include "DataTransfer.h" +class Csock_cl; + +//clase cliente de descarga de archivos +class FT_EXPORT FileTransferClient +{ + Csock_cl *sc; + Cb_file f; + DataTransfer dt; + char buff[sizeof(int)+ sizeof(Usuario_conx_0)+256]; + double porcentOld; + FileTransferClientLisener *lisener; +public: + FileTransferClient(void); + ~FileTransferClient(void); + bool conecta(char* ip, int puerto); + bool Presenta(char *user, char *key); + void setLisener(FileTransferClientLisener*lis); + bool DescargaFile(char *pathOrig, char *pathDest); + bool DescargaDir(char *dirOrig, char *dirDest); + bool desconecta(); + bool enviaOk(); + double getPorcen(); +}; +#endif \ No newline at end of file diff --git a/FileTransfer/FileTransferDef.h b/FileTransfer/FileTransferDef.h new file mode 100644 index 0000000..7b79ff8 --- /dev/null +++ b/FileTransfer/FileTransferDef.h @@ -0,0 +1,28 @@ +#ifndef FT_EXPORT +#ifdef _WINDLL +#define FT_EXPORT __declspec(dllexport) +#else +#define FT_EXPORT __declspec(dllimport) +#endif +struct Usuario_conx_0; +class FT_EXPORT IDataUserProvider +{ +public: + virtual bool fill(Usuario_conx_0 *user, char *pathRaid) = 0; + virtual bool getConf(char *ip, int *port) = 0; + + +}; + +#define FILE_TRANSMISION_GET_FILES 7 +#define FILE_TRANSMISION_GET_DIRS 8 + +class FT_EXPORT FileTransferClientLisener +{ +public: + virtual void setStatus(double porcent){}; + virtual void finTransfer(bool finalFeliz){}; + virtual bool cancelTransfer(){ return false;}; + +}; +#endif diff --git a/FileTransfer/FileTransferManager.cpp b/FileTransfer/FileTransferManager.cpp new file mode 100644 index 0000000..45b6fa4 --- /dev/null +++ b/FileTransfer/FileTransferManager.cpp @@ -0,0 +1,233 @@ +#include "StdAfx.h" +#include "FileTransferManager.h" +#include "DataTransfer.h" + +#include "_log.h" +#include "proceso_cliente.h" +#include "sock_sv.h" +#include "dir_manager.h" +#include "StrArray.h" + +#define MODULO "ProcClient" +//***************************************************************************** +FileTransferManager::FileTransferManager(void) +{ + pirate = false; + dirRaid[0]=0; +} +//***************************************************************************** +FileTransferManager::~FileTransferManager(void) +{ +} +//***************************************************************************** +bool FileTransferManager::envia(int id) +{ + return soc->envia_package((BYTE*)&id, sizeof(id)) == TRUE; +} +//***************************************************************************** +bool FileTransferManager::envia(void *buf, int siz) +{ + return soc->envia_package((BYTE*)buf, siz) == TRUE; +} +//***************************************************************************** +void FileTransferManager::run() +{ + DataTransfer dt; + Cb_file f; + char str[512]; + int nr=0; + int nraid=0; + void *buf; + StrArray files,dirs; + C_log::log(MODULO, "Iniciada Conexion"); + if(!dt.setData(soc,&f) || !dt.setMode(DataTransfer::MODE_SEND)) + { + C_log::log(MODULO, "error al iniciar buffers de transmision"); + pirate =true; + } + while(!pirate && !*soc->pirate) + { + if(exSal && *exSal) + { + C_log::log(MODULO, "Sale por desconexion del socket"); + pirate =true; + continue; + } + if(!soc->recibe_package(0)) + { + nr++; + if(nr>1000) + { + pirate = true; + C_log::log(MODULO, "Sobrepasado tiempo de espera."); + } + else + Sleep(1); + continue; + } + nr =0; + //recive package------------- + if(soc->nbbuf; + int nb =soc->nb-(sizeof(int)); + buf = &((int*)soc->buf)[1]; + switch(idp) + { + + case(PETICION_GENERAL_PRESENTA): + //pilla usuario, pilla key + if(nb!= sizeof(usu)) + { + C_log::log(MODULO, "Paquete de presentacion defectuoso"); + pirate = true; + break; + } + memcpy(&usu, buf,sizeof(usu)); + usu.nombre[31] = 0; + usu.clave[31] = 0; + char claveUser[32]; + memcpy(claveUser, usu.clave,32); + nraid = 0; + dirRaid[0]=0; + if(duProv) + { + if(!duProv->fill(&usu, dirRaid)) + { + envia(PETICION_GENERAL_NO); + C_log::log(MODULO, "Error al pillar datos de usuario: %s",usu.nombre); + pirate = true; + } + } + nraid = strlen(dirRaid); + if(strcmp(usu.clave, claveUser)) + { + envia(PETICION_GENERAL_NO); + C_log::log(MODULO, "Error clave de usuario incorrecta usuario: %s key: %s",usu.nombre, claveUser); + pirate = true; + } + C_log::log(MODULO, "Presentado usuario %s",usu.nombre); + if(!envia(PETICION_GENERAL_OK)) + { + C_log::log(MODULO, "Error al enviar ok en presentacion"); + pirate = true; + } + break; + case(PETICION_GENERAL_OK)://envia descargar archivo + //pilla path + if(nb!= 256) + { + C_log::log(MODULO, "Paquete ok defectuoso"); + pirate = true; + break; + } + memcpy(str,dirRaid,nraid); + memcpy(&str[nraid], buf, 256); + str[255]=0; + C_log::log(MODULO, "Peticion de descarga de archivo %s", str); + if(!f.abre(str,1,FALSE,TRUE)) + { + if(!envia(PETICION_GENERAL_NO)) + { + C_log::log(MODULO, "Error al enviar no en descarga"); + pirate = true; + } + break; + } + if(!envia(PETICION_GENERAL_OK)) + { + C_log::log(MODULO, "Error al enviar no en descarga"); + pirate = true; + break; + } + if(!dt.start()) + { + C_log::log(MODULO, "Error al iniciar descarga"); + pirate = true; + break; + } + while(dt.currando()) + Sleep(10); + if(dt.isCanceled()) + { + C_log::log(MODULO, "Error al descargar archivo"); + pirate = true; + break; + } + C_log::log(MODULO, "Descarga archivo Exitosa"); + break; + case(PETICION_GENERAL_NO): + if(!envia(PETICION_GENERAL_OK)) + { + C_log::log(MODULO, "Error al enviar no"); + pirate = true; + } + break; + case(PETICION_GENERAL_FIN): + C_log::log(MODULO, "Recibida desconexion"); + pirate = true; + break; + case(FILE_TRANSMISION_GET_FILES): + C_log::log(MODULO, "Recibida peticion de getFiles"); + //pilla path + if(nb!= 256) + { + C_log::log(MODULO, "Paquete ok defectuoso"); + pirate = true; + break; + } + memcpy(str,dirRaid,nraid); + memcpy(&str[nraid], buf, 256); + str[255]=0; + if(!Cdir_manager::listar_elementos(str, &files, &dirs)) + { + if(!envia(PETICION_GENERAL_NO)) + { + C_log::log(MODULO, "Error al enviar no"); + pirate = true; + } + break; + + } + if(!envia(PETICION_GENERAL_OK)) + { + C_log::log(MODULO, "Error al enviar ok"); + pirate = true; + } + if(!envia(files.n_i)) + { + C_log::log(MODULO, "Error al enviar strArray"); + pirate = true; + } + if(!envia(files.str, files.n_str)) + { + C_log::log(MODULO, "Error al enviar strArray"); + pirate = true; + } + if(!envia(dirs.n_i)) + { + C_log::log(MODULO, "Error al enviar strArray"); + pirate = true; + } + if(!envia(dirs.str, dirs.n_str)) + { + C_log::log(MODULO, "Error al enviar strArray"); + pirate = true; + } + + break; + default: + C_log::log(MODULO, "Id cab no reconocido"); + pirate = true; + break; + } + + } + C_log::log(MODULO, "Se desconecta proceso"); +} + +//***************************************************************************** \ No newline at end of file diff --git a/FileTransfer/FileTransferManager.h b/FileTransfer/FileTransferManager.h new file mode 100644 index 0000000..3cd0b0e --- /dev/null +++ b/FileTransfer/FileTransferManager.h @@ -0,0 +1,27 @@ +#pragma once +#ifndef FileTransferManager_H +#define FileTransferManager_H + +#include "proceso_cliente.h" +#include "utiles_def.h" +#include "FileTransferDef.h" +#include "proceso_cliente.h" +//clase servidor de descarga de archivos +class FT_EXPORT FileTransferManager: + public Cproceso_cliente +{ +public: + FileTransferManager(void); + ~FileTransferManager(void); + + Usuario_conx_0 usu;//usuario conectado + IDataUserProvider *duProv; + char dirRaid[MAX_PATH]; + bool pirate; + BOOL *exSal; + virtual void run();//funcion que hace el thread +private: + bool envia(int id); + bool envia(void *buf, int siz); +}; +#endif \ No newline at end of file diff --git a/FileTransfer/ReadMe.txt b/FileTransfer/ReadMe.txt new file mode 100644 index 0000000..090c5fe --- /dev/null +++ b/FileTransfer/ReadMe.txt @@ -0,0 +1,60 @@ +======================================================================== + MICROSOFT FOUNDATION CLASS LIBRARY : FileTransfer Project Overview +======================================================================== + + +AppWizard has created this FileTransfer DLL for you. This DLL not only +demonstrates the basics of using the Microsoft Foundation classes but +is also a starting point for writing your DLL. + +This file contains a summary of what you will find in each of the files that +make up your FileTransfer DLL. + +FileTransfer.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +FileTransfer.h + This is the main header file for the DLL. It declares the + CFileTransferApp class. + +FileTransfer.cpp + This is the main DLL source file. It contains the class CFileTransferApp. + +FileTransfer.rc + This is a listing of all of the Microsoft Windows resources that the + program uses. It includes the icons, bitmaps, and cursors that are stored + in the RES subdirectory. This file can be directly edited in Microsoft + Visual C++. + +res\FileTransfer.rc2 + This file contains resources that are not edited by Microsoft + Visual C++. You should place all resources not editable by + the resource editor in this file. + +FileTransfer.def + This file contains information about the DLL that must be + provided to run with Microsoft Windows. It defines parameters + such as the name and description of the DLL. It also exports + functions from the DLL. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named FileTransfer.pch and a precompiled types file named StdAfx.obj. + +Resource.h + This is the standard header file, which defines new resource IDs. + Microsoft Visual C++ reads and updates this file. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" to indicate parts of the source code you +should add to or customize. + +///////////////////////////////////////////////////////////////////////////// diff --git a/FileTransfer/Resource.h b/FileTransfer/Resource.h new file mode 100644 index 0000000..4f597c8 --- /dev/null +++ b/FileTransfer/Resource.h @@ -0,0 +1,17 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by FileTransfer.rc +// +#define IDP_SOCKETS_INIT_FAILED 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS + +#define _APS_NEXT_RESOURCE_VALUE 2000 +#define _APS_NEXT_CONTROL_VALUE 2000 +#define _APS_NEXT_SYMED_VALUE 2000 +#define _APS_NEXT_COMMAND_VALUE 32771 +#endif +#endif diff --git a/FileTransfer/res/FileTransfer.rc2 b/FileTransfer/res/FileTransfer.rc2 new file mode 100644 index 0000000..b448513 --- /dev/null +++ b/FileTransfer/res/FileTransfer.rc2 @@ -0,0 +1,13 @@ +// +// FileTransfer.RC2 - resources Microsoft Visual C++ does not edit directly +// + +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// Add manually edited resources here... + +///////////////////////////////////////////////////////////////////////////// diff --git a/FileTransfer/stdafx.cpp b/FileTransfer/stdafx.cpp new file mode 100644 index 0000000..950aa25 --- /dev/null +++ b/FileTransfer/stdafx.cpp @@ -0,0 +1,7 @@ +// stdafx.cpp : source file that includes just the standard includes +// FileTransfer.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + diff --git a/FileTransfer/stdafx.h b/FileTransfer/stdafx.h new file mode 100644 index 0000000..37f7fa5 --- /dev/null +++ b/FileTransfer/stdafx.h @@ -0,0 +1,41 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently + +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#endif + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit + +#include // MFC core and standard components +#include // MFC extensions + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC OLE classes +#include // MFC OLE dialog classes +#include // MFC Automation classes +#endif // _AFX_NO_OLE_SUPPORT + +#ifndef _AFX_NO_DB_SUPPORT +#include // MFC ODBC database classes +#endif // _AFX_NO_DB_SUPPORT + +#ifndef _AFX_NO_DAO_SUPPORT +#include // MFC DAO database classes +#endif // _AFX_NO_DAO_SUPPORT + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC support for Internet Explorer 4 Common Controls +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // MFC socket extensions + +#include "FileTransferManager.h" \ No newline at end of file diff --git a/FileTransfer/targetver.h b/FileTransfer/targetver.h new file mode 100644 index 0000000..11730d5 --- /dev/null +++ b/FileTransfer/targetver.h @@ -0,0 +1,26 @@ + +#pragma once + +// The following macros define the minimum required platform. The minimum required platform +// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run +// your application. The macros work by enabling all features available on platform versions up to and +// including the version specified. + +// Modify the following defines if you have to target a platform prior to the ones specified below. +// Refer to MSDN for the latest info on corresponding values for different platforms. +#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. +#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. +#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. +#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. +#endif + +#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. +#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. +#endif + diff --git a/TransferSrv.sln b/TransferSrv.sln new file mode 100644 index 0000000..7cf8402 --- /dev/null +++ b/TransferSrv.sln @@ -0,0 +1,42 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TransferSrv", "TransferSrv\TransferSrv.vcproj", "{30C05365-2DFC-4AD4-905E-8A414AE0D0A0}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "utiles", "..\Utiles\utiles.vcproj", "{AA58C828-7025-4A4C-868E-76B8902AF6BB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FileTransfer", "FileTransfer\FileTransfer.vcproj", "{149E3D49-90F8-44E6-A4F9-BDEE84F65A70}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {30C05365-2DFC-4AD4-905E-8A414AE0D0A0}.Debug|Win32.ActiveCfg = Debug|Win32 + {30C05365-2DFC-4AD4-905E-8A414AE0D0A0}.Debug|Win32.Build.0 = Debug|Win32 + {30C05365-2DFC-4AD4-905E-8A414AE0D0A0}.Debug|x64.ActiveCfg = Debug|Win32 + {30C05365-2DFC-4AD4-905E-8A414AE0D0A0}.Release|Win32.ActiveCfg = Release|Win32 + {30C05365-2DFC-4AD4-905E-8A414AE0D0A0}.Release|Win32.Build.0 = Release|Win32 + {30C05365-2DFC-4AD4-905E-8A414AE0D0A0}.Release|x64.ActiveCfg = Release|Win32 + {AA58C828-7025-4A4C-868E-76B8902AF6BB}.Debug|Win32.ActiveCfg = Debug|Win32 + {AA58C828-7025-4A4C-868E-76B8902AF6BB}.Debug|Win32.Build.0 = Debug|Win32 + {AA58C828-7025-4A4C-868E-76B8902AF6BB}.Debug|x64.ActiveCfg = Debug|x64 + {AA58C828-7025-4A4C-868E-76B8902AF6BB}.Debug|x64.Build.0 = Debug|x64 + {AA58C828-7025-4A4C-868E-76B8902AF6BB}.Release|Win32.ActiveCfg = Release|Win32 + {AA58C828-7025-4A4C-868E-76B8902AF6BB}.Release|Win32.Build.0 = Release|Win32 + {AA58C828-7025-4A4C-868E-76B8902AF6BB}.Release|x64.ActiveCfg = Release|x64 + {AA58C828-7025-4A4C-868E-76B8902AF6BB}.Release|x64.Build.0 = Release|x64 + {149E3D49-90F8-44E6-A4F9-BDEE84F65A70}.Debug|Win32.ActiveCfg = Debug|Win32 + {149E3D49-90F8-44E6-A4F9-BDEE84F65A70}.Debug|Win32.Build.0 = Debug|Win32 + {149E3D49-90F8-44E6-A4F9-BDEE84F65A70}.Debug|x64.ActiveCfg = Debug|Win32 + {149E3D49-90F8-44E6-A4F9-BDEE84F65A70}.Release|Win32.ActiveCfg = Release|Win32 + {149E3D49-90F8-44E6-A4F9-BDEE84F65A70}.Release|Win32.Build.0 = Release|Win32 + {149E3D49-90F8-44E6-A4F9-BDEE84F65A70}.Release|x64.ActiveCfg = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/TransferSrv/AppClasSrv.cpp b/TransferSrv/AppClasSrv.cpp new file mode 100644 index 0000000..c3ca37f --- /dev/null +++ b/TransferSrv/AppClasSrv.cpp @@ -0,0 +1,93 @@ +#include "StdAfx.h" +#include "AppClasSrv.h" +#include "FileTransferManager.h" +#include "FileTransferFiller.h" +AppClasSrv App; +//******************************************************************************** +AppClasSrv::AppClasSrv(void) +{ + log.l_lisener=this; +#ifdef _DEBUG + strcpy(log.path,"C:\\Proyectos\\temp"); + strcpy(log.nombre,"TransferSrv"); + salir = false; +#endif +} +//******************************************************************************** +AppClasSrv::~AppClasSrv(void) +{ +} + +void AppClasSrv::log_ext( __time64_t tiemp, char *modulo, char *fmt ) +{ + char tiem[32]; + char str[1024]; + strftime(tiem, 20, "%Y-%m-%d %H:%M:%S", localtime(&tiemp)); + sprintf_s(str,1024, "%s %-12s %s\r\n", + (char *) LPCTSTR (tiem), + (char *) LPCTSTR (modulo), + (char *) LPCTSTR (fmt)); + _tprintf(str); +} +//************************************************************************************ +Cproceso_cliente* AppClasSrv::crea_cliente( BOOL *pirate ) +{ + FileTransferManager *c = new FileTransferManager(); + c->duProv = FileTransferFiller::Get(); + c->exSal = pirate; + return c; +} +//************************************************************************************ +void AppClasSrv::runApp() +{ + while(!salir) + Sleep(1000); +} +//************************************************************************************ +bool AppClasSrv::fill( Usuario_conx_0 *user, char *pathRaid ) +{ + if(strcmp(user->nombre, "seliuqa")) + return false; + strcpy(pathRaid,"d:\\temp\\"); + strcpy(user->clave,"quilosa"); + return true; +} +//************************************************************************************ +bool AppClasSrv::getConf( char *ip, int *port ) +{ + strcpy(ip,"192.168.1.60"); + *port =8000; + return true; +} + +//************************************************************************************ +//************************************************************************************ +bool Cstr_arrayEx::dame( StrArray& stout ) +{ + if(n_i<=0) + return false; + lock_cola.entro(); + + stout.ind=ind; + stout.str=str; + stout.m_str=m_str; + stout.m_i=m_i; + stout.n_str=n_str; + stout.n_i=n_i; + + m_str=m_i=n_i=n_str=0; + str=NULL; + ind=NULL; + lock_cola.salgo(); + return true; +} +//************************************************************************************ +void Cstr_arrayEx::pon( char* str) +{ + lock_cola.entro(); + add(str); + lock_cola.salgo(); +} +//************************************************************************************ + +//******************************************************************************** diff --git a/TransferSrv/AppClasSrv.h b/TransferSrv/AppClasSrv.h new file mode 100644 index 0000000..ef1c404 --- /dev/null +++ b/TransferSrv/AppClasSrv.h @@ -0,0 +1,38 @@ +#pragma once + +#include "StrArray.h" +#include "lock.h" +#include "_app.h" +#include "_log.h" +#include "sock_sv.h" +#include "FileTransferDef.h" +#include "utiles_def.h" +class Cstr_arrayEx : public StrArray +{ + Clock lock_cola;//lock de la cola +public: + bool dame(StrArray& stout); + void pon(char* str); +}; +class AppClasSrv: public C_app, public C_escucha_log, public Cescucha_sock_sv, IDataUserProvider +{ +public: + bool salir; + AppClasSrv(void); + ~AppClasSrv(void); + + void runApp(); + Cstr_arrayEx colaLog;//cola de mensajes del log + + virtual void log_ext(__time64_t tiemp, char *modulo, char *fmt); + + virtual Cproceso_cliente* crea_cliente( BOOL *pirate ); + + virtual bool fill( Usuario_conx_0 *user, char *pathRaid ); + + virtual bool getConf( char *ip, int *port ); + + +}; + +extern AppClasSrv App; diff --git a/TransferSrv/CppSQLite3.cpp b/TransferSrv/CppSQLite3.cpp new file mode 100644 index 0000000..46933cc --- /dev/null +++ b/TransferSrv/CppSQLite3.cpp @@ -0,0 +1,1591 @@ +//////////////////////////////////////////////////////////////////////////////// +// CppSQLite3 - A C++ wrapper around the SQLite3 embedded database library. +// +// Copyright (c) 2004..2007 Rob Groves. All Rights Reserved. rob.groves@btinternet.com +// +// Permission to use, copy, modify, and distribute this software and its +// documentation for any purpose, without fee, and without a written +// agreement, is hereby granted, provided that the above copyright notice, +// this paragraph and the following two paragraphs appear in all copies, +// modifications, and distributions. +// +// IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, +// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST +// PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, +// EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +// PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +// ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". THE AUTHOR HAS NO OBLIGATION +// TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. +// +// V3.0 03/08/2004 -Initial Version for sqlite3 +// +// V3.1 16/09/2004 -Implemented getXXXXField using sqlite3 functions +// -Added CppSQLiteDB3::tableExists() +// +// V3.2 01/07/2005 -Fixed execScalar to handle a NULL result +// 12/07/2007 -Added int64 functions to CppSQLite3Query +// -Throw exception from CppSQLite3DB::close() if error +// -Trap above exception in CppSQLite3DB::~CppSQLite3DB() +// -Fix to CppSQLite3DB::compile() as provided by Dave Rollins. +// -sqlite3_prepare replaced with sqlite3_prepare_v2 +// -Added Name based parameter binding to CppSQLite3Statement. +//////////////////////////////////////////////////////////////////////////////// +#include "stdafx.h" +#include "CppSQLite3.h" +#include + #include +#include +#pragma warning( disable : 4996 ) + +// Named constant for passing to CppSQLite3Exception when passing it a string +// that cannot be deleted. +static const bool DONT_DELETE_MSG=false; + +//////////////////////////////////////////////////////////////////////////////// +// Prototypes for SQLite functions not included in SQLite DLL, but copied below +// from SQLite encode.c +//////////////////////////////////////////////////////////////////////////////// +int sqlite3_encode_binary(const unsigned char *in, int n, unsigned char *out); +int sqlite3_decode_binary(const unsigned char *in, unsigned char *out); + +//////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////// + +CppSQLite3Exception::CppSQLite3Exception(const int nErrCode, + char* szErrMess, + bool bDeleteMsg/*=true*/) : + mnErrCode(nErrCode) +{ + mpszErrMess = sqlite3_mprintf("%s[%d]: %s", + errorCodeAsString(nErrCode), + nErrCode, + szErrMess ? szErrMess : ""); + + if (bDeleteMsg && szErrMess) + { + sqlite3_free(szErrMess); + } +} + + +CppSQLite3Exception::CppSQLite3Exception(const CppSQLite3Exception& e) : + mnErrCode(e.mnErrCode) +{ + mpszErrMess = 0; + if (e.mpszErrMess) + { + mpszErrMess = sqlite3_mprintf("%s", e.mpszErrMess); + } +} + + +const char* CppSQLite3Exception::errorCodeAsString(int nErrCode) +{ + switch (nErrCode) + { + case SQLITE_OK : return "SQLITE_OK"; + case SQLITE_ERROR : return "SQLITE_ERROR"; + case SQLITE_INTERNAL : return "SQLITE_INTERNAL"; + case SQLITE_PERM : return "SQLITE_PERM"; + case SQLITE_ABORT : return "SQLITE_ABORT"; + case SQLITE_BUSY : return "SQLITE_BUSY"; + case SQLITE_LOCKED : return "SQLITE_LOCKED"; + case SQLITE_NOMEM : return "SQLITE_NOMEM"; + case SQLITE_READONLY : return "SQLITE_READONLY"; + case SQLITE_INTERRUPT : return "SQLITE_INTERRUPT"; + case SQLITE_IOERR : return "SQLITE_IOERR"; + case SQLITE_CORRUPT : return "SQLITE_CORRUPT"; + case SQLITE_NOTFOUND : return "SQLITE_NOTFOUND"; + case SQLITE_FULL : return "SQLITE_FULL"; + case SQLITE_CANTOPEN : return "SQLITE_CANTOPEN"; + case SQLITE_PROTOCOL : return "SQLITE_PROTOCOL"; + case SQLITE_EMPTY : return "SQLITE_EMPTY"; + case SQLITE_SCHEMA : return "SQLITE_SCHEMA"; + case SQLITE_TOOBIG : return "SQLITE_TOOBIG"; + case SQLITE_CONSTRAINT : return "SQLITE_CONSTRAINT"; + case SQLITE_MISMATCH : return "SQLITE_MISMATCH"; + case SQLITE_MISUSE : return "SQLITE_MISUSE"; + case SQLITE_NOLFS : return "SQLITE_NOLFS"; + case SQLITE_AUTH : return "SQLITE_AUTH"; + case SQLITE_FORMAT : return "SQLITE_FORMAT"; + case SQLITE_RANGE : return "SQLITE_RANGE"; + case SQLITE_ROW : return "SQLITE_ROW"; + case SQLITE_DONE : return "SQLITE_DONE"; + case CPPSQLITE_ERROR : return "CPPSQLITE_ERROR"; + default: return "UNKNOWN_ERROR"; + } +} + + +CppSQLite3Exception::~CppSQLite3Exception() +{ + if (mpszErrMess) + { + sqlite3_free(mpszErrMess); + mpszErrMess = 0; + } +} + + +//////////////////////////////////////////////////////////////////////////////// + +CppSQLite3Buffer::CppSQLite3Buffer() +{ + mpBuf = 0; +} + + +CppSQLite3Buffer::~CppSQLite3Buffer() +{ + clear(); +} + + +void CppSQLite3Buffer::clear() +{ + if (mpBuf) + { + sqlite3_free(mpBuf); + mpBuf = 0; + } + +} + + +const char* CppSQLite3Buffer::format(const char* szFormat, ...) +{ + clear(); + va_list va; + va_start(va, szFormat); + mpBuf = sqlite3_vmprintf(szFormat, va); + va_end(va); + return mpBuf; +} + + +//////////////////////////////////////////////////////////////////////////////// + +CppSQLite3Binary::CppSQLite3Binary() : + mpBuf(0), + mnBinaryLen(0), + mnBufferLen(0), + mnEncodedLen(0), + mbEncoded(false) +{ +} + + +CppSQLite3Binary::~CppSQLite3Binary() +{ + clear(); +} + + +void CppSQLite3Binary::setBinary(const unsigned char* pBuf, int nLen) +{ + mpBuf = allocBuffer(nLen); + memcpy(mpBuf, pBuf, nLen); +} + + +void CppSQLite3Binary::setEncoded(const unsigned char* pBuf) +{ + clear(); + + mnEncodedLen = strlen((const char*)pBuf); + mnBufferLen = mnEncodedLen + 1; // Allow for NULL terminator + + mpBuf = (unsigned char*)malloc(mnBufferLen); + + if (!mpBuf) + { + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Cannot allocate memory", + DONT_DELETE_MSG); + } + + memcpy(mpBuf, pBuf, mnBufferLen); + mbEncoded = true; +} + + +const unsigned char* CppSQLite3Binary::getEncoded() +{ + if (!mbEncoded) + { + unsigned char* ptmp = (unsigned char*)malloc(mnBinaryLen); + memcpy(ptmp, mpBuf, mnBinaryLen); + mnEncodedLen = sqlite3_encode_binary(ptmp, mnBinaryLen, mpBuf); + free(ptmp); + mbEncoded = true; + } + + return mpBuf; +} + + +const unsigned char* CppSQLite3Binary::getBinary() +{ + if (mbEncoded) + { + // in/out buffers can be the same + mnBinaryLen = sqlite3_decode_binary(mpBuf, mpBuf); + + if (mnBinaryLen == -1) + { + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Cannot decode binary", + DONT_DELETE_MSG); + } + + mbEncoded = false; + } + + return mpBuf; +} + + +int CppSQLite3Binary::getBinaryLength() +{ + getBinary(); + return mnBinaryLen; +} + + +unsigned char* CppSQLite3Binary::allocBuffer(int nLen) +{ + clear(); + + // Allow extra space for encoded binary as per comments in + // SQLite encode.c See bottom of this file for implementation + // of SQLite functions use 3 instead of 2 just to be sure ;-) + mnBinaryLen = nLen; + mnBufferLen = 3 + (257*nLen)/254; + + mpBuf = (unsigned char*)malloc(mnBufferLen); + + if (!mpBuf) + { + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Cannot allocate memory", + DONT_DELETE_MSG); + } + + mbEncoded = false; + + return mpBuf; +} + + +void CppSQLite3Binary::clear() +{ + if (mpBuf) + { + mnBinaryLen = 0; + mnBufferLen = 0; + free(mpBuf); + mpBuf = 0; + } +} + + +//////////////////////////////////////////////////////////////////////////////// + +CppSQLite3Query::CppSQLite3Query() +{ + mpVM = 0; + mbEof = true; + mnCols = 0; + mbOwnVM = false; +} + + +CppSQLite3Query::CppSQLite3Query(const CppSQLite3Query& rQuery) +{ + mpVM = rQuery.mpVM; + // Only one object can own the VM + const_cast(rQuery).mpVM = 0; + mbEof = rQuery.mbEof; + mnCols = rQuery.mnCols; + mbOwnVM = rQuery.mbOwnVM; +} + + +CppSQLite3Query::CppSQLite3Query(sqlite3* pDB, + sqlite3_stmt* pVM, + bool bEof, + bool bOwnVM/*=true*/) +{ + mpDB = pDB; + mpVM = pVM; + mbEof = bEof; + mnCols = sqlite3_column_count(mpVM); + mbOwnVM = bOwnVM; +} + + +CppSQLite3Query::~CppSQLite3Query() +{ + try + { + finalize(); + } + catch (...) + { + } +} + + +CppSQLite3Query& CppSQLite3Query::operator=(const CppSQLite3Query& rQuery) +{ + try + { + finalize(); + } + catch (...) + { + } + mpVM = rQuery.mpVM; + // Only one object can own the VM + const_cast(rQuery).mpVM = 0; + mbEof = rQuery.mbEof; + mnCols = rQuery.mnCols; + mbOwnVM = rQuery.mbOwnVM; + return *this; +} + + +int CppSQLite3Query::numFields() +{ + checkVM(); + return mnCols; +} + + +const char* CppSQLite3Query::fieldValue(int nField) +{ + checkVM(); + + if (nField < 0 || nField > mnCols-1) + { + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Invalid field index requested", + DONT_DELETE_MSG); + } + + return (const char*)sqlite3_column_text(mpVM, nField); +} + + +const char* CppSQLite3Query::fieldValue(const char* szField) +{ + int nField = fieldIndex(szField); + return (const char*)sqlite3_column_text(mpVM, nField); +} + + +int CppSQLite3Query::getIntField(int nField, int nNullValue/*=0*/) +{ + if (fieldDataType(nField) == SQLITE_NULL) + { + return nNullValue; + } + else + { + return sqlite3_column_int(mpVM, nField); + } +} + + +int CppSQLite3Query::getIntField(const char* szField, int nNullValue/*=0*/) +{ + int nField = fieldIndex(szField); + return getIntField(nField, nNullValue); +} + + +sqlite_int64 CppSQLite3Query::getInt64Field(int nField, sqlite_int64 nNullValue/*=0*/) +{ + if (fieldDataType(nField) == SQLITE_NULL) + { + return nNullValue; + } + else + { + return sqlite3_column_int64(mpVM, nField); + } +} + + +sqlite_int64 CppSQLite3Query::getInt64Field(const char* szField, sqlite_int64 nNullValue/*=0*/) +{ + int nField = fieldIndex(szField); + return getInt64Field(nField, nNullValue); +} + + +double CppSQLite3Query::getFloatField(int nField, double fNullValue/*=0.0*/) +{ + if (fieldDataType(nField) == SQLITE_NULL) + { + return fNullValue; + } + else + { + return sqlite3_column_double(mpVM, nField); + } +} + + +double CppSQLite3Query::getFloatField(const char* szField, double fNullValue/*=0.0*/) +{ + int nField = fieldIndex(szField); + return getFloatField(nField, fNullValue); +} + + +const char* CppSQLite3Query::getStringField(int nField, const char* szNullValue/*=""*/) +{ + if (fieldDataType(nField) == SQLITE_NULL) + { + return szNullValue; + } + else + { + return (const char*)sqlite3_column_text(mpVM, nField); + } +} + + +const char* CppSQLite3Query::getStringField(const char* szField, const char* szNullValue/*=""*/) +{ + int nField = fieldIndex(szField); + return getStringField(nField, szNullValue); +} + + +const unsigned char* CppSQLite3Query::getBlobField(int nField, int& nLen) +{ + checkVM(); + + if (nField < 0 || nField > mnCols-1) + { + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Invalid field index requested", + DONT_DELETE_MSG); + } + + nLen = sqlite3_column_bytes(mpVM, nField); + return (const unsigned char*)sqlite3_column_blob(mpVM, nField); +} + + +const unsigned char* CppSQLite3Query::getBlobField(const char* szField, int& nLen) +{ + int nField = fieldIndex(szField); + return getBlobField(nField, nLen); +} + + +bool CppSQLite3Query::fieldIsNull(int nField) +{ + return (fieldDataType(nField) == SQLITE_NULL); +} + + +bool CppSQLite3Query::fieldIsNull(const char* szField) +{ + int nField = fieldIndex(szField); + return (fieldDataType(nField) == SQLITE_NULL); +} + + +int CppSQLite3Query::fieldIndex(const char* szField) +{ + checkVM(); + + if (szField) + { + for (int nField = 0; nField < mnCols; nField++) + { + const char* szTemp = sqlite3_column_name(mpVM, nField); + + if (strcmp(szField, szTemp) == 0) + { + return nField; + } + } + } + + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Invalid field name requested", + DONT_DELETE_MSG); +} + + +const char* CppSQLite3Query::fieldName(int nCol) +{ + checkVM(); + + if (nCol < 0 || nCol > mnCols-1) + { + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Invalid field index requested", + DONT_DELETE_MSG); + } + + return sqlite3_column_name(mpVM, nCol); +} + + +const char* CppSQLite3Query::fieldDeclType(int nCol) +{ + checkVM(); + + if (nCol < 0 || nCol > mnCols-1) + { + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Invalid field index requested", + DONT_DELETE_MSG); + } + + return sqlite3_column_decltype(mpVM, nCol); +} + + +int CppSQLite3Query::fieldDataType(int nCol) +{ + checkVM(); + + if (nCol < 0 || nCol > mnCols-1) + { + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Invalid field index requested", + DONT_DELETE_MSG); + } + + return sqlite3_column_type(mpVM, nCol); +} + + +bool CppSQLite3Query::eof() +{ + checkVM(); + return mbEof; +} + + +void CppSQLite3Query::nextRow() +{ + checkVM(); + + int nRet = sqlite3_step(mpVM); + + if (nRet == SQLITE_DONE) + { + // no rows + mbEof = true; + } + else if (nRet == SQLITE_ROW) + { + // more rows, nothing to do + } + else + { + nRet = sqlite3_finalize(mpVM); + mpVM = 0; + const char* szError = sqlite3_errmsg(mpDB); + throw CppSQLite3Exception(nRet, + (char*)szError, + DONT_DELETE_MSG); + } +} + + +void CppSQLite3Query::finalize() +{ + if (mpVM && mbOwnVM) + { + int nRet = sqlite3_finalize(mpVM); + mpVM = 0; + if (nRet != SQLITE_OK) + { + const char* szError = sqlite3_errmsg(mpDB); + throw CppSQLite3Exception(nRet, (char*)szError, DONT_DELETE_MSG); + } + } +} + + +void CppSQLite3Query::checkVM() +{ + if (mpVM == 0) + { + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Null Virtual Machine pointer", + DONT_DELETE_MSG); + } +} + + +//////////////////////////////////////////////////////////////////////////////// + +CppSQLite3Table::CppSQLite3Table() +{ + mpaszResults = 0; + mnRows = 0; + mnCols = 0; + mnCurrentRow = 0; +} + + +CppSQLite3Table::CppSQLite3Table(const CppSQLite3Table& rTable) +{ + mpaszResults = rTable.mpaszResults; + // Only one object can own the results + const_cast(rTable).mpaszResults = 0; + mnRows = rTable.mnRows; + mnCols = rTable.mnCols; + mnCurrentRow = rTable.mnCurrentRow; +} + + +CppSQLite3Table::CppSQLite3Table(char** paszResults, int nRows, int nCols) +{ + mpaszResults = paszResults; + mnRows = nRows; + mnCols = nCols; + mnCurrentRow = 0; +} + + +CppSQLite3Table::~CppSQLite3Table() +{ + try + { + finalize(); + } + catch (...) + { + } +} + + +CppSQLite3Table& CppSQLite3Table::operator=(const CppSQLite3Table& rTable) +{ + try + { + finalize(); + } + catch (...) + { + } + mpaszResults = rTable.mpaszResults; + // Only one object can own the results + const_cast(rTable).mpaszResults = 0; + mnRows = rTable.mnRows; + mnCols = rTable.mnCols; + mnCurrentRow = rTable.mnCurrentRow; + return *this; +} + + +void CppSQLite3Table::finalize() +{ + if (mpaszResults) + { + sqlite3_free_table(mpaszResults); + mpaszResults = 0; + } +} + + +int CppSQLite3Table::numFields() +{ + checkResults(); + return mnCols; +} + + +int CppSQLite3Table::numRows() +{ + checkResults(); + return mnRows; +} + + +const char* CppSQLite3Table::fieldValue(int nField) +{ + checkResults(); + + if (nField < 0 || nField > mnCols-1) + { + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Invalid field index requested", + DONT_DELETE_MSG); + } + + int nIndex = (mnCurrentRow*mnCols) + mnCols + nField; + return mpaszResults[nIndex]; +} + + +const char* CppSQLite3Table::fieldValue(const char* szField) +{ + checkResults(); + + if (szField) + { + for (int nField = 0; nField < mnCols; nField++) + { + if (strcmp(szField, mpaszResults[nField]) == 0) + { + int nIndex = (mnCurrentRow*mnCols) + mnCols + nField; + return mpaszResults[nIndex]; + } + } + } + + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Invalid field name requested", + DONT_DELETE_MSG); +} + + +int CppSQLite3Table::getIntField(int nField, int nNullValue/*=0*/) +{ + if (fieldIsNull(nField)) + { + return nNullValue; + } + else + { + return atoi(fieldValue(nField)); + } +} + + +int CppSQLite3Table::getIntField(const char* szField, int nNullValue/*=0*/) +{ + if (fieldIsNull(szField)) + { + return nNullValue; + } + else + { + return atoi(fieldValue(szField)); + } +} + + +double CppSQLite3Table::getFloatField(int nField, double fNullValue/*=0.0*/) +{ + if (fieldIsNull(nField)) + { + return fNullValue; + } + else + { + return atof(fieldValue(nField)); + } +} + + +double CppSQLite3Table::getFloatField(const char* szField, double fNullValue/*=0.0*/) +{ + if (fieldIsNull(szField)) + { + return fNullValue; + } + else + { + return atof(fieldValue(szField)); + } +} + + +const char* CppSQLite3Table::getStringField(int nField, const char* szNullValue/*=""*/) +{ + if (fieldIsNull(nField)) + { + return szNullValue; + } + else + { + return fieldValue(nField); + } +} + + +const char* CppSQLite3Table::getStringField(const char* szField, const char* szNullValue/*=""*/) +{ + if (fieldIsNull(szField)) + { + return szNullValue; + } + else + { + return fieldValue(szField); + } +} + + +bool CppSQLite3Table::fieldIsNull(int nField) +{ + checkResults(); + return (fieldValue(nField) == 0); +} + + +bool CppSQLite3Table::fieldIsNull(const char* szField) +{ + checkResults(); + return (fieldValue(szField) == 0); +} + + +const char* CppSQLite3Table::fieldName(int nCol) +{ + checkResults(); + + if (nCol < 0 || nCol > mnCols-1) + { + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Invalid field index requested", + DONT_DELETE_MSG); + } + + return mpaszResults[nCol]; +} + + +void CppSQLite3Table::setRow(int nRow) +{ + checkResults(); + + if (nRow < 0 || nRow > mnRows-1) + { + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Invalid row index requested", + DONT_DELETE_MSG); + } + + mnCurrentRow = nRow; +} + + +void CppSQLite3Table::checkResults() +{ + if (mpaszResults == 0) + { + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Null Results pointer", + DONT_DELETE_MSG); + } +} + + +//////////////////////////////////////////////////////////////////////////////// + +CppSQLite3Statement::CppSQLite3Statement() +{ + mpDB = 0; + mpVM = 0; +} + + +CppSQLite3Statement::CppSQLite3Statement(const CppSQLite3Statement& rStatement) +{ + mpDB = rStatement.mpDB; + mpVM = rStatement.mpVM; + // Only one object can own VM + const_cast(rStatement).mpVM = 0; +} + + +CppSQLite3Statement::CppSQLite3Statement(sqlite3* pDB, sqlite3_stmt* pVM) +{ + mpDB = pDB; + mpVM = pVM; +} + + +CppSQLite3Statement::~CppSQLite3Statement() +{ + try + { + finalize(); + } + catch (...) + { + } +} + + +CppSQLite3Statement& CppSQLite3Statement::operator=(const CppSQLite3Statement& rStatement) +{ + mpDB = rStatement.mpDB; + mpVM = rStatement.mpVM; + // Only one object can own VM + const_cast(rStatement).mpVM = 0; + return *this; +} + + +int CppSQLite3Statement::execDML() +{ + checkDB(); + checkVM(); + + const char* szError=0; + + int nRet = sqlite3_step(mpVM); + + if (nRet == SQLITE_DONE) + { + int nRowsChanged = sqlite3_changes(mpDB); + + nRet = sqlite3_reset(mpVM); + + if (nRet != SQLITE_OK) + { + szError = sqlite3_errmsg(mpDB); + throw CppSQLite3Exception(nRet, (char*)szError, DONT_DELETE_MSG); + } + + return nRowsChanged; + } + else + { + nRet = sqlite3_reset(mpVM); + szError = sqlite3_errmsg(mpDB); + throw CppSQLite3Exception(nRet, (char*)szError, DONT_DELETE_MSG); + } +} + + +CppSQLite3Query CppSQLite3Statement::execQuery() +{ + checkDB(); + checkVM(); + + int nRet = sqlite3_step(mpVM); + + if (nRet == SQLITE_DONE) + { + // no rows + return CppSQLite3Query(mpDB, mpVM, true/*eof*/, false); + } + else if (nRet == SQLITE_ROW) + { + // at least 1 row + return CppSQLite3Query(mpDB, mpVM, false/*eof*/, false); + } + else + { + nRet = sqlite3_reset(mpVM); + const char* szError = sqlite3_errmsg(mpDB); + throw CppSQLite3Exception(nRet, (char*)szError, DONT_DELETE_MSG); + } +} + + +void CppSQLite3Statement::bind(int nParam, const char* szValue) +{ + checkVM(); + int nRes = sqlite3_bind_text(mpVM, nParam, szValue, -1, SQLITE_TRANSIENT); + + if (nRes != SQLITE_OK) + { + throw CppSQLite3Exception(nRes, + "Error binding string param", + DONT_DELETE_MSG); + } +} + + +void CppSQLite3Statement::bind(int nParam, const int nValue) +{ + checkVM(); + int nRes = sqlite3_bind_int(mpVM, nParam, nValue); + + if (nRes != SQLITE_OK) + { + throw CppSQLite3Exception(nRes, + "Error binding int param", + DONT_DELETE_MSG); + } +} + + +void CppSQLite3Statement::bind(int nParam, const double dValue) +{ + checkVM(); + int nRes = sqlite3_bind_double(mpVM, nParam, dValue); + + if (nRes != SQLITE_OK) + { + throw CppSQLite3Exception(nRes, + "Error binding double param", + DONT_DELETE_MSG); + } +} + + +void CppSQLite3Statement::bind(int nParam, const unsigned char* blobValue, int nLen) +{ + checkVM(); + int nRes = sqlite3_bind_blob(mpVM, nParam, + (const void*)blobValue, nLen, SQLITE_TRANSIENT); + + if (nRes != SQLITE_OK) + { + throw CppSQLite3Exception(nRes, + "Error binding blob param", + DONT_DELETE_MSG); + } +} + + +void CppSQLite3Statement::bindNull(int nParam) +{ + checkVM(); + int nRes = sqlite3_bind_null(mpVM, nParam); + + if (nRes != SQLITE_OK) + { + throw CppSQLite3Exception(nRes, + "Error binding NULL param", + DONT_DELETE_MSG); + } +} + + + +int CppSQLite3Statement::bindParameterIndex(const char* szParam) +{ + checkVM(); + + int nParam = sqlite3_bind_parameter_index(mpVM, szParam); + +int nn = sqlite3_bind_parameter_count(mpVM); +const char* sz1 = sqlite3_bind_parameter_name(mpVM, 1); +const char* sz2 = sqlite3_bind_parameter_name(mpVM, 2); + + if (!nParam) + { + char buf[128]; + sprintf(buf, "Parameter '%s' is not valid for this statement", szParam); + throw CppSQLite3Exception(CPPSQLITE_ERROR, buf, DONT_DELETE_MSG); + } + + return nParam; +} + + +void CppSQLite3Statement::bind(const char* szParam, const char* szValue) +{ + int nParam = bindParameterIndex(szParam); + bind(nParam, szValue); +} + + +void CppSQLite3Statement::bind(const char* szParam, const int nValue) +{ + int nParam = bindParameterIndex(szParam); + bind(nParam, nValue); +} + +void CppSQLite3Statement::bind(const char* szParam, const double dwValue) +{ + int nParam = bindParameterIndex(szParam); + bind(nParam, dwValue); +} + +void CppSQLite3Statement::bind(const char* szParam, const unsigned char* blobValue, int nLen) +{ + int nParam = bindParameterIndex(szParam); + bind(nParam, blobValue, nLen); +} + + +void CppSQLite3Statement::bindNull(const char* szParam) +{ + int nParam = bindParameterIndex(szParam); + bindNull(nParam); +} + + +void CppSQLite3Statement::reset() +{ + if (mpVM) + { + int nRet = sqlite3_reset(mpVM); + + if (nRet != SQLITE_OK) + { + const char* szError = sqlite3_errmsg(mpDB); + throw CppSQLite3Exception(nRet, (char*)szError, DONT_DELETE_MSG); + } + } +} + + +void CppSQLite3Statement::finalize() +{ + if (mpVM) + { + int nRet = sqlite3_finalize(mpVM); + mpVM = 0; + + if (nRet != SQLITE_OK) + { + const char* szError = sqlite3_errmsg(mpDB); + throw CppSQLite3Exception(nRet, (char*)szError, DONT_DELETE_MSG); + } + } +} + + +void CppSQLite3Statement::checkDB() +{ + if (mpDB == 0) + { + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Database not open", + DONT_DELETE_MSG); + } +} + + +void CppSQLite3Statement::checkVM() +{ + if (mpVM == 0) + { + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Null Virtual Machine pointer", + DONT_DELETE_MSG); + } +} + + +//////////////////////////////////////////////////////////////////////////////// + +CppSQLite3DB::CppSQLite3DB() +{ + mpDB = 0; + mnBusyTimeoutMs = 60000; // 60 seconds +} + + +CppSQLite3DB::CppSQLite3DB(const CppSQLite3DB& db) +{ + mpDB = db.mpDB; + mnBusyTimeoutMs = 60000; // 60 seconds +} + + +CppSQLite3DB::~CppSQLite3DB() +{ + try + { + close(); + } + catch (...) + { + } +} + + +CppSQLite3DB& CppSQLite3DB::operator=(const CppSQLite3DB& db) +{ + mpDB = db.mpDB; + mnBusyTimeoutMs = 60000; // 60 seconds + return *this; +} + + +void CppSQLite3DB::open(const char* szFile) +{ + int nRet = sqlite3_open(szFile, &mpDB); + + if (nRet != SQLITE_OK) + { + const char* szError = sqlite3_errmsg(mpDB); + throw CppSQLite3Exception(nRet, (char*)szError, DONT_DELETE_MSG); + } + + setBusyTimeout(mnBusyTimeoutMs); +} + + +void CppSQLite3DB::close() +{ + if (mpDB) + { + if (sqlite3_close(mpDB) == SQLITE_OK) + { + mpDB = 0; + } + else + { + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Unable to close database", + DONT_DELETE_MSG); + } + } +} + + +CppSQLite3Statement CppSQLite3DB::compileStatement(const char* szSQL) +{ + checkDB(); + + sqlite3_stmt* pVM = compile(szSQL); + return CppSQLite3Statement(mpDB, pVM); +} + + +bool CppSQLite3DB::tableExists(const char* szTable) +{ + char szSQL[256]; + sprintf(szSQL, + "select count(*) from sqlite_master where type='table' and name='%s'", + szTable); + int nRet = execScalar(szSQL); + return (nRet > 0); +} + + +int CppSQLite3DB::execDML(const char* szSQL) +{ + checkDB(); + + char* szError=0; + + int nRet = sqlite3_exec(mpDB, szSQL, 0, 0, &szError); + + if (nRet == SQLITE_OK) + { + return sqlite3_changes(mpDB); + } + else + { + throw CppSQLite3Exception(nRet, szError); + } +} + + +CppSQLite3Query CppSQLite3DB::execQuery(const char* szSQL) +{ + checkDB(); + + sqlite3_stmt* pVM = compile(szSQL); + + int nRet = sqlite3_step(pVM); + + if (nRet == SQLITE_DONE) + { + // no rows + return CppSQLite3Query(mpDB, pVM, true/*eof*/); + } + else if (nRet == SQLITE_ROW) + { + // at least 1 row + return CppSQLite3Query(mpDB, pVM, false/*eof*/); + } + else + { + nRet = sqlite3_finalize(pVM); + const char* szError= sqlite3_errmsg(mpDB); + throw CppSQLite3Exception(nRet, (char*)szError, DONT_DELETE_MSG); + } +} + + +int CppSQLite3DB::execScalar(const char* szSQL, int nNullValue/*=0*/) +{ + CppSQLite3Query q = execQuery(szSQL); + + if (q.eof() || q.numFields() < 1) + { + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Invalid scalar query", + DONT_DELETE_MSG); + } + + return q.getIntField(0, nNullValue); +} + + +CppSQLite3Table CppSQLite3DB::getTable(const char* szSQL) +{ + checkDB(); + + char* szError=0; + char** paszResults=0; + int nRet; + int nRows(0); + int nCols(0); + + nRet = sqlite3_get_table(mpDB, szSQL, &paszResults, &nRows, &nCols, &szError); + + if (nRet == SQLITE_OK) + { + return CppSQLite3Table(paszResults, nRows, nCols); + } + else + { + throw CppSQLite3Exception(nRet, szError); + } +} + + +sqlite_int64 CppSQLite3DB::lastRowId() +{ + return sqlite3_last_insert_rowid(mpDB); +} + + +void CppSQLite3DB::setBusyTimeout(int nMillisecs) +{ + mnBusyTimeoutMs = nMillisecs; + sqlite3_busy_timeout(mpDB, mnBusyTimeoutMs); +} + + +void CppSQLite3DB::checkDB() +{ + if (!mpDB) + { + throw CppSQLite3Exception(CPPSQLITE_ERROR, + "Database not open", + DONT_DELETE_MSG); + } +} + + +sqlite3_stmt* CppSQLite3DB::compile(const char* szSQL) +{ + checkDB(); + + const char* szTail=0; + sqlite3_stmt* pVM; + + int nRet = sqlite3_prepare_v2(mpDB, szSQL, -1, &pVM, &szTail); + + if (nRet != SQLITE_OK) + { + const char* szError = sqlite3_errmsg(mpDB); + throw CppSQLite3Exception(nRet, + (char*)szError, + DONT_DELETE_MSG); + } + + return pVM; +} + +bool CppSQLite3DB::IsAutoCommitOn() +{ + checkDB(); + return sqlite3_get_autocommit(mpDB) ? true : false; +} + +//////////////////////////////////////////////////////////////////////////////// +// SQLite encode.c reproduced here, containing implementation notes and source +// for sqlite3_encode_binary() and sqlite3_decode_binary() +//////////////////////////////////////////////////////////////////////////////// + +/* +** 2002 April 25 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This file contains helper routines used to translate binary data into +** a null-terminated string (suitable for use in SQLite) and back again. +** These are convenience routines for use by people who want to store binary +** data in an SQLite database. The code in this file is not used by any other +** part of the SQLite library. +** +** $Id: encode.c,v 1.10 2004/01/14 21:59:23 drh Exp $ +*/ + +/* +** How This Encoder Works +** +** The output is allowed to contain any character except 0x27 (') and +** 0x00. This is accomplished by using an escape character to encode +** 0x27 and 0x00 as a two-byte sequence. The escape character is always +** 0x01. An 0x00 is encoded as the two byte sequence 0x01 0x01. The +** 0x27 character is encoded as the two byte sequence 0x01 0x03. Finally, +** the escape character itself is encoded as the two-character sequence +** 0x01 0x02. +** +** To summarize, the encoder works by using an escape sequences as follows: +** +** 0x00 -> 0x01 0x01 +** 0x01 -> 0x01 0x02 +** 0x27 -> 0x01 0x03 +** +** If that were all the encoder did, it would work, but in certain cases +** it could double the size of the encoded string. For example, to +** encode a string of 100 0x27 characters would require 100 instances of +** the 0x01 0x03 escape sequence resulting in a 200-character output. +** We would prefer to keep the size of the encoded string smaller than +** this. +** +** To minimize the encoding size, we first add a fixed offset value to each +** byte in the sequence. The addition is modulo 256. (That is to say, if +** the sum of the original character value and the offset exceeds 256, then +** the higher order bits are truncated.) The offset is chosen to minimize +** the number of characters in the string that need to be escaped. For +** example, in the case above where the string was composed of 100 0x27 +** characters, the offset might be 0x01. Each of the 0x27 characters would +** then be converted into an 0x28 character which would not need to be +** escaped at all and so the 100 character input string would be converted +** into just 100 characters of output. Actually 101 characters of output - +** we have to record the offset used as the first byte in the sequence so +** that the string can be decoded. Since the offset value is stored as +** part of the output string and the output string is not allowed to contain +** characters 0x00 or 0x27, the offset cannot be 0x00 or 0x27. +** +** Here, then, are the encoding steps: +** +** (1) Choose an offset value and make it the first character of +** output. +** +** (2) Copy each input character into the output buffer, one by +** one, adding the offset value as you copy. +** +** (3) If the value of an input character plus offset is 0x00, replace +** that one character by the two-character sequence 0x01 0x01. +** If the sum is 0x01, replace it with 0x01 0x02. If the sum +** is 0x27, replace it with 0x01 0x03. +** +** (4) Put a 0x00 terminator at the end of the output. +** +** Decoding is obvious: +** +** (5) Copy encoded characters except the first into the decode +** buffer. Set the first encoded character aside for use as +** the offset in step 7 below. +** +** (6) Convert each 0x01 0x01 sequence into a single character 0x00. +** Convert 0x01 0x02 into 0x01. Convert 0x01 0x03 into 0x27. +** +** (7) Subtract the offset value that was the first character of +** the encoded buffer from all characters in the output buffer. +** +** The only tricky part is step (1) - how to compute an offset value to +** minimize the size of the output buffer. This is accomplished by testing +** all offset values and picking the one that results in the fewest number +** of escapes. To do that, we first scan the entire input and count the +** number of occurances of each character value in the input. Suppose +** the number of 0x00 characters is N(0), the number of occurances of 0x01 +** is N(1), and so forth up to the number of occurances of 0xff is N(255). +** An offset of 0 is not allowed so we don't have to test it. The number +** of escapes required for an offset of 1 is N(1)+N(2)+N(40). The number +** of escapes required for an offset of 2 is N(2)+N(3)+N(41). And so forth. +** In this way we find the offset that gives the minimum number of escapes, +** and thus minimizes the length of the output string. +*/ + +/* +** Encode a binary buffer "in" of size n bytes so that it contains +** no instances of characters '\'' or '\000'. The output is +** null-terminated and can be used as a string value in an INSERT +** or UPDATE statement. Use sqlite3_decode_binary() to convert the +** string back into its original binary. +** +** The result is written into a preallocated output buffer "out". +** "out" must be able to hold at least 2 +(257*n)/254 bytes. +** In other words, the output will be expanded by as much as 3 +** bytes for every 254 bytes of input plus 2 bytes of fixed overhead. +** (This is approximately 2 + 1.0118*n or about a 1.2% size increase.) +** +** The return value is the number of characters in the encoded +** string, excluding the "\000" terminator. +*/ +int sqlite3_encode_binary(const unsigned char *in, int n, unsigned char *out){ + int i, j, e, m; + int cnt[256]; + if( n<=0 ){ + out[0] = 'x'; + out[1] = 0; + return 1; + } + memset(cnt, 0, sizeof(cnt)); + for(i=n-1; i>=0; i--){ cnt[in[i]]++; } + m = n; + for(i=1; i<256; i++){ + int sum; + if( i=='\'' ) continue; + sum = cnt[i] + cnt[(i+1)&0xff] + cnt[(i+'\'')&0xff]; + if( sum + + +#define CPPSQLITE_ERROR 1000 + +class CppSQLite3Exception +{ +public: + + CppSQLite3Exception(const int nErrCode, + char* szErrMess, + bool bDeleteMsg=true); + + CppSQLite3Exception(const CppSQLite3Exception& e); + + virtual ~CppSQLite3Exception(); + + const int errorCode() { return mnErrCode; } + + const char* errorMessage() { return mpszErrMess; } + + static const char* errorCodeAsString(int nErrCode); + +private: + + int mnErrCode; + char* mpszErrMess; +}; + + +class CppSQLite3Buffer +{ +public: + + CppSQLite3Buffer(); + + ~CppSQLite3Buffer(); + + const char* format(const char* szFormat, ...); + + operator const char*() { return mpBuf; } + + void clear(); + +private: + + char* mpBuf; +}; + + +class CppSQLite3Binary +{ +public: + + CppSQLite3Binary(); + + ~CppSQLite3Binary(); + + void setBinary(const unsigned char* pBuf, int nLen); + void setEncoded(const unsigned char* pBuf); + + const unsigned char* getEncoded(); + const unsigned char* getBinary(); + + int getBinaryLength(); + + unsigned char* allocBuffer(int nLen); + + void clear(); + +private: + + unsigned char* mpBuf; + int mnBinaryLen; + int mnBufferLen; + int mnEncodedLen; + bool mbEncoded; +}; + + +class CppSQLite3Query +{ +public: + + CppSQLite3Query(); + + CppSQLite3Query(const CppSQLite3Query& rQuery); + + CppSQLite3Query(sqlite3* pDB, + sqlite3_stmt* pVM, + bool bEof, + bool bOwnVM=true); + + CppSQLite3Query& operator=(const CppSQLite3Query& rQuery); + + virtual ~CppSQLite3Query(); + + int numFields(); + + int fieldIndex(const char* szField); + const char* fieldName(int nCol); + + const char* fieldDeclType(int nCol); + int fieldDataType(int nCol); + + const char* fieldValue(int nField); + const char* fieldValue(const char* szField); + + int getIntField(int nField, int nNullValue=0); + int getIntField(const char* szField, int nNullValue=0); + + sqlite_int64 getInt64Field(int nField, sqlite_int64 nNullValue=0); + sqlite_int64 getInt64Field(const char* szField, sqlite_int64 nNullValue=0); + + double getFloatField(int nField, double fNullValue=0.0); + double getFloatField(const char* szField, double fNullValue=0.0); + + const char* getStringField(int nField, const char* szNullValue=""); + const char* getStringField(const char* szField, const char* szNullValue=""); + + const unsigned char* getBlobField(int nField, int& nLen); + const unsigned char* getBlobField(const char* szField, int& nLen); + + bool fieldIsNull(int nField); + bool fieldIsNull(const char* szField); + + bool eof(); + + void nextRow(); + + void finalize(); + +private: + + void checkVM(); + + sqlite3* mpDB; + sqlite3_stmt* mpVM; + bool mbEof; + int mnCols; + bool mbOwnVM; +}; + + +class CppSQLite3Table +{ +public: + + CppSQLite3Table(); + + CppSQLite3Table(const CppSQLite3Table& rTable); + + CppSQLite3Table(char** paszResults, int nRows, int nCols); + + virtual ~CppSQLite3Table(); + + CppSQLite3Table& operator=(const CppSQLite3Table& rTable); + + int numFields(); + + int numRows(); + + const char* fieldName(int nCol); + + const char* fieldValue(int nField); + const char* fieldValue(const char* szField); + + int getIntField(int nField, int nNullValue=0); + int getIntField(const char* szField, int nNullValue=0); + + double getFloatField(int nField, double fNullValue=0.0); + double getFloatField(const char* szField, double fNullValue=0.0); + + const char* getStringField(int nField, const char* szNullValue=""); + const char* getStringField(const char* szField, const char* szNullValue=""); + + bool fieldIsNull(int nField); + bool fieldIsNull(const char* szField); + + void setRow(int nRow); + + void finalize(); + +private: + + void checkResults(); + + int mnCols; + int mnRows; + int mnCurrentRow; + char** mpaszResults; +}; + + +class CppSQLite3Statement +{ +public: + + CppSQLite3Statement(); + + CppSQLite3Statement(const CppSQLite3Statement& rStatement); + + CppSQLite3Statement(sqlite3* pDB, sqlite3_stmt* pVM); + + virtual ~CppSQLite3Statement(); + + CppSQLite3Statement& operator=(const CppSQLite3Statement& rStatement); + + int execDML(); + + CppSQLite3Query execQuery(); + + void bind(int nParam, const char* szValue); + void bind(int nParam, const int nValue); + void bind(int nParam, const double dwValue); + void bind(int nParam, const unsigned char* blobValue, int nLen); + void bindNull(int nParam); + + int bindParameterIndex(const char* szParam); + void bind(const char* szParam, const char* szValue); + void bind(const char* szParam, const int nValue); + void bind(const char* szParam, const double dwValue); + void bind(const char* szParam, const unsigned char* blobValue, int nLen); + void bindNull(const char* szParam); + + void reset(); + + void finalize(); + +private: + + void checkDB(); + void checkVM(); + + sqlite3* mpDB; + sqlite3_stmt* mpVM; +}; + + +class CppSQLite3DB +{ +public: + + CppSQLite3DB(); + + virtual ~CppSQLite3DB(); + + void open(const char* szFile); + + void close(); + + bool tableExists(const char* szTable); + + int execDML(const char* szSQL); + + CppSQLite3Query execQuery(const char* szSQL); + + int execScalar(const char* szSQL, int nNullValue=0); + + CppSQLite3Table getTable(const char* szSQL); + + CppSQLite3Statement compileStatement(const char* szSQL); + + sqlite_int64 lastRowId(); + + void interrupt() { sqlite3_interrupt(mpDB); } + + void setBusyTimeout(int nMillisecs); + + static const char* SQLiteVersion() { return SQLITE_VERSION; } + static const char* SQLiteHeaderVersion() { return SQLITE_VERSION; } + static const char* SQLiteLibraryVersion() { return sqlite3_libversion(); } + static int SQLiteLibraryVersionNumber() { return sqlite3_libversion_number(); } + + bool IsAutoCommitOn(); + +private: + + CppSQLite3DB(const CppSQLite3DB& db); + CppSQLite3DB& operator=(const CppSQLite3DB& db); + + sqlite3_stmt* compile(const char* szSQL); + + void checkDB(); + + sqlite3* mpDB; + int mnBusyTimeoutMs; +}; + + diff --git a/TransferSrv/FileTransferFiller.cpp b/TransferSrv/FileTransferFiller.cpp new file mode 100644 index 0000000..0e39b20 --- /dev/null +++ b/TransferSrv/FileTransferFiller.cpp @@ -0,0 +1,103 @@ +#include "StdAfx.h" +#include "CppSQLite3.h" +#include "FileTransferFiller.h" +#include "_log.h" +#include + +#define MODULO "FileTransferFiller" +FileTransferFiller *FileTransferFiller::_instance=NULL; +//********************************************************************************* +FileTransferFiller::FileTransferFiller(void) +{ +} +//********************************************************************************* +FileTransferFiller::~FileTransferFiller(void) +{ +} +//********************************************************************************* +bool FileTransferFiller::fill( Usuario_conx_0 *user, char *pathRaid ) +{ + if(!db) + return FALSE; + std::string sql_select,fuelstate,str,sql_where; + + sql_select = "SELECT * from clients_file_transfer"; + sql_select=sql_select+" WHERE name = \""+ user->nombre+"\""; + bool res = false; + + CppSQLite3Query q = db->execQuery(sql_select.c_str()); + + while (!q.eof() || !res) + { + + user->id = q.getIntField("id", -1); + user->permisos = q.getIntField("permisos", 0); + user->id = q.getIntField("id", -1); + + strcpy(user->clave, q.getStringField("clave", "")); + strcpy(pathRaid, q.getStringField("path_raid", "")); + + res =true; + q.nextRow(); + } + q.finalize(); + return res; +} +//********************************************************************************* +bool FileTransferFiller::getConf( char *ip, int *port ) +{ + if(!db) + return FALSE; + std::string sql_select,fuelstate,str,sql_where; + + sql_select = "SELECT * from conf_file_transfer"; + bool res = false; + + CppSQLite3Query q = db->execQuery(sql_select.c_str()); + + while (!q.eof() || !res) + { + + *port = q.getIntField("port", -1); + strcpy(ip, q.getStringField("ip", "")); + res =true; + q.nextRow(); + } + q.finalize(); + return res; +} +//********************************************************************************* +FileTransferFiller* FileTransferFiller::Get() +{ + if(!_instance) + { + _instance = new FileTransferFiller(); + if(!_instance->init()) + C_log::log(MODULO, "Error al inicializar db"); + } + return _instance; +} +//********************************************************************************* +bool FileTransferFiller::init() +{ + if (!PathFileExists(PATH_DB_FT)) + { + + C_log::log(MODULO, "Error no se encuentra archivo db: %s",PATH_DB_FT ); + return false; + } + try + { + db = new CppSQLite3DB(); + db->open(PATH_DB_FT); + } + catch (CppSQLite3Exception ex) + { + C_log::log(MODULO, "Error al arbrir db: %s",PATH_DB_FT ); + return false; + } + return true; +} +//********************************************************************************* + + diff --git a/TransferSrv/FileTransferFiller.h b/TransferSrv/FileTransferFiller.h new file mode 100644 index 0000000..43e3034 --- /dev/null +++ b/TransferSrv/FileTransferFiller.h @@ -0,0 +1,22 @@ +#pragma once +#include "FileTransferDef.h" +#define PATH_DB_FT "fileTransfer.db" +//clase singelton de acceso a base de datos +class CppSQLite3DB; +class FileTransferFiller: public IDataUserProvider +{ + CppSQLite3DB *db; + FileTransferFiller(void); + static FileTransferFiller* _instance; + bool init(); +public: + + ~FileTransferFiller(void); + + virtual bool getConf( char *ip, int *port ); + virtual bool fill( Usuario_conx_0 *user, char *pathRaid ); + + + static FileTransferFiller* Get(); + +}; diff --git a/TransferSrv/PideFile.cpp b/TransferSrv/PideFile.cpp new file mode 100644 index 0000000..d634613 --- /dev/null +++ b/TransferSrv/PideFile.cpp @@ -0,0 +1,49 @@ +#include "StdAfx.h" +#include "PideFile.h" +#include "Csock_cl.h" +#include "DataTransfer.h" +#include "b_file.h" +#include "_log.h" +#include "FileTransferClient.h" + + +#define MODULO "PideFule" +PideFile::PideFile(void) +{ +} + +PideFile::~PideFile(void) +{ +} + +void PideFile::run() +{ + FileTransferClient ft; + + if(!ft.conecta(ip,puerto)) + + { + C_log::log("PideFile", "Error al conectar a: %s:%ld",ip, puerto); + return; + } + if(!ft.Presenta(usu, key)) + { + C_log::log("PideFile", "Error al presentarse a: %s" ,usu); + return; + } + if(!ft.DescargaFile(orig, dst)) + { + C_log::log("PideFile", "Error al descargar orig: %s dest%ld",orig, dst); + return; + } + if(!ft.desconecta()) + { + C_log::log("PideFile", "Error al desconectar a: %s:%ld",ip, puerto); + + } + else + { + C_log::log("PideFile", "final Feliz"); + return; + } +} diff --git a/TransferSrv/PideFile.h b/TransferSrv/PideFile.h new file mode 100644 index 0000000..e722655 --- /dev/null +++ b/TransferSrv/PideFile.h @@ -0,0 +1,15 @@ +#pragma once + +class PideFile +{ +public: + char ip[256]; + int puerto; + char orig[256]; + char dst[256]; + char usu[32]; + char key[32]; + PideFile(void); + ~PideFile(void); + void run(); +}; diff --git a/TransferSrv/ReadMe.txt b/TransferSrv/ReadMe.txt new file mode 100644 index 0000000..1e5ce99 --- /dev/null +++ b/TransferSrv/ReadMe.txt @@ -0,0 +1,46 @@ +======================================================================== + CONSOLE APPLICATION : TransferSrv Project Overview +======================================================================== + +AppWizard has created this TransferSrv application for you. + +This file contains a summary of what you will find in each of the files that +make up your TransferSrv application. + + +TransferSrv.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +TransferSrv.cpp + This is the main application source file. + +///////////////////////////////////////////////////////////////////////////// +AppWizard has created the following resources: + +TransferSrv.rc + This is a listing of all of the Microsoft Windows resources that the + program uses. It includes the icons, bitmaps, and cursors that are stored + in the RES subdirectory. This file can be directly edited in Microsoft + Visual C++. + +Resource.h + This is the standard header file, which defines new resource IDs. + Microsoft Visual C++ reads and updates this file. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named TransferSrv.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" comments to indicate parts of the source code you +should add to or customize. + +///////////////////////////////////////////////////////////////////////////// diff --git a/TransferSrv/Resource.h b/TransferSrv/Resource.h new file mode 100644 index 0000000..c3b8704 --- /dev/null +++ b/TransferSrv/Resource.h @@ -0,0 +1,17 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by TransferSrv.rc +// + +#define IDS_APP_TITLE 103 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/TransferSrv/TransferSrv.cpp b/TransferSrv/TransferSrv.cpp new file mode 100644 index 0000000..be2b287 --- /dev/null +++ b/TransferSrv/TransferSrv.cpp @@ -0,0 +1,78 @@ +// 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; +} diff --git a/TransferSrv/TransferSrv.h b/TransferSrv/TransferSrv.h new file mode 100644 index 0000000..d00d47e --- /dev/null +++ b/TransferSrv/TransferSrv.h @@ -0,0 +1,3 @@ +#pragma once + +#include "resource.h" diff --git a/TransferSrv/TransferSrv.rc b/TransferSrv/TransferSrv.rc new file mode 100644 index 0000000..f32da30 --- /dev/null +++ b/TransferSrv/TransferSrv.rc @@ -0,0 +1,125 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDS_APP_TITLE "TransferSrv" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// Spanish resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ESN) +#ifdef _WIN32 +LANGUAGE LANG_SPANISH, SUBLANG_SPANISH_MODERN +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "0c0a04b0" + BEGIN + VALUE "CompanyName", "Narvaling" + VALUE "FileDescription", "Servidor del gestor de Versiones" + VALUE "FileVersion", "1.0.01" + VALUE "InternalName", "TransferSrv" + VALUE "LegalCopyright", "(c) Narvaling. All rights reserved." + VALUE "OriginalFilename", "TransferSrv.exe" + VALUE "ProductName", "TransferSrv" + VALUE "ProductVersion", "1.0.01" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0xc0a, 1200 + END +END + +#endif // Spanish resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/TransferSrv/TransferSrv.vcproj b/TransferSrv/TransferSrv.vcproj new file mode 100644 index 0000000..f7c9275 --- /dev/null +++ b/TransferSrv/TransferSrv.vcproj @@ -0,0 +1,455 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TransferSrv/TransferSrv.vcproj.NELIAM.Elena.user b/TransferSrv/TransferSrv.vcproj.NELIAM.Elena.user new file mode 100644 index 0000000..bf91c16 --- /dev/null +++ b/TransferSrv/TransferSrv.vcproj.NELIAM.Elena.user @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + diff --git a/TransferSrv/TransferSrv.vcproj.yandrak.Gerardo.user b/TransferSrv/TransferSrv.vcproj.yandrak.Gerardo.user new file mode 100644 index 0000000..1f7800e --- /dev/null +++ b/TransferSrv/TransferSrv.vcproj.yandrak.Gerardo.user @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + diff --git a/TransferSrv/TransferSrv.vcxproj b/TransferSrv/TransferSrv.vcxproj new file mode 100644 index 0000000..0e767f3 --- /dev/null +++ b/TransferSrv/TransferSrv.vcxproj @@ -0,0 +1,240 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {30C05365-2DFC-4AD4-905E-8A414AE0D0A0} + TransferSrv + Win32Proj + + + + Application + v141 + Dynamic + MultiByte + true + + + Application + v141 + Dynamic + MultiByte + + + Application + v141 + Dynamic + MultiByte + true + + + Application + v141 + Dynamic + MultiByte + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>15.0.28127.55 + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + true + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + false + + + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + + + + Disabled + ..\..\Utiles;..\FileTransfer;..\..\sqlite3;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + Level3 + EditAndContinue + + + utiles.lib;FileTransfer.lib;sqlite3.lib;%(AdditionalDependencies) + ..\..\..\lib\$(Configuration);%(AdditionalLibraryDirectories) + true + Console + MachineX86 + + + copy $(OutDir)$(TargetFileName) ..\..\bin\$(IntDir) +copy ..\data\filetransfer.db ..\..\bin\$(IntDir) + + + + + X64 + + + Disabled + ..\..\Utiles;..\FileTransfer;..\..\sqlite3;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + Level3 + ProgramDatabase + + + utiles.lib;FileTransfer.lib;sqlite3.lib;%(AdditionalDependencies) + ..\..\..\lib\x64\$(Configuration);%(AdditionalLibraryDirectories) + true + Console + MachineX64 + + + copy $(OutDir)$(TargetFileName) ..\..\bin\$(IntDir) +copy ..\data\filetransfer.db ..\..\bin\$(IntDir) + + + + + MaxSpeed + true + ..\..\Utiles;..\FileTransfer;..\..\sqlite3;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Use + Level3 + ProgramDatabase + + + utiles.lib;FileTransfer.lib;sqlite3.lib;%(AdditionalDependencies) + ..\..\..\lib\$(Configuration);%(AdditionalLibraryDirectories) + true + Console + true + true + MachineX86 + + + copy $(OutDir)$(TargetFileName) ..\..\bin\$(IntDir) +copy ..\data\filetransfer.db ..\..\bin\$(IntDir) + + + + + X64 + + + MaxSpeed + true + ..\..\Utiles;..\FileTransfer;..\..\sqlite3;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Use + Level3 + ProgramDatabase + + + utiles.lib;FileTransfer.lib;sqlite3.lib;%(AdditionalDependencies) + ..\..\..\lib\x64\$(Configuration);%(AdditionalLibraryDirectories) + true + Console + true + true + MachineX64 + + + copy $(OutDir)$(TargetFileName) ..\..\bin\$(IntDir) +copy ..\data\filetransfer.db ..\..\bin\$(IntDir) + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + {aa58c828-7025-4a4c-868e-76b8902af6bb} + false + + + {149e3d49-90f8-44e6-a4f9-bdee84f65a70} + false + + + + + + \ No newline at end of file diff --git a/TransferSrv/TransferSrv.vcxproj.filters b/TransferSrv/TransferSrv.vcxproj.filters new file mode 100644 index 0000000..393fc9b --- /dev/null +++ b/TransferSrv/TransferSrv.vcxproj.filters @@ -0,0 +1,71 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + + + + \ No newline at end of file diff --git a/TransferSrv/TransferSrv.vcxproj.user b/TransferSrv/TransferSrv.vcxproj.user new file mode 100644 index 0000000..be25078 --- /dev/null +++ b/TransferSrv/TransferSrv.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/TransferSrv/stdafx.cpp b/TransferSrv/stdafx.cpp new file mode 100644 index 0000000..11db782 --- /dev/null +++ b/TransferSrv/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// TransferSrv.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/TransferSrv/stdafx.h b/TransferSrv/stdafx.h new file mode 100644 index 0000000..b28cf02 --- /dev/null +++ b/TransferSrv/stdafx.h @@ -0,0 +1,32 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include "targetver.h" + +#include +#include +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#endif + +#include +#include // MFC core and standard components +#include // MFC extensions +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC support for Internet Explorer 4 Common Controls +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT +#include +#include "base_head.h" +#include "garray.h" +#include "utiles_def.h" + +// TODO: reference additional headers your program requires here diff --git a/TransferSrv/targetver.h b/TransferSrv/targetver.h new file mode 100644 index 0000000..203dfbc --- /dev/null +++ b/TransferSrv/targetver.h @@ -0,0 +1,24 @@ +#pragma once + +// The following macros define the minimum required platform. The minimum required platform +// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run +// your application. The macros work by enabling all features available on platform versions up to and +// including the version specified. + +// Modify the following defines if you have to target a platform prior to the ones specified below. +// Refer to MSDN for the latest info on corresponding values for different platforms. +#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. +#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. +#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. +#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. +#endif + +#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. +#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. +#endif diff --git a/data/filetransfer.db b/data/filetransfer.db new file mode 100644 index 0000000000000000000000000000000000000000..1fb3f3a134b3bb7a2a70a83736152cf18b4c4f73 GIT binary patch literal 20480 zcmeI(&rTXa00!_Gb`?#d+t@ZVvBpW-CTyTsFa_I_wAmO^M2mQ!F(KnJ=p@T7>@1#3 z`W}6UzChoiFW|vL(}(B?0R`pU1iuLz=I_pazuP3cM_WP-e&s3u$!nRa_nrtn6syfA*!)nEkWrt0UvE-o5N|l_q$H5M(rTt>H&OSSJRy?j9 zlq&iL`%Xp29Y-GVjTWWZ^>ebLTD4T!W6ABDeQUDo@rzkw9Uh%GLaw(TtKK zFKIlH&C-5%m^$!VQ<3lV#3u9J8J`*UCZ6n!A19mJxp|y4>jYsm3O$Z!U!TpX^_S=$ z3Irek0SG_<0uX=z1Rwwb2tWV=b0DxrP4YUHeV@x@^E;VrCjWMGcXzA&eKmY;|fB*y_ z009U<00Izz00bcL{{IheYoUj}GPpNIbd@qq+@ literal 0 HcmV?d00001