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
@ -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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
|
@ -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));
|
||||||
|
setkey(1);
|
||||||
|
if (cisread(_isamfile, curr(), _isequal + _nolock) == _iskeynotfound)
|
||||||
|
{
|
||||||
_lasterr = DB_add(_isamfile->fhnd);
|
_lasterr = DB_add(_isamfile->fhnd);
|
||||||
if (_lasterr != NOERR) _lasterr = get_error(_lasterr);
|
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));
|
||||||
|
setkey(1);
|
||||||
|
if (cisread(_isamfile, (TRectype&)rec, _isequal + _nolock) == _iskeynotfound)
|
||||||
|
{
|
||||||
_lasterr = DB_add(_isamfile->fhnd);
|
_lasterr = DB_add(_isamfile->fhnd);
|
||||||
if (_lasterr != NOERR) _lasterr = get_error(_lasterr);
|
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,11 +959,16 @@ 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);
|
||||||
|
if (d.is_com())
|
||||||
|
d.put(num(),_comdir);
|
||||||
|
else
|
||||||
d.put(num());
|
d.put(num());
|
||||||
}
|
}
|
||||||
filehnd()->ln = num();
|
filehnd()->ln = num();
|
||||||
@ -987,11 +999,16 @@ 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);
|
||||||
|
if (d.is_com())
|
||||||
|
d.put(num(),_comdir);
|
||||||
|
else
|
||||||
d.put(num());
|
d.put(num());
|
||||||
}
|
}
|
||||||
CHECK(openf[num() - 1] != NULL, "Open file array corrupted");
|
CHECK(openf[num() - 1] != NULL, "Open file array corrupted");
|
||||||
@ -1062,11 +1079,16 @@ 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;
|
||||||
|
if (d.is_com())
|
||||||
|
d.put(num(),_comdir);
|
||||||
|
else
|
||||||
d.put(num());
|
d.put(num());
|
||||||
}
|
}
|
||||||
err = DB_close(_isamfile->fhnd);
|
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));
|
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,7 +2629,17 @@ 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
|
}
|
||||||
|
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);
|
if (t == _realfld) setdec(s2, d);
|
||||||
|
|
||||||
len = strlen(s2);
|
len = strlen(s2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user