aggiunta classe TExternisamfile git-svn-id: svn://10.65.10.50/trunk@4878 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			179 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			179 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include <stdlib.h>
 | |
| #include <stdio.h>
 | |
| 
 | |
| #define __STDTYPES_CPP
 | |
| 
 | |
| #include <extcdecl.h>
 | |
| #include <conf.h>
 | |
| #include <modaut.h>
 | |
| #include <isamrpc.h>
 | |
| 
 | |
| #if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
 | |
| #include <dos.h>
 | |
| #include <hlapi_c.h>
 | |
| #endif
 | |
| 
 | |
| #include <applicat.h>
 | |
| #include <isam.h>
 | |
| #include <prefix.h>
 | |
| #include <codeb.h>
 | |
| 
 | |
| extern isfdptr *openf;
 | |
| extern isfdptr *ext_files;
 | |
| HIDDEN long _stdlevel = 0;
 | |
| 
 | |
| // @doc INTERNAL
 | |
| 
 | |
| // @func Ritorna il livello degli archivi
 | |
| long get_std_level()
 | |
| { return _stdlevel; }
 | |
| 
 | |
| // @func Setta il livello degli archivi
 | |
| void set_std_level(const long l)
 | |
| { _stdlevel = l; }
 | |
| 
 | |
| // @doc INTERNAL
 | |
| 
 | |
| static int _login_status = 0;
 | |
| 
 | |
| // @func Ritorna il numero di serie della chiave
 | |
| //
 | |
| // @rdesc Numero di serie della chiave
 | |
| int get_serial_number(const char* appname)
 | |
| {   
 | |
|   if (_login_status == 0)
 | |
|   {
 | |
|     if (HL_LOGIN(ModAd, DONT_CARE, REFKEY, VERKEY) == STATUS_OK)
 | |
|     {              
 | |
|       _login_status = 1;                             
 | |
|       getser();
 | |
|     }
 | |
|   }  
 | |
|   if (_login_status != 1)
 | |
|   {                     
 | |
|     if (_login_status == 2)
 | |
|     {
 | |
|       rpc_UserLogout();
 | |
|       SerNo = 0xFFFF;
 | |
|     }
 | |
|       
 | |
|     TConfig ini(CONFIG_STUDIO, "Server");
 | |
|     const char* server = ini.get("Name");
 | |
|     const char* guest  = "******";
 | |
|     const char* utente = (!xvt_running() && !stricmp(appname, "ba0100")) ? guest : user();
 | |
|     
 | |
|     if (rpc_UserLogin(server, utente, guest, appname))
 | |
|     {                        
 | |
|       _login_status = 2;
 | |
|       SerNo = rpc_DongleNumber();
 | |
|     } 
 | |
|     else                
 | |
|       _login_status = 0;
 | |
|   }
 | |
|   
 | |
|   switch(_login_status)
 | |
|   {
 | |
|     case 1 : CGetAut(1) != 0; break;
 | |
|     case 2 : rpc_DongleModules(_int_tab0); break;
 | |
|     default: memset(_int_tab0, 0, sizeof(_int_tab0)); break;
 | |
|   }
 | |
| 
 | |
|   return SerNo;
 | |
| }
 | |
| 
 | |
| // @doc INTERNAL
 | |
| 
 | |
| // @func Inizilizza le variabili globali
 | |
| void init_global_vars()
 | |
| {
 | |
|   TPrefix& pref = prefix_init();
 | |
|   
 | |
|   pref.set("");
 | |
|   _stdlevel = pref.filelevel();
 | |
|   
 | |
|   FileDes       d;
 | |
|   CGetFile(LF_DIR, &d, _nolock, NORDIR);
 | |
|   
 | |
|   long maxfdir = d.EOX;
 | |
|   pref.set("DEF");
 | |
|   CGetFile(LF_DIR, &d, _nolock, NORDIR);
 | |
|   if (d.EOD > maxfdir) maxfdir = d.EOD;
 | |
| 
 | |
|   isjournal = FALSE;
 | |
|   
 | |
|   openf = new isfdptr[maxfdir];
 | |
|   openrec = new TRectype*[maxfdir];
 | |
|   ext_files = new isfdptr[maxfdir];
 | |
|   
 | |
|   for (long i = 0; i < maxfdir; i++)
 | |
|   {
 | |
|     openf[i] = NULL;
 | |
|     openrec[i] = NULL;
 | |
|     ext_files[i] = NULL;
 | |
|   }
 | |
|   
 | |
|   DB_init();
 | |
| }
 | |
| // @doc INTERNAL
 | |
| 
 | |
| // @func Dealloca le variabili globali
 | |
| void free_global_vars()
 | |
| {                
 | |
| #if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
 | |
|   if (_login_status == 2)
 | |
|     rpc_UserLogout();
 | |
|   else
 | |
|     HL_LOGOUT();
 | |
| #endif
 | |
|   
 | |
|   if (openf != NULL)
 | |
|   {
 | |
|     delete openf;
 | |
|     delete openrec;
 | |
|     delete ext_files;
 | |
|     prefix_destroy();
 | |
|   }  
 | |
|   DB_exit();
 | |
| }
 | |
| 
 | |
| #ifndef FOXPRO
 | |
| #include <xvt.h>
 | |
| 
 | |
| // @doc EXTERNAL
 | |
| 
 | |
| // @func Operatore per la creazione di un oggetto (sostituisce operatore C++)
 | |
| //
 | |
| // @rdesc Ritorna il puntatore all'oggetto creato
 | |
| void* operator new(size_t size)
 | |
| 
 | |
| // @comm Per maggiori informazioni fare riferimento all'omonimo comando sull'help
 | |
| //   in linea del C++.
 | |
| //       <nl>Questa funzione viene implementata se non si opera in ambiante FoxPro.
 | |
| 
 | |
| { 
 | |
|   void* mem = (void*)malloc(size); 
 | |
|   if (mem == NULL)
 | |
|     fatal_box("Out of memory: can't allocate %u bytes", size);
 | |
| 
 | |
|   return mem;
 | |
| }
 | |
| // @doc EXTERNAL
 | |
| 
 | |
| // @func Operatore per la distruzione di un oggetto (sostituisce operatore C++)
 | |
| void operator delete(
 | |
|      void* ptr) // @parm Puntatore all'oggetto da distruggere
 | |
| 
 | |
| // @comm Per maggiori informazioni fare riferimento all'omonimo comando sull'help
 | |
| //   in linea del C++.
 | |
| //       <nl>Nel caso venga passato un puntatore NULL viene emesso un <f CKECK>.
 | |
| //       <nl>Questa funzione viene implementata se non si opera in ambiante FoxPro.
 | |
| 
 | |
| {
 | |
|   CHECK(ptr, "Can't delete a NULL pointer");
 | |
|   free(ptr);
 | |
| }
 | |
| 
 | |
| #endif // FOXPRO
 | |
| 
 | |
| 
 |