Avoid potential negative array index access to cached text.
[LibreOffice.git] / extensions / source / update / check / updateprotocoltest.cxx
blob070f930af160afcb5caf0f13b754bc41dde69172
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 #include <cppuhelper/bootstrap.hxx>
23 #include "updateprotocol.hxx"
24 #include <com/sun/star/ucb/UniversalContentBroker.hpp>
26 #include <sal/main.h>
27 #include <osl/process.h>
28 #include <stdio.h>
29 #include "sal/log.hxx"
31 namespace task = ::com::sun::star::task;
32 namespace uno = ::com::sun::star::uno;
35 SAL_IMPLEMENT_MAIN()
37 (void) argv;
38 (void) argc;
40 if( osl_getCommandArgCount() != 0 )
42 fprintf(stderr, "Usage: updateprotocoltest\n");
43 return -1;
46 // create the initial component context
47 uno::Reference< uno::XComponentContext > rComponentContext = cppu::defaultBootstrap_InitialComponentContext();
49 // initialize UCB (for backwards compatibility, in case some code still uses
50 // plain createInstance w/o args directly to obtain an instance):
51 css::ucb::UniversalContentBroker::create(rComponentContext);
54 OUString aURL;
55 OUString aVersion;
57 try
59 if( checkForUpdates(rComponentContext, uno::Reference< task::XInteractionHandler > (), aURL, aVersion) )
61 SAL_INFO("extensions.update", "Update found: " << aVersion << " on " << aURL);
63 else
65 SAL_INFO("extensions.update", "no updates found" );
68 catch( ... )
70 SAL_INFO("extensions.update", "unhandled exception caught" );
73 return 0;
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */