UDK 3.2.7 C/C++ API Reference
|
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 00002 /************************************************************************* 00003 * 00004 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 00005 * 00006 * Copyright 2000, 2010 Oracle and/or its affiliates. 00007 * 00008 * OpenOffice.org - a multi-platform office productivity suite 00009 * 00010 * This file is part of OpenOffice.org. 00011 * 00012 * OpenOffice.org is free software: you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 3 00014 * only, as published by the Free Software Foundation. 00015 * 00016 * OpenOffice.org is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License version 3 for more details 00020 * (a copy is included in the LICENSE file that accompanied this code). 00021 * 00022 * You should have received a copy of the GNU Lesser General Public License 00023 * version 3 along with OpenOffice.org. If not, see 00024 * <http://www.openoffice.org/license.html> 00025 * for a copy of the LGPLv3 License. 00026 * 00027 ************************************************************************/ 00028 00029 #ifndef _SAL_MAIN_H_ 00030 #define _SAL_MAIN_H_ 00031 00032 #include <sal/types.h> 00033 #if defined(AIX) 00034 # include <unistd.h> 00035 #endif 00036 00037 #ifdef __cplusplus 00038 extern "C" { 00039 #endif 00040 00041 SAL_DLLPUBLIC void SAL_CALL sal_detail_initialize(int argc, char ** argv); 00042 SAL_DLLPUBLIC void SAL_CALL sal_detail_deinitialize(); 00043 00044 #if defined IOS || defined ANDROID 00045 00046 #ifdef __cplusplus 00047 extern "C" SAL_DLLPUBLIC_EXPORT void lo_main(int argc, char **argv); 00048 #endif 00049 00050 #define SAL_MAIN_WITH_ARGS_IMPL \ 00051 SAL_DLLPUBLIC_EXPORT void lo_main(int argc, char **argv) \ 00052 { \ 00053 sal_detail_initialize(argc, argv); \ 00054 sal_main_with_args(argc, argv); \ 00055 sal_detail_deinitialize(); \ 00056 } 00057 00058 #define SAL_MAIN_IMPL \ 00059 SAL_DLLPUBLIC_EXPORT void lo_main(int argc, char **argv) \ 00060 { \ 00061 sal_detail_initialize(argc, argv); \ 00062 sal_main(); \ 00063 sal_detail_deinitialize(); \ 00064 } 00065 00066 #else 00067 00068 #define SAL_MAIN_WITH_ARGS_IMPL \ 00069 int SAL_CALL main(int argc, char ** argv) \ 00070 { \ 00071 int ret; \ 00072 sal_detail_initialize(argc, argv); \ 00073 ret = sal_main_with_args(argc, argv); \ 00074 sal_detail_deinitialize(); \ 00075 return ret; \ 00076 } 00077 00078 #define SAL_MAIN_IMPL \ 00079 int SAL_CALL main(int argc, char ** argv) \ 00080 { \ 00081 int ret; \ 00082 sal_detail_initialize(argc, argv); \ 00083 ret = sal_main(); \ 00084 sal_detail_deinitialize(); \ 00085 return ret; \ 00086 } 00087 00088 #endif 00089 00090 00091 /* Definition macros for CRT entries */ 00092 00093 #ifdef SAL_W32 00094 00095 #ifndef INCLUDED_STDLIB_H 00096 #include <stdlib.h> 00097 #define INCLUDED_STDLIB_H 00098 #endif 00099 00100 /* Sorry but this is neccessary cause HINSTANCE is a typedef that differs (C++ causes an error) */ 00101 00102 #ifndef WINAPI 00103 # define WINAPI __stdcall 00104 #endif 00105 00106 #if !defined(DECLARE_HANDLE) 00107 # ifdef STRICT 00108 typedef void *HANDLE; 00109 # define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name 00110 # else 00111 typedef void *PVOID; 00112 typedef PVOID HANDLE; 00113 # define DECLARE_HANDLE(name) typedef HANDLE name 00114 # endif 00115 DECLARE_HANDLE(HINSTANCE); 00116 #endif 00117 00118 00119 00120 #define SAL_WIN_WinMain \ 00121 int WINAPI WinMain( HINSTANCE _hinst, HINSTANCE _dummy, char* _cmdline, int _nshow ) \ 00122 { \ 00123 int argc = __argc; char ** argv = __argv; \ 00124 (void) _hinst; (void) _dummy; (void) _cmdline; (void) _nshow; /* unused */ \ 00125 return main(argc, argv); \ 00126 } 00127 00128 #else /* ! SAL_W32 */ 00129 00130 # define SAL_WIN_WinMain 00131 00132 #endif /* ! SAL_W32 */ 00133 00134 /* Implementation macro */ 00135 00136 #define SAL_IMPLEMENT_MAIN_WITH_ARGS(_argc_, _argv_) \ 00137 static int SAL_CALL sal_main_with_args (int _argc_, char ** _argv_); \ 00138 SAL_MAIN_WITH_ARGS_IMPL \ 00139 SAL_WIN_WinMain \ 00140 static int SAL_CALL sal_main_with_args(int _argc_, char ** _argv_) 00141 00142 #define SAL_IMPLEMENT_MAIN() \ 00143 static int SAL_CALL sal_main(void); \ 00144 SAL_MAIN_IMPL \ 00145 SAL_WIN_WinMain \ 00146 static int SAL_CALL sal_main(void) 00147 00148 /* 00149 "How to use" Examples: 00150 00151 #include <sal/main.h> 00152 00153 SAL_IMPLEMENT_MAIN() 00154 { 00155 DoSomething(); 00156 00157 return 0; 00158 } 00159 00160 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) 00161 { 00162 DoSomethingWithArgs(argc, argv); 00163 00164 return 0; 00165 } 00166 00167 */ 00168 00169 #ifdef __cplusplus 00170 } /* extern "C" */ 00171 #endif 00172 00173 #endif /* _SAL_MAIN_H_ */ 00174 00175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */