Patch level :4.0

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :riportate modifiche dalla 3.1 per poter proseguire con i cespiti


git-svn-id: svn://10.65.10.50/trunk@15890 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
luca 2007-12-17 10:32:43 +00:00
parent 9c3428c116
commit 0d26ca337b
7 changed files with 177 additions and 32 deletions

View File

@ -129,7 +129,7 @@ void TDate::set_end_month()
_val = makedata(last_day(month(),year()),month(),year());
}
bool TDate::is_end_month()
bool TDate::is_end_month() const
{
return day() == last_day(month(),year());
}

View File

@ -107,7 +107,7 @@ public:
// @cmember Ritorna l'ultimo giorno possibile del mese
static int last_day(int month, int year);
// @cmember Controlla se il giorno e' l'ultimo del mese
bool is_end_month();
bool is_end_month() const;
// @cmember Setta il giorno del mese all'ultimo possibile
void set_end_month();
// @cmember Controlla se la data è nulla

View File

@ -1087,6 +1087,26 @@ int TBaseisamfile::write()
return TBaseisamfile::write(curr());
}
int TBaseisamfile::write_rewrite(const TRectype& rec)
{
return rec.write_rewrite(*this);
}
int TBaseisamfile::write_rewrite()
{
return TBaseisamfile::write_rewrite(curr());
}
int TBaseisamfile::rewrite_write(const TRectype& rec)
{
return rec.rewrite_write(*this);
}
int TBaseisamfile::rewrite_write()
{
return TBaseisamfile::rewrite_write(curr());
}
int TBaseisamfile::_rewrite(const TRectype& rec)
{
CHECK(!rec.empty(), "Can't write an empty record");
@ -3926,6 +3946,22 @@ int TRectype::rewrite(TBaseisamfile& f) const
return f._rewrite(*this);
}
int TRectype::write_rewrite(TBaseisamfile& f) const
{
int err = write(f);
if (err != NOERR)
err = rewrite(f);
return err;
}
int TRectype::rewrite_write(TBaseisamfile& f) const
{
int err = rewrite(f);
if (err != NOERR)
err = write(f);
return err;
}
// Certified ??%
int TRectype::remove(TBaseisamfile& f) const
{

View File

@ -44,7 +44,7 @@ public:
TIsam_handle file() const { return _isamfile; }
void copy(const TMemo_data& m);
bool is_dirty(int i) const { return _dirty[i]; }
void set_dirty(int i, bool d = TRUE) { _dirty.set(i, d); }
void set_dirty(int i, bool d = true) { _dirty.set(i, d); }
TMemo_data& operator=(const TMemo_data& m) { copy(m); return *this; }
TMemo_data(const TMemo_data& m) { copy(m); }
@ -118,6 +118,10 @@ public:
virtual int write(TBaseisamfile& f) const;
// @cmember Riscrive il record sul file
virtual int rewrite(TBaseisamfile& f) const;
// @cmember Aggiunge/Aggiorna il record
virtual int write_rewrite(TBaseisamfile& f) const;
// @cmember Aggiorna/Aggiunge il record
virtual int rewrite_write(TBaseisamfile& f) const;
// @cmember Elimina il record dal file
virtual int remove(TBaseisamfile& f) const;
// @cmember Cambia il campo <p field> della chiave principale con il valore <p val>
@ -127,7 +131,7 @@ public:
int items() const;
// @cmember Setta il record come non vuoto (chiama <mf TRectype::setempty>)
void setdirty()
{ setempty(FALSE); }
{ setempty(false); }
// @cmember Setta il codice della tabella utilizzata
void settab(const char *tab);
// @cmember Ritorna il puntatore all'inizio del record. NON dovrebbe essere usata!
@ -161,7 +165,7 @@ public:
const char* build_key(int key = 1) const;
// @cmember Confronta le chiavi di due record
int compare_key(const TRectype& rec, int key = 1, int skip_last = 0) const;
// @cmember Ritorna TRUE se le chiavi di due record sono uguali (vedi <mf TRectype::compare_key>)
// @cmember Ritorna true se le chiavi di due record sono uguali (vedi <mf TRectype::compare_key>)
bool same_key(const TRectype& rec, int key = 1, int skip_last = 0) const
{ return compare_key(rec, key, skip_last) == 0; }
@ -241,7 +245,7 @@ public:
// @cmember Ritorna se si tratta di un record valido
virtual bool ok() const
{ return _rec != NULL; }
// @cmember Ritorna TRUE se sono uguali
// @cmember Ritorna true se sono uguali
bool is_equal(const TRectype& r) const;
virtual void init_memo(const TRecnotype recno = RECORD_NON_FISICO, TIsam_handle file = 0);
@ -320,8 +324,8 @@ protected:
// @cmember UNUSED
void recover();
// @cmember Apre il file isam di base con lock, permettendo di specificare se usare gli indici o no
int _open(unsigned int mode = _manulock, bool index = TRUE);
int _open_ex(unsigned int mode = _manulock, bool index = TRUE);
int _open(unsigned int mode = _manulock, bool index = true);
int _open_ex(unsigned int mode = _manulock, bool index = true);
// @cmember Chiude il file isam di base
int _close();
@ -375,6 +379,12 @@ public:
virtual int rewrite();
// @cmember Riscrive un record (il record <p rec>)
virtual int rewrite(const TRectype& rec);
// @cmember Tenta di aggiungere un record ma se esiste gia' lo aggiorna
virtual int write_rewrite(const TRectype& rec);
virtual int write_rewrite();
// @cmember Tenta di aggiornare un record ma se non esiste lo crea
virtual int rewrite_write(const TRectype& rec);
virtual int rewrite_write();
// @cmember Riscrive un record alla posizione <p nrec>
virtual int rewriteat(TRecnotype nrec);
// @cmember Riscrive un record alla posizione <p nrec> copiando da <p rec>
@ -402,27 +412,27 @@ public:
{ return _lasterr; }
// @cmember Controlla se il file e' valido (ritorna 0 se il file e' valido)
int is_valid(bool exclusive);
// @cmember Restituisce se il file è ordinato con indice esterno (default:FALSE)
// @cmember Restituisce se il file è ordinato con indice esterno (default:false)
virtual bool is_sorted()
{return FALSE;}
{return false;}
// @cmember Ritorna il puntatore al record corrente
virtual TRectype& curr() const
{return *_current;}
// @cmember Controlla se e' stata raggiunta la fine del file (TRUE se EOF)
// @cmember Controlla se e' stata raggiunta la fine del file (true se EOF)
bool eof() const
{ return status() == _iseof || status() == _isemptyfile;}
// @cmember Controlla se e' stato raggiunto l'inizio del file (TRUE se BOF)
// @cmember Controlla se e' stato raggiunto l'inizio del file (true se BOF)
bool bof() const
{ return status() == _isbof || status() == _isemptyfile;}
// @cmember Controlla se l'ultima operazione sul file e' stata effettuata correttamente
// (TRUE se <p _lasterr> non contiene codici di errore)
// (true se <p _lasterr> non contiene codici di errore)
bool good() const
{ return status() == NOERR;}
// @cmember Controlla se l'ultima operazione sul file ha generato un errore
// (TRUE se <p _lasterr> contiene codici di errore)
// (true se <p _lasterr> contiene codici di errore)
bool bad() const
{ return status() != NOERR;}
// @cmember Controlla se il file e' vuoto (TRUE se vuoto)
// @cmember Controlla se il file e' vuoto (true se vuoto)
virtual bool empty();
// @cmember Ritorna il numero logico del record corrente
int num() const
@ -540,13 +550,13 @@ class TIsamfile : public TBaseisamfile
// @access Public Member
public:
// @cmember Aggiorna i flags associati al file
// int flags(bool updateeod = FALSE);
// int flags(bool updateeod = false);
// @cmember Apre un file di isam con lock (vedi <mf TBaseisamfile::_open>)
int open(unsigned int mode = _manulock, bool index = TRUE)
int open(unsigned int mode = _manulock, bool index = true)
{ return _open(mode, index); }
int open_ex(unsigned int mode = _manulock, bool index = TRUE)
int open_ex(unsigned int mode = _manulock, bool index = true)
{ return _open_ex(mode, index); }
// @cmember Chiude il file di isam
@ -600,14 +610,14 @@ public:
// @cmember Calcola lo spazio che il file occuperebbe se venisse esteso a <p eox>
long size(TRecnotype eox);
// @cmember Esegue la conversione del tracciato record del file
int update(const TTrec& newrec, bool interactive = FALSE);
int update(const TTrec& newrec, bool interactive = false);
// @cmember Esegue sia <mf TSystemisamfile::packfile> e <mf TSystemisamfile::packindex>
int pack(bool vis = FALSE, bool ask = TRUE);
int pack(bool vis = false, bool ask = true);
// @cmember Rimuove fisicamente i record cancellati
int packfile(bool vis = FALSE, bool zap = FALSE);
int packfile(bool vis = false, bool zap = false);
// @cmember Rimuove fisicamente gli indici cancellati
int packindex(bool vis = FALSE, bool ask = TRUE);
int packindex(bool vis = false, bool ask = true);
// @cmember Rimuove fisicamente tutti i records e gli indici
int zap();
@ -661,9 +671,9 @@ public:
virtual int operator ++();
// @cmember Indietreggia al record precedente
virtual int operator --();
// @cmember Ritorna TRUE se tabella
// @cmember Ritorna true se tabella
virtual bool tab() const
{ return FALSE;}
{ return false;}
virtual word class_id() const { return CLASS_LOCALISAMFILE; }
virtual bool is_kind_of(word id) const { return id == class_id() || TBaseisamfile::is_kind_of(id); }
@ -700,14 +710,14 @@ protected:
// @access Public Member
public:
// @cmember Setta il valore di <p _autodel> a <p val>
void set_autodel(bool val=TRUE)
void set_autodel(bool val = true)
{_autodel = val;}
virtual word class_id() const { return CLASS_ISAMTEMPFILE; }
virtual bool is_kind_of(word id) const { return id == class_id() || TLocalisamfile::is_kind_of(id); }
// @cmember Costruttore
TIsamtempfile(int logicnum, const char* radix, bool create=TRUE, bool autodel=FALSE);
TIsamtempfile(int logicnum, const char* radix, bool create = true, bool autodel = false);
// @cmember Distruttore
virtual ~TIsamtempfile();
};
@ -730,7 +740,7 @@ protected:
// @cmember inizializza il file. <p exclusive> indica se aprire il file in modo esclusivo
void init(const char* name, bool exclusive, bool index);
// @cmember Apre il file. <p exclusive> indica se aprire il file in modo esclusivo
int open(bool exclusive, bool index = TRUE);
int open(bool exclusive, bool index = true);
// @cmember Chiude il file
int close();
@ -747,12 +757,12 @@ public:
// @cmember Costruttore. <p exclusive> indica se aprire il file in modo esclusivo.
// <p index> indica se aprire il file con indici o meno
TExternisamfile(const char* name, bool exclusive = FALSE, bool index = TRUE);
TExternisamfile(const char* name, bool exclusive = false, bool index = true);
// @cmember Costruttore. <p descname> é il nome del file che contiene la descrizione del file (estensione trr).
// <p exclusive> indica se aprire il file in modo esclusivo.
// <p index> indica se aprire il file con indici o meno
TExternisamfile(const char* name, const char * descname, bool exclusive = FALSE,
bool index = TRUE);
TExternisamfile(const char* name, const char * descname, bool exclusive = false,
bool index = true);
// @cmember Distruttore
virtual ~TExternisamfile();
};

View File

@ -1095,6 +1095,92 @@ bool TSocketClient::HttpPostFile(CONNID id, const char* remote, const char* loca
return ok;
}
static bool FtpSendCommand(TSocket_connection& conn, const char* cmd, const char* param, TString* line)
{
TString command = cmd;
if (param && *param)
command << ' ' << param;
command << "\r\n";
if (!conn.WriteLine(command))
return false;
if (line != NULL)
{
line->cut(0);
if (!conn.ReadLine(*line))
return false;
line->rtrim();
}
return true;
}
bool TSocketClient::FtpSendFile(CONNID id, const char* remote, const char* local, const char* user, const char* pass)
{
bool ok = false;
if (!fexist(local))
return ok;
TString response;
if (!ReadLine(id, response)) // 220 Welcome
return ok;
TSocket_connection& conn = *(TSocket_connection*)GetConnection(id);
if (user==NULL || !*user)
user = "anonimous";
ok = FtpSendCommand(conn, "USER", user, &response); // 331 Please specify the password.
if (!ok || response[0] != '3')
return false;
if (pass==NULL || !*pass)
pass = "user@campo.it";
ok = FtpSendCommand(conn, "PASS", pass, &response); // 230 Login successful.
if (!ok || response[0] != '2')
return false;
ok = FtpSendCommand(conn, "TYPE", "I", &response); // 200 Switching to Binary mode.
if (!ok || response[0] != '2')
return false;
FtpSendCommand(conn, "PASV", NULL, &response); // 227 Entering Passive Mode (192,168,4,3,4,82)
const TString& address = response.after("(").before(")");
int a[6];
if (sscanf(address, "%d,%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]) != 6)
return false;
ok = FtpSendCommand(conn, "STOR", remote, NULL);
if (!ok)
return false;
TString16 addr; addr.format("%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
const skstream::service port = skstream::service((a[4] << 8) | a[5]);
skstream outstream(addr, port) ;
ifstream input(local, ios::binary);
while (!input.eof())
{
input.read(response.get_buffer(), 1024*4);
const size_t count = input.gcount();
if (count > 0)
{
outstream.sync();
outstream.write(response, count);
outstream.flush();
}
else
break;
}
ok = conn.ReadLine(response); // 150 Ok to send data.
if (ok)
ok = response[0] == '1';
FtpSendCommand(conn, "QUIT", NULL, NULL);
return ok;
}
///////////////////////////////////////////////////////////
// TDDEClient
///////////////////////////////////////////////////////////

View File

@ -53,6 +53,8 @@ public:
bool HttpGetDir(CONNID id, const char* remote, TString_array& list);
bool HttpSoap(CONNID id, const char* query);
bool HttpPostFile(CONNID id, const char* remote, const char* local, const char* authorization = NULL);
bool HttpPutFile(CONNID id, const char* remote, const char* local);
bool FtpSendFile(CONNID id, const char* remote, const char* local, const char* user, const char* pass);
TSocketClient();
virtual ~TSocketClient();

View File

@ -301,7 +301,7 @@ int TXmlItem::ReadTag(istream& inf)
if (name[0] == '>')
return bChildrenFollow ? +1 : 0;
if (name[0] == '/')
if (name[0] == '/' || name[0] == '?') // Gestisce i casi "/>" e "?>")
{
bChildrenFollow = false;
continue;
@ -367,7 +367,15 @@ void TXmlItem::RemoveLastChild()
bool TXmlItem::Read(istream& inf)
{
Destroy();
const int res = ReadTag(inf);
int res = ReadTag(inf);
// Ignora la eventuale riga <?xml version="1.0" encoding="UTF-8" ?>
if (res == 0 && GetTag()[0] == '?')
{
Destroy();
res = ReadTag(inf);
}
if (res > 0) // There are children ahead
{
while (!inf.eof())
@ -444,6 +452,9 @@ TXmlItem& operator<<(TXmlItem& item, const char* str)
void TXmlItem::Write(ostream& outf, int tab) const
{
if (tab == 0)
outf << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
if (!GetTag().empty())
{
Spaces(outf, tab);