Corretti alcuni errori inerenti i lock, e la gestione dei campi booleani.
git-svn-id: svn://10.65.10.50/trunk@1548 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
2fbfb0a6b5
commit
d4e8e2d49e
427
include/codeb.c
427
include/codeb.c
@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
Attenzione!. Per costruire la DLL accertarsi che siano attivati i seguenti switch:
|
Attenzione!. Per costruire la DLL accertarsi che siano attivati i seguenti switch:
|
||||||
1) S4DLL_BUILD definito da command line del compilatore
|
1) S4DLL_BUILD definito da command line del compilatore
|
||||||
2) Uno solo tra S4FOX S4CLIPPER S4NDX e S4MDX, definito in d4all.h
|
2) Uno solo tra S4FOX S4CLIPPER S4NDX e S4MDX, definito in d4all.h
|
||||||
|
|
||||||
Gli altri switch di configurazione generale sono a piacere (S4DEBUG, S4ERROR_HOOK, ecc.)
|
Gli altri switch di configurazione generale sono a piacere (S4DEBUG, S4ERROR_HOOK, ecc.)
|
||||||
|
|
||||||
Per costruire WINUNO.LIB Accertarsi che d4all.h non abbia definito S4DLL o S4UNIX,
|
Per costruire WINUNO.LIB Accertarsi che d4all.h non abbia definito S4DLL o S4UNIX,
|
||||||
e tanto meno S4DLL_BUILD, altrimenti per costruire la library di UNIX e' necessario
|
e tanto meno S4DLL_BUILD, altrimenti per costruire la library di UNIX e' necessario
|
||||||
cambiare ogni volta. La definizione di tali simboli avviene qui dentro.
|
cambiare ogni volta. La definizione di tali simboli avviene qui dentro.
|
||||||
Inoltre deve essere attivo uno solo degli switch di selezione formato database
|
Inoltre deve essere attivo uno solo degli switch di selezione formato database
|
||||||
(S4FOX, S4MDX ecc.); nel caso si faccia uso della DLL non importa quale si e' definito.
|
(S4FOX, S4MDX ecc.); nel caso si faccia uso della DLL non importa quale si e' definito.
|
||||||
E' importante solo in caso di utilizzo di una static Library.
|
E' importante solo in caso di utilizzo di una static Library.
|
||||||
|
|
||||||
Per costruire l'aga.fll e' necessario togliere le funzioni progind* e definire S4DLL.
|
Per costruire l'aga.fll e' necessario togliere le funzioni progind* e definire S4DLL.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
#if XVT_OS == XVT_OS_SCOUNIX
|
#if XVT_OS == XVT_OS_SCOUNIX
|
||||||
#define S4UNIX
|
#define S4UNIX
|
||||||
#else
|
#else
|
||||||
@ -48,17 +48,17 @@ static X4FILTER xdb[CB4FILES];
|
|||||||
|
|
||||||
static char * find_slash_backslash(char * str)
|
static char * find_slash_backslash(char * str)
|
||||||
{
|
{
|
||||||
int l=strlen(str);
|
int l=strlen(str);
|
||||||
static char * xstr ;
|
static char * xstr ;
|
||||||
xstr = str + l;
|
xstr = str + l;
|
||||||
|
|
||||||
while (xstr-- && l--)
|
while (xstr-- && l--)
|
||||||
if (*xstr == '\\' || *xstr == '/')
|
if (*xstr == '\\' || *xstr == '/')
|
||||||
break;
|
break;
|
||||||
if (l == 0)
|
if (l == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
else
|
else
|
||||||
return xstr;
|
return xstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ void DB_init(void)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0;i<CB4FILES;i++) {
|
for(i=0;i<CB4FILES;i++) {
|
||||||
dbdata[i]=(DATA4 *) 0;
|
dbdata[i]=(DATA4 *) 0;
|
||||||
}
|
}
|
||||||
d4init(&code_base);
|
d4init(&code_base);
|
||||||
code_base.read_lock=0;
|
code_base.read_lock=0;
|
||||||
@ -114,10 +114,10 @@ int DB_open(const char *filename,int mode)
|
|||||||
// cerca il primo posto libero nel vettore dbdata
|
// cerca il primo posto libero nel vettore dbdata
|
||||||
found=-1;
|
found=-1;
|
||||||
for(i=0;i<CB4FILES;i++) {
|
for(i=0;i<CB4FILES;i++) {
|
||||||
if(dbdata[i]==(DATA4 *) 0) {
|
if(dbdata[i]==(DATA4 *) 0) {
|
||||||
found=i;
|
found=i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// se non ci sono posti liberi torna -1
|
// se non ci sono posti liberi torna -1
|
||||||
if(found==-1) return(found);
|
if(found==-1) return(found);
|
||||||
@ -128,7 +128,7 @@ int DB_open(const char *filename,int mode)
|
|||||||
code_base.exclusive=0;
|
code_base.exclusive=0;
|
||||||
d4tag_select(dbdata[found],d4tag_default(dbdata[found]));
|
d4tag_select(dbdata[found],d4tag_default(dbdata[found]));
|
||||||
if (d4reccount(dbdata[found]) > 0)
|
if (d4reccount(dbdata[found]) > 0)
|
||||||
x4top(&xdb[found]);
|
x4top(&xdb[found]);
|
||||||
return(found);
|
return(found);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,8 +210,8 @@ int DB_tagselect(int handle,int index_no)
|
|||||||
tt=d4tag_next(dbdata[handle],NULL);
|
tt=d4tag_next(dbdata[handle],NULL);
|
||||||
if(tt==NULL) return(-1);
|
if(tt==NULL) return(-1);
|
||||||
for(i=1;i<index_no;i++) {
|
for(i=1;i<index_no;i++) {
|
||||||
tt=d4tag_next(dbdata[handle],tt);
|
tt=d4tag_next(dbdata[handle],tt);
|
||||||
if(tt==NULL) return(-1);
|
if(tt==NULL) return(-1);
|
||||||
}
|
}
|
||||||
d4tag_select(dbdata[handle],tt);
|
d4tag_select(dbdata[handle],tt);
|
||||||
return(0);
|
return(0);
|
||||||
@ -235,8 +235,8 @@ int DB_tagget(int handle)
|
|||||||
tt1=d4tag_next(dbdata[handle],NULL);
|
tt1=d4tag_next(dbdata[handle],NULL);
|
||||||
i=1;
|
i=1;
|
||||||
while(tt!=tt1 && tt1!=NULL) {
|
while(tt!=tt1 && tt1!=NULL) {
|
||||||
tt1=d4tag_next(dbdata[handle],tt1);
|
tt1=d4tag_next(dbdata[handle],tt1);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return(i);
|
return(i);
|
||||||
}
|
}
|
||||||
@ -297,8 +297,7 @@ int DB_skip(int handle,long int recno)
|
|||||||
int DB_lock(int handle)
|
int DB_lock(int handle)
|
||||||
{
|
{
|
||||||
if(dbdata[handle]==0) return(-1);
|
if(dbdata[handle]==0) return(-1);
|
||||||
if(d4lock(dbdata[handle],d4recno(dbdata[handle]))==r4locked) return(-1);
|
return(d4lock(dbdata[handle],d4recno(dbdata[handle])));
|
||||||
else return(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
@ -384,14 +383,14 @@ int DB_delkey(int handle, char* key, long recno)
|
|||||||
t=d4tag_default(dbdata[handle]);
|
t=d4tag_default(dbdata[handle]);
|
||||||
|
|
||||||
if (u4switch() & 2 || u4switch() & 8) // Clipper & DBIII
|
if (u4switch() & 2 || u4switch() & 8) // Clipper & DBIII
|
||||||
u4name_piece(fn,32,dbdata[handle]->file.name,0,0);
|
u4name_piece(fn,32,dbdata[handle]->file.name,0,0);
|
||||||
else
|
else
|
||||||
strcpy(fn,dbdata[handle]->file.name);
|
strcpy(fn,dbdata[handle]->file.name);
|
||||||
if ((i=d4index(dbdata[handle],fn)) == NULL)
|
if ((i=d4index(dbdata[handle],fn)) == NULL)
|
||||||
return(e4index);
|
return(e4index);
|
||||||
rt=i4lock(i);
|
rt=i4lock(i);
|
||||||
if (rt == 0)
|
if (rt == 0)
|
||||||
rt=t4remove_calc(t,recno);
|
rt=t4remove_calc(t,recno);
|
||||||
i4unlock(i);
|
i4unlock(i);
|
||||||
return(rt);
|
return(rt);
|
||||||
}
|
}
|
||||||
@ -435,9 +434,9 @@ HIDDEN int is_inkey(RecDes *r, int numfield)
|
|||||||
int found=0,i,j;
|
int found=0,i,j;
|
||||||
|
|
||||||
for (i=0; ((i < MaxKeys) && (i < r->NKeys) && !found); i++)
|
for (i=0; ((i < MaxKeys) && (i < r->NKeys) && !found); i++)
|
||||||
for (j=0; ((j < r->Ky[i].NkFields) && !found); j++)
|
for (j=0; ((j < r->Ky[i].NkFields) && !found); j++)
|
||||||
if (numfield == r->Ky[i].FieldSeq[j])
|
if (numfield == r->Ky[i].FieldSeq[j])
|
||||||
found=1;
|
found=1;
|
||||||
return(found);
|
return(found);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,95 +449,95 @@ HIDDEN void do_key(char *fname, RecDes *r, TAG4INFO *tag_info)
|
|||||||
CUpString(tiname);
|
CUpString(tiname);
|
||||||
for (i=0; ((i < MaxKeys) && (i < r->NKeys)); i++)
|
for (i=0; ((i < MaxKeys) && (i < r->NKeys)); i++)
|
||||||
{
|
{
|
||||||
tag_info[i].name=(char *)u4alloc(9);
|
tag_info[i].name=(char *)u4alloc(9);
|
||||||
tag_info[i].expression=(char *)u4alloc(128);
|
tag_info[i].expression=(char *)u4alloc(128);
|
||||||
tag_info[i].filter=(char*)u4alloc(20);
|
tag_info[i].filter=(char*)u4alloc(20);
|
||||||
tag_info[i].descending=0;
|
tag_info[i].descending=0;
|
||||||
if (r->Ky[i].DupKeys)
|
if (r->Ky[i].DupKeys)
|
||||||
tag_info[i].unique=0;
|
tag_info[i].unique=0;
|
||||||
else
|
else
|
||||||
tag_info[i].unique=e4unique;
|
tag_info[i].unique=e4unique;
|
||||||
strcpy(tag_info[i].filter,""); // Not available for DBIII and CLIPPER
|
strcpy(tag_info[i].filter,""); // Not available for DBIII and CLIPPER
|
||||||
strcpy(tag_info[i].name,tiname) ;
|
strcpy(tag_info[i].name,tiname) ;
|
||||||
if (strlen(tiname) < 8)
|
if (strlen(tiname) < 8)
|
||||||
strcat(tag_info[i].name," ");
|
strcat(tag_info[i].name," ");
|
||||||
tag_info[i].name[strlen(tag_info[i].name)-1] = '0' + i + 1;
|
tag_info[i].name[strlen(tag_info[i].name)-1] = '0' + i + 1;
|
||||||
for (j=0; j < r->Ky[i].NkFields; j++)
|
for (j=0; j < r->Ky[i].NkFields; j++)
|
||||||
{
|
{
|
||||||
int nf= r->Ky[i].FieldSeq[j];
|
int nf= r->Ky[i].FieldSeq[j];
|
||||||
if (nf > MaxFields) // When Upper field is specified
|
if (nf > MaxFields) // When Upper field is specified
|
||||||
{
|
{
|
||||||
nf -= MaxFields;
|
nf -= MaxFields;
|
||||||
strcat(tag_info[i].expression,"UPPER(");
|
strcat(tag_info[i].expression,"UPPER(");
|
||||||
}
|
}
|
||||||
if (r->Ky[i].FromCh[j] != 255) // When partial field is specified
|
if (r->Ky[i].FromCh[j] != 255) // When partial field is specified
|
||||||
strcat(tag_info[i].expression,"SUBSTR(");
|
strcat(tag_info[i].expression,"SUBSTR(");
|
||||||
|
|
||||||
switch (r->Fd[nf].TypeF) // When numeric field in key is specified
|
switch (r->Fd[nf].TypeF) // When numeric field in key is specified
|
||||||
{
|
{
|
||||||
case _intfld:
|
case _intfld:
|
||||||
case _longfld:
|
case _longfld:
|
||||||
case _realfld:
|
case _realfld:
|
||||||
case _wordfld:
|
case _wordfld:
|
||||||
case _intzerofld:
|
case _intzerofld:
|
||||||
case _longzerofld:
|
case _longzerofld:
|
||||||
strcat(tag_info[i].expression,"STR(");
|
strcat(tag_info[i].expression,"STR(");
|
||||||
break;
|
break;
|
||||||
case _datefld:
|
case _datefld:
|
||||||
strcat(tag_info[i].expression,"DTOS(");
|
strcat(tag_info[i].expression,"DTOS(");
|
||||||
break;
|
break;
|
||||||
case _boolfld:
|
case _boolfld:
|
||||||
strcat(tag_info[i].expression,"IIF("); // Logical fields are in key too...
|
strcat(tag_info[i].expression,"IIF("); // Logical fields are in key too...
|
||||||
break;
|
break;
|
||||||
default: // It's a non sense to keep _realfld in key...
|
default: // It's a non sense to keep _realfld in key...
|
||||||
break; // however it's possible to have it...
|
break; // however it's possible to have it...
|
||||||
} // Le chiavi composte da campi data non necessitano di funzioni di traduzione.
|
} // Le chiavi composte da campi data non necessitano di funzioni di traduzione.
|
||||||
|
|
||||||
strcat(tag_info[i].expression,r->Fd[nf].Name); // Append field name
|
strcat(tag_info[i].expression,r->Fd[nf].Name); // Append field name
|
||||||
|
|
||||||
if (r->Ky[i].FromCh[j] != 255) // If partial field was specified
|
if (r->Ky[i].FromCh[j] != 255) // If partial field was specified
|
||||||
{ // add parameters to SUBSTR
|
{ // add parameters to SUBSTR
|
||||||
char ts[8];
|
char ts[8];
|
||||||
|
|
||||||
strcat(tag_info[i].expression,",");
|
strcat(tag_info[i].expression,",");
|
||||||
sprintf(ts,"%d",r->Ky[i].FromCh[j]);
|
sprintf(ts,"%d",r->Ky[i].FromCh[j]);
|
||||||
strcat(tag_info[i].expression,ts);
|
strcat(tag_info[i].expression,ts);
|
||||||
strcat(tag_info[i].expression,",");
|
strcat(tag_info[i].expression,",");
|
||||||
sprintf(ts,"%d",r->Ky[i].ToCh[j] - r->Ky[i].FromCh[j] + 1);
|
sprintf(ts,"%d",r->Ky[i].ToCh[j] - r->Ky[i].FromCh[j] + 1);
|
||||||
strcat(tag_info[i].expression,ts);
|
strcat(tag_info[i].expression,ts);
|
||||||
strcat(tag_info[i].expression,")");
|
strcat(tag_info[i].expression,")");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (r->Fd[nf].TypeF) // If numeric field was specified
|
switch (r->Fd[nf].TypeF) // If numeric field was specified
|
||||||
{ // add parameters to STR
|
{ // add parameters to STR
|
||||||
case _intfld:
|
case _intfld:
|
||||||
case _longfld:
|
case _longfld:
|
||||||
case _realfld: // Questo tipo di campo(real) non ha senso in un a chiave...
|
case _realfld: // Questo tipo di campo(real) non ha senso in un a chiave...
|
||||||
case _wordfld:
|
case _wordfld:
|
||||||
case _intzerofld:
|
case _intzerofld:
|
||||||
case _longzerofld:
|
case _longzerofld:
|
||||||
{
|
{
|
||||||
char ts[8];
|
char ts[8];
|
||||||
strcat(tag_info[i].expression,",");
|
strcat(tag_info[i].expression,",");
|
||||||
sprintf(ts,"%d",r->Fd[nf].Len);
|
sprintf(ts,"%d",r->Fd[nf].Len);
|
||||||
strcat(tag_info[i].expression,ts);
|
strcat(tag_info[i].expression,ts);
|
||||||
strcat(tag_info[i].expression,",0)");
|
strcat(tag_info[i].expression,",0)");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case _boolfld: // Orgssbb... Che culo.
|
case _boolfld: // Orgssbb... Che culo.
|
||||||
strcat(tag_info[i].expression,",\"T\",\"F\")");
|
strcat(tag_info[i].expression,",\"T\",\"F\")");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close parentheses if UPPER or DTOS operators were used:
|
// Close parentheses if UPPER or DTOS operators were used:
|
||||||
if (r->Ky[i].FieldSeq[j] > MaxFields || (r->Fd[nf].TypeF == _datefld))
|
if (r->Ky[i].FieldSeq[j] > MaxFields || (r->Fd[nf].TypeF == _datefld))
|
||||||
strcat(tag_info[i].expression,")");
|
strcat(tag_info[i].expression,")");
|
||||||
// If there's another field in key adds "+" operator:
|
// If there's another field in key adds "+" operator:
|
||||||
if (j < (r->Ky[i].NkFields-1))
|
if (j < (r->Ky[i].NkFields-1))
|
||||||
strcat(tag_info[i].expression,"+");
|
strcat(tag_info[i].expression,"+");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tag_info[i].name=NULL;
|
tag_info[i].name=NULL;
|
||||||
tag_info[i].expression=NULL;
|
tag_info[i].expression=NULL;
|
||||||
@ -560,32 +559,32 @@ int DB_packfile(short vis, const char * filename, long eod)
|
|||||||
handle=DB_open(filename,1); // Exclusive mode open!
|
handle=DB_open(filename,1); // Exclusive mode open!
|
||||||
if (handle > -1)
|
if (handle > -1)
|
||||||
{
|
{
|
||||||
char s[81];
|
char s[81];
|
||||||
|
|
||||||
if (vis)
|
if (vis)
|
||||||
{
|
{
|
||||||
strcpy(s,"Compattamento dati file : ");
|
strcpy(s,"Compattamento dati file : ");
|
||||||
strcat(s,(char*)filename);
|
strcat(s,(char*)filename);
|
||||||
#ifndef FOXPRO
|
#ifndef FOXPRO
|
||||||
progind_create(10L,s,1,1,1);
|
progind_create(10L,s,1,1,1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (eod < d4reccount(dbdata[handle]))
|
if (eod < d4reccount(dbdata[handle]))
|
||||||
{
|
{
|
||||||
rt=d4zap(dbdata[handle],++eod,d4reccount(dbdata[handle]));
|
rt=d4zap(dbdata[handle],++eod,d4reccount(dbdata[handle]));
|
||||||
} else
|
} else
|
||||||
rt=d4pack(dbdata[handle]);
|
rt=d4pack(dbdata[handle]);
|
||||||
if (vis)
|
if (vis)
|
||||||
{
|
{
|
||||||
#ifndef FOXPRO
|
#ifndef FOXPRO
|
||||||
progind_set_status((long)10);
|
progind_set_status((long)10);
|
||||||
progind_destroy();
|
progind_destroy();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
DB_close(handle);
|
DB_close(handle);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
rt=code_base.error_code;
|
rt=code_base.error_code;
|
||||||
code_base.auto_open = 1;
|
code_base.auto_open = 1;
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
@ -607,63 +606,63 @@ int DB_packindex(short vis, const char * filename, RecDes *r, long *peod)
|
|||||||
handle=DB_open(filename,1); // Exclusive mode open
|
handle=DB_open(filename,1); // Exclusive mode open
|
||||||
if (handle > -1)
|
if (handle > -1)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *ff = find_slash_backslash((char *)filename);
|
char *ff = find_slash_backslash((char *)filename);
|
||||||
if (vis)
|
if (vis)
|
||||||
{
|
{
|
||||||
#ifndef FOXPRO
|
#ifndef FOXPRO
|
||||||
progind_create((long)r->NKeys,s,1,1,1);
|
progind_create((long)r->NKeys,s,1,1,1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (ff == NULL || *ff == NULL)
|
if (ff == NULL || *ff == NULL)
|
||||||
ff = filename;
|
ff = filename;
|
||||||
else
|
else
|
||||||
ff++;
|
ff++;
|
||||||
do_key(ff,r,tags);
|
do_key(ff,r,tags);
|
||||||
if (u4switch() &2 || u4switch() & 8) // Clipper and DBIII
|
if (u4switch() &2 || u4switch() & 8) // Clipper and DBIII
|
||||||
{
|
{
|
||||||
rt = (int)i4create(dbdata[handle],(char*)filename,tags);
|
rt = (int)i4create(dbdata[handle],(char*)filename,tags);
|
||||||
#ifndef FOXPRO
|
#ifndef FOXPRO
|
||||||
progind_set_status((long)r->NKeys);
|
progind_set_status((long)r->NKeys);
|
||||||
#endif
|
#endif
|
||||||
if (rt!=0 && code_base.error_code==0)
|
if (rt!=0 && code_base.error_code==0)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char cgp[81];
|
char cgp[81];
|
||||||
|
|
||||||
strcpy(cgp,filename);
|
strcpy(cgp,filename);
|
||||||
strcat(cgp,".CGP");
|
strcat(cgp,".CGP");
|
||||||
if ((fp=fopen(cgp,"w"))!=NULL)
|
if ((fp=fopen(cgp,"w"))!=NULL)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
for (j=0; j<r->NKeys;j++)
|
for (j=0; j<r->NKeys;j++)
|
||||||
fprintf(fp,"%s\n",tags[j].name);
|
fprintf(fp,"%s\n",tags[j].name);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (u4switch() & 1 || u4switch() & 4) // FOXPRO and DBIV
|
if (u4switch() & 1 || u4switch() & 4) // FOXPRO and DBIV
|
||||||
{
|
{
|
||||||
rt = (int)i4create(dbdata[handle],NULL,tags);
|
rt = (int)i4create(dbdata[handle],NULL,tags);
|
||||||
#ifndef FOXPRO
|
#ifndef FOXPRO
|
||||||
progind_set_status((long)r->NKeys);
|
progind_set_status((long)r->NKeys);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
for (i=0; ((i < MaxKeys) && (i < r->NKeys)); i++)
|
for (i=0; ((i < MaxKeys) && (i < r->NKeys)); i++)
|
||||||
{
|
{
|
||||||
u4free(tags[i].name);
|
u4free(tags[i].name);
|
||||||
u4free(tags[i].expression);
|
u4free(tags[i].expression);
|
||||||
u4free(tags[i].filter);
|
u4free(tags[i].filter);
|
||||||
}
|
}
|
||||||
if (vis)
|
if (vis)
|
||||||
{
|
{
|
||||||
#ifndef FOXPRO
|
#ifndef FOXPRO
|
||||||
progind_destroy();
|
progind_destroy();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
*peod=DB_reccount(handle);
|
*peod=DB_reccount(handle);
|
||||||
DB_close(handle);
|
DB_close(handle);
|
||||||
}
|
}
|
||||||
code_base.auto_open = 1;
|
code_base.auto_open = 1;
|
||||||
return(code_base.error_code);
|
return(code_base.error_code);
|
||||||
@ -692,24 +691,24 @@ int DB_build(const char * filename, RecDes *r)
|
|||||||
field_info[i].dec = r->Fd[i].Dec;
|
field_info[i].dec = r->Fd[i].Dec;
|
||||||
switch (r->Fd[i].TypeF)
|
switch (r->Fd[i].TypeF)
|
||||||
{
|
{
|
||||||
case _intfld:
|
case _intfld:
|
||||||
case _longfld:
|
case _longfld:
|
||||||
case _realfld: // It's a non sense to keep this in key!
|
case _realfld: // It's a non sense to keep this in key!
|
||||||
case _wordfld:
|
case _wordfld:
|
||||||
case _intzerofld:
|
case _intzerofld:
|
||||||
case _longzerofld:
|
case _longzerofld:
|
||||||
field_info[i].type=r4num;
|
field_info[i].type=r4num;
|
||||||
break;
|
break;
|
||||||
case _boolfld:
|
case _boolfld:
|
||||||
field_info[i].type=r4log;
|
field_info[i].type=r4log;
|
||||||
break;
|
break;
|
||||||
case _datefld:
|
case _datefld:
|
||||||
field_info[i].type=r4date;
|
field_info[i].type=r4date;
|
||||||
break;
|
break;
|
||||||
case _charfld:
|
case _charfld:
|
||||||
default:
|
default:
|
||||||
field_info[i].type=r4str;
|
field_info[i].type=r4str;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
field_info[i].name=NULL;
|
field_info[i].name=NULL;
|
||||||
@ -726,7 +725,7 @@ int DB_build(const char * filename, RecDes *r)
|
|||||||
if ((dbuilded=d4create(&code_base, (char *)filename, field_info, tag_info))==0) // deve solo creare il file dati vuoto
|
if ((dbuilded=d4create(&code_base, (char *)filename, field_info, tag_info))==0) // deve solo creare il file dati vuoto
|
||||||
rt=code_base.error_code;
|
rt=code_base.error_code;
|
||||||
else
|
else
|
||||||
rt=d4close(dbuilded);
|
rt=d4close(dbuilded);
|
||||||
if (u4switch() & 2 || u4switch() & 8) // Rebuild filename.cgp for CLIPPER AND DBIII only
|
if (u4switch() & 2 || u4switch() & 8) // Rebuild filename.cgp for CLIPPER AND DBIII only
|
||||||
{
|
{
|
||||||
FILE* fp;
|
FILE* fp;
|
||||||
@ -762,9 +761,9 @@ int DB_build(const char * filename, RecDes *r)
|
|||||||
|
|
||||||
int DB_get_error(void)
|
int DB_get_error(void)
|
||||||
{
|
{
|
||||||
int rt = code_base.error_code;
|
int rt = code_base.error_code;
|
||||||
code_base.error_code=0;
|
code_base.error_code=0;
|
||||||
return (rt);
|
return (rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
@ -773,7 +772,7 @@ int DB_get_error(void)
|
|||||||
|
|
||||||
void DB_zero_error(void)
|
void DB_zero_error(void)
|
||||||
{
|
{
|
||||||
code_base.error_code=0;
|
code_base.error_code=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
@ -904,9 +903,9 @@ long DB_changed(int handle)
|
|||||||
|
|
||||||
if(dbdata[handle]==0) return(-1);
|
if(dbdata[handle]==0) return(-1);
|
||||||
if (u4switch() & 2 || u4switch() & 8) // Clipper & DBIII
|
if (u4switch() & 2 || u4switch() & 8) // Clipper & DBIII
|
||||||
u4name_piece(fn,32,dbdata[handle]->file.name,0,0);
|
u4name_piece(fn,32,dbdata[handle]->file.name,0,0);
|
||||||
else
|
else
|
||||||
strcpy(fn,dbdata[handle]->file.name);
|
strcpy(fn,dbdata[handle]->file.name);
|
||||||
i=d4index(dbdata[handle],fn);
|
i=d4index(dbdata[handle],fn);
|
||||||
if (i == NULL) return(-1);
|
if (i == NULL) return(-1);
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
CODEBASE.H
|
CODEBASE.H
|
||||||
data : 23.01.95
|
data : 23.01.95
|
||||||
scopo: interfaccia verso CodeBase 5.0
|
scopo: interfaccia verso CodeBase 5.0
|
||||||
--------------------------------------------------------------------------*/
|
--------------------------------------------------------------------------*/
|
||||||
#ifndef __CODEBASE_H
|
#ifndef __CODEBASE_H
|
||||||
#define __CODEBASE_H
|
#define __CODEBASE_H
|
||||||
|
|
||||||
@ -12,59 +12,59 @@
|
|||||||
|
|
||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
numero massimo di database aperti contemporaneamente
|
numero massimo di database aperti contemporaneamente
|
||||||
--------------------------------------------------------------------------*/
|
--------------------------------------------------------------------------*/
|
||||||
#define CB4FILES 50
|
#define CB4FILES 50
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
prototipi funzioni
|
prototipi funzioni
|
||||||
--------------------------------------------------------------------------*/
|
--------------------------------------------------------------------------*/
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
void DB_init(void);
|
void DB_init(void);
|
||||||
void DB_exit(void);
|
void DB_exit(void);
|
||||||
int DB_open(const char *filename,int mode);
|
int DB_open(const char *filename,int mode);
|
||||||
int DB_close(int handle);
|
int DB_close(int handle);
|
||||||
char *DB_getrecord(int handle);
|
char *DB_getrecord(int handle);
|
||||||
int DB_reclen(int handle);
|
int DB_reclen(int handle);
|
||||||
int DB_keylen(int handle);
|
int DB_keylen(int handle);
|
||||||
long int DB_recno(int handle);
|
long int DB_recno(int handle);
|
||||||
long int DB_reccount(int handle);
|
long int DB_reccount(int handle);
|
||||||
int DB_tagselect(int handle,int index_no);
|
int DB_tagselect(int handle,int index_no);
|
||||||
int DB_tagget(int handle);
|
int DB_tagget(int handle);
|
||||||
int DB_first(int handle);
|
int DB_first(int handle);
|
||||||
int DB_last(int handle);
|
int DB_last(int handle);
|
||||||
int DB_next(int handle);
|
int DB_next(int handle);
|
||||||
int DB_prev(int handle);
|
int DB_prev(int handle);
|
||||||
int DB_skip(int handle,long int recno);
|
int DB_skip(int handle,long int recno);
|
||||||
int DB_lock(int handle);
|
int DB_lock(int handle);
|
||||||
int DB_lockrec(int handle, long recno); // Per sbloccare il record basta la DB_unlock()
|
int DB_lockrec(int handle, long recno); // Per sbloccare il record basta la DB_unlock()
|
||||||
int DB_unlock(int handle);
|
int DB_unlock(int handle);
|
||||||
int DB_seek(int handle,char *key);
|
int DB_seek(int handle,char *key);
|
||||||
int DB_eof(int handle);
|
int DB_eof(int handle);
|
||||||
int DB_bof(int handle);
|
int DB_bof(int handle);
|
||||||
int DB_go(int handle,long int recno);
|
int DB_go(int handle,long int recno);
|
||||||
int DB_delete(int handle);
|
int DB_delete(int handle);
|
||||||
int DB_recall(int handle);
|
int DB_recall(int handle);
|
||||||
int DB_delkey(int handle, char* key, long recno);
|
int DB_delkey(int handle, char* key, long recno);
|
||||||
int DB_rewrite(int handle);
|
int DB_rewrite(int handle);
|
||||||
int DB_add(int handle);
|
int DB_add(int handle);
|
||||||
int DB_lockfile(int handle); // Per sbloccare il file basta la DB_unlock()
|
int DB_lockfile(int handle); // Per sbloccare il file basta la DB_unlock()
|
||||||
int DB_packfile(short vis, const char * filename, long eod);
|
int DB_packfile(short vis, const char * filename, long eod);
|
||||||
int DB_packindex(short vis, const char * filename, RecDes *r, long *peod );
|
int DB_packindex(short vis, const char * filename, RecDes *r, long *peod );
|
||||||
int DB_build(const char * filename, RecDes *r);
|
int DB_build(const char * filename, RecDes *r);
|
||||||
int DB_get_error(void);
|
int DB_get_error(void);
|
||||||
void DB_zero_error(void);
|
void DB_zero_error(void);
|
||||||
int DB_index_seek(int handle, char* from);
|
int DB_index_seek(int handle, char* from);
|
||||||
long DB_index_recno(int handle);
|
long DB_index_recno(int handle);
|
||||||
long DB_index_next(int handle);
|
long DB_index_next(int handle);
|
||||||
char* DB_index_getkey(int handle);
|
char* DB_index_getkey(int handle);
|
||||||
int DB_index_eof(int handle);
|
int DB_index_eof(int handle);
|
||||||
int DB_lock_rec(int handle,long nrec);
|
int DB_lock_rec(int handle,long nrec);
|
||||||
int DB_file_locked(int handle);
|
int DB_file_locked(int handle);
|
||||||
int DB_rec_locked(int handle,long nrec);
|
int DB_rec_locked(int handle,long nrec);
|
||||||
long DB_getconf();
|
long DB_getconf();
|
||||||
long DB_changed(int handle); // returns true if the index of the key is changed
|
long DB_changed(int handle); // returns true if the index of the key is changed
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -300,17 +300,18 @@ HIDDEN int cisread(isfdptr isfd, TRectype & record, int mode)
|
|||||||
}
|
}
|
||||||
if (rmode != _isequal && err == _iseof)
|
if (rmode != _isequal && err == _iseof)
|
||||||
DB_last(isfd->fhnd);
|
DB_last(isfd->fhnd);
|
||||||
|
if (err == NOERR && (lmode == _lock || lmode == _testandlock)) // _lock e _testandlock
|
||||||
|
{
|
||||||
|
err=DB_lock(isfd->fhnd);
|
||||||
|
if (err != NOERR) err=get_error(err);
|
||||||
|
if (err == _islocked && lmode == _testandlock) break;
|
||||||
|
}
|
||||||
if (!tlock && err == _islocked)
|
if (!tlock && err == _islocked)
|
||||||
{
|
{
|
||||||
CBuildKey(isfd->r, DB_tagget(isfd->fhnd), record.string(), key);
|
CBuildKey(isfd->r, DB_tagget(isfd->fhnd), record.string(), key);
|
||||||
message_box("Codice %s in uso da parte\ndi un altro utente.", key);
|
message_box("Codice %s in uso da parte\ndi un altro utente.", key);
|
||||||
}
|
}
|
||||||
} while (!tlock && err ==_islocked);
|
} while (!tlock && err ==_islocked);
|
||||||
if (err == NOERR && lmode == _lock)
|
|
||||||
{
|
|
||||||
err=DB_lock(isfd->fhnd);
|
|
||||||
if (err != NOERR) err=get_error(err);
|
|
||||||
}
|
|
||||||
if (err == NOERR && unlock)
|
if (err == NOERR && unlock)
|
||||||
{
|
{
|
||||||
err=DB_unlock(isfd->fhnd);
|
err=DB_unlock(isfd->fhnd);
|
||||||
@ -675,16 +676,6 @@ int TBaseisamfile::skip(TRecnotype nrec, word lockop)
|
|||||||
}
|
}
|
||||||
_lasterr=cisread(_isamfile,curr(),_iscurr + lockop);
|
_lasterr=cisread(_isamfile,curr(),_iscurr + lockop);
|
||||||
} while (!tlock && _lasterr ==_islocked);
|
} while (!tlock && _lasterr ==_islocked);
|
||||||
if (_lasterr == NOERR && lmode == _lock)
|
|
||||||
{
|
|
||||||
_lasterr=DB_lock(_isamfile->fhnd);
|
|
||||||
if (_lasterr != NOERR) _lasterr=get_error(_lasterr);
|
|
||||||
}
|
|
||||||
if (_lasterr == NOERR && unlock)
|
|
||||||
{
|
|
||||||
_lasterr=DB_unlock(_isamfile->fhnd);
|
|
||||||
if (_lasterr != NOERR) _lasterr=get_error(_lasterr);
|
|
||||||
}
|
|
||||||
_recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd);
|
_recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd);
|
||||||
return _lasterr;
|
return _lasterr;
|
||||||
}
|
}
|
||||||
@ -748,10 +739,18 @@ int TBaseisamfile::write(TDate& atdate)
|
|||||||
|
|
||||||
{
|
{
|
||||||
NOT_OPEN();
|
NOT_OPEN();
|
||||||
|
int oldkey=getkey();
|
||||||
browse_null(curr().string(),DB_reclen(_isamfile->fhnd));
|
browse_null(curr().string(),DB_reclen(_isamfile->fhnd));
|
||||||
memcpy(DB_getrecord(_isamfile->fhnd),curr().string(),DB_reclen(_isamfile->fhnd));
|
memcpy(DB_getrecord(_isamfile->fhnd),curr().string(),DB_reclen(_isamfile->fhnd));
|
||||||
_lasterr = DB_add(_isamfile->fhnd);
|
setkey(1);
|
||||||
if (_lasterr != NOERR) _lasterr = get_error(_lasterr);
|
if (cisread(_isamfile, curr(), _isequal + _nolock) == _iskeynotfound)
|
||||||
|
{
|
||||||
|
_lasterr = DB_add(_isamfile->fhnd);
|
||||||
|
if (_lasterr != NOERR) _lasterr = get_error(_lasterr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_lasterr=_isreinsert;
|
||||||
|
setkey(oldkey);
|
||||||
_recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd);
|
_recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd);
|
||||||
return _lasterr;
|
return _lasterr;
|
||||||
}
|
}
|
||||||
@ -761,10 +760,18 @@ int TBaseisamfile::write(const TRectype& rec, TDate& atdate)
|
|||||||
|
|
||||||
{
|
{
|
||||||
NOT_OPEN();
|
NOT_OPEN();
|
||||||
|
int oldkey=getkey();
|
||||||
browse_null(rec.string(),DB_reclen(_isamfile->fhnd));
|
browse_null(rec.string(),DB_reclen(_isamfile->fhnd));
|
||||||
memcpy(DB_getrecord(_isamfile->fhnd),rec.string(),DB_reclen(_isamfile->fhnd));
|
memcpy(DB_getrecord(_isamfile->fhnd),rec.string(),DB_reclen(_isamfile->fhnd));
|
||||||
_lasterr = DB_add(_isamfile->fhnd);
|
setkey(1);
|
||||||
if (_lasterr != NOERR) _lasterr = get_error(_lasterr);
|
if (cisread(_isamfile, (TRectype&)rec, _isequal + _nolock) == _iskeynotfound)
|
||||||
|
{
|
||||||
|
_lasterr = DB_add(_isamfile->fhnd);
|
||||||
|
if (_lasterr != NOERR) _lasterr = get_error(_lasterr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_lasterr=_isreinsert;
|
||||||
|
setkey(oldkey);
|
||||||
_recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd);
|
_recno = _isamfile->RecNo = DB_recno(_isamfile->fhnd);
|
||||||
return _lasterr;
|
return _lasterr;
|
||||||
}
|
}
|
||||||
@ -952,12 +959,17 @@ int TBaseisamfile::_open(unsigned int mode)
|
|||||||
{
|
{
|
||||||
TRecnotype n=DB_reccount(filehnd()->fhnd);
|
TRecnotype n=DB_reccount(filehnd()->fhnd);
|
||||||
TDir d;
|
TDir d;
|
||||||
d.get(num());
|
// d.get(num());
|
||||||
|
d.get(num(),_nolock,_nordir,_sysdirop);
|
||||||
|
if (d.is_com()) d.get(num(),_nolock,_comdir);
|
||||||
if ((filehnd()->d->EOD != n && n > 0) || (n >= d.eox()))
|
if ((filehnd()->d->EOD != n && n > 0) || (n >= d.eox()))
|
||||||
{
|
{
|
||||||
filehnd()->d->EOD = d.eod() = n;
|
filehnd()->d->EOD = d.eod() = n;
|
||||||
filehnd()->d->EOX = d.eox() = (TRecnotype) (n*1.2);
|
filehnd()->d->EOX = d.eox() = (TRecnotype) (n*1.2);
|
||||||
d.put(num());
|
if (d.is_com())
|
||||||
|
d.put(num(),_comdir);
|
||||||
|
else
|
||||||
|
d.put(num());
|
||||||
}
|
}
|
||||||
filehnd()->ln = num();
|
filehnd()->ln = num();
|
||||||
openf[num() - 1] = filehnd();
|
openf[num() - 1] = filehnd();
|
||||||
@ -987,12 +999,17 @@ int TBaseisamfile::_close()
|
|||||||
{
|
{
|
||||||
TDir d;
|
TDir d;
|
||||||
TRecnotype n=DB_reccount(filehnd()->fhnd);
|
TRecnotype n=DB_reccount(filehnd()->fhnd);
|
||||||
d.get(num());
|
//d.get(num());
|
||||||
|
d.get(num(),_nolock,_nordir,_sysdirop);
|
||||||
|
if (d.is_com()) d.get(num(),_nolock,_comdir);
|
||||||
if ((filehnd()->d->EOD != n && n > 0) || (n >= d.eox()))
|
if ((filehnd()->d->EOD != n && n > 0) || (n >= d.eox()))
|
||||||
{
|
{
|
||||||
filehnd()->d->EOD=d.eod()=n;
|
filehnd()->d->EOD=d.eod()=n;
|
||||||
filehnd()->d->EOX = d.eox() = (TRecnotype) (n*1.2);
|
filehnd()->d->EOX = d.eox() = (TRecnotype) (n*1.2);
|
||||||
d.put(num());
|
if (d.is_com())
|
||||||
|
d.put(num(),_comdir);
|
||||||
|
else
|
||||||
|
d.put(num());
|
||||||
}
|
}
|
||||||
CHECK(openf[num() - 1] != NULL, "Open file array corrupted");
|
CHECK(openf[num() - 1] != NULL, "Open file array corrupted");
|
||||||
err=DB_close(filehnd()->fhnd);
|
err=DB_close(filehnd()->fhnd);
|
||||||
@ -1062,12 +1079,17 @@ int TLocalisamfile::close()
|
|||||||
{
|
{
|
||||||
TRecnotype n = DB_reccount(filehnd()->fhnd);
|
TRecnotype n = DB_reccount(filehnd()->fhnd);
|
||||||
TDir d;
|
TDir d;
|
||||||
d.get(num());
|
//d.get(num());
|
||||||
|
d.get(num(),_nolock,_nordir,_sysdirop);
|
||||||
|
if (d.is_com()) d.get(num(),_nolock,_comdir);
|
||||||
if ((filehnd()->d->EOD!=n && n > 0) || (n > d.eox()))
|
if ((filehnd()->d->EOD!=n && n > 0) || (n > d.eox()))
|
||||||
{
|
{
|
||||||
filehnd()->d->EOD = d.eod() = n;
|
filehnd()->d->EOD = d.eod() = n;
|
||||||
filehnd()->d->EOX = d.eox() = n;
|
filehnd()->d->EOX = d.eox() = n;
|
||||||
d.put(num());
|
if (d.is_com())
|
||||||
|
d.put(num(),_comdir);
|
||||||
|
else
|
||||||
|
d.put(num());
|
||||||
}
|
}
|
||||||
err = DB_close(_isamfile->fhnd);
|
err = DB_close(_isamfile->fhnd);
|
||||||
if (err != NOERR) err = get_error(err);
|
if (err != NOERR) err = get_error(err);
|
||||||
@ -2578,6 +2600,14 @@ HIDDEN void __getfieldbuff(byte l, byte t, const char* recin, char *s)
|
|||||||
TDate dt(atol(s));
|
TDate dt(atol(s));
|
||||||
strcpy(s, dt.string(full));
|
strcpy(s, dt.string(full));
|
||||||
}
|
}
|
||||||
|
if (t == _boolfld && *s)
|
||||||
|
{
|
||||||
|
if (toupper(*s) == 'T' || toupper(*s) == 'Y'
|
||||||
|
|| toupper(*s) == 'S' || toupper(*s) == 'X')
|
||||||
|
strcpy(s,"X");
|
||||||
|
else
|
||||||
|
strcpy(s," ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2599,8 +2629,18 @@ HIDDEN void __putfieldbuff(byte l, byte d, byte t, const char* s, char* recout)
|
|||||||
TDate dt(s2);
|
TDate dt(s2);
|
||||||
sprintf(s2,"%8s", dt.string(ANSI));
|
sprintf(s2,"%8s", dt.string(ANSI));
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
if (t == _realfld) setdec(s2, d);
|
else
|
||||||
|
if (t == _boolfld)
|
||||||
|
{
|
||||||
|
if (toupper(*s2) == 'T' || toupper(*s2) == 'Y'
|
||||||
|
|| toupper(*s2) == 'S' || toupper(*s2) == 'X')
|
||||||
|
strcpy(s2,"T");
|
||||||
|
else
|
||||||
|
strcpy(s2,"F");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (t == _realfld) setdec(s2, d);
|
||||||
|
|
||||||
len = strlen(s2);
|
len = strlen(s2);
|
||||||
if (len > l) return ;
|
if (len > l) return ;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user