X11workbench Toolkit  1.0
platform_helper.h
Go to the documentation of this file.
1 // _ _ __ _ _ _ //
3 // _ __ | | __ _ | |_ / _| ___ _ __ _ __ ___ | |__ ___ | | _ __ ___ _ __ | |__ //
4 // | '_ \ | | / _` || __|| |_ / _ \ | '__|| '_ ` _ \ | '_ \ / _ \| || '_ \ / _ \| '__|| '_ \ //
5 // | |_) || || (_| || |_ | _|| (_) || | | | | | | | | | | || __/| || |_) || __/| | _ | | | | //
6 // | .__/ |_| \__,_| \__||_| \___/ |_| |_| |_| |_|_____|_| |_| \___||_|| .__/ \___||_|(_)|_| |_| //
7 // |_| |_____| |_| //
8 // //
9 // This header contains platform-specific definitions that rectify various issues. //
10 // It also contains a lot of the 'core' functionality for strings, startup, etc. //
11 // //
13 
14 /*****************************************************************************
15 
16  X11workbench - X11 programmer's 'work bench' application and toolkit
17  Copyright (c) 2010-2019 by Bob Frazier (aka 'Big Bad Bombastic Bob')
18 
19  DISCLAIMER: The X11workbench application and toolkit software are supplied
20  'as-is', with no warranties, either implied or explicit.
21  Any claims to alleged functionality or features should be
22  considered 'preliminary', and might not function as advertised.
23 
24  MIT-like license:
25 
26  There is no restriction as to what you can do with this software, so long
27  as you include the above copyright notice and DISCLAIMER for any distributed
28  work that is equal to or derived from this one, along with this paragraph
29  that explains the terms of the license if the source is also being made
30  available. A "derived work" describes a work that uses a significant portion
31  of the source files or algorithms that are included with this one.
32  Specifically excluded from this are files that were generated by the software,
33  or anything that is included with the software that is part of another package
34  (such as files that were created or added during the 'configure' process).
35  Specifically included is the use of part or all of any of the X11 workbench
36  toolkit source or header files in your distributed application. If you do not
37  ship the source, the above copyright statement is still required to be placed
38  in a reasonably prominent place, such as documentation, splash screens, and/or
39  'about the application' dialog boxes.
40 
41  Use and distribution are in accordance with GPL, LGPL, and/or the above
42  MIT-like license. See COPYING and README files for more information.
43 
44 
45  Additional information at http://sourceforge.net/projects/X11workbench
46 
47 ******************************************************************************/
48 
49 // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
50 //
51 // TODO: support some kind of COM objects on POSIX systems, with an API that
52 // translates directly to OLE 2 on Windows in a platform-indepenent way.
53 //
54 // COM equivalents (ORBs) on POSIX include the following technologies:
55 //
56 // libbonobo
57 // D-Bus
58 // XPCOM (Mozilla)
59 // CORBA and DCOP [obsolete]
60 //
61 // 'ORB' = 'Object Request Broker'
62 //
63 // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
64 
65 
76 #ifndef _PLATFORM_HELPER_H_INCLUDED_
77 #define _PLATFORM_HELPER_H_INCLUDED_
78 
79 #include <stdarg.h> /* stdarg to make sure I have va_list and other important stuff */
80 #include <stdint.h> /* for standard integer types like uint32_t */
81 
82 #ifndef WIN32
83 // X11 header files
84 
85 #include <X11/Xlib.h>
86 #include <X11/Xutil.h>
87 #include <X11/Xmd.h> // for 'CARD32' and other things
88 #include <X11/Xatom.h> // for 'XA_CARDINAL' and other things
89 
90 #else // WIN32
91 
92 #include <windows.h> // for WIN32 applications
93 
94 #endif // WIN32
95 
96 
97 
98 #if defined(__GNUC__) || defined(__DOXYGEN__)
99 
100 // ======================================================================================
101 // this section is used for doxygen documentation using the X11 definitions
102 // Additionally, 'clang' compilers also define '__GNUC__' and will use this section
103 
104 #include <pthread.h> /* make sure this is included for POSIX */
105 
106 #ifdef X11WORKBENCH_PROJECT_BUILD
107 
108 // Globally include the output of the configure script for GNUC compiles for "the project"
109 #include "X11workbenchToolkit_config.h" // the 'generated' version'
110 
111 #else // X11WORKBENCH_PROJECT_BUILD
112 
113 // This is for the installed version, a subset of the things defined by the configure output script.
114 // NOTE: this must be installed in the appropriate package directory along with platform_helper.h
115 #include "X11workbenchToolkit_install_config.h"
116 
117 #endif // X11WORKBENCH_PROJECT_BUILD
118 
119 // TESTING THE CONFIGURATION - TODO: for some, provide alternates?
120 // NOTE that for '_MSC_VER' defined, certain features won't be checked
121 
122 // basic checks - test them all up front, then individual errors if any of these
123 // are not defined in the appropriate header files
124 #if !defined( HAVE_ALARM ) || !defined( HAVE_CHOWN ) || \
125  !defined( HAVE_CLOCK_GETTIME ) || !defined( HAVE_DUP2 ) || !defined( HAVE_FORK ) || \
126  !defined( HAVE_FTRUNCATE ) || !defined( HAVE_GETCWD ) || !defined( HAVE_GETTIMEOFDAY ) || \
127  !defined( HAVE_MALLOC ) || !defined( HAVE_MBLEN ) || !defined( HAVE_MEMCHR ) || \
128  !defined( HAVE_MEMMOVE ) || !defined( HAVE_MEMSET ) || !defined( HAVE_MKDIR ) || \
129  !defined( HAVE_PRINTF ) || !defined( HAVE_REALLOC ) || \
130  !defined( HAVE_SELECT ) || !defined( HAVE_SETLOCALE ) || !defined( HAVE_STRCASECMP ) || \
131  !defined( HAVE_STRCHR ) || !defined( HAVE_STRNCASECMP ) || !defined( HAVE_STRRCHR ) || \
132  !defined( HAVE_STRSTR ) || !defined( HAVE__BOOL ) || \
133  ( !defined(_MSC_VER) && ( !defined( LSTAT_FOLLOWS_SLASHED_SYMLINK ) || !defined( HAVE_VFORK ) || \
134  !defined( HAVE_WORKING_FORK ) || !defined( HAVE_WORKING_VFORK ) ))
135 // *************************************************************
136 #error
137 #error configure script feature check 1 fail
138 #error critical features missing
139 #error
140 // this next section spits out errors based on what's not defined.
141 #ifndef HAVE_ALARM
142 #error HAVE_ALARM is not defined
143 #endif // HAVE_ALARM
144 #ifndef HAVE_CHOWN
145 #error HAVE_CHOWN is not defined
146 #endif // HAVE_CHOWN
147 #ifndef HAVE_CLOCK_GETTIME
148 #error HAVE_CLOCK_GETTIME is not defined
149 #endif // HAVE_CLOCK_GETTIME
150 #ifndef HAVE_DUP2
151 #error HAVE_DUP2 is not defined
152 #endif // HAVE_DUP2
153 #ifndef HAVE_FORK
154 #error HAVE_FORK is not defined
155 #endif // HAVE_FORK
156 #ifndef HAVE_FTRUNCATE
157 #error HAVE_FTRUNCATE is not defined
158 #endif // HAVE_FTRUNCATE
159 #ifndef HAVE_GETCWD
160 #error HAVE_GETCWD is not defined
161 #endif // HAVE_GETCWD
162 #ifndef HAVE_GETTIMEOFDAY
163 #error HAVE_GETTIMEOFDAY is not defined
164 #endif // HAVE_GETTIMEOFDAY
165 #ifndef HAVE_MALLOC
166 #error HAVE_MALLOC is not defined
167 #endif // HAVE_MALLOC
168 #ifndef HAVE_MBLEN
169 #error HAVE_MBLEN is not defined
170 #endif // HAVE_MBLEN
171 #ifndef HAVE_MEMCHR
172 #error HAVE_MEMCHR is not defined
173 #endif // HAVE_MEMCHR
174 #ifndef HAVE_MEMMOVE
175 #error HAVE_MEMMOVE is not defined
176 #endif // HAVE_MEMMOVE
177 #ifndef HAVE_MEMSET
178 #error HAVE_MEMSET is not defined
179 #endif // HAVE_MEMSET
180 #ifndef HAVE_MKDIR
181 #error HAVE_MKDIR is not defined
182 #endif // HAVE_MKDIR
183 #ifndef HAVE_PRINTF
184 #error HAVE_PRINTF is not defined
185 #endif // HAVE_PRINTF
186 #ifndef HAVE_REALLOC
187 #error HAVE_REALLOC is not defined
188 #endif // HAVE_REALLOC
189 #ifndef HAVE_SELECT
190 #error HAVE_SELECT is not defined
191 #endif // HAVE_SELECT
192 #ifndef HAVE_SETLOCALE
193 #error HAVE_SETLOCALE is not defined
194 #endif // HAVE_SETLOCALE
195 #ifndef HAVE_STRCASECMP
196 #error HAVE_STRCASECMP is not defined
197 #endif // HAVE_STRCASECMP
198 #ifndef HAVE_STRCHR
199 #error HAVE_STRCHR is not defined
200 #endif // HAVE_STRCHR
201 #ifndef HAVE_STRNCASECMP
202 #error HAVE_STRNCASECMP is not defined
203 #endif // HAVE_STRNCASECMP
204 #ifndef HAVE_STRRCHR
205 #error HAVE_STRRCHR is not defined
206 #endif // HAVE_STRRCHR
207 #ifndef HAVE_STRSTR
208 #error HAVE_STRSTR is not defined
209 #endif // HAVE_STRSTR
210 #ifndef HAVE__BOOL
211 #error HAVE__BOOL is not defined
212 #endif // HAVE__BOOL
213 #ifndef LSTAT_FOLLOWS_SLASHED_SYMLINK
214 #error LSTAT_FOLLOWS_SLASHED_SYMLINK is not defined
215 #endif // LSTAT_FOLLOWS_SLASHED_SYMLINK
216 #ifndef HAVE_VFORK
217 #error HAVE_VFORK is not defined
218 #endif // HAVE_VFORK
219 #ifndef HAVE_WORKING_FORK
220 #error HAVE_WORKING_FORK is not defined
221 #endif // HAVE_WORKING_FORK
222 #ifndef HAVE_WORKING_VFORK
223 #error HAVE_WORKING_VFORK is not defined
224 #endif // HAVE_WORKING_VFORK
225 #error
226 // the end of that previous error section
227 // *************************************************************
228 #else
229 // -------------------------------------------------------------
230 #if !( HAVE_ALARM ) || !( HAVE_CHOWN ) || \
231  !( HAVE_CLOCK_GETTIME ) || !( HAVE_DUP2 ) || !( HAVE_FORK ) || \
232  !( HAVE_FTRUNCATE ) || !( HAVE_GETCWD ) || !( HAVE_GETTIMEOFDAY ) || \
233  !( HAVE_MALLOC ) || !( HAVE_MBLEN ) || !( HAVE_MEMCHR ) || \
234  !( HAVE_MEMMOVE ) || !( HAVE_MEMSET ) || !( HAVE_MKDIR ) || \
235  !( HAVE_PRINTF ) || !( HAVE_REALLOC ) || \
236  !( HAVE_SELECT ) || !( HAVE_SETLOCALE ) || !( HAVE_STRCASECMP ) || \
237  !( HAVE_STRCHR ) || !( HAVE_STRNCASECMP ) || !( HAVE_STRRCHR ) || \
238  !( HAVE_STRSTR ) || !( HAVE__BOOL ) || \
239  ( !defined(_MSC_VER) && ( !( LSTAT_FOLLOWS_SLASHED_SYMLINK ) || !( HAVE_VFORK ) || \
240  !( HAVE_WORKING_FORK ) || !( HAVE_WORKING_VFORK ) ))
241 #error
242 #error configure script feature check 2 fail
243 #error critical features missing
244 #error
245 
246 // TODO: individual error messages for those things 'not defined'? It's a bit
247 // easier to see where something is defined as '0' rather than finding
248 // something that isn't there. For now, I won't add that section, but I
249 // might do it if it becomes necessary
250 
251 #endif // all that stuff defined as a zero
252 // -------------------------------------------------------------
253 #endif // all that prior stuff
254 
255 #ifndef HAVE_BZERO
256  #define HAVE_BZERO 0
257 #endif // !HAVE_BZERO
258 
259 #if !( HAVE_BZERO )
260 // swap this in for 'bzero' using memset - it was checked for earlier
261  #define bzero(X,Y) memset((X),0,(Y))
262 #endif
263 
264 
265 // DEBUG vs RELEASE code
266 
267 #ifdef DEBUG /* explicit DEBUG build */
268 #ifdef NO_DEBUG
269 #undef NO_DEBUG // only one may be defined
270 #endif // NO_DEBUG
271 #endif // DEBUG
272 
273 // NOTE: The debug code will be included when NO_DEBUG is *NOT* defined
274 
293 #define INVALID_HANDLE_VALUE ((int)-1)
294 
299 // -----------------
300 // STRING-IZE MACROS
301 // -----------------
308 #define WB_STRINGIZE(X) WB_STRINGIZE_INTERNAL(X)
309 
314 #define WB_STRINGIZE_INTERNAL(X) #X
315 
316 
317 //-------------------------------------------------
318 // branch optimization macros - gcc and clang only
319 //-------------------------------------------------
320 
321 #if defined(COMPILER_SUPPORTS_BUILTIN_EXPECT) || defined(__DOXYGEN__)
322 
332 #define WB_UNLIKELY(x) (__builtin_expect (!!(x), 0))
333 
342 #define WB_LIKELY(x) (__builtin_expect (!!(x), 1))
343 
344 #else // !COMPILER_SUPPORTS_BUILTIN_EXPECT
345 
346 #define WB_UNLIKELY(x) (x)
347 #define WB_LIKELY(x) (x)
348 
349 #endif // COMPILER_SUPPORTS_BUILTIN_EXPECT
350 
351 #if defined(COMPILER_SUPPORTS_UNUSED_ATTRIBUTE) || defined(__DOXYGEN__)
352 
364 #define WB_UNUSED __attribute__((unused))
365 
366 #else // !COMPILER_SUPPORTS_UNUSED_ATTRIBUTE
367 
368 #define WB_UNUSED
369 
370 #endif // COMPILER_SUPPORTS_UNUSED_ATTRIBUTE
371 
372 
391 #define WB_INTERNAL_ATOM_MIN_VAL 0x3f000000L
402 typedef int WB_INT32;
403 
409 typedef unsigned int WB_UINT32;
410 
411 
412 #if defined(HAVE_LONGLONG) || defined(__DOXYGEN__) /* 'configure' tests for 'long long' datatype valid in configure script */
413 
417 #define HAS_WB_UINT64_BUILTIN
418 
419 
425 typedef long long WB_INT64;
426 
432 typedef unsigned long long WB_UINT64;
433 
434 #else // !defined HAVE_LONGLONG, unlikely (this part won't show up in doxygen either)
435 
436 typedef struct tagWB_INT64 { WB_UINT32 dw2; WB_INT32 dw1; } WB_INT64; // note 'dw1' is a signed value
437 typedef struct tagWB_UINT64 { WB_UINT32 dw2; WB_UINT32 dw1; } WB_UINT64;
438 
439 #endif // _LONGLONG
440 
441 #ifdef __DOXYGEN__
442 
447 typedef unsigned long long WB_UINTPTR;
448 #else /* regular code uses this next part */
449 
450 #if !defined(__SIZEOF_POINTER__) // TODO find a better way to deal with pointer size if this isn't defined
451 #define __SIZEOF_POINTER__ 0
452 #endif
453 
454 #if defined(__LP64__) /* TODO see what WIN32 vs WIN64 does */
455 typedef WB_UINT64 WB_UINTPTR;
456 #elif __SIZEOF_POINTER__ == 4 /* 4-byte pointer */
457 typedef WB_UINT32 WB_UINTPTR;
458 #else // assume long pointer
459 typedef WB_UINT64 WB_UINTPTR;
460 #endif // __LP64__
461 #endif // __DOXYGEN__
462 
463 
467 #define WB_C99_INITIALIZERS /* allow C99-style initializers */
468 
474 typedef void * WB_MODULE;
475 
481 typedef pthread_t WB_THREAD;
482 
488 typedef void (* WB_PROCADDRESS)(void);
489 
495 typedef pthread_key_t WB_THREAD_KEY;
496 
502 typedef WB_UINT32 WB_COND; // defined as 'WB_UINT32' because of pthread_cond problems under Linux
503 //typedef pthread_cond_t WB_COND;
504 
510 typedef pthread_mutex_t WB_MUTEX;
511 
512 // TODO: sizeof(int) sizeof(long) - long is 64-bit for GNUC - MS compilers make it 32-bit
513 
514 #ifdef __DOXYGEN__
515 
521 #define __PACKED__ /* platform dependent; actual def must be a blank or doxygen barphs on it */
522 
523 #else // !__DOXYGEN__
524 
525 #define __PACKED__ __attribute__((__packed__))
526 
527 #endif // __DOXYGEN__
528 
529 // end of section for clang and gcc compilers (and also doxygen definitions)
530 // ======================================================================================
531 
532 #elif defined(_MSC_VER) /* Microsoft C/C++ compiler */
533 
534 // ======================================================================================
535 // this section is dedicated to Microsoft compilers, which do things a bit different...
536 
537 // TODO: add proper support for MS compiler
538 #if _MSC_VER > 1300
539 
540 // TODO: specify correct version in which C99 initializers are supported
541 // as of MSC for ".Net" 2010 it's _NOT_ supported (still!)
542 //#define WB_C99_INITIALIZERS
543 
544 #endif // _MSC_VER > xxxx
545 
546 #define WB_UNLIKELY(x) (x)
547 #define WB_LIKELY(x) (x)
548 
549 #ifndef __inline__
550 #define __inline__ inline /* this assumes 'inline' is supported (MSC should support this) */
551 #endif // __inline__
552 
553 typedef __int64 WB_INT64;
554 typedef unsigned __int64 WB_UINT64;
555 typedef int WB_INT32;
556 typedef unsigned int WB_UINT32;
557 
558 // use terms similar to MS Windows Win32 API
559 typedef HMODULE WB_MODULE ; /* module handle */
560 typedef HANDLE WB_THREAD; /* thread handle - thread IDs are still 'int' types */
561 typedef FARPROC WB_PROCADDRESS; // generic proc address returned from GetProcAddress()
562 
563 typedef DWORD WBTHREAD_KEY; // return from 'TlsAlloc()'
564 typedef HANDLE WB_COND; // equivalent to an event handle
565 typedef HANDLE WB_MUTEX; // equivalent to a mutex handle
566 
567 
568 // TODO: sizeof(int) sizeof(long) - long is 32-bit for MSC
569 
570 // TODO: compatibility definition file for winders
571 
572 #define __PACKED__ /* TODO: a definition for packing in MS-land */
573 
574 // end of section specific to Microsoft compilers
575 // ======================================================================================
576 
577 #else // !defined(_MSVC_VER) && !defined(__GNUC__)
578 
579 #error unknown and/or unsupported compiler
580 
581 #endif // __GNUC__
582 
583 
584 // put standard '#define's and typedefs here, the ones that apply to EVERYBODY
585 
590 #define WB_SECURE_HASH_TIMEOUT 60000
600 typedef char * WB_PSTR;
601 typedef const char * WB_PCSTR;
602 
603 
609 // //
611 // ____ _ _ _ _ ____ _ _ _ //
612 // / ___| | |_ __ _ _ __ | |_ _ _ _ __ / \ _ __ __| | / ___| | |__ _ _ | |_ __| | ___ __ __ _ __ //
613 // \___ \ | __|/ _` || '__|| __|| | | || '_ \ / _ \ | '_ \ / _` | \___ \ | '_ \ | | | || __|/ _` | / _ \\ \ /\ / /| '_ \ //
614 // ___) || |_| (_| || | | |_ | |_| || |_) | / ___ \ | | | || (_| | ___) || | | || |_| || |_| (_| || (_) |\ V V / | | | | //
615 // |____/ \__|\__,_||_| \__| \__,_|| .__/ /_/ \_\|_| |_| \__,_| |____/ |_| |_| \__,_| \__|\__,_| \___/ \_/\_/ |_| |_| //
616 // |_| //
617 // //
619 
636 extern int bQuitFlag;
637 
638 // these functions are internal-only, implemented in window_helper.c, but must be defined here
639 void __internal_startup_display(const char *szVal);
640 void __internal_startup_minimize(void);
641 void __internal_startup_maximize(void);
642 void __internal_startup_geometry(const char *szVal);
643 
644 // thwaw function ARE internal only, implemented in font_helper.c and window_helper.c
645 void __internal_disable_antialias(void);
646 void __internal_disable_imagecache(void);
647 
648 
649 
650 // *******************************************
651 // STARTUP AND SHUTDOWN (must-call functions)
652 // *******************************************
653 
663 void WBPlatformOnInit(void);
664 
675 void WBPlatformOnExit(void);
676 
697 #if defined(DOXYGEN) || !defined(_MSC_VER)
698 int WBMain(int argc, char *argv[], char *envp[]);
699 #else // MSVC
700 int __declspec(selectany) WBMain(int argc, char *argv[], char *envp[]);
701 #endif // _MSC_VER
702 
716 #if defined(DOXYGEN) || !defined(_MSC_VER)
717 void WBUsage(void);
718 #else // _MSC_VER
719 void __declspec(selectany) WBUsage(void);
720 #endif // _MSC_VER
721 
751 int WBParseStandardArguments(int *pargc, char ***pargv, char ***penvp);
752 
758 void WBToolkitUsage(void);
759 
769 const char *GetStartupAppName(void);
770 
771 
772 
773 
775 // //
776 // ____ _ _ _ _ _ _ //
777 // / ___| _ _ ___ | |_ ___ _ __ ___ | | | || |_ (_)| | ___ //
778 // \___ \ | | | |/ __|| __|/ _ \| '_ ` _ \ | | | || __|| || |/ __| //
779 // ___) || |_| |\__ \| |_| __/| | | | | | | |_| || |_ | || |\__ \ //
780 // |____/ \__, ||___/ \__|\___||_| |_| |_| \___/ \__||_||_||___/ //
781 // |___/ //
782 // //
784 
785 
803 #if defined(HAS_WB_UINT64_BUILTIN) || defined(__DOXYGEN__)
805 #else // !defined(HAS_WB_UINT64_BUILTIN) && !defined(__DOXYGEN__)
807 #endif // defined(HAS_WB_UINT64_BUILTIN) || defined(__DOXYGEN__)
808 
809 
824 void WBDelay(uint32_t uiDelay); // approximate delay for specified period (in microseconds). may be interruptible
825 
826 
840 int WBCPUCount(void);
841 
842 
843 
845 // //
846 // __ __ _ _ _ _ _ //
847 // | \/ | ___ _ __ ___ ___ _ __ _ _ / \ | || | ___ ___ __ _ | |_ (_) ___ _ __ //
848 // | |\/| | / _ \| '_ ` _ \ / _ \ | '__|| | | | / _ \ | || | / _ \ / __|/ _` || __|| | / _ \ | '_ \ //
849 // | | | || __/| | | | | || (_) || | | |_| | / ___ \ | || || (_) || (__| (_| || |_ | || (_) || | | | //
850 // |_| |_| \___||_| |_| |_| \___/ |_| \__, | /_/ \_\|_||_| \___/ \___|\__,_| \__||_| \___/ |_| |_| //
851 // |___/ //
852 // //
854 
855 
856 // memory allocation (with debug support)
857 
866 void *WBAlloc(int nSize);
867 
876 void WBFree(void *pBuf);
877 
895 int WBAllocUsableSize(void *pBuf);
896 
906 void * WBReAlloc(void *pBuf, int nNewSize);
907 
917 void WBSubAllocTrashMasher(void);
918 
919 
920 // BASIC STRING UTILITIES
921 
922 // simple but helpful string utilities
923 
936 char *WBCopyString(const char *pSrc);
937 
952 char *WBCopyStringN(const char *pSrc, unsigned int nMaxChars);
953 
969 void WBCatString(char **ppDest, const char *pSrc);
970 
988 void WBCatStringN(char **ppDest, const char *pSrc, unsigned int nMaxChars);
989 
1001 void WBDeQuoteString(char *pszStr); // de-quote a string in place
1002 
1015 void WBNormalizeXMLString(char *pString);
1016 
1030 int WBStringLineCount(const char *pSrc, unsigned int nMaxChars);
1031 
1045 const char *WBStringNextLine(const char *pSrc, unsigned int *pnMaxChars);
1046 
1047 
1048 #if 0
1049 
1050 // THIS IS ALL RESERVED FOR FUTURE USE
1051 // MAY NOT BE NEEDED IF I USE _Xmbtowc _Xwctomb and _Xwctomb
1052 // X11 defines them as mblen(), mbtowc(), and wctomb()
1053 // The alternative is to do something similar on WIN32, once that is implemented in the toolkit
1054 // with '#ifdef blocks all around it
1055 
1073 int WBIsMultiByte(const char *pszStr);
1074 
1075 
1087 XChar2b * WBConvertMultiByteTo16(const char *pszStr);
1088 
1099 char *WBConvertMultiByteFrom16(const XChar2b *pwzStr);
1100 #endif // 0
1101 
1102 
1104 // //
1105 // __ __ ____ __ __ _ _ _ //
1106 // \ \/ /| _ \ | \/ | | | (_)| |__ _ __ __ _ _ __ _ _ //
1107 // \ / | |_) || |\/| | | | | || '_ \ | '__|/ _` || '__|| | | | //
1108 // / \ | __/ | | | | | |___ | || |_) || | | (_| || | | |_| | //
1109 // /_/\_\|_| |_| |_| |_____||_||_.__/ |_| \__,_||_| \__, | //
1110 // |___/ //
1111 // //
1113 
1114 
1115 // XPM library (libXpm) and X11/xpm.h
1116 
1117 #if defined(X11WORKBENCH_TOOLKIT_HAVE_XPM) && !defined(__DOXYGEN__)
1118 
1119 // Doxygen doesn't need THIS part, it needs the other one.
1120 
1121 #include <X11/xpm.h>
1122 
1123 // no need for doxygen doc comments here, see '!defined(__DOXYGEN__)' above
1124 // these definitions are for when libXpm is being used
1125 #define XPM_ATTRIBUTES XpmAttributes
1126 #define XPM_CREATE_PIXMAP_FROM_DATA(A,B,C,D,E,F) XpmCreatePixmapFromData(A,B,C,D,E,F)
1127 #define XPM_FREE_ATTRIBUTES(pAttr) XpmFreeAttributes(pAttr)
1128 
1129 #else // !X11WORKBENCH_TOOLKIT_HAVE_XPM or __DOXYGEN__
1130 
1177 typedef struct tagXPM_ATTRIBUTES
1178 {
1179  // I only need certain information from MyLoadPixmapFromData(), so that's all I'm doing with this structure
1180 
1181  int width;
1182  int height;
1183  int depth;
1184 
1185 } XPM_ATTRIBUTES;
1186 
1187 
1216 int MyLoadPixmapFromData(Display *pDisplay, Window wID, char *aData[],
1217  Pixmap *pPixmap, Pixmap *pMask, XPM_ATTRIBUTES *pAttr);
1218 
1233 #define XPM_CREATE_PIXMAP_FROM_DATA(A,B,C,D,E,F) MyLoadPixmapFromData(A,B,C,D,E,F)
1234 
1246 #define XPM_FREE_ATTRIBUTES(pAttr) /* does nothing */
1247 
1248 
1249 #endif
1250 
1251 
1252 // some helpful macros that need to be universal without being in a different header
1253 
1263 #define NEXT_WORD(pX, pY, pZ) {while(*(pX) && *(pX) <= ' '){(pX)++;} (pY)=(pZ)=(pX); while(*(pX)>' '){(pX)++;} (pZ)=(pX);}
1264 
1265 
1266 
1267 
1268 
1269 #ifdef __cplusplus
1270 extern "C" {
1271 #endif // __cplusplus
1272 
1273 // common macros
1274 
1275 #ifndef FALSE
1276 #define FALSE 0
1277 #endif // FALSE
1278 #ifndef TRUE
1279 #define TRUE !0
1280 #endif // TRUE
1281 
1282 
1283 
1284 // HANDLING qsort_r CALLING CONVENTION DIFFERENCES
1285 //
1286 #if defined(QSORT_R_BSD) && !defined(__DOXYGEN__)
1287 
1288 // DECLARE_SORT_FUNCTION based on - int (*compar)(void *, const void *, const void *)
1289 // generates int fn_name(void *p0, const void *p1, const void *p2)
1290 #define DECLARE_SORT_FUNCTION(fn_name,p0,p1,p2) int fn_name(void *p0, const void *p1, const void *p2)
1291 // void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))
1292 #define QSORT_R(A,B,C,D,E) qsort_r((A),(B),(C),(D),(E))
1293 
1294 #elif defined(QSORT_R_GNUC) && !defined(__DOXYGEN__)
1295 
1296 // DECLARE_SORT_FUNCTION based on typedef int (*__compar_d_fn_t) (__const void *, __const void *, void *)
1297 // generates int fn_name(const void *p1, const void *p2, void *p0)
1298 #define DECLARE_SORT_FUNCTION(fn_name,p0,p1,p2) int fn_name(const void *p1, const void *p2, void *p0)
1299 // extern void qsort_r (void *__base, size_t __nmemb, size_t __size, __compar_d_fn_t __compar, void *__arg)
1300 #define QSORT_R(A,B,C,D,E) qsort_r((A),(B),(C),(E),(D))
1301 
1302 #else
1303 
1304 // here is where I implement 'vectored' quicksort for OTHER PLATFORMS
1305 
1319 void my_qsort_r(void *base, int nmemb, int size, void *thunk,
1320  int (*compar)(void *, const void *, const void *));
1321 
1322 // the rest is exactly like the BSD version
1323 
1356 #define DECLARE_SORT_FUNCTION(fn_name,p0,p1,p2) int fn_name(void *p0, const void *p1, const void *p2)
1357 
1358 
1372 #define QSORT_R(base,nmemb,size,thunk,compar) my_qsort_r((base),(nmemb),(size),(thunk),(compar))
1373 
1374 #endif
1375 
1376 
1378 // //
1379 // ___ _ _ //
1380 // |_ _| _ __ | |_ ___ _ __ _ __ __ _ | | //
1381 // | | | '_ \ | __|/ _ \| '__|| '_ \ / _` || | //
1382 // | | | | | || |_| __/| | | | | || (_| || | //
1383 // |___||_| |_| \__|\___||_| |_| |_| \__,_||_| //
1384 // //
1385 // //
1387 
1388 
1389 // *********************************
1390 // INTERNAL memory/security helpers
1391 // *********************************
1392 
1418 WB_UINT32 WBCreatePointerHash(void *pPointer);
1419 
1441 void WBDestroyPointerHash(WB_UINT32 uiHash);
1442 
1459 void WBDestroyPointerHashPtr(void *pPointer);
1460 
1479 void * WBGetPointerFromHash(WB_UINT32 uiHash);
1480 
1481 
1482 
1484 // //
1485 // _ _ //
1486 // / \ | |_ ___ _ __ ___ ___ //
1487 // / _ \ | __|/ _ \ | '_ ` _ \ / __| //
1488 // / ___ \| |_| (_) || | | | | |\__ \ //
1489 // /_/ \_\\__|\___/ |_| |_| |_||___/ //
1490 // //
1491 // //
1493 
1494 //-----------------------------------------
1495 // ATOM HELPERS (internally-defined atoms)
1496 //-----------------------------------------
1497 
1498 
1522 Atom WBGetAtom(Display *pDisplay, const char *szAtomName);
1523 
1551 Atom WBLookupAtom(Display *pDisplay, const char *szAtomName);
1552 
1573 char * WBGetAtomName(Display *pDisplay, Atom aAtom);
1574 
1575 
1576 
1577 
1579 // //
1580 // ____ _ _ _ _____ _____ _ _ //
1581 // | _ \ __ _ | |_ | |__ ___ __ _ _ __ __| | |_ _|___ _ __ ___ _ __ | ___|(_)| | ___ ___ //
1582 // | |_) |/ _` || __|| '_ \ / __| / _` || '_ \ / _` | | | / _ \| '_ ` _ \ | '_ \ | |_ | || | / _ \/ __| //
1583 // | __/| (_| || |_ | | | |\__ \ | (_| || | | || (_| | | || __/| | | | | || |_) | | _| | || || __/\__ \ //
1584 // |_| \__,_| \__||_| |_||___/ \__,_||_| |_| \__,_| |_| \___||_| |_| |_|| .__/ |_| |_||_| \___||___/ //
1585 // |_| //
1586 // //
1588 
1589 // *******************************************
1590 // FILE/APPLICATION SEARCH PATH AND TEMP FILES
1591 // *******************************************
1592 
1604 int WBMkDir(const char *szFileName, int flags);
1605 
1606 
1621 char * WBSearchPath(const char *szFileName);
1622 
1641 char * WBTempFile(const char *szExt);
1642 
1643 
1658 char * WBTempFile0(const char *szExt);
1659 
1660 
1661 
1663 // //
1664 // _____ _ _ _ _ _ _ _ //
1665 // | ____|__ __| |_ ___ _ __ _ __ __ _ | | / \ _ __ _ __ | |(_) ___ __ _ | |_ (_) ___ _ __ ___ //
1666 // | _| \ \/ /| __|/ _ \| '__|| '_ \ / _` || | / _ \ | '_ \ | '_ \ | || | / __|/ _` || __|| | / _ \ | '_ \ / __| //
1667 // | |___ > < | |_| __/| | | | | || (_| || | / ___ \ | |_) || |_) || || || (__| (_| || |_ | || (_) || | | |\__ \ //
1668 // |_____|/_/\_\ \__|\___||_| |_| |_| \__,_||_| /_/ \_\| .__/ | .__/ |_||_| \___|\__,_| \__||_| \___/ |_| |_||___/ //
1669 // |_| |_| //
1670 // //
1671 // _ _ ____ //
1672 // / \ _ __ __| | | _ \ _ __ ___ ___ ___ ___ ___ ___ ___ //
1673 // / _ \ | '_ \ / _` | | |_) || '__|/ _ \ / __|/ _ \/ __|/ __| / _ \/ __| //
1674 // / ___ \ | | | || (_| | | __/ | | | (_) || (__| __/\__ \\__ \| __/\__ \ //
1675 // /_/ \_\|_| |_| \__,_| |_| |_| \___/ \___|\___||___/|___/ \___||___/ //
1676 // //
1678 
1679 // *********************
1680 // SPAWNING APPLICATIONS
1681 // *********************
1682 
1683 #ifdef WIN32
1684 #define WB_FILE_HANDLE HANDLE
1685 #define WB_PROCESS_ID HANDLE
1686 #define WB_INVALID_FILE_HANDLE INVALID_HANDLE_VALUE
1687 #else // !WIN32
1688 #define WB_FILE_HANDLE int
1689 #define WB_PROCESS_ID unsigned int
1690 #define WB_INVALID_FILE_HANDLE -1
1691 #endif // WIN32
1692 
1706 WB_PROCESS_ID WBRunAsync(const char *szAppName, ...);
1707 
1730 int WBGetProcessState(WB_PROCESS_ID idProcess, WB_INT32 *pExitCode);
1731 
1749 char * WBRunResult(const char *szAppName, ...);
1750 
1775 char * WBRunResultWithInput(const char *szStdInBuf, const char *szAppName, ...);
1776 
1804 WB_PROCESS_ID WBRunAsyncPipe(WB_FILE_HANDLE hStdIn, WB_FILE_HANDLE hStdOut, WB_FILE_HANDLE hStdErr,
1805  const char *szAppName, ...);
1806 
1837 WB_PROCESS_ID WBRunAsyncPipeV(WB_FILE_HANDLE hStdIn, WB_FILE_HANDLE hStdOut, WB_FILE_HANDLE hStdErr,
1838  const char *szAppName, va_list va);
1839 
1840 
1841 
1842 
1844 // ____ _ _ _ ____ _____ ____ _ ___ ____ ____ //
1845 // / ___|| | | | / \ | _ \| ____| _ \ | | |_ _| __ ) ___| //
1846 // \___ \| |_| | / _ \ | |_) | _| | | | | | | | || _ \___ \ //
1847 // ___) | _ |/ ___ \| _ <| |___| |_| | | |___ | || |_) |__) | //
1848 // |____/|_| |_/_/ \_\_| \_\_____|____/ |_____|___|____/____/ //
1849 // //
1851 
1879 WB_MODULE WBLoadLibrary(const char *szModuleName); // load a library module (shared lib, DLL, whatever)
1880 
1900 void WBFreeLibrary(WB_MODULE hModule);
1901 
1913 WB_PROCADDRESS WBGetProcAddress(WB_MODULE hModule, const char *szProcName);
1914 
1927 void * WBGetDataAddress(WB_MODULE hModule, const char *szDataName);
1928 
1929 
1931 // _____ _ _ ____ _____ _ ____ ____ //
1932 // |_ _| | | | _ \| ____| / \ | _ \/ ___| //
1933 // | | | |_| | |_) | _| / _ \ | | | \___ \ //
1934 // | | | _ | _ <| |___ / ___ \| |_| |___) | //
1935 // |_| |_| |_|_| \_\_____/_/ \_\____/|____/ //
1936 // //
1938 
1949 
1959 void WBThreadFreeLocal(WB_THREAD_KEY keyVal);
1960 
1971 void * WBThreadGetLocal(WB_THREAD_KEY keyVal);
1972 
1983 void WBThreadSetLocal(WB_THREAD_KEY keyVal, void *pValue);
1984 
1985 
1986 // simplified thread support (cross-platform)
1987 
1999 
2011 WB_THREAD WBThreadCreate(void *(*function)(void *), void *pParam);
2012 
2024 void *WBThreadWait(WB_THREAD hThread); // closes hThread, returns exit code, waits for thread to terminate (blocks)
2025 
2039 int WBThreadRunning(WB_THREAD hThread);
2040 
2052 void WBThreadExit(void *pRval);
2053 
2067 void WBThreadClose(WB_THREAD hThread);
2068 
2069 
2081 int WBCondCreate(WB_COND *pCond);
2082 
2093 int WBMutexCreate(WB_MUTEX *pMtx);
2094 
2104 void WBCondFree(WB_COND *pCond);
2105 
2115 void WBMutexFree(WB_MUTEX *pMtx);
2116 
2130 int WBMutexLock(WB_MUTEX *pMtx, int nTimeout);
2131 
2142 int WBMutexUnlock(WB_MUTEX *pMtx);
2143 
2155 int WBCondSignal(WB_COND *pCond);
2156 
2169 int WBCondWait(WB_COND *pCond, int nTimeout);
2170 
2189 int WBCondWaitMutex(WB_COND *pCond, WB_MUTEX *pMtx, int nTimeout);
2190 
2191 
2204 WB_UINT32 WBInterlockedDecrement(volatile WB_UINT32 *pValue);
2205 
2206 
2219 WB_UINT32 WBInterlockedIncrement(volatile WB_UINT32 *pValue);
2220 
2221 
2236 WB_UINT32 WBInterlockedExchange(volatile WB_UINT32 *pValue, WB_UINT32 nNewVal);
2237 
2238 
2252 WB_UINT32 WBInterlockedRead(volatile WB_UINT32 *pValue);
2253 
2254 
2255 
2257 // ____ ____ ___ _ _ _____ ___ _ _ ____ //
2258 // | _ \| _ \|_ _| \ | |_ _|_ _| \ | |/ ___| //
2259 // | |_) | |_) || || \| | | | | || \| | | _ //
2260 // | __/| _ < | || |\ | | | | || |\ | |_| | //
2261 // |_| |_| \_\___|_| \_| |_| |___|_| \_|\____| //
2262 // //
2264 
2265 // NOTE: the POSIX world uses postscript, particularly with CUPS. So does this library.
2266 
2294 int WBPrintPostScriptFile(const char *szPrinterName, const char *szFileName);
2295 
2314 char *WBGetPrinterList(void);
2315 
2316 // TODO: complete IPP support for cups and network-capable printers
2317 
2318 // TODO: printer capabilities in a binary structure
2319 
2320 // TODO: support for port 515 'printer' TCP/UDP printer services (i.e. cups-lpd or lpd)
2321 
2322 // TODO: dynamically load CUPS API when available. see 'cups-config' application docs
2323 
2324 
2325 
2326 #ifdef __cplusplus
2327 };
2328 #endif // __cplusplus
2329 
2330 
2331 #endif // _PLATFORM_HELPER_H_INCLDUED_
2332 
void * WBGetPointerFromHash(WB_UINT32 uiHash)
Obtain a pointer from a 32-bit 'secure' pointer hash value.
unsigned int WB_UINT32
Platform abstract unsigned 32-bit integer.
const char * GetStartupAppName(void)
returns a pointer to a copy of the application name from argv[0]
void WBPlatformOnExit(void)
Resource 'free-up' on exit (must call)
void * WB_MODULE
MODULE HANDLE equivalent.
char * WBTempFile(const char *szExt)
Get the name for a new, unique temporary file, creating the file in the process, and save its name fo...
WB_UINT32 WB_COND
CONDITION HANDLE equivalent (similar to an 'event')
WB_THREAD_KEY WBThreadAllocLocal(void)
Allocate 'thread local' storage.
int bQuitFlag
'Quit' Flag - you should check this periodically in your main (message) loop and exit whenever it is ...
void WBThreadFreeLocal(WB_THREAD_KEY keyVal)
Free 'thread local' storage allocated by WBThreadAllocLocal()
int WB_INT32
Platform abstract 32-bit integer.
int WBMutexUnlock(WB_MUTEX *pMtx)
Unlock a previously locked mutex.
void * WBThreadGetLocal(WB_THREAD_KEY keyVal)
Get 'thread local' data identified by 'keyVal'.
void WBCatStringN(char **ppDest, const char *pSrc, unsigned int nMaxChars)
A simple utility that concatenates a string onto the end of a 0-byte terminated WBAlloc() string up t...
int WBStringLineCount(const char *pSrc, unsigned int nMaxChars)
Determine how many 'lines' are in a block of text by counting 'linefeed' characters.
char * WBRunResult(const char *szAppName,...)
Run an application synchronously, returning 'stdout' output in a character buffer.
void WBSubAllocTrashMasher(void)
High performance memory sub-allocator 'trash masher' - call periodically to minimize wasted memory.
int MyLoadPixmapFromData(Display *pDisplay, Window wID, char *aData[], Pixmap *pPixmap, Pixmap *pMask, XPM_ATTRIBUTES *pAttr)
Alternate for XpmCreatePixmapFromData() whenever libXpm is not being used.
void WBFreeLibrary(WB_MODULE hModule)
Frees a shared library, DLL, module, or whatever, that was loaded via 'WBLoadLibrary()'.
WB_MODULE WBLoadLibrary(const char *szModuleName)
Loads a shared library, DLL, module, or whatever you call it on your operating system.
char * WBRunResultWithInput(const char *szStdInBuf, const char *szAppName,...)
Run an application synchronously, supplying an input buffer for 'stdin', and returning 'stdout' outpu...
void * WBThreadWait(WB_THREAD hThread)
Wait for a specified threat to exit.
void WBThreadExit(void *pRval)
Exit the current thread immediately, specifying return code.
WB_UINT32 WBInterlockedIncrement(volatile WB_UINT32 *pValue)
Interlocked 'atomic' increment of an unsigned integer.
void my_qsort_r(void *base, int nmemb, int size, void *thunk, int(*compar)(void *, const void *, const void *))
Local implementation of qsort_r() for operating systems that do not have it.
Compatibility structure for use with MyLoadPixmapFromData() whenever libXpm is not in use.
pthread_key_t WB_THREAD_KEY
THREAD LOCAL STORAGE 'key' equivalent.
WB_UINT32 WBCreatePointerHash(void *pPointer)
Create/obtain a 32-bit 'secure' hash for a pointer.
int WBMain(int argc, char *argv[], char *envp[])
Startup function, equivalent to 'main()' - provided for convenience.
Definition: X11workbench.c:164
WB_PROCESS_ID WBRunAsyncPipe(WB_FILE_HANDLE hStdIn, WB_FILE_HANDLE hStdOut, WB_FILE_HANDLE hStdErr, const char *szAppName,...)
Run an application asynchronously, specifying file handles for STDIN, STDOUT, and STDERR.
int WBMkDir(const char *szFileName, int flags)
a wrapper for 'mkdir' that makes directories recursively (as needed)
WB_UINT32 WBInterlockedExchange(volatile WB_UINT32 *pValue, WB_UINT32 nNewVal)
Interlocked 'atomic' exchange of an unsigned integer with a specified value.
int width
The width of the returned pixmaps.
void * WBReAlloc(void *pBuf, int nNewSize)
High performance memory sub-allocator 're-allocate'.
pthread_mutex_t WB_MUTEX
MUTEX HANDLE equivalent.
int WBGetProcessState(WB_PROCESS_ID idProcess, WB_INT32 *pExitCode)
Check on a running process, and return its state, and optionally the exit code.
WB_UINT64 WBGetTimeIndex(void)
Returns the current 'time index' (in microseconds)
WB_THREAD WBThreadCreate(void *(*function)(void *), void *pParam)
Create a new thread, returning its WB_THREAD identifier.
void WBDeQuoteString(char *pszStr)
De-Quote a string 'in place', that is modifying the original string by removing quotes.
void WBToolkitUsage(void)
Displays 'usage' for toolkit options to stderr.
void WBThreadSetLocal(WB_THREAD_KEY keyVal, void *pValue)
Get 'thread local' data identified by 'keyVal'.
void WBDestroyPointerHashPtr(void *pPointer)
Destroy a 32-bit 'secure' hash for a pointer regardless of reference count.
void(* WB_PROCADDRESS)(void)
PROC ADDRESS equivalent.
void * WBAlloc(int nSize)
High performance memory sub-allocator 'allocate'.
int WBCondSignal(WB_COND *pCond)
Signal a condition (event)
unsigned long long WB_UINT64
Platform abstract unsigned 64-bit integer.
void * WBGetDataAddress(WB_MODULE hModule, const char *szDataName)
Obtains a data pointer for an exported data symbol in a shared library (or DLL)
WB_PROCESS_ID WBRunAsync(const char *szAppName,...)
Run an application asynchronously.
char * WBGetPrinterList(void)
Get a list of printer names.
Atom WBLookupAtom(Display *pDisplay, const char *szAtomName)
Lookup (but do not allocate) an internal (or X11) Atom for a named string.
WB_THREAD WBThreadGetCurrent(void)
Get 'current thread' identifier.
char * WBSearchPath(const char *szFileName)
search for a file using the PATH environment variable
void WBFree(void *pBuf)
High performance memory sub-allocator 'free'.
void WBDelay(uint32_t uiDelay)
Delay for a specified period in microseconds.
int WBParseStandardArguments(int *pargc, char ***pargv, char ***penvp)
parses standard C arguments as passed to 'main()'
void WBPlatformOnInit(void)
Resource initialization on startup.
WB_UINT32 WBInterlockedDecrement(volatile WB_UINT32 *pValue)
Interlocked 'atomic' decrement of an unsigned integer.
int WBAllocUsableSize(void *pBuf)
High performance memory sub-allocator, similar to 'malloc_usable_size'.
unsigned long long WB_UINTPTR
Platform abstract unsigned integer that matches pointer size.
void WBUsage(void)
Optional startup function, sends 'usage' (help) info to stderr - application-defined function.
Atom WBGetAtom(Display *pDisplay, const char *szAtomName)
Lookup and/or allocate an internal Atom for a named string (lookups include X11 atoms)
WB_PROCADDRESS WBGetProcAddress(WB_MODULE hModule, const char *szProcName)
Obtains a function pointer for an exported function symbol in a shared library (or DLL)
int WBMutexCreate(WB_MUTEX *pMtx)
Create a lockable mutex.
int WBMutexLock(WB_MUTEX *pMtx, int nTimeout)
Wait for and lock a mutex, blocking until it is available.
int WBThreadRunning(WB_THREAD hThread)
Determine whether a thread is running (can be suspended)
const char * WBStringNextLine(const char *pSrc, unsigned int *pnMaxChars)
Locate the next line in a block of text, returning its pointer (and updating remaining length)
struct tagXPM_ATTRIBUTES XPM_ATTRIBUTES
Compatibility structure for use with MyLoadPixmapFromData() whenever libXpm is not in use.
WB_PROCESS_ID WBRunAsyncPipeV(WB_FILE_HANDLE hStdIn, WB_FILE_HANDLE hStdOut, WB_FILE_HANDLE hStdErr, const char *szAppName, va_list va)
Run an application asynchronously, specifying file handles for STDIN, STDOUT, and STDERR,...
char * WBCopyStringN(const char *pSrc, unsigned int nMaxChars)
A simple utility that returns a WBAlloc() copy of a string up to a maximum length (can also be 0-byte...
long long WB_INT64
Platform abstract 64-bit integer.
int depth
depth of the returned 'image' pixmap. The mask pixmap always has a depth of '1'.
int WBCondWait(WB_COND *pCond, int nTimeout)
Wait for a signal on a condition (event)
void WBMutexFree(WB_MUTEX *pMtx)
Free a lockable mutex.
void WBDestroyPointerHash(WB_UINT32 uiHash)
Destroy a 32-bit 'secure' hash for a pointer.
char * WBGetAtomName(Display *pDisplay, Atom aAtom)
Lookup and/or allocate an internal Atom for a named string.
pthread_t WB_THREAD
THREAD HANDLE equivalent.
char * WBTempFile0(const char *szExt)
Get the name for a new, unique temporary file, creating the file in the process.
char * WBCopyString(const char *pSrc)
A simple utility that returns a WBAlloc() copy of a 0-byte terminated string.
int WBCondWaitMutex(WB_COND *pCond, WB_MUTEX *pMtx, int nTimeout)
Wait for a signal on a condition (event)
void WBThreadClose(WB_THREAD hThread)
Close the specified WB_THREAD identifier.
int WBCPUCount(void)
Get the number of available CPU cores.
WB_UINT32 WBInterlockedRead(volatile WB_UINT32 *pValue)
Interlocked 'atomic' read of an unsigned integer.
int height
height of the returned pixmaps
int WBPrintPostScriptFile(const char *szPrinterName, const char *szFileName)
Send postscript file to a printer (using lpr-cups or lpr on POSIX systems)
int WBCondCreate(WB_COND *pCond)
Create a signallable condition.
void WBNormalizeXMLString(char *pString)
De-Quote and 'normalize' an XML string 'in place', that is modifying the original string by removing ...
void WBCatString(char **ppDest, const char *pSrc)
A simple utility that concatenates a string onto the end of a 0-byte terminated WBAlloc() string.
void WBCondFree(WB_COND *pCond)
Free a signallable condition.