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
@ -14,7 +14,7 @@
|
||||
|
||||
Per costruire l'aga.fll e' necessario togliere le funzioni progind* e definire S4DLL.
|
||||
|
||||
*/
|
||||
*/
|
||||
#if XVT_OS == XVT_OS_SCOUNIX
|
||||
#define S4UNIX
|
||||
#else
|
||||
@ -297,8 +297,7 @@ int DB_skip(int handle,long int recno)
|
||||
int DB_lock(int handle)
|
||||
{
|
||||
if(dbdata[handle]==0) return(-1);
|
||||
if(d4lock(dbdata[handle],d4recno(dbdata[handle]))==r4locked) return(-1);
|
||||
else return(0);
|
||||
return(d4lock(dbdata[handle],d4recno(dbdata[handle])));
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
|
@ -2,7 +2,7 @@
|
||||
CODEBASE.H
|
||||
data : 23.01.95
|
||||
scopo: interfaccia verso CodeBase 5.0
|
||||
--------------------------------------------------------------------------*/
|
||||
--------------------------------------------------------------------------*/
|
||||
#ifndef __CODEBASE_H
|
||||
#define __CODEBASE_H
|
||||
|
||||
@ -12,59 +12,59 @@
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
numero massimo di database aperti contemporaneamente
|
||||
--------------------------------------------------------------------------*/
|
||||
--------------------------------------------------------------------------*/
|
||||
#define CB4FILES 50
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
prototipi funzioni
|
||||
--------------------------------------------------------------------------*/
|
||||
--------------------------------------------------------------------------*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void DB_init(void);
|
||||
void DB_exit(void);
|
||||
int DB_open(const char *filename,int mode);
|
||||
int DB_close(int handle);
|
||||
char *DB_getrecord(int handle);
|
||||
int DB_reclen(int handle);
|
||||
int DB_keylen(int handle);
|
||||
long int DB_recno(int handle);
|
||||
long int DB_reccount(int handle);
|
||||
int DB_tagselect(int handle,int index_no);
|
||||
int DB_tagget(int handle);
|
||||
int DB_first(int handle);
|
||||
int DB_last(int handle);
|
||||
int DB_next(int handle);
|
||||
int DB_prev(int handle);
|
||||
int DB_skip(int handle,long int recno);
|
||||
int DB_lock(int handle);
|
||||
int DB_lockrec(int handle, long recno); // Per sbloccare il record basta la DB_unlock()
|
||||
int DB_unlock(int handle);
|
||||
int DB_seek(int handle,char *key);
|
||||
int DB_eof(int handle);
|
||||
int DB_bof(int handle);
|
||||
int DB_go(int handle,long int recno);
|
||||
int DB_delete(int handle);
|
||||
int DB_recall(int handle);
|
||||
int DB_delkey(int handle, char* key, long recno);
|
||||
int DB_rewrite(int handle);
|
||||
int DB_add(int handle);
|
||||
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_packindex(short vis, const char * filename, RecDes *r, long *peod );
|
||||
int DB_build(const char * filename, RecDes *r);
|
||||
int DB_get_error(void);
|
||||
void DB_zero_error(void);
|
||||
int DB_index_seek(int handle, char* from);
|
||||
long DB_index_recno(int handle);
|
||||
long DB_index_next(int handle);
|
||||
char* DB_index_getkey(int handle);
|
||||
int DB_index_eof(int handle);
|
||||
int DB_lock_rec(int handle,long nrec);
|
||||
int DB_file_locked(int handle);
|
||||
int DB_rec_locked(int handle,long nrec);
|
||||
long DB_getconf();
|
||||
long DB_changed(int handle); // returns true if the index of the key is changed
|
||||
void DB_init(void);
|
||||
void DB_exit(void);
|
||||
int DB_open(const char *filename,int mode);
|
||||
int DB_close(int handle);
|
||||
char *DB_getrecord(int handle);
|
||||
int DB_reclen(int handle);
|
||||
int DB_keylen(int handle);
|
||||
long int DB_recno(int handle);
|
||||
long int DB_reccount(int handle);
|
||||
int DB_tagselect(int handle,int index_no);
|
||||
int DB_tagget(int handle);
|
||||
int DB_first(int handle);
|
||||
int DB_last(int handle);
|
||||
int DB_next(int handle);
|
||||
int DB_prev(int handle);
|
||||
int DB_skip(int handle,long int recno);
|
||||
int DB_lock(int handle);
|
||||
int DB_lockrec(int handle, long recno); // Per sbloccare il record basta la DB_unlock()
|
||||
int DB_unlock(int handle);
|
||||
int DB_seek(int handle,char *key);
|
||||
int DB_eof(int handle);
|
||||
int DB_bof(int handle);
|
||||
int DB_go(int handle,long int recno);
|
||||
int DB_delete(int handle);
|
||||
int DB_recall(int handle);
|
||||
int DB_delkey(int handle, char* key, long recno);
|
||||
int DB_rewrite(int handle);
|
||||
int DB_add(int handle);
|
||||
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_packindex(short vis, const char * filename, RecDes *r, long *peod );
|
||||
int DB_build(const char * filename, RecDes *r);
|
||||
int DB_get_error(void);
|
||||
void DB_zero_error(void);
|
||||
int DB_index_seek(int handle, char* from);
|
||||
long DB_index_recno(int handle);
|
||||
long DB_index_next(int handle);
|
||||
char* DB_index_getkey(int handle);
|
||||
int DB_index_eof(int handle);
|
||||
int DB_lock_rec(int handle,long nrec);
|
||||
int DB_file_locked(int handle);
|
||||
int DB_rec_locked(int handle,long nrec);
|
||||
long DB_getconf();
|
||||
long DB_changed(int handle); // returns true if the index of the key is changed
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
@ -300,17 +300,18 @@ HIDDEN int cisread(isfdptr isfd, TRectype & record, int mode)
|
||||
}
|
||||
if (rmode != _isequal && err == _iseof)
|
||||
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)
|
||||
{
|
||||
CBuildKey(isfd->r, DB_tagget(isfd->fhnd), record.string(), key);
|
||||
message_box("Codice %s in uso da parte\ndi un altro utente.", key);
|
||||
}
|
||||
} 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)
|
||||
{
|
||||
err=DB_unlock(isfd->fhnd);
|
||||
@ -675,16 +676,6 @@ int TBaseisamfile::skip(TRecnotype nrec, word lockop)
|
||||
}
|
||||
_lasterr=cisread(_isamfile,curr(),_iscurr + lockop);
|
||||
} 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);
|
||||
return _lasterr;
|
||||
}
|
||||
@ -748,10 +739,18 @@ int TBaseisamfile::write(TDate& atdate)
|
||||
|
||||
{
|
||||
NOT_OPEN();
|
||||
int oldkey=getkey();
|
||||
browse_null(curr().string(),DB_reclen(_isamfile->fhnd));
|
||||
memcpy(DB_getrecord(_isamfile->fhnd),curr().string(),DB_reclen(_isamfile->fhnd));
|
||||
setkey(1);
|
||||
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);
|
||||
return _lasterr;
|
||||
}
|
||||
@ -761,10 +760,18 @@ int TBaseisamfile::write(const TRectype& rec, TDate& atdate)
|
||||
|
||||
{
|
||||
NOT_OPEN();
|
||||
int oldkey=getkey();
|
||||
browse_null(rec.string(),DB_reclen(_isamfile->fhnd));
|
||||
memcpy(DB_getrecord(_isamfile->fhnd),rec.string(),DB_reclen(_isamfile->fhnd));
|
||||
setkey(1);
|
||||
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);
|
||||
return _lasterr;
|
||||
}
|
||||
@ -952,11 +959,16 @@ int TBaseisamfile::_open(unsigned int mode)
|
||||
{
|
||||
TRecnotype n=DB_reccount(filehnd()->fhnd);
|
||||
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()))
|
||||
{
|
||||
filehnd()->d->EOD = d.eod() = n;
|
||||
filehnd()->d->EOX = d.eox() = (TRecnotype) (n*1.2);
|
||||
if (d.is_com())
|
||||
d.put(num(),_comdir);
|
||||
else
|
||||
d.put(num());
|
||||
}
|
||||
filehnd()->ln = num();
|
||||
@ -987,11 +999,16 @@ int TBaseisamfile::_close()
|
||||
{
|
||||
TDir d;
|
||||
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()))
|
||||
{
|
||||
filehnd()->d->EOD=d.eod()=n;
|
||||
filehnd()->d->EOX = d.eox() = (TRecnotype) (n*1.2);
|
||||
if (d.is_com())
|
||||
d.put(num(),_comdir);
|
||||
else
|
||||
d.put(num());
|
||||
}
|
||||
CHECK(openf[num() - 1] != NULL, "Open file array corrupted");
|
||||
@ -1062,11 +1079,16 @@ int TLocalisamfile::close()
|
||||
{
|
||||
TRecnotype n = DB_reccount(filehnd()->fhnd);
|
||||
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()))
|
||||
{
|
||||
filehnd()->d->EOD = d.eod() = n;
|
||||
filehnd()->d->EOX = d.eox() = n;
|
||||
if (d.is_com())
|
||||
d.put(num(),_comdir);
|
||||
else
|
||||
d.put(num());
|
||||
}
|
||||
err = DB_close(_isamfile->fhnd);
|
||||
@ -2578,6 +2600,14 @@ HIDDEN void __getfieldbuff(byte l, byte t, const char* recin, char *s)
|
||||
TDate dt(atol(s));
|
||||
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,7 +2629,17 @@ HIDDEN void __putfieldbuff(byte l, byte d, byte t, const char* s, char* recout)
|
||||
TDate dt(s2);
|
||||
sprintf(s2,"%8s", dt.string(ANSI));
|
||||
}
|
||||
} else
|
||||
}
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user