Use basegfx::rad2deg() instead of *57.29577951308
[LibreOffice.git] / include / sal / main.h
blob7d10988c6f10297dbd632ed22c269d2259e42b59
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 * This file is part of LibreOffice published API.
24 #ifndef INCLUDED_SAL_MAIN_H
25 #define INCLUDED_SAL_MAIN_H
27 #include "sal/config.h"
29 #include "sal/saldllapi.h"
30 #include "sal/types.h"
32 #if defined AIX
33 #include <unistd.h>
34 #endif
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
40 #if defined LIBO_INTERNAL_ONLY && defined __cplusplus
41 // Special token for sal_detail_initialize argc parameter, used by the soffice.bin process to tell
42 // SAL that it is running as part of that process (see sal/osl/unx/soffice.hxx); argv should be null
43 // in such a sal_detail_initialize call:
44 namespace sal::detail { constexpr int InitializeSoffice = -1; }
45 #endif
47 SAL_DLLPUBLIC void SAL_CALL sal_detail_initialize(int argc, char ** argv);
48 SAL_DLLPUBLIC void SAL_CALL sal_detail_deinitialize(void);
50 #if !(defined IOS || defined ANDROID)
51 /* No code that uses this should be built for iOS or Android */
53 #define SAL_MAIN_WITH_ARGS_IMPL \
54 int SAL_DLLPUBLIC_EXPORT SAL_CALL main(int argc, char ** argv) \
55 { \
56 int ret; \
57 sal_detail_initialize(argc, argv); \
58 ret = sal_main_with_args(argc, argv); \
59 sal_detail_deinitialize(); \
60 return ret; \
63 #define SAL_MAIN_IMPL \
64 int SAL_DLLPUBLIC_EXPORT SAL_CALL main(int argc, char ** argv) \
65 { \
66 int ret; \
67 sal_detail_initialize(argc, argv); \
68 ret = sal_main(); \
69 sal_detail_deinitialize(); \
70 return ret; \
73 #endif
76 /* Definition macros for CRT entries */
78 #ifdef _WIN32
80 #include <stdlib.h>
82 /* Sorry but this is necessary cause HINSTANCE is a typedef that differs (C++ causes an error) */
84 #ifndef WINAPI
85 # define WINAPI __stdcall
86 #endif
88 #if !defined(DECLARE_HANDLE)
89 # ifdef STRICT
90 typedef void *HANDLE;
91 # define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
92 # else
93 typedef void *PVOID;
94 typedef PVOID HANDLE;
95 # define DECLARE_HANDLE(name) typedef HANDLE name
96 # endif
97 DECLARE_HANDLE(HINSTANCE);
98 #endif
102 #define SAL_WIN_WinMain \
103 int WINAPI WinMain( HINSTANCE _hinst, HINSTANCE _dummy, char* _cmdline, int _nshow ) \
105 int argc = __argc; char ** argv = __argv; \
106 (void) _hinst; (void) _dummy; (void) _cmdline; (void) _nshow; /* unused */ \
107 return main(argc, argv); \
110 #else /* ! _WIN32 */
112 # define SAL_WIN_WinMain
114 #endif /* ! _WIN32 */
116 /* Implementation macro */
118 #define SAL_IMPLEMENT_MAIN_WITH_ARGS(_argc_, _argv_) \
119 static int SAL_CALL sal_main_with_args (int _argc_, char ** _argv_); \
120 SAL_MAIN_WITH_ARGS_IMPL \
121 SAL_WIN_WinMain \
122 static int SAL_CALL sal_main_with_args(int _argc_, char ** _argv_)
124 #define SAL_IMPLEMENT_MAIN() \
125 static int SAL_CALL sal_main(void); \
126 SAL_MAIN_IMPL \
127 SAL_WIN_WinMain \
128 static int SAL_CALL sal_main(void)
131 "How to use" Examples:
133 #include <sal/main.h>
135 SAL_IMPLEMENT_MAIN()
137 DoSomething();
139 return 0;
142 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
144 DoSomethingWithArgs(argc, argv);
146 return 0;
151 #ifdef __cplusplus
152 } /* extern "C" */
153 #endif
155 #endif // INCLUDED_SAL_MAIN_H
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */