My Project
UDK 3.2.7 C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
main.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org. If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 
29 #ifndef _SAL_MAIN_H_
30 #define _SAL_MAIN_H_
31 
32 #include <sal/types.h>
33 #if defined(AIX)
34 # include <unistd.h>
35 #endif
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 SAL_DLLPUBLIC void SAL_CALL sal_detail_initialize(int argc, char ** argv);
43 
44 #if defined IOS || defined ANDROID
45 
46 #ifdef __cplusplus
47 extern "C" SAL_DLLPUBLIC_EXPORT void lo_main(int argc, char **argv);
48 #endif
49 
50 #define SAL_MAIN_WITH_ARGS_IMPL \
51 SAL_DLLPUBLIC_EXPORT void lo_main(int argc, char **argv) \
52 { \
53  sal_detail_initialize(argc, argv); \
54  sal_main_with_args(argc, argv); \
55  sal_detail_deinitialize(); \
56 }
57 
58 #define SAL_MAIN_IMPL \
59 SAL_DLLPUBLIC_EXPORT void lo_main(int argc, char **argv) \
60 { \
61  sal_detail_initialize(argc, argv); \
62  sal_main(); \
63  sal_detail_deinitialize(); \
64 }
65 
66 #else
67 
68 #define SAL_MAIN_WITH_ARGS_IMPL \
69 int SAL_CALL main(int argc, char ** argv) \
70 { \
71  int ret; \
72  sal_detail_initialize(argc, argv); \
73  ret = sal_main_with_args(argc, argv); \
74  sal_detail_deinitialize(); \
75  return ret; \
76 }
77 
78 #define SAL_MAIN_IMPL \
79 int SAL_CALL main(int argc, char ** argv) \
80 { \
81  int ret; \
82  sal_detail_initialize(argc, argv); \
83  ret = sal_main(); \
84  sal_detail_deinitialize(); \
85  return ret; \
86 }
87 
88 #endif
89 
90 
91 /* Definition macros for CRT entries */
92 
93 #ifdef SAL_W32
94 
95 #ifndef INCLUDED_STDLIB_H
96 #include <stdlib.h>
97 #define INCLUDED_STDLIB_H
98 #endif
99 
100 /* Sorry but this is neccessary cause HINSTANCE is a typedef that differs (C++ causes an error) */
101 
102 #ifndef WINAPI
103 # define WINAPI __stdcall
104 #endif
105 
106 #if !defined(DECLARE_HANDLE)
107 # ifdef STRICT
108  typedef void *HANDLE;
109 # define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
110 # else
111  typedef void *PVOID;
112  typedef PVOID HANDLE;
113 # define DECLARE_HANDLE(name) typedef HANDLE name
114 # endif
115 DECLARE_HANDLE(HINSTANCE);
116 #endif
117 
118 
119 
120 #define SAL_WIN_WinMain \
121 int WINAPI WinMain( HINSTANCE _hinst, HINSTANCE _dummy, char* _cmdline, int _nshow ) \
122 { \
123  int argc = __argc; char ** argv = __argv; \
124  (void) _hinst; (void) _dummy; (void) _cmdline; (void) _nshow; /* unused */ \
125  return main(argc, argv); \
126 }
127 
128 #else /* ! SAL_W32 */
129 
130 # define SAL_WIN_WinMain
131 
132 #endif /* ! SAL_W32 */
133 
134 /* Implementation macro */
135 
136 #define SAL_IMPLEMENT_MAIN_WITH_ARGS(_argc_, _argv_) \
137  static int SAL_CALL sal_main_with_args (int _argc_, char ** _argv_); \
138  SAL_MAIN_WITH_ARGS_IMPL \
139  SAL_WIN_WinMain \
140  static int SAL_CALL sal_main_with_args(int _argc_, char ** _argv_)
141 
142 #define SAL_IMPLEMENT_MAIN() \
143  static int SAL_CALL sal_main(void); \
144  SAL_MAIN_IMPL \
145  SAL_WIN_WinMain \
146  static int SAL_CALL sal_main(void)
147 
148 /*
149  "How to use" Examples:
150 
151  #include <sal/main.h>
152 
153  SAL_IMPLEMENT_MAIN()
154  {
155  DoSomething();
156 
157  return 0;
158  }
159 
160  SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
161  {
162  DoSomethingWithArgs(argc, argv);
163 
164  return 0;
165  }
166 
167 */
168 
169 #ifdef __cplusplus
170 } /* extern "C" */
171 #endif
172 
173 #endif /* _SAL_MAIN_H_ */
174 
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */