*** empty log message ***

git-svn-id: svn://10.65.10.50/trunk@11841 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2004-03-12 14:52:53 +00:00
parent ee474af565
commit 980fbadf0b
12 changed files with 117 additions and 1334 deletions

View File

@ -179,19 +179,19 @@ bool TArray::destroy(
TArray::TArray(int arraysize) TArray::TArray(int arraysize)
: _size(0), _items(0), _next(0), _data(NULL) : _data(NULL), _size(0), _items(0), _next(0)
{ {
if (arraysize) if (arraysize)
resize(arraysize); resize(arraysize);
} }
TArray::TArray() TArray::TArray()
: _size(0), _items(0), _next(0), _data(NULL) : _data(NULL), _size(0), _items(0), _next(0)
{ {
} }
TArray::TArray(const TArray& a) TArray::TArray(const TArray& a)
: _size(0), _items(0), _next(0), _data(NULL) : _data(NULL), _size(0), _items(0), _next(0)
{ {
(*this) = a; (*this) = a;
} }
@ -629,7 +629,7 @@ int TPointer_array::insert(const TObject& object, int index, bool force)
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
TBit_array::TBit_array(long size) TBit_array::TBit_array(long size)
: _bit(NULL), _size(0) : _size(0), _bit(NULL)
{ {
if (size) if (size)
resize(index(size)); resize(index(size));
@ -653,7 +653,7 @@ void TBit_array::copy(
memcpy(_bit, ba._bit, _size); memcpy(_bit, ba._bit, _size);
} }
TBit_array::TBit_array(const TBit_array& ba) : _bit(NULL), _size(0) TBit_array::TBit_array(const TBit_array& ba) : _size(0), _bit(NULL)
{ copy(ba); } { copy(ba); }
TBit_array& TBit_array::operator=(const TBit_array& ba) TBit_array& TBit_array::operator=(const TBit_array& ba)
@ -747,7 +747,7 @@ void TBit_array::reset(long n)
} }
// Certified 99% // Certified 99%
void TBit_array::not(long n) void TBit_array::neg(long n)
{ {
const word i = index(n); const word i = index(n);
if (i >= _size) resize(i); if (i >= _size) resize(i);

View File

@ -208,7 +208,7 @@ inline TObject& TArray::operator[] (int index) const
#define FOR_EACH_ARRAY_ITEM(__arr, __r, __obj) \ #define FOR_EACH_ARRAY_ITEM(__arr, __r, __obj) \
TObject* __obj; \ TObject* __obj; \
for (int __r = __arr.first(); \ for (int __r = __arr.first(); \
__obj = __arr.objptr(__r); \ (__obj = __arr.objptr(__r)); \
__r = __arr.succ(__r)) __r = __arr.succ(__r))
#define FOR_EACH_ARRAY_ITEM_BACK(__arr, __r, __obj) \ #define FOR_EACH_ARRAY_ITEM_BACK(__arr, __r, __obj) \
@ -309,7 +309,7 @@ public:
// @cmember Setta a 0 il bit n-esimo dell'array // @cmember Setta a 0 il bit n-esimo dell'array
void reset(long n); void reset(long n);
// @cmember Not logico del bit n-esimo dell'array // @cmember Not logico del bit n-esimo dell'array
void not(long n); void neg(long n);
// @cmember Setta il bit n-esimo a seconda del valore passato come secondo elemento // @cmember Setta il bit n-esimo a seconda del valore passato come secondo elemento
void set(long n, bool on) { on ? set(n) : reset(n); } void set(long n, bool on) { on ? set(n) : reset(n); }

View File

@ -43,8 +43,9 @@ THash_object* TAssoc_array::_lookup(
TArray& arr = bucket(hv); TArray& arr = bucket(hv);
THash_object* o = NULL; THash_object* o = NULL;
isnew = FALSE; isnew = FALSE;
int i;
for (int i = 0; i < arr.items(); i++) for (i = 0; i < arr.items(); i++)
{ {
THash_object* ob = (THash_object*)arr.objptr(i); THash_object* ob = (THash_object*)arr.objptr(i);
if (ob->_key == key) if (ob->_key == key)
@ -198,7 +199,7 @@ bool TAssoc_array::add(const char* key, const TObject& obj, bool force)
{ {
// Non inserire l'Hash_object se non lo trovi (ci pensa la add sotto) // Non inserire l'Hash_object se non lo trovi (ci pensa la add sotto)
bool isnew = FALSE; bool isnew = FALSE;
THash_object* o = _lookup(key,isnew,FALSE); _lookup(key,isnew,FALSE);
if (!isnew && !force) if (!isnew && !force)
return TRUE; return TRUE;
return add(key,obj.dup(),force); return add(key,obj.dup(),force);
@ -221,7 +222,9 @@ bool TAssoc_array::remove(
const word hv = key.hash() % HASH_SIZE; const word hv = key.hash() % HASH_SIZE;
TArray& arr = bucket(hv); TArray& arr = bucket(hv);
THash_object* o = NULL; THash_object* o = NULL;
for (int i = 0; i < arr.items(); i++) int i;
for (i = 0; i < arr.items(); i++)
{ {
THash_object* ob = (THash_object*)&arr[i]; THash_object* ob = (THash_object*)&arr[i];
if (ob->_key == key) if (ob->_key == key)
@ -349,7 +352,7 @@ int TAssoc_array::get_keys(TString_array& kl, bool add_values)
restart(); restart();
THash_object* o = NULL; THash_object* o = NULL;
TString tmp(80); TString tmp(80);
while (o = get_hashobj()) while ((o = get_hashobj()))
{ {
TToken_string* tt = new TToken_string(o->key()); TToken_string* tt = new TToken_string(o->key());
if (add_values) if (add_values)

View File

@ -60,7 +60,6 @@ TField_event TAutomask::key2event(TMask_field& f, KEY key) const
case K_SPACE: case K_SPACE:
if (!f.is_edit()) if (!f.is_edit())
{ {
const TMask& wm = f.mask();
if (f.is_kind_of(CLASS_BUTTON_FIELD)) if (f.is_kind_of(CLASS_BUTTON_FIELD))
fe = fe_button; else fe = fe_button; else
if (f.is_kind_of(CLASS_TREE_FIELD)) if (f.is_kind_of(CLASS_TREE_FIELD))

View File

@ -1,4 +1,4 @@
#define F_STRING 101 #define F_STRING 101
#define F_DIRECT 102 #define F_DIRECT 102
#define F_REGEXP 104 #define F_REGEXP 104
#define F_CASE 103 #define F_CASE 103

View File

@ -5,4 +5,4 @@
#define S_FILE 101 #define S_FILE 101
#define S_ALIAS 102 #define S_ALIAS 102
#define S_LINK 103 #define S_LINK 103

View File

@ -83,13 +83,15 @@
#define ntrrec "trc.gen" #define ntrrec "trc.gen"
#define nditta "dta.gen" #define nditta "dta.gen"
#ifndef __STDTYPES_H
typedef unsigned char byte; typedef unsigned char byte;
#endif
typedef char Str8[9]; typedef char Str8[9];
typedef char Str25[26]; typedef char Str25[26];
typedef char Str30[32]; typedef char Str30[32];
typedef char Str80[82]; typedef char Str80[82];
typedef char Str255[256]; typedef char Str255[256];
typedef byte StCh[256]; typedef byte StCh[256];
typedef long TrDate; typedef long TrDate;
typedef char PathSt[82]; typedef char PathSt[82];
@ -99,10 +101,7 @@ extern Str80 cprefix;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
char *esc(char *); int CIOResult(void );
int CIOResult(void );
#ifdef WIN32 #ifdef WIN32
void tmpfname(char *,char *); void tmpfname(char *,char *);
#endif #endif

View File

@ -1,21 +1,15 @@
#include "ccustio.h" #include "ccustio.h"
#include <sys/stat.h>
#include "checks.h"
#ifdef WIN32 #ifdef WIN32
#include <sys/types.h> #include <sys/types.h>
#endif
#include <sys/stat.h>
#ifdef LINUX
#include <sys/ipc.h>
#include <sys/sem.h>
#include <unistd.h>
#else
#include <io.h> #include <io.h>
#include <share.h> #include <share.h>
#include <sys/locking.h> #include <sys/locking.h>
#else
#include "../xvaga/xvt.h"
#include <sys/ipc.h>
#include <sys/sem.h>
#include <unistd.h>
#endif #endif
#define CalcPos(Rec, Len, Base) (((Rec) - 1) * ((RecNoType) (Len)) + ((RecNoType) (Base))) #define CalcPos(Rec, Len, Base) (((Rec) - 1) * ((RecNoType) (Len)) + ((RecNoType) (Base)))
@ -25,8 +19,8 @@
#define LOCKSEM "locksem" #define LOCKSEM "locksem"
/* extern long lseek(int, long, int);*/ /* extern long lseek(int, long, int);*/
extern int chsize(int, long); // extern int chsize(int, long);
extern int lockf(int, int, long); // extern int lockf(int, int, long);
#endif #endif
unsigned setlock(unsigned); unsigned setlock(unsigned);
@ -262,8 +256,13 @@ void CCreate(S, Name, Len, Base, MaxSec)
if ((S->F = open(Name, O_RDWR | O_CREAT, 0666)) == -1) if ((S->F = open(Name, O_RDWR | O_CREAT, 0666)) == -1)
#endif #endif
if ((S->IOR = CIOResult()) != NoErr) return ; if ((S->IOR = CIOResult()) != NoErr) return ;
#ifdef WIN32
if (chsize(S->F, ((RecNoType) MaxSec)*BlockLenIO) == -1) if (chsize(S->F, ((RecNoType) MaxSec)*BlockLenIO) == -1)
S->IOR = CIOResult(); #else
if (lseek(S->F, ((RecNoType) MaxSec)*BlockLenIO, SEEK_SET) == -1)
#endif
S->IOR = CIOResult();
if (close(S->F) == -1) if (close(S->F) == -1)
{ {
junk = CIOResult(); junk = CIOResult();
@ -300,7 +299,12 @@ void CChsize(S, Name, Len, Base, MaxSec)
if ((S->F = open(Name, O_RDWR, 0666)) == -1) if ((S->F = open(Name, O_RDWR, 0666)) == -1)
#endif #endif
if ((S->IOR = CIOResult()) != NoErr) return ; if ((S->IOR = CIOResult()) != NoErr) return ;
if (chsize(S->F, ((RecNoType) MaxSec)*BlockLenIO) == -1) #ifdef WIN32
if (chsize(S->F, ((RecNoType) MaxSec)*BlockLenIO) == -1)#else
#else
if (lseek(S->F, ((RecNoType) MaxSec)*BlockLenIO, SEEK_SET) == -1)
#endif
S->IOR = CIOResult(); S->IOR = CIOResult();
if (close(S->F) == -1) if (close(S->F) == -1)
{ {
@ -731,9 +735,7 @@ void VS(sid)
sid = identificatore del semaforo su locksem. sid = identificatore del semaforo su locksem.
errno = numero errore. errno = codice errore.
sb = struttura che contiene informazioni sullo stato del file (vedi "stat").
@(FSV) @(FSV)
*/ */
@ -747,7 +749,6 @@ int excllock(name,excl)
char path[200], dir[200]; char path[200], dir[200];
int fd, junk, sid; int fd, junk, sid;
extern int errno; extern int errno;
struct stat sb;
strcpy(path, lockpath(name)); strcpy(path, lockpath(name));
strcpy(dir, dirname(path)); strcpy(dir, dirname(path));
@ -755,7 +756,8 @@ int excllock(name,excl)
if (semres == -1) return(-1); if (semres == -1) return(-1);
PS(sid); PS(sid);
if (semres == -1) return(-1); if (semres == -1) return(-1);
if ((stat(dir, &sb) == -1) && (errno == ENOENT)) CMkDir(dir); if (xvt_fsys_access(dir, F_OK) == ENOENT)
xvt_fsys_mkdir(dir);
if (((fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0666)) == -1) && if (((fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0666)) == -1) &&
errno == EEXIST) errno == EEXIST)
{ {

View File

@ -49,7 +49,7 @@ typedef struct {
#define TESTLOCK(x) ((x) == 13 || (x) == 11) #define TESTLOCK(x) ((x) == 13 || (x) == 11)
#define DEADLOCK(x) ((x) == EDEADLOCK) #define DEADLOCK(x) ((x) == EDEADLOCK)
#else #else
#define TESTLOCK(x) (((x) == EACCES) || ((x) == EGAIN) || ((x) == ENOLCK)) #define TESTLOCK(x) (((x) == EACCES) || ((x) == ENOLCK))
#define DEADLOCK(x) (((x) == EDEADLOCK) || ((x) == EDEADLK)) #define DEADLOCK(x) (((x) == EDEADLOCK) || ((x) == EDEADLK))
#endif #endif
#define BLOCKEXT(len,rec) (((((RecNoType) (len)) * ((RecNoType) (rec))) / BlockLenIO) + 1) #define BLOCKEXT(len,rec) (((((RecNoType) (len)) * ((RecNoType) (rec))) / BlockLenIO) + 1)

View File

@ -2,6 +2,11 @@
#include <xvt.h> #include <xvt.h>
#ifdef LINUX
extern const char * _c_user;
extern BOOLEAN _is_admin;
#endif
#include "cfiles.h" #include "cfiles.h"
int dirfl[2] = {0, 0}, recfl[2] = {0, 0} ; int dirfl[2] = {0, 0}, recfl[2] = {0, 0} ;
@ -390,8 +395,8 @@ int CGetCampoStpValue(const char* name, char* value, int valsize)
break; break;
} }
} }
#endif
#endif
return bFound; return bFound;
} }
@ -413,13 +418,15 @@ const char* CGetCampoIni(void)
static char* prawin = NULL; static char* prawin = NULL;
if (prawin == NULL) if (prawin == NULL)
{ {
BOOLEAN bFound = FALSE;
#ifdef WIN32
// Nelle installazioni sfigate con programmi in rete cerca di stabilire il percorso locale di Campo.ini
DIRECTORY dir;
char exedir[_MAX_PATH], path[_MAX_PATH]; char exedir[_MAX_PATH], path[_MAX_PATH];
DIRECTORY dir;
// Nelle installazioni sfigate con programmi in rete cerca di stabilire il percorso locale di Campo.ini
xvt_fsys_get_default_dir(&dir); xvt_fsys_get_default_dir(&dir);
xvt_fsys_convert_dir_to_str(&dir, exedir, sizeof(exedir)); xvt_fsys_convert_dir_to_str(&dir, exedir, sizeof(exedir));
#ifdef WIN32
BOOLEAN bFound = FALSE;
if (xvt_fsys_is_network_drive(exedir)) if (xvt_fsys_is_network_drive(exedir))
{ {
bFound = CGetCampoStpValue("CampoIni", path, sizeof(path)); bFound = CGetCampoStpValue("CampoIni", path, sizeof(path));
@ -435,14 +442,9 @@ const char* CGetCampoIni(void)
} }
} }
} }
#endif
if (!bFound) if (!bFound)
{ {
#ifdef LINUX #endif
char ininame[32];
sprintf(ininame, "campo%u", getuid());
xvt_fsys_build_pathname(path, NULL, exedir, ininame, "ini", NULL);
#else
xvt_fsys_build_pathname(path, NULL, exedir, "campo", "ini", NULL); xvt_fsys_build_pathname(path, NULL, exedir, "campo", "ini", NULL);
if (! xvt_fsys_file_exists(path)) if (! xvt_fsys_file_exists(path))
{ {
@ -450,8 +452,9 @@ const char* CGetCampoIni(void)
sprintf(msg, "Impossibile aprire '%s'", (const char *)path); sprintf(msg, "Impossibile aprire '%s'", (const char *)path);
xvt_dm_post_fatal_exit(msg); xvt_dm_post_fatal_exit(msg);
} }
#endif #ifdef WIN32
} }
#endif
prawin = xvt_str_duplicate(path); prawin = xvt_str_duplicate(path);
} }
return prawin; return prawin;
@ -463,12 +466,31 @@ HIDDEN BOOLEAN CGetFirmDir()
BOOLEAN good = xvt_fsys_file_exists(prawin); BOOLEAN good = xvt_fsys_file_exists(prawin);
if (good) if (good)
{ {
const int len = xvt_sys_get_profile_string(prawin, "Main", "Study", "", __ptprf, sizeof(__ptprf)); int len = 0;
good = len > 0; #ifdef LINUX
good = FALSE;
if (!_is_admin)
{
char varname[80];
sprintf(varname, "Study[%s]", _c_user);
len = xvt_sys_get_profile_string(prawin, "Main", varname, "", __ptprf, sizeof(__ptprf));
good = len > 0;
}
if (!good)
{
#endif
len = xvt_sys_get_profile_string(prawin, "Main", "Study", "", __ptprf, sizeof(__ptprf));
good = len > 0;
#ifdef LINUX
}
#endif
if (good) if (good)
{ {
char firm[8]; char firm[8];
long ditta; long ditta;
#ifdef LINUX
char path[_MAX_PATH], user[80];
#endif
if (__ptprf[len-1] != '\\' && __ptprf[len-1] != '/') if (__ptprf[len-1] != '\\' && __ptprf[len-1] != '/')
{ {
@ -476,9 +498,16 @@ HIDDEN BOOLEAN CGetFirmDir()
__ptprf[len+1] = '\0'; __ptprf[len+1] = '\0';
} }
xvt_sys_get_profile_string(prawin, "Main", "Firm", "COM", firm, sizeof(firm)); #ifdef LINUX
strcpy(user, _c_user),
xvt_str_make_lower(user);
sprintf(path, "%sconfig%c%s.ini", __ptprf, DIRSEP, user);
len = xvt_sys_get_profile_string(path, "Main", "Firm", "", firm, sizeof(firm));
if (len == 0)
#endif
xvt_sys_get_profile_string(prawin, "Main", "Firm", "com", firm, sizeof(firm));
ditta = atol(firm); ditta = atol(firm);
if (ditta > 0) sprintf(firm, "%05ldA", ditta); if (ditta > 0) sprintf(firm, "%05lda", ditta);
xvt_fsys_build_pathname(cprefix, NULL, __ptprf, firm, NULL, NULL); xvt_fsys_build_pathname(cprefix, NULL, __ptprf, firm, NULL, NULL);
} }
} }
@ -489,8 +518,27 @@ HIDDEN BOOLEAN CGetFirmDir()
BOOLEAN CPutFirmDir(const char* pref) BOOLEAN CPutFirmDir(const char* pref)
{ {
const char* prawin = CGetCampoIni(); const char* prawin = CGetCampoIni();
#ifdef LINUX
char path[_MAX_PATH], user[80];
strcpy(user, _c_user),
xvt_str_make_lower(user);
sprintf(path, "%sconfig%c%s.ini", __ptprf, DIRSEP, user);
BOOLEAN good = xvt_sys_set_profile_string(path, "Main", "Firm", pref);
#else
BOOLEAN good = xvt_sys_set_profile_string(prawin, "Main", "Firm", pref); BOOLEAN good = xvt_sys_set_profile_string(prawin, "Main", "Firm", pref);
xvt_sys_set_profile_string(prawin, "Main", "Study", __ptprf); #endif
#ifdef LINUX
if (!_is_admin)
{
char varname[80];
sprintf(varname, "Study[%s]", _c_user);
xvt_sys_set_profile_string(prawin, "Main", varname, __ptprf);
}
else
#endif
xvt_sys_set_profile_string(prawin, "Main", "Study", __ptprf);
return good; return good;
} }
@ -516,7 +564,7 @@ const char* CGetPref()
{ {
if (!CGetFirmDir()) if (!CGetFirmDir())
{ {
strcpy(cprefix, "COM"); strcpy(cprefix, "com");
CPutFirmDir(cprefix); CPutFirmDir(cprefix);
} }
return cprefix; return cprefix;

File diff suppressed because it is too large Load Diff

View File

@ -61,7 +61,7 @@ unsigned int color_distance(COLOR col1, COLOR col2)
const int g2 = XVT_COLOR_GET_GREEN(col2); const int g2 = XVT_COLOR_GET_GREEN(col2);
const int b2 = XVT_COLOR_GET_BLUE(col2); const int b2 = XVT_COLOR_GET_BLUE(col2);
const int r = abs(r1-r2); const int r = abs(r1-r2);
const int g = abs(g1-b2); const int g = abs(g1-g2);
const int b = abs(b1-b2); const int b = abs(b1-b2);
return (r > g && r > b) ? r : (g > b ? g : b); return (r > g && r > b) ? r : (g > b ? g : b);
} }
@ -343,4 +343,4 @@ TSelect_color_mask::TSelect_color_mask(const char * mask_name, const char * para
TSelect_color_mask::~TSelect_color_mask() TSelect_color_mask::~TSelect_color_mask()
{ {
delete _sheet_mask; delete _sheet_mask;
} }