LibreOffice
LibreOffice 4.1 SDK C/C++ API Reference
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
sal
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
* This file is part of the LibreOffice project.
4
*
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/.
8
*
9
* This file incorporates work covered by the following license notice:
10
*
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 .
18
*/
19
20
#ifndef _SAL_MAIN_H_
21
#define _SAL_MAIN_H_
22
23
#include "
sal/config.h
"
24
25
#include "
sal/saldllapi.h
"
26
#include "
sal/types.h
"
27
28
#if defined AIX
29
#include <unistd.h>
30
#endif
31
32
#ifdef __cplusplus
33
extern
"C"
{
34
#endif
35
36
SAL_DLLPUBLIC
void
SAL_CALL
sal_detail_initialize
(
int
argc,
char
** argv);
37
SAL_DLLPUBLIC
void
SAL_CALL
sal_detail_deinitialize
();
38
39
#if defined IOS || defined ANDROID
40
41
#error No code that includes this should be built for iOS or Android
42
43
#else
44
45
#define SAL_MAIN_WITH_ARGS_IMPL \
46
int SAL_CALL main(int argc, char ** argv) \
47
{ \
48
int ret; \
49
sal_detail_initialize(argc, argv); \
50
ret = sal_main_with_args(argc, argv); \
51
sal_detail_deinitialize(); \
52
return ret; \
53
}
54
55
#define SAL_MAIN_IMPL \
56
int SAL_CALL main(int argc, char ** argv) \
57
{ \
58
int ret; \
59
sal_detail_initialize(argc, argv); \
60
ret = sal_main(); \
61
sal_detail_deinitialize(); \
62
return ret; \
63
}
64
65
#endif
66
67
68
/* Definition macros for CRT entries */
69
70
#ifdef SAL_W32
71
72
#include <stdlib.h>
73
74
/* Sorry but this is neccessary cause HINSTANCE is a typedef that differs (C++ causes an error) */
75
76
#ifndef WINAPI
77
# define WINAPI __stdcall
78
#endif
79
80
#if !defined(DECLARE_HANDLE)
81
# ifdef STRICT
82
typedef
void
*HANDLE;
83
# define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
84
# else
85
typedef
void
*PVOID;
86
typedef
PVOID HANDLE;
87
# define DECLARE_HANDLE(name) typedef HANDLE name
88
# endif
89
DECLARE_HANDLE(HINSTANCE);
90
#endif
91
92
93
94
#define SAL_WIN_WinMain \
95
int WINAPI WinMain( HINSTANCE _hinst, HINSTANCE _dummy, char* _cmdline, int _nshow ) \
96
{ \
97
int argc = __argc; char ** argv = __argv; \
98
(void) _hinst; (void) _dummy; (void) _cmdline; (void) _nshow;
/* unused */
\
99
return main(argc, argv); \
100
}
101
102
#else
/* ! SAL_W32 */
103
104
# define SAL_WIN_WinMain
105
106
#endif
/* ! SAL_W32 */
107
108
/* Implementation macro */
109
110
#define SAL_IMPLEMENT_MAIN_WITH_ARGS(_argc_, _argv_) \
111
static int SAL_CALL sal_main_with_args (int _argc_, char ** _argv_); \
112
SAL_MAIN_WITH_ARGS_IMPL \
113
SAL_WIN_WinMain \
114
static int SAL_CALL sal_main_with_args(int _argc_, char ** _argv_)
115
116
#define SAL_IMPLEMENT_MAIN() \
117
static int SAL_CALL sal_main(void); \
118
SAL_MAIN_IMPL \
119
SAL_WIN_WinMain \
120
static int SAL_CALL sal_main(void)
121
122
/*
123
"How to use" Examples:
124
125
#include <sal/main.h>
126
127
SAL_IMPLEMENT_MAIN()
128
{
129
DoSomething();
130
131
return 0;
132
}
133
134
SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
135
{
136
DoSomethingWithArgs(argc, argv);
137
138
return 0;
139
}
140
141
*/
142
143
#ifdef __cplusplus
144
}
/* extern "C" */
145
#endif
146
147
#endif
/* _SAL_MAIN_H_ */
148
149
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Generated on Thu Oct 31 2013 06:18:06 for LibreOffice by
1.8.1.2