From 80e4d5fb3e1975f5f956a33f886306f6af56c897 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 27 Mar 2003 12:14:51 +0000 Subject: [PATCH] Patch level : 2.0 nopatch Files correlati : tutti Ricompilazione Demo : [ ] Commento : Cancellato un sacco, una sporta ed un sacchettino di plastica di roba inutile: riferimenti a FOXPRO, simboli doppi, __tmp_string e compagnia bella. git-svn-id: svn://10.65.10.50/trunk@10949 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/applicat.cpp | 3 - include/ccommon.h | 33 ++-------- include/cfiles.c | 12 ++-- include/dongle.cpp | 8 --- include/execp.cpp | 2 +- include/extctype.h | 3 + include/files.cpp | 8 +-- include/form.cpp | 35 +++++------ include/mask.cpp | 18 +----- include/os_dep.h | 9 +-- include/os_win32.cpp | 140 +++---------------------------------------- include/prefix.cpp | 12 ++-- include/printer.cpp | 6 +- include/relapp.cpp | 2 +- include/stdtypes.h | 71 +++++----------------- include/strings.cpp | 25 ++++---- include/strings.h | 5 +- include/utility.cpp | 29 ++++----- include/viswin.cpp | 4 +- include/xvtility.cpp | 34 +++++++++-- 20 files changed, 135 insertions(+), 324 deletions(-) diff --git a/include/applicat.cpp b/include/applicat.cpp index dcaff371c..15accc87a 100755 --- a/include/applicat.cpp +++ b/include/applicat.cpp @@ -345,7 +345,6 @@ long TApplication::task_eh(WINDOW win, EVENT *ep) create_backdrop(); do_events(); - os_allow_another_instance(); } break; case E_UPDATE: @@ -557,8 +556,6 @@ bool TApplication::destroy() void TApplication::terminate() { - os_wake_up_caller(); - close_all_dialogs(); if (_create_ok) diff --git a/include/ccommon.h b/include/ccommon.h index ccd8475f5..5fb493523 100755 --- a/include/ccommon.h +++ b/include/ccommon.h @@ -78,7 +78,7 @@ #define CCLEAREOL(w) xwclrtoeol(WINHND(w)) #define CCLEAREOS(w) xwclrtobot(WINHND(w)) #define CCLEARWIN(w) xpaint(WINHND(w), setattr[warr[(w)].bkat][iscolordisp]) -#define INSET(c,s) (ustrchr((s), (c)) != (uchar *) NULL) +#define INSET(c,s) (ustrchr((s), (c)) != (byte *) NULL) #define CBITTEST(w,p) (((w) & (0x0001 << (p))) != 0) #define CBITSET(w,p,v) ((v) ? ((w) |= (0x0001 << (p))) : ((w) &= (~(0x0001 << (p))))) /* @(!) 2.3.01.temp */ @@ -87,43 +87,18 @@ #endif /* @(:) 2.3.01.temp */ #define NoErr 0 -//#define BADSIG (int (*)()) -1 -//#define MAXMENUITEM 21 -//#define MAXWIN 20 -//#define MAXBORDERS 8 -//#define MAXATTRS 20 -//#define BackCh '_' + #define directory "dir.gen" #define ntrrec "trc.gen" #define nditta "dta.gen" -//#define printers "prt.gen" -//#define prcodes "prc.gen" -//#define WWMESS 0 -//#define WWBAR 1 - -/* gia' definito in gm.h - typedef unsigned int word; - */ -typedef unsigned char byte; -#ifndef DOS -typedef unsigned char uchar; -#endif -#ifdef FOXPRO -typedef unsigned char uchar; -#endif -#ifdef XVT -#ifdef DOS -typedef unsigned char uchar; -#endif -#endif - +typedef unsigned char byte; typedef char Str8[9]; typedef char Str25[26]; typedef char Str30[32]; typedef char Str80[82]; typedef char Str255[256]; -typedef uchar StCh[256]; +typedef byte StCh[256]; typedef long TrDate; typedef char PathSt[82]; diff --git a/include/cfiles.c b/include/cfiles.c index a1f0be13c..400234e2f 100755 --- a/include/cfiles.c +++ b/include/cfiles.c @@ -2,7 +2,6 @@ #ifdef DOS -#define XVT_INCL_NATIVE #include #include @@ -385,7 +384,8 @@ HIDDEN const char* prefname() { #ifdef DOS char *s1 = getenv("PREFPATH"); - if (s1 == NULL) s1 = "campo.ini"; + if (s1 == NULL) + s1 = "campo.ini"; s = strdup(s1); #else s = malloc(32); @@ -428,7 +428,7 @@ HIDDEN BOOLEAN CGetPrawin() BOOLEAN good = _access(prawin, 0x00) == 0; if (good) { - UINT len = GetPrivateProfileString("Main", "Study", "", __ptprf, sizeof(__ptprf), prawin); + const int len = xvt_sys_get_profile_string(prawin, "Main", "Study", "", __ptprf, sizeof(__ptprf)); good = len > 0; if (good) { @@ -441,7 +441,7 @@ HIDDEN BOOLEAN CGetPrawin() __ptprf[len+1] = '\0'; } - GetPrivateProfileString("Main", "Firm", "COM", firm, sizeof(firm), prawin); + xvt_sys_get_profile_string(prawin, "Main", "Firm", "COM", firm, sizeof(firm)); ditta = atol(firm); if (ditta > 0) sprintf(firm, "%05ldA", ditta); _makepath(cprefix, NULL, __ptprf, firm, NULL); @@ -454,8 +454,8 @@ HIDDEN BOOLEAN CGetPrawin() BOOLEAN CPutPrawin(const char* pref) { const char* prawin = CGetPrawinName(); - BOOLEAN good = WritePrivateProfileString("Main", "Firm", pref, prawin); - WritePrivateProfileString("Main", "Study", __ptprf, prawin); + BOOLEAN good = xvt_sys_set_profile_string(prawin, "Main", "Firm", pref); + xvt_sys_set_profile_string(prawin, "Main", "Study", __ptprf); return good; } diff --git a/include/dongle.cpp b/include/dongle.cpp index f39f0826b..f7ec04f35 100755 --- a/include/dongle.cpp +++ b/include/dongle.cpp @@ -1,4 +1,3 @@ -#define XVT_INCL_NATIVE #include #include @@ -18,7 +17,6 @@ #define USERADR 26952 #define AGAADR 26953 #define PRASSIADR 26954 -#define PROCOMADR 26956 #define REFKEY (unsigned char*)"CAMPOKEY" #define VERKEY (unsigned char*)"ìpÙˆ¬cê<" @@ -288,12 +286,6 @@ bool TDongle::hardlock_login(bool test_all_keys) HL_LOGOUT(); if (HL_LOGIN(PRASSIADR, LOCAL_DEVICE, REFKEY, VERKEY) == STATUS_OK) _type = _prassi_dongle; - else - { - HL_LOGOUT(); - if (HL_LOGIN(PROCOMADR, LOCAL_DEVICE, REFKEY, VERKEY) == STATUS_OK) - _type = _procom_dongle; - } } } HL_LOGOUT(); diff --git a/include/execp.cpp b/include/execp.cpp index 0c288e525..cc8e3a0cf 100755 --- a/include/execp.cpp +++ b/include/execp.cpp @@ -27,7 +27,7 @@ word TExternal_app::run( comm_name.custom_path(); TString name(comm_name.name()); - if (utente == TRUE) // utente puo' essere 0 = No, 1 = Si, 3 = Forzatura + if (utente == 1) // utente puo' essere 0 = No, 1 = Si, 3 = Forzatura { bool our_app = name.len() > 2; if (our_app && atoi(name) < 70) diff --git a/include/extctype.h b/include/extctype.h index 73130b4cc..ceb38185d 100755 --- a/include/extctype.h +++ b/include/extctype.h @@ -39,6 +39,9 @@ #define MOSTMEM 51200 #define LEASTMEM 10240 +#define INT16 short +#define UINT16 unsigned short + /* @END */ /* @T */ diff --git a/include/files.cpp b/include/files.cpp index 167e7b068..2e739f2eb 100755 --- a/include/files.cpp +++ b/include/files.cpp @@ -196,15 +196,13 @@ const char* TDir::tab_des(const char* tab) { const char* t = tab; if (t[0] == '$' || t[0] == '%') t++; - TString256 tmp; + TString& tmp = get_tmp_string(); tmp << DESCDIR << "/d" << t << ".des"; -#ifndef FOXPRO TConfig cnf(tmp, DESCTAB); - t = cnf.get("Description", NULL, -1, tab); -#endif + tmp = cnf.get("Description", NULL, -1, tab); - return strcpy(__tmp_string, t); + return tmp; } diff --git a/include/form.cpp b/include/form.cpp index 161030462..5a9b1bd67 100755 --- a/include/form.cpp +++ b/include/form.cpp @@ -448,9 +448,9 @@ void TForm_item::string_at(int x, int y, const char* s) if (_width > 0 && strlen(s) > (word)_width) // Tronca testo se necessario { - strncpy(__tmp_string, s, width()); - __tmp_string[_width] = '\0'; - s = __tmp_string; + TString& tmp = get_tmp_string(); + tmp.strncpy(s, _width); + s = tmp; } row.put(s, x-1); // Stampa testo } @@ -1187,15 +1187,15 @@ bool TForm_string::update() const char* TForm_string::example() const { - TString prova("XXXXXXXXXXXXXXXXXXXXXXXXXX"); + TString& prova = get_tmp_string(); + prova = "XXXXXXXXXXXXXXXXXXXXXXXXXX"; apply_format(prova); const int w = width(); - if (prova.size() > w && w > 0) prova.cut(w); - return strcpy(__tmp_string, prova); + if (prova.size() > w && w > 0) + prova.cut(w); + return prova; } - - /////////////////////////////////////////////////////////// // TForm_number /////////////////////////////////////////////////////////// @@ -1404,9 +1404,10 @@ void TForm_number::set_picture(const char *p) const char* TForm_number::example() const { - TString s("1234567890.123456"); + TString& s = get_tmp_string(); + s = "1234567890.123456"; apply_format(s); - return strcpy(__tmp_string, s); + return s; } /////////////////////////////////////////////////////////// @@ -1747,8 +1748,9 @@ const char* TForm_date::example() const { const TDate dd(TODAY); TFormatted_date d(dd); d.set_format(_format); - TString s(d.string()); - return strcpy(__tmp_string, s); + TString& s = get_tmp_string(); + s = d.string(); + return s; } /////////////////////////////////////////////////////////// @@ -3360,6 +3362,7 @@ void TForm::arrange_form() // CHR(15), allora prima del posizionamento scrivo il chr(15) sulla stampante! { +/* int i, x; TString str_pos; TMask m("ba2100c"); @@ -3386,14 +3389,8 @@ void TForm::arrange_form() os_spool_row(str_pos); os_close_spool_row(); } while (m.run() == K_ESC); // cicla sulla stampa posizionamento... -/* const int h = height(odd_page); - str_pos.cut(0); - for (i=0; i < h; i++) str_pos << "\n"; - lpt = fopen(device,"w"); - if (lpt == NULL) fatal_box("Non rieso ad aprire il device %s.",device); - fprintf(lpt, "%s", (const char*) str_pos); // Salta tante righe quanto e' lungo il form standard - fclose (lpt); */ printer().set_offset(-(_ipy-1), printer().get_column_offset()); +*/ } long TForm::records() const diff --git a/include/mask.cpp b/include/mask.cpp index a8d6b5a17..2d8c951ff 100755 --- a/include/mask.cpp +++ b/include/mask.cpp @@ -481,7 +481,7 @@ void TMask::start_run() for (int i = 0; i < max; i++) { TMask_field& f = fld(i); - if (f.dirty() <= TRUE) + if (f.dirty() <= 1) // Attenzione puo' valere anche 3 per i very dirty! { f.set_dirty(FALSE); const bool op = f.is_operable() && !f.is_kind_of(CLASS_BUTTON_FIELD); @@ -496,20 +496,8 @@ void TMask::start_run() for (int i = 0; i < max; i++) { TMask_field& f = fld(i); - -/* Guy: proviamo a fregarcene - if (query_mode() && f.is_edit() && f.in_key(1) && - !f.automagic() && !f.empty()) - { - f.set_dirty(TRUE); - } - else -*/ - - { - if (f.dirty() == TRUE) - f.set_dirty(FALSE); - } + if (f.dirty() == 1) // Attenzione puo' valere anche 3 per i very dirty! + f.set_dirty(FALSE); } _init_time = clock()-start; diff --git a/include/os_dep.h b/include/os_dep.h index e01ceea7c..f8a31c937 100755 --- a/include/os_dep.h +++ b/include/os_dep.h @@ -14,7 +14,6 @@ enum os_type { os_Unknown, os_Win32s, os_Windows, os_Windows95, os_Windows98, os_type os_get_type(); void os_post_menu_event(WINDOW win, MENU_TAG tag); -void os_set_event_hook(); unsigned long os_get_free_memory(); bool os_is_removable_drive(const char* path); @@ -26,16 +25,11 @@ bool os_test_disk_free_space(const char* path, unsigned long filesize_bytes); int os_execute(const TFilename& path, bool sync, bool iconizetask, bool showchild); unsigned long os_execute_in_window(const TFilename& path, WINDOW win); -bool os_file_exist(const char* path); bool os_destroy_native_icon(unsigned icon); void os_draw_native_icon(WINDOW win, const RCT& rct, unsigned icon); -bool os_allow_another_instance(); -bool os_deny_another_instance(); - bool os_spawn_by_menu(); -void os_wake_up_caller(); void os_iconize_window(WINDOW win); void os_maximize_window(WINDOW win); @@ -44,9 +38,12 @@ void os_restore_window(WINDOW win); int os_get_printer_names(TToken_string& printers); bool os_set_default_printer(const char* name); bool os_get_default_printer(TString& name); + +/* bool os_open_spool_row(const char* device); bool os_spool_row(const char* str); bool os_close_spool_row(); +*/ bool os_dongle_server_running(); diff --git a/include/os_win32.cpp b/include/os_win32.cpp index 06518d270..639bdabe5 100755 --- a/include/os_win32.cpp +++ b/include/os_win32.cpp @@ -12,70 +12,10 @@ #include #include -/////////////////////////////////////////////////////////// -// Win32 event hook -/////////////////////////////////////////////////////////// - -HIDDEN BOOLEAN event_hook(HWND hwnd, - UINT msg, - UINT wparam, - ULONG lparam, - long* ret) -{ - switch(msg) - { - case WM_MENUCHAR: - if (wparam > ' ' && wparam <= 'z') - { - WINDOW win = cur_win(); - if (win != NULL_WIN) - { - const KEY key = toupper(wparam)+K_CTRL; - dispatch_e_char(win, key); - *ret = 2 << 16; - } - } - break; - case WM_KEYDOWN: - if (wparam == VK_F1) - { - if ((lparam & (1<<29)) == 0) // Il tasto alt non e' premuto - { - KEY k = K_F1; - - int sc = GetAsyncKeyState(VK_CONTROL); // Stato del tasto control - if (sc & 0x8000) k += K_CTRL; - - int ss = GetAsyncKeyState(VK_SHIFT); // Stato del tasto shift - if (ss & 0x8000) k += K_SHIFT; - - WINDOW win = cur_win(); - if (win != NULL_WIN) - dispatch_e_char(win, k); - } - } - break; - default: - break; - } - - return TRUE; // Continua col processo normale -} - /////////////////////////////////////////////////////////// // Operating system dependent functions /////////////////////////////////////////////////////////// -bool os_allow_another_instance() -{ - return TRUE; -} - -bool os_deny_another_instance() -{ - return FALSE; -} - bool os_destroy_native_icon(unsigned icon) { return DestroyIcon((HICON)icon) != 0; @@ -131,8 +71,9 @@ static unsigned long get_disk_size(const char* path, bool tot, char unit) case 'T': nBytes >>= 40; break; // Terabytes default: break; } - unsigned long nVal = nBytes > ULONG_MAX ? (unsigned long)ULONG_MAX - : (unsigned long)nBytes; + + const unsigned long nMax = (unsigned long)(~0L); + unsigned long nVal = nBytes > nMax ? nMax : (unsigned long)nBytes; return nVal; } @@ -322,11 +263,10 @@ bool os_get_default_printer(TString& name) bool os_spawn_by_menu() { -#ifdef DBG - bool ok = TRUE; -#else - TString str = main_app().name(); - bool ok = str == "ba0100"; + bool ok = true; +#ifndef DBG + TString16 str = main_app().name(); + ok = str == "ba0100"; if (!ok) { str.insert("ba0100->", 0); @@ -369,72 +309,6 @@ void os_post_menu_event(WINDOW win, MENU_TAG tag) PostMessage(w, WM_COMMAND, tag, 0L); } -void os_set_event_hook() -{ - xvt_vobj_set_attr(NULL_WIN, ATTR_EVENT_HOOK, (long)event_hook); - - long twin_style = WSF_ICONIZABLE | WSF_CLOSE | WSF_SIZE; - const int scx = GetSystemMetrics(SM_CXSCREEN); - const int scy = GetSystemMetrics(SM_CYSCREEN); - static RCT rct; - if (scx <= 640 && os_get_type() >= os_Windows95) - { - const int bcx = GetSystemMetrics(SM_CXFRAME); - const int bcy = GetSystemMetrics(SM_CYFRAME); - rct.left = -bcx; - rct.top = GetSystemMetrics(SM_CYCAPTION)-bcy-1; - rct.right = scx+bcx; - rct.bottom = scy+bcy; - xvt_vobj_set_attr(NULL_WIN, ATTR_WIN_PM_TWIN_STARTUP_RCT, long(&rct)); - } - else - { - TConfig cfg(CONFIG_USER, "Colors"); - const int res = cfg.get_int("Resolution"); - if (res >= 640 && res < scx) - { - const int width = res + 2*GetSystemMetrics(SM_CXFRAME); - const int height = (res * 3) / 4 + 2*GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYCAPTION) - 1; - const int deltax = (scx - width) / 2; - const int deltay = (scy - height) / 2; - rct.left = deltax; - rct.top = deltay; - rct.right = deltax + width; - rct.bottom = deltay + height; - xvt_vobj_set_attr(NULL_WIN, ATTR_WIN_PM_TWIN_STARTUP_RCT, long(&rct)); - } - else - twin_style |= WSF_MAXIMIZED; - } - - xvt_vobj_set_attr(NULL_WIN,ATTR_WIN_PM_TWIN_STARTUP_STYLE, twin_style); -} - -void os_wake_up_caller() -{ - HWND hwnd = (HWND)xvt_vobj_get_attr(TASK_WIN, ATTR_NATIVE_WINDOW); -} - -bool os_file_exist(const char* file) -{ - return FALSE; -} - -bool os_open_spool_row(const char* device) -{ - return TRUE; -} - -bool os_spool_row(const char* str) -{ - return FALSE; -} - -bool os_close_spool_row() -{ - return TRUE; -} - void os_iconize_window(WINDOW win) { HWND hwnd = (HWND)xvt_vobj_get_attr(win, ATTR_NATIVE_WINDOW); diff --git a/include/prefix.cpp b/include/prefix.cpp index 32bc5a18a..65beeb785 100755 --- a/include/prefix.cpp +++ b/include/prefix.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -857,12 +858,13 @@ TFirm::TFirm(long code) // TPrefix /////////////////////////////////////////////////////////// -HIDDEN const char* const glockname = "xx"; - TPrefix::TPrefix() : _filelevel(0), _items(0), _firm(NULL) { _prefix = "."; CGetPref(); + + if (!fexist(__ptprf) || strchr(__ptprf, ' ') != NULL) + fatal_box(FR("Percorso dati non valido: '%s'"), __ptprf); const TFilename dir(cprefix); const long primaditta = atol(dir.name()); @@ -872,7 +874,6 @@ TPrefix::TPrefix() : _filelevel(0), _items(0), _firm(NULL) DB_init(); } - TPrefix::~TPrefix() { set(); @@ -988,7 +989,7 @@ bool TPrefix::test(const char* s) const s1.add("dir.gen"); if (!s1.exist()) - return error_box("Impossibile trovare il file '%s'", (const char*)s1); + return error_box(FR("Impossibile trovare il file '%s'"), (const char*)s1); } return TRUE; @@ -1043,6 +1044,9 @@ const char* TPrefix::get_studio() const bool TPrefix::set_studio(const char* study, long ditta) { TFilename dirtest(study); + if (!dirtest.exist() || dirtest.find(' ') >= 0) + return FALSE; + dirtest.add("com/dir.gen"); if (!dirtest.exist()) return FALSE; diff --git a/include/printer.cpp b/include/printer.cpp index 5c2c71b46..9988e1368 100755 --- a/include/printer.cpp +++ b/include/printer.cpp @@ -13,8 +13,6 @@ #include -#define STYLE_NUM 4 - HIDDEN TPrinter* _printer = NULL; TPrinter& printer() @@ -1697,8 +1695,10 @@ void TPrinter::print_txt(TTextfile& txt) xvt_print_open(); xvt_print_start_thread(start_print, (long) (&PrintWhat)); xvt_print_close(); +/* if (is_generic()) os_spool_row("\n"); // Force flushing on Generic printer +*/ } } @@ -1745,8 +1745,6 @@ void TPrinter::close () else if (_printertype == winprinter && _txt.lines() > 0L) { print_txt(_txt); - if (is_generic()) - os_spool_row("\n"); // Force flushing on Generic printer os_set_default_printer(_defPrinter); } else if (_printertype == fileprinter) diff --git a/include/relapp.cpp b/include/relapp.cpp index a5e66c4c1..9f3644d88 100755 --- a/include/relapp.cpp +++ b/include/relapp.cpp @@ -976,7 +976,7 @@ bool TRelation_application::save(bool check_dirty) const KEY last = _mask->last_key(); const bool annulla = last == K_ESC || last == K_QUIT || last == K_F9; - const bool errore = dirty && _mask->field(dirty).dirty() > TRUE; + const bool errore = dirty && _mask->field(dirty).dirty() > 1; KEY k; if (errore) diff --git a/include/stdtypes.h b/include/stdtypes.h index 345be8fa7..65232f4a2 100755 --- a/include/stdtypes.h +++ b/include/stdtypes.h @@ -1,11 +1,9 @@ #ifndef __STDTYPES_H #define __STDTYPES_H -#ifdef XVT #ifndef XVT_INCL_XVTENV #include #endif -#endif #ifndef DBG #ifndef NDEBUG @@ -20,76 +18,42 @@ #define EOL -1 #define NOERR 0 -// @doc EXTERNAL -// @type UINT8 | Altro nome di assegnazione per gli unsigned char -typedef unsigned char UINT8; - -// @type UINT16 | Altro nome di assegnazione per gli unsigned short -typedef unsigned short UINT16; - -// @doc EXTERNAL - -// @type UINT32 | Altro nome di assegnazione per gli unsigned long -#if XVT_OS==XVT_OS_WIN32 -typedef unsigned int UINT32; -#else -typedef unsigned long UINT32; -#endif -// @doc EXTERNAL - -// @type INT8 | Altro nome di assegnazione per i char -typedef char INT8; -// @type INT16 | Altro nome di assegnazione per gli short -typedef short INT16; - -// @doc EXTERNAL - -// @type INT32 | Altro nome di assegnazione per i long -#if XVT_OS==XVT_OS_WIN32 -typedef int INT32; -#else -typedef long INT32; -#endif // @doc EXTERNAL // @type bool | Tipo booleano che puo' assumere i valori TRUE (definito come 1) // e FALSE (definito come 0). -#if XVT_OS==XVT_OS_WIN32 - -#ifndef __cplusplus -typedef unsigned short bool; -#endif - +#ifdef __cplusplus + #ifndef FALSE + #define FALSE false + #define TRUE true + #endif #else - -typedef unsigned char bool; - -#endif - -#ifndef FALSE -#define FALSE 0 -#define TRUE 1 + typedef unsigned short bool; + #ifndef FALSE + #define FALSE 0 + #define TRUE 1 + #endif #endif // @doc EXTERNAL // @type word | Tipo per la definizione di tipi di lunghezza pari a due byte -typedef UINT16 word; +typedef unsigned short word; // @doc EXTERNAL // @type dword | Tipo per la definizione di tipi di lunghezza pari a quattro byte -typedef UINT32 dword; +typedef unsigned int dword; // @doc EXTERNAL // @type byte | Tipo per la definizione di tipi di lunghezza pari ad un byte -typedef UINT8 byte; +typedef unsigned char byte; // @doc EXTERNAL // @type KEY | Tipo per la definizione di variabili destinati a contenere i caratteri // immessi da tastiera -typedef UINT16 KEY; +typedef unsigned short KEY; #define UNDEFINED -32767 @@ -103,13 +67,6 @@ void set_std_level(const long l); void init_global_vars(); void free_global_vars(); -/* -#ifdef __cplusplus -extern void* operator new(unsigned); -extern void operator delete(void*); -#endif -*/ - #endif // __STDTYPES_H diff --git a/include/strings.cpp b/include/strings.cpp index 24a0d19aa..547d4c657 100755 --- a/include/strings.cpp +++ b/include/strings.cpp @@ -754,6 +754,21 @@ TString& TString::picture( return *this; } +// Certified 99% (s != NULL) +int TString::strncpy(const char* s, int n) +{ + if (n > size()) + resize(n, FALSE); + int i = 0; + if (s && *s) + { + for (; *s && i < n; i++) + _str[i] = *s++; + } + _str[i] = '\0'; + return i; +} + // Certified 90% (spark size limited) // @doc EXTERNAL @@ -940,16 +955,6 @@ void TFixed_string::resize(int size, bool) _size, size, _str); } -// Certified 99% (s != NULL) -void TFixed_string::strncpy(const char* s, int n) -{ - CHECKD(n <= _size, "Fixed string can't be strncpyed: lenght ", n); - int i = 0; - if (s && *s) - for (; *s && i < n; i++) _str[i] = *s++; - _str[i] = '\0'; -} - // Certified 99% // @doc EXTERNAL diff --git a/include/strings.h b/include/strings.h index b0383fa55..a0a5cc5bd 100755 --- a/include/strings.h +++ b/include/strings.h @@ -168,6 +168,9 @@ public: // @cmember Formatta una stringa usando il formato dato da pic TString& picture(const char* pic, const char* s); + // @cmember Copia n caratteri nella stringa oggetto + int strncpy(const char* s, int n); + // @cmember Manda un output formattato alla stringa oggetto virtual TString& format(const char* fmt, ...); @@ -293,8 +296,6 @@ public: // @cmember Assegna la stringa passata const TString& operator =(const char* str) { return set(str); } - // @cmember Copia n caratteri nella stringa oggetto - void strncpy(const char* s, int n); }; diff --git a/include/utility.cpp b/include/utility.cpp index 81d0b3418..ee43a6dbc 100755 --- a/include/utility.cpp +++ b/include/utility.cpp @@ -1,5 +1,6 @@ #include +#include #include #include @@ -75,11 +76,6 @@ bool fexist( const char* file) // @parm Nome del file di cui contrallare l'esistenza { int err = access(file, 0x00); - if (err) // Se la access fallisce provo con una funzione dipendente dal sistema - { - if (os_file_exist(file)) - err = 0; - } return err == 0; } @@ -115,8 +111,6 @@ bool make_dir( return res == 0; } -#ifndef FOXPRO - // @doc EXTERNAL // @func Ritorna la lista dei file il cui nome corrisponde alla stringa (con caratteri @@ -182,15 +176,19 @@ bool input_filename(TFilename& file) strcpy(fs.name, file); strcpy(fs.creator, "AGA"); - const bool good = xvt_dm_post_file_open(&fs, "Selezionare il file ...") == FL_OK; + const bool good = xvt_dm_post_file_open(&fs, TR("Selezionare il file")) == FL_OK; xvt_fsys_set_dir(&dir); - if (good) - file = fs.name; + if (good) + { + char buf[_MAX_PATH]; + xvt_fsys_convert_dir_to_str(&fs.dir, buf, sizeof(buf)); + file = buf; + file.add(fs.name); + } return good; } -#endif // Certified 99% // @doc EXTERNAL @@ -207,12 +205,15 @@ char* format( { va_list pars; + TString& tmp = get_tmp_string(512); + char* buf = tmp.get_buffer(); + va_start(pars, fmt); - const int tot = vsprintf(__tmp_string, fmt, pars); + const int tot = vsprintf(buf, fmt, pars); va_end(pars); - CHECK(tot >= 0 && tot < sizeof(__tmp_string)-1, "Ue'! Ma quanto scrivi?"); - return(__tmp_string); + CHECK(tot >= 0 && tot < 512, "Ue'! Ma quanto scrivi?"); + return buf; } // @doc EXTERNAL diff --git a/include/viswin.cpp b/include/viswin.cpp index 3faaa6be6..09808d97c 100755 --- a/include/viswin.cpp +++ b/include/viswin.cpp @@ -2603,8 +2603,8 @@ TViswin::TViswin(const char *fname, _showbuts = cnf.get_bool("Bottoni", NULL, -1,TRUE); // Se rulers vale 3 allora leggi dal config il vero valore - if (_rulers != FALSE && _rulers != TRUE) - _rulers = cnf.get_bool("Righelli", NULL, -1,TRUE); + if (_rulers != 0 && _rulers != 1) + _rulers = cnf.get_bool("Righelli", NULL, -1, TRUE); PRINT_HEIGHT = cnf.get_int("FontSize", NULL, -1, PRINT_HEIGHT); } diff --git a/include/xvtility.cpp b/include/xvtility.cpp index df538790b..079e56f77 100755 --- a/include/xvtility.cpp +++ b/include/xvtility.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -377,7 +378,34 @@ void set_xvt_hooks() { xvt_vobj_set_attr(NULL_WIN,ATTR_ERRMSG_HANDLER, (long)error_hook); xvt_vobj_set_attr(NULL_WIN,ATTR_WIN_PM_DRAWABLE_TWIN, TRUE); - os_set_event_hook(); + + long twin_style = WSF_ICONIZABLE | WSF_CLOSE | WSF_SIZE; + TConfig cfg(CONFIG_USER, "Colors"); + const int res = cfg.get_int("Resolution"); + + const int scx = xvt_vobj_get_attr(NULL_WIN, ATTR_SCREEN_WIDTH); + const int scy = xvt_vobj_get_attr(NULL_WIN, ATTR_SCREEN_HEIGHT); + if (res >= 640 && res < scx) + { + const fx = xvt_vobj_get_attr(NULL_WIN, ATTR_FRAME_WIDTH); + const fy = xvt_vobj_get_attr(NULL_WIN, ATTR_FRAME_HEIGHT); + const cy = xvt_vobj_get_attr(NULL_WIN, ATTR_TITLE_HEIGHT); + const int width = res + 2*fx; + const int height = (res * scy) / scx + 2*fy + cy; + const int deltax = (scx - width) / 2; + const int deltay = (scy - height) / 2; + + RCT rct; + rct.left = deltax; + rct.top = deltay; + rct.right = deltax + width; + rct.bottom = deltay + height; + xvt_vobj_set_attr(NULL_WIN, ATTR_WIN_PM_TWIN_STARTUP_RCT, long(&rct)); + } + else + twin_style |= WSF_MAXIMIZED; + + xvt_vobj_set_attr(NULL_WIN,ATTR_WIN_PM_TWIN_STARTUP_STYLE, twin_style); } // @doc INTERNAL @@ -388,15 +416,11 @@ void customize_controls( { if (on) { -//#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32 -// HInstance = (HINSTANCE)xvt_vobj_get_attr(NULL_WIN, ATTR_WIN_INSTANCE); -//#endif customize_colors(); init_controls(); } else { - os_deny_another_instance(); free_controls(); } }