MiniGUI API Reference (MiniGUI-Processes)  v5.0.6
A mature and proven cross-platform GUI system for embedded and smart IoT devices
common.h
Go to the documentation of this file.
1 //
3 // IMPORTANT NOTICE
4 //
5 // The following open source license statement does not apply to any
6 // entity in the Exception List published by FMSoft.
7 //
8 // For more information, please visit:
9 //
10 // https://www.fmsoft.cn/exception-list
11 //
13 
58 /*
59  * $Id: common.h 13674 2010-12-06 06:45:01Z wanzheng $
60  *
61  * MiniGUI for Linux/uClinux, eCos, uC/OS-II, VxWorks,
62  * pSOS, ThreadX, NuCleus, OSE, and Win32.
63  *
64  * The definitions of some data types and byte order macros
65  * borrowed from LGPL'ed SDL by Sam Lantinga.
66  *
67  * Fix point math routines come from Allegro (a gift software)
68  * by Shawn Hargreaves and others.
69  */
70 
71 #ifndef _MGUI_COMMON_H
72 
73 #define _MGUI_COMMON_H
74 
75 #ifndef MINIGUI_MAJOR_VERSION
76 # undef PACKAGE
77 # undef VERSION
78 # undef PACKAGE_BUGREPORT
79 # undef PACKAGE_NAME
80 # undef PACKAGE_STRING
81 # undef PACKAGE_TARNAME
82 # undef PACKAGE_VERSION
83 # ifdef __MINIGUI_LIB__
84 # ifdef _FOR_DATANG
85 # ifdef WIN32
86 # include <config-win32/mgconfig.h>
87 # elif defined (__THREADX__)
88 # include "config-threadx/mgconfig.h"
89 # elif defined (__NUCLEUS__)
90 # include "config-nucleus/mgconfig.h"
91 # endif
92 # else
93 # if defined(__CMAKE_PROJECT__) || defined(WIN32)
94 # include "mgconfig.h"
95 # else
96 # include "../mgconfig.h"
97 # endif
98 # endif
99 # else
100 # include "mgconfig.h"
101 # endif
102 #endif
103 
104 #include <stdio.h>
105 #include <stdlib.h>
106 #include <string.h>
107 #include <stdint.h>
108 #include <stdarg.h>
109 #include <errno.h>
110 #include <assert.h>
111 
132 #define _VERSION_CODE(major, minor, micro) \
133  (((major)<<16) | ((minor)<<8) | (micro))
134 
141 #define _MINIGUI_VERSION_CODE \
142  ((MINIGUI_MAJOR_VERSION << 16) | \
143  (MINIGUI_MINOR_VERSION << 8) | \
144  MINIGUI_MICRO_VERSION)
145 
157 typedef unsigned char Uint8;
162 typedef signed char Sint8;
167 typedef unsigned short Uint16;
172 typedef signed short Sint16;
177 typedef unsigned int Uint32;
182 typedef signed int Sint32;
183 
184 /* Figure out how to support 64-bit datatypes */
185 #if !defined(__STRICT_ANSI__)
186 # if defined(__GNUC__)
187 # define MGUI_HAS_64BIT_TYPE long long
188 # endif
189 # if defined(__CC_ARM)
190 # define MGUI_HAS_64BIT_TYPE long long
191 # endif
192 # if defined(_MSC_VER)
193 # define MGUI_HAS_64BIT_TYPE __int64
194 # endif
195 #endif /* !__STRICT_ANSI__ */
196 
197 /* The 64-bit datatype isn't supported on all platforms */
198 #ifdef MGUI_HAS_64BIT_TYPE
199 
206 typedef unsigned MGUI_HAS_64BIT_TYPE Uint64;
213 typedef signed MGUI_HAS_64BIT_TYPE Sint64;
214 #else
215 /* This is really just a hack to prevent the compiler from complaining */
216 typedef struct {
217  Uint32 hi;
218  Uint32 lo;
219 } Uint64, Sint64;
220 #endif
221 
222 /* Make sure the types really have the right sizes */
223 #define MGUI_COMPILE_TIME_ASSERT(name, x) \
224  typedef int MGUI_dummy_ ## name[(x) * 2 - 1]
225 
226 MGUI_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
227 MGUI_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1);
228 MGUI_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
229 MGUI_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);
230 MGUI_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
231 MGUI_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
232 MGUI_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
233 MGUI_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
234 
235 #undef MGUI_COMPILE_TIME_ASSERT
236 
239 /* Here we provide MG_GNUC_EXTENSION as an alias for __extension__,
240  * where this is valid. This allows for warningless compilation of
241  * "long long" types even in the presence of '-ansi -pedantic'.
242  */
243 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
244 #define MG_GNUC_EXTENSION __extension__
245 #else
246 #define MG_GNUC_EXTENSION
247 #endif
248 
249 /*
250  * The MG_LIKELY and MG_UNLIKELY macros let the programmer give hints to
251  * the compiler about the expected result of an expression. Some compilers
252  * can use this information for optimizations.
253  */
254 #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
255 #define _MG_BOOLEAN_EXPR(expr) \
256  MG_GNUC_EXTENSION ({ \
257  int _g_boolean_var_; \
258  if (expr) \
259  _g_boolean_var_ = 1; \
260  else \
261  _g_boolean_var_ = 0; \
262  _g_boolean_var_; \
263 })
264 #define MG_LIKELY(expr) (__builtin_expect (_MG_BOOLEAN_EXPR(expr), 1))
265 #define MG_UNLIKELY(expr) (__builtin_expect (_MG_BOOLEAN_EXPR(expr), 0))
266 #else
267 #define MG_LIKELY(expr) (expr)
268 #define MG_UNLIKELY(expr) (expr)
269 #endif
270 
280 #define MGUI_LIL_ENDIAN 1234
281 
285 #define MGUI_BIG_ENDIAN 4321
286 
287 /* Pardon the mess, I'm trying to determine the endianness of this host.
288  * I'm doing it by preprocessor defines rather than some sort of configure
289  * script so that application code can use this too. The "right" way would
290  * be to dynamically generate this file on install, but that's a lot of work.
291  */
292 
310 #if defined(__i386__) || defined(__ia64__) || defined(__x86_64__) || \
311  defined(__amd64) || \
312  (defined(__alpha__) || defined(__alpha)) || \
313  defined(__arm__) || defined(__aarch64__) || \
314  defined(__riscv) || \
315  (defined(__CC_ARM) && !defined(__BIG_ENDIAN)) || \
316  (defined(__mips__) && defined(__MIPSEL__)) || \
317  defined(__LITTLE_ENDIAN__) || \
318  defined(WIN32)
319 # define MGUI_BYTEORDER MGUI_LIL_ENDIAN
320 #else
321 # define MGUI_BYTEORDER MGUI_BIG_ENDIAN
322 #endif
323 
336 typedef void *PVOID;
337 
342 #ifndef BOOL
343 typedef int BOOL;
344 #endif
345 
350 #ifndef FALSE
351  #define FALSE 0
352 #endif
353 
357 #ifndef TRUE
358  #define TRUE 1
359 #endif
360 
365 #ifndef NULL
366 # ifdef __cplusplus
367 # define NULL (0)
368 # else
369 # define NULL ((void *)0)
370 # endif
371 #endif
372 
377 #define INV_PTR ((void *)-1)
378 
379 #define GUIAPI
380 
381 #if !defined(__NODLL__) && (defined (WIN32) || defined (__NUCLEUS_MNT__))
382 # if defined(__MINIGUI_LIB__)
383 # define MG_EXPORT __declspec(dllexport)
384 # else
385 # define MG_EXPORT __declspec(dllimport)
386 # endif
387 #else
388 # define MG_EXPORT
389 #endif
390 
402 typedef PVOID GHANDLE;
407 typedef GHANDLE HWND;
412 typedef GHANDLE HDC;
422 typedef GHANDLE HCURSOR;
427 typedef GHANDLE HICON;
432 typedef GHANDLE HMENU;
437 typedef GHANDLE HACCEL;
442 typedef GHANDLE HDLG;
447 typedef GHANDLE HHOOK;
448 
460 typedef unsigned char BYTE;
461 
466 typedef signed char SBYTE;
467 
476 #if defined(_WIN64)
477 # define SIZEOF_PTR 8
478 # define SIZEOF_HPTR 4
479 #elif defined(__LP64__)
480 # define SIZEOF_PTR 8
481 # define SIZEOF_HPTR 4
482 #else
483 # define SIZEOF_PTR 4
484 # define SIZEOF_HPTR 2
485 #endif
486 
487 #if SIZEOF_PTR == 8
488 # define NR_BITS_BYTE (8)
489 # define NR_BITS_WORD (32)
490 # define NR_BITS_DWORD (64)
491 
492 # define BITMASK_BYTE (0xFF)
493 # define BITMASK_WORD (0xFFFFFFFF)
494 # define BITMASK_DWORD (0xFFFFFFFFFFFFFFFF)
495 
496 # define INT_PTR_MIN (-9223372036854775807L-1)
497 # define INT_PTR_MAX (9223372036854775807L)
498 # define UINT_PTR_MAX (18446744073709551615UL)
499 #else
500 # define NR_BITS_BYTE (8)
501 # define NR_BITS_WORD (16)
502 # define NR_BITS_DWORD (32)
503 
504 # define BITMASK_BYTE (0xFF)
505 # define BITMASK_WORD (0xFFFF)
506 # define BITMASK_DWORD (0xFFFFFFFF)
507 
508 # define INT_PTR_MIN (-2147483647-1)
509 # define INT_PTR_MAX (2147483647)
510 # define UINT_PTR_MAX (4294967295U)
511 #endif
512 
517 #if defined(_WIN64)
518 typedef unsigned int WORD_HPTR;
519 #elif defined(__LP64__)
520 typedef unsigned int WORD_HPTR;
521 #else
522 typedef unsigned short WORD_HPTR;
523 #endif
524 
529 #if defined(_WIN64)
530 typedef signed int SWORD_HPTR;
531 #elif defined(__LP64__)
532 typedef signed int SWORD_HPTR;
533 #else
534 typedef signed short SWORD_HPTR;
535 #endif
536 
541 typedef WORD_HPTR WORD;
542 
548 
553 typedef unsigned short WORD16;
554 
559 typedef signed short SWORD16;
560 
565 #if defined(_WIN64)
566 typedef __int64 LONG_PTR;
567 #elif defined(__LP64__)
568 typedef long LONG_PTR;
569 #else
570 typedef long LONG_PTR;
571 #endif
572 
577 typedef LONG_PTR LINT;
578 
584 
592 #if defined(_WIN64)
593 typedef unsigned __int64 DWORD_PTR;
594 #elif defined(__LP64__)
595 typedef unsigned long DWORD_PTR;
596 #else
597 typedef unsigned long DWORD_PTR;
598 #endif
599 
604 typedef DWORD_PTR DWORD;
605 
610 typedef unsigned int DWORD32;
611 
619 #if defined(_WIN64)
620 typedef signed __int64 SDWORD_PTR;
621 #elif defined(__LP64__)
622 typedef signed long SDWORD_PTR;
623 #else
624 typedef signed long SDWORD_PTR;
625 #endif
626 
632 
637 typedef signed int SDWORD32;
638 
639 #if SIZEOF_PTR == 8
640 typedef unsigned short QDWORD;
641 #define QDWORD_SHIFT 16
642 #else
643 typedef unsigned char QDWORD;
644 #define QDWORD_SHIFT 8
645 #endif
646 
647 #define MAKEDWORD(q1, q2, q3, q4) \
648  ((DWORD)( \
649  (((DWORD)(QDWORD)(q1))) | \
650  (((DWORD)((QDWORD)(q2))) << QDWORD_SHIFT) | \
651  (((DWORD)((QDWORD)(q3))) << (QDWORD_SHIFT*2)) | \
652  (((DWORD)((QDWORD)(q4))) << (QDWORD_SHIFT*3)) \
653  ))
654 
655 #define FIRST_QDWORD(dw) ((QDWORD)(((DWORD)(dw))))
656 #define SECOND_QDWORD(dw) ((QDWORD)((((DWORD)(dw)) >> QDWORD_SHIFT)))
657 #define THIRD_QDWORD(dw) ((QDWORD)((((DWORD)(dw)) >> (QDWORD_SHIFT*2))))
658 #define FOURTH_QDWORD(dw) ((QDWORD)((((DWORD)(dw)) >> (QDWORD_SHIFT*3))))
659 
664 typedef unsigned int UINT;
665 
670 #if defined(_WIN64)
671 typedef __int64 INT_PTR;
672 #elif defined(__LP64__)
673 typedef long INT_PTR;
674 #else
675 typedef int INT_PTR;
676 #endif
677 
682 #if defined(_WIN64)
683 typedef unsigned __int64 UINT_PTR;
684 #elif defined(__LP64__)
685 typedef unsigned long UINT_PTR;
686 #else
687 typedef unsigned long UINT_PTR;
688 #endif
689 
694 typedef long LONG;
695 
700 typedef unsigned long ULONG;
701 
706 typedef UINT_PTR WPARAM;
707 
712 typedef UINT_PTR LPARAM;
713 
720 #define LOBYTE(w) ((BYTE)(w))
721 
728 #define HIBYTE(w) ((BYTE)(((WORD)(w) >> NR_BITS_BYTE) & BITMASK_BYTE))
729 
736 #define MAKEWORD(low, high) \
737  ((WORD)(((BYTE)(low)) | (((WORD)((BYTE)(high))) << NR_BITS_BYTE)))
738 
745 #define MAKEWORD16(low, high) \
746  ((WORD16)(((BYTE)(low)) | (((WORD16)((BYTE)(high))) << 8)))
747 
754 #define MAKEDWORD32(first, second, third, fourth) \
755  ((DWORD32)( \
756  ((BYTE)(first)) | \
757  (((DWORD32)((BYTE)(second))) << 8) | \
758  (((DWORD32)((BYTE)(third))) << 16) | \
759  (((DWORD32)((BYTE)(fourth))) << 24) \
760  ))
761 
768 #define MAKEWPARAM(first, second, third, fourth) \
769  ((WPARAM)( \
770  ((BYTE)(first)) | \
771  (((WPARAM)((BYTE)(second))) << 8) | \
772  (((WPARAM)((BYTE)(third))) << 16) | \
773  (((WPARAM)((BYTE)(fourth))) << 24) \
774  ))
775 
782 #define FIRSTBYTE(w) ((BYTE)(w))
783 
790 #define SECONDBYTE(w) ((BYTE)(((DWORD32)(w)) >> 8))
791 
798 #define THIRDBYTE(w) ((BYTE)(((DWORD32)(w)) >> 16))
799 
806 #define FOURTHBYTE(w) ((BYTE)(((DWORD32)(w)) >> 24))
807 
814 #define LOWORD(l) ((WORD)(DWORD)(l))
815 
821 #define HIWORD(l) \
822  ((WORD)((((DWORD)(l)) >> NR_BITS_WORD) & BITMASK_WORD))
823 
830 #define LOSWORD(l) ((SWORD)(DWORD)(l))
831 
837 #define HISWORD(l) \
838  ((SWORD)((((DWORD)(l)) >> NR_BITS_WORD) & BITMASK_WORD))
839 
845 #define MAKELONG32(low, high) \
846  ((DWORD32)(((WORD16)(low)) | (((DWORD32)((WORD16)(high))) << 16)))
847 
853 #define MAKELONG(low, high) \
854  ((DWORD)(((WORD)(low)) | (((DWORD)((WORD)(high))) << NR_BITS_WORD)))
855 
861 
870 #define GetRValue(rgba) ((BYTE)(rgba))
871 
879 #define GetGValue(rgba) ((BYTE)(((DWORD32)(rgba)) >> 8))
880 
888 #define GetBValue(rgba) ((BYTE)((DWORD32)(rgba) >> 16))
889 
897 #define GetAValue(rgba) ((BYTE)((DWORD32)(rgba) >> 24))
898 
909 #define MakeRGBA(r, g, b, a) \
910  (((DWORD32)((BYTE)(r))) \
911  | ((DWORD32)((BYTE)(g)) << 8) \
912  | ((DWORD32)((BYTE)(b)) << 16) \
913  | ((DWORD32)((BYTE)(a)) << 24))
914 
925 #define MakeRGB(r, g, b) MakeRGBA((r), (g), (b), 255)
926 
936 typedef struct _RECT {
940  int left;
944  int top;
948  int right;
952  int bottom;
953 } RECT;
960 typedef RECT* PRECT;
961 
966 typedef struct _POINT
967 {
971  int x;
975  int y;
976 } POINT;
983 typedef POINT* PPOINT;
984 
989 typedef struct _SIZE
990 {
994  int cx;
998  int cy;
999 } SIZE;
1006 typedef SIZE* PSIZE;
1007 
1012 typedef struct _RGB
1013 {
1030 } RGB;
1031 
1038 typedef RGB* PRGB;
1039 
1060 
1075 
1090 
1095 typedef signed int gal_sint;
1100 typedef unsigned int gal_uint;
1101 
1112 
1117 typedef long fixed;
1118 
1123 typedef struct _GAL_Color
1124 {
1141 } GAL_Color;
1142 
1147 typedef struct _GAL_Palette
1148 {
1152  int ncolors;
1157 } GAL_Palette;
1158 
1163 typedef struct _GAL_Rect {
1167  Sint32 x, y;
1171  Sint32 w, h;
1172 } GAL_Rect;
1173 
1196 #define MGUI_NR_KEYS 255
1197 
1210 #ifndef NR_KEYS
1211 #define NR_KEYS 250
1212 #endif
1213 
1230 #define SCANCODE_USER (NR_KEYS + 1)
1231 
1232 #define SCANCODE_RESERVED 0
1233 #define SCANCODE_ESCAPE 1
1234  #define SCANCODE_ESC SCANCODE_ESCAPE
1235 
1236 #define SCANCODE_1 2
1237 #define SCANCODE_2 3
1238 #define SCANCODE_3 4
1239 #define SCANCODE_4 5
1240 #define SCANCODE_5 6
1241 #define SCANCODE_6 7
1242 #define SCANCODE_7 8
1243 #define SCANCODE_8 9
1244 #define SCANCODE_9 10
1245 #define SCANCODE_0 11
1246 
1247 #define SCANCODE_MINUS 12
1248 #define SCANCODE_EQUAL 13
1249 
1250 #define SCANCODE_BACKSPACE 14
1251 #define SCANCODE_TAB 15
1252 
1253 #define SCANCODE_Q 16
1254 #define SCANCODE_W 17
1255 #define SCANCODE_E 18
1256 #define SCANCODE_R 19
1257 #define SCANCODE_T 20
1258 #define SCANCODE_Y 21
1259 #define SCANCODE_U 22
1260 #define SCANCODE_I 23
1261 #define SCANCODE_O 24
1262 #define SCANCODE_P 25
1263 #define SCANCODE_BRACKET_LEFT 26
1264  #define SCANCODE_LEFTBRACE SCANCODE_BRACKET_LEFT
1265 #define SCANCODE_BRACKET_RIGHT 27
1266  #define SCANCODE_RIGHTBRACE SCANCODE_BRACKET_RIGHT
1267 
1268 #define SCANCODE_ENTER 28
1269 
1270 #define SCANCODE_LEFTCONTROL 29
1271  #define SCANCODE_LEFTCTRL SCANCODE_LEFTCONTROL
1272 
1273 #define SCANCODE_A 30
1274 #define SCANCODE_S 31
1275 #define SCANCODE_D 32
1276 #define SCANCODE_F 33
1277 #define SCANCODE_G 34
1278 #define SCANCODE_H 35
1279 #define SCANCODE_J 36
1280 #define SCANCODE_K 37
1281 #define SCANCODE_L 38
1282 #define SCANCODE_SEMICOLON 39
1283 #define SCANCODE_APOSTROPHE 40
1284 #define SCANCODE_GRAVE 41
1285 #define SCANCODE_LEFTSHIFT 42
1286 #define SCANCODE_BACKSLASH 43
1287 
1288 #define SCANCODE_Z 44
1289 #define SCANCODE_X 45
1290 #define SCANCODE_C 46
1291 #define SCANCODE_V 47
1292 #define SCANCODE_B 48
1293 #define SCANCODE_N 49
1294 #define SCANCODE_M 50
1295 #define SCANCODE_COMMA 51
1296 #define SCANCODE_PERIOD 52
1297  #define SCANCODE_DOT SCANCODE_PERIOD
1298 #define SCANCODE_SLASH 53
1299 #define SCANCODE_RIGHTSHIFT 54
1300 #define SCANCODE_KEYPADMULTIPLY 55
1301  #define SCANCODE_KPASTERISK SCANCODE_KEYPADMULTIPLY
1302 #define SCANCODE_LEFTALT 56
1303 #define SCANCODE_SPACE 57
1304 #define SCANCODE_CAPSLOCK 58
1305 
1306 #define SCANCODE_F1 59
1307 #define SCANCODE_F2 60
1308 #define SCANCODE_F3 61
1309 #define SCANCODE_F4 62
1310 #define SCANCODE_F5 63
1311 #define SCANCODE_F6 64
1312 #define SCANCODE_F7 65
1313 #define SCANCODE_F8 66
1314 #define SCANCODE_F9 67
1315 #define SCANCODE_F10 68
1316 
1317 #define SCANCODE_NUMLOCK 69
1318 #define SCANCODE_SCROLLLOCK 70
1319 
1320 #define SCANCODE_KEYPAD7 71
1321  #define SCANCODE_KP7 SCANCODE_KEYPAD7
1322 #define SCANCODE_CURSORUPLEFT 71
1323 #define SCANCODE_KEYPAD8 72
1324  #define SCANCODE_KP8 SCANCODE_KEYPAD8
1325 #define SCANCODE_CURSORUP 72
1326 #define SCANCODE_KEYPAD9 73
1327  #define SCANCODE_KP9 SCANCODE_KEYPAD9
1328 #define SCANCODE_CURSORUPRIGHT 73
1329 #define SCANCODE_KEYPADMINUS 74
1330  #define SCANCODE_KPMINUS SCANCODE_KEYPADMINUS
1331 #define SCANCODE_KEYPAD4 75
1332  #define SCANCODE_KP4 SCANCODE_KEYPAD4
1333 #define SCANCODE_CURSORLEFT 75
1334 #define SCANCODE_KEYPAD5 76
1335  #define SCANCODE_KP5 SCANCODE_KEYPAD5
1336 #define SCANCODE_KEYPAD6 77
1337  #define SCANCODE_KP6 SCANCODE_KEYPAD6
1338 #define SCANCODE_CURSORRIGHT 77
1339 #define SCANCODE_KEYPADPLUS 78
1340  #define SCANCODE_KPPLUS SCANCODE_KEYPADPLUS
1341 #define SCANCODE_KEYPAD1 79
1342  #define SCANCODE_KP1 SCANCODE_KEYPAD1
1343 #define SCANCODE_CURSORDOWNLEFT 79
1344 #define SCANCODE_KEYPAD2 80
1345  #define SCANCODE_KP2 SCANCODE_KEYPAD2
1346 #define SCANCODE_CURSORDOWN 80
1347 #define SCANCODE_KEYPAD3 81
1348  #define SCANCODE_KP3 SCANCODE_KEYPAD3
1349 #define SCANCODE_CURSORDOWNRIGHT 81
1350 #define SCANCODE_KEYPAD0 82
1351  #define SCANCODE_KP0 SCANCODE_KEYPAD0
1352 #define SCANCODE_KEYPADPERIOD 83
1353  #define SCANCODE_KPDOT SCANCODE_KEYPADPERIOD
1354 
1355 #define SCANCODE_ZENKAKUHANKAKU 85
1356 
1357 #define SCANCODE_LESS 86
1358 #define SCANCODE_102ND SCANCODE_LESS
1359 
1360 #define SCANCODE_F11 87
1361 #define SCANCODE_F12 88
1362 
1363 #define SCANCODE_RO 89
1364 #define SCANCODE_KATAKANA 90
1365 #define SCANCODE_HIRAGANA 91
1366 #define SCANCODE_HENKAN 92
1367 #define SCANCODE_KATAKANAHIRAGANA 93
1368 #define SCANCODE_MUHENKAN 94
1369 #define SCANCODE_KPJPCOMMA 95
1370 
1371 #define SCANCODE_KEYPADENTER 96
1372  #define SCANCODE_KPENTER SCANCODE_KEYPADENTER
1373 #define SCANCODE_RIGHTCONTROL 97
1374  #define SCANCODE_RIGHTCTRL SCANCODE_RIGHTCONTROL
1375 #define SCANCODE_CONTROL 97
1376 #define SCANCODE_KEYPADDIVIDE 98
1377  #define SCANCODE_KPSLASH SCANCODE_KEYPADDIVIDE
1378 #define SCANCODE_PRINTSCREEN 99
1379  #define SCANCODE_SYSRQ SCANCODE_PRINTSCREEN
1380 #define SCANCODE_RIGHTALT 100
1381 #define SCANCODE_LINEFEED 101
1382 
1383 #define SCANCODE_HOME 102
1384 #define SCANCODE_CURSORBLOCKUP 103 /* Cursor key block */
1385  #define SCANCODE_UP SCANCODE_CURSORBLOCKUP
1386 #define SCANCODE_PAGEUP 104
1387 #define SCANCODE_CURSORBLOCKLEFT 105 /* Cursor key block */
1388  #define SCANCODE_LEFT SCANCODE_CURSORBLOCKLEFT
1389 #define SCANCODE_CURSORBLOCKRIGHT 106 /* Cursor key block */
1390  #define SCANCODE_RIGHT SCANCODE_CURSORBLOCKRIGHT
1391 #define SCANCODE_END 107
1392 #define SCANCODE_CURSORBLOCKDOWN 108 /* Cursor key block */
1393  #define SCANCODE_DOWN SCANCODE_CURSORBLOCKDOWN
1394 #define SCANCODE_PAGEDOWN 109
1395 #define SCANCODE_INSERT 110
1396 #define SCANCODE_REMOVE 111
1397  #define SCANCODE_DELETE SCANCODE_REMOVE
1398 
1399 #define SCANCODE_MACRO 112
1400 #define SCANCODE_MUTE 113
1401 #define SCANCODE_VOLUMEDOWN 114
1402 #define SCANCODE_VOLUMEUP 115
1403 #define SCANCODE_POWER 116 /* SC System Power Down */
1404 #define SCANCODE_KPEQUAL 117
1405 #define SCANCODE_KPPLUSMINUS 118
1406 #define SCANCODE_BREAK 119
1407  #define SCANCODE_BREAK_ALTERNATIVE SCANCODE_BREAK
1408  #define SCANCODE_PAUSE SCANCODE_BREAK
1409 
1410 #define SCANCODE_SCALE 120 /* AL Compiz Scale (Expose) */
1411 #define SCANCODE_KPCOMMA 121
1412 #define SCANCODE_HANGEUL 122
1413 #define SCANCODE_HANJA 123
1414 #define SCANCODE_YEN 124
1415 #define SCANCODE_LEFTWIN 125
1416  #define SCANCODE_LEFTMETA SCANCODE_LEFTWIN
1417 #define SCANCODE_RIGHTWIN 126
1418  #define SCANCODE_RIGHTMETA SCANCODE_RIGHTWIN
1419 #define SCANCODE_COMPOSE 127
1420 #define SCANCODE_STOP 128 /* AC Stop */
1421 #define SCANCODE_AGAIN 129
1422 #define SCANCODE_PROPS 130 /* AC Properties */
1423 #define SCANCODE_UNDO 131 /* AC Undo */
1424 #define SCANCODE_FRONT 132
1425 #define SCANCODE_COPY 133 /* AC Copy */
1426 #define SCANCODE_OPEN 134 /* AC Open */
1427 #define SCANCODE_PASTE 135 /* AC Paste */
1428 #define SCANCODE_FIND 136 /* AC Search */
1429 #define SCANCODE_CUT 137 /* AC Cut */
1430 #define SCANCODE_HELP 138 /* AL Integrated Help Center */
1431 #define SCANCODE_MENU 139 /* Menu (show menu) */
1432 #define SCANCODE_CALC 140 /* AL Calculator */
1433 #define SCANCODE_SETUP 141
1434 #define SCANCODE_SLEEP 142 /* SC System Sleep */
1435 #define SCANCODE_WAKEUP 143 /* System Wake Up */
1436 #define SCANCODE_FILE 144 /* AL Local Machine Browser */
1437 #define SCANCODE_SENDFILE 145
1438 #define SCANCODE_DELETEFILE 146
1439 #define SCANCODE_XFER 147
1440 #define SCANCODE_PROG1 148
1441 #define SCANCODE_PROG2 149
1442 #define SCANCODE_WWW 150 /* AL Internet Browser */
1443 #define SCANCODE_MSDOS 151
1444 #define SCANCODE_COFFEE 152 /* AL Terminal Lock/Screensaver */
1445  #define SCANCODE_SCREENLOCK SCANCODE_COFFEE
1446 #define SCANCODE_ROTATE_DISPLAY 153 /* Display orientation for e.g. tablets */
1447  #define SCANCODE_DIRECTION SCANCODE_ROTATE_DISPLAY
1448 #define SCANCODE_CYCLEWINDOWS 154
1449 #define SCANCODE_MAIL 155
1450 #define SCANCODE_BOOKMARKS 156 /* AC Bookmarks */
1451 #define SCANCODE_COMPUTER 157
1452 #define SCANCODE_BACK 158 /* AC Back */
1453 #define SCANCODE_FORWARD 159 /* AC Forward */
1454 #define SCANCODE_CLOSECD 160
1455 #define SCANCODE_EJECTCD 161
1456 #define SCANCODE_EJECTCLOSECD 162
1457 #define SCANCODE_NEXTSONG 163
1458 #define SCANCODE_PLAYPAUSE 164
1459 #define SCANCODE_PREVIOUSSONG 165
1460 #define SCANCODE_STOPCD 166
1461 #define SCANCODE_RECORD 167
1462 #define SCANCODE_REWIND 168
1463 #define SCANCODE_PHONE 169 /* Media Select Telephone */
1464 #define SCANCODE_ISO 170
1465 #define SCANCODE_CONFIG 171 /* AL Consumer Control Configuration */
1466 #define SCANCODE_HOMEPAGE 172 /* AC Home */
1467 #define SCANCODE_REFRESH 173 /* AC Refresh */
1468 #define SCANCODE_EXIT 174 /* AC Exit */
1469 #define SCANCODE_MOVE 175
1470 #define SCANCODE_EDIT 176
1471 #define SCANCODE_SCROLLUP 177
1472 #define SCANCODE_SCROLLDOWN 178
1473 #define SCANCODE_KPLEFTPAREN 179
1474 #define SCANCODE_KPRIGHTPAREN 180
1475 #define SCANCODE_NEW 181 /* AC New */
1476 #define SCANCODE_REDO 182 /* AC Redo/Repeat */
1477 #define SCANCODE_F13 183
1478 #define SCANCODE_F14 184
1479 #define SCANCODE_F15 185
1480 #define SCANCODE_F16 186
1481 #define SCANCODE_F17 187
1482 #define SCANCODE_F18 188
1483 #define SCANCODE_F19 189
1484 #define SCANCODE_F20 190
1485 #define SCANCODE_F21 191
1486 #define SCANCODE_F22 192
1487 #define SCANCODE_F23 193
1488 #define SCANCODE_F24 194
1489 
1490 #define SCANCODE_PLAYCD 200
1491 #define SCANCODE_PAUSECD 201
1492 #define SCANCODE_PROG3 202
1493 #define SCANCODE_PROG4 203
1494 #define SCANCODE_DASHBOARD 204 /* AL Dashboard */
1495 #define SCANCODE_SUSPEND 205
1496 #define SCANCODE_CLOSE 206 /* AC Close */
1497 #define SCANCODE_PLAY 207
1498 #define SCANCODE_FASTFORWARD 208
1499 #define SCANCODE_BASSBOOST 209
1500 #define SCANCODE_PRINT 210 /* AC Print */
1501 #define SCANCODE_HP 211
1502 #define SCANCODE_CAMERA 212
1503 #define SCANCODE_SOUND 213
1504 #define SCANCODE_QUESTION 214
1505 #define SCANCODE_EMAIL 215
1506 #define SCANCODE_CHAT 216
1507 #define SCANCODE_SEARCH 217
1508 #define SCANCODE_CONNECT 218
1509 #define SCANCODE_FINANCE 219 /* AL Checkbook/Finance */
1510 #define SCANCODE_SPORT 220
1511 #define SCANCODE_SHOP 221
1512 #define SCANCODE_ALTERASE 222
1513 #define SCANCODE_CANCEL 223 /* AC Cancel */
1514 #define SCANCODE_BRIGHTNESSDOWN 224
1515 #define SCANCODE_BRIGHTNESSUP 225
1516 #define SCANCODE_MEDIA 226
1517 #define SCANCODE_SWITCHVIDEOMODE 227 /* Cycle between available video outputs (Monitor/LCD/TV-out/etc) */
1518 #define SCANCODE_KBDILLUMTOGGLE 228
1519 #define SCANCODE_KBDILLUMDOWN 229
1520 #define SCANCODE_KBDILLUMUP 230
1521 #define SCANCODE_SEND 231 /* AC Send */
1522 #define SCANCODE_REPLY 232 /* AC Reply */
1523 #define SCANCODE_FORWARDMAIL 233 /* AC Forward Msg */
1524 #define SCANCODE_SAVE 234 /* AC Save */
1525 #define SCANCODE_DOCUMENTS 235
1526 #define SCANCODE_BATTERY 236
1527 #define SCANCODE_BLUETOOTH 237
1528 #define SCANCODE_WLAN 238
1529 #define SCANCODE_UWB 239
1530 #define SCANCODE_UNKNOWN 240
1531 #define SCANCODE_VIDEO_NEXT 241 /* drive next video source */
1532 #define SCANCODE_VIDEO_PREV 242 /* drive previous video source */
1533 #define SCANCODE_BRIGHTNESS_CYCLE 243 /* brightness up, after max is min */
1534 #define SCANCODE_BRIGHTNESS_AUTO 244 /* Set Auto Brightness: manual brightness control is off, rely on ambient */
1535  #define SCANCODE_BRIGHTNESS_ZERO SCANCODE_BRIGHTNESS_AUTO
1536 #define SCANCODE_DISPLAY_OFF 245 /* display device to off state */
1537 #define SCANCODE_WWAN 246 /* Wireless WAN (LTE, UMTS, GSM, etc.) */
1538  #define SCANCODE_WIMAX SCANCODE_WWAN
1539 #define SCANCODE_RFKILL 247 /* Key that controls all radios */
1540 #define SCANCODE_MICMUTE 248 /* Mute / unmute the microphone */
1541 
1542 #define SCANCODE_LEFTBUTTON 0x1000
1543 #define SCANCODE_RIGHTBUTTON 0x2000
1544 #define SCANCODE_MIDDLBUTTON 0x4000
1545 
1555 #define KS_LEFTMETA 0x00002000
1556 
1566 #define KS_RIGHTMETA 0x00001000
1567 
1577 #define KS_META 0x00003000
1578 
1599 #define KS_REPEATED 0x00000800
1600 
1621 #define KS_CAPTURED 0x00000400
1622 
1629 #define KS_IMEPOST 0x00000200
1630 
1651 #define KS_CAPSLOCK 0x00000100
1652 
1660 #define KS_NUMLOCK 0x00000080
1661 
1669 #define KS_SCROLLLOCK 0x00000040
1670 
1678 #define KS_LEFTCTRL 0x00000020
1679 
1687 #define KS_RIGHTCTRL 0x00000010
1688 
1697 #define KS_CTRL 0x00000030
1698 
1706 #define KS_LEFTALT 0x00000008
1707 
1715 #define KS_RIGHTALT 0x00000004
1716 
1724 #define KS_ALT 0x0000000C
1725 
1733 #define KS_LEFTSHIFT 0x00000002
1734 
1742 #define KS_RIGHTSHIFT 0x00000001
1743 
1752 #define KS_SHIFT 0x00000003
1753 
1758 #define MASK_KS_SHIFTKEYS 0x0000FFFF
1759 
1767 #define KS_LEFTBUTTON 0x00010000
1768 
1776 #define KS_RIGHTBUTTON 0x00020000
1777 
1785 #define KS_MIDDLEBUTTON 0x00040000
1786 
1791 #define MASK_KS_BUTTONS 0x000F0000
1792 
1803 #define ERR_OK 0
1804 
1809 #define ERR_QUEUE_FULL -1
1810 
1815 #define ERR_INVALID_HANDLE -2
1816 
1821 #define ERR_INV_HWND ERR_INVALID_HANDLE
1822 
1827 #define ERR_INVALID_HMENU ERR_INVALID_HANDLE
1828 
1833 #define ERR_MSG_CANCELED -3
1834 
1839 #define ERR_INVALID_POS -5
1840 
1845 #define ERR_INVALID_ID -6
1846 
1851 #define ERR_RES_ALLOCATION -7
1852 
1857 #define ERR_CTRLCLASS_INVNAME -8
1858 
1863 #define ERR_CTRLCLASS_INVLEN -9
1864 
1869 #define ERR_CTRLCLASS_MEM -10
1870 
1875 #define ERR_CTRLCLASS_INUSE -11
1876 
1881 #define ERR_ALREADY_EXIST -12
1882 
1887 #define ERR_NO_MATCH -13
1888 
1893 #define ERR_BAD_OWNER -14
1894 
1899 #define ERR_IME_TOOMUCHIMEWND -15
1900 
1905 #define ERR_IME_NOSUCHIMEWND -16
1906 
1911 #define ERR_IME_NOIMEWND -17
1912 
1917 #define ERR_CONFIG_FILE -18
1918 
1923 #define ERR_FILE_IO -19
1924 
1929 #define ERR_GFX_ENGINE -20
1930 
1935 #define ERR_INPUT_ENGINE -21
1936 
1941 #define ERR_NO_ENGINE -22
1942 
1947 #define ERR_INVALID_ARGS -23
1948 
1959 #define TABLESIZE(table) (sizeof(table)/sizeof(table[0]))
1960 
1961 /* MAX/MIN/ABS macors */
1966 #ifndef MAX
1967 #define MAX(x, y) (((x) > (y))?(x):(y))
1968 #endif
1969 
1973 #ifndef MIN
1974 #define MIN(x, y) (((x) < (y))?(x):(y))
1975 #endif
1976 
1980 #ifndef ABS
1981 #define ABS(x) (((x)<0) ? -(x) : (x))
1982 #endif
1983 
1984 /* Commonly used definitions */
1985 #ifdef HAVE_LIMITS_H
1986 #include <limits.h>
1987 #endif
1988 
1989 #ifndef PATH_MAX
1990 # define PATH_MAX 256
1991 #endif
1992 
1993 #ifndef NAME_MAX
1994 # define NAME_MAX 64
1995 #endif
1996 
1997 
2003 #ifndef MAX_PATH
2004 # define MAX_PATH PATH_MAX
2005 #endif
2006 
2012 #ifndef MAX_NAME
2013 # define MAX_NAME NAME_MAX
2014 #endif
2015 
2020 #ifdef HAVE_TIME
2021 #include <time.h>
2022 #else
2023 typedef unsigned long time_t;
2024 
2025 struct tm {
2026  int tm_sec; /* seconds [0,61] */
2027  int tm_min; /* minutes [0,59] */
2028  int tm_hour; /* hour [0,23] */
2029  int tm_mday; /* day of month [1,31] */
2030  int tm_mon; /* month of year [0,11] */
2031  int tm_year; /* years since 1900 */
2032  int tm_wday; /* day of week [0,6] (Sunday = 0) */
2033  int tm_yday; /* day of year [0,365] */
2034  int tm_isdst; /* daylight savings flag */
2035 };
2036 #endif
2037 
2038 #ifdef __cplusplus
2039 extern "C" {
2040 #endif
2041 
2042 #if defined (__THREADX__) && defined (__TARGET_VFANVIL__)
2043 #include "fx_api.h"
2044 #include "tx_api.h"
2045 #include "os_type.h"
2046 #include "os_file_api.h"
2047 
2048 #define fopen tp_fopen
2049 #define fclose tp_fclose
2050 #define fwrite tp_fwrite
2051 #define fread tp_fread
2052 #define fseek tp_fseek
2053 #define feof tp_feof
2054 
2055 #undef assert
2056 #define _HAVE_ASSERT 1
2057 
2058 #define assert(e) \
2059  do { \
2060  e; \
2061  } while (0)
2062 
2063 #undef stdin
2064 #undef stdout
2065 #undef stderr
2066 
2067 #define stdin ((FILE*)0)
2068 #define stdout ((FILE*)1)
2069 #define stderr ((FILE*)2)
2070 void Comm_Lock_Screen (void);
2071 void Comm_Unlock_Screen (void);
2072 
2073 #endif
2074 
2075 #ifdef __UCOSII__
2076 
2077 /* use our own implementation of strdup */
2078 #undef HAVE_STRDUP
2079 #undef strdup
2080 #define strdup own_strdup
2081 
2082 #endif /* __UCOSII__ */
2083 
2084 #ifndef HAVE_STRDUP
2085 MG_EXPORT char *strdup(const char *s);
2086 #endif
2087 
2088 #ifndef HAVE_STRCASECMP
2089 MG_EXPORT int strcasecmp(const char *s1, const char *s2);
2090 #endif
2091 
2092 #ifndef HAVE_STRNCASECMP
2093 MG_EXPORT int strncasecmp(const char *s1, const char *s2, unsigned int n);
2094 #endif
2095 
2096 #ifdef _MGUSE_OWN_MALLOC
2097 
2120 int init_minigui_malloc (unsigned char* heap, unsigned int heap_size,
2121  int (*lock_heap) (void), int (*unlock_heap) (void));
2122 
2123 #define USE_DL_PREFIX
2124 
2125 #include "own_malloc.h"
2126 
2127 /* wrappers for malloc functions */
2128 #define calloc dlcalloc
2129 #define free dlfree
2130 #define malloc dlmalloc
2131 #define memalign dlmemalign
2132 #define realloc dlrealloc
2133 #define valloc dlvalloc
2134 
2135 #endif
2136 
2137 /* Do not use the alloca of ARMCC */
2138 #if defined(__CC_ARM)
2139 # undef HAVE_ALLOCA
2140 # undef HAVE_ALLOCA_H
2141 #endif
2142 
2143 #ifdef HAVE_ALLOCA_H
2144 # include <alloca.h>
2145 # define ALLOCATE_LOCAL(size) alloca((int)(size))
2146 # define DEALLOCATE_LOCAL(ptr) /* as nothing */
2147 #else
2148 # define ALLOCATE_LOCAL(size) malloc((int)(size))
2149 # define DEALLOCATE_LOCAL(ptr) free(ptr)
2150 #endif
2151 
2152 #ifdef _MGUSE_OWN_STDIO
2153 
2166 int init_minigui_printf (int (*output_char) (int ch),
2167  int (*input_char) (void));
2168 
2169 #if defined (__UCOSII__) || defined (__VXWORKS__) || defined (__NUCLEUS__) || defined (__PSOS__)
2170 # undef _PRINTF_FLOATING_POINT
2171 # undef _SCANF_FLOATING_POINT
2172 #else
2173 # ifdef HAVE_MATH_H
2174 # define _PRINTF_FLOATING_POINT 1
2175 # define _SCANF_FLOATING_POINT 1
2176 # endif
2177 #endif
2178 
2179 #ifdef WIN32
2180 # include <float.h>
2181 # define isnan _isnan
2182 # define finite _finite
2183 #endif
2184 
2185 #undef _I18N_MB_REQUIRED
2186 
2187 #if defined(__VXWORKS__) || defined(WIN32) || defined (__NUCLEUS_MNT__) || defined (__PSOS__)
2188  #define _MGUSE_OWN_SNPRINTF
2189  #define _MGUSE_OWN_VSNPRINTF
2190  #define _MGUSE_OWN_VFNPRINTF
2191 #else
2192  #define _MGUSE_OWN_PRINTF
2193  #define _MGUSE_OWN_FPRINTF
2194  #define _MGUSE_OWN_SPRINTF
2195  #define _MGUSE_OWN_FNPRINTF
2196  #define _MGUSE_OWN_SNPRINTF
2197  #define _MGUSE_OWN_VPRINTF
2198  #define _MGUSE_OWN_VFPRINTF
2199  #define _MGUSE_OWN_VSPRINTF
2200  #define _MGUSE_OWN_VFNPRINTF
2201  #define _MGUSE_OWN_VSNPRINTF
2202  #define _MGUSE_OWN_SCANF
2203  #define _MGUSE_OWN_FSCANF
2204  #define _MGUSE_OWN_SSCANF
2205  #define _MGUSE_OWN_VSCANF
2206  #define _MGUSE_OWN_VFSCANF
2207  #define _MGUSE_OWN_VSSCANF
2208 #endif
2209 
2210 #include "own_stdio.h"
2211 
2212 /* wrappers for stdio functions */
2213 #ifdef _MGUSE_OWN_PRINTF
2214  #define printf own_printf
2215 #endif
2216 
2217 #ifdef _MGUSE_OWN_FPRINTF
2218  #define fprintf own_fprintf
2219 #endif
2220 
2221 #ifdef _MGUSE_OWN_SPRINTF
2222  #define sprintf own_sprintf
2223 #endif
2224 
2225 #ifdef _MGUSE_OWN_FNPRINTF
2226  #define fnprintf own_fnprintf
2227 #endif
2228 
2229 #ifdef _MGUSE_OWN_SNPRINTF
2230  #define snprintf own_snprintf
2231 #endif
2232 
2233 #ifdef _MGUSE_OWN_VPRINTF
2234  #define vprintf own_vprintf
2235 #endif
2236 
2237 #ifdef _MGUSE_OWN_VFPRINTF
2238  #define vfprintf own_vfprintf
2239 #endif
2240 
2241 #ifdef _MGUSE_OWN_VSPRINTF
2242  #define vsprintf own_vsprintf
2243 #endif
2244 
2245 #ifdef _MGUSE_OWN_VFNPRINTF
2246  #define vfnprintf own_vfnprintf
2247 #endif
2248 
2249 #ifdef _MGUSE_OWN_VSNPRINTF
2250  #define vsnprintf own_vsnprintf
2251 #endif
2252 
2253 #ifdef _MGUSE_OWN_SCANF
2254  #define scanf own_scanf
2255 #endif
2256 
2257 #ifdef _MGUSE_OWN_FSCANF
2258  #define fscanf own_fscanf
2259 #endif
2260 
2261 #ifdef _MGUSE_OWN_SSCANF
2262  #define sscanf own_sscanf
2263 #endif
2264 
2265 #ifdef _MGUSE_OWN_VSCANF
2266  #define vscanf own_vscanf
2267 #endif
2268 
2269 #ifdef _MGUSE_OWN_VFSCANF
2270  #define vfscanf own_vfscanf
2271 #endif
2272 
2273 #ifdef _MGUSE_OWN_VSSCANF
2274  #define vsscanf own_vsscanf
2275 #endif
2276 
2277 #endif /* _MGUSE_OWN_STDIO */
2278 
2279 #ifdef __LINUX__
2280  #define TCS_NONE(fp) fprintf (fp, "\e[0m")
2281  #define TCS_BLACK(fp) fprintf (fp, "\e[0;30m")
2282  #define TCS_BOLD_BLACK(fp) fprintf (fp, "\e[1;30m")
2283  #define TCS_RED(fp) fprintf (fp, "\e[0;31m")
2284  #define TCS_BOLD_RED(fp) fprintf (fp, "\e[1;31m")
2285  #define TCS_GREEN(fp) fprintf (fp, "\e[0;32m")
2286  #define TCS_BOLD_GREEN(fp) fprintf (fp, "\e[1;32m")
2287  #define TCS_BROWN(fp) fprintf (fp, "\e[0;33m")
2288  #define TCS_YELLOW(fp) fprintf (fp, "\e[1;33m")
2289  #define TCS_BLUE(fp) fprintf (fp, "\e[0;34m")
2290  #define TCS_BOLD_BLUE(fp) fprintf (fp, "\e[1;34m")
2291  #define TCS_PURPLE(fp) fprintf (fp, "\e[0;35m")
2292  #define TCS_BOLD_PURPLE(fp) fprintf (fp, "\e[1;35m")
2293  #define TCS_CYAN(fp) fprintf (fp, "\e[0;36m")
2294  #define TCS_BOLD_CYAN(fp) fprintf (fp, "\e[1;36m")
2295  #define TCS_GRAY(fp) fprintf (fp, "\e[0;37m")
2296  #define TCS_WHITE(fp) fprintf (fp, "\e[1;37m")
2297  #define TCS_BOLD(fp) fprintf (fp, "\e[1m")
2298  #define TCS_UNDERLINE(fp) fprintf (fp, "\e[4m")
2299  #define TCS_BLINK(fp) fprintf (fp, "\e[5m")
2300  #define TCS_REVERSE(fp) fprintf (fp, "\e[7m")
2301  #define TCS_HIDE(fp) fprintf (fp, "\e[8m")
2302  #define TCS_CLEAR(fp) fprintf (fp, "\e[2J")
2303  #define TCS_CLRLINE(fp) fprintf (fp, "\e[1K\r")
2304 #else
2305  #define TCS_NONE(fp)
2306  #define TCS_BLACK(fp)
2307  #define TCS_BOLD_BLACK(fp)
2308  #define TCS_RED(fp)
2309  #define TCS_BOLD_RED(fp)
2310  #define TCS_GREEN(fp)
2311  #define TCS_BOLD_GREEN(fp)
2312  #define TCS_BROWN(fp)
2313  #define TCS_YELLOW(fp)
2314  #define TCS_BLUE(fp)
2315  #define TCS_BOLD_BLUE(fp)
2316  #define TCS_PURPLE(fp)
2317  #define TCS_BOLD_PURPLE(fp)
2318  #define TCS_CYAN(fp)
2319  #define TCS_BOLD_CYAN(fp)
2320  #define TCS_GRAY(fp)
2321  #define TCS_WHITE(fp)
2322  #define TCS_BOLD(fp)
2323  #define TCS_UNDERLINE(fp)
2324  #define TCS_BLINK(fp)
2325  #define TCS_REVERSE(fp)
2326  #define TCS_HIDE(fp)
2327  #define TCS_CLEAR(fp)
2328  #define TCS_CLRLINE(fp)
2329 #endif
2330 
2331 #define _MG_PRINTF(fmt, ...) \
2332  do { \
2333  TCS_GREEN (stdout); \
2334  fprintf (stdout, fmt, ##__VA_ARGS__); \
2335  TCS_NONE (stdout); \
2336  } while (0)
2337 
2338 #define _WRN_PRINTF(fmt, ...) \
2339  do { \
2340  TCS_BROWN (stderr); \
2341  fprintf (stderr, "%s: ", __FUNCTION__); \
2342  fprintf (stderr, fmt, ##__VA_ARGS__); \
2343  TCS_NONE (stderr); \
2344  } while (0)
2345 
2346 #define _ERR_PRINTF(fmt, ...) \
2347  do { \
2348  TCS_RED (stderr); \
2349  fprintf (stderr, fmt, ##__VA_ARGS__); \
2350  TCS_NONE (stderr); \
2351  } while (0)
2352 
2353 #if defined(_DEBUG)
2354 # define _DBG_PRINTF(fmt, ...) \
2355  do { \
2356  TCS_YELLOW (stderr); \
2357  fprintf (stderr, "%s: ", __FUNCTION__); \
2358  fprintf (stderr, fmt, ##__VA_ARGS__); \
2359  TCS_NONE (stderr); \
2360  } while (0)
2361 # else
2362 # define _DBG_PRINTF(fmt, ...) do { } while (0)
2363 #endif
2364 
2365 #ifdef _MGRM_THREADS
2366 
2367 #ifdef _MGUSE_OWN_PTHREAD
2368 
2369 #define MAIN_PTH_MIN_STACK_SIZE (1024)
2370 #define MAIN_PTH_DEF_STACK_SIZE (1024*4)
2371 
2396 int start_minigui_pthread (int (* pth_entry) (int argc, const char* argv []),
2397  int argc, const char* argv[],
2398  char* stack_base, unsigned int stack_size);
2399 
2400 #ifndef ESRCH
2401 # define ESRCH 3
2402 #endif
2403 
2404 #ifndef EAGAIN
2405 # define EAGAIN 11
2406 #endif
2407 
2408 #ifndef ENOMEM
2409 # define ENOMEM 12
2410 #endif
2411 
2412 #ifndef EBUSY
2413 # define EBUSY 16
2414 #endif
2415 
2416 #ifndef EINVAL
2417 # define EINVAL 22
2418 #endif
2419 
2420 #ifndef EDEADLK
2421 # define EDEADLK 35
2422 #endif
2423 
2424 #ifndef ENOSYS
2425 # define ENOSYS 38
2426 #endif
2427 
2428 #ifndef ENOTSUP
2429 # define ENOTSUP 95
2430 #endif
2431 
2432 #ifdef __VXWORKS__
2433 
2434 #define pthread_create vxworks_pthread_create
2435 #define pthread_self vxworks_pthread_self
2436 #define pthread_equal vxworks_pthread_equal
2437 #define pthread_exit vxworks_pthread_exit
2438 #define pthread_join vxworks_pthread_join
2439 #define pthread_detach vxworks_pthread_detach
2440 #define pthread_cancel vxworks_pthread_cancel
2441 #define pthread_once vxworks_pthread_once
2442 #define pthread_key_create vxworks_pthread_key_create
2443 #define pthread_key_delete vxworks_pthread_key_delete
2444 #define pthread_setspecific vxworks_pthread_setspecific
2445 #define pthread_getspecific vxworks_pthread_getspecific
2446 #define pthread_setcancelstate vxworks_pthread_setcancelstate
2447 #define pthread_setcanceltype vxworks_pthread_setcanceltype
2448 #define pthread_testcancel vxworks_pthread_testcancel
2449 
2450 #define pthread_attr_init vxworks_pthread_attr_init
2451 #define pthread_attr_destroy vxworks_pthread_attr_destroy
2452 #define pthread_attr_setdetachstate vxworks_pthread_attr_setdetachstate
2453 #define pthread_attr_getdetachstate vxworks_pthread_attr_getdetachstate
2454 #define pthread_attr_setscope vxworks_pthread_attr_setscope
2455 #define pthread_attr_getscope vxworks_pthread_attr_getscope
2456 #define pthread_attr_setinheritsched vxworks_pthread_attr_setinheritsched
2457 #define pthread_attr_getinheritsched vxworks_pthread_attr_getinheritsched
2458 #define pthread_attr_setschedpolicy vxworks_pthread_attr_setschedpolicy
2459 #define pthread_attr_getschedpolicy vxworks_pthread_attr_getschedpolicy
2460 #define pthread_attr_setschedparam vxworks_pthread_attr_setschedparam
2461 #define pthread_attr_getschedparam vxworks_pthread_attr_getschedparam
2462 #define pthread_attr_setstackaddr vxworks_pthread_attr_setstackaddr
2463 #define pthread_attr_getstackaddr vxworks_pthread_attr_getstackaddr
2464 #define pthread_attr_setstacksize vxworks_pthread_attr_setstacksize
2465 #define pthread_attr_getstacksize vxworks_pthread_attr_getstacksize
2466 #define pthread_setschedparam vxworks_pthread_setschedparam
2467 #define pthread_getschedparam vxworks_pthread_getschedparam
2468 
2469 #define pthread_mutex_init vxworks_pthread_mutex_init
2470 #define pthread_mutex_destroy vxworks_pthread_mutex_destroy
2471 #define pthread_mutex_lock vxworks_pthread_mutex_lock
2472 #define pthread_mutex_unlock vxworks_pthread_mutex_unlock
2473 #define pthread_mutex_trylock vxworks_pthread_mutex_trylock
2474 #define pthread_mutexattr_init vxworks_pthread_mutexattr_init
2475 #define pthread_mutexattr_destroy vxworks_pthread_mutexattr_destroy
2476 #define pthread_mutexattr_setpriorityinherit vxworks_pthread_mutexattr_setpriorityinherit
2477 #define pthread_mutexattr_getpriorityinherit vxworks_pthread_mutexattr_getpriorityinherit
2478 
2479 #ifdef _MGUSE_OWN_SEMAPHORE
2480 
2481 #define sem_t vxworks_sem_t
2482 
2483 #define sem_init vxworks_sem_init
2484 #define sem_destroy vxworks_sem_destroy
2485 #define sem_wait vxworks_sem_wait
2486 #define sem_trywait vxworks_sem_trywait
2487 #define sem_post vxworks_sem_post
2488 #define sem_getvalue vxworks_sem_getvalue
2489 
2490 #endif /* _MGUSE_OWN_SEMAPHORE */
2491 
2492 #endif /* __VXWORKS__ */
2493 
2494 #ifdef __MINIGUI_LIB__
2495 
2496 #ifdef __UCOSII__
2497 # include "ucos2_pthread.h"
2498 # include "ucos2_semaphore.h"
2499 #elif defined (__THREADX__)
2500 # include "threadx_pthread.h"
2501 # include "threadx_semaphore.h"
2502 #elif defined (__NUCLEUS__)
2503 # include "nucleus_pthread.h"
2504 # include "nucleus_semaphore.h"
2505 #elif defined (__VXWORKS__)
2506 # include "vxworks_pthread.h"
2507 # ifdef _MGUSE_OWN_SEMAPHORE
2508 # include "vxworks_semaphore.h"
2509 # else
2510 # include "semaphore.h"
2511 # endif
2512 #elif defined (__OSE__)
2513 # include "pthread.h"
2514 # include "ose_semaphore.h"
2515 #elif defined (__PSOS__)
2516 # include "psos_pthread.h"
2517 # include "psos_semaphore.h"
2518 #elif defined (WIN32)
2519 # include "win32_pthread.h"
2520 # include "win32_semaphore.h"
2521 #else
2522 # error No own pthread implementation for this OS!
2523 #endif
2524 
2525 #else
2526 
2527 # include <pthread.h>
2528 # include <semaphore.h>
2529 
2530 #endif /* __MINIGUI_LIB__ */
2531 
2532 #else /* _MGUSE_OWN_PTHREAD */
2533 
2534 #include <pthread.h>
2535 #include <semaphore.h>
2536 
2537 #endif /* !_MGUSE_OWN_PTHREAD */
2538 
2539 #ifdef __DARWIN__
2540 
2541 #define _USE_SEM_ON_SYSVIPC 1
2542 
2543 #endif
2544 
2545 #if defined (_USE_MUTEX_ON_SYSVIPC) || defined (_USE_SEM_ON_SYSVIPC)
2546 
2547 int _sysvipc_mutex_sem_init (void);
2548 int _sysvipc_mutex_sem_term (void);
2549 
2550 #endif
2551 
2552 #ifdef _USE_MUTEX_ON_SYSVIPC
2553 
2554 #define pthread_mutex_t _sysvipc_pthread_mutex_t
2555 #define pthread_mutexattr_t _sysvipc_pthread_mutexattr_t
2556 
2557 #define pthread_mutexattr_init _sysvipc_pthread_mutexattr_init
2558 #define pthread_mutexattr_destroy _sysvipc_pthread_mutexattr_destroy
2559 #define pthread_mutexattr_settype _sysvipc_pthread_mutexattr_settype
2560 #define pthread_mutexattr_gettype _sysvipc_pthread_mutexattr_gettype
2561 
2562 #define pthread_init _sysvipc_pthread_init
2563 #define pthread_mutex_init _sysvipc_pthread_mutex_init
2564 #define pthread_mutex_destroy _sysvipc_pthread_mutex_destroy
2565 #define pthread_mutex_lock _sysvipc_pthread_mutex_lock
2566 #define pthread_mutex_trylock _sysvipc_pthread_mutex_trylock
2567 #define pthread_mutex_unlock _sysvipc_pthread_mutex_unlock
2568 
2569 typedef struct
2570 {
2571  int kind;
2572  int semid;
2573  int sem_num;
2574  int locked_times;
2575 } pthread_mutex_t;
2576 
2577 #define SYSVIPC_PTHREAD_MUTEX_FAST_NP 0
2578 #define SYSVIPC_PTHREAD_MUTEX_RECURSIVE_NP 1
2579 #define SYSVIPC_PTHREAD_MUTEX_ERRORCHECK_NP 2
2580 
2581 typedef struct
2582 {
2583  int kind;
2584 } pthread_mutexattr_t;
2585 
2586 int pthread_mutexattr_init (pthread_mutexattr_t *attr);
2587 int pthread_mutexattr_destroy (pthread_mutexattr_t *attr);
2588 int pthread_mutexattr_settype (pthread_mutexattr_t *attr, int type);
2589 int pthread_mutexattr_gettype (const pthread_mutexattr_t *attr, int* type);
2590 
2591 int pthread_mutex_init (pthread_mutex_t *mutex,
2592  const pthread_mutexattr_t *mutex_attr);
2593 
2594 int pthread_mutex_destroy (pthread_mutex_t *mutex);
2595 
2596 int pthread_mutex_lock (pthread_mutex_t *mutex);
2597 int pthread_mutex_trylock (pthread_mutex_t *mutex);
2598 int pthread_mutex_unlock (pthread_mutex_t *mutex);
2599 
2600 #endif /* _USE_MUTEX_ON_SYSVIPC */
2601 
2602 #ifdef _USE_SEM_ON_SYSVIPC
2603 
2604 #define sem_t _sysvipc_sem_t
2605 
2606 #define sem_init _sysvipc_sem_init
2607 #define sem_destroy _sysvipc_sem_destroy
2608 #define sem_wait _sysvipc_sem_wait
2609 #define sem_trywait _sysvipc_sem_trywait
2610 #define sem_post _sysvipc_sem_post
2611 #define sem_getvalue _sysvipc_sem_getvalue
2612 
2613 #define SYSVIPC_SEM_VALUE_MAX USHRT_MAX
2614 
2615 /*-----------------------------------------------------------------------------
2616 ** Semaphore object definition
2617 */
2618 
2619 typedef struct
2620 {
2621  int semid;
2622  int sem_num;
2623 } sem_t;
2624 
2625 int sem_init (sem_t *sem, int pshared, unsigned int value);
2626 int sem_destroy (sem_t *sem);
2627 int sem_wait (sem_t *sem);
2628 int sem_trywait (sem_t *sem);
2629 int sem_post (sem_t *sem);
2630 int sem_getvalue (sem_t *sem, int *sval);
2631 
2632 #endif /* _USE_SEM_ON_SYSVIPC */
2633 
2634 #endif /* _MGRM_THREADS */
2635 
2636 #ifdef __cplusplus
2637 } /* end of extern "C" */
2638 #endif
2639 
2640 #endif /* _MGUI_COMMON_H */
2641 
_POINT::y
int y
Definition: common.h:975
_POINT
Definition: common.h:966
_RECT::right
int right
Definition: common.h:948
_GAL_Rect
Definition: common.h:1163
_GAL_Color::a
gal_uint8 a
Definition: common.h:1140
DWORD
DWORD_PTR DWORD
A unsigned long type definition for pointer precision.
Definition: common.h:604
gal_attr
Uint32 gal_attr
Data type of attribute value.
Definition: common.h:1111
fixed
long fixed
Data type of fixed point.
Definition: common.h:1117
HWND
GHANDLE HWND
Handle to main window or control.
Definition: common.h:407
HDC
GHANDLE HDC
Handle to device context.
Definition: common.h:412
gal_uint
unsigned int gal_uint
Data type of unsigned integer.
Definition: common.h:1100
WORD16
unsigned short WORD16
A type definition for a 16-bit unsigned integer (word).
Definition: common.h:553
_GAL_Color::r
gal_uint8 r
Definition: common.h:1128
RECT
struct _RECT RECT
LONG
long LONG
A type definition for long integer.
Definition: common.h:694
PRECT
RECT * PRECT
Data type of the pointer to a RECT.
Definition: common.h:960
gal_sint8
Sint8 gal_sint8
Data type of 8-bit signed integer.
Definition: common.h:1052
_GAL_Palette
Definition: common.h:1147
WPARAM
UINT_PTR WPARAM
A type definition for the first message paramter.
Definition: common.h:706
_GAL_Rect::w
Sint32 w
Definition: common.h:1171
SWORD
SWORD_HPTR SWORD
A type definition for a signed integer.
Definition: common.h:547
LRESULT
LONG_PTR LRESULT
Signed result of message processing.
Definition: common.h:583
PVOID
void * PVOID
A type definition for a pointer to any type.
Definition: common.h:336
GHANDLE
PVOID GHANDLE
General handle.
Definition: common.h:402
UINT
unsigned int UINT
A type definition for unsigned integer.
Definition: common.h:664
BYTE
unsigned char BYTE
A type definition for an 8-bit unsigned character (byte).
Definition: common.h:460
LINT
LONG_PTR LINT
Signed integer which has pointer precision.
Definition: common.h:577
_RECT
Definition: common.h:936
UINT_PTR
unsigned long UINT_PTR
A unsigned integer type for pointer precision.
Definition: common.h:687
PRGB
RGB * PRGB
Data type of the pointer to a RGB.
Definition: common.h:1038
HMENU
GHANDLE HMENU
Handle to menu.
Definition: common.h:432
Sint32
signed int Sint32
A type definition for a 32-bit signed integer.
Definition: common.h:182
Uint64
unsigned long long Uint64
A type definition for a 64-bit unsigned integer.
Definition: common.h:206
LONG_PTR
long LONG_PTR
A signed long type for pointer precision.
Definition: common.h:570
Uint16
unsigned short Uint16
A type definition for a 16-bit unsigned integer.
Definition: common.h:167
Sint8
signed char Sint8
A type definition for an 8-bit signed character.
Definition: common.h:162
HICON
GHANDLE HICON
Handle to icon.
Definition: common.h:427
_GAL_Color::g
gal_uint8 g
Definition: common.h:1132
_SIZE::cy
int cy
Definition: common.h:998
Uint8
unsigned char Uint8
A type definition for an 8-bit unsigned character.
Definition: common.h:157
HACCEL
GHANDLE HACCEL
Handle to accelarator.
Definition: common.h:437
GAL_Color
struct _GAL_Color GAL_Color
BOOL
int BOOL
A type definition for boolean value.
Definition: common.h:343
RGBCOLOR
DWORD32 RGBCOLOR
A type definition for a RGB color value.
Definition: common.h:860
_RGB::b
BYTE b
Definition: common.h:1025
SDWORD_PTR
signed long SDWORD_PTR
A signed long type for pointer precision.
Definition: common.h:624
_RGB
Definition: common.h:1012
SBYTE
signed char SBYTE
A type definition for an 8-bit signed character.
Definition: common.h:466
Sint16
signed short Sint16
A type definition for a 16-bit signed integer.
Definition: common.h:172
Sint64
signed long long Sint64
A type definition for a 64-bit signed integer.
Definition: common.h:213
DWORD_PTR
unsigned long DWORD_PTR
An unsigned long type for pointer precision.
Definition: common.h:597
gal_sint
signed int gal_sint
Data type of signed integer.
Definition: common.h:1095
POINT
struct _POINT POINT
_GAL_Color
Definition: common.h:1123
gal_sint32
Sint32 gal_sint32
Data type of 32-bit signed integer.
Definition: common.h:1082
SDWORD
SDWORD_PTR SDWORD
A signed long type definition for pointer precision.
Definition: common.h:631
ULONG
unsigned long ULONG
A type definition for unsigned long integer.
Definition: common.h:700
_RECT::bottom
int bottom
Definition: common.h:952
_GAL_Palette::colors
GAL_Color * colors
Definition: common.h:1156
_GAL_Color::b
gal_uint8 b
Definition: common.h:1136
_RGB::g
BYTE g
Definition: common.h:1021
_SIZE::cx
int cx
Definition: common.h:994
HHOOK
GHANDLE HHOOK
Handle to keyboard or mouse event hook.
Definition: common.h:447
SWORD16
signed short SWORD16
A type definition for a 16-bit signed integer.
Definition: common.h:559
_POINT::x
int x
Definition: common.h:971
_RGB::r
BYTE r
Definition: common.h:1017
gal_sint16
Sint16 gal_sint16
Data type of 16-bit signed integer.
Definition: common.h:1067
SDWORD32
signed int SDWORD32
A type definition for a 32-bit signed integer.
Definition: common.h:637
_GAL_Rect::x
Sint32 x
Definition: common.h:1167
_GAL_Palette::ncolors
int ncolors
Definition: common.h:1152
Uint32
unsigned int Uint32
A type definition for a 32-bit unsigned integer.
Definition: common.h:177
PPOINT
POINT * PPOINT
Data type of the pointer to a POINT.
Definition: common.h:983
_SIZE
Definition: common.h:989
gal_uint16
Uint16 gal_uint16
Data type of 16-bit unsigned integer.
Definition: common.h:1074
gal_uint32
Uint32 gal_uint32
Data type of 32-bit unsigned integer.
Definition: common.h:1089
PSIZE
SIZE * PSIZE
Data type of the pointer to a SIZE.
Definition: common.h:1006
HDLG
GHANDLE HDLG
Handle to dialog box, same as HWND.
Definition: common.h:442
_RGB::a
BYTE a
Definition: common.h:1029
SIZE
struct _SIZE SIZE
HPALETTE
GHANDLE HPALETTE
Handle to a logical palette.
Definition: common.h:417
LPARAM
UINT_PTR LPARAM
A type definition for the second message paramter.
Definition: common.h:712
gal_pixel
Uint32 gal_pixel
Data type of pixel value.
Definition: common.h:1106
_RECT::top
int top
Definition: common.h:944
HCURSOR
GHANDLE HCURSOR
Handle to cursor.
Definition: common.h:422
WORD_HPTR
unsigned short WORD_HPTR
An unsigned int (word) type in half pointer precision.
Definition: common.h:522
INT_PTR
int INT_PTR
A signed integer type for pointer precision.
Definition: common.h:675
SWORD_HPTR
signed short SWORD_HPTR
An signed int type in half pointer precision.
Definition: common.h:534
gal_uint8
Uint8 gal_uint8
Data type of 8-bit unsigned integer.
Definition: common.h:1059
GAL_Rect
struct _GAL_Rect GAL_Rect
RGB
struct _RGB RGB
_RECT::left
int left
Definition: common.h:940
GAL_Palette
struct _GAL_Palette GAL_Palette
DWORD32
unsigned int DWORD32
A type definition for a 32-bit unsigned integer.
Definition: common.h:610
WORD
WORD_HPTR WORD
A type definition for an unsigned integer (word).
Definition: common.h:541