]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/common/utilscmn.cpp
wxWindow::Fit() infinite loop bug fixed
[wxWidgets.git] / src / common / utilscmn.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: utilscmn.cpp
3// Purpose: Miscellaneous utility functions and classes
4// Author: Julian Smart
5// Modified by:
6// Created: 29/01/98
7// RCS-ID: $Id$
8// Copyright: (c) 1998 Julian Smart
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "utils.h"
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20#pragma hdrstop
21#endif
22
23#ifndef WX_PRECOMP
24#include "wx/defs.h"
25#include "wx/utils.h"
26#include "wx/window.h"
27#include "wx/menu.h"
28#include "wx/frame.h"
29#include "wx/msgdlg.h"
30#include "wx/textdlg.h"
31#endif
32
33#include "wx/ioswrap.h"
34
35#if wxUSE_IOSTREAMH
36 #include <fstream.h>
37#else
38 #include <fstream>
39#endif
40
41#include <ctype.h>
42#include <stdio.h>
43#include <stdlib.h>
44#include <string.h>
45#if !defined(__WATCOMC__)
46 #if !(defined(_MSC_VER) && (_MSC_VER > 800))
47 #include <errno.h>
48 #endif
49#endif
50#include <time.h>
51#ifndef __MWERKS__
52#include <sys/types.h>
53#include <sys/stat.h>
54#endif
55
56#ifdef __SALFORDC__
57#include <clib.h>
58#endif
59
60// Pattern matching code.
61// Yes, this path is deliberate (for Borland compilation)
62#ifdef wx_mac /* MATTHEW: [5] Mac doesn't like paths with "/" */
63#include "glob.inc"
64#else
65#include "../common/glob.inc"
66#endif
67
68#ifdef __WXMSW__
69#include "windows.h"
70#endif
71
72#define _MAXPATHLEN 500
73
74extern wxChar *wxBuffer;
75
76// ----------------------------------------------------------------------------
77// private functions
78// ----------------------------------------------------------------------------
79
80static wxWindow *wxFindWindowByLabel1(const wxString& title, wxWindow * parent);
81static wxWindow *wxFindWindowByName1 (const wxString& title, wxWindow * parent);
82
83#ifdef __WXMAC__
84int strcasecmp(const char *str_1, const char *str_2)
85{
86 register char c1, c2;
87 do {
88 c1 = tolower(*str_1++);
89 c2 = tolower(*str_2++);
90 } while ( c1 && (c1 == c2) );
91
92 return c1 - c2;
93}
94
95int strncasecmp(const char *str_1, const char *str_2, size_t maxchar)
96{
97
98 register char c1, c2;
99 while( maxchar--)
100 {
101 c1 = tolower(*str_1++);
102 c2 = tolower(*str_2++);
103
104 if ( !c1 || c1!=c2 )
105 return c1 - c2;
106
107 } ;
108
109 return 0 ;
110
111}
112#endif
113#ifdef __VMS__
114// we have no strI functions under VMS, therefore I have implemented
115// an inefficient but portable version: convert copies of strings to lowercase
116// and then use the normal comparison
117static void myLowerString(char *s)
118{
119 while(*s){
120 if(isalpha(*s)) *s = (char)tolower(*s);
121 s++;
122 }
123}
124
125int strcasecmp(const char *str_1, const char *str_2)
126{
127 char *temp1 = new char[strlen(str_1)+1];
128 char *temp2 = new char[strlen(str_2)+1];
129 strcpy(temp1,str_1);
130 strcpy(temp2,str_2);
131 myLowerString(temp1);
132 myLowerString(temp2);
133
134 int result = strcmp(temp1,temp2);
135 delete[] temp1;
136 delete[] temp2;
137
138 return(result);
139}
140
141int strncasecmp(const char *str_1, const char *str_2, size_t maxchar)
142{
143 char *temp1 = new char[strlen(str_1)+1];
144 char *temp2 = new char[strlen(str_2)+1];
145 strcpy(temp1,str_1);
146 strcpy(temp2,str_2);
147 myLowerString(temp1);
148 myLowerString(temp2);
149
150 int result = strncmp(temp1,temp2,maxchar);
151 delete[] temp1;
152 delete[] temp2;
153
154 return(result);
155}
156#endif
157
158#ifdef __WINDOWS__
159
160#ifndef __GNUWIN32__
161#ifndef __MWERKS__
162#define strcasecmp stricmp
163#define strncasecmp strnicmp
164#else
165#define strcasecmp _stricmp
166#define strncasecmp _strnicmp
167#endif
168#endif
169
170#else
171
172#ifdef __EMX__
173#define strcasecmp stricmp
174#define strncasecmp strnicmp
175#endif
176
177// This declaration is missing in SunOS!
178// (Yes, I know it is NOT ANSI-C but its in BSD libc)
179#if defined(__xlC) || defined(__AIX__) || defined(__GNUG__)
180extern "C"
181{
182 int strcasecmp (const char *, const char *);
183 int strncasecmp (const char *, const char *, size_t);
184}
185#endif
186#endif /* __WXMSW__ */
187
188
189wxChar *
190copystring (const wxChar *s)
191{
192 if (s == NULL) s = _T("");
193 size_t len = wxStrlen (s) + 1;
194
195 wxChar *news = new wxChar[len];
196 memcpy (news, s, len * sizeof(wxChar)); // Should be the fastest
197
198 return news;
199}
200
201// Id generation
202static long wxCurrentId = 100;
203
204long
205wxNewId (void)
206{
207 return wxCurrentId++;
208}
209
210long
211wxGetCurrentId(void) { return wxCurrentId; }
212
213void
214wxRegisterId (long id)
215{
216 if (id >= wxCurrentId)
217 wxCurrentId = id + 1;
218}
219
220void
221StringToFloat (wxChar *s, float *number)
222{
223 if (s && *s && number)
224 *number = (float) wxStrtod (s, (wxChar **) NULL);
225}
226
227void
228StringToDouble (wxChar *s, double *number)
229{
230 if (s && *s && number)
231 *number = wxStrtod (s, (wxChar **) NULL);
232}
233
234wxChar *
235FloatToString (float number, const wxChar *fmt)
236{
237 static wxChar buf[256];
238
239// sprintf (buf, "%.2f", number);
240 wxSprintf (buf, fmt, number);
241 return buf;
242}
243
244wxChar *
245DoubleToString (double number, const wxChar *fmt)
246{
247 static wxChar buf[256];
248
249 wxSprintf (buf, fmt, number);
250 return buf;
251}
252
253void
254StringToInt (wxChar *s, int *number)
255{
256 if (s && *s && number)
257 *number = (int) wxStrtol (s, (wxChar **) NULL, 10);
258}
259
260void
261StringToLong (wxChar *s, long *number)
262{
263 if (s && *s && number)
264 *number = wxStrtol (s, (wxChar **) NULL, 10);
265}
266
267wxChar *
268IntToString (int number)
269{
270 static wxChar buf[20];
271
272 wxSprintf (buf, _T("%d"), number);
273 return buf;
274}
275
276wxChar *
277LongToString (long number)
278{
279 static wxChar buf[20];
280
281 wxSprintf (buf, _T("%ld"), number);
282 return buf;
283}
284
285// Array used in DecToHex conversion routine.
286static wxChar hexArray[] = _T("0123456789ABCDEF");
287
288// Convert 2-digit hex number to decimal
289int wxHexToDec(const wxString& buf)
290{
291 int firstDigit, secondDigit;
292
293 if (buf.GetChar(0) >= _T('A'))
294 firstDigit = buf.GetChar(0) - _T('A') + 10;
295 else
296 firstDigit = buf.GetChar(0) - _T('0');
297
298 if (buf.GetChar(1) >= _T('A'))
299 secondDigit = buf.GetChar(1) - _T('A') + 10;
300 else
301 secondDigit = buf.GetChar(1) - _T('0');
302
303 return firstDigit * 16 + secondDigit;
304}
305
306// Convert decimal integer to 2-character hex string
307void wxDecToHex(int dec, wxChar *buf)
308{
309 int firstDigit = (int)(dec/16.0);
310 int secondDigit = (int)(dec - (firstDigit*16.0));
311 buf[0] = hexArray[firstDigit];
312 buf[1] = hexArray[secondDigit];
313 buf[2] = 0;
314}
315
316// Convert decimal integer to 2-character hex string
317wxString wxDecToHex(int dec)
318{
319 wxChar buf[3];
320 wxDecToHex(dec, buf);
321 return wxString(buf);
322}
323
324// Match a string INDEPENDENT OF CASE
325bool
326StringMatch (char *str1, char *str2, bool subString, bool exact)
327{
328 if (str1 == NULL || str2 == NULL)
329 return FALSE;
330 if (str1 == str2)
331 return TRUE;
332
333 if (subString)
334 {
335 int len1 = strlen (str1);
336 int len2 = strlen (str2);
337 int i;
338
339 // Search for str1 in str2
340 // Slow .... but acceptable for short strings
341 for (i = 0; i <= len2 - len1; i++)
342 {
343 if (strncasecmp (str1, str2 + i, len1) == 0)
344 return TRUE;
345 }
346 }
347 else if (exact)
348 {
349 if (strcasecmp (str1, str2) == 0)
350 return TRUE;
351 }
352 else
353 {
354 int len1 = strlen (str1);
355 int len2 = strlen (str2);
356
357 if (strncasecmp (str1, str2, wxMin (len1, len2)) == 0)
358 return TRUE;
359 }
360
361 return FALSE;
362}
363
364// Don't synthesize KeyUp events holding down a key and producing
365// KeyDown events with autorepeat. On by default and always on
366// on in wxMSW. wxGTK version in utilsgtk.cpp.
367#ifndef __WXGTK__
368bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) )
369{
370 return TRUE; // detectable auto-repeat is the only mode MSW supports
371}
372#endif
373
374// Return the current date/time
375// [volatile]
376wxString wxNow( void )
377{
378 time_t now = time((time_t *) NULL);
379 char *date = ctime(&now);
380 date[24] = '\0';
381 return wxString(date);
382}
383
384/*
385 * Strip out any menu codes
386 */
387
388wxChar *wxStripMenuCodes (wxChar *in, wxChar *out)
389{
390 if (!in)
391 return (wxChar *) NULL;
392
393 if (!out)
394 out = copystring(in);
395
396 wxChar *tmpOut = out;
397
398 while (*in)
399 {
400 if (*in == _T('&'))
401 {
402 // Check && -> &, &x -> x
403 if (*++in == _T('&'))
404 *out++ = *in++;
405 }
406 else if (*in == _T('\t'))
407 {
408 // Remove all stuff after \t in X mode, and let the stuff as is
409 // in Windows mode.
410 // Accelerators are handled in wx_item.cc for Motif, and are not
411 // YET supported in XView
412 break;
413 }
414 else
415 *out++ = *in++;
416 } // while
417
418 *out = _T('\0');
419
420 return tmpOut;
421}
422
423wxString wxStripMenuCodes(const wxString& str)
424{
425 wxChar *buf = new wxChar[str.Length() + 1];
426 wxStripMenuCodes(WXSTRINGCAST str, buf);
427 wxString str1(buf);
428 delete[] buf;
429 return str1;
430}
431
432/*
433 * Window search functions
434 *
435 */
436
437/*
438 * If parent is non-NULL, look through children for a label or title
439 * matching the specified string. If NULL, look through all top-level windows.
440 *
441 */
442
443wxWindow *
444wxFindWindowByLabel (const wxString& title, wxWindow * parent)
445{
446 if (parent)
447 {
448 return wxFindWindowByLabel1(title, parent);
449 }
450 else
451 {
452 for ( wxWindowList::Node * node = wxTopLevelWindows.GetFirst();
453 node;
454 node = node->GetNext() )
455 {
456 wxWindow *win = node->GetData();
457 wxWindow *retwin = wxFindWindowByLabel1 (title, win);
458 if (retwin)
459 return retwin;
460 } // for()
461
462 }
463 return (wxWindow *) NULL;
464}
465
466// Recursive
467static wxWindow *
468wxFindWindowByLabel1 (const wxString& title, wxWindow * parent)
469{
470 if (parent)
471 {
472 if (parent->GetLabel() == title)
473 return parent;
474 }
475
476 if (parent)
477 {
478 for ( wxWindowList::Node * node = parent->GetChildren().GetFirst();
479 node;
480 node = node->GetNext() )
481 {
482 wxWindow *win = (wxWindow *)node->GetData();
483 wxWindow *retwin = wxFindWindowByLabel1 (title, win);
484 if (retwin)
485 return retwin;
486 }
487
488 }
489
490 return (wxWindow *) NULL; // Not found
491}
492
493/*
494 * If parent is non-NULL, look through children for a name
495 * matching the specified string. If NULL, look through all top-level windows.
496 *
497 */
498
499wxWindow *
500wxFindWindowByName (const wxString& title, wxWindow * parent)
501{
502 if (parent)
503 {
504 return wxFindWindowByName1 (title, parent);
505 }
506 else
507 {
508 for ( wxWindowList::Node * node = wxTopLevelWindows.GetFirst();
509 node;
510 node = node->GetNext() )
511 {
512 wxWindow *win = node->GetData();
513 wxWindow *retwin = wxFindWindowByName1 (title, win);
514 if (retwin)
515 return retwin;
516 }
517
518 }
519
520 // Failed? Try by label instead.
521 return wxFindWindowByLabel(title, parent);
522}
523
524// Recursive
525static wxWindow *
526wxFindWindowByName1 (const wxString& title, wxWindow * parent)
527{
528 if (parent)
529 {
530 if ( parent->GetName() == title )
531 return parent;
532 }
533
534 if (parent)
535 {
536 for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ())
537 {
538 wxWindow *win = (wxWindow *) node->Data ();
539 wxWindow *retwin = wxFindWindowByName1 (title, win);
540 if (retwin)
541 return retwin;
542 } // for()
543
544 }
545
546 return (wxWindow *) NULL; // Not found
547
548}
549
550// Returns menu item id or -1 if none.
551int
552wxFindMenuItemId (wxFrame * frame, const wxString& menuString, const wxString& itemString)
553{
554 wxMenuBar *menuBar = frame->GetMenuBar ();
555 if (!menuBar)
556 return -1;
557 return menuBar->FindMenuItem (menuString, itemString);
558}
559
560/*
561On Fri, 21 Jul 1995, Paul Craven wrote:
562
563> Is there a way to find the path of running program's executable? I can get
564> my home directory, and the current directory, but I don't know how to get the
565> executable directory.
566>
567
568The code below (warty as it is), does what you want on most Unix,
569DOS, and Mac platforms (it's from the ALS Prolog main).
570
571|| Ken Bowen Applied Logic Systems, Inc. PO Box 180,
572||==== Voice: +1 (617)965-9191 Newton Centre,
573|| FAX: +1 (617)965-1636 MA 02159 USA
574 Email: ken@als.com WWW: http://www.als.com
575------------------------------------------------------------------------
576*/
577
578// This code is commented out but it may be integrated with wxWin at
579// a later date, after testing. Thanks Ken!
580#if 0
581
582/*--------------------------------------------------------------------*
583 | whereami is given a filename f in the form: whereami(argv[0])
584 | It returns the directory in which the executable file (containing
585 | this code [main.c] ) may be found. A dot will be returned to indicate
586 | the current directory.
587 *--------------------------------------------------------------------*/
588
589static void
590whereami(name)
591 char *name;
592{
593 register char *cutoff = NULL; /* stifle -Wall */
594 register char *s;
595 register char *t;
596 int cc;
597 char ebuf[4096];
598
599 /*
600 * See if the file is accessible either through the current directory
601 * or through an absolute path.
602 */
603
604 if (access(name, R_OK) == 0) {
605
606 /*-------------------------------------------------------------*
607 * The file was accessible without any other work. But the current
608 * working directory might change on us, so if it was accessible
609 * through the cwd, then we should get it for later accesses.
610 *-------------------------------------------------------------*/
611
612 t = imagedir;
613 if (!absolute_pathname(name)) {
614#if defined(DOS) || defined(__WIN32__)
615 int drive;
616 char *newrbuf;
617
618 newrbuf = imagedir;
619#ifndef __DJGPP__
620 if (*(name + 1) == ':') {
621 if (*name >= 'a' && *name <= 'z')
622 drive = (int) (*name - 'a' + 1);
623 else
624 drive = (int) (*name - 'A' + 1);
625 *newrbuf++ = *name;
626 *newrbuf++ = *(name + 1);
627 *newrbuf++ = DIR_SEPARATOR;
628 }
629 else {
630 drive = 0;
631 *newrbuf++ = DIR_SEPARATOR;
632 }
633 if (getcwd(newrbuf, drive) == 0) { /* } */
634#else
635 if (getcwd(newrbuf, 1024) == 0) { /* } */
636#endif
637#else /* DOS */
638#ifdef HAVE_GETWD
639 if (getwd(imagedir) == 0) { /* } */
640#else /* !HAVE_GETWD */
641 if (getcwd(imagedir, 1024) == 0) {
642#endif /* !HAVE_GETWD */
643#endif /* DOS */
644 fatal_error(FE_GETCWD, 0);
645 }
646 for (; *t; t++) /* Set t to end of buffer */
647 ;
648 if (*(t - 1) == DIR_SEPARATOR) /* leave slash if already
649 * last char
650 */
651 cutoff = t - 1;
652 else {
653 cutoff = t; /* otherwise put one in */
654 *t++ = DIR_SEPARATOR;
655 }
656 }
657#if (!defined(__MAC__) && !defined(__DJGPP__) && !defined(__GO32__) && !defined(__WIN32__))
658 else
659 (*t++ = DIR_SEPARATOR);
660#endif
661
662 /*-------------------------------------------------------------*
663 * Copy the rest of the string and set the cutoff if it was not
664 * already set. If the first character of name is a slash, cutoff
665 * is not presently set but will be on the first iteration of the
666 * loop below.
667 *-------------------------------------------------------------*/
668
669 for ((*name == DIR_SEPARATOR ? (s = name+1) : (s = name));;) {
670 if (*s == DIR_SEPARATOR)
671 cutoff = t;
672 if (!(*t++ = *s++))
673 break;
674 }
675
676 }
677 else {
678
679 /*-------------------------------------------------------------*
680 * Get the path list from the environment. If the path list is
681 * inaccessible for any reason, leave with fatal error.
682 *-------------------------------------------------------------*/
683
684#ifdef __MAC__
685 if ((s = getenv("Commands")) == (char *) 0)
686#else
687 if ((s = getenv("PATH")) == (char *) 0)
688#endif
689 fatal_error(FE_PATH, 0);
690
691 /*
692 * Copy path list into ebuf and set the source pointer to the
693 * beginning of this buffer.
694 */
695
696 strcpy(ebuf, s);
697 s = ebuf;
698
699 for (;;) {
700 t = imagedir;
701 while (*s && *s != PATH_SEPARATOR)
702 *t++ = *s++;
703 if (t > imagedir && *(t - 1) == DIR_SEPARATOR)
704 ; /* do nothing -- slash already is in place */
705 else
706 *t++ = DIR_SEPARATOR; /* put in the slash */
707 cutoff = t - 1; /* set cutoff */
708 strcpy(t, name);
709 if (access(imagedir, R_OK) == 0)
710 break;
711
712 if (*s)
713 s++; /* advance source pointer */
714 else
715 fatal_error(FE_INFND, 0);
716 }
717
718 }
719
720 /*-------------------------------------------------------------*
721 | At this point the full pathname should exist in imagedir and
722 | cutoff should be set to the final slash. We must now determine
723 | whether the file name is a symbolic link or not and chase it down
724 | if it is. Note that we reuse ebuf for getting the link.
725 *-------------------------------------------------------------*/
726
727#ifdef HAVE_SYMLINK
728 while ((cc = readlink(imagedir, ebuf, 512)) != -1) {
729 ebuf[cc] = 0;
730 s = ebuf;
731 if (*s == DIR_SEPARATOR) {
732 t = imagedir;
733 }
734 else {
735 t = cutoff + 1;
736 }
737 for (;;) {
738 if (*s == DIR_SEPARATOR)
739 cutoff = t; /* mark the last slash seen */
740 if (!(*t++ = *s++)) /* copy the character */
741 break;
742 }
743 }
744
745#endif /* HAVE_SYMLINK */
746
747 strcpy(imagename, cutoff + 1); /* keep the image name */
748 *(cutoff + 1) = 0; /* chop off the filename part */
749}
750
751#endif
752void wxEnableTopLevelWindows(bool enable)
753{
754 wxWindowList::Node *node;
755 for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() )
756 node->GetData()->Enable(enable);
757}
758
759// Yield to other apps/messages and disable user input
760bool wxSafeYield(wxWindow *win)
761{
762 wxEnableTopLevelWindows(FALSE);
763 // always enable ourselves
764 if ( win )
765 win->Enable(TRUE);
766 bool rc = wxYield();
767 wxEnableTopLevelWindows(TRUE);
768 return rc;
769}
770
771/*
772 * N.B. these convenience functions must be separate from msgdlgg.cpp, textdlgg.cpp
773 * since otherwise the generic code may be pulled in unnecessarily.
774 */
775
776int wxMessageBox(const wxString& message, const wxString& caption, long style,
777 wxWindow *parent, int WXUNUSED(x), int WXUNUSED(y) )
778{
779 wxMessageDialog dialog(parent, message, caption, style);
780
781 int ans = dialog.ShowModal();
782 switch ( ans )
783 {
784 case wxID_OK:
785 return wxOK;
786 break;
787 case wxID_YES:
788 return wxYES;
789 break;
790 case wxID_NO:
791 return wxNO;
792 break;
793 default:
794 case wxID_CANCEL:
795 return wxCANCEL;
796 break;
797 }
798 return ans;
799}
800
801#if wxUSE_TEXTDLG
802wxString wxGetTextFromUser(const wxString& message, const wxString& caption,
803 const wxString& defaultValue, wxWindow *parent,
804 int x, int y, bool WXUNUSED(centre) )
805{
806 wxTextEntryDialog dialog(parent, message, caption, defaultValue, wxOK|wxCANCEL, wxPoint(x, y));
807 if (dialog.ShowModal() == wxID_OK)
808 return dialog.GetValue();
809 else
810 return wxString("");
811}
812#endif // wxUSE_TEXTDLG
813
814#ifdef __MWERKS__
815char *strdup(const char *s)
816{
817 return strcpy( (char*) malloc( strlen( s ) + 1 ) , s ) ;
818}
819
820int isascii( int c )
821{
822 return ( c >= 0 && c < 128 ) ;
823}
824#endif
825
826// ----------------------------------------------------------------------------
827// network and user id functions
828// ----------------------------------------------------------------------------
829
830// Get Full RFC822 style email address
831bool wxGetEmailAddress(wxChar *address, int maxSize)
832{
833 wxString email = wxGetEmailAddress();
834 if ( !email )
835 return FALSE;
836
837 wxStrncpy(address, email, maxSize - 1);
838 address[maxSize - 1] = _T('\0');
839
840 return TRUE;
841}
842
843wxString wxGetEmailAddress()
844{
845 wxString email;
846
847 wxString host = wxGetHostName();
848 if ( !!host )
849 {
850 wxString user = wxGetUserId();
851 if ( !!user )
852 {
853 wxString email(user);
854 email << _T('@') << host;
855 }
856 }
857
858 return email;
859}
860
861wxString wxGetUserId()
862{
863 static const int maxLoginLen = 256; // FIXME arbitrary number
864
865 wxString buf;
866 bool ok = wxGetUserId(buf.GetWriteBuf(maxLoginLen), maxLoginLen);
867 buf.UngetWriteBuf();
868
869 if ( !ok )
870 buf.Empty();
871
872 return buf;
873}
874
875wxString wxGetUserName()
876{
877 static const int maxUserNameLen = 1024; // FIXME arbitrary number
878
879 wxString buf;
880 bool ok = wxGetUserName(buf.GetWriteBuf(maxUserNameLen), maxUserNameLen);
881 buf.UngetWriteBuf();
882
883 if ( !ok )
884 buf.Empty();
885
886 return buf;
887}
888
889wxString wxGetHostName()
890{
891 static const size_t hostnameSize = 257;
892
893 wxString buf;
894 bool ok = wxGetHostName(buf.GetWriteBuf(hostnameSize), hostnameSize);
895
896 buf.UngetWriteBuf();
897
898 if ( !ok )
899 buf.Empty();
900
901 return buf;
902}
903
904wxString wxGetFullHostName()
905{
906 static const size_t hostnameSize = 257;
907
908 wxString buf;
909 bool ok = wxGetFullHostName(buf.GetWriteBuf(hostnameSize), hostnameSize);
910
911 buf.UngetWriteBuf();
912
913 if ( !ok )
914 buf.Empty();
915
916 return buf;
917}
918