1
//------------------------------------------------------------------------------
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
4
// (c) copyright 1995, Vrije Universiteit Amsterdam.
5
// Author: Frank Dehne (frank@cs.vu.nl).
7
// TCM is free software; you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License as published by
9
// the Free Software Foundation; either version 2 of the License, or
10
// (at your option) any later version.
12
// TCM is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
17
// You should have received a copy of the GNU General Public License
18
// along with TCM; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21
//-----------------------------------------------------------------------------
28
/// Encapsulates some O.S. specific functions.
30
/*@Doc: {\large {\bf scope:} global} */
32
/// set unix signal handler.
33
static void SetSignalHandler();
35
/// copies into host the hostname of the machine.
36
static bool GetHostName(char* host);
38
static bool GetHostName(string* host);
40
/// copies into login the loginname of the user.
41
static bool GetLoginName(char* login);
43
static bool GetLoginName(string* login);
45
/// copies in time the current machine time as a string.
46
static bool GetTime(char* time);
48
static bool GetTime(string* time);
50
/// returns a random number based on the time and the given number.
51
static unsigned long GenerateId(unsigned long);
53
/// copies into printer the PRINTER environment variable.
54
static bool GetPrinter(char* printer);
56
static bool GetPrinter(string* printer);
58
/// retrieve current working directory.
59
static bool GetCwd(char* dir);
61
static bool GetCwd(string* dir);
63
/// retrieve home directory.
64
static bool GetHome(char* home);
66
static bool GetHome(string* home);
68
/// copies the tool home directory variable into home.
69
static void GetToolkitHome(char* home);
71
static void GetToolkitHome(string* home);
73
/// copies the tool lib directory variable into lib.
74
static void GetToolkitLib(char* lib);
76
static void GetToolkitLib(string* lib);
78
/// copies the tool config directory variable into conf.
79
static void GetToolkitConfig(char* conf);
81
static void GetToolkitConfig(string* conf);
83
/// copies the tool share directory variable into share.
84
static void GetToolkitShare(char* share);
86
static void GetToolkitShare(string* share);
88
/// copies the tool help directory variable into help.
89
static void GetToolkitHelp(char* help);
91
static void GetToolkitHelp(string* help);
93
/// copies in dir and file the directory and file in the name 'path'.
94
static void GiveFile(const char* path, char* dir, char* file);
96
static void GiveFile(const string* path, string* dir, string* file);
98
/// copies in file the file in the name 'path'.
99
static void GiveFile(const char* path, char* file);
101
static void GiveFile(const string* path, string* file);
103
/// returns if file is regular (not directory, named pipe etc).
104
static bool FileRegular(const char* file);
106
/// returns whether file exists
107
static bool FileExists(const char* file);
109
/// returns whether executable file exists
110
static bool FileExecutable(const char* file);
112
/// returns whether directory exists
113
static bool DirExists(const char* dir);
115
/// returns if there is command in a std dir, program becomes the path.
116
static bool FindProgram(char* program, const char* command);
118
static bool FindProgram(string* program, const char* command);
120
/// return true if desc is a 'num1'x'num2' string.
121
static bool NxnParse(const char* desc, int &num1, int &num2);
123
/// return if argv contains arg. Index will be the position in argv.
124
static bool FindArg(char** argv, int argc, const char* arg, int &index);
126
/// send an email message (for instance for stats or bug reports).
127
static void SendEmail(const char* recipient, const char* subject,
128
const char* program, const char* version, const char* text);
130
/// default toolkit home directory.
131
static const char TOOLKIT_HOME_DEFAULT[];
133
/// Statistics message subject for logging.
134
static const char TOOLKIT_STAT_HEADER[];
136
/// Bug report message subject.
137
static const char TOOLKIT_BUG_HEADER[];
139
/// Variable name that contains the tool home directory.
140
static const char TOOLKIT_HOME_VAR_NAME[];
142
/// most common Unix directories for system wide available binaries.
143
static const char* STD_SEARCH_DIRS[];
145
/// send an email after crash
146
static bool sendBugEmail;
148
/// email address to send to.
149
static char emailAddress[];
151
/// the command name of the current program (argv[0]).
152
static char currentProgram[];
154
/// called when signal occurs.
155
static void SignalHandler(int s);