Products Support Documentation Download
psptypes-win.h
Go to the documentation of this file.
1 /*
2  * Raima Database Manager
3  *
4  * Copyright (C) 2016 Raims Inc., All rights reserved.
5  *
6  * Use of this software, whether in source code format, or in executable,
7  * binary object code form, is governed by the Raima LICENSE which
8  * is fully described in the LICENSE.TXT file, included within this
9  * distribution of files.
10  */
11 
16 #ifndef RDM_DOXYGEN
17 #ifndef PSPTYPES_WIN_H
18 #define PSPTYPES_WIN_H
19 
20 #if defined(RDM_CPP_BUILD)
21 #define PUBLIC_CLASS RDM_EXPORT
22 #else
23 #define PUBLIC_CLASS RDM_IMPORT
24 #endif
25 
26 #if !defined(RDM_WINCE)
27  #include <stdint.h>
28 #else
29  typedef signed char int8_t;
30  typedef unsigned char uint8_t;
31 
32  typedef short int16_t;
33  typedef unsigned short uint16_t;
34 
35  typedef int int32_t;
36  typedef unsigned int uint32_t;
37 
38  typedef __int64 int64_t;
39  typedef unsigned __int64 uint64_t;
40 
41  typedef int64_t intmax_t;
42  typedef uint64_t uintmax_t;
43 #endif
44 
45 #if !defined(RDM_UNREF) && defined(_MSC_VER) && _MSC_VER < 1800
46 #define RDM_UNREF(a)
47 #endif
48 
49 #if !defined(RDM_NO_ASSERT) && !defined(NDEBUG)
50 #include <assert.h>
51 #define RDM_ASSERT(x) assert(x)
52 #define RDM_ASSERT_ENABLED
53 #endif
54 
55 #define RDM_64BIT_CODE RDM_T("I64")
56 #define RDM_64BIT_CODE_A "I64"
57 
58 #if defined(RDM_WINCE)
59 #define ARG_COUNT 10
60 
61 #define RDM_STARTUP_EXAMPLE(name) \
62  static wchar_t name##argv[ARG_COUNT + 1][100]; \
63  \
64  static void name##SetArgs( \
65  const wchar_t *name, \
66  wchar_t *argv[], \
67  int32_t argc) \
68  { \
69  int32_t ii; \
70  \
71  memset(name##argv, 0, sizeof(name##argv)); \
72  \
73  /* Break here and set arguments in argv1, argv2, ... */ \
74  for (ii = 0; ii <= argc; ii++) \
75  argv[ii] = name##argv[ii]; \
76  \
77  wcscpy(argv[0], name); \
78  } \
79  \
80  /*int32_t name ## _mainW(int32_t, const wchar_t *const *);*/ \
81  int32_t WINAPI WinMain ( \
82  HINSTANCE hInstance, \
83  HINSTANCE hPrevInstance, \
84  LPWSTR lpCmdLine, \
85  int nCmdShow) \
86  { \
87  int32_t status = EXIT_FAILURE; \
88  int32_t argc; \
89  wchar_t *argv[11]; \
90  \
91  RDM_UNREF(hInstance) \
92  RDM_UNREF(hPrevInstance) \
93  RDM_UNREF(lpCmdLine) \
94  RDM_UNREF(nCmdShow) \
95  \
96  MessageBox(NULL, L"Start Program: Attach a debugger, " \
97  L"break in " L ## #name L"SetArgs to set arguments.", \
98  L ## #name, MB_SETFOREGROUND); \
99  name##SetArgs(L ## #name, argv, ARG_COUNT); \
100  \
101  for (argc = 1; argc <= 10; argc++) \
102  { \
103  if (*argv[argc] == L'\0') \
104  break; \
105  } \
106  \
107  RDM_STARTUP_HOOK \
108  status = name##_mainW(argc, argv); \
109  MessageBox(NULL, L"Terminate program", L ## #name, \
110  MB_SETFOREGROUND); \
111  RDM_SHUTDOWN_HOOK \
112  \
113  return status; \
114  }
115 #else
116 /* RDM_STARTUP_EXAMPLE_CR we want to prompt the user upon termination */
117 #define RDM_STARTUP_EXAMPLE_CR(name) \
118  int32_t name##_main(int32_t argc, const char *const *argv); \
119  int main(int32_t argc, const char *const *argv) { \
120  int32_t status = EXIT_FAILURE; \
121  \
122  RDM_STARTUP_HOOK \
123  status = name##_main(argc, argv); \
124  puts("Press RETURN to exit."); \
125  (void) getchar(); \
126  RDM_SHUTDOWN_HOOK \
127  \
128  return status; \
129  }
130 
131 #endif
132 
133 #endif
134 #endif