Patch level :
Files correlati : agalib Ricompilazione Demo : [ ] Commento : Implementato di meccanismo generico di blocco degli inserimenti, attivabile nelle singole applicazioni (cg2 e ve0) git-svn-id: svn://10.65.10.50/branches/R_10_00@22420 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
1e3f90b8f9
commit
d1852229ad
@ -23,7 +23,6 @@ DEFFLD(DATAREG)
|
||||
DEFFLD(MODPAG)
|
||||
DEFFLD(IMPORTO)
|
||||
DEFFLD(IMPOSTA)
|
||||
DEFFLD(NATOPE)
|
||||
DEFFLD(TIPOPE)
|
||||
|
||||
DEFFLD(CONTRATTO)
|
||||
|
@ -500,7 +500,6 @@ void TApplication::run(
|
||||
|
||||
// @comm E' in questa fase che si controlla se esiste la chiave e' attaccata
|
||||
{
|
||||
CHECK(_application == NULL, "Sorry, multitasking not implemented yet");
|
||||
// Devo metterla qui per far funzionare la TDongle::network_login
|
||||
_application = this;
|
||||
|
||||
|
@ -5,6 +5,10 @@
|
||||
#include <xvt.h>
|
||||
#endif
|
||||
|
||||
#ifndef __ASSOC_H
|
||||
#include <assoc.h>
|
||||
#endif
|
||||
|
||||
#ifndef __DICTION_H
|
||||
#include <diction.h>
|
||||
#endif
|
||||
@ -17,9 +21,6 @@
|
||||
#define CHK_DONGLE 0 // dongle authorization checks
|
||||
//#define CHK_USER 1 // user authorization checks
|
||||
|
||||
#ifndef __ASSOC_H
|
||||
class TAssoc_array;
|
||||
#endif
|
||||
// @doc EXTERNAL
|
||||
|
||||
// @class TApplication | Classe per la gestione di tutte le applicazioni PRASSI
|
||||
|
@ -1,6 +1,10 @@
|
||||
#ifndef __ARCHIVES_H
|
||||
#define __ARCHIVES_H
|
||||
|
||||
#ifndef __ARRAY_H
|
||||
#include <array.h>
|
||||
#endif
|
||||
|
||||
#ifndef __STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
@ -1,7 +1,4 @@
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <array.h>
|
||||
#include <strings.h>
|
||||
|
||||
void TContainer::for_each( OPERATION_FUNCTION op )
|
||||
@ -555,14 +552,111 @@ static int sortable_compare(
|
||||
void TArray::sort(
|
||||
COMPARE_FUNCTION compare) // @parm Funzione indicante il criterio di ordinamento (default TSortable)
|
||||
|
||||
// @comm Nel caso non venga passata nessuna funzione che permetta di conforntare
|
||||
// i due oggetti viene utilizzato il criterio <c Tsortable>
|
||||
// @comm Nel caso non venga passata nessuna funzione che permetta di confrontare
|
||||
// i due oggetti viene utilizzato il criterio <c TSortable>
|
||||
{
|
||||
typedef int (*qsortfunc)(const void*, const void*);
|
||||
if (compare == NULL) compare = sortable_compare;
|
||||
|
||||
pack();
|
||||
qsort(_data, items(), sizeof(TObject*), (qsortfunc)compare);
|
||||
qsort(_data, last()+1, sizeof(TObject*), (qsortfunc)compare);
|
||||
}
|
||||
|
||||
|
||||
static COMPARE_FUNCTION_EX _cmp_func = NULL;
|
||||
static void* _cmp_jolly = NULL;
|
||||
|
||||
static int compare_ex(const void* p1, const void* p2)
|
||||
{
|
||||
if (p1 == p2)
|
||||
return 0;
|
||||
const TSortable& o1 = **(const TSortable**)p1;
|
||||
const TSortable& o2 = **(const TSortable**)p2;
|
||||
return _cmp_func(o1, o2, _cmp_jolly);
|
||||
}
|
||||
|
||||
void TArray::sort(
|
||||
COMPARE_FUNCTION_EX compare, // @parm Funzione indicante il criterio di ordinamento (default TSortable)
|
||||
void* jolly)
|
||||
|
||||
// @comm Nel caso non venga passata nessuna funzione che permetta di conforntare
|
||||
// i due oggetti viene utilizzato il criterio <c TSortable>
|
||||
{
|
||||
_cmp_func = compare;
|
||||
_cmp_jolly = jolly ? jolly : this;
|
||||
pack();
|
||||
qsort(_data, last()+1, sizeof(TObject*), compare_ex);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TString_array
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
int TString_array::add(const char* s, int n)
|
||||
{
|
||||
if (objptr(n) == NULL)
|
||||
n = TArray::add(new TToken_string(s), n);
|
||||
else
|
||||
row(n) = s;
|
||||
return n;
|
||||
}
|
||||
|
||||
int TString_array::add(TToken_string* s, int n)
|
||||
{ return TArray::add(s, n); }
|
||||
|
||||
int TString_array::add(const TToken_string& s, int n)
|
||||
{
|
||||
if (objptr(n) == NULL)
|
||||
n = TArray::add(s, n);
|
||||
else
|
||||
row(n) = s;
|
||||
return n;
|
||||
}
|
||||
|
||||
const TString_array& TString_array::operator=(const TString_array& a)
|
||||
{
|
||||
destroy();
|
||||
FOR_EACH_ARRAY_ROW_BACK(a, i, riga)
|
||||
add(*riga, i);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
|
||||
// @mfunc Cerca una stringa nell'array
|
||||
//
|
||||
// @rdesc Ritorna la posizione nell'array in cui si trova la stringa (-1 se non
|
||||
// e' stata trovata)
|
||||
int TString_array::find(
|
||||
const char* s, // @parm Stringa da cercare
|
||||
int from) const // @parm Posizione dalla quale cercare la stringa
|
||||
{
|
||||
int found = -1;
|
||||
for (int i = from; i < items(); i++)
|
||||
if (row(i).compare(s, -1, true) == 0)
|
||||
{
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
HIDDEN int ascending_string(const TObject** o1, const TObject** o2)
|
||||
{
|
||||
const TString* s1 = (const TString*)*o1;
|
||||
const TString* s2 = (const TString*)*o2;
|
||||
return strcmp(*s1, *s2);
|
||||
}
|
||||
|
||||
HIDDEN int descending_string(const TObject** o1, const TObject** o2)
|
||||
{
|
||||
return -ascending_string(o1, o2);
|
||||
}
|
||||
|
||||
void TString_array::sort(bool ascending)
|
||||
{
|
||||
TArray::sort(ascending ? ascending_string : descending_string);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
@ -14,6 +14,7 @@
|
||||
// @type COMPARE_FUNCTION | Prototipo funzione di confronto tra elementi della
|
||||
// classe <c TObject> da passare al metodo sort dei <c TArray>
|
||||
typedef int (*COMPARE_FUNCTION)(const TObject**, const TObject**);
|
||||
typedef int (*COMPARE_FUNCTION_EX)(const TSortable&, const TSortable&, void*);
|
||||
|
||||
// @doc EXTERNAL
|
||||
|
||||
@ -196,6 +197,7 @@ public:
|
||||
virtual void pack();
|
||||
// @cmember Ordina i TObject secondo il criterio definito in <t COMPARE_FUNCTION>
|
||||
void sort(COMPARE_FUNCTION = NULL);
|
||||
void sort(COMPARE_FUNCTION_EX cmp, void* jolly);
|
||||
};
|
||||
|
||||
inline TObject* TArray::objptr(int index) const
|
||||
@ -218,6 +220,70 @@ inline TObject& TArray::operator[] (int index) const
|
||||
(__obj = (__arr).objptr(__r)) != NULL; \
|
||||
__r = (__arr).pred(__r))
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TString_array
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __STRINGS_H
|
||||
class TToken_string;
|
||||
#endif
|
||||
|
||||
// @doc EXTERNAL
|
||||
|
||||
// @class TString_array | Array di stringhe
|
||||
//
|
||||
// @base public | TArray
|
||||
class TString_array : public TArray
|
||||
// @author:(INTERNAL) Guido
|
||||
{
|
||||
// @access Public Member
|
||||
public:
|
||||
// @cmember Ritorna la stringa n dell'array (se non c'e' ritorna errore)
|
||||
TToken_string& row(int n)
|
||||
{ return (TToken_string&)operator[](n); }
|
||||
// @cmember Ritorna la stringa n dell'array (se non c'e' ritorna errore)
|
||||
const TToken_string& row(int n) const
|
||||
{ return (const TToken_string&)operator[](n); }
|
||||
// @cmember Restituisce il puntatore alla stringa n dell'array (NULL se non esiste)
|
||||
TToken_string* rowptr(int n)
|
||||
{ return (TToken_string*)objptr(n); }
|
||||
// @cmember assegnamento di un array
|
||||
const TString_array& operator=(const TString_array& a);
|
||||
// @cmember Aggiunge una Token string all'array (chiama <mf TArray::add>)
|
||||
int add(TToken_string* s, int n = -1);
|
||||
// @cmember Aggiunge un oggetto stringa all'array (chiama <mf TArray::add>)
|
||||
int add(const TToken_string& s, int n = -1);
|
||||
// @cmember Aggiunge una stringa all'array (chiama <mf TArray::add>)
|
||||
int add(const char* s, int n = -1);
|
||||
// @cmember Cerca una stringa nell'array
|
||||
int find(const char* s, int from = 0) const;
|
||||
// @cmember Ordina alfabeticamente l'array
|
||||
void sort(bool ascendig = true);
|
||||
// @cmember Ritorna l'ultima riga (deve esistere!)
|
||||
TToken_string& last_row()
|
||||
{ return (TToken_string&)operator[](last()); }
|
||||
|
||||
// @cmember Costruttore
|
||||
TString_array(int size = 8) : TArray(size)
|
||||
{}
|
||||
// @cmember Distruttore
|
||||
virtual ~TString_array()
|
||||
{}
|
||||
};
|
||||
|
||||
#define FOR_EACH_ARRAY_ROW(__arr, __r, __riga) \
|
||||
TToken_string* __riga; \
|
||||
int __r; \
|
||||
for (__r = (__arr).first(); \
|
||||
(__riga = (TToken_string*)(__arr).objptr(__r)); \
|
||||
__r = (__arr).succ(__r))
|
||||
|
||||
#define FOR_EACH_ARRAY_ROW_BACK(__arr, __r, __riga) \
|
||||
TToken_string* __riga; \
|
||||
int __r; \
|
||||
for (__r = (__arr).last(); \
|
||||
(__riga = (TToken_string*)(__arr).objptr(__r)); \
|
||||
__r = (__arr).pred(__r))
|
||||
|
||||
class TPointer_array : public TArray
|
||||
{
|
||||
|
@ -1,6 +1,10 @@
|
||||
#ifndef __ASSOC_H
|
||||
#define __ASSOC_H
|
||||
|
||||
#ifndef __ARRAY_H
|
||||
#include <array.h>
|
||||
#endif
|
||||
|
||||
#ifndef __STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
@ -5,6 +5,11 @@
|
||||
#include <real.h>
|
||||
#endif
|
||||
|
||||
#ifndef __STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef TRectype
|
||||
class TRectype;
|
||||
#endif
|
||||
|
@ -937,6 +937,10 @@ class TEnigma_machine : public TObject
|
||||
protected:
|
||||
void init_key(char key[8]) const;
|
||||
bool decode_string(const TString& datain, TString& dataout) const;
|
||||
bool encode_string(const TString& linein, TString& lineout) const;
|
||||
|
||||
bool init();
|
||||
void uninit();
|
||||
|
||||
public:
|
||||
virtual bool ok() const { return _scan != NULL && !_scan->eof(); }
|
||||
@ -945,6 +949,8 @@ public:
|
||||
bool find_serno(long serno);
|
||||
int year_assist() const { return _year_assist; }
|
||||
|
||||
bool encode(const TString& txtfile); // dninst.txt -> dninst.zip
|
||||
|
||||
TEnigma_machine();
|
||||
~TEnigma_machine();
|
||||
};
|
||||
@ -970,6 +976,22 @@ bool TEnigma_machine::decode_string(const TString& datain, TString& dataout) con
|
||||
return dataout.full();
|
||||
}
|
||||
|
||||
bool TEnigma_machine::encode_string(const TString& linein, TString& lineout) const
|
||||
{
|
||||
lineout.cut(0);
|
||||
if (linein.full() && !linein.starts_with("//"))
|
||||
{
|
||||
char key[8]; init_key(key);
|
||||
char* buf = lineout.get_buffer(linein.len());
|
||||
size_t i = 0;
|
||||
for (i = 0; linein[i]; i++)
|
||||
buf[i] = linein[i] + (i < 8 ? key[i] : linein[i - 8]);
|
||||
buf[i] = '\0';
|
||||
}
|
||||
return lineout.full();
|
||||
}
|
||||
|
||||
|
||||
bool TEnigma_machine::line(TString& data)
|
||||
{ return _scan != NULL ? decode_string(_scan->line(), data) : false; }
|
||||
|
||||
@ -999,9 +1021,47 @@ bool TEnigma_machine::find_serno(long serno)
|
||||
return false;
|
||||
}
|
||||
|
||||
TEnigma_machine::TEnigma_machine()
|
||||
: _scan(NULL), _year_assist(0)
|
||||
bool TEnigma_machine::encode(const TString& txtfile)
|
||||
{
|
||||
uninit();
|
||||
|
||||
ofstream o(DNINST_PATH);
|
||||
|
||||
TString lineout;
|
||||
|
||||
TScanner s(txtfile);
|
||||
const TString& year = s.line();
|
||||
::srand(883);
|
||||
encode_string(year, lineout);
|
||||
o << lineout << endl;
|
||||
::srand(atoi(year));
|
||||
while (s.good())
|
||||
{
|
||||
const TString& linein = s.line();
|
||||
if (linein.empty())
|
||||
break;
|
||||
encode_string(linein, lineout);
|
||||
o << lineout << endl;
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
return o.good();
|
||||
}
|
||||
|
||||
void TEnigma_machine::uninit()
|
||||
{
|
||||
_year_assist = 0;
|
||||
if (_scan != NULL)
|
||||
{
|
||||
delete _scan;
|
||||
_scan = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool TEnigma_machine::init()
|
||||
{
|
||||
uninit();
|
||||
if (fexist(DNINST_PATH))
|
||||
{
|
||||
_scan = new TScanner(DNINST_PATH);
|
||||
@ -1010,13 +1070,15 @@ TEnigma_machine::TEnigma_machine()
|
||||
_year_assist = atoi(l1);
|
||||
::srand(_year_assist);
|
||||
}
|
||||
return _scan != NULL;
|
||||
}
|
||||
|
||||
TEnigma_machine::TEnigma_machine()
|
||||
: _scan(NULL), _year_assist(0)
|
||||
{ init(); }
|
||||
|
||||
TEnigma_machine::~TEnigma_machine()
|
||||
{
|
||||
if (_scan != NULL)
|
||||
delete _scan;
|
||||
}
|
||||
{ uninit(); }
|
||||
|
||||
int Tdninst::assistance_year2solar(int ay) const
|
||||
{ return (ay/1000)*1000 + (ay%1000)/10; }
|
||||
@ -1300,6 +1362,64 @@ bool Tdninst::find_expiring(int days, TString& module, TDate& expires) const
|
||||
return module.full();
|
||||
}
|
||||
|
||||
int Tdninst::check_customer() const
|
||||
{
|
||||
int error = 2; // Not found
|
||||
|
||||
const word serno = dongle().number();
|
||||
if (serno == 0)
|
||||
error = is_power_station() ? 0 : 2;
|
||||
else
|
||||
{
|
||||
TEnigma_machine em;
|
||||
if (em.ok() && em.year_assist() > 2100 && em.find_serno(serno))
|
||||
{
|
||||
error = 0;
|
||||
const TDate oggi(TODAY);
|
||||
TToken_string l(80, '=');
|
||||
TString16 str;
|
||||
TDate ds;
|
||||
while (em.line(l) && error == 0)
|
||||
{
|
||||
if (l.empty() || l[0] == '[')
|
||||
break;
|
||||
if (parse_date(l, str, ds))
|
||||
{
|
||||
if (ds >= oggi)
|
||||
{
|
||||
if (str == "*")
|
||||
error = 2; else
|
||||
if (str == "MustCall")
|
||||
error = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
bool Tdninst::decode(const TString& f) const
|
||||
{
|
||||
ofstream o(f);
|
||||
|
||||
TEnigma_machine em;
|
||||
o << em.year_assist() << endl;
|
||||
|
||||
TString256 l;
|
||||
while (em.line(l))
|
||||
o << l << endl;
|
||||
|
||||
return em.ok();
|
||||
}
|
||||
|
||||
bool Tdninst::encode(const TString& f) const
|
||||
{
|
||||
TEnigma_machine em;
|
||||
return em.encode(f);
|
||||
}
|
||||
|
||||
Tdninst::Tdninst() : _year_assist(0)
|
||||
{
|
||||
TEnigma_machine s;
|
||||
|
@ -1,6 +1,10 @@
|
||||
#ifndef __DONGLE_H
|
||||
#define __DONGLE_H
|
||||
|
||||
#ifndef __ARRAY_H
|
||||
#include <array.h>
|
||||
#endif
|
||||
|
||||
#ifndef __DATE_H
|
||||
#include <date.h>
|
||||
#endif
|
||||
@ -118,6 +122,10 @@ public:
|
||||
bool find_serno() const;
|
||||
bool find_killed(TToken_string& kill_list) const;
|
||||
bool find_expiring(int days, TString& module, TDate& expires) const;
|
||||
int check_customer() const;
|
||||
|
||||
bool decode(const TString& txt) const; // dninst.zip -> dninst.txt
|
||||
bool encode(const TString& txt) const; // dninst.txt -> dninst.zip
|
||||
|
||||
Tdninst();
|
||||
};
|
||||
|
@ -9,6 +9,9 @@
|
||||
#include <stack.h>
|
||||
#endif
|
||||
|
||||
#ifndef __STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
// @doc INTERNAL
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <fraction.h>
|
||||
#include <strings.h>
|
||||
|
||||
|
||||
static __int64 mcd(__int64 a, __int64 b)
|
||||
{
|
||||
|
@ -5,8 +5,8 @@
|
||||
#include <date.h>
|
||||
#endif
|
||||
|
||||
#ifndef __STRINGS_H
|
||||
#include <strings.h>
|
||||
#ifndef __ARRAY_H
|
||||
#include <array.h>
|
||||
#endif
|
||||
|
||||
bool goto_url(const char* url);
|
||||
|
@ -1,6 +1,10 @@
|
||||
#ifndef __MAILBOX_H
|
||||
#define __MAILBOX_H
|
||||
|
||||
#ifndef __ARRAY_H
|
||||
#include <array.h>
|
||||
#endif
|
||||
|
||||
#ifndef __STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
@ -15,10 +19,7 @@
|
||||
//
|
||||
// @base public | TObject
|
||||
class TMessage : public TObject
|
||||
|
||||
// @author:(INTERNAL) Villa
|
||||
|
||||
|
||||
{
|
||||
// @cfriend TMailbox
|
||||
friend class TMailbox;
|
||||
|
@ -383,7 +383,7 @@ void TODBC_recordset::parsed_text(TString& sql) const
|
||||
TString pwd = conn.get(); pwd.strip("\"");
|
||||
TString dir = conn.get(); dir.strip("\"");
|
||||
if (!((TODBC_recordset*)this)->connect(dsn, usr, pwd, dir))
|
||||
error_box(TR("Impossibile connettersi al DSN %s"), (const char*)dsn);
|
||||
error_box(FR("Impossibile connettersi al DSN %s"), (const char*)dsn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <xvt.h>
|
||||
#include <real.h>
|
||||
#include <strings.h>
|
||||
|
||||
const real ZERO(0.0);
|
||||
const real UNO(1.0);
|
||||
|
@ -1,8 +1,8 @@
|
||||
#ifndef __REAL_H
|
||||
#define __REAL_H
|
||||
|
||||
#ifndef __STRINGS_H
|
||||
#include <strings.h>
|
||||
#ifndef __ARRAY_H
|
||||
#include <array.h>
|
||||
#endif
|
||||
|
||||
#define ALL_DECIMALS 883
|
||||
|
@ -1657,6 +1657,6 @@ long TRecordset_sheet::get_items() const
|
||||
}
|
||||
|
||||
TRecordset_sheet::TRecordset_sheet(TRecordset& query, const char* title, byte buttons)
|
||||
: TSheet(-1, -1, -2, -4, title, query.sheet_head(), buttons), _query(query)
|
||||
: TSheet(-1, -1, -2, -5, title, query.sheet_head(), buttons, 1), _query(query)
|
||||
{
|
||||
}
|
||||
|
@ -255,10 +255,16 @@ void TRelation_application::enable_query()
|
||||
set_fixed();
|
||||
}
|
||||
|
||||
bool TRelation_application::can_I_write(const TRelation* rel) const
|
||||
{ return user_can_write(rel); }
|
||||
|
||||
bool TRelation_application::can_I_read(const TRelation* rel) const
|
||||
{ return user_can_write(rel); }
|
||||
|
||||
void TRelation_application::set_toolbar()
|
||||
{
|
||||
const int mode = _mask->mode();
|
||||
const bool can_edit_some = user_can_write(NULL);
|
||||
const bool can_edit_some = can_I_write(NULL);
|
||||
const bool can_nav = _lnflag == 0 && _curr_transaction != TRANSACTION_LINK;
|
||||
|
||||
int pos = _mask->id2pos(DLG_SAVEREC);
|
||||
@ -266,7 +272,7 @@ void TRelation_application::set_toolbar()
|
||||
{
|
||||
bool enabsave=mode != MODE_QUERY;
|
||||
if (enabsave)
|
||||
enabsave = user_can_write(get_relation());
|
||||
enabsave = can_I_write(get_relation());
|
||||
_mask->fld(pos).enable(enabsave);
|
||||
}
|
||||
pos = _mask->id2pos(DLG_DELREC);
|
||||
@ -474,9 +480,9 @@ void TRelation_application::insert_mode()
|
||||
r->zero();
|
||||
_mask->autosave(*r);
|
||||
|
||||
if (!user_can_write(r))
|
||||
if (!can_I_write(r))
|
||||
{
|
||||
warning_box(FR("L'utente %s non puo' inserire in questo archivio"), (const char*)user());
|
||||
warning_box(FR("L'utente %s non puo' inserire %s"), (const char*)user(), r->file().description());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -514,14 +520,14 @@ void TRelation_application::insert_mode()
|
||||
bool TRelation_application::modify_mode()
|
||||
{
|
||||
TRelation* rel = get_relation();
|
||||
if (!user_can_read(rel))
|
||||
if (!can_I_read(rel))
|
||||
{
|
||||
warning_box(TR("I dati non sono accessibili per l'utente %s"), (const char*)user());
|
||||
query_mode();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
const TReclock block = user_can_write(rel) ? _testandlock : _nolock;
|
||||
const TReclock block = can_I_write(rel) ? _testandlock : _nolock;
|
||||
int err = rel->read(_isequal, block);
|
||||
if (err != NOERR)
|
||||
{
|
||||
@ -1409,7 +1415,7 @@ void TRelation_application::main_loop()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (save_and_new())
|
||||
if (save_and_new() && can_I_write(NULL))
|
||||
{
|
||||
if (_mask->insert_mode())
|
||||
insert_mode();
|
||||
|
@ -199,6 +199,9 @@ protected:
|
||||
|
||||
// @cmember Richiede se il record corrente e' protetto (non cancellabile)
|
||||
virtual bool protected_record(TRelation &);
|
||||
|
||||
virtual bool can_I_write(const TRelation* rel) const;
|
||||
virtual bool can_I_read(const TRelation* rel) const;
|
||||
|
||||
// @cmember Inizializza la maschera per il modo ricerca
|
||||
virtual void init_query_mode(TMask&)
|
||||
|
@ -2060,76 +2060,6 @@ void TParagraph_string::tokenize()
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TString_array
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
int TString_array::add(const char* s, int n)
|
||||
{
|
||||
if (objptr(n) == NULL)
|
||||
n = TArray::add(new TToken_string(s), n);
|
||||
else
|
||||
row(n) = s;
|
||||
return n;
|
||||
}
|
||||
|
||||
int TString_array::add(const TToken_string& s, int n)
|
||||
{
|
||||
if (objptr(n) == NULL)
|
||||
n = TArray::add(s, n);
|
||||
else
|
||||
row(n) = s;
|
||||
return n;
|
||||
}
|
||||
|
||||
const TString_array& TString_array::operator=(const TString_array& a)
|
||||
{
|
||||
destroy();
|
||||
for (int i = a.last(); i >= 0; i = a.pred(i))
|
||||
{
|
||||
const TToken_string& s = a.row(i);
|
||||
add(s, i);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
|
||||
// @mfunc Cerca una stringa nell'array
|
||||
//
|
||||
// @rdesc Ritorna la posizione nell'array in cui si trova la stringa (-1 se non
|
||||
// e' stata trovata)
|
||||
int TString_array::find(
|
||||
const char* s, // @parm Stringa da cercare
|
||||
int from) const // @parm Posizione dalla quale cercare la stringa
|
||||
{
|
||||
int found = -1;
|
||||
for (int i = from; i < items(); i++)
|
||||
if (row(i).compare(s, -1, true) == 0)
|
||||
{
|
||||
found = i;
|
||||
break;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
HIDDEN int ascending_string(const TObject** o1, const TObject** o2)
|
||||
{
|
||||
const TString* s1 = (const TString*)*o1;
|
||||
const TString* s2 = (const TString*)*o2;
|
||||
return strcmp(*s1, *s2);
|
||||
}
|
||||
|
||||
HIDDEN int descending_string(const TObject** o1, const TObject** o2)
|
||||
{
|
||||
return -ascending_string(o1, o2);
|
||||
}
|
||||
|
||||
void TString_array::sort(bool ascending)
|
||||
{
|
||||
TArray::sort(ascending ? ascending_string : descending_string);
|
||||
}
|
||||
|
||||
// Temporary strings generator: a little step for a man, a big step for campo!
|
||||
|
||||
TToken_string& get_tmp_string(int len)
|
||||
|
@ -1,12 +1,8 @@
|
||||
#ifndef __STRINGS_H
|
||||
#define __STRINGS_H
|
||||
|
||||
#ifndef _INC_STRING
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifndef __ARRAY_H
|
||||
#include <array.h>
|
||||
#ifndef __OBJECT_H
|
||||
#include <object.h>
|
||||
#endif
|
||||
|
||||
#define SAFE_PIPE_CHR '¦'
|
||||
@ -694,77 +690,12 @@ public:
|
||||
{ _width = width; }
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// DES TString_array
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
// @doc EXTERNAL
|
||||
|
||||
// @class TString_array | Array di stringhe
|
||||
//
|
||||
// @base public | TArray
|
||||
class TString_array : public TArray
|
||||
// @author:(INTERNAL) Guido
|
||||
{
|
||||
// @access Public Member
|
||||
public:
|
||||
// @cmember Ritorna la stringa n dell'array (se non c'e' ritorna errore)
|
||||
TToken_string& row(int n)
|
||||
{ return (TToken_string&)operator[](n); }
|
||||
// @cmember Ritorna la stringa n dell'array (se non c'e' ritorna errore)
|
||||
const TToken_string& row(int n) const
|
||||
{ return (const TToken_string&)operator[](n); }
|
||||
// @cmember Restituisce il puntatore alla stringa n dell'array (NULL se non esiste)
|
||||
TToken_string* rowptr(int n)
|
||||
{ return (TToken_string*)objptr(n); }
|
||||
// @cmember assegnamento di un array
|
||||
const TString_array& operator=(const TString_array& a);
|
||||
// @cmember Aggiunge una Token string all'array (chiama <mf TArray::add>)
|
||||
int add(TToken_string* s, int n = -1)
|
||||
{ return TArray::add(s, n); }
|
||||
// @cmember Aggiunge un oggetto stringa all'array (chiama <mf TArray::add>)
|
||||
int add(const TToken_string& s, int n = -1);
|
||||
// @cmember Aggiunge una stringa all'array (chiama <mf TArray::add>)
|
||||
int add(const char* s, int n = -1);
|
||||
// @cmember Cerca una stringa nell'array
|
||||
int find(const char* s, int from = 0) const;
|
||||
// @cmember Ordina alfabeticamente l'array
|
||||
void sort(bool ascendig = true);
|
||||
|
||||
// @cmember Costruttore
|
||||
TString_array(int size = 8) : TArray(size)
|
||||
{}
|
||||
// @cmember Distruttore
|
||||
virtual ~TString_array()
|
||||
{}
|
||||
};
|
||||
|
||||
TString& user();
|
||||
|
||||
TToken_string& get_tmp_string(int len = -1);
|
||||
|
||||
const TToken_string& empty_string();
|
||||
#define EMPTY_STRING empty_string()
|
||||
|
||||
#define FOR_EACH_ARRAY_ROW(__arr, __r, __riga) \
|
||||
TToken_string* __riga; \
|
||||
int __r; \
|
||||
for (__r = (__arr).first(); \
|
||||
(__riga = (TToken_string*)(__arr).objptr(__r)); \
|
||||
__r = (__arr).succ(__r))
|
||||
|
||||
#define FOR_EACH_ARRAY_ROW_BACK(__arr, __r, __riga) \
|
||||
TToken_string* __riga; \
|
||||
int __r; \
|
||||
for (__r = (__arr).last(); \
|
||||
(__riga = (TToken_string*)(__arr).objptr(__r)); \
|
||||
__r = (__arr).pred(__r))
|
||||
|
||||
const char SLASH =
|
||||
#if XVT_OS == XVT_OS_WIN32
|
||||
'\\';
|
||||
#else
|
||||
'/';
|
||||
#endif
|
||||
const char SLASH = '\\';
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,10 @@
|
||||
#ifndef __TEXTFILE_H
|
||||
#define __TEXTFILE_H
|
||||
|
||||
#ifndef __ARRAY_H
|
||||
#include <array.h>
|
||||
#endif
|
||||
|
||||
#ifndef __STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
@ -9,6 +9,10 @@
|
||||
#include <real.h>
|
||||
#endif
|
||||
|
||||
#ifndef __STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#ifndef __RECTYPES_H
|
||||
#include <rectypes.h>
|
||||
#endif
|
||||
|
@ -1,6 +1,10 @@
|
||||
#ifndef __WINDOW_H
|
||||
#define __WINDOW_H
|
||||
|
||||
#ifndef __ARRAY_H
|
||||
#include <array.h>
|
||||
#endif
|
||||
|
||||
#ifndef __STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
@ -20,12 +24,14 @@ WINDOW cur_win();
|
||||
// @author:(INTERNAL) Guido
|
||||
struct TSize
|
||||
{
|
||||
// @cmember Coordinate del punto
|
||||
// @cmember Larghezza ed altezza
|
||||
long x, y;
|
||||
|
||||
bool operator ==(const TSize& s) const { return s.x == x && s.y == y; }
|
||||
bool operator !=(const TSize& s) const { return s.x != x || s.y != y; }
|
||||
|
||||
TSize& operator =(const TSize& s) { x = s.x; y = s.y; return *this; }
|
||||
|
||||
TSize() : x(0), y(0) {}
|
||||
TSize(long cx, long cy) : x(cx), y(cy) {}
|
||||
TSize(const TSize& s) : x(s.x), y(s.y) {}
|
||||
|
@ -518,11 +518,7 @@ void TXmlItem::AsString(TString& str) const
|
||||
{
|
||||
char* buf = str.get_buffer(nSize);
|
||||
memset(buf, 0, nSize);
|
||||
#ifdef WIN32
|
||||
ostrstream outf(buf, nSize);
|
||||
#else
|
||||
ostringstream outf(buf);
|
||||
#endif
|
||||
|
||||
Write(outf, 0);
|
||||
if (buf[nSize-1] == '\0')
|
||||
@ -538,8 +534,25 @@ void TXmlItem::Save(const char* strFilename) const
|
||||
|
||||
bool TXmlItem::Load(const char* strFilename)
|
||||
{
|
||||
ifstream qry(strFilename);
|
||||
return Read(qry);
|
||||
bool ok = false;
|
||||
if (strFilename && *strFilename)
|
||||
{
|
||||
if (strncmp(strFilename, "http://", 7) == 0 || strncmp(strFilename, "ftp://", 6) == 0)
|
||||
{
|
||||
TFilename tmp; tmp.temp(NULL, "xml");
|
||||
xvt_fsys_fcopy(strFilename, tmp);
|
||||
ifstream qry(tmp);
|
||||
ok = Read(qry);
|
||||
qry.close();
|
||||
xvt_fsys_remove_file(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
ifstream qry(strFilename);
|
||||
ok = Read(qry);
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
static bool FindFirstCallback(TXmlItem& item, long jolly)
|
||||
|
Loading…
x
Reference in New Issue
Block a user