Replaced the old wxGetResource implementation with one based
in wxFileConfig. Compile fix for gsocket.c. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5037 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -47,15 +47,12 @@
|
|||||||
wxApp *wxTheApp = (wxApp *) NULL;
|
wxApp *wxTheApp = (wxApp *) NULL;
|
||||||
wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
|
wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
|
||||||
|
|
||||||
extern wxResourceCache *wxTheResourceCache;
|
|
||||||
extern bool g_isIdle;
|
extern bool g_isIdle;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// local functions
|
// local functions
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
extern void wxFlushResources();
|
|
||||||
|
|
||||||
/* forward declaration */
|
/* forward declaration */
|
||||||
gint wxapp_idle_callback( gpointer WXUNUSED(data) );
|
gint wxapp_idle_callback( gpointer WXUNUSED(data) );
|
||||||
void wxapp_install_idle_handler();
|
void wxapp_install_idle_handler();
|
||||||
@@ -498,12 +495,6 @@ bool wxApp::Initialize()
|
|||||||
wxInitializeStockLists();
|
wxInitializeStockLists();
|
||||||
wxInitializeStockObjects();
|
wxInitializeStockObjects();
|
||||||
|
|
||||||
#if wxUSE_WX_RESOURCES
|
|
||||||
wxTheResourceCache = new wxResourceCache( wxKEY_STRING );
|
|
||||||
|
|
||||||
wxInitializeResourceSystem();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxModule::RegisterModules();
|
wxModule::RegisterModules();
|
||||||
if (!wxModule::InitializeModules()) return FALSE;
|
if (!wxModule::InitializeModules()) return FALSE;
|
||||||
|
|
||||||
@@ -514,16 +505,6 @@ void wxApp::CleanUp()
|
|||||||
{
|
{
|
||||||
wxModule::CleanUpModules();
|
wxModule::CleanUpModules();
|
||||||
|
|
||||||
#if wxUSE_WX_RESOURCES
|
|
||||||
wxFlushResources();
|
|
||||||
|
|
||||||
if (wxTheResourceCache)
|
|
||||||
delete wxTheResourceCache;
|
|
||||||
wxTheResourceCache = (wxResourceCache*) NULL;
|
|
||||||
|
|
||||||
wxCleanUpResourceSystem();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (wxTheColourDatabase)
|
if (wxTheColourDatabase)
|
||||||
delete wxTheColourDatabase;
|
delete wxTheColourDatabase;
|
||||||
wxTheColourDatabase = (wxColourDatabase*) NULL;
|
wxTheColourDatabase = (wxColourDatabase*) NULL;
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
// #pragma implementation
|
// #pragma implementation
|
||||||
#endif
|
#endif
|
||||||
@@ -22,14 +21,6 @@
|
|||||||
|
|
||||||
#define _MAXPATHLEN 500
|
#define _MAXPATHLEN 500
|
||||||
|
|
||||||
/* Used for X resources */
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <X11/Xutil.h>
|
|
||||||
#include <X11/Xresource.h>
|
|
||||||
|
|
||||||
wxResourceCache *wxTheResourceCache = (wxResourceCache *) NULL;
|
|
||||||
XrmDatabase wxResourceDatabase;
|
|
||||||
|
|
||||||
/* Useful buffer, initialized in wxCommonInit */
|
/* Useful buffer, initialized in wxCommonInit */
|
||||||
wxChar *wxBuffer = (wxChar *) NULL;
|
wxChar *wxBuffer = (wxChar *) NULL;
|
||||||
|
|
||||||
|
@@ -1,13 +1,12 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: utils.cpp
|
// Name: utilres.cpp
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Author: Robert Roebling
|
// Author: Robert Roebling
|
||||||
// Id: $Id$
|
// Id: $Id$
|
||||||
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
|
// Copyright: (c) 1998 Robert Roebling
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
//#ifdef __GNUG__
|
//#ifdef __GNUG__
|
||||||
//#pragma implementation "utils.h"
|
//#pragma implementation "utils.h"
|
||||||
//#endif
|
//#endif
|
||||||
@@ -16,190 +15,8 @@
|
|||||||
#include "wx/string.h"
|
#include "wx/string.h"
|
||||||
#include "wx/list.h"
|
#include "wx/list.h"
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
#include "wx/gdicmn.h"
|
#include "wx/config.h"
|
||||||
|
#include "wx/app.h"
|
||||||
#include <ctype.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
//#ifdef __SVR4__
|
|
||||||
//#include <sys/systeminfo.h>
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
#include "gdk/gdkx.h" // GDK_DISPLAY
|
|
||||||
#include "gdk/gdkprivate.h" // gdk_progclass
|
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <X11/Xutil.h>
|
|
||||||
#include <X11/Xresource.h>
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// constants
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Yuck this is really BOTH site and platform dependent
|
|
||||||
// so we should use some other strategy!
|
|
||||||
#ifdef __SUN__
|
|
||||||
# define DEFAULT_XRESOURCE_DIR wxT("/usr/openwin/lib/app-defaults")
|
|
||||||
#else
|
|
||||||
# define DEFAULT_XRESOURCE_DIR wxT("/usr/lib/X11/app-defaults")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// glabal data (data.cpp)
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
extern wxResourceCache *wxTheResourceCache;
|
|
||||||
extern XrmDatabase wxResourceDatabase;
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// utility functions for get/write resources
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
static wxChar *GetResourcePath(wxChar *buf, wxChar *name, bool create)
|
|
||||||
{
|
|
||||||
if (create && FileExists(name))
|
|
||||||
{
|
|
||||||
wxStrcpy(buf, name);
|
|
||||||
return buf; // Exists so ...
|
|
||||||
}
|
|
||||||
if (*name == wxT('/'))
|
|
||||||
wxStrcpy(buf, name);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Put in standard place for resource files if not absolute
|
|
||||||
wxStrcpy(buf, DEFAULT_XRESOURCE_DIR);
|
|
||||||
wxStrcat(buf, wxT("/"));
|
|
||||||
wxStrcat(buf, FileNameFromPath(name));
|
|
||||||
}
|
|
||||||
if (create)
|
|
||||||
{
|
|
||||||
// Touch the file to create it
|
|
||||||
FILE *fd = fopen(wxConvCurrent->cWX2MB(buf), "w");
|
|
||||||
if (fd) fclose(fd);
|
|
||||||
}
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read $HOME for what it says is home, if not
|
|
||||||
// read $USER or $LOGNAME for user name else determine
|
|
||||||
// the Real User, then determine the Real home dir.
|
|
||||||
static wxChar *GetIniFile(wxChar *dest, const wxChar *filename)
|
|
||||||
{
|
|
||||||
const wxChar *home = (const wxChar *) NULL;
|
|
||||||
if (filename && wxIsAbsolutePath(filename))
|
|
||||||
{
|
|
||||||
wxStrcpy(dest, filename);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ((home = wxGetUserHome(wxString())) != NULL)
|
|
||||||
{
|
|
||||||
wxStrcpy(dest, home);
|
|
||||||
if (dest[wxStrlen(dest) - 1] != wxT('/')) wxStrcat(dest, wxT("/"));
|
|
||||||
if (filename == NULL)
|
|
||||||
{
|
|
||||||
if ((filename = wxGetenv(wxT("XENVIRONMENT"))) == NULL) filename = wxT(".Xdefaults");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (*filename != wxT('.')) wxStrcat(dest, wxT("."));
|
|
||||||
wxStrcat(dest, filename);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dest[0] = wxT('\0');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void wxXMergeDatabases()
|
|
||||||
{
|
|
||||||
XrmDatabase homeDB, serverDB, applicationDB;
|
|
||||||
wxChar filenamebuf[1024];
|
|
||||||
|
|
||||||
wxChar *filename = &filenamebuf[0];
|
|
||||||
wxChar *environment;
|
|
||||||
char *classname = gdk_progclass; // Robert Roebling ??
|
|
||||||
char name[256];
|
|
||||||
(void)strcpy(name, "/usr/lib/X11/app-defaults/");
|
|
||||||
(void)strcat(name, classname ? classname : "wxWindows");
|
|
||||||
|
|
||||||
// Get application defaults file, if any
|
|
||||||
if ((applicationDB = XrmGetFileDatabase(name)))
|
|
||||||
(void)XrmMergeDatabases(applicationDB, &wxResourceDatabase);
|
|
||||||
|
|
||||||
// Merge server defaults, created by xrdb, loaded as a property of the root
|
|
||||||
// window when the server initializes and loaded into the display
|
|
||||||
// structure on XOpenDisplay;
|
|
||||||
// if not defined, use .Xdefaults
|
|
||||||
if (XResourceManagerString(GDK_DISPLAY()) != NULL)
|
|
||||||
{
|
|
||||||
serverDB = XrmGetStringDatabase(XResourceManagerString(GDK_DISPLAY()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
(void)GetIniFile(filename, (wxChar *) NULL);
|
|
||||||
serverDB = XrmGetFileDatabase(wxConvCurrent->cWX2MB(filename));
|
|
||||||
}
|
|
||||||
if (serverDB)
|
|
||||||
XrmMergeDatabases(serverDB, &wxResourceDatabase);
|
|
||||||
|
|
||||||
// Open XENVIRONMENT file, or if not defined, the .Xdefaults,
|
|
||||||
// and merge into existing database
|
|
||||||
|
|
||||||
if ((environment = wxGetenv(wxT("XENVIRONMENT"))) == NULL)
|
|
||||||
{
|
|
||||||
environment = GetIniFile(filename, (const wxChar *) NULL);
|
|
||||||
size_t len = wxStrlen(environment);
|
|
||||||
|
|
||||||
wxChar hostbuf[1024];
|
|
||||||
(void)wxGetHostName(hostbuf, WXSIZEOF(hostbuf) - len);
|
|
||||||
|
|
||||||
wxStrcat(environment, hostbuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((homeDB = XrmGetFileDatabase(wxConvCurrent->cWX2MB(environment))))
|
|
||||||
XrmMergeDatabases(homeDB, &wxResourceDatabase);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// called on application exit
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void wxFlushResources()
|
|
||||||
{
|
|
||||||
wxChar nameBuffer[512];
|
|
||||||
|
|
||||||
wxNode *node = wxTheResourceCache->First();
|
|
||||||
while (node) {
|
|
||||||
wxString str = node->GetKeyString();
|
|
||||||
wxChar *file = WXSTRINGCAST str;
|
|
||||||
// If file doesn't exist, create it first.
|
|
||||||
(void)GetResourcePath(nameBuffer, file, TRUE);
|
|
||||||
|
|
||||||
XrmDatabase database = (XrmDatabase)node->Data();
|
|
||||||
XrmPutFileDatabase(database, wxConvCurrent->cWX2MB(nameBuffer));
|
|
||||||
XrmDestroyDatabase(database);
|
|
||||||
wxNode *next = node->Next();
|
|
||||||
// delete node;
|
|
||||||
node = next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxDeleteResources(const wxChar *file)
|
|
||||||
{
|
|
||||||
wxLogTrace(wxTraceResAlloc, wxT("Delete: Number = %d"), wxTheResourceCache->Number());
|
|
||||||
wxChar buffer[500];
|
|
||||||
(void)GetIniFile(buffer, file);
|
|
||||||
|
|
||||||
wxNode *node = wxTheResourceCache->Find(buffer);
|
|
||||||
if (node) {
|
|
||||||
XrmDatabase database = (XrmDatabase)node->Data();
|
|
||||||
XrmDestroyDatabase(database);
|
|
||||||
// delete node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// resource functions
|
// resource functions
|
||||||
@@ -207,148 +24,100 @@ void wxDeleteResources(const wxChar *file)
|
|||||||
|
|
||||||
bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file )
|
bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file )
|
||||||
{
|
{
|
||||||
wxChar buffer[500];
|
wxString filename( file );
|
||||||
|
if (filename.IsEmpty()) filename = wxT(".wxWindows");
|
||||||
|
|
||||||
if (!entry) return FALSE;
|
wxFileConfig conf( wxTheApp->GetAppName(), wxTheApp->GetVendorName(), filename );
|
||||||
|
|
||||||
(void)GetIniFile(buffer, file);
|
conf.SetPath( section );
|
||||||
|
|
||||||
XrmDatabase database;
|
return conf.Write( entry, value );
|
||||||
wxNode *node = wxTheResourceCache->Find(buffer);
|
|
||||||
if (node)
|
|
||||||
database = (XrmDatabase)node->Data();
|
|
||||||
else {
|
|
||||||
database = XrmGetFileDatabase(wxConvCurrent->cWX2MB(buffer));
|
|
||||||
wxLogTrace(wxTraceResAlloc, wxT("Write: Number = %d"), wxTheResourceCache->Number());
|
|
||||||
wxTheResourceCache->Append(buffer, (wxObject *)database);
|
|
||||||
}
|
}
|
||||||
char resName[300];
|
|
||||||
strcpy(resName, !section.IsNull() ? wxMBSTRINGCAST section.mb_str() : "wxWindows");
|
|
||||||
strcat(resName, ".");
|
|
||||||
strcat(resName, entry.mb_str());
|
|
||||||
XrmPutStringResource(&database, resName, value.mb_str());
|
|
||||||
return TRUE;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file )
|
bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file )
|
||||||
{
|
{
|
||||||
char buf[50];
|
wxString buf;
|
||||||
sprintf(buf, "%.4f", value);
|
buf.Printf(wxT("%.4f"), value);
|
||||||
|
|
||||||
return wxWriteResource(section, entry, buf, file);
|
return wxWriteResource(section, entry, buf, file);
|
||||||
};
|
}
|
||||||
|
|
||||||
bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file )
|
bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file )
|
||||||
{
|
{
|
||||||
char buf[50];
|
wxString buf;
|
||||||
sprintf(buf, "%ld", value);
|
buf.Printf(wxT("%ld"), value);
|
||||||
|
|
||||||
return wxWriteResource(section, entry, buf, file);
|
return wxWriteResource(section, entry, buf, file);
|
||||||
};
|
}
|
||||||
|
|
||||||
bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file )
|
bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file )
|
||||||
{
|
{
|
||||||
char buf[50];
|
wxString buf;
|
||||||
sprintf(buf, "%d", value);
|
buf.Printf(wxT("%d"), value);
|
||||||
|
|
||||||
return wxWriteResource(section, entry, buf, file);
|
return wxWriteResource(section, entry, buf, file);
|
||||||
};
|
}
|
||||||
|
|
||||||
bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file )
|
bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file )
|
||||||
{
|
{
|
||||||
if (!wxResourceDatabase)
|
wxString filename( file );
|
||||||
wxXMergeDatabases();
|
if (filename.IsEmpty()) filename = wxT(".wxWindows");
|
||||||
|
|
||||||
XrmDatabase database;
|
wxFileConfig conf( wxTheApp->GetAppName(), wxTheApp->GetVendorName(), filename );
|
||||||
if (!file.IsEmpty())
|
|
||||||
{
|
|
||||||
wxChar buffer[500];
|
|
||||||
// Is this right? Trying to get it to look in the user's
|
|
||||||
// home directory instead of current directory -- JACS
|
|
||||||
(void)GetIniFile(buffer, file);
|
|
||||||
|
|
||||||
wxNode *node = (wxNode*) NULL; /* suppress egcs warning */
|
conf.SetPath( section );
|
||||||
node = wxTheResourceCache->Find(buffer);
|
|
||||||
if (node)
|
|
||||||
{
|
|
||||||
database = (XrmDatabase)node->Data();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
database = XrmGetFileDatabase(wxConvCurrent->cWX2MB(buffer));
|
|
||||||
wxLogTrace(wxTraceResAlloc, wxT("Get: Number = %d"), wxTheResourceCache->Number());
|
|
||||||
wxTheResourceCache->Append(buffer, (wxObject *)database);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
database = wxResourceDatabase;
|
|
||||||
|
|
||||||
XrmValue xvalue;
|
wxString result;
|
||||||
char *str_type[20];
|
if (conf.Write( entry, &result ))
|
||||||
char buf[150];
|
|
||||||
strcpy(buf, section.mb_str());
|
|
||||||
strcat(buf, ".");
|
|
||||||
strcat(buf, entry.mb_str());
|
|
||||||
|
|
||||||
bool success = XrmGetResource(database, buf, "*", str_type, &xvalue);
|
|
||||||
// Try different combinations of upper/lower case, just in case...
|
|
||||||
if (!success)
|
|
||||||
{
|
{
|
||||||
buf[0] = (isupper(buf[0]) ? tolower(buf[0]) : toupper(buf[0]));
|
if (!result.IsEmpty())
|
||||||
success = XrmGetResource(database, buf, "*", str_type, &xvalue);
|
|
||||||
}
|
|
||||||
if (success)
|
|
||||||
{
|
{
|
||||||
if (*value)
|
char *s = new char[result.Len()+1];
|
||||||
delete[] *value;
|
wxStrcpy( s, result.c_str() );
|
||||||
*value = new char[xvalue.size + 1];
|
*value = s;
|
||||||
strncpy(*value, xvalue.addr, (int)xvalue.size);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
};
|
}
|
||||||
|
|
||||||
bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file )
|
bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file )
|
||||||
{
|
{
|
||||||
char *s = (char *) NULL;
|
wxChar *s = NULL;
|
||||||
bool succ = wxGetResource(section, entry, &s, file);
|
bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
|
||||||
if (succ)
|
if (succ)
|
||||||
{
|
{
|
||||||
*value = (float)strtod(s, (char **) NULL);
|
*value = (float)wxStrtod(s, NULL);
|
||||||
delete[] s;
|
delete[] s;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else
|
}
|
||||||
return FALSE;
|
else return FALSE;
|
||||||
};
|
}
|
||||||
|
|
||||||
bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file )
|
bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file )
|
||||||
{
|
{
|
||||||
char *s = (char *) NULL;
|
wxChar *s = NULL;
|
||||||
bool succ = wxGetResource(section, entry, &s, file);
|
bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
|
||||||
if (succ)
|
if (succ)
|
||||||
{
|
{
|
||||||
*value = strtol(s, (char **) NULL, 10);
|
*value = wxStrtol(s, NULL, 10);
|
||||||
delete[] s;
|
delete[] s;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else
|
}
|
||||||
return FALSE;
|
else return FALSE;
|
||||||
};
|
}
|
||||||
|
|
||||||
bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file )
|
bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file )
|
||||||
{
|
{
|
||||||
char *s = (char *) NULL;
|
wxChar *s = NULL;
|
||||||
bool succ = wxGetResource(section, entry, &s, file);
|
bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
|
||||||
if (succ)
|
if (succ)
|
||||||
{
|
{
|
||||||
// Handle True, False here
|
*value = (int)wxStrtol(s, NULL, 10);
|
||||||
// True, Yes, Enables, Set or Activated
|
|
||||||
if (*s == 'T' || *s == 'Y' || *s == 'E' || *s == 'S' || *s == 'A')
|
|
||||||
*value = TRUE;
|
|
||||||
// False, No, Disabled, Reset, Cleared, Deactivated
|
|
||||||
else if (*s == 'F' || *s == 'N' || *s == 'D' || *s == 'R' || *s == 'C')
|
|
||||||
*value = FALSE;
|
|
||||||
// Handle as Integer
|
|
||||||
else
|
|
||||||
*value = (int)strtol(s, (char **) NULL, 10);
|
|
||||||
delete[] s;
|
delete[] s;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else
|
}
|
||||||
return FALSE;
|
else return FALSE;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
@@ -47,15 +47,12 @@
|
|||||||
wxApp *wxTheApp = (wxApp *) NULL;
|
wxApp *wxTheApp = (wxApp *) NULL;
|
||||||
wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
|
wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
|
||||||
|
|
||||||
extern wxResourceCache *wxTheResourceCache;
|
|
||||||
extern bool g_isIdle;
|
extern bool g_isIdle;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// local functions
|
// local functions
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
extern void wxFlushResources();
|
|
||||||
|
|
||||||
/* forward declaration */
|
/* forward declaration */
|
||||||
gint wxapp_idle_callback( gpointer WXUNUSED(data) );
|
gint wxapp_idle_callback( gpointer WXUNUSED(data) );
|
||||||
void wxapp_install_idle_handler();
|
void wxapp_install_idle_handler();
|
||||||
@@ -498,12 +495,6 @@ bool wxApp::Initialize()
|
|||||||
wxInitializeStockLists();
|
wxInitializeStockLists();
|
||||||
wxInitializeStockObjects();
|
wxInitializeStockObjects();
|
||||||
|
|
||||||
#if wxUSE_WX_RESOURCES
|
|
||||||
wxTheResourceCache = new wxResourceCache( wxKEY_STRING );
|
|
||||||
|
|
||||||
wxInitializeResourceSystem();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxModule::RegisterModules();
|
wxModule::RegisterModules();
|
||||||
if (!wxModule::InitializeModules()) return FALSE;
|
if (!wxModule::InitializeModules()) return FALSE;
|
||||||
|
|
||||||
@@ -514,16 +505,6 @@ void wxApp::CleanUp()
|
|||||||
{
|
{
|
||||||
wxModule::CleanUpModules();
|
wxModule::CleanUpModules();
|
||||||
|
|
||||||
#if wxUSE_WX_RESOURCES
|
|
||||||
wxFlushResources();
|
|
||||||
|
|
||||||
if (wxTheResourceCache)
|
|
||||||
delete wxTheResourceCache;
|
|
||||||
wxTheResourceCache = (wxResourceCache*) NULL;
|
|
||||||
|
|
||||||
wxCleanUpResourceSystem();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (wxTheColourDatabase)
|
if (wxTheColourDatabase)
|
||||||
delete wxTheColourDatabase;
|
delete wxTheColourDatabase;
|
||||||
wxTheColourDatabase = (wxColourDatabase*) NULL;
|
wxTheColourDatabase = (wxColourDatabase*) NULL;
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
// #pragma implementation
|
// #pragma implementation
|
||||||
#endif
|
#endif
|
||||||
@@ -22,14 +21,6 @@
|
|||||||
|
|
||||||
#define _MAXPATHLEN 500
|
#define _MAXPATHLEN 500
|
||||||
|
|
||||||
/* Used for X resources */
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <X11/Xutil.h>
|
|
||||||
#include <X11/Xresource.h>
|
|
||||||
|
|
||||||
wxResourceCache *wxTheResourceCache = (wxResourceCache *) NULL;
|
|
||||||
XrmDatabase wxResourceDatabase;
|
|
||||||
|
|
||||||
/* Useful buffer, initialized in wxCommonInit */
|
/* Useful buffer, initialized in wxCommonInit */
|
||||||
wxChar *wxBuffer = (wxChar *) NULL;
|
wxChar *wxBuffer = (wxChar *) NULL;
|
||||||
|
|
||||||
|
@@ -1,13 +1,12 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: utils.cpp
|
// Name: utilres.cpp
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Author: Robert Roebling
|
// Author: Robert Roebling
|
||||||
// Id: $Id$
|
// Id: $Id$
|
||||||
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
|
// Copyright: (c) 1998 Robert Roebling
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
//#ifdef __GNUG__
|
//#ifdef __GNUG__
|
||||||
//#pragma implementation "utils.h"
|
//#pragma implementation "utils.h"
|
||||||
//#endif
|
//#endif
|
||||||
@@ -16,190 +15,8 @@
|
|||||||
#include "wx/string.h"
|
#include "wx/string.h"
|
||||||
#include "wx/list.h"
|
#include "wx/list.h"
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
#include "wx/gdicmn.h"
|
#include "wx/config.h"
|
||||||
|
#include "wx/app.h"
|
||||||
#include <ctype.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
//#ifdef __SVR4__
|
|
||||||
//#include <sys/systeminfo.h>
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
#include "gdk/gdkx.h" // GDK_DISPLAY
|
|
||||||
#include "gdk/gdkprivate.h" // gdk_progclass
|
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <X11/Xutil.h>
|
|
||||||
#include <X11/Xresource.h>
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// constants
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Yuck this is really BOTH site and platform dependent
|
|
||||||
// so we should use some other strategy!
|
|
||||||
#ifdef __SUN__
|
|
||||||
# define DEFAULT_XRESOURCE_DIR wxT("/usr/openwin/lib/app-defaults")
|
|
||||||
#else
|
|
||||||
# define DEFAULT_XRESOURCE_DIR wxT("/usr/lib/X11/app-defaults")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// glabal data (data.cpp)
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
extern wxResourceCache *wxTheResourceCache;
|
|
||||||
extern XrmDatabase wxResourceDatabase;
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// utility functions for get/write resources
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
static wxChar *GetResourcePath(wxChar *buf, wxChar *name, bool create)
|
|
||||||
{
|
|
||||||
if (create && FileExists(name))
|
|
||||||
{
|
|
||||||
wxStrcpy(buf, name);
|
|
||||||
return buf; // Exists so ...
|
|
||||||
}
|
|
||||||
if (*name == wxT('/'))
|
|
||||||
wxStrcpy(buf, name);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Put in standard place for resource files if not absolute
|
|
||||||
wxStrcpy(buf, DEFAULT_XRESOURCE_DIR);
|
|
||||||
wxStrcat(buf, wxT("/"));
|
|
||||||
wxStrcat(buf, FileNameFromPath(name));
|
|
||||||
}
|
|
||||||
if (create)
|
|
||||||
{
|
|
||||||
// Touch the file to create it
|
|
||||||
FILE *fd = fopen(wxConvCurrent->cWX2MB(buf), "w");
|
|
||||||
if (fd) fclose(fd);
|
|
||||||
}
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read $HOME for what it says is home, if not
|
|
||||||
// read $USER or $LOGNAME for user name else determine
|
|
||||||
// the Real User, then determine the Real home dir.
|
|
||||||
static wxChar *GetIniFile(wxChar *dest, const wxChar *filename)
|
|
||||||
{
|
|
||||||
const wxChar *home = (const wxChar *) NULL;
|
|
||||||
if (filename && wxIsAbsolutePath(filename))
|
|
||||||
{
|
|
||||||
wxStrcpy(dest, filename);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ((home = wxGetUserHome(wxString())) != NULL)
|
|
||||||
{
|
|
||||||
wxStrcpy(dest, home);
|
|
||||||
if (dest[wxStrlen(dest) - 1] != wxT('/')) wxStrcat(dest, wxT("/"));
|
|
||||||
if (filename == NULL)
|
|
||||||
{
|
|
||||||
if ((filename = wxGetenv(wxT("XENVIRONMENT"))) == NULL) filename = wxT(".Xdefaults");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (*filename != wxT('.')) wxStrcat(dest, wxT("."));
|
|
||||||
wxStrcat(dest, filename);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dest[0] = wxT('\0');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void wxXMergeDatabases()
|
|
||||||
{
|
|
||||||
XrmDatabase homeDB, serverDB, applicationDB;
|
|
||||||
wxChar filenamebuf[1024];
|
|
||||||
|
|
||||||
wxChar *filename = &filenamebuf[0];
|
|
||||||
wxChar *environment;
|
|
||||||
char *classname = gdk_progclass; // Robert Roebling ??
|
|
||||||
char name[256];
|
|
||||||
(void)strcpy(name, "/usr/lib/X11/app-defaults/");
|
|
||||||
(void)strcat(name, classname ? classname : "wxWindows");
|
|
||||||
|
|
||||||
// Get application defaults file, if any
|
|
||||||
if ((applicationDB = XrmGetFileDatabase(name)))
|
|
||||||
(void)XrmMergeDatabases(applicationDB, &wxResourceDatabase);
|
|
||||||
|
|
||||||
// Merge server defaults, created by xrdb, loaded as a property of the root
|
|
||||||
// window when the server initializes and loaded into the display
|
|
||||||
// structure on XOpenDisplay;
|
|
||||||
// if not defined, use .Xdefaults
|
|
||||||
if (XResourceManagerString(GDK_DISPLAY()) != NULL)
|
|
||||||
{
|
|
||||||
serverDB = XrmGetStringDatabase(XResourceManagerString(GDK_DISPLAY()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
(void)GetIniFile(filename, (wxChar *) NULL);
|
|
||||||
serverDB = XrmGetFileDatabase(wxConvCurrent->cWX2MB(filename));
|
|
||||||
}
|
|
||||||
if (serverDB)
|
|
||||||
XrmMergeDatabases(serverDB, &wxResourceDatabase);
|
|
||||||
|
|
||||||
// Open XENVIRONMENT file, or if not defined, the .Xdefaults,
|
|
||||||
// and merge into existing database
|
|
||||||
|
|
||||||
if ((environment = wxGetenv(wxT("XENVIRONMENT"))) == NULL)
|
|
||||||
{
|
|
||||||
environment = GetIniFile(filename, (const wxChar *) NULL);
|
|
||||||
size_t len = wxStrlen(environment);
|
|
||||||
|
|
||||||
wxChar hostbuf[1024];
|
|
||||||
(void)wxGetHostName(hostbuf, WXSIZEOF(hostbuf) - len);
|
|
||||||
|
|
||||||
wxStrcat(environment, hostbuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((homeDB = XrmGetFileDatabase(wxConvCurrent->cWX2MB(environment))))
|
|
||||||
XrmMergeDatabases(homeDB, &wxResourceDatabase);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// called on application exit
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void wxFlushResources()
|
|
||||||
{
|
|
||||||
wxChar nameBuffer[512];
|
|
||||||
|
|
||||||
wxNode *node = wxTheResourceCache->First();
|
|
||||||
while (node) {
|
|
||||||
wxString str = node->GetKeyString();
|
|
||||||
wxChar *file = WXSTRINGCAST str;
|
|
||||||
// If file doesn't exist, create it first.
|
|
||||||
(void)GetResourcePath(nameBuffer, file, TRUE);
|
|
||||||
|
|
||||||
XrmDatabase database = (XrmDatabase)node->Data();
|
|
||||||
XrmPutFileDatabase(database, wxConvCurrent->cWX2MB(nameBuffer));
|
|
||||||
XrmDestroyDatabase(database);
|
|
||||||
wxNode *next = node->Next();
|
|
||||||
// delete node;
|
|
||||||
node = next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxDeleteResources(const wxChar *file)
|
|
||||||
{
|
|
||||||
wxLogTrace(wxTraceResAlloc, wxT("Delete: Number = %d"), wxTheResourceCache->Number());
|
|
||||||
wxChar buffer[500];
|
|
||||||
(void)GetIniFile(buffer, file);
|
|
||||||
|
|
||||||
wxNode *node = wxTheResourceCache->Find(buffer);
|
|
||||||
if (node) {
|
|
||||||
XrmDatabase database = (XrmDatabase)node->Data();
|
|
||||||
XrmDestroyDatabase(database);
|
|
||||||
// delete node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// resource functions
|
// resource functions
|
||||||
@@ -207,148 +24,100 @@ void wxDeleteResources(const wxChar *file)
|
|||||||
|
|
||||||
bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file )
|
bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file )
|
||||||
{
|
{
|
||||||
wxChar buffer[500];
|
wxString filename( file );
|
||||||
|
if (filename.IsEmpty()) filename = wxT(".wxWindows");
|
||||||
|
|
||||||
if (!entry) return FALSE;
|
wxFileConfig conf( wxTheApp->GetAppName(), wxTheApp->GetVendorName(), filename );
|
||||||
|
|
||||||
(void)GetIniFile(buffer, file);
|
conf.SetPath( section );
|
||||||
|
|
||||||
XrmDatabase database;
|
return conf.Write( entry, value );
|
||||||
wxNode *node = wxTheResourceCache->Find(buffer);
|
|
||||||
if (node)
|
|
||||||
database = (XrmDatabase)node->Data();
|
|
||||||
else {
|
|
||||||
database = XrmGetFileDatabase(wxConvCurrent->cWX2MB(buffer));
|
|
||||||
wxLogTrace(wxTraceResAlloc, wxT("Write: Number = %d"), wxTheResourceCache->Number());
|
|
||||||
wxTheResourceCache->Append(buffer, (wxObject *)database);
|
|
||||||
}
|
}
|
||||||
char resName[300];
|
|
||||||
strcpy(resName, !section.IsNull() ? wxMBSTRINGCAST section.mb_str() : "wxWindows");
|
|
||||||
strcat(resName, ".");
|
|
||||||
strcat(resName, entry.mb_str());
|
|
||||||
XrmPutStringResource(&database, resName, value.mb_str());
|
|
||||||
return TRUE;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file )
|
bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file )
|
||||||
{
|
{
|
||||||
char buf[50];
|
wxString buf;
|
||||||
sprintf(buf, "%.4f", value);
|
buf.Printf(wxT("%.4f"), value);
|
||||||
|
|
||||||
return wxWriteResource(section, entry, buf, file);
|
return wxWriteResource(section, entry, buf, file);
|
||||||
};
|
}
|
||||||
|
|
||||||
bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file )
|
bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file )
|
||||||
{
|
{
|
||||||
char buf[50];
|
wxString buf;
|
||||||
sprintf(buf, "%ld", value);
|
buf.Printf(wxT("%ld"), value);
|
||||||
|
|
||||||
return wxWriteResource(section, entry, buf, file);
|
return wxWriteResource(section, entry, buf, file);
|
||||||
};
|
}
|
||||||
|
|
||||||
bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file )
|
bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file )
|
||||||
{
|
{
|
||||||
char buf[50];
|
wxString buf;
|
||||||
sprintf(buf, "%d", value);
|
buf.Printf(wxT("%d"), value);
|
||||||
|
|
||||||
return wxWriteResource(section, entry, buf, file);
|
return wxWriteResource(section, entry, buf, file);
|
||||||
};
|
}
|
||||||
|
|
||||||
bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file )
|
bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file )
|
||||||
{
|
{
|
||||||
if (!wxResourceDatabase)
|
wxString filename( file );
|
||||||
wxXMergeDatabases();
|
if (filename.IsEmpty()) filename = wxT(".wxWindows");
|
||||||
|
|
||||||
XrmDatabase database;
|
wxFileConfig conf( wxTheApp->GetAppName(), wxTheApp->GetVendorName(), filename );
|
||||||
if (!file.IsEmpty())
|
|
||||||
{
|
|
||||||
wxChar buffer[500];
|
|
||||||
// Is this right? Trying to get it to look in the user's
|
|
||||||
// home directory instead of current directory -- JACS
|
|
||||||
(void)GetIniFile(buffer, file);
|
|
||||||
|
|
||||||
wxNode *node = (wxNode*) NULL; /* suppress egcs warning */
|
conf.SetPath( section );
|
||||||
node = wxTheResourceCache->Find(buffer);
|
|
||||||
if (node)
|
|
||||||
{
|
|
||||||
database = (XrmDatabase)node->Data();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
database = XrmGetFileDatabase(wxConvCurrent->cWX2MB(buffer));
|
|
||||||
wxLogTrace(wxTraceResAlloc, wxT("Get: Number = %d"), wxTheResourceCache->Number());
|
|
||||||
wxTheResourceCache->Append(buffer, (wxObject *)database);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
database = wxResourceDatabase;
|
|
||||||
|
|
||||||
XrmValue xvalue;
|
wxString result;
|
||||||
char *str_type[20];
|
if (conf.Write( entry, &result ))
|
||||||
char buf[150];
|
|
||||||
strcpy(buf, section.mb_str());
|
|
||||||
strcat(buf, ".");
|
|
||||||
strcat(buf, entry.mb_str());
|
|
||||||
|
|
||||||
bool success = XrmGetResource(database, buf, "*", str_type, &xvalue);
|
|
||||||
// Try different combinations of upper/lower case, just in case...
|
|
||||||
if (!success)
|
|
||||||
{
|
{
|
||||||
buf[0] = (isupper(buf[0]) ? tolower(buf[0]) : toupper(buf[0]));
|
if (!result.IsEmpty())
|
||||||
success = XrmGetResource(database, buf, "*", str_type, &xvalue);
|
|
||||||
}
|
|
||||||
if (success)
|
|
||||||
{
|
{
|
||||||
if (*value)
|
char *s = new char[result.Len()+1];
|
||||||
delete[] *value;
|
wxStrcpy( s, result.c_str() );
|
||||||
*value = new char[xvalue.size + 1];
|
*value = s;
|
||||||
strncpy(*value, xvalue.addr, (int)xvalue.size);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
};
|
}
|
||||||
|
|
||||||
bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file )
|
bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file )
|
||||||
{
|
{
|
||||||
char *s = (char *) NULL;
|
wxChar *s = NULL;
|
||||||
bool succ = wxGetResource(section, entry, &s, file);
|
bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
|
||||||
if (succ)
|
if (succ)
|
||||||
{
|
{
|
||||||
*value = (float)strtod(s, (char **) NULL);
|
*value = (float)wxStrtod(s, NULL);
|
||||||
delete[] s;
|
delete[] s;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else
|
}
|
||||||
return FALSE;
|
else return FALSE;
|
||||||
};
|
}
|
||||||
|
|
||||||
bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file )
|
bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file )
|
||||||
{
|
{
|
||||||
char *s = (char *) NULL;
|
wxChar *s = NULL;
|
||||||
bool succ = wxGetResource(section, entry, &s, file);
|
bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
|
||||||
if (succ)
|
if (succ)
|
||||||
{
|
{
|
||||||
*value = strtol(s, (char **) NULL, 10);
|
*value = wxStrtol(s, NULL, 10);
|
||||||
delete[] s;
|
delete[] s;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else
|
}
|
||||||
return FALSE;
|
else return FALSE;
|
||||||
};
|
}
|
||||||
|
|
||||||
bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file )
|
bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file )
|
||||||
{
|
{
|
||||||
char *s = (char *) NULL;
|
wxChar *s = NULL;
|
||||||
bool succ = wxGetResource(section, entry, &s, file);
|
bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
|
||||||
if (succ)
|
if (succ)
|
||||||
{
|
{
|
||||||
// Handle True, False here
|
*value = (int)wxStrtol(s, NULL, 10);
|
||||||
// True, Yes, Enables, Set or Activated
|
|
||||||
if (*s == 'T' || *s == 'Y' || *s == 'E' || *s == 'S' || *s == 'A')
|
|
||||||
*value = TRUE;
|
|
||||||
// False, No, Disabled, Reset, Cleared, Deactivated
|
|
||||||
else if (*s == 'F' || *s == 'N' || *s == 'D' || *s == 'R' || *s == 'C')
|
|
||||||
*value = FALSE;
|
|
||||||
// Handle as Integer
|
|
||||||
else
|
|
||||||
*value = (int)strtol(s, (char **) NULL, 10);
|
|
||||||
delete[] s;
|
delete[] s;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else
|
}
|
||||||
return FALSE;
|
else return FALSE;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
@@ -325,6 +325,7 @@ GSocket *GSocket_WaitConnection(GSocket *socket)
|
|||||||
struct sockaddr from;
|
struct sockaddr from;
|
||||||
SOCKLEN_T fromlen = sizeof(from);
|
SOCKLEN_T fromlen = sizeof(from);
|
||||||
GSocket *connection;
|
GSocket *connection;
|
||||||
|
GSocketError err;
|
||||||
int arg = 1;
|
int arg = 1;
|
||||||
|
|
||||||
assert(socket != NULL);
|
assert(socket != NULL);
|
||||||
|
Reference in New Issue
Block a user