00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _SAL_MAIN_H_
00021 #define _SAL_MAIN_H_
00022
00023 #include "sal/config.h"
00024
00025 #include "sal/saldllapi.h"
00026 #include "sal/types.h"
00027
00028 #if defined AIX
00029 #include <unistd.h>
00030 #endif
00031
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035
00036 SAL_DLLPUBLIC void SAL_CALL sal_detail_initialize(int argc, char ** argv);
00037 SAL_DLLPUBLIC void SAL_CALL sal_detail_deinitialize();
00038
00039 #if defined IOS || defined ANDROID
00040
00041 #error No code that includes this should be built for iOS or Android
00042
00043 #else
00044
00045 #define SAL_MAIN_WITH_ARGS_IMPL \
00046 int SAL_CALL main(int argc, char ** argv) \
00047 { \
00048 int ret; \
00049 sal_detail_initialize(argc, argv); \
00050 ret = sal_main_with_args(argc, argv); \
00051 sal_detail_deinitialize(); \
00052 return ret; \
00053 }
00054
00055 #define SAL_MAIN_IMPL \
00056 int SAL_CALL main(int argc, char ** argv) \
00057 { \
00058 int ret; \
00059 sal_detail_initialize(argc, argv); \
00060 ret = sal_main(); \
00061 sal_detail_deinitialize(); \
00062 return ret; \
00063 }
00064
00065 #endif
00066
00067
00068
00069
00070 #ifdef SAL_W32
00071
00072 #ifndef INCLUDED_STDLIB_H
00073 #include <stdlib.h>
00074 #define INCLUDED_STDLIB_H
00075 #endif
00076
00077
00078
00079 #ifndef WINAPI
00080 # define WINAPI __stdcall
00081 #endif
00082
00083 #if !defined(DECLARE_HANDLE)
00084 # ifdef STRICT
00085 typedef void *HANDLE;
00086 # define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
00087 # else
00088 typedef void *PVOID;
00089 typedef PVOID HANDLE;
00090 # define DECLARE_HANDLE(name) typedef HANDLE name
00091 # endif
00092 DECLARE_HANDLE(HINSTANCE);
00093 #endif
00094
00095
00096
00097 #define SAL_WIN_WinMain \
00098 int WINAPI WinMain( HINSTANCE _hinst, HINSTANCE _dummy, char* _cmdline, int _nshow ) \
00099 { \
00100 int argc = __argc; char ** argv = __argv; \
00101 (void) _hinst; (void) _dummy; (void) _cmdline; (void) _nshow; \
00102 return main(argc, argv); \
00103 }
00104
00105 #else
00106
00107 # define SAL_WIN_WinMain
00108
00109 #endif
00110
00111
00112
00113 #define SAL_IMPLEMENT_MAIN_WITH_ARGS(_argc_, _argv_) \
00114 static int SAL_CALL sal_main_with_args (int _argc_, char ** _argv_); \
00115 SAL_MAIN_WITH_ARGS_IMPL \
00116 SAL_WIN_WinMain \
00117 static int SAL_CALL sal_main_with_args(int _argc_, char ** _argv_)
00118
00119 #define SAL_IMPLEMENT_MAIN() \
00120 static int SAL_CALL sal_main(void); \
00121 SAL_MAIN_IMPL \
00122 SAL_WIN_WinMain \
00123 static int SAL_CALL sal_main(void)
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146 #ifdef __cplusplus
00147 }
00148 #endif
00149
00150 #endif
00151
00152