1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_cppuhelper.hxx"
26 
27 #include <sal/main.h>
28 
29 
30 
31 #include <cstdio>
32 
33 #include <rtl/process.h>
34 #include <cppuhelper/bootstrap.hxx>
35 
36 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 
38 using namespace ::cppu;
39 using namespace ::com::sun::star::lang;
40 using namespace ::com::sun::star::uno;
41 using namespace ::rtl;
42 
43 
SAL_IMPLEMENT_MAIN()44 SAL_IMPLEMENT_MAIN()
45 {
46 	sal_Bool result = sal_True;
47 
48 	try {
49 		Reference<XComponentContext> xComponentContext = defaultBootstrap_InitialComponentContext();
50 
51 		Reference<XMultiServiceFactory> smgr(xComponentContext->getServiceManager(), UNO_QUERY);
52 
53 		for(sal_uInt32 i = 0; i < rtl_getAppCommandArgCount(); ++ i) {
54 			OUString arg;
55 
56 			rtl_getAppCommandArg(i, &arg.pData);
57 			if (arg.getLength())
58 			{
59 				Reference<XInterface> xInterface = smgr->createInstance(arg);
60 				OString tmp = OUStringToOString(arg, RTL_TEXTENCODING_ASCII_US);
61 #if OSL_DEBUG_LEVEL > 1
62 				fprintf(stderr, "got the %s service %p\n", tmp.getStr(), xInterface.get());
63 #endif
64 
65 				result = result && (xInterface.get() != 0);
66 			}
67 		}
68 	}
69 	catch(Exception & exception) {
70 		OString message = OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US);
71 
72 		fprintf(stderr, "an exception occurred: %s\n", message.getStr());
73 	}
74 
75 #if OSL_DEBUG_LEVEL > 1
76 	OSL_TRACE("---------------------------------- %i", result);
77 #endif
78 
79 	return result;
80 }
81