2010-10-27 13:13:11 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-19 19:45:04 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2001-02-21 19:15:20 +00:00
|
|
|
|
2013-10-23 19:14:56 +02:00
|
|
|
#ifndef INCLUDED_SAL_MAIN_H
|
|
|
|
#define INCLUDED_SAL_MAIN_H
|
2001-02-21 19:15:20 +00:00
|
|
|
|
2013-11-09 15:15:40 -06:00
|
|
|
#include <sal/config.h>
|
2012-09-15 12:21:17 +02:00
|
|
|
|
2013-11-09 15:15:40 -06:00
|
|
|
#include <sal/saldllapi.h>
|
|
|
|
#include <sal/types.h>
|
2012-09-15 12:21:17 +02:00
|
|
|
|
|
|
|
#if defined AIX
|
|
|
|
#include <unistd.h>
|
2010-10-13 15:06:44 +01:00
|
|
|
#endif
|
2001-02-21 19:15:20 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2011-12-17 13:22:02 +01:00
|
|
|
SAL_DLLPUBLIC void SAL_CALL sal_detail_initialize(int argc, char ** argv);
|
2014-06-17 15:36:26 +02:00
|
|
|
SAL_DLLPUBLIC void SAL_CALL sal_detail_deinitialize(void);
|
2001-02-21 19:15:20 +00:00
|
|
|
|
2012-02-16 09:09:14 +02:00
|
|
|
#if defined IOS || defined ANDROID
|
2011-11-04 18:36:26 +02:00
|
|
|
|
2013-02-22 23:19:22 +02:00
|
|
|
#error No code that includes this should be built for iOS or Android
|
2011-11-04 18:36:26 +02:00
|
|
|
|
2011-07-07 07:58:56 +03:00
|
|
|
#else
|
|
|
|
|
2006-12-01 16:24:31 +00:00
|
|
|
#define SAL_MAIN_WITH_ARGS_IMPL \
|
2013-07-05 22:41:00 +02:00
|
|
|
int SAL_DLLPUBLIC_EXPORT SAL_CALL main(int argc, char ** argv) \
|
2006-12-01 16:24:31 +00:00
|
|
|
{ \
|
2007-10-15 11:47:44 +00:00
|
|
|
int ret; \
|
|
|
|
sal_detail_initialize(argc, argv); \
|
|
|
|
ret = sal_main_with_args(argc, argv); \
|
|
|
|
sal_detail_deinitialize(); \
|
2010-10-13 15:34:27 +01:00
|
|
|
return ret; \
|
2006-12-01 16:24:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define SAL_MAIN_IMPL \
|
2013-07-05 22:41:00 +02:00
|
|
|
int SAL_DLLPUBLIC_EXPORT SAL_CALL main(int argc, char ** argv) \
|
2006-12-01 16:24:31 +00:00
|
|
|
{ \
|
2007-10-15 11:47:44 +00:00
|
|
|
int ret; \
|
|
|
|
sal_detail_initialize(argc, argv); \
|
|
|
|
ret = sal_main(); \
|
|
|
|
sal_detail_deinitialize(); \
|
2010-10-13 15:34:27 +01:00
|
|
|
return ret; \
|
2006-12-01 16:24:31 +00:00
|
|
|
}
|
|
|
|
|
2011-07-07 07:58:56 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2001-02-21 19:15:20 +00:00
|
|
|
/* Definition macros for CRT entries */
|
|
|
|
|
|
|
|
#ifdef SAL_W32
|
|
|
|
|
2004-10-28 15:25:00 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2013-12-20 11:25:37 +01:00
|
|
|
/* Sorry but this is necessary cause HINSTANCE is a typedef that differs (C++ causes an error) */
|
2001-02-22 14:53:46 +00:00
|
|
|
|
|
|
|
#ifndef WINAPI
|
|
|
|
# define WINAPI __stdcall
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(DECLARE_HANDLE)
|
|
|
|
# ifdef STRICT
|
2001-02-27 09:44:53 +00:00
|
|
|
typedef void *HANDLE;
|
2001-02-22 14:53:46 +00:00
|
|
|
# define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
|
|
|
|
# else
|
2001-02-27 09:44:53 +00:00
|
|
|
typedef void *PVOID;
|
|
|
|
typedef PVOID HANDLE;
|
2001-02-22 14:53:46 +00:00
|
|
|
# define DECLARE_HANDLE(name) typedef HANDLE name
|
|
|
|
# endif
|
|
|
|
DECLARE_HANDLE(HINSTANCE);
|
|
|
|
#endif
|
|
|
|
|
2010-10-18 16:25:37 +01:00
|
|
|
|
2001-02-22 14:53:46 +00:00
|
|
|
|
2006-12-01 16:24:31 +00:00
|
|
|
#define SAL_WIN_WinMain \
|
2001-02-22 14:53:46 +00:00
|
|
|
int WINAPI WinMain( HINSTANCE _hinst, HINSTANCE _dummy, char* _cmdline, int _nshow ) \
|
2001-02-21 19:15:20 +00:00
|
|
|
{ \
|
2004-10-28 15:25:00 +00:00
|
|
|
int argc = __argc; char ** argv = __argv; \
|
2006-06-20 03:15:39 +00:00
|
|
|
(void) _hinst; (void) _dummy; (void) _cmdline; (void) _nshow; /* unused */ \
|
2006-12-01 16:24:31 +00:00
|
|
|
return main(argc, argv); \
|
2001-02-21 19:15:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#else /* ! SAL_W32 */
|
2007-09-20 14:08:10 +00:00
|
|
|
|
2006-12-01 16:24:31 +00:00
|
|
|
# define SAL_WIN_WinMain
|
2001-02-21 19:15:20 +00:00
|
|
|
|
2004-10-28 15:25:00 +00:00
|
|
|
#endif /* ! SAL_W32 */
|
2001-02-21 19:15:20 +00:00
|
|
|
|
|
|
|
/* Implementation macro */
|
|
|
|
|
2004-10-28 15:25:00 +00:00
|
|
|
#define SAL_IMPLEMENT_MAIN_WITH_ARGS(_argc_, _argv_) \
|
2006-12-01 16:24:31 +00:00
|
|
|
static int SAL_CALL sal_main_with_args (int _argc_, char ** _argv_); \
|
|
|
|
SAL_MAIN_WITH_ARGS_IMPL \
|
|
|
|
SAL_WIN_WinMain \
|
|
|
|
static int SAL_CALL sal_main_with_args(int _argc_, char ** _argv_)
|
|
|
|
|
|
|
|
#define SAL_IMPLEMENT_MAIN() \
|
|
|
|
static int SAL_CALL sal_main(void); \
|
|
|
|
SAL_MAIN_IMPL \
|
|
|
|
SAL_WIN_WinMain \
|
|
|
|
static int SAL_CALL sal_main(void)
|
2001-02-21 19:15:20 +00:00
|
|
|
|
2004-10-28 15:25:00 +00:00
|
|
|
/*
|
|
|
|
"How to use" Examples:
|
2001-02-21 19:15:20 +00:00
|
|
|
|
|
|
|
#include <sal/main.h>
|
|
|
|
|
|
|
|
SAL_IMPLEMENT_MAIN()
|
|
|
|
{
|
|
|
|
DoSomething();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-10-28 15:25:00 +00:00
|
|
|
SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
|
|
|
|
{
|
|
|
|
DoSomethingWithArgs(argc, argv);
|
2001-02-21 19:15:20 +00:00
|
|
|
|
2004-10-28 15:25:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
2001-02-21 19:15:20 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
|
|
|
#endif
|
|
|
|
|
2013-10-23 19:14:56 +02:00
|
|
|
#endif // INCLUDED_SAL_MAIN_H
|
2001-02-21 19:15:20 +00:00
|
|
|
|
2010-10-27 13:13:11 +01:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|