UDK 3.2.7 C/C++ API Reference

sal/main.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /*
00003  * This file is part of the LibreOffice project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * This file incorporates work covered by the following license notice:
00010  *
00011  *   Licensed to the Apache Software Foundation (ASF) under one or more
00012  *   contributor license agreements. See the NOTICE file distributed
00013  *   with this work for additional information regarding copyright
00014  *   ownership. The ASF licenses this file to you under the Apache
00015  *   License, Version 2.0 (the "License"); you may not use this file
00016  *   except in compliance with the License. You may obtain a copy of
00017  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
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 /* Definition macros for CRT entries */
00069 
00070 #ifdef SAL_W32
00071 
00072 #ifndef INCLUDED_STDLIB_H
00073 #include <stdlib.h>
00074 #define INCLUDED_STDLIB_H
00075 #endif
00076 
00077 /* Sorry but this is neccessary cause HINSTANCE is a typedef that differs (C++ causes an error) */
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; /* unused */ \
00102     return main(argc, argv); \
00103 }
00104 
00105 #else   /* ! SAL_W32 */
00106 
00107 # define SAL_WIN_WinMain
00108 
00109 #endif /* ! SAL_W32 */
00110 
00111 /* Implementation macro */
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     "How to use" Examples:
00127 
00128     #include <sal/main.h>
00129 
00130     SAL_IMPLEMENT_MAIN()
00131     {
00132         DoSomething();
00133 
00134         return 0;
00135     }
00136 
00137     SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
00138     {
00139         DoSomethingWithArgs(argc, argv);
00140 
00141         return 0;
00142     }
00143 
00144 */
00145 
00146 #ifdef __cplusplus
00147 }   /* extern "C" */
00148 #endif
00149 
00150 #endif  /* _SAL_MAIN_H_ */
00151 
00152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines