Modifiche dalla versione Linux sulla 2.1
git-svn-id: svn://10.65.10.50/trunk@11847 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
6dffdb1751
commit
1d697528db
@ -1,9 +1,11 @@
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
|
||||
#include <diction.h>
|
||||
#ifdef WIN32
|
||||
#include <io.h>
|
||||
#include <share.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@ -436,7 +438,7 @@ int get_error(int err)
|
||||
{
|
||||
// Codici negativi
|
||||
HIDDEN int error_codes_g[] = {-1,_isnotopen,-1,-1,-1,_islocked,-1,-1,-1,-1,-1,-1,_isfilefull,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,_iskeynotfound,_ispatherr,-1,-1,_isdupkey};
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,_iskeynotfound,_ispatherr,-1,-1,_isdupkey};
|
||||
// Codici da 0 a 9
|
||||
HIDDEN int error_codes_ra[] = {NOERR,NOERR,_iskeynotfound,_iseof,_isbof,_isnrecerr} ;
|
||||
// Codici da 10 a ...
|
||||
@ -444,26 +446,26 @@ HIDDEN int error_codes_rb[] = {-1,-1,_isreinsert,-1,-1,_islocked,-1,_isalropen,_
|
||||
|
||||
int isamerr = NOERR;
|
||||
|
||||
#ifdef DBG
|
||||
#ifdef DBG
|
||||
if (err <= 200 || err >= 230)
|
||||
cb_error = err;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (err > 0)
|
||||
{
|
||||
if (err > 0)
|
||||
{
|
||||
if (err >= 10)
|
||||
{
|
||||
if (err > 80 || error_codes_rb[err/10]==-1)
|
||||
if (err > 80 || error_codes_rb[err/10]==-1)
|
||||
isamerr = err;
|
||||
else
|
||||
isamerr = error_codes_rb[err/10];
|
||||
}
|
||||
else
|
||||
isamerr = error_codes_ra[err];
|
||||
isamerr = error_codes_ra[err];
|
||||
}
|
||||
else
|
||||
if (err < 0)
|
||||
{
|
||||
{
|
||||
if (err == -1)
|
||||
isamerr = _isnotopen;
|
||||
else
|
||||
@ -471,38 +473,40 @@ HIDDEN int error_codes_rb[] = {-1,-1,_isreinsert,-1,-1,_islocked,-1,_isalropen,_
|
||||
int ierr = DB_get_error();
|
||||
if (ierr == 0) ierr = -err; // DB_get_error already called
|
||||
if (ierr < 0) ierr = -ierr;
|
||||
if (ierr > 340 || error_codes_g[ierr/10]==-1)
|
||||
if (ierr > 340 || error_codes_g[ierr/10]==-1)
|
||||
isamerr = -ierr;
|
||||
else
|
||||
isamerr = error_codes_g[ierr/10];
|
||||
}
|
||||
}
|
||||
DB_zero_error();
|
||||
}
|
||||
DB_zero_error();
|
||||
return isamerr;
|
||||
}
|
||||
|
||||
// Used also by varrec
|
||||
bool rec_has_memo(const RecDes* rd)
|
||||
{
|
||||
{
|
||||
CHECKD(rd->NFields <= MaxFields, "Tracciato con troppi campi ", rd->NFields);
|
||||
for( int i = rd->NFields - 1; i >= 0; i--)
|
||||
if (rd->Fd[i].TypeF == _memofld)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
HIDDEN bool lf_has_memo(int lffile)
|
||||
{
|
||||
{
|
||||
return rec_has_memo(&prefix().get_recdes(lffile));
|
||||
}
|
||||
}
|
||||
|
||||
HIDDEN void browse_null(char *start, int nc)
|
||||
{
|
||||
{
|
||||
for (int i = nc - 1; i >= 0 ; i--) // Anche il primo byte(deletion flag) deve essere cambiato. nc comprende il primo byte
|
||||
if (start[i] == '\0') start[i] = ' ';
|
||||
}
|
||||
|
||||
// Traduce l'espressione chiave di CodeBase
|
||||
|
||||
HIDDEN const char * translate_key(const char* key) // Traduce l'espressione chiave di CodeBase
|
||||
/*HIDDEN const char * translate_key(const char* key)
|
||||
{
|
||||
// Trasforma l'espressione
|
||||
TToken_string t = key;
|
||||
@ -518,7 +522,7 @@ HIDDEN const char * translate_key(const char* key) // Traduce l'espressione chia
|
||||
const bool is_upper = ws.find("UPPER") >= 0;
|
||||
const bool is_sub = ws.find("SUBSTR") >= 0;
|
||||
int paren1 = ws.find('('); // Trova la prima parentesi aperta
|
||||
int paren2,last,from,to;
|
||||
int paren2,last,from = 0,to = 0;
|
||||
|
||||
if (paren1 >= 0 && is_sub && is_upper)
|
||||
paren1 = ws.find('('); // Trova la seconda parentesi (in questo caso c'e' per forza)
|
||||
@ -562,7 +566,7 @@ HIDDEN const char * translate_key(const char* key) // Traduce l'espressione chia
|
||||
TString& tmp = get_tmp_string();
|
||||
tmp = t;
|
||||
return tmp;
|
||||
}
|
||||
} */
|
||||
|
||||
HIDDEN int __build_key(const RecDes *recd, int numkey, RecType recin, char *key, bool build_x_cb)
|
||||
/* *recd; descrittore record */
|
||||
@ -1401,7 +1405,7 @@ int TBaseisamfile::is_valid(bool exclusive)
|
||||
const int trcreclen = prefix().get_reclen(_logicnum);
|
||||
if (trcreclen > 0)
|
||||
{
|
||||
if (DB_tagget(fhnd) == -1)
|
||||
if (DB_tagget(fhnd) == -1)
|
||||
err = _ispatherr;
|
||||
else
|
||||
{
|
||||
@ -1427,8 +1431,9 @@ bool TBaseisamfile::get_relapp(TString& app) const
|
||||
bool TBaseisamfile::is_changed_since(long& last) const
|
||||
{
|
||||
bool yes = FALSE;
|
||||
|
||||
const int fh = ::sopen(filename(), _O_RDONLY, _SH_DENYNO);
|
||||
|
||||
#ifdef WIN32
|
||||
const int fh = ::_sopen(filename(), _O_RDONLY, _SH_DENYNO);
|
||||
if (fh > 0)
|
||||
{
|
||||
struct stat stat;
|
||||
@ -1439,8 +1444,16 @@ bool TBaseisamfile::is_changed_since(long& last) const
|
||||
last = tim;
|
||||
}
|
||||
::_close(fh);
|
||||
}
|
||||
|
||||
}
|
||||
#else
|
||||
struct stat stat;
|
||||
if (lstat(filename(), &stat) == 0)
|
||||
{
|
||||
const long tim = long(stat.st_mtime) ^ long(stat.st_size);
|
||||
yes = tim != last;
|
||||
last = tim;
|
||||
}
|
||||
#endif
|
||||
return yes;
|
||||
}
|
||||
|
||||
@ -1599,7 +1612,11 @@ TIsamtempfile::TIsamtempfile(int logicnum, const char* radix, bool create, bool
|
||||
|
||||
FILE* f = fopen(n, "rb");
|
||||
if (f == NULL)
|
||||
#ifdef WIN32
|
||||
fatal_box("Impossibile aprire il file temporaneo %s: %s",(const char*) n,(const char*)_strerror(NULL));
|
||||
#else
|
||||
fatal_box("Impossibile aprire il file temporaneo %s: %s",(const char*) n,(const char*)strerror(errno));
|
||||
#endif
|
||||
|
||||
fseek(f, 0, SEEK_END);
|
||||
eod = eox = ftell(f) / len;
|
||||
@ -2124,7 +2141,8 @@ int TSystemisamfile::update(
|
||||
|
||||
const int nflds = curr().items();
|
||||
TArray infld, outfld;
|
||||
for (int j = 0; j < nflds; j++)
|
||||
int j;
|
||||
for (j = 0; j < nflds; j++)
|
||||
{
|
||||
const char* fld_name = curr().fieldname(j);
|
||||
infld.add(new TRecfield(curr(), fld_name), j);
|
||||
@ -2132,10 +2150,10 @@ int TSystemisamfile::update(
|
||||
outfld.add(new TRecfield(nrec, fld_name), j);
|
||||
}
|
||||
|
||||
const clock_t start_time = clock();
|
||||
// const clock_t start_time = clock(); verificare
|
||||
for (first(); good(); next())
|
||||
{
|
||||
const bool tick = p.addstatus(1);
|
||||
p.addstatus(1);
|
||||
ni++;
|
||||
|
||||
if (curr().isdeleted())
|
||||
@ -2448,7 +2466,7 @@ int TSystemisamfile::load(
|
||||
} else
|
||||
if (key == "Fields")
|
||||
{
|
||||
TToken_string riga = f.token().mid(equal+1);
|
||||
TToken_string riga(f.token().mid(equal+1));
|
||||
TToken_string wfd(32, ',');
|
||||
FOR_EACH_TOKEN(riga, fd)
|
||||
{
|
||||
@ -2604,8 +2622,9 @@ int TSystemisamfile::dump(
|
||||
TArray fld(nflds);
|
||||
TBit_array rjust(nflds);
|
||||
int len[MaxFields];
|
||||
int j;
|
||||
|
||||
for (int j = 0; j < nflds; j++)
|
||||
for (j = 0; j < nflds; j++)
|
||||
{
|
||||
fld.add(TString(curr().fieldname(j)), j);
|
||||
const TString & wfld = (const TString&) fld[j];
|
||||
@ -2624,7 +2643,7 @@ int TSystemisamfile::dump(
|
||||
TString s1, sfld;
|
||||
|
||||
fprintf(f, "[Header]\nVersion=%ld\nFile=%d",
|
||||
prefix().filelevel(), num());
|
||||
(long) prefix().filelevel(), num());
|
||||
for (int k = 0; k < nflds; k++)
|
||||
{
|
||||
if ((k % 10) == 0) fprintf(f, "\nFields=");
|
||||
@ -2762,7 +2781,7 @@ void TBaseisamfile::recover()
|
||||
|
||||
void TMemo_data::init(TRecnotype recno, TIsam_handle file)
|
||||
{
|
||||
CHECK(file != NULL || recno < 0, "Valid memo recno with NULL memo file");
|
||||
CHECK(file > 0 || recno < 0, "Valid memo recno with NULL memo file"); // verificare
|
||||
_recno = recno;
|
||||
_isamfile = file;
|
||||
}
|
||||
@ -2772,7 +2791,7 @@ void TMemo_data::destroy()
|
||||
TString_array::destroy();
|
||||
_dirty.reset();
|
||||
_recno = RECORD_NON_FISICO;
|
||||
_isamfile = NULL;
|
||||
_isamfile = 0;
|
||||
}
|
||||
|
||||
void TMemo_data::copy(const TMemo_data& m)
|
||||
@ -2977,7 +2996,8 @@ HIDDEN bool fld_empty(const char* s, int len, bool number)
|
||||
|
||||
HIDDEN int fld_cmp(const char* a, const char* b, int len, bool number)
|
||||
{
|
||||
for (int i = 0; i < len && *a == *b; b++, a++, i++);
|
||||
int i;
|
||||
for (i = 0; i < len && *a == *b; b++, a++, i++);
|
||||
if (i == len) return 0;
|
||||
int res = *a - *b;
|
||||
if (number)
|
||||
@ -3756,4 +3776,4 @@ TRecnotype TRecfield::ptr() const
|
||||
while(wp-- > (unsigned char*) _p)
|
||||
r = (r << 8) + *wp;
|
||||
return n ? -r : r;
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,8 @@ TMask_field::TField_Flags::TField_Flags()
|
||||
// Certified 100%
|
||||
char TMask_field::TField_Flags::update(const char* f, bool reset)
|
||||
{
|
||||
for (const char* s = f; *s; s++)
|
||||
const char * s;
|
||||
for (s = f; *s; s++)
|
||||
switch(*s)
|
||||
{
|
||||
case '#':
|
||||
@ -142,7 +143,7 @@ void TMask_field::update_flags(const char* f, bool reset)
|
||||
}
|
||||
|
||||
TMask_field::TMask_field(TMask* m)
|
||||
: _mask(m), _ctl(NULL), _groups(NULL)
|
||||
: _mask(m), _groups(NULL), _ctl(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@ -668,7 +669,7 @@ void TGroup_field::create(WINDOW parent)
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TOperable_field::TOperable_field(TMask* m)
|
||||
: TMask_field(m), _handler(NULL), _message(NULL)
|
||||
: TMask_field(m), _message(NULL), _handler(NULL)
|
||||
{ }
|
||||
|
||||
TOperable_field::~TOperable_field()
|
||||
@ -1180,8 +1181,8 @@ void TButton_field::set_central_icon(unsigned icon)
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TEditable_field::TEditable_field(TMask* m)
|
||||
: TLoadable_field(m), _prompt(NULL), _field(NULL), _keys(NULL),
|
||||
_validate(NULL), _warning(NULL), _drivers(NULL), _userdata(NULL)
|
||||
: TLoadable_field(m), _field(NULL), _prompt(NULL), _keys(NULL),
|
||||
_warning(NULL), _drivers(NULL), _userdata(NULL), _validate(NULL)
|
||||
{ }
|
||||
|
||||
|
||||
@ -1379,7 +1380,8 @@ word TEditable_field::first_key() const
|
||||
if (_keys == NULL)
|
||||
return 0;
|
||||
const int last = last_key();
|
||||
for (int i = 1; i <= last; i++)
|
||||
int i;
|
||||
for (i = 1; i <= last; i++)
|
||||
if (in_key(i) == TRUE)
|
||||
break;
|
||||
return (word)i;
|
||||
@ -1471,7 +1473,8 @@ word TEditable_field::create_prompt(
|
||||
if (height < 3)
|
||||
{
|
||||
width = _ctl_data._prompt.len();
|
||||
for (word i = 0; i < width && _ctl_data._prompt[(int)i] == '@'; i += 2);
|
||||
word i;
|
||||
for (i = 0; i < width && _ctl_data._prompt[(int)i] == '@'; i += 2);
|
||||
width -= i;
|
||||
_prompt = new TText_control(parent, -1, _ctl_data._x, _ctl_data._y,
|
||||
0, 1, flags, _ctl_data._prompt);
|
||||
@ -1759,7 +1762,8 @@ int TList_sheet::do_input()
|
||||
TToken_string& ts =_data.row(i);
|
||||
|
||||
ts.restart();
|
||||
for ( const char* item = rowsel.get(0); item ; item = rowsel.get())
|
||||
const char * item;
|
||||
for (item = rowsel.get(0); item ; item = rowsel.get())
|
||||
{
|
||||
it = item; it.trim();
|
||||
fd = ts.get(); fd.trim();
|
||||
@ -2369,7 +2373,7 @@ bool TBrowse::do_link(bool insert)
|
||||
}
|
||||
|
||||
TExternal_app a(app);
|
||||
const int err = a.run();
|
||||
a.run();
|
||||
field().mask().set_focus();
|
||||
|
||||
if (msg.not_empty())
|
||||
@ -2396,7 +2400,6 @@ bool TBrowse::do_link(bool insert)
|
||||
|
||||
TToken_string& TBrowse::create_siblings(TToken_string& siblings)
|
||||
{
|
||||
const TMask& mask = field().mask();
|
||||
siblings = ""; // Azzera la lista dei campi associati
|
||||
|
||||
TBit_array key(4); // Elenco delle chiavi gia' utilizzate
|
||||
@ -2866,8 +2869,8 @@ bool TProfile_select::check(CheckTime ct)
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TEdit_field::TEdit_field(TMask* mask)
|
||||
: TEditable_field(mask), _browse(NULL),
|
||||
_check(CHECK_NONE), _check_enabled(FALSE), _forced(FALSE)
|
||||
: TEditable_field(mask), _check(CHECK_NONE),
|
||||
_forced(FALSE), _check_enabled(FALSE), _browse(NULL)
|
||||
{ }
|
||||
|
||||
TEdit_field::~TEdit_field()
|
||||
@ -3221,7 +3224,8 @@ const char* TEdit_field::reformat(const char* str) const
|
||||
if (isdigit(s[0]) && real::is_natural(s))
|
||||
s.right_just(size(), '0');
|
||||
}
|
||||
for (const char * w = (const char *) s; *w == '0'; w++) ;
|
||||
const char * w;
|
||||
for (w = (const char *) s; *w == '0'; w++) ;
|
||||
if (*w == '\0')
|
||||
s.cut(0);
|
||||
}
|
||||
@ -4048,7 +4052,7 @@ bool TCurrency_field::is_kind_of(word cid) const
|
||||
|
||||
TCurrency& TCurrency_field::get_currency(TCurrency& cur) const
|
||||
{
|
||||
const real num = get();
|
||||
const real num(get());
|
||||
const char* value = NULL;
|
||||
real exchange;
|
||||
exchange_type et = _exchange_undefined;
|
||||
|
@ -397,8 +397,8 @@ TSpreadsheet::TSpreadsheet(
|
||||
const char* head, // @parm Titolo delle colonne
|
||||
TSheet_field* o) // @parm Indica il campo della maschera che contiene lo spreadsheet
|
||||
:
|
||||
_mask(), _notify(NULL),
|
||||
_cur_row(0), _cur_col(1), _cur_rec(0), _edit_field(NULL), _active(TRUE),
|
||||
_mask(), _active(TRUE), _notify(NULL),
|
||||
_edit_field(NULL), _cur_row(0), _cur_rec(0), _cur_col(1),
|
||||
_row_dirty(FALSE), _cell_dirty(FALSE), _check_enabled(TRUE),
|
||||
_needs_update(-1), _selection_posted(-1), _save_columns_order(FALSE)
|
||||
{
|
||||
@ -416,8 +416,9 @@ TSpreadsheet::TSpreadsheet(
|
||||
int i = 0, tot_width = NUMBER_WIDTH+1;
|
||||
int max_width = tot_width<<1; // Stima larghezza della colonna piu' grande
|
||||
unsigned char f_width[MAX_COL]; // Larghezza colonne fisse
|
||||
const char * h;
|
||||
|
||||
for (const char* h = header.get(); h; h = header.get(), i++)
|
||||
for (h = header.get(); h; h = header.get(), i++)
|
||||
{
|
||||
CHECKD(i < MAX_COL, "Tu meni calumns in scit: ", i);
|
||||
|
||||
@ -521,7 +522,7 @@ TSpreadsheet::TSpreadsheet(
|
||||
|
||||
XI_OBJ_DEF* coldef = xi_add_column_def(listdef, 0, attr, 0,
|
||||
NUMBER_WIDTH * XI_FU_MULTIPLE, NUMBER_WIDTH+1,
|
||||
attr & XI_ATR_SELECTABLE ? "X" : "");
|
||||
(char *)((attr & XI_ATR_SELECTABLE) ? "X" : ""));
|
||||
|
||||
coldef->app_data = (long)this;
|
||||
coldef->v.column->heading_platform = TRUE;
|
||||
@ -819,7 +820,7 @@ int TSpreadsheet::insert(
|
||||
{
|
||||
static bool ininsert = FALSE;
|
||||
|
||||
TMask & m = owner().mask();
|
||||
// TMask & m = owner().mask(); verificare
|
||||
if (ininsert || items() >= 9999)
|
||||
return -1;
|
||||
|
||||
@ -1007,8 +1008,7 @@ bool TSpreadsheet::test_focus_change()
|
||||
// Certified 75%
|
||||
bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
|
||||
{
|
||||
static KEY _lastab = K_TAB;
|
||||
static char tmp[16];
|
||||
// static KEY _lastab = K_TAB; verificare
|
||||
static clock_t digit_timer = 0;
|
||||
|
||||
BOOLEAN& refused = xiev->refused;
|
||||
@ -1567,7 +1567,7 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
|
||||
|
||||
if (items() > 0 && !owner().append())
|
||||
{
|
||||
XI_OBJ* itf = get_interface();
|
||||
get_interface(); // verificare
|
||||
if (owner().mask().focus_field().dlg() == owner().dlg())
|
||||
rec = _cur_rec + 1;
|
||||
else
|
||||
@ -1876,7 +1876,8 @@ XI_OBJ* TSpreadsheet::find_column(
|
||||
|
||||
int num;
|
||||
XI_OBJ** columns = xi_get_member_list(_obj, &num);
|
||||
for (int c = num-1; c >= 0; c--)
|
||||
int c;
|
||||
for (c = num-1; c >= 0; c--)
|
||||
{
|
||||
if (columns[c]->cid == col)
|
||||
break;
|
||||
@ -2158,7 +2159,7 @@ bool TSpreadsheet::user_saved_columns_order() const
|
||||
TFilename parag; field2parag(owner(), parag);
|
||||
TConfig config(CONFIG_USER, parag); // Apre il file di configurazione
|
||||
const int index = owner().dlg();
|
||||
TToken_string order = config.get("Browse", NULL, index);
|
||||
TToken_string order(config.get("Browse", NULL, index));
|
||||
return !order.empty_items();
|
||||
}
|
||||
|
||||
@ -2192,7 +2193,7 @@ void TSpreadsheet::load_columns_order()
|
||||
TFilename parag; field2parag(owner(), parag);
|
||||
TConfig config(CONFIG_USER, parag);
|
||||
const int index = owner().dlg();
|
||||
TToken_string order = config.get("Browse", NULL, index);
|
||||
TToken_string order(config.get("Browse", NULL, index));
|
||||
if (order.empty_items())
|
||||
config.remove("Browse", index);
|
||||
else
|
||||
@ -2366,9 +2367,8 @@ KEY TSpreadsheet::edit(int n)
|
||||
// Certified 100%
|
||||
TSheet_field::TSheet_field(TMask* m)
|
||||
: TLoadable_field(m), _append(TRUE),
|
||||
_enable_autoload(FALSE),_sheetfile(NULL),_linee_rec(NULL),
|
||||
_external_record(FALSE), _userput(NULL),_userget(NULL),
|
||||
_separator('|')
|
||||
_separator('|'), _enable_autoload(FALSE), _sheetfile(NULL),
|
||||
_linee_rec(NULL), _external_record(FALSE), _userput(NULL),_userget(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@ -2450,8 +2450,6 @@ bool TSheet_field::parse_item(TScanner& scanner)
|
||||
}
|
||||
if (scanner.key() == "US") // USE
|
||||
{
|
||||
int key = 1;
|
||||
|
||||
const int logicnum = scanner.integer();
|
||||
|
||||
if (logicnum > 0)
|
||||
@ -2528,8 +2526,9 @@ void TSheet_field::create(WINDOW parent)
|
||||
disable();
|
||||
}
|
||||
const TMask & s = sheet_mask();
|
||||
short id;
|
||||
|
||||
for (short id = FIRST_FIELD; ; id++)
|
||||
for (id = FIRST_FIELD; ; id++)
|
||||
if (s.id2pos(id) < 0) break;
|
||||
_last_column_id = id - 1;
|
||||
|
||||
@ -2549,7 +2548,8 @@ int TSheet_field::first_empty() const
|
||||
{
|
||||
TSpreadsheet* s = (TSpreadsheet*)_ctl;
|
||||
const int max = (int)s->items();
|
||||
for (int n = 0; n < max; n++)
|
||||
int n;
|
||||
for (n = 0; n < max; n++)
|
||||
if (s->row(n).empty_items())
|
||||
break;
|
||||
return n;
|
||||
@ -3187,7 +3187,7 @@ bool TSheet_field::autosave(TRelation& rel)
|
||||
TString dbfieldname;
|
||||
TMask_field * f;
|
||||
restart_key();
|
||||
while (f = get_key(dbfieldname))
|
||||
while ((f = get_key(dbfieldname)))
|
||||
_linee_rec->renum_key(dbfieldname, f->get());
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#define XVT_INCL_NATIVE
|
||||
#include <xvt.h>
|
||||
#include <progind.h>
|
||||
#include <config.h>
|
||||
#include <agasys.h>
|
||||
@ -21,9 +22,26 @@
|
||||
// [JCW 95-Dec-20] comments added for distribution 95a
|
||||
// [JCW 96-Jan-01] removed UDP capabilities from skstream
|
||||
|
||||
#include <fstream.h>
|
||||
#ifdef INCSTR_H
|
||||
#include <incstr.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include "winsock.h"
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
#define SOCKET int
|
||||
#define INVALID_SOCKET -1
|
||||
#define SOCKET_ERROR -1
|
||||
#define SOCKADDR_IN sockaddr_in
|
||||
#define closesocket close
|
||||
#define BYTE byte
|
||||
#endif
|
||||
|
||||
//
|
||||
// sockbuf
|
||||
@ -142,29 +160,37 @@ protected:
|
||||
int skstream::init( void )
|
||||
{
|
||||
// platform dependent initialization
|
||||
#ifdef WIN32
|
||||
const WORD wMinVer = 0x0101; // request WinSock v1.1 (at least)
|
||||
WSADATA wsaData;
|
||||
if( 0 == WSAStartup( wMinVer, &wsaData ) )
|
||||
return TRUE ;
|
||||
return FALSE ;
|
||||
#else
|
||||
return TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
int skstream::shutdown( void )
|
||||
{
|
||||
// platform dependent shutdown
|
||||
#ifdef WIN32
|
||||
if( 0 == WSACleanup() )
|
||||
return TRUE ;
|
||||
return FALSE ;
|
||||
#else
|
||||
return TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
skstream::skstream( void ) : _sockbuf( _socket ), iostream( &_sockbuf )
|
||||
skstream::skstream( void ) : iostream( &_sockbuf ), _sockbuf( _socket )
|
||||
{
|
||||
if( init() )
|
||||
attach( INVALID_SOCKET ) ;
|
||||
}
|
||||
|
||||
skstream::skstream( const char *addr, const service port, const role side )
|
||||
: _sockbuf( _socket ), iostream( &_sockbuf )
|
||||
: iostream( &_sockbuf ), _sockbuf( _socket )
|
||||
{
|
||||
if( init() )
|
||||
{
|
||||
@ -173,7 +199,7 @@ skstream::skstream( const char *addr, const service port, const role side )
|
||||
}
|
||||
}
|
||||
|
||||
skstream::skstream( SOCKET sock ) : _sockbuf( _socket ), iostream( &_sockbuf )
|
||||
skstream::skstream( SOCKET sock ) : iostream( &_sockbuf ), _sockbuf( _socket )
|
||||
{
|
||||
if( init() )
|
||||
attach( sock ) ;
|
||||
@ -205,7 +231,11 @@ void skstream::open( const char *addr, const service port, const role side )
|
||||
// 2. Bind
|
||||
SOCKADDR_IN sa ;
|
||||
sa.sin_family = AF_INET ;
|
||||
#ifdef WIN32
|
||||
sa.sin_addr.S_un.S_addr = INADDR_ANY ;
|
||||
#else
|
||||
sa.sin_addr.s_addr = INADDR_ANY ;
|
||||
#endif
|
||||
sa.sin_port = side == client ? 0 : htons( (unsigned short)port ) ;
|
||||
// rationale: no client requires fixed port number, so let system assign
|
||||
if( SOCKET_ERROR == ::bind( _socket, (sockaddr *)&sa, sizeof( sa ) ) )
|
||||
@ -245,8 +275,13 @@ void skstream::open( const char *addr, const service port, const role side )
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
sa.sin_addr.S_un.S_addr = indirizzo;
|
||||
sa.sin_port = ::htons( port ) ;
|
||||
#else
|
||||
sa.sin_addr.s_addr = indirizzo;
|
||||
sa.sin_port = htons( port ) ;
|
||||
#endif
|
||||
|
||||
if( SOCKET_ERROR == ::connect( _socket, (sockaddr *)&sa, sizeof( sa ) ) )
|
||||
{
|
||||
@ -314,7 +349,11 @@ char *skstream::getpeername( char *buf, int size ) const
|
||||
{
|
||||
SOCKADDR_IN sa ;
|
||||
int sasize = sizeof( sa ) ;
|
||||
#ifdef WIN32
|
||||
if( SOCKET_ERROR ==::getpeername( getsocket(), (sockaddr *)&sa, &sasize ) )
|
||||
#else
|
||||
if( SOCKET_ERROR ==::getpeername( getsocket(), (sockaddr *)&sa, (socklen_t *) &sasize ) )
|
||||
#endif
|
||||
// Cannot get peer name
|
||||
return NULL ;
|
||||
strncpy( buf, ::inet_ntoa( sa.sin_addr ), size - 1 ) ;
|
||||
@ -325,16 +364,23 @@ unsigned short skstream::getport( void ) const
|
||||
{
|
||||
SOCKADDR_IN sa ;
|
||||
int sasize = sizeof( sa ) ;
|
||||
#ifdef WIN32
|
||||
if( SOCKET_ERROR ==::getpeername( getsocket(), (sockaddr *)&sa, &sasize ) )
|
||||
// Cannot get peer port
|
||||
return ::ntohs( IPPORT_RESERVED ) ;
|
||||
return ::ntohs( IPPORT_RESERVED );
|
||||
return ::ntohs( sa.sin_port ) ;
|
||||
#else
|
||||
if( SOCKET_ERROR ==::getpeername( getsocket(), (sockaddr *)&sa, (socklen_t *) &sasize ) )
|
||||
// Cannot get peer port
|
||||
return ntohs( IPPORT_RESERVED );
|
||||
return ntohs( sa.sin_port ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// sockbuf
|
||||
//
|
||||
sockbuf::sockbuf( SOCKET &sock ) : _socket( sock ), streambuf( NULL, 0 )
|
||||
sockbuf::sockbuf( SOCKET &sock ) : _socket( sock )
|
||||
{
|
||||
const int insize = 0x2000 ; // allocate 16k buffer each for input and output
|
||||
const int outsize = 0x2000 ;
|
||||
@ -351,13 +397,15 @@ sockbuf::sockbuf( SOCKET &sock ) : _socket( sock ), streambuf( NULL, 0 )
|
||||
}
|
||||
}
|
||||
|
||||
sockbuf::sockbuf( SOCKET &sock, char *buf, int length )
|
||||
: _socket( sock ), streambuf( buf, length )
|
||||
sockbuf::sockbuf( SOCKET &sock, char *buf, int length ) : _socket( sock )
|
||||
{
|
||||
_buffer = NULL ;
|
||||
|
||||
setp( buf, buf + length / 2 ) ;
|
||||
setg( buf + length / 2, buf + length, buf + length ) ;
|
||||
if( this == setbuf( buf, length ) )
|
||||
{
|
||||
setp( buf, buf + length / 2 ) ;
|
||||
setg( buf + length / 2, buf + length, buf + length ) ;
|
||||
}
|
||||
}
|
||||
|
||||
sockbuf::~sockbuf()
|
||||
@ -459,7 +507,7 @@ int sockbuf::sync()
|
||||
// end of skstreams
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
#include "NetSock.h"
|
||||
#include "netsock.h"
|
||||
|
||||
class TSocket_connection : public TConnection
|
||||
{
|
||||
@ -532,7 +580,7 @@ bool TSocket_connection::Read(byte* buf, size_t size)
|
||||
bool ok = calza != NULL;
|
||||
if (ok)
|
||||
{
|
||||
calza->read(buf, size);
|
||||
calza->read((char *)buf, size);
|
||||
ok = calza->good() != 0;
|
||||
}
|
||||
return ok;
|
||||
@ -580,7 +628,7 @@ TSocket_connection::TSocket_connection(TLanManager* lm,
|
||||
_server.cut(pos);
|
||||
}
|
||||
|
||||
if (_server.blank() || stricmp(_server, "localhost") == 0)
|
||||
if (_server.blank() || xvt_str_compare_ignoring_case(_server, "localhost") == 0)
|
||||
_server = "127.0.0.1";
|
||||
|
||||
connect();
|
||||
@ -693,8 +741,6 @@ bool TSocketClient::HttpGetFile(CONNID id, const char* remote, const char* local
|
||||
|
||||
|
||||
{
|
||||
const clock_t start = clock();
|
||||
|
||||
long size = 0;
|
||||
for (int r = 0; ; r++)
|
||||
{
|
||||
@ -843,7 +889,7 @@ bool TSocketClient::HttpSoap(CONNID id, const char* cmd)
|
||||
m_pData = new BYTE[m_dwSize];
|
||||
}
|
||||
memset(m_pData, 0, m_dwSize);
|
||||
cur_socket->read(m_pData, size);
|
||||
cur_socket->read((char *) m_pData, size);
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
@ -871,7 +917,11 @@ bool TSocketClient::HttpPostFile(CONNID id, const char* remote, const char* loca
|
||||
ok = conn->WriteLine(buf);
|
||||
if (ok)
|
||||
{
|
||||
#ifdef WIN32
|
||||
ifstream input(local, ios::nocreate | ios::binary);
|
||||
#else
|
||||
ifstream input(local, ios::binary);
|
||||
#endif
|
||||
while (!input.eof())
|
||||
{
|
||||
input.read(buf.get_buffer(), buf.size());
|
||||
@ -912,7 +962,7 @@ bool TSocketClient::HttpPostFile(CONNID id, const char* remote, const char* loca
|
||||
m_dwSize = size;
|
||||
m_pData = new BYTE[m_dwSize+1];
|
||||
memset(m_pData, 0, size_t(m_dwSize+1));
|
||||
cur_socket->read(m_pData, (size_t)m_dwSize);
|
||||
cur_socket->read((char *) m_pData, (size_t)m_dwSize);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user