not quite there yet, but have made it to filesystem tests.
// the default is a dash (-), while for DOS most programs use forward-slash
// (/). Adding more characters is trivial; just add a character to the list
// before the sentinel of '\0'.
-#if defined(_MSC_VER) || defined(__MINGW32__)
+#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__WIN32__)
static char option_prefixes[] = { '-', '/', '\0' };
#elif defined(__UNIX__)
static char option_prefixes[] = { '-', '\0' };
// the temporary string below can be given a flat formatting of the commands
// and it will be popped out into a list of arguments.
astring temporary;
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
if (!_global_argc || !_global_argv) {
// our global parameters have not been set, so we must calculate them.
temporary = application_configuration::get_cmdline_from_proc();
// we don't need a long string to be parsed; the list is ready.
return listo_cmds;
}
-#elif defined(__WIN32__)
+#elif defined(_MSC_VER)
// we have easy access to the original list of commands.
for (int i = 0; i < _global_argc; i++) {
// add a string entry for each argument.
//////////////
-#elif defined(__UNIX__)
+#elif defined(__UNIX__) || defined(__GNU_WINDOWS__)
//! options that should work for most unix and linux apps.
#define HOOPLE_MAIN(obj_name, obj_args) \
HOOPLE_STARTUP_CODE; \
//////////////
-#elif defined(__WIN32__)
+#elif defined(_MSC_VER)
// for win32 we need to support four different environments--console mode,
// borland compilation, MFC programs and regular windows programs.
#ifdef _CONSOLE
// zap all of them using our signal.
for (int i = 0; i < pids.length(); i++) {
//would linux be better served with sigterm also?
-#ifdef __UNIX__
+#ifndef _MSC_VER
kill(pids[i], SIGHUP);
-#endif
-#ifdef __WIN32__
+#else
//lame--goes to whole program.
raise(SIGTERM);
#endif
// setup signal handler for HUP signal. this is the one used to tell us
// to leave.
-#ifdef __UNIX__
+#ifndef _MSC_VER
signal(SIGHUP, handle_OS_signal);
#endif
// setup a handler for interrupt (e.g. ctrl-C) also.
signal(SIGINT, handle_OS_signal);
-#ifdef __WIN32__
+#ifdef _MSC_VER
signal(SIGBREAK, handle_OS_signal);
#endif
using namespace filesystem;
using namespace structures;
-#ifdef __WIN32__
+#ifdef _MSC_VER
// this implementation only works on windows currently.
//hmmm: i suppose we could fake it with an ini file.
if (!to_store.length()) return delete_entry(section, entry);
else if (!section.length()) return false;
-#ifdef __WIN32__
+#ifdef _MSC_VER
HKEY key;
long ret = RegOpenKeyEx((HKEY)translate_hive(_hive),
to_unicode_temp(section), 0, KEY_WRITE, &key);
if (!section_in) return false;
if (!entry) {} // not a problem.
astring section = fix_section(section_in);
-#ifdef __WIN32__
+#ifdef _MSC_VER
HKEY key;
long ret = RegOpenKeyEx((HKEY)translate_hive(_hive),
to_unicode_temp(section), 0, KEY_QUERY_VALUE, &key);
info.reset();
if (!section_in.length()) return false;
astring section = fix_section(section_in);
-#ifdef __WIN32__
+#ifdef _MSC_VER
HKEY key;
long ret = RegOpenKeyEx((HKEY)translate_hive(_hive),
to_unicode_temp(section), 0, KEY_QUERY_VALUE, &key);
FUNCDEF("section_exists");
if (!section_in.length()) return false;
astring section = fix_section(section_in);
-#ifdef __WIN32__
+#ifdef _MSC_VER
HKEY key;
long ret = RegOpenKeyEx((HKEY)translate_hive(_hive),
to_unicode_temp(section), 0, KEY_QUERY_VALUE, &key);
if (!section_in.length()) return false;
astring section = fix_section(section_in);
//if the key doesn't exist, should that be a failure?
-#ifdef __WIN32__
+#ifdef _MSC_VER
long ret = SHDeleteKey((HKEY)translate_hive(_hive),
to_unicode_temp(section));
if (ret != ERROR_SUCCESS) {
astring section = fix_section(section_in);
if (!entry) {} // no problem.
-#ifdef __WIN32__
+#ifdef _MSC_VER
HKEY key;
long ret = RegOpenKeyEx((HKEY)translate_hive(_hive),
to_unicode_temp(section), 0, KEY_SET_VALUE, &key);
// gnarly headers that are needed for certain types of compilation...
//unix headers not needed in here for new purpose of file.
-#ifdef __UNIX__
+#ifndef _MSC_VER
#include <unistd.h>
+ #ifdef __GNU_WINDOWS__
+ #include <sys/unistd.h>
+ #endif
#endif
#ifndef NO_XWINDOWS
#ifdef __XWINDOWS__
#ifndef STRICT
#define STRICT
#endif
+ // winsock support...
+ #undef FD_SETSIZE
+ #define FD_SETSIZE 1000
+ // if you don't set this, you can only select on a default of 64 sockets.
+ #include <winsock2.h>
// windows headers...
#define _WINSOCKAPI_ // make windows.h happy about winsock.
#ifndef _AFXDLL
#include <afx.h>
#include <afxwin.h>
#endif
- // winsock support...
- #undef FD_SETSIZE
- #define FD_SETSIZE 1000
- // if you don't set this, you can only select on a default of 64 sockets.
- #include <winsock2.h>
#endif
// forward.
#include <stdlib.h>
#include <string.h>
-#ifdef __WIN32__
- #undef strcasecmp
- #undef strncasecmp
- #define strcasecmp strcmpi
- #define strncasecmp strnicmp
-#endif
+//#ifdef __WIN32__
+// #undef strcasecmp
+// #undef strncasecmp
+// #define strcasecmp strcmpi
+// #define strncasecmp strnicmp
+//#endif
//#define DEBUG_STRING
// uncomment for debugging version.
#include <stdlib.h>
#include <sys/types.h>
-#ifdef __UNIX__
+#ifndef _MSC_VER
#include <unistd.h>
#include <sys/times.h>
#endif
-#ifdef __WIN32__
+#ifdef _MSC_VER
#define _WINSOCKAPI_ // make windows.h happy about winsock.
+ // winsock support...
+ #undef FD_SETSIZE
+ #define FD_SETSIZE 1000
+ // if you don't set this, you can only select on a default of 64 sockets.
+ #include <winsock2.h>
#include <windows.h>
#include <mmsystem.h>
#endif
astring environment::get(const astring &variable_name)
{
-#ifdef __WIN32__
+#ifdef _MSC_VER
char *value = getenv(variable_name.upper().observe());
// dos & os/2 require upper case for the name, so we just do it that way.
#else
bool environment::set(const astring &variable_name, const astring &value)
{
int ret = 0;
-#ifdef __WIN32__
+#ifdef _MSC_VER
astring assignment = variable_name + "=" + value;
ret = _putenv(assignment.s());
#else
basis::un_int environment::system_uptime()
{
-#ifdef __WIN32__
+#ifdef _MSC_VER
return timeGetTime();
#else
static clock_t __ctps = sysconf(_SC_CLK_TCK); // clock ticks per second.
#endif
#ifdef __WIN32__
#define _WINSOCKAPI_ // make windows.h happy about winsock.
+ // winsock support...
+ #undef FD_SETSIZE
+ #define FD_SETSIZE 1000
+ // if you don't set this, you can only select on a default of 64 sockets.
+ #include <winsock2.h>
#include <windows.h>
#endif
#include <mach-o/dyld.h>
#include <limits.h>
#endif
-#ifdef __WIN32__
+#ifdef _MSC_VER
#include <direct.h>
#include <process.h>
#else
#include <dirent.h>
-#endif
-#ifdef __UNIX__
#include <sys/utsname.h>
#include <unistd.h>
#endif
const int MAXIMUM_COMMAND_LINE = 32 * KILOBYTE;
// maximum command line that we'll deal with here.
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
astring application_configuration::get_cmdline_from_proc()
{
FUNCDEF("get_cmdline_from_proc");
uint32_t buffsize = MAX_ABS_PATH - 1;
_NSGetExecutablePath(buffer, &buffsize);
to_return = (char *)buffer;
-#elif __UNIX__
+#elif defined(__UNIX__) || defined(__GNU_WINDOWS__)
to_return = get_cmdline_from_proc();
-#elif defined(__WIN32__)
+#elif defined(_MSC_VER)
flexichar low_buff[MAX_ABS_PATH + 1];
GetModuleFileName(NIL, low_buff, MAX_ABS_PATH - 1);
astring buff = from_unicode_temp(low_buff);
return to_return;
}
-#if defined(__UNIX__) || defined(__WIN32__)
+#if defined(__UNIX__) || defined(_MSC_VER) || defined(__GNU_WINDOWS__)
basis::un_int application_configuration::process_id() { return getpid(); }
#else
#pragma error("hmmm: need process id implementation for this OS!")
char buff[MAX_ABS_PATH];
getcwd(buff, MAX_ABS_PATH - 1);
to_return = buff;
-#elif defined(__WIN32__)
+#elif defined(_MSC_VER)
flexichar low_buff[MAX_ABS_PATH + 1];
GetCurrentDirectory(MAX_ABS_PATH, low_buff);
to_return = from_unicode_temp(low_buff);
utsname kernel_parms;
uname(&kernel_parms);
to_return = version(kernel_parms.release);
-#elif defined(__WIN32__)
+#elif defined(_MSC_VER)
OSVERSIONINFO info;
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
::GetVersionEx(&info);
need a filename. an empty string is returned on failure to create the
directory. */
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
#ifdef __APPLE__
static basis::astring get_cmdline_for_apple();
#endif
treatment_of_defaults behavior, file_location_default where)
: configurator(behavior),
_ini_name(new filename),
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
_parser(new ini_parser("", behavior)),
#endif
_where(where),
ini_configurator::~ini_configurator()
{
WHACK(_ini_name);
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
WHACK(_parser);
#endif
}
void ini_configurator::refresh()
{
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
write_ini_file();
WHACK(_parser);
_parser = new ini_parser("", behavior());
// that don't include a directory name.
if (_where == OS_DIRECTORY) use_appdir = false;
if (_where == ALL_USERS_DIRECTORY) use_appdir = false;
-#ifndef __WIN32__
+#ifdef _MSC_VER
use_appdir = true;
#endif
// we must create the filename if they specified no directory at all.
_ini_name->basename());
}
}
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
// read in the file's contents.
read_ini_file();
#endif
//hmmm: refactor section_exists to use the sections call, if it's faser?
bool ini_configurator::section_exists(const astring §ion)
{
-#ifdef __WIN32__
+#ifdef _MSC_VER
string_table infos;
// heavy-weight call here...
return get_section(section, infos);
#endif
}
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
void ini_configurator::read_ini_file()
{
#ifdef DEBUG_INI_CONFIGURATOR
bool ini_configurator::delete_section(const astring §ion)
{
-#ifdef __WIN32__
+#ifdef _MSC_VER
return put_profile_string(section, "", "");
#else
// zap the section.
bool ini_configurator::delete_entry(const astring §ion, const astring &ent)
{
-#ifdef __WIN32__
+#ifdef _MSC_VER
return put_profile_string(section, ent, "");
#else
// zap the entry.
if (!to_store.length()) return delete_entry(section, entry);
else if (!entry.length()) return delete_section(section);
else if (!section.length()) return false;
-#ifdef __WIN32__
+#ifdef _MSC_VER
return put_profile_string(section, entry, to_store);
#else
// write the entry.
bool ini_configurator::get(const astring §ion, const astring &entry,
astring &found)
{
-#ifndef __WIN32__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
return _parser->get(section, entry, found);
#else
flexichar temp_buffer[MAXIMUM_LINE_INI_CONFIG];
bool ini_configurator::get_section(const astring §ion, string_table &info)
{
FUNCDEF("get_section");
-#ifndef __WIN32__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
return _parser->get_section(section, info);
#else
info.reset();
bool ini_configurator::put_section(const astring §ion,
const string_table &info)
{
-#ifdef __WIN32__
+#ifdef _MSC_VER
variable_tokenizer parser("\1", "=");
parser.table() = info;
astring flat = parser.text_form();
#endif
}
-#ifdef __WIN32__
+#ifdef _MSC_VER
bool ini_configurator::put_profile_string(const astring §ion,
const astring &entry, const astring &to_store)
{
\*****************************************************************************/
#include "configurator.h"
-#ifndef __WIN32__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
#include "ini_parser.h"
#include <basis/utf_conversion.h>
#endif
private:
filesystem::filename *_ini_name; //!< the file we're manipulating.
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
ini_parser *_parser; //!< used for real storage and parsing.
#endif
file_location_default _where; //!< where to find and store the file.
bool _add_spaces; //!< tracks whether we're adding spaces around equals.
-#ifdef __WIN32__
+#ifdef _MSC_VER
bool put_profile_string(const basis::astring §ion, const basis::astring &entry,
const basis::astring &to_store);
//!< encapsulates windows' ini storage method.
const basis::astring &default_value, basis::flexichar *return_buffer,
int buffer_size);
//!< encapsulates windows' ini retrieval method.
-#endif
-#ifdef __UNIX__
+#else
void read_ini_file();
//!< reads the INI file's contents into memory.
void write_ini_file();
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
#include <dirent.h>
#include <fnmatch.h>
#include <string.h>
#include <unistd.h>
#endif
-#ifdef __WIN32__
+#ifdef _MSC_VER
#include <direct.h>
#endif
{
char abs_path[MAX_ABS_PATH + 1];
abs_path[0] = '\0';
-#ifdef __WIN32__
+#ifdef _MSC_VER
if (!_fullpath(abs_path, rel_path.s(), MAX_ABS_PATH)) return "";
return abs_path;
#else
astring directory::current()
{
astring to_return("."); // failure result.
-#ifdef __WIN32__
+#ifdef _MSC_VER
flexichar buffer[MAX_ABS_PATH + 1] = { '\0' };
GetCurrentDirectory(MAX_ABS_PATH, buffer);
to_return = from_unicode_temp(buffer);
_folders->reset();
astring cur_dir = ".";
astring par_dir = "..";
-#ifdef __WIN32__
+#ifdef _MSC_VER
// start reading the directory.
WIN32_FIND_DATA wfd;
astring real_path_spec = *_path + "/" + *_pattern;
}
} while (FindNextFile(search_handle, &wfd));
FindClose(search_handle);
-#endif
-#ifdef __UNIX__
+#else
DIR *dir = opendir(_path->s());
//hmmm: could check errno to determine what caused the problem.
if (!dir) return false;
bool directory::make_directory(const astring &path)
{
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
int mk_ret = mkdir(path.s(), 0777);
-#endif
-#ifdef __WIN32__
+#else
int mk_ret = mkdir(path.s());
#endif
return !mk_ret;
bool directory::remove_directory(const astring &path)
{
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
int rm_ret = rmdir(path.s());
-#endif
-#ifdef __WIN32__
+#else
int rm_ret = rmdir(path.s());
#endif
return !rm_ret;
}
} // namespace.
+
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
#include <unistd.h>
-#endif
-#ifdef __WIN32__
+#else
#include <io.h>
#endif
// define useful constant for filesystem path length.
#ifndef MAX_ABS_PATH
#ifdef __WIN32__
+ // winsock support...
+ #undef FD_SETSIZE
+ #define FD_SETSIZE 1000
+ // if you don't set this, you can only select on a default of 64 sockets.
+ #include <winsock2.h>
#include <windows.h>
#define MAX_ABS_PATH MAX_PATH
#else
#include <structures/static_memory_gremlin.h>
#include <textual/byte_formatter.h>
-#ifdef __WIN32__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
+ #include <unistd.h>
+#else
#include <io.h>
#endif
#include <stdio.h>
-#ifdef __UNIX__
- #include <unistd.h>
-#endif
using namespace basis;
using namespace configuration;
#include <structures/static_memory_gremlin.h>
#include <timely/time_control.h>
-#ifdef __WIN32__
+#ifdef _MSC_VER
#include <process.h>
-#elif defined(__UNIX__)
+#elif defined(__UNIX__) || defined(__GNU_WINDOWS__)
#include <pthread.h>
#else
#error unknown OS for thread support.
_thread_active(false),
_stop_thread(false),
_data(NIL),
-#ifdef __UNIX__
- _handle(new pthread_t),
-#elif defined(__WIN32__)
+#ifdef _MSC_VER
_handle(0),
+#else
+ _handle(new pthread_t),
#endif
_sleep_time(0),
_periodic(false),
_thread_active(false),
_stop_thread(false),
_data(NIL),
-#ifdef __UNIX__
- _handle(new pthread_t),
-#elif defined(__WIN32__)
+#ifdef _MSC_VER
_handle(0),
+#else
+ _handle(new pthread_t),
#endif
_sleep_time(sleep_timer),
_periodic(true),
{
stop();
WHACK(_next_activation);
-#ifdef __UNIX__
+#ifndef _MSC_VER
WHACK(_handle);
#endif
}
int error = 0;
int attempts = 0;
while (attempts++ < MAXIMUM_CREATE_ATTEMPTS) {
-#ifdef __UNIX__
+#ifndef _MSC_VER
pthread_attr_t attribs; // special flags for creation of thread.
int aret = pthread_attr_init(&attribs);
if (aret) LOG("failed to init attribs.");
(void *)this);
if (!ret) success = true;
else error = ret;
-#elif defined(__WIN32__)
+#else
if (_periodic)
_handle = _beginthread(periodic_thread_driver, 0, (void *)this);
else
cancel(); // tell thread to leave.
if (!thread_started()) return; // not running.
while (!thread_finished()) {
-#ifdef __WIN32__
+#ifdef _MSC_VER
int result = 0;
if (!GetExitCodeThread((HANDLE)_handle, (LPDWORD)&result)
|| (result != STILL_ACTIVE)) {
{
_thread_active = false;
_thread_ready = false;
-#ifdef __WIN32__
+#ifdef _MSC_VER
_handle = 0;
#endif
}
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
void *ethread::one_shot_thread_driver(void *hidden_pointer)
-#elif defined(__WIN32__)
+#elif defined(_MSC_VER)
void ethread::one_shot_thread_driver(void *hidden_pointer)
#else
#error unknown thread signature.
{
FUNCDEF("one_shot_thread_driver");
ethread *manager = (ethread *)hidden_pointer;
-#ifdef __UNIX__
+#ifndef _MSC_VER
if (!manager) return NIL;
#else
if (!manager) return;
#ifdef COUNT_THREADS
_current_threads().decrement();
#endif
-#ifdef __UNIX__
+#ifndef _MSC_VER
pthread_exit(NIL);
return NIL;
#else
#endif
}
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
void *ethread::periodic_thread_driver(void *hidden_pointer)
-#elif defined(__WIN32__)
+#elif defined(_MSC_VER)
void ethread::periodic_thread_driver(void *hidden_pointer)
#else
#error unknown thread signature.
{
FUNCDEF("periodic_thread_driver");
ethread *manager = (ethread *)hidden_pointer;
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
if (!manager) return NIL;
-#elif defined(__WIN32__)
+#elif defined(_MSC_VER)
if (!manager) return;
#endif
#ifdef COUNT_THREADS
#ifdef COUNT_THREADS
_current_threads().decrement();
#endif
-#ifdef __UNIX__
+#ifndef _MSC_VER
pthread_exit(NIL);
return NIL;
-#elif defined(__WIN32__)
+#else
_endthread();
#endif
}
#include <signal.h>
-#ifndef __APPLE__
-#ifdef __UNIX__
-// typedef long unsigned int pthread_t;
-#endif
-#endif
-
namespace processes {
//! Provides a platform-independent object for adding threads to a program.
bool _thread_active; //!< is the thread currently performing?
bool _stop_thread; //!< true if the thread should stop now.
void *_data; //!< holds the thread's link back to whatever.
-#ifdef __UNIX__
+#ifndef _MSC_VER
pthread_t *_handle; //!< thread structure for our thread.
-#elif defined(__WIN32__)
+#else
uintptr_t _handle; //!< thread handle for the active thread, or zero.
#endif
int _sleep_time; //!< threads perform at roughly this interval.
timed_thread_types _how; //!< how is the period evaluated?
// the OS level thread functions.
-#ifdef __UNIX__
+#ifndef _MSC_VER
static void *periodic_thread_driver(void *hidden_pointer);
static void *one_shot_thread_driver(void *hidden_pointer);
-#elif defined(__WIN32__)
+#else
static void periodic_thread_driver(void *hidden_pointer);
static void one_shot_thread_driver(void *hidden_pointer);
#endif
#include <timely/time_control.h>
#include <stdlib.h>
-#ifdef __UNIX__
+#ifndef _MSC_VER
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
-#endif
-#ifdef __WIN32__
+#else
#include <process.h>
#include <shellapi.h>
#include <shlobj.h>
return __hidden_kids;
}
-#ifdef __WIN32__
+#ifdef _MSC_VER
bool launch_process::event_poll(MSG &message)
{
message.hwnd = 0;
//const int MAXIMUM_COMMAND_LINE = 32 * KILOBYTE;
// maximum command line that we'll deal with here.
-#ifdef __UNIX__
+#ifndef _MSC_VER
void launch_process::exiting_child_signal_handler(int sig_num)
{
FUNCDEF("exiting_child_signal_handler");
app_name.insert(0, "\"");
if (app_name[app_name.end()] != '"')
app_name += "\"";
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
// unix / linux implementation.
if (flag & RETURN_IMMEDIATELY) {
// they want to get back right away.
// assume they want to wait.
return system((app_name + " " + command_line).s());
}
-#elif defined(__WIN32__)
+#elif defined(_MSC_VER)
//checking on whether we have admin rights for the launch.
//if (IsUserAnAdmin()) {
function. */
private:
-#ifdef __UNIX__
+#ifndef _MSC_VER
static void exiting_child_signal_handler(int sig_num);
//!< awaits the child processes rather than leaving process handles willy nilly.
-#endif
-#ifdef __WIN32__
+#else
static bool event_poll(tagMSG &message);
//!< tries to process one win32 event and retrieve the "message" from it.
/*!< this is a very general poll and will retrieve any message that's
#include <stdio.h>
#include <stdlib.h>
-#ifdef __UNIX__
+#ifndef _MSC_VER
#include <unistd.h>
#endif
namespace processes {
-#ifdef __WIN32__
+#ifdef _MSC_VER
#include <tlhelp32.h>
const astring NTVDM_NAME = "ntvdm.exe";
// the umbrella process that hangs onto 16 bit tasks for NT.
- #ifdef _MSCVER
- #include <vdmdbg.h>
- #endif
-#endif
-#ifdef __UNIX__
+// #ifdef _MSCVER
+// #include <vdmdbg.h>
+// #endif
+#else
#include <signal.h>
#include <stdio.h>
#endif
class process_implementation_hider
{
public:
-#ifdef __WIN32__
+#ifdef _MSC_VER
// psapi members:
application_instance psapi_dll;
application_instance vdm_dll;
BOOL (WINAPI *enumerate_processes)(basis::un_int *, basis::un_int cb, basis::un_int *);
BOOL (WINAPI *enumerate_modules)(HANDLE, HMODULE *, basis::un_int, basis::un_int *);
basis::un_int (WINAPI *get_module_name)(HANDLE, HMODULE, LPTSTR, basis::un_int);
-#ifdef _MSCVER
- INT (WINAPI *tasker_16bit)(basis::un_int, TASKENUMPROCEX fp, LPARAM);
-#endif
+//#ifdef _MSCVER
+// INT (WINAPI *tasker_16bit)(basis::un_int, TASKENUMPROCEX fp, LPARAM);
+//#endif
// toolhelp members:
application_instance kernel32_dll;
process_implementation_hider()
: psapi_dll(NIL), vdm_dll(NIL), enumerate_processes(NIL),
enumerate_modules(NIL), get_module_name(NIL),
-#ifdef _MSCVER
- tasker_16bit(NIL),
-#endif
+//#ifdef _MSCVER
+// tasker_16bit(NIL),
+//#endif
kernel32_dll(NIL), create_snapshot(NIL), first_process(NIL),
next_process(NIL) {}
process_control::process_control()
: _ptrs(new process_implementation_hider),
-#ifdef __WIN32__
+#ifdef _MSC_VER
_use_psapi(true),
-#endif
-#ifdef __UNIX__
+#else
_rando(new chaos),
#endif
_healthy(false)
// Check to see if were running under Windows95 or Windows NT.
version osver = application_configuration::get_OS_version();
-#ifdef __WIN32__
+#ifdef _MSC_VER
if (osver.v_revision() == VER_PLATFORM_WIN32_WINDOWS) {
// we're on Windows 95, so use the toolhelp API for the processes.
_use_psapi = false;
_healthy = initialize_psapi_support();
else
_healthy = initialize_toolhelp_support();
-#endif
-#ifdef __UNIX__
+#else
_healthy = true;
#endif
}
process_control::~process_control()
{
WHACK(_ptrs);
-#ifdef __UNIX__
+#ifndef _MSC_VER
WHACK(_rando);
#endif
}
bool process_control::query_processes(process_entry_array &to_fill)
{
if (!_healthy) return false;
-#ifdef __WIN32__
+#ifdef _MSC_VER
if (!_use_psapi) {
// we're on Windows 95 or something, so use the toolhelp API for the
// processes.
// we're on Windows NT and so on; use the process API (PSAPI) to get info.
return get_processes_with_psapi(to_fill);
}
-#endif
-#ifdef __UNIX__
+#else
return get_processes_with_ps(to_fill);
#endif
}
-#ifdef __WIN32__
+#ifdef _MSC_VER
bool process_control::initialize_psapi_support()
{
// create an instance of the PSAPI dll for querying 32-bit processes and
_ptrs->get_module_name
= (basis::un_int (WINAPI *)(HANDLE, HMODULE, LPTSTR, basis::un_int))
GetProcAddress(_ptrs->psapi_dll, "GetModuleFileNameExA");
-#ifdef _MSCVER
- _ptrs->tasker_16bit = (INT(WINAPI *)(basis::un_int, TASKENUMPROCEX, LPARAM))
- GetProcAddress(_ptrs->vdm_dll, "VDMEnumTaskWOWEx");
-#endif
+//#ifdef _MSCVER
+// _ptrs->tasker_16bit = (INT(WINAPI *)(basis::un_int, TASKENUMPROCEX, LPARAM))
+// GetProcAddress(_ptrs->vdm_dll, "VDMEnumTaskWOWEx");
+//#endif
if (!_ptrs->enumerate_processes || !_ptrs->enumerate_modules
|| !_ptrs->get_module_name
-#ifdef _MSCVER
- || !_ptrs->tasker_16bit
-#endif
+//#ifdef _MSCVER
+// || !_ptrs->tasker_16bit
+//#endif
) return false;
return true;
FUNCDEF("zap_process");
#endif
if (!_healthy) return false;
-#ifdef __UNIX__
+#ifndef _MSC_VER
int ret = kill(to_zap, 9);
// send the serious take-down signal to the process.
return !ret;
-#endif
-#ifdef __WIN32__
+#else
HANDLE h = OpenProcess(PROCESS_TERMINATE, false, to_zap);
if (!h) {
#ifdef DEBUG_PROCESS_CONTROL
}
//hmmm: implement more specifically.
-#ifdef __UNIX__
+#ifndef _MSC_VER
//put in the single process grabber deal.
-#endif
-#ifdef __WIN32__
+#else
//grab the entry from the list.
#endif
//////////////
-#ifdef __WIN32__
+#ifdef _MSC_VER
// this section is the PSAPI version of the query.
// called back on each 16 bit task.
(new_entry.path().end() - NTVDM_NAME.length() + 1,
new_entry.path().end());
temp.to_lower();
-#ifdef _MSCVER
-//hmmm: pull this back in for mingw when it seems to be supported, if ever.
- if (temp == NTVDM_NAME) {
- // set up a callback stampede on the 16 bit processes.
- process_info_clump info(pid_list[i], to_fill);
- _ptrs->tasker_16bit(pid_list[i], (TASKENUMPROCEX)process_16bit,
- (LPARAM)&info);
- }
-#endif
+//#ifdef _MSCVER
+////hmmm: pull this back in for mingw when it seems to be supported, if ever.
+// if (temp == NTVDM_NAME) {
+// // set up a callback stampede on the 16 bit processes.
+// process_info_clump info(pid_list[i], to_fill);
+// _ptrs->tasker_16bit(pid_list[i], (TASKENUMPROCEX)process_16bit,
+// (LPARAM)&info);
+// }
+//#endif
}
}
}
#endif // __WIN32__
-#ifdef __UNIX__
+#ifndef _MSC_VER
#define CLOSE_TEMPORARY_FILE { \
/* continuable_error("process_control", "get_processes_with_ps", error); */ \
private:
process_implementation_hider *_ptrs; //!< our OS baggage.
-#ifdef __UNIX__
+#ifndef _MSC_VER
mathematics::chaos *_rando; //!< used for process list.
-#endif
-#ifdef __WIN32__
+#else
bool _use_psapi; //!< true if we should be using the PSAPI on NT and family.
#endif
bool _healthy; //!< true if construction succeeded.
-#ifdef __UNIX__
+#ifndef _MSC_VER
bool get_processes_with_ps(process_entry_array &to_fill);
//!< asks the ps program what processes exist.
-#endif
-#ifdef __WIN32__
+#else
// fill in our function pointers to access the kernel functions appropriate
// for either NT (psapi) or 9x (toolhelp).
bool initialize_psapi_support();
#include <timely/time_stamp.h>
#include <unit_test/unit_base.h>
-#ifdef __WIN32__
+#ifdef _MSC_VER
#include <comdef.h>
#endif
#include <stdio.h>
void test_string::run_test_24()
{
FUNCDEF("run_test_24");
+#ifndef __GNU_WINDOWS__
#ifdef __WIN32__
// 24th test group tests _bstr_t conversions.
_bstr_t beast("abcdefgh");
_bstr_t pork = string_convert::to_bstr_t(jethro);
ASSERT_FALSE(strcmp(pork.operator char *(), jethro.s()), "second test failed comparison");
#endif
+#endif
}
void test_string::run_test_25()
#ifdef __WIN32__
#ifndef _MANAGED
- #ifndef __MINGW32__
#define _WINSOCKAPI_ // the dance of the windows headers.
- #include <windows.h>
- #include <comdef.h>
- #endif
+ // winsock support...
+ #undef FD_SETSIZE
+ #define FD_SETSIZE 1000
+ // if you don't set this, you can only select on a default of 64 sockets.
+ #include <winsock2.h>
+ #include <windows.h>
+ #ifndef __GNU_WINDOWS__
+ #include <comdef.h>
+ #endif
#endif
#endif
#ifdef WIN32
#ifndef _MANAGED
- #ifndef __MINGW32__
+ #ifndef __GNU_WINDOWS__
//! conversion from ATL's _bstr_t object to astring.
inline basis::astring to_astring(const _bstr_t &original) {
return basis::astring(basis::astring::UNTERMINATED, (const char *)original,
//! conversion from astring to the ATL _bstr_t object.
inline _bstr_t to_bstr_t(const basis::astring &original)
{ return _bstr_t(original.s()); }
- #endif
+ #endif
#endif
#endif
//////////////
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
const int OUR_SIGNAL = SIGUSR2;
class signalling_thread : public ethread
};
#endif
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
void timer_driver_private_handler(int signal_seen)
#elif defined(__WIN32__)
void __stdcall timer_driver_private_handler(window_handle hwnd, basis::un_int msg,
#define static_class_name() "timer_driver"
FUNCDEF("timer_driver_private_handler");
#endif
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
int seen = signal_seen;
if (seen != OUR_SIGNAL) {
#elif defined(__WIN32__)
timer_driver::timer_driver()
: _timers(new driven_objects_list),
_lock(new mutex),
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
_prompter(new signalling_thread(INITIAL_TIMER_GRANULARITY)),
-#endif
-#ifdef __WIN32__
+#else
_real_timer_id(NIL),
#endif
_in_timer(false)
#endif
}
-#ifdef __WIN32__
+#ifdef _MSC_VER
basis::un_int *timer_driver::real_timer_id() { return _real_timer_id; }
#endif
#ifdef DEBUG_TIMER_DRIVER
LOG(a_sprintf("hooking next OS timer in %d ms.", duration));
#endif
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
// just make our thread hit after the duration specified.
_prompter->reschedule(duration);
-#elif defined(__WIN32__)
+#elif defined(_MSC_VER)
int max_tries_left = 100;
while (max_tries_left-- >= 0) {
_real_timer_id = (basis::un_int *)SetTimer(NIL, 0, duration,
#ifdef DEBUG_TIMER_DRIVER
FUNCDEF("unhook_OS_timer");
#endif
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
// postpone the thread for quite a while so we can take care of business.
_prompter->reschedule(LONG_TIME);
-#elif defined(__WIN32__)
+#elif defined(_MSC_VER)
if (_real_timer_id) KillTimer(NIL, (UINT_PTR)_real_timer_id);
#endif
#ifdef DEBUG_TIMER_DRIVER
// internal methods.
-#ifdef __WIN32__
+#if defined(_MSC_VER)
basis::un_int *real_timer_id();
//!< provides the timer id for comparison on windows platforms.
#endif
private:
driven_objects_list *_timers; //!< timer hooked objects.
basis::mutex *_lock; //!< protects list of timers.
-#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
signalling_thread *_prompter; //!< drives our timers.
-#endif
-#ifdef __WIN32__
+#else
basis::un_int *_real_timer_id; //!< used for storing window timer handle.
#endif
bool _in_timer; //!< true if we're handling the timer right now.
# implement special bits for gnu on unix.
ifeq "$(COMPILER)" "GNU_LINUX"
ifneq "$(USE_XWIN)" ""
- ifneq "$(OP_SYSTEM)" "WIN32"
- DEFINITIONS += __XWINDOWS__ __X__
- LIBS_USED += Xm Xt X11 Xft Xp
+ DEFINITIONS += __XWINDOWS__ __X__
+ LIBS_USED += Xm Xt X11 Xft Xp
#need to separate out with a USE_MOTIF kind of thing.
LIBS_USED += Xmu
- HEADER_SEARCH_PATH += /usr/include/X11 /usr/X11R6/include /usr/include/g++
- LIBRARY_SEARCH_PATH += /usr/X11R6/lib
+ HEADER_SEARCH_PATH += /usr/include/X11 /usr/X11R6/include /usr/include/g++
+ LIBRARY_SEARCH_PATH += /usr/X11R6/lib
+ endif
+
+ ifneq "$(USE_SSL)" ""
+ LIBS_USED += ssl crypto
+ endif
+
+ ifneq "$(USE_WXWIDGETS)" ""
+ DEFINITIONS += __WXWIDGETS__
+ use_unicode =
+ ifneq "$(findstring UNICODE, $(DEFINITIONS))" ""
+ use_unicode = true
+ endif
+
+ # decide whether to turn on the unicode flag or not.
+ ifneq "$(use_unicode)" ""
+ DEFINITIONS += wxUSE_UNICODE
+ UNICODE_FLAG_ADD = --unicode=yes
+ else
+ UNICODE_FLAG_ADD = --unicode=no
endif
+ # could add for debugging: --debug=yes
+ COMPILER_FLAGS += $(shell wx-config --cxxflags $(UNICODE_FLAG_ADD) )
+
+ LOAD_FLAG_PREFIX += $(shell wx-config --libs $(UNICODE_FLAG_ADD) )
endif
+ ifneq "$(USE_CURL)" ""
+ COMPILER_FLAGS += `curl-config --cflags`
+ LOAD_FLAG_SUFFIX += `curl-config --libs`
+ endif
+endif
+
+# some special code for gnu compiler on windows.
+ifeq "$(COMPILER)" "GNU_WINDOWS"
+
ifneq "$(USE_SSL)" ""
LIBS_USED += ssl crypto
endif
DEFINITIONS += __WXWIDGETS__
use_unicode =
ifneq "$(findstring UNICODE, $(DEFINITIONS))" ""
-# ifeq "$(OP_SYSTEM)" "WIN32"
- use_unicode = true
-# endif
+ use_unicode = true
endif
# decide whether to turn on the unicode flag or not.
DEFINITIONS += __WXWIDGETS__
use_unicode =
ifneq "$(findstring UNICODE, $(DEFINITIONS))" ""
-# ifeq "$(OP_SYSTEM)" "WIN32"
use_unicode = true
-# endif
endif
# decide whether to turn on the unicode flag or not.
# win32 compiler additions.
ifeq "$(OP_SYSTEM)" "WIN32"
+#ifeq "$(COMPILER)" "VISUAL_CPP"
# processes the def file for linkage, if one has been specified.
ifneq "$(DEF_FILE)" ""
LOAD_FLAG_PREFIX += -def:$(DEF_FILE)
# Adds the primary targets to the list of products to create.
ifeq "$(NO_COMPILE)" ""
- ifeq "$(OP_SYSTEM)" "UNIX"
+ ifneq "$(COMPILER)" "VISUAL_CPP"
ACTUAL_TARGETS1 = $(TARGETS:%.exe=$(EXECUTABLE_DIR)/%)
else
ACTUAL_TARGETS1 = $(TARGETS:%.exe=$(EXECUTABLE_DIR)/%.exe)
endif
- ifeq "$(OP_SYSTEM)" "UNIX"
+ ifneq "$(COMPILER)" "VISUAL_CPP"
ACTUAL_TARGETS2 = $(ACTUAL_TARGETS1:%.dll=%.so)
ACTUAL_TARGETS3 = $(ACTUAL_TARGETS2:%.so=$(DYNAMIC_LIBRARY_DIR)/%$(TRIPART_VERSION).so)
else
# creates "exe" executables using all of the appropriate objects.
-ifeq "$(OP_SYSTEM)" "WIN32"
+ifeq "$(COMPILER)" "VISUAL_CPP"
ifneq "$(NO_COMPILE)" ""
$(EXECUTABLE_DIR)/%.exe:
endif
$(HIDER)ReplaceVistaIcon "$@" "$(VCPP_VISTA_ICON)"
endif
endif #no_compile
-endif #win32
+endif #visual studio
-ifeq "$(OP_SYSTEM)" "UNIX"
+ifneq "$(COMPILER)" "VISUAL_CPP"
ifneq "$(NO_COMPILE)" ""
$(EXECUTABLE_DIR)/%:
endif
# code. It is mainly used within CLAM itself for determining the proper
# compiler flags.
export COMPILER
-#COMPILER := GNU_LINUX | GNU_ARM_LINUX | GNU_DARWIN | GNU_WIN32 | VISUAL_CPP
+#COMPILER := GNU_LINUX | GNU_ARM_LINUX | GNU_DARWIN | GNU_WINDOWS | VISUAL_CPP
# choose a default compiler if none was specified.
ifeq "$(COMPILER)" ""
endif
endif
ifeq "$(OP_SYSTEM)" "WIN32"
-# COMPILER := GNU_WIN32
- COMPILER := VISUAL_CPP
+ COMPILER := GNU_WINDOWS
+# COMPILER := VISUAL_CPP
endif
ifeq "$(COMPILER)" ""
# if we get into this case, we have no idea how to set the default
DYNLIB_ENDING = .so
endif
ifeq "$(OP_SYSTEM)" "WIN32"
- LIB_ENDING = .lib
- DYNLIB_ENDING = .dll
+ ifeq "$(COMPILER)" "VISUAL_CPP"
+ LIB_ENDING = .lib
+ DYNLIB_ENDING = .dll
+ else
+ LIB_ENDING = .a
+ DYNLIB_ENDING = .so
+ endif
endif
###############################################################################
endif
-ifeq "$(COMPILER)" "GNU_WIN32"
+ifeq "$(COMPILER)" "GNU_WINDOWS"
# GNU compiler for MS Windoze...
CC = g++
ifeq "$(COMPILER_ROOT_DIR)" ""
- COMPILER_ROOT_DIR = c:/system/mingw
+ COMPILER_ROOT_DIR = $(CYGROOT)
endif
export COMPILER_VERSION = $(shell $(SHELL) $(CLAM_DIR)/cpp/get_version.sh $(COMPILER) $(COMPILER_ROOT_DIR) )
RC := $(COMPILER_ROOT_DIR)/bin/windres
PLATFORM_ADD_IN = w32_
- COMPILER_HEADER_DIR = $(COMPILER_ROOT_DIR)/include $(COMPILER_ROOT_DIR)/include/c++/3.4.2 $(COMPILER_ROOT_DIR)/lib/gcc/mingw32/3.4.2/include
+ COMPILER_HEADER_DIR = $(COMPILER_ROOT_DIR)/include $(COMPILER_ROOT_DIR)/include/c++/3.4.2
+#$(COMPILER_ROOT_DIR)/lib/gcc/mingw32/3.4.2/include
###$(COMPILER_ROOT_DIR)/usr/include/mingw $(COMPILER_ROOT_DIR)/usr/include $(COMPILER_ROOT_DIR)/usr/include/w32api $(COMPILER_ROOT_DIR)/usr/include/extras
COMPILER_LIBRARY_DIR = $(COMPILER_ROOT_DIR)/lib
- DEFINITIONS += _Windows _WINDOWS WIN32 __WIN32__ __FLAT__ VC_EXTRALEAN WIN32_LEAN_AND_MEAN ATL_NO_LEAN_AND_MEAN _WIN32 __cplusplus
+ DEFINITIONS += __GNU_WINDOWS__ _Windows _WINDOWS WIN32 __WIN32__ __FLAT__ VC_EXTRALEAN WIN32_LEAN_AND_MEAN ATL_NO_LEAN_AND_MEAN _WIN32 __cplusplus __USE_W32_SOCKETS
#__USE_GNU
LIBRARY_TOOL = ar
+ LIBRARY_PATH_FLAG = -L
+ LIB_PREFIX = lib
# LOAD_FLAG_PREFIX += -lpthread
LOAD_FLAG_PREFIX += -mwindows
CREATE_LIBRARY_FLAG += -r