2016-09-09 13:58:28 +00:00
|
|
|
#ifndef __UTILITY_H
|
|
|
|
#define __UTILITY_H
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __ARRAY_H
|
|
|
|
#include <array.h>
|
|
|
|
#endif
|
|
|
|
|
2020-09-24 07:19:56 +02:00
|
|
|
#ifndef __DATE_H
|
|
|
|
#include <date.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __STRINGS_H
|
|
|
|
#include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
2018-01-09 09:31:50 +00:00
|
|
|
#ifndef __VARIANT_H
|
|
|
|
#include <variant.h>
|
|
|
|
#endif
|
|
|
|
|
2019-06-11 11:07:47 +02:00
|
|
|
#include <lffiles.h>
|
|
|
|
|
2016-09-09 13:58:28 +00:00
|
|
|
#define STRINGIFY(x) #x
|
2020-05-19 19:32:56 +02:00
|
|
|
#define SAFE_DELETE(p) safe_delete(p)
|
2016-09-09 13:58:28 +00:00
|
|
|
#define TOSTRING(x) STRINGIFY(x)
|
2017-11-08 10:45:17 +00:00
|
|
|
#define DEBUG_ENABLED is_debug_station()
|
2016-09-09 13:58:28 +00:00
|
|
|
|
2019-12-09 09:36:04 +01:00
|
|
|
bool sirio_codesigning(const TFilename& filename, bool verify = false);
|
2019-11-28 11:04:32 +01:00
|
|
|
#define SIRIOSIGN(filename) sirio_codesigning((const TFilename&)((filename)), false)
|
|
|
|
#define SIRIOSIGN_VERIFY(filename) sirio_codesigning((const TFilename&)((filename)), true)
|
2021-03-16 13:39:22 +01:00
|
|
|
#define SIRIOCFPI "04879210963"
|
2019-11-27 18:04:18 +01:00
|
|
|
|
2020-11-25 07:32:41 +01:00
|
|
|
typedef enum { desktop_dir = 0, documents_dir, exec_dir, install_dir, temp_dir } TSystem_dirs;
|
|
|
|
|
2020-05-28 15:54:13 +02:00
|
|
|
template<typename T> void safe_delete(T*& a)
|
|
|
|
{
|
2020-05-19 19:32:56 +02:00
|
|
|
delete a;
|
|
|
|
a = nullptr;
|
|
|
|
}
|
2019-06-11 11:07:47 +02:00
|
|
|
|
2016-09-09 13:58:28 +00:00
|
|
|
class TPerformance_profiler : public TObject
|
|
|
|
{
|
|
|
|
TString _desc;
|
|
|
|
long _start;
|
|
|
|
bool _trc;
|
|
|
|
|
|
|
|
public:
|
|
|
|
void show() const;
|
|
|
|
|
|
|
|
TPerformance_profiler(const char* desc = "", bool trc = false);
|
|
|
|
~TPerformance_profiler();
|
|
|
|
};
|
|
|
|
|
|
|
|
char* format (const char* fmt, ...);
|
|
|
|
const char* cmd2name(const char* argv0, const char* argv1 = "");
|
|
|
|
int rtoi(const char * roman);
|
|
|
|
const char* itor(int i);
|
|
|
|
bool fcopy(const char* orig, const char* dest, bool append = false, bool advanced = false);
|
2020-09-24 07:19:56 +02:00
|
|
|
bool fmove(const char* orig, const char* dest, bool append = false, bool advanced = false);
|
2016-09-09 13:58:28 +00:00
|
|
|
bool fexist(const char* file);
|
|
|
|
long fsize(const char* file);
|
|
|
|
bool dexist(const char* file);
|
2020-11-25 07:32:41 +01:00
|
|
|
void log_message(const char* fmt, ...);
|
2020-09-24 07:19:56 +02:00
|
|
|
|
2021-01-20 17:10:55 +01:00
|
|
|
const time_t atime(const char* file); // access time
|
|
|
|
const time_t ctime(const char* file); // creation time
|
|
|
|
const time_t mtime(const char* file); // modification time
|
2020-09-24 07:19:56 +02:00
|
|
|
struct tm * altime(const char* file); // access local time
|
|
|
|
struct tm * cltime(const char* file); // creation local time
|
|
|
|
struct tm * mltime(const char* file); // creation local time
|
|
|
|
TDate aldate(const char* file); // creation date
|
|
|
|
TDate cldate(const char* file);// modification date
|
|
|
|
TDate mldate(const char* file);// access date
|
|
|
|
|
2016-09-09 13:58:28 +00:00
|
|
|
bool make_dir(const char* dir);
|
|
|
|
bool remove_file(const char* file);
|
|
|
|
int remove_files(const char* mask, bool subdirs);
|
|
|
|
int count_files(const char* dir, bool subdirs);
|
|
|
|
int list_files(const char* mask, TString_array& result);
|
2021-12-13 12:58:48 +01:00
|
|
|
bool input_filename(TFilename& file, bool existent = true);
|
|
|
|
|
2020-11-25 07:32:41 +01:00
|
|
|
const char * get_system_dir(TSystem_dirs what);
|
2021-10-08 22:30:54 +02:00
|
|
|
const char * standard_path_list();
|
2016-09-09 13:58:28 +00:00
|
|
|
|
|
|
|
const char* encode(const char* data);
|
|
|
|
const char* decode(const char* data);
|
|
|
|
|
|
|
|
inline bool is_slash(char s) // @parm Carattere da confrontare
|
|
|
|
{ return s == '\\' || s == '/'; }
|
|
|
|
|
|
|
|
inline bool is_not_slash(char s) // @parm Carattere da confrontare
|
|
|
|
{ return s != '\\' && s != '/'; }
|
|
|
|
|
|
|
|
const char* esc(const char* str); // Trasforma le sequenze "\n" nel carattere '\n'
|
|
|
|
const char* unesc(const char* str); // Trasforma i caratteri '\n' nella sequenza "\n"
|
|
|
|
|
|
|
|
istream& eatwhite (istream& i);
|
|
|
|
|
|
|
|
const TString& get_hostname();
|
2017-11-08 10:45:17 +00:00
|
|
|
bool is_debug_station();
|
2016-09-09 13:58:28 +00:00
|
|
|
bool is_power_station();
|
|
|
|
bool is_power_reseller(bool power_user_only = false);
|
|
|
|
long daytime();
|
|
|
|
bool expand_sys_vars(TString& str);
|
|
|
|
void quoted_string(TString& query, const char* val);
|
|
|
|
|
2018-01-09 09:31:50 +00:00
|
|
|
inline const char* get_iva_sirio() // Ritorna la partita IVA della Sirio
|
|
|
|
{ return "04879210963"; }
|
2017-04-28 15:19:48 +00:00
|
|
|
|
2018-07-06 16:30:37 +02:00
|
|
|
TString& to_tstring(long n);
|
|
|
|
TString& to_tstring(int n);
|
|
|
|
|
2020-09-24 07:19:56 +02:00
|
|
|
const TString & mod2name(word module);
|
|
|
|
const TString & mod2tabname(word module);
|
|
|
|
|
2019-06-11 11:07:47 +02:00
|
|
|
inline bool is_multi_table(const int file) { return file == LF_TAB || file == LF_TABGEN || file == LF_TABCOM || file == LF_TABMOD; }
|
2019-06-13 17:40:53 +02:00
|
|
|
|
2021-03-22 11:41:28 +01:00
|
|
|
void build_IBAN(TString & iban, const char * iso, const char * icin,
|
|
|
|
const char * bcin, const char * abi, const char * cab, const char * cc);
|
|
|
|
void split_IBAN(const char * iban, TString & iso, TString & icin,
|
|
|
|
TString & bcin, TString & abi, TString & cab, TString & cc);
|
2021-03-22 12:27:04 +01:00
|
|
|
|
2021-04-01 00:57:49 +02:00
|
|
|
void set_test_mail(const TString & email);
|
2021-03-29 22:32:54 +02:00
|
|
|
bool send_mail(TToken_string & to, TToken_string & cc, TToken_string & ccn,
|
2021-04-01 00:57:49 +02:00
|
|
|
const char * subj, const char * text, TToken_string & attachment, bool ui, bool receipt);
|
2021-12-13 12:58:48 +01:00
|
|
|
inline bool between(const long val, const long a, const long b) { return ((a == 0 ||val >= a) && (b == 0 || val <= b)); }
|
2021-03-29 22:32:54 +02:00
|
|
|
|
2016-09-09 13:58:28 +00:00
|
|
|
#endif /* __UTILITY_H */
|