alex 0c0abd6589 This commit was generated by cvs2svn to compensate for changes in r5942,
which included commits to RCS files with non-trunk default branches.

git-svn-id: svn://10.65.10.50/trunk@5943 c028cbd2-c16b-5b4b-a496-9718f37d4682
1998-01-15 16:39:02 +00:00

1095 lines
22 KiB
C++
Executable File

#include <stdio.h>
#ifdef WIN32
#define W32SUT_32 // Required for universal thunking under Win32s
#endif
#include <windows.h>
#ifndef WIN32
#include <toolhelp.h>
#else
#include "w32sut.h" // Required for universal thunking under Win32s
#define SYNCHSPAWN 1
#endif
#define DLL_OR_LIGHT (LIGHT || DLL)
#ifndef DLL_OR_LIGHT
#include <checks.h>
#include <extcdecl.h>
#include <isam.h>
#else
#include <string.h>
#include <direct.h>
#include <io.h>
#ifndef WIN32
#include <stdtypes.h>
#endif
#endif
#ifndef DLL
#include "../foxlck/pro_ext.h"
#endif
#ifdef DLL_OR_LIGHT
static char cprefix[81]="";
static char __ptprf[81]="";
#ifdef DLL
static char __prfpth[81]="";
static char __user[17]="";
static char __tmpdir[256]="";
#endif
#ifdef WIN32
#define EXPORT32
#define EXPORT16
HWND HWin;
typedef BOOL (WINAPI * PUTREGISTER) ( HANDLE hModule,
LPCSTR lpsz16BitDLL,
LPCSTR lpszInitName,
LPCSTR lpszProcName,
UT32PROC* ppfn32Thunk,
FARPROC pfnUT32CallBack,
LPVOID lpBuff
);
typedef VOID (WINAPI * PUTUNREGISTER) (HANDLE hModule);
//typedef DWORD (APIENTRY * PUT32CBPROC) (LPVOID lpBuff, DWORD dwUserDefined, LPVOID *lpTranslationList);
UT32PROC pfnUTProc = NULL;
PUTREGISTER pUTRegister = NULL;
PUTUNREGISTER pUTUnRegister = NULL;
FARPROC pfnUT32CBProc = NULL;
int cProcessesAttached = 0;
BOOL fWin32s = FALSE;
HANDLE hKernel32 = 0;
#else
#define EXPORT16 far pascal _export
#define EXPORT32
#endif
#ifndef DLL
static bool get_fox(const char* var, char* val)
{
*val = '\0';
const NTI nti = _NameTableIndex((char*)var);
if (nti >= 0)
{
Locator loc;
if (_FindVar(nti, -1, &loc)) // Find memory variable
{
Value value;
_Load(&loc, &value);
if (value.ev_type == 'C')
{
const char* p = (const char*)_HandToPtr(value.ev_handle);
if (*p > ' ')
strcpy(val, p);
}
}
}
return *val != '\0';
}
#endif
//#ifndef WIN32
static char _tmp[256];
static char* prefname()
{
#ifndef DLL
if (!get_fox("PREFPATH", _tmp))
strcpy(_tmp, "prefix.txt");
return _tmp;
#else
return __prfpth;
#endif
}
static const char* username()
{
#ifndef DLL
if (!get_fox("USER", _tmp))
strcpy(_tmp, "PRASSI");
return _tmp;
#else
return __user;
#endif
}
static const char* tempdir()
{
char user[16];
strncpy(user, username(), 16);
#ifndef DLL
if (!get_fox("TEMPDIR", _tmp))
strcpy(_tmp, "\\tmp");
#else
if (__tmpdir[0] == '\0')
strcpy(_tmp,"\\tmp");
else
strcpy(_tmp,__tmpdir);
#endif
if (access(_tmp,0)!=0)
mkdir(_tmp);
strcat(_tmp, "\\"); strcat(_tmp, user);
if (access(_tmp,0)!=0)
mkdir(_tmp);
return _tmp;
}
static char *CGetPref()
{
const char* p = prefname();
FILE *f = fopen(p, "r");
if (f == NULL)
{
strcpy(cprefix, "");
}
else
{
if (fgets(cprefix, 42, f) != NULL)
{
const int len = strlen(cprefix)-1;
if (len >= 0 && cprefix[len] <= ' ') cprefix[len] = '\0';
}
else
*cprefix = '\0';
fclose(f);
}
{
const char* p = "pathpref.ini";
FILE* f = fopen(p, "r");
if (f != NULL)
{
if (fgets(__ptprf, 42, f) != NULL)
{
const int len = strlen(__ptprf)-1;
if (len >= 0 && __ptprf[len] <= ' ')
{
__ptprf[len] = '\0';
if (len > 0) strcat(__ptprf, "/");
}
}
else
*__ptprf = '\0';
fclose(f);
}
}
if (*__ptprf)
{
char ws[200];
sprintf(ws, "%s%s", __ptprf, cprefix);
strcpy(cprefix, ws);
}
return(cprefix);
}
//#endif // WIN32
#else
extern const char* tempdir();
#endif
#ifdef DBG
#ifdef DLL
#define BREAK __asm \
{ \
int 3h \
}
#else
#define BREAK _BreakPoint()
#endif
#else
#define BREAK
#endif
#ifndef DLL_OR_LIGHT
const int MAXFILE = 128;
TLocalisamfile FAR* file[MAXFILE];
TLocalisamfile FAR* use = NULL;
bool exact = FALSE;
bool old_tab = TRUE;
#endif
#ifndef DLL
///////////////////////////////////////////////////////////
// Foxpro utility functions
///////////////////////////////////////////////////////////
static Value* pop_value(ParamBlk FAR *parm = NULL)
{
static ParamBlk FAR* block = NULL;
static int curr = 0;
if (parm != NULL)
{
block = parm;
curr = 0;
}
#ifdef DBG
if (block == NULL)
{
//fatal_box("Blocco parametri nullo");
return NULL;
}
#endif
return &(block->p[curr++].val);
}
static long pop_int(ParamBlk FAR *pb = NULL)
{
Value* val = pop_value(pb);
long num = 0;
if (val && val->ev_type == 'I')
num = val->ev_long;
return num;
}
static long pop_bool(ParamBlk FAR *pb = NULL)
{
Value* val = pop_value(pb);
bool on = FALSE;
if (val && val->ev_type == 'L')
on = val->ev_length != 0;
return on;
}
static char FAR* pop_str(ParamBlk FAR *pb = NULL)
{
Value* val = pop_value(pb);
char FAR* str = "";
if (val && val->ev_type == 'C')
str = (char*)_HandToPtr(val->ev_handle);
return str;
}
#ifndef LIGHT
static TLocalisamfile* pop_file(ParamBlk FAR *pb)
{
int logicnum = (int)pop_int(pb);
TLocalisamfile* f = NULL;
if (logicnum > 0 && logicnum < MAXFILE)
f = file[logicnum];
else
f = use;
if (f == NULL)
fatal_box("Il file %d non e' aperto", logicnum);
return f;
}
#endif
static int ret_bool(unsigned char b)
{
_RetLogical(b);
return b;
}
static int ret_int(long l)
{
_RetInt(l, 10);
return (int)l;
}
#endif
static int ret_err(int err)
{
if (err > 0) err += 5000;
#ifdef DLL
return err;
#else
return ret_int(err);
#endif
}
#ifndef DLL
static int ret_str(const char* s)
{
_RetChar((char FAR*)s);
return *s;
}
#endif
extern "C" {
///////////////////////////////////////////////////////////
// Setup functions
///////////////////////////////////////////////////////////
int FAR Aga_init()
{
BREAK;
#ifndef DLL_OR_LIGHT
for (int i = 0; i < MAXFILE; i++) file[i] = NULL;
init_global_vars();
#endif
#ifndef WIN32
CGetPref();
#endif
return TRUE;
}
int FAR Aga_exit()
{
#ifndef DLL_OR_LIGHT
for (int i = 0; i < MAXFILE; i++) if (file[i] != NULL)
{
delete file[i];
file[i] = NULL;
}
free_global_vars();
#endif
return TRUE;
}
///////////////////////////////////////////////////////////
// Utility Functions
///////////////////////////////////////////////////////////
#ifdef DLL
EXPORT32 int EXPORT16 Aga_setvar(const char* p, const char* u, const char* t)
{
strcpy(__prfpth,p);
strcpy(__user,u);
strcpy(__tmpdir,t);
CGetPref();
return TRUE;
}
#endif
#ifdef DLL
EXPORT32 int EXPORT16 Aga_wakeup()
#else
int FAR Aga_wakeup(ParamBlk FAR *pb)
#endif
{
const UINT WM_WAKEUP = RegisterWindowMessage("WAKEUP");
SendMessage(HWND_BROADCAST, WM_WAKEUP, 0, 0);
#ifdef DLL
return TRUE;
#else
return ret_bool(TRUE);
#endif
}
#ifdef DLL
#ifdef WIN32
static DWORD SynchSpawn (LPCSTR lpszCmdLine, UINT nCmdShow)
{
DWORD Args[2];
PVOID Translist[2];
Args[0] = (DWORD) lpszCmdLine;
Args[1] = (DWORD) nCmdShow;
Translist[0] = &Args[0];
Translist[1] = NULL;
return ( (* pfnUTProc) ( Args, SYNCHSPAWN, Translist) );
}
#endif
#endif
#ifdef DLL
EXPORT32 int EXPORT16 Aga_exec(const char* p)
#else
int FAR Aga_exec(ParamBlk FAR *pb)
#endif
{
#ifndef WIN32
const word WM_WAKEUP = RegisterWindowMessage("WAKEUP");
#ifndef DLL
const char* p = pop_str(pb);
#endif
const HINSTANCE inst = WinExec(p, SW_SHOW);
const BOOL ok = inst >= 32;
if (ok)
{
HTASK child = NULL;
TASKENTRY te; te.dwSize = sizeof(TASKENTRY);
for (bool ok = TaskFirst(&te); ok && child == NULL; ok = TaskNext(&te))
if (te.hInst == inst)
{
child = te.hTask;
break;
}
BOOL again = TRUE;
MSG msg;
for (byte i = 0; again; i++)
{/* Esegue la TaskFindHandle ogni 256 cicli */
if (i == 0 && ok && TaskFindHandle(&te, child) == FALSE)
break;
while (PeekMessage(&msg, NULL, 0,0, PM_REMOVE) && again)
{
if (msg.message == WM_QUIT ||
(msg.message == WM_WAKEUP && msg.wParam == child))
again=FALSE;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
#ifdef DLL
return ok;
#else
return ret_bool(ok);
#endif
#else
DWORD dwVersion,dwWindowsMajorVersion,dwWindowsMinorVersion;
BOOL is_win32s=FALSE;
dwVersion = GetVersion();
dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
if ( ! (dwVersion < 0x80000000) && (dwWindowsMajorVersion < 4)) // That's Win32s, my dear!
is_win32s = TRUE;
STARTUPINFO StartupInfo= {0};
PROCESS_INFORMATION ProcessInfo;
if (is_win32s) // Oh, Sky's God! That's Win32s!
SynchSpawn(p,SW_SHOWNORMAL);
else // This is Windows NT or Windows95.
{
StartupInfo.cb = sizeof(STARTUPINFO);
if (CreateProcess(NULL,(char*)p,NULL,NULL,FALSE,0,NULL,NULL,&StartupInfo,&ProcessInfo))
{
DWORD result;
MSG msg;
WaitForInputIdle(ProcessInfo.hProcess,INFINITE);
for (BYTE i = 0; ; i++)
{
if (i==0)
{
GetExitCodeProcess(ProcessInfo.hProcess,&result);
if (result != STILL_ACTIVE) break;
}
GetMessage(&msg, (HWND)NULL, 0, 0);
}
}
else
return FALSE;
}
return TRUE;
#endif // WIN32
}
///////////////////////////////////////////////////////////
// ISAM Funtions
///////////////////////////////////////////////////////////
#ifdef DLL
EXPORT32 const char * EXPORT16 Aga_workdir()
#else
int FAR Aga_workdir(ParamBlk FAR *pb)
#endif
{
char park[81];
const int len = strlen(cprefix);
int j=0;
for (int i=0; i<len; i++)
{
char c=cprefix[i];
if (c=='/') c='\\';
if (c=='\\' && j>0 && park[j-1]=='\\') continue;
park[j++] = c;
}
if (park[j-1]=='\\') j--;
park[j]='\0';
strcpy(cprefix,park);
#ifdef DLL
return cprefix;
#else
return ret_str(cprefix);
#endif
}
#ifndef DLL_OR_LIGHT
int FAR Aga_open(ParamBlk FAR *pb)
{
const int logicnum = (int)pop_int(pb);
if (logicnum < 0 || logicnum >= MAXFILE)
return ret_err(81);
if (file[logicnum] != NULL)
return ret_err(222);
TLocalisamfile* f = new TLocalisamfile(logicnum);
if (f == NULL)
return ret_err(81);
file[logicnum] = f;
return ret_err(0);
}
int FAR Aga_opentmp(ParamBlk FAR *pb)
{
const int logicnum = (int)pop_int(pb);
const int create = (int)pop_int();
if (logicnum < 0 || logicnum >= MAXFILE)
return ret_err(81);
if (use != NULL)
return ret_err(222);
// Apre tracciati record!
if (file[logicnum] == NULL)
{
TLocalisamfile* f = new TLocalisamfile(logicnum);
if (f == NULL)
return ret_err(81);
file[logicnum] = f;
}
TString256 t;
t << "%" << tempdir() << "\\tmp" << logicnum;
use = new TIsamtempfile(logicnum, t, create);
if (use == NULL)
return ret_err(81);
return ret_err(0);
}
int FAR Aga_close(ParamBlk FAR *pb)
{
const int logicnum = (int)pop_int(pb);
TLocalisamfile* f = NULL;
if (logicnum > 0)
{
f = file[logicnum];
file[logicnum] = NULL;
}
else
{
f = use;
use = NULL;
}
if (f == NULL)
return ret_err(220);
delete f;
return ret_err(NOERR);
}
int FAR Aga_key(ParamBlk FAR *pb)
{
TLocalisamfile* f = pop_file(pb);
if (f == NULL) return ret_err(220);
const int key = (int)pop_int();
if (key < 1) return ret_err(211);
f->setkey(key);
return ret_err(NOERR);
}
int FAR Aga_zero(ParamBlk FAR *pb)
{
TLocalisamfile* f = pop_file(pb);
if (f == NULL) return ret_err(220);
f->curr().zero();
return ret_err(NOERR);
}
static void put(TLocalisamfile* f, const TString& name, const char* value)
{
int err = NOERR;
if (old_tab && name == "CODTAB")
{
char cod[4];
strncpy(cod, value, 3); cod[3] = '\0';
f->curr().put("COD", cod);
f->curr().put("CODTAB", value+3);
}
else
f->curr().put(name, value);
}
static int get(const TLocalisamfile* f, const TString& name)
{
static char value[80];
if (old_tab && name == "CODTAB")
{
strcpy(value, f->curr().get_str("COD"));
strcat(value, f->curr().get_str(name));
return ret_str(value);
}
return ret_str(f->curr().get_str(name));
}
int FAR Aga_set(ParamBlk FAR *pb)
{
TLocalisamfile* f = pop_file(pb);
if (f == NULL) return ret_err(220);
const TString16 name(pop_str());
const TString256 value(pop_str());
put(f, name, value);
return ret_err(NOERR);
}
int FAR Aga_get(ParamBlk FAR *pb)
{
TLocalisamfile* f = pop_file(pb);
if (f == NULL) return ret_str("");
const TString16 name(pop_str());
return get(f, name);
}
int FAR Aga_exact(ParamBlk FAR *pb)
{
exact = (bool)pop_bool(pb);
return TRUE;
}
int FAR Aga_setopt(ParamBlk FAR *pb)
{
const TFixed_string opt(pop_str(pb));
const long val = pop_int();
bool ok = FALSE;
if (opt == "OLDTAB") { old_tab = (bool)val; ok = TRUE; } else
if (opt == "EXACT") { exact = (bool)val; ok = TRUE; }
return ret_bool(ok);
}
int FAR Aga_getopt(ParamBlk FAR *pb)
{
const TFixed_string opt(pop_str(pb));
long val = 0L;
if (opt == "OLDTAB") { val = old_tab; } else
if (opt == "EXACT") { val = exact; }
return ret_int(val);
}
int FAR Aga_read(ParamBlk FAR *pb)
{
TLocalisamfile* f = pop_file(pb);
if (f == NULL) return ret_err(220);
return ret_err(f->read(exact ? _isequal : _isgteq));
}
int FAR Aga_next(ParamBlk FAR *pb)
{
TLocalisamfile* f = pop_file(pb);
if (f == NULL) return ret_err(220);
return ret_err(f->next());
}
int FAR Aga_prev(ParamBlk FAR *pb)
{
TLocalisamfile* f = pop_file(pb);
if (f == NULL) return ret_err(220);
return ret_err(f->prev());
}
int FAR Aga_write(ParamBlk FAR *pb)
{
TLocalisamfile* f = pop_file(pb);
if (f == NULL) return ret_err(220);
return ret_err(f->write());
}
int FAR Aga_rewrite(ParamBlk FAR *pb)
{
TLocalisamfile* f = pop_file(pb);
if (f == NULL) return ret_err(220);
return ret_err(f->rewrite());
}
int FAR Aga_first(ParamBlk FAR *pb)
{
TLocalisamfile* f = pop_file(pb);
if (f == NULL) return ret_err(220);
return ret_err(f->first());
}
int FAR Aga_last(ParamBlk FAR *pb)
{
TLocalisamfile* f = pop_file(pb);
if (f == NULL) return ret_err(220);
return ret_err(f->last());
}
int FAR Aga_eof(ParamBlk FAR *pb)
{
TLocalisamfile* f = pop_file(pb);
if (f == NULL) return ret_bool(TRUE);
return ret_bool(f->eof());
}
int FAR Aga_bof(ParamBlk FAR *pb)
{
TLocalisamfile* f = pop_file(pb);
if (f == NULL) return ret_bool(FALSE);
return ret_bool(f->bof());
}
int FAR Aga_status(ParamBlk FAR *pb)
{
TLocalisamfile* f = pop_file(pb);
if (f == NULL) return ret_err(220);
return ret_err(f->status());
}
int FAR Aga_lock(ParamBlk FAR *pb)
{
TLocalisamfile* f = pop_file(pb);
if (f == NULL) return ret_err(220);
return ret_err(f->reread(_lock));
}
int FAR Aga_unlock(ParamBlk FAR *pb)
{
TLocalisamfile* f = pop_file(pb);
if (f == NULL) return ret_err(220);
return ret_err(f->reread(_unlock));
}
int FAR Aga_recno(ParamBlk FAR *pb)
{
TLocalisamfile* f = pop_file(pb);
if (f == NULL) return ret_int(-1);
return ret_int(f->recno());
}
int FAR Aga_goto(ParamBlk FAR *pb)
{
TLocalisamfile* f = pop_file(pb);
if (f == NULL) return ret_err(220);
const long n = pop_int();
return ret_err(f->readat(n, _nolock));
}
///////////////////////////////////////////////////////////
// Clipper like funtions
///////////////////////////////////////////////////////////
int FAR Fox_select(ParamBlk FAR *pb)
{
const int logicnum = (int)pop_int(pb);
if (logicnum < 0 || logicnum >= MAXFILE)
return ret_err(81);
if (use) delete use;
use = new TLocalisamfile(logicnum);
return ret_bool(use != NULL);
}
int FAR Fox_unselect(ParamBlk FAR *pb)
{
if (use)
{
delete use;
use = NULL;
return ret_bool(TRUE);
}
return ret_bool(FALSE);
}
int FAR Fox_key(ParamBlk FAR *pb)
{
if (use == NULL) fatal_box("Nessun file selezionato");
int key = (int)pop_int(pb);
if (key > 0) use->setkey(key);
else fatal_box("Numero di chiave errato: %d", key);
return ret_bool(TRUE);
}
int FAR Fox_reset(ParamBlk FAR *pb)
{
if (use == NULL) fatal_box("Nessun file selezionato");
use->curr().zero();
return ret_bool(TRUE);
}
int FAR Fox_set(ParamBlk FAR *pb)
{
if (use == NULL) fatal_box("Nessun file selezionato");
const TString16 name(pop_str(pb));
const TString80 value(pop_str());
put(use, name, value);
return ret_bool(TRUE);
}
int FAR Fox_get(ParamBlk FAR *pb)
{
if (use == NULL) fatal_box("Nessun file selezionato");
const TFixed_string name(pop_str(pb));
return get(use, name);
}
int FAR Fox_show(ParamBlk FAR *pb)
{
if (use == NULL) fatal_box("Nessun file selezionato");
TRectype& r = use->curr();
const char* name;
for (int i = 0; (name = r.fieldname(i)) != NULL; i++)
{
_PutStr((char*)(const char*)r.get_str(name));
_PutChr('\t');
}
return TRUE;
}
int FAR Fox_struct(ParamBlk FAR *pb)
{
if (use == NULL) fatal_box("Nessun file selezionato");
TRectype& r = use->curr();
const char* name = "";
const char* type = "";
char s[80];
for (int i = 0; (name = r.fieldname(i)) != NULL; i++)
{
switch(r.type(name))
{
case _nullfld: type = "NULL"; break;
case _alfafld: type = "CHAR"; break;
case _datefld: type = "DATE"; break;
default : type = "REAL"; break;
}
sprintf(s, "%16s %4s %3d\n", name, type, r.length(name));
_PutStr(s);
}
return TRUE;
}
int FAR Fox_find(ParamBlk FAR *pb)
{
if (use == NULL) fatal_box("Nessun file selezionato");
return ret_bool(use->read(_isgteq) == NOERR);
}
int FAR Fox_skip(ParamBlk FAR *pb)
{
if (use == NULL) fatal_box("Nessun file selezionato");
int skip = (int)pop_int(pb);
if (skip > 0)
{
for (int i = 0; i < skip; i++) use->next();
return ret_bool(!use->eof());
} else
if (skip < 0)
{
for (int i = 0; i > skip; i--) use->prev();
return ret_bool(!use->bof());
}
return ret_bool(TRUE);
}
int FAR Fox_store(ParamBlk FAR *pb)
{
if (use == NULL) fatal_box("Nessun file selezionato");
return ret_bool(use->write() == NOERR);
}
int FAR Fox_eof(ParamBlk FAR *pb)
{
if (use == NULL) fatal_box("Nessun file selezionato");
return ret_bool(use->eof());
}
int FAR Fox_bof(ParamBlk FAR *pb)
{
if (use == NULL) fatal_box("Nessun file selezionato");
return ret_bool(use->bof());
}
#endif
///////////////////////////////////////////////////////////
// Foxpro export tables
///////////////////////////////////////////////////////////
#ifndef DLL
FoxInfo AgaFoxInfo[] =
{
#ifndef LIGHT
{ "A_BOF", (FPFI)Aga_bof, 1, "I" },
{ "A_CLOSE", (FPFI)Aga_close, 1, "I" },
{ "A_EOF", (FPFI)Aga_eof, 1, "I" },
{ "A_EXACT", (FPFI)Aga_exact, 1, "L" },
#endif
{ "A_EXEC", (FPFI)Aga_exec, 1, "C" },
{ "A_EXIT", (FPFI)Aga_exit, CALLONUNLOAD, "" },
#ifndef LIGHT
{ "A_GET", (FPFI)Aga_get, 2, "I,C" },
{ "A_GOTO", (FPFI)Aga_goto, 2, "I,I" },
{ "A_STATUS", (FPFI)Aga_status, 1, "I" },
{ "A_FIRST", (FPFI)Aga_first, 1, "I" },
{ "A_LAST", (FPFI)Aga_last, 1, "I" },
{ "A_KEY", (FPFI)Aga_key, 2, "I,I" },
#endif
{ "A_INIT", (FPFI)Aga_init, CALLONLOAD, "" },
#ifndef LIGHT
{ "A_NEXT", (FPFI)Aga_next, 1, "I" },
{ "A_SETOPT", (FPFI)Aga_setopt, 2, "C,I" },
{ "A_GETOPT", (FPFI)Aga_getopt, 1, "C" },
{ "A_OPEN", (FPFI)Aga_open, 1, "I" },
{ "A_OPENTMP", (FPFI)Aga_opentmp, 2, "I,I" },
{ "A_PREV", (FPFI)Aga_prev, 1, "I" },
{ "A_READ", (FPFI)Aga_read, 1, "I" },
{ "A_SET", (FPFI)Aga_set, 3, "I,C,C" },
#endif
{ "A_WAKEUP", (FPFI)Aga_wakeup, 0, "" },
{ "A_WORKDIR", (FPFI)Aga_workdir, 0, "" },
#ifndef LIGHT
{ "A_WRITE", (FPFI)Aga_write, 1, "I" },
{ "A_RECNO", (FPFI)Aga_recno, 1, "I" },
{ "A_REWRITE", (FPFI)Aga_rewrite, 1, "I" },
{ "A_ZERO", (FPFI)Aga_zero, 1, "I" },
{ "A_LOCK", (FPFI)Aga_lock, 1, "I" },
{ "A_UNLOCK", (FPFI)Aga_unlock, 1, "I" },
{ "F_BOF", (FPFI)Fox_bof, 0, "" },
{ "F_EOF", (FPFI)Fox_eof, 0, "" },
{ "F_FIND", (FPFI)Fox_find, 0, "" },
{ "F_GET", (FPFI)Fox_get, 1, "C" },
{ "F_KEY", (FPFI)Fox_key, 1, "I" },
{ "F_RESET", (FPFI)Fox_reset, 0, "" },
{ "F_SELECT", (FPFI)Fox_select, 1, "I" },
{ "F_UNSELECT",(FPFI)Fox_unselect,0, "" },
{ "F_SET", (FPFI)Fox_set, 2, "C,C" },
{ "F_SHOW", (FPFI)Fox_show, 0, "" },
{ "F_SKIP", (FPFI)Fox_skip, 1, "I" },
{ "F_STORE", (FPFI)Fox_store, 0, "" },
{ "F_STRUCT", (FPFI)Fox_struct, 0, "" },
#endif
};
FoxTable _FoxTable =
{
(FoxTable FAR *)0,
sizeof(AgaFoxInfo)/sizeof(FoxInfo),
AgaFoxInfo
};
#endif
} // extern "C"
#ifdef WIN32
BOOL APIENTRY DllMain(HANDLE hInst, DWORD fdwReason, LPVOID lpReserved)
{
DWORD dwVersion,dwWindowsMajorVersion,dwWindowsMinorVersion;
if (fdwReason == DLL_PROCESS_ATTACH)
{
Aga_init();
if (cProcessesAttached++) // Don't do initilization any more
return TRUE;
dwVersion = GetVersion();
dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
if ( ! (dwVersion < 0x80000000) && (dwWindowsMajorVersion < 4)) // That's Win32s, my dear!
fWin32s = TRUE;
if (!fWin32s) // Esegue le pazzie che seguono (per il thunking) solo se siamo in Win32s
return (TRUE);
#ifdef DBG
MessageBox(GetFocus(),"Loading thunking to AGA32(1)","AGA32", MB_OK | MB_ICONINFORMATION);
#endif
hKernel32 = LoadLibrary("Kernel32.Dll");
pUTRegister = (PUTREGISTER) GetProcAddress(hKernel32, "UTRegister");
#ifdef DBG
MessageBox(GetFocus(),"Loading thunking to AGA32(2)","AGA32", MB_OK | MB_ICONINFORMATION);
#endif
if (!pUTRegister)
return (FALSE);
pUTUnRegister = (PUTUNREGISTER) GetProcAddress(hKernel32,"UTUnRegister");
#ifdef DBG
MessageBox(GetFocus(),"Loading thunking to AGA32(3)","AGA32", MB_OK | MB_ICONINFORMATION);
#endif
if (!pUTUnRegister)
return (FALSE);
#ifdef DBG
MessageBox(GetFocus(),"Loading thunking to AGA32(4)","AGA32", MB_OK | MB_ICONINFORMATION);
#endif
return (*pUTRegister) (hInst, // AGA32.DLL module handle
"AGA16.DLL", // 16 bit thunk dll
"UTInit", // Init routine
"UTProc", // 16 bit dispatch routine
&pfnUTProc, // Receives thunk address
pfnUT32CBProc, // Call-back function
NULL); // no shared memory
}
else
if (fdwReason == DLL_PROCESS_DETACH)
{
Aga_exit();
if ((0 == --cProcessesAttached) && fWin32s) // is Win32s ?
{
(*pUTUnRegister) (hInst); // if so, free the library loaded
FreeLibrary(hKernel32);
}
}
return (TRUE);
}
#endif
#ifdef DLL
#ifndef WIN32
int CALLBACK LibMain (HINSTANCE hinst, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine)
{
return Aga_init();
}
int CALLBACK WEP (int nExitType)
{
if (nExitType == WEP_FREE_DLL)
Aga_exit();
return 1;
}
#endif
#endif