many miscellaneous fixes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1998 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-03-29 16:46:18 +00:00
parent 8826f46f0d
commit 0fb67cd196
7 changed files with 1826 additions and 1732 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -274,6 +274,12 @@ bool wxFileExists(const char *pszFileName)
}
*/
bool wxDirExists( const wxString& dir )
{
struct stat st;
return ((stat(dir, &st) != -1) && S_ISDIR(st.st_mode) ? TRUE : FALSE);
}
bool
wxIsAbsolutePath (const wxString& filename)
{
@@ -785,7 +791,7 @@ wxMac2UnixFilename (char *s)
if (*s == ':')
*s = '/';
else
*s = wxToLower (*s); // Case INDEPENDENT
*s = tolower(*s); // Case INDEPENDENT
s++;
}
}
@@ -830,7 +836,7 @@ wxDos2UnixFilename (char *s)
*s = '/';
#ifdef __WXMSW__
else
*s = wxToLower (*s); // Case INDEPENDENT
*s = tolower(*s); // Case INDEPENDENT
#endif
s++;
}

View File

@@ -30,6 +30,7 @@
// standard headers
#include <locale.h>
#include <ctype.h>
// wxWindows
#include "wx/defs.h"
@@ -435,7 +436,7 @@ bool wxLocale::Init(const char *szName,
if ( m_strShort.IsEmpty() ) {
// FIXME I don't know how these 2 letter abbreviations are formed,
// this wild guess is surely wrong
m_strShort = wxToLower(szLocale[0]) + wxToLower(szLocale[1]);
m_strShort = tolower(szLocale[0]) + tolower(szLocale[1]);
}
// save the old locale to be able to restore it later

File diff suppressed because it is too large Load Diff

View File

@@ -359,28 +359,6 @@ wxString wxNow( void )
return wxString(date);
}
/* Get Full RFC822 style email address */
bool
wxGetEmailAddress (char *address, int maxSize)
{
char host[65];
char user[65];
if (wxGetHostName(host, 64) == FALSE)
return FALSE;
if (wxGetUserId(user, 64) == FALSE)
return FALSE;
char tmp[130];
strcpy(tmp, user);
strcat(tmp, "@");
strcat(tmp, host);
strncpy(address, tmp, maxSize - 1);
address[maxSize-1] = '\0';
return TRUE;
}
/*
* Strip out any menu codes
*/
@@ -822,37 +800,81 @@ int isascii( int c )
}
#endif
bool wxGetUserId(wxString& buf)
// ----------------------------------------------------------------------------
// network and user id functions
// ----------------------------------------------------------------------------
// Get Full RFC822 style email address
bool wxGetEmailAddress(char *address, int maxSize)
{
bool success = wxGetUserId(wxBuffer, 500);
if (success)
{
buf = wxBuffer;
return TRUE;
}
else
wxString email = wxGetEmailAddress();
if ( !email )
return FALSE;
strncpy(address, email, maxSize - 1);
address[maxSize - 1] = '\0';
return TRUE;
}
bool wxGetUserName(wxString& buf)
wxString wxGetEmailAddress()
{
bool success = wxGetUserName(wxBuffer, 500);
if (success)
wxString email;
wxString host = wxGetHostName();
if ( !!host )
{
buf = wxBuffer;
return TRUE;
wxString user = wxGetUserId();
if ( !!user )
{
wxString email(user);
email << '@' << host;
}
}
else
return FALSE;
return email;
}
bool wxGetHostName(wxString& buf)
wxString wxGetUserId()
{
static const int maxLoginLen = 256; // FIXME arbitrary number
wxString buf;
bool ok = wxGetUserId(buf.GetWriteBuf(maxLoginLen), maxLoginLen);
buf.UngetWriteBuf();
if ( !ok )
buf.Empty();
return buf;
}
wxString wxGetUserName()
{
static const int maxUserNameLen = 1024; // FIXME arbitrary number
wxString buf;
bool ok = wxGetUserName(buf.GetWriteBuf(maxUserNameLen), maxUserNameLen);
buf.UngetWriteBuf();
if ( !ok )
buf.Empty();
return buf;
}
wxString wxGetHostName()
{
static const size_t hostnameSize = 257;
wxString buf;
bool ok = wxGetHostName(buf.GetWriteBuf(hostnameSize), hostnameSize);
buf.UngetWriteBuf();
return ok;
if ( !ok )
buf.Empty();
return buf;
}

View File

@@ -29,7 +29,7 @@ class WXDLLEXPORT wxAcceleratorRefData: public wxObjectRefData
public:
wxAcceleratorRefData();
~wxAcceleratorRefData();
public:
int m_count;
wxAcceleratorEntry* m_entries;
@@ -71,13 +71,13 @@ wxAcceleratorTable::wxAcceleratorTable(int n, wxAcceleratorEntry entries[])
{
wxAcceleratorRefData* data = new wxAcceleratorRefData;
m_refData = data;
data->m_count = n;
data->m_entries = new wxAcceleratorEntry[n];
int i;
for (i = 0; i < n; i++)
data->m_entries[i] = entries[i];
}
bool wxAcceleratorTable::Ok() const
@@ -102,15 +102,15 @@ bool wxAcceleratorEntry::MatchesEvent(const wxKeyEvent& event) const
bool eventCtrlDown = event.ControlDown();
bool eventShiftDown = event.ShiftDown();
int eventKeyCode = event.KeyCode();
bool accAltDown = ((GetFlags() & wxACCEL_ALT) == wxACCEL_ALT);
bool accCtrlDown = ((GetFlags() & wxACCEL_CTRL) == wxACCEL_CTRL);
bool accShiftDown = ((GetFlags() & wxACCEL_SHIFT) == wxACCEL_SHIFT);
int accKeyCode = GetKeyCode();
int accKeyCode2 = GetKeyCode();
if (isascii(accKeyCode2))
accKeyCode2 = wxToLower(accKeyCode2);
accKeyCode2 = tolower(accKeyCode2);
return ((eventAltDown == accAltDown) && (eventCtrlDown == accCtrlDown) &&
(eventShiftDown == accShiftDown) &&
((eventKeyCode == accKeyCode || eventKeyCode == accKeyCode2))) ;

View File

@@ -110,9 +110,9 @@ void wxUsleep(unsigned long milliseconds)
// process management
// ----------------------------------------------------------------------------
int wxKill(long pid, int sig)
int wxKill(long pid, wxSignal sig)
{
return kill(pid, sig);
return kill(pid, (int)sig);
}
#define WXEXECUTE_NARGS 127
@@ -350,7 +350,7 @@ char *wxGetUserHome( const wxString &user )
{
struct passwd *who = (struct passwd *) NULL;
if (user.IsNull() || (user== ""))
if ( !user )
{
register char *ptr;
@@ -378,12 +378,15 @@ char *wxGetUserHome( const wxString &user )
}
// ----------------------------------------------------------------------------
// id routines
// network and user id routines
// ----------------------------------------------------------------------------
bool wxGetHostName(char *buf, int sz)
// retrieve either the hostname or FQDN depending on platform (caller must
// check whether it's one or the other, this is why this function is for
// private use only)
static bool wxGetHostNameInternal(char *buf, int sz)
{
wxCHECK_MSG( buf, FALSE, "NULL pointer in wxGetHostName" );
wxCHECK_MSG( buf, FALSE, "NULL pointer in wxGetHostNameInternal" );
*buf = '\0';
@@ -398,11 +401,11 @@ bool wxGetHostName(char *buf, int sz)
}
#elif defined(HAVE_GETHOSTNAME)
bool ok = gethostname(buf, sz) != -1;
#else
#else // no uname, no gethostname
wxFAIL_MSG("don't know host name for this machibe");
bool ok = FALSE;
#endif
#endif // uname/gethostname
if ( !ok )
{
@@ -412,6 +415,52 @@ bool wxGetHostName(char *buf, int sz)
return ok;
}
bool wxGetHostName(char *buf, int sz)
{
bool ok = wxGetHostNameInternal(buf, sz);
if ( ok )
{
// BSD systems return the FQDN, we only want the hostname, so extract
// it (we consider that dots are domain separators)
char *dot = strchr(buf, '.');
if ( dot )
{
// nuke it
*dot = '\0';
}
}
return ok;
}
bool wxGetFullHostName(char *buf, int sz)
{
bool ok = wxGetHostNameInternal(buf, sz);
if ( ok )
{
if ( !strchr(buf, '.') )
{
struct hostent *host = gethostbyname(buf);
if ( !host )
{
wxLogSysError(_("Cannot get the official hostname"));
ok = FALSE;
}
else
{
// the canonical name
strncpy(buf, host->h_name, sz);
}
}
//else: it's already a FQDN (BSD behaves this way)
}
return ok;
}
bool wxGetUserId(char *buf, int sz)
{
struct passwd *who;
@@ -473,14 +522,3 @@ void wxFatalError( const wxString &msg, const wxString &title )
exit(3); // the same exit code as for abort()
}
//------------------------------------------------------------------------
// directory routines
//------------------------------------------------------------------------
bool wxDirExists( const wxString& dir )
{
char buf[500];
strcpy( buf, WXSTRINGCAST(dir) );
struct stat sbuf;
return ((stat(buf, &sbuf) != -1) && S_ISDIR(sbuf.st_mode) ? TRUE : FALSE);
}