1*01797804SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*01797804SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*01797804SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*01797804SAndrew Rist * distributed with this work for additional information 6*01797804SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*01797804SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*01797804SAndrew Rist * "License"); you may not use this file except in compliance 9*01797804SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*01797804SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*01797804SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*01797804SAndrew Rist * software distributed under the License is distributed on an 15*01797804SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*01797804SAndrew Rist * KIND, either express or implied. See the License for the 17*01797804SAndrew Rist * specific language governing permissions and limitations 18*01797804SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*01797804SAndrew Rist *************************************************************/ 21*01797804SAndrew Rist 22*01797804SAndrew Rist 23cdf0e10cSrcweir #include <stdlib.h> 24cdf0e10cSrcweir #include <stdio.h> 25cdf0e10cSrcweir #include <string.h> 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <vector> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "sal/main.h" 30cdf0e10cSrcweir #include <rtl/strbuf.hxx> 31cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx> 34cdf0e10cSrcweir #include <cppuhelper/shlib.hxx> 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include <com/sun/star/container/XSet.hpp> 37cdf0e10cSrcweir #include <com/sun/star/container/XContentEnumerationAccess.hpp> 38cdf0e10cSrcweir #include <com/sun/star/registry/XImplementationRegistration2.hpp> 39cdf0e10cSrcweir #include <com/sun/star/registry/XSimpleRegistry.hpp> 40cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 41cdf0e10cSrcweir 42cdf0e10cSrcweir #include <algorithm> 43cdf0e10cSrcweir #include <osl/process.h> 44cdf0e10cSrcweir #include <osl/diagnose.h> 45cdf0e10cSrcweir #include <osl/thread.h> 46cdf0e10cSrcweir #include <osl/file.hxx> 47cdf0e10cSrcweir 48cdf0e10cSrcweir #ifdef SAL_UNX 49cdf0e10cSrcweir #define SEPARATOR '/' 50cdf0e10cSrcweir #else 51cdf0e10cSrcweir #define SEPARATOR '\\' 52cdf0e10cSrcweir #endif 53cdf0e10cSrcweir 54cdf0e10cSrcweir using namespace ::rtl; 55cdf0e10cSrcweir using namespace ::osl; 56cdf0e10cSrcweir using namespace ::cppu; 57cdf0e10cSrcweir using namespace ::std; 58cdf0e10cSrcweir using namespace ::com::sun::star::uno; 59cdf0e10cSrcweir using namespace ::com::sun::star::lang; 60cdf0e10cSrcweir using namespace ::com::sun::star::registry; 61cdf0e10cSrcweir using com::sun::star::container::XSet; 62cdf0e10cSrcweir using com::sun::star::container::XContentEnumerationAccess; 63cdf0e10cSrcweir using com::sun::star::container::XEnumeration; 64cdf0e10cSrcweir 65cdf0e10cSrcweir namespace { 66cdf0e10cSrcweir 67cdf0e10cSrcweir OUString replacePrefix(OUString const & url, OUString const & prefix) { 68cdf0e10cSrcweir sal_Int32 i = url.lastIndexOf('/'); 69cdf0e10cSrcweir // Backward compatibility with stoc/source/implementationregistration/ 70cdf0e10cSrcweir // implreg.cxx:1.27 l. 1892: 71cdf0e10cSrcweir if (i == -1) { 72cdf0e10cSrcweir i = url.lastIndexOf('\\'); 73cdf0e10cSrcweir } 74cdf0e10cSrcweir return prefix + url.copy(i + 1); 75cdf0e10cSrcweir } 76cdf0e10cSrcweir 77cdf0e10cSrcweir } 78cdf0e10cSrcweir 79cdf0e10cSrcweir sal_Bool isFileUrl(const OUString& fileName) 80cdf0e10cSrcweir { 81cdf0e10cSrcweir if (fileName.indexOf(OUString::createFromAscii("file://")) == 0 ) 82cdf0e10cSrcweir return sal_True; 83cdf0e10cSrcweir return sal_False; 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir OUString convertToFileUrl(const OUString& fileName) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir if ( isFileUrl(fileName) ) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir return fileName; 91cdf0e10cSrcweir } 92cdf0e10cSrcweir 93cdf0e10cSrcweir OUString uUrlFileName; 94cdf0e10cSrcweir if ( fileName.indexOf('.') == 0 || fileName.indexOf(SEPARATOR) < 0 ) 95cdf0e10cSrcweir { 96cdf0e10cSrcweir OUString uWorkingDir; 97cdf0e10cSrcweir if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None) { 98cdf0e10cSrcweir OSL_ASSERT(false); 99cdf0e10cSrcweir } 100cdf0e10cSrcweir if (FileBase::getAbsoluteFileURL(uWorkingDir, fileName, uUrlFileName) 101cdf0e10cSrcweir != FileBase::E_None) 102cdf0e10cSrcweir { 103cdf0e10cSrcweir OSL_ASSERT(false); 104cdf0e10cSrcweir } 105cdf0e10cSrcweir } else 106cdf0e10cSrcweir { 107cdf0e10cSrcweir if (FileBase::getFileURLFromSystemPath(fileName, uUrlFileName) 108cdf0e10cSrcweir != FileBase::E_None) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir OSL_ASSERT(false); 111cdf0e10cSrcweir } 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir return uUrlFileName; 115cdf0e10cSrcweir } 116cdf0e10cSrcweir static void usingRegisterImpl() 117cdf0e10cSrcweir { 118cdf0e10cSrcweir fprintf(stderr, "usage: regcomp -register|revoke -r registryfile -c locationUrl [-br registryfile] [-l componentLoaderUrl] [-s] [-classpath path]\n"); 119cdf0e10cSrcweir fprintf(stderr, " Parameters:\n"); 120cdf0e10cSrcweir fprintf(stderr, " -register\n" 121cdf0e10cSrcweir " register a new component.\n"); 122cdf0e10cSrcweir fprintf(stderr, " -revoke\n" 123cdf0e10cSrcweir " revoke a component.\n"); 124cdf0e10cSrcweir fprintf(stderr, " -br registryfile\n" 125cdf0e10cSrcweir " the name of the registry used for bootstrapping\n" 126cdf0e10cSrcweir " regcomp. The option can be given twice, each\n" 127cdf0e10cSrcweir " one followed by exactly one registry file.\n" 128cdf0e10cSrcweir " The registries are used to access both types and\n" 129cdf0e10cSrcweir " registered components.\n"); 130cdf0e10cSrcweir fprintf(stderr, " -r registryfile\n" 131cdf0e10cSrcweir " the name of the target registry (will be created\n" 132cdf0e10cSrcweir " if it does not exists). The file name may match\n" 133cdf0e10cSrcweir " with one of the filenames given with the -br option.\n"); 134cdf0e10cSrcweir fprintf(stderr, " -c locationUrls\n" 135cdf0e10cSrcweir " the location of a component (a url to a shared\n" 136cdf0e10cSrcweir " library or a absolute url to a .jar file) or a\n" 137cdf0e10cSrcweir " list of urls seperated by ';' or ' '. Note if a\n" 138cdf0e10cSrcweir " list of urls is specified, the components must\n" 139cdf0e10cSrcweir " all need the same loader (quoting is possible with\n" 140cdf0e10cSrcweir " \\ or \"\").\n"); 141cdf0e10cSrcweir fprintf(stderr, " -l componentLoaderUrl\n" 142cdf0e10cSrcweir " the name of the needed loader. If no loader is\n" 143cdf0e10cSrcweir " specified and the components have a .jar suffix,\n" 144cdf0e10cSrcweir " the default is com.sun.star.loader.Java2.\n" 145cdf0e10cSrcweir " Otherwise, the default is\n" 146cdf0e10cSrcweir " com.sun.star.loader.SharedLibrary\n" 147cdf0e10cSrcweir " -s\n" 148cdf0e10cSrcweir " silent, regcomp prints messages only on error.\n" 149cdf0e10cSrcweir " -wop\n" 150cdf0e10cSrcweir " register the component name only without path\n" 151cdf0e10cSrcweir " -wop=prefix\n" 152cdf0e10cSrcweir " register the component name with path replaced\n" 153cdf0e10cSrcweir " by given prefix\n" 154cdf0e10cSrcweir " -classpath path\n" 155cdf0e10cSrcweir " sets the java classpath to path (overwriting the\n" 156cdf0e10cSrcweir " current classpath environment variable). Note that\n" 157cdf0e10cSrcweir " in case you start regcomp e.g. within an office\n" 158cdf0e10cSrcweir " environment, the classpath entries in the\n" 159cdf0e10cSrcweir " configuration still have precedence over this\n" 160cdf0e10cSrcweir " option.\n"); 161cdf0e10cSrcweir } 162cdf0e10cSrcweir 163cdf0e10cSrcweir class IllegalArgument 164cdf0e10cSrcweir { 165cdf0e10cSrcweir public: 166cdf0e10cSrcweir IllegalArgument(const OString& rMessage) 167cdf0e10cSrcweir : m_message(rMessage) 168cdf0e10cSrcweir {} 169cdf0e10cSrcweir 170cdf0e10cSrcweir OString m_message; 171cdf0e10cSrcweir }; 172cdf0e10cSrcweir 173cdf0e10cSrcweir struct Options 174cdf0e10cSrcweir { 175cdf0e10cSrcweir Options() 176cdf0e10cSrcweir : bRegister(sal_False) 177cdf0e10cSrcweir , bRevoke(sal_False) 178cdf0e10cSrcweir , bSilent( sal_False ) 179cdf0e10cSrcweir , bPrefix( sal_False ) 180cdf0e10cSrcweir {} 181cdf0e10cSrcweir 182cdf0e10cSrcweir sal_Bool bRegister; 183cdf0e10cSrcweir sal_Bool bRevoke; 184cdf0e10cSrcweir sal_Bool bSilent; 185cdf0e10cSrcweir sal_Bool bPrefix; 186cdf0e10cSrcweir OUString sPrefix; 187cdf0e10cSrcweir OUString sProgramName; 188cdf0e10cSrcweir OUString sBootRegName; 189cdf0e10cSrcweir OUString sBootRegName2; 190cdf0e10cSrcweir OUString sRegName; 191cdf0e10cSrcweir OUString sComponentUrls; 192cdf0e10cSrcweir OUString sLoaderName; 193cdf0e10cSrcweir }; 194cdf0e10cSrcweir 195cdf0e10cSrcweir sal_Bool parseOptions(int ac, char* av[], Options& rOptions, sal_Bool bCmdFile) 196cdf0e10cSrcweir throw( IllegalArgument ) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir sal_Bool ret = sal_True; 199cdf0e10cSrcweir sal_uInt16 i=0; 200cdf0e10cSrcweir sal_Bool bLoaderExplicitlyGiven = sal_False; 201cdf0e10cSrcweir 202cdf0e10cSrcweir rOptions.sProgramName = OUString::createFromAscii(av[i++]); 203cdf0e10cSrcweir 204cdf0e10cSrcweir if (!bCmdFile) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir bCmdFile = sal_True; 207cdf0e10cSrcweir 208cdf0e10cSrcweir if (ac < 2) 209cdf0e10cSrcweir { 210cdf0e10cSrcweir usingRegisterImpl(); 211cdf0e10cSrcweir ret = sal_False; 212cdf0e10cSrcweir } 213cdf0e10cSrcweir } 214cdf0e10cSrcweir 215cdf0e10cSrcweir for (; i < ac; i++) 216cdf0e10cSrcweir { 217cdf0e10cSrcweir if (av[i][0] == '-') 218cdf0e10cSrcweir { 219cdf0e10cSrcweir switch (av[i][1]) 220cdf0e10cSrcweir { 221cdf0e10cSrcweir case 'r': 222cdf0e10cSrcweir if (strcmp(av[i], "-register") == 0) 223cdf0e10cSrcweir { 224cdf0e10cSrcweir rOptions.bRegister = sal_True; 225cdf0e10cSrcweir } else 226cdf0e10cSrcweir if (strcmp(av[i], "-revoke") == 0) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir rOptions.bRevoke = sal_True; 229cdf0e10cSrcweir } else 230cdf0e10cSrcweir if (av[i][2] == '\0') 231cdf0e10cSrcweir { 232cdf0e10cSrcweir if (i < ac - 1 && av[i+1][0] != '-') 233cdf0e10cSrcweir { 234cdf0e10cSrcweir i++; 235cdf0e10cSrcweir rOptions.sRegName = OStringToOUString(av[i], osl_getThreadTextEncoding()); 236cdf0e10cSrcweir } else 237cdf0e10cSrcweir { 238cdf0e10cSrcweir OString tmp("'-r', please check"); 239cdf0e10cSrcweir if (i <= ac - 1) 240cdf0e10cSrcweir { 241cdf0e10cSrcweir tmp += " your input '" + OString(av[i+1]) + "'"; 242cdf0e10cSrcweir } 243cdf0e10cSrcweir throw IllegalArgument(tmp); 244cdf0e10cSrcweir } 245cdf0e10cSrcweir } else 246cdf0e10cSrcweir { 247cdf0e10cSrcweir rOptions.sRegName = OStringToOUString(av[i]+2, osl_getThreadTextEncoding()); 248cdf0e10cSrcweir } 249cdf0e10cSrcweir break; 250cdf0e10cSrcweir case 'b': 251cdf0e10cSrcweir if (av[i][2] != 'r') 252cdf0e10cSrcweir { 253cdf0e10cSrcweir OString tmp("'-b', invalid option!"); 254cdf0e10cSrcweir throw IllegalArgument(tmp); 255cdf0e10cSrcweir } 256cdf0e10cSrcweir if (av[i][3] == '\0') 257cdf0e10cSrcweir { 258cdf0e10cSrcweir if (i < ac - 1 && av[i+1][0] != '-') 259cdf0e10cSrcweir { 260cdf0e10cSrcweir i++; 261cdf0e10cSrcweir OUString regName = OStringToOUString(av[i], osl_getThreadTextEncoding()); 262cdf0e10cSrcweir if( ! rOptions.sBootRegName.getLength() ) 263cdf0e10cSrcweir { 264cdf0e10cSrcweir rOptions.sBootRegName = regName; 265cdf0e10cSrcweir } 266cdf0e10cSrcweir else 267cdf0e10cSrcweir { 268cdf0e10cSrcweir rOptions.sBootRegName2 = regName; 269cdf0e10cSrcweir } 270cdf0e10cSrcweir } else 271cdf0e10cSrcweir { 272cdf0e10cSrcweir OString tmp("'-br', please check"); 273cdf0e10cSrcweir if (i <= ac - 1) 274cdf0e10cSrcweir { 275cdf0e10cSrcweir tmp += " your input '" + OString(av[i+1]) + "'"; 276cdf0e10cSrcweir } 277cdf0e10cSrcweir throw IllegalArgument(tmp); 278cdf0e10cSrcweir } 279cdf0e10cSrcweir } else 280cdf0e10cSrcweir { 281cdf0e10cSrcweir rOptions.sBootRegName = OStringToOUString(av[i]+3, osl_getThreadTextEncoding()); 282cdf0e10cSrcweir } 283cdf0e10cSrcweir break; 284cdf0e10cSrcweir case 'c': 285cdf0e10cSrcweir { 286cdf0e10cSrcweir OUString sUrls; 287cdf0e10cSrcweir if (av[i][2] == '\0') 288cdf0e10cSrcweir { 289cdf0e10cSrcweir if (i < ac - 1 && av[i+1][0] != '-') 290cdf0e10cSrcweir { 291cdf0e10cSrcweir i++; 292cdf0e10cSrcweir sUrls = OStringToOUString(av[i], osl_getThreadTextEncoding()); 293cdf0e10cSrcweir } else 294cdf0e10cSrcweir { 295cdf0e10cSrcweir OString tmp("'-c', please check"); 296cdf0e10cSrcweir if (i <= ac - 1) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir tmp += " your input '" + OString(av[i+1]) + "'"; 299cdf0e10cSrcweir } 300cdf0e10cSrcweir throw IllegalArgument(tmp); 301cdf0e10cSrcweir } 302cdf0e10cSrcweir } 303cdf0e10cSrcweir else if( 0 == strncmp( av[i] , "-classpath" ,10 ) ) 304cdf0e10cSrcweir { 305cdf0e10cSrcweir i++; 306cdf0e10cSrcweir if( i < ac ) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir rtl::OUString envVar(RTL_CONSTASCII_USTRINGPARAM("CLASSPATH")); 309cdf0e10cSrcweir rtl::OUString envValue(av[i], strlen(av[i]), osl_getThreadTextEncoding()); 310cdf0e10cSrcweir osl_setEnvironment(envVar.pData, envValue.pData); 311cdf0e10cSrcweir } 312cdf0e10cSrcweir break; 313cdf0e10cSrcweir } 314cdf0e10cSrcweir else 315cdf0e10cSrcweir { 316cdf0e10cSrcweir sUrls = OStringToOUString(av[i]+2, osl_getThreadTextEncoding()); 317cdf0e10cSrcweir } 318cdf0e10cSrcweir 319cdf0e10cSrcweir if (rOptions.sComponentUrls.getLength()) 320cdf0e10cSrcweir { 321cdf0e10cSrcweir OUString tmp(rOptions.sComponentUrls + OUString(";", 1, osl_getThreadTextEncoding()) + sUrls); 322cdf0e10cSrcweir rOptions.sComponentUrls = tmp; 323cdf0e10cSrcweir } else 324cdf0e10cSrcweir { 325cdf0e10cSrcweir rOptions.sComponentUrls = sUrls; 326cdf0e10cSrcweir } 327cdf0e10cSrcweir break; 328cdf0e10cSrcweir } 329cdf0e10cSrcweir case 'l': 330cdf0e10cSrcweir { 331cdf0e10cSrcweir if (av[i][2] == '\0') 332cdf0e10cSrcweir { 333cdf0e10cSrcweir if (i < ac - 1 && av[i+1][0] != '-') 334cdf0e10cSrcweir { 335cdf0e10cSrcweir i++; 336cdf0e10cSrcweir rOptions.sLoaderName = OUString::createFromAscii(av[i]); 337cdf0e10cSrcweir bLoaderExplicitlyGiven = sal_True; 338cdf0e10cSrcweir } else 339cdf0e10cSrcweir { 340cdf0e10cSrcweir OString tmp("'-l', please check"); 341cdf0e10cSrcweir if (i <= ac - 1) 342cdf0e10cSrcweir { 343cdf0e10cSrcweir tmp += " your input '" + OString(av[i+1]) + "'"; 344cdf0e10cSrcweir } 345cdf0e10cSrcweir throw IllegalArgument(tmp); 346cdf0e10cSrcweir } 347cdf0e10cSrcweir } else 348cdf0e10cSrcweir { 349cdf0e10cSrcweir bLoaderExplicitlyGiven = sal_True; 350cdf0e10cSrcweir rOptions.sLoaderName = OUString::createFromAscii(av[i]+2); 351cdf0e10cSrcweir } 352cdf0e10cSrcweir break; 353cdf0e10cSrcweir } 354cdf0e10cSrcweir case 's': 355cdf0e10cSrcweir { 356cdf0e10cSrcweir if( av[i][2] == 0 ) 357cdf0e10cSrcweir { 358cdf0e10cSrcweir rOptions.bSilent = sal_True; 359cdf0e10cSrcweir } 360cdf0e10cSrcweir else 361cdf0e10cSrcweir { 362cdf0e10cSrcweir rtl::OStringBuffer buf; 363cdf0e10cSrcweir buf.append( "Unknown error " ); 364cdf0e10cSrcweir buf.append( av[i] ); 365cdf0e10cSrcweir throw IllegalArgument( av[i] ); 366cdf0e10cSrcweir } 367cdf0e10cSrcweir break; 368cdf0e10cSrcweir } 369cdf0e10cSrcweir case 'e': 370cdf0e10cSrcweir { 371cdf0e10cSrcweir if( av[i][2] == 'n' && av[i][3] == 'v' && av[i][4] == ':' ) 372cdf0e10cSrcweir { 373cdf0e10cSrcweir // bootstrap variable, ignore it 374cdf0e10cSrcweir break; 375cdf0e10cSrcweir } 376cdf0e10cSrcweir } 377cdf0e10cSrcweir case 'w': 378cdf0e10cSrcweir { 379cdf0e10cSrcweir if (strcmp(av[i], "-wop") == 0) 380cdf0e10cSrcweir { 381cdf0e10cSrcweir rOptions.bPrefix = sal_True; 382cdf0e10cSrcweir rOptions.sPrefix = OUString(); 383cdf0e10cSrcweir // in case there are multiple -wops 384cdf0e10cSrcweir break; 385cdf0e10cSrcweir } 386cdf0e10cSrcweir else if ( 387cdf0e10cSrcweir strncmp(av[i], "-wop=", RTL_CONSTASCII_LENGTH("-wop=")) 388cdf0e10cSrcweir == 0) 389cdf0e10cSrcweir { 390cdf0e10cSrcweir rOptions.bPrefix = sal_True; 391cdf0e10cSrcweir rOptions.sPrefix = OStringToOUString( 392cdf0e10cSrcweir av[i] + RTL_CONSTASCII_LENGTH("-wop="), 393cdf0e10cSrcweir osl_getThreadTextEncoding()); 394cdf0e10cSrcweir break; 395cdf0e10cSrcweir } 396cdf0e10cSrcweir } 397cdf0e10cSrcweir default: 398cdf0e10cSrcweir { 399cdf0e10cSrcweir OString tmp( "unknown option " ); 400cdf0e10cSrcweir tmp += av[i]; 401cdf0e10cSrcweir throw IllegalArgument( tmp ); 402cdf0e10cSrcweir } 403cdf0e10cSrcweir } 404cdf0e10cSrcweir } else 405cdf0e10cSrcweir { 406cdf0e10cSrcweir if (av[i][0] == '@') 407cdf0e10cSrcweir { 408cdf0e10cSrcweir FILE* cmdFile = fopen(av[i]+1, "r"); 409cdf0e10cSrcweir if( cmdFile == NULL ) 410cdf0e10cSrcweir { 411cdf0e10cSrcweir usingRegisterImpl(); 412cdf0e10cSrcweir ret = sal_False; 413cdf0e10cSrcweir } else 414cdf0e10cSrcweir { 415cdf0e10cSrcweir fseek( cmdFile , 0 , SEEK_END ); 416cdf0e10cSrcweir sal_Int32 nLen = ftell( cmdFile); 417cdf0e10cSrcweir fseek( cmdFile, 0, SEEK_SET ); 418cdf0e10cSrcweir 419cdf0e10cSrcweir // 2 chars per string is a upper limit for the number of 420cdf0e10cSrcweir // substrings ( at least one separator char needed for fscanf). 421cdf0e10cSrcweir char ** rargv = (char **)rtl_allocateMemory( nLen * sizeof( char* ) /2); 422cdf0e10cSrcweir if( ! rargv ) 423cdf0e10cSrcweir { 424cdf0e10cSrcweir OStringBuffer buf; 425cdf0e10cSrcweir buf.append( "Not enough memory for reading command file " ); 426cdf0e10cSrcweir buf.append( av[i] +1 ); 427cdf0e10cSrcweir buf.append( " with length " ); 428cdf0e10cSrcweir buf.append( nLen ); 429cdf0e10cSrcweir buf.append( "." ); 430cdf0e10cSrcweir throw IllegalArgument( buf.makeStringAndClear() ); 431cdf0e10cSrcweir } 432cdf0e10cSrcweir char *buffer = ( char * )rtl_allocateMemory( nLen +1 ); 433cdf0e10cSrcweir if( ! buffer ) 434cdf0e10cSrcweir { 435cdf0e10cSrcweir OStringBuffer buf; 436cdf0e10cSrcweir buf.append( "Not enough memory for reading command file " ); 437cdf0e10cSrcweir buf.append( av[i] +1 ); 438cdf0e10cSrcweir buf.append( " with length " ); 439cdf0e10cSrcweir buf.append( nLen ); 440cdf0e10cSrcweir buf.append( "." ); 441cdf0e10cSrcweir throw IllegalArgument( buf.makeStringAndClear() ); 442cdf0e10cSrcweir } 443cdf0e10cSrcweir 444cdf0e10cSrcweir // we start at one to omit argv[0] 445cdf0e10cSrcweir sal_Int32 rargc = 1; 446cdf0e10cSrcweir rargv[0] = av[0]; 447cdf0e10cSrcweir while ( fscanf(cmdFile, "%s", buffer) != EOF ) 448cdf0e10cSrcweir { 449cdf0e10cSrcweir rargv[rargc]= (char * )rtl_allocateMemory( strlen( buffer ) +1 ); 450cdf0e10cSrcweir if( ! rargv[rargc] ) 451cdf0e10cSrcweir { 452cdf0e10cSrcweir OStringBuffer buf; 453cdf0e10cSrcweir buf.append( "Not enough memory for reading command file " ); 454cdf0e10cSrcweir buf.append( av[i] +1 ); 455cdf0e10cSrcweir buf.append( " with length " ); 456cdf0e10cSrcweir buf.append( nLen ); 457cdf0e10cSrcweir buf.append( "." ); 458cdf0e10cSrcweir throw IllegalArgument( buf.makeStringAndClear() ); 459cdf0e10cSrcweir } 460cdf0e10cSrcweir strcpy( rargv[rargc] , buffer ); // #100211# - checked 461cdf0e10cSrcweir rargc++; 462cdf0e10cSrcweir } 463cdf0e10cSrcweir fclose(cmdFile); 464cdf0e10cSrcweir 465cdf0e10cSrcweir parseOptions(rargc, rargv, rOptions, bCmdFile); 466cdf0e10cSrcweir 467cdf0e10cSrcweir for (long j=1; j < rargc; j++) 468cdf0e10cSrcweir { 469cdf0e10cSrcweir rtl_freeMemory(rargv[j]); 470cdf0e10cSrcweir } 471cdf0e10cSrcweir rtl_freeMemory( buffer ); 472cdf0e10cSrcweir rtl_freeMemory( rargv ); 473cdf0e10cSrcweir } 474cdf0e10cSrcweir } else 475cdf0e10cSrcweir { 476cdf0e10cSrcweir usingRegisterImpl(); 477cdf0e10cSrcweir ret = sal_False; 478cdf0e10cSrcweir } 479cdf0e10cSrcweir } 480cdf0e10cSrcweir } 481cdf0e10cSrcweir 482cdf0e10cSrcweir if( ! bLoaderExplicitlyGiven ) 483cdf0e10cSrcweir { 484cdf0e10cSrcweir if ( rOptions.sComponentUrls.getLength() > 4 && 485cdf0e10cSrcweir rOptions.sComponentUrls.matchAsciiL( 486cdf0e10cSrcweir ".jar" , 4 , rOptions.sComponentUrls.getLength() - 4 ) ) 487cdf0e10cSrcweir { 488cdf0e10cSrcweir if( ! rOptions.bSilent ) 489cdf0e10cSrcweir { 490cdf0e10cSrcweir printf( "using loader com.sun.star.loader.Java2\n" ); 491cdf0e10cSrcweir } 492cdf0e10cSrcweir rOptions.sLoaderName = OUString( 493cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.Java2")); 494cdf0e10cSrcweir } 495cdf0e10cSrcweir else 496cdf0e10cSrcweir { 497cdf0e10cSrcweir rOptions.sLoaderName = OUString( 498cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.SharedLibrary") ); 499cdf0e10cSrcweir } 500cdf0e10cSrcweir } 501cdf0e10cSrcweir 502cdf0e10cSrcweir return ret; 503cdf0e10cSrcweir } 504cdf0e10cSrcweir 505cdf0e10cSrcweir 506cdf0e10cSrcweir struct DoIt 507cdf0e10cSrcweir { 508cdf0e10cSrcweir sal_Bool _bRegister; 509cdf0e10cSrcweir sal_Bool _bRevoke; 510cdf0e10cSrcweir sal_Bool _bSilent; 511cdf0e10cSrcweir sal_Bool _bPrefix; 512cdf0e10cSrcweir OUString _sPrefix; 513cdf0e10cSrcweir OString _sRegName; 514cdf0e10cSrcweir OUString _sLoaderName; 515cdf0e10cSrcweir Reference<XImplementationRegistration2> _xImplRegistration; 516cdf0e10cSrcweir Reference<XSimpleRegistry> _xReg; 517cdf0e10cSrcweir sal_uInt32 * _exitCode; 518cdf0e10cSrcweir 519cdf0e10cSrcweir DoIt(sal_Bool bRegister, 520cdf0e10cSrcweir sal_Bool bRevoke, 521cdf0e10cSrcweir sal_Bool bSilent, 522cdf0e10cSrcweir sal_Bool bPrefix, 523cdf0e10cSrcweir const OUString & sPrefix, 524cdf0e10cSrcweir const Reference<XSimpleRegistry> & xReg, 525cdf0e10cSrcweir const OString & sRegName, 526cdf0e10cSrcweir const Reference<XImplementationRegistration2> & xImplRegistration, 527cdf0e10cSrcweir const OUString & sLoaderName, 528cdf0e10cSrcweir sal_uInt32 * exitCode) 529cdf0e10cSrcweir throw(); 530cdf0e10cSrcweir 531cdf0e10cSrcweir void operator()(const OUString & url) throw(); 532cdf0e10cSrcweir }; 533cdf0e10cSrcweir 534cdf0e10cSrcweir DoIt::DoIt(sal_Bool bRegister, 535cdf0e10cSrcweir sal_Bool bRevoke, 536cdf0e10cSrcweir sal_Bool bSilent, 537cdf0e10cSrcweir sal_Bool bPrefix, 538cdf0e10cSrcweir const OUString & sPrefix, 539cdf0e10cSrcweir const Reference<XSimpleRegistry> & xReg, 540cdf0e10cSrcweir const OString & sRegName, 541cdf0e10cSrcweir const Reference<XImplementationRegistration2> & xImplRegistration, 542cdf0e10cSrcweir const OUString & sLoaderName, 543cdf0e10cSrcweir sal_uInt32 * exitCode) throw() 544cdf0e10cSrcweir : _bRegister(bRegister), 545cdf0e10cSrcweir _bRevoke(bRevoke), 546cdf0e10cSrcweir _bSilent( bSilent ), 547cdf0e10cSrcweir _bPrefix( bPrefix ), 548cdf0e10cSrcweir _sPrefix( sPrefix ), 549cdf0e10cSrcweir _sRegName(sRegName), 550cdf0e10cSrcweir _sLoaderName(sLoaderName), 551cdf0e10cSrcweir _xImplRegistration(xImplRegistration), 552cdf0e10cSrcweir _xReg(xReg), 553cdf0e10cSrcweir _exitCode(exitCode) 554cdf0e10cSrcweir {} 555cdf0e10cSrcweir 556cdf0e10cSrcweir void DoIt::operator() (const OUString & url) throw() 557cdf0e10cSrcweir { 558cdf0e10cSrcweir OString sUrl = OUStringToOString(url, osl_getThreadTextEncoding()); 559cdf0e10cSrcweir 560cdf0e10cSrcweir if (_bRegister) 561cdf0e10cSrcweir { 562cdf0e10cSrcweir try 563cdf0e10cSrcweir { 564cdf0e10cSrcweir Reference<XImplementationRegistration2> _xImplRegistration2(_xImplRegistration, UNO_QUERY); 565cdf0e10cSrcweir if ( _bPrefix ) { 566cdf0e10cSrcweir _xImplRegistration->registerImplementationWithLocation( 567cdf0e10cSrcweir _sLoaderName, url, replacePrefix(url, _sPrefix), _xReg); 568cdf0e10cSrcweir } else { 569cdf0e10cSrcweir _xImplRegistration->registerImplementation(_sLoaderName, url, _xReg); 570cdf0e10cSrcweir } 571cdf0e10cSrcweir 572cdf0e10cSrcweir if ( ! _bSilent ) 573cdf0e10cSrcweir { 574cdf0e10cSrcweir fprintf(stderr, "register component '%s' in registry '%s' successful!\n", sUrl.getStr(), _sRegName.getStr()); 575cdf0e10cSrcweir } 576cdf0e10cSrcweir 577cdf0e10cSrcweir } 578cdf0e10cSrcweir catch(CannotRegisterImplementationException & cannotRegisterImplementationException) { 579cdf0e10cSrcweir OString aMessage(OUStringToOString(cannotRegisterImplementationException.Message, RTL_TEXTENCODING_ASCII_US)); 580cdf0e10cSrcweir fprintf(stderr, "register component '%s' in registry '%s' failed!\n", sUrl.getStr(), _sRegName.getStr()); 581cdf0e10cSrcweir fprintf(stderr, "error (CannotRegisterImplementationException): %s\n", aMessage.getStr()); 582cdf0e10cSrcweir 583cdf0e10cSrcweir ++ (*_exitCode); 584cdf0e10cSrcweir } 585cdf0e10cSrcweir catch( RuntimeException & e ) 586cdf0e10cSrcweir { 587cdf0e10cSrcweir OString aMessage(OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US)); 588cdf0e10cSrcweir fprintf(stderr, "register component '%s' in registry '%s' failed!\n", sUrl.getStr(), _sRegName.getStr()); 589cdf0e10cSrcweir fprintf(stderr, "error (RuntimeException): %s\n", aMessage.getStr()); 590cdf0e10cSrcweir 591cdf0e10cSrcweir ++ (*_exitCode); 592cdf0e10cSrcweir } 593cdf0e10cSrcweir } 594cdf0e10cSrcweir else if(_bRevoke) 595cdf0e10cSrcweir { 596cdf0e10cSrcweir try 597cdf0e10cSrcweir { 598cdf0e10cSrcweir sal_Bool bRet = _xImplRegistration->revokeImplementation(url, _xReg); 599cdf0e10cSrcweir 600cdf0e10cSrcweir if (bRet) 601cdf0e10cSrcweir { 602cdf0e10cSrcweir if ( ! _bSilent ) 603cdf0e10cSrcweir fprintf(stderr, "revoke component '%s' from registry '%s' successful!\n", sUrl.getStr(), _sRegName.getStr()); 604cdf0e10cSrcweir } 605cdf0e10cSrcweir else 606cdf0e10cSrcweir { 607cdf0e10cSrcweir fprintf(stderr, "revoke component '%s' from registry '%s' failed!\n", sUrl.getStr(), _sRegName.getStr()); 608cdf0e10cSrcweir ++ (*_exitCode); 609cdf0e10cSrcweir } 610cdf0e10cSrcweir } 611cdf0e10cSrcweir catch( RuntimeException & e ) 612cdf0e10cSrcweir { 613cdf0e10cSrcweir OString aMessage(OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US)); 614cdf0e10cSrcweir fprintf( stderr, 615cdf0e10cSrcweir "revoke component '%s' from registry '%s' failed!\n", 616cdf0e10cSrcweir sUrl.getStr(), 617cdf0e10cSrcweir _sRegName.getStr() ); 618cdf0e10cSrcweir fprintf( stderr, "RuntimeException: %s\n" , aMessage.getStr()); 619cdf0e10cSrcweir ++ (*_exitCode); 620cdf0e10cSrcweir } 621cdf0e10cSrcweir } 622cdf0e10cSrcweir } 623cdf0e10cSrcweir 624cdf0e10cSrcweir static bool hasService( 625cdf0e10cSrcweir const Reference< XMultiServiceFactory > &xSMgr, 626cdf0e10cSrcweir const sal_Char * service ) 627cdf0e10cSrcweir { 628cdf0e10cSrcweir bool ret = false; 629cdf0e10cSrcweir 630cdf0e10cSrcweir Reference< XContentEnumerationAccess > access( xSMgr, UNO_QUERY ); 631cdf0e10cSrcweir if( access.is( )) 632cdf0e10cSrcweir { 633cdf0e10cSrcweir Reference< XEnumeration > enumeration = access->createContentEnumeration( 634cdf0e10cSrcweir OUString::createFromAscii( service ) ); 635cdf0e10cSrcweir 636cdf0e10cSrcweir if( enumeration.is() && enumeration->hasMoreElements() ) 637cdf0e10cSrcweir { 638cdf0e10cSrcweir ret = true; 639cdf0e10cSrcweir } 640cdf0e10cSrcweir } 641cdf0e10cSrcweir return ret; 642cdf0e10cSrcweir } 643cdf0e10cSrcweir 644cdf0e10cSrcweir static void bootstrap( 645cdf0e10cSrcweir Options & opt , 646cdf0e10cSrcweir Reference< XMultiServiceFactory > &xSMgr, 647cdf0e10cSrcweir Reference< XSimpleRegistry > & reg ) throw ( Exception ) 648cdf0e10cSrcweir { 649cdf0e10cSrcweir if( opt.sRegName.equals( opt.sBootRegName2 ) ) 650cdf0e10cSrcweir { 651cdf0e10cSrcweir OUString tmp2 = opt.sBootRegName; 652cdf0e10cSrcweir opt.sBootRegName = opt.sBootRegName2; 653cdf0e10cSrcweir opt.sBootRegName2 = tmp2; 654cdf0e10cSrcweir } 655cdf0e10cSrcweir 656cdf0e10cSrcweir if ( opt.sRegName.equals(opt.sBootRegName) ) 657cdf0e10cSrcweir { 658cdf0e10cSrcweir if( opt.sBootRegName2.getLength() ) 659cdf0e10cSrcweir { 660cdf0e10cSrcweir xSMgr = createRegistryServiceFactory( 661cdf0e10cSrcweir convertToFileUrl(opt.sRegName), 662cdf0e10cSrcweir convertToFileUrl(opt.sBootRegName2), 663cdf0e10cSrcweir sal_False ); 664cdf0e10cSrcweir } 665cdf0e10cSrcweir else 666cdf0e10cSrcweir { 667cdf0e10cSrcweir xSMgr = createRegistryServiceFactory( 668cdf0e10cSrcweir convertToFileUrl(opt.sRegName) , sal_False ); 669cdf0e10cSrcweir } 670cdf0e10cSrcweir } 671cdf0e10cSrcweir else 672cdf0e10cSrcweir { 673cdf0e10cSrcweir if( opt.sBootRegName2.getLength() ) 674cdf0e10cSrcweir { 675cdf0e10cSrcweir xSMgr = createRegistryServiceFactory( 676cdf0e10cSrcweir convertToFileUrl( opt.sBootRegName2 ), 677cdf0e10cSrcweir convertToFileUrl( opt.sBootRegName ), 678cdf0e10cSrcweir sal_True ); 679cdf0e10cSrcweir } 680cdf0e10cSrcweir else if ( opt.sBootRegName.getLength() ) 681cdf0e10cSrcweir { 682cdf0e10cSrcweir xSMgr = createRegistryServiceFactory( 683cdf0e10cSrcweir convertToFileUrl( opt.sBootRegName ), 684cdf0e10cSrcweir sal_True ); 685cdf0e10cSrcweir } 686cdf0e10cSrcweir else 687cdf0e10cSrcweir { 688cdf0e10cSrcweir xSMgr = createServiceFactory(); 689cdf0e10cSrcweir } 690cdf0e10cSrcweir reg = Reference< XSimpleRegistry >( 691cdf0e10cSrcweir xSMgr->createInstance( 692cdf0e10cSrcweir rtl::OUString::createFromAscii("com.sun.star.registry.SimpleRegistry")), UNO_QUERY); 693cdf0e10cSrcweir 694cdf0e10cSrcweir if (reg.is()) 695cdf0e10cSrcweir { 696cdf0e10cSrcweir try 697cdf0e10cSrcweir { 698cdf0e10cSrcweir reg->open( convertToFileUrl(opt.sRegName), sal_False, sal_True); 699cdf0e10cSrcweir if (!reg->isValid()) 700cdf0e10cSrcweir { 701cdf0e10cSrcweir fprintf(stderr, "ERROR: open|create registry '%s' failed!\n", 702cdf0e10cSrcweir OUStringToOString(opt.sRegName, osl_getThreadTextEncoding() ).getStr()); 703cdf0e10cSrcweir exit(1); 704cdf0e10cSrcweir } 705cdf0e10cSrcweir } 706cdf0e10cSrcweir catch( InvalidRegistryException & e) 707cdf0e10cSrcweir { 708cdf0e10cSrcweir OString o = OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ); 709cdf0e10cSrcweir fprintf(stderr, 710cdf0e10cSrcweir "ERROR: create registry '%s' failed!\n" 711cdf0e10cSrcweir "InvalidRegistryException: %s\n", 712cdf0e10cSrcweir OUStringToOString( opt.sRegName, osl_getThreadTextEncoding()).getStr(), 713cdf0e10cSrcweir o.getStr() ); 714cdf0e10cSrcweir exit(1); 715cdf0e10cSrcweir } 716cdf0e10cSrcweir } 717cdf0e10cSrcweir } 718cdf0e10cSrcweir 719cdf0e10cSrcweir if( ! opt.sLoaderName.compareToAscii( "com.sun.star.loader.Java2" ) && 720cdf0e10cSrcweir ! hasService( xSMgr, "com.sun.star.loader.Java2" ) ) 721cdf0e10cSrcweir { 722cdf0e10cSrcweir // we know our java loader, so we check, whether a java-loader is 723cdf0e10cSrcweir // registered 724cdf0e10cSrcweir Reference< XInterface > r = loadSharedLibComponentFactory( 725cdf0e10cSrcweir OUString::createFromAscii( "javavm.uno" SAL_DLLEXTENSION ), 726cdf0e10cSrcweir OUString(), 727cdf0e10cSrcweir OUString::createFromAscii( "com.sun.star.comp.stoc.JavaVirtualMachine" ), 728cdf0e10cSrcweir xSMgr, 729cdf0e10cSrcweir Reference< XRegistryKey > () ); 730cdf0e10cSrcweir Reference< XInterface > r2 = loadSharedLibComponentFactory( 731cdf0e10cSrcweir OUString::createFromAscii( "javaloader.uno" SAL_DLLEXTENSION ), 732cdf0e10cSrcweir OUString(), 733cdf0e10cSrcweir OUString::createFromAscii(( "com.sun.star.comp.stoc.JavaComponentLoader" ) ), 734cdf0e10cSrcweir xSMgr, 735cdf0e10cSrcweir Reference< XRegistryKey > () ); 736cdf0e10cSrcweir Reference <XSet> xSet( xSMgr, UNO_QUERY ); 737cdf0e10cSrcweir if( r.is() && r2.is() && xSet.is() ) 738cdf0e10cSrcweir { 739cdf0e10cSrcweir xSet->insert( makeAny( r ) ); 740cdf0e10cSrcweir xSet->insert( makeAny( r2 ) ); 741cdf0e10cSrcweir } 742cdf0e10cSrcweir } 743cdf0e10cSrcweir } 744cdf0e10cSrcweir 745cdf0e10cSrcweir SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) 746cdf0e10cSrcweir { 747cdf0e10cSrcweir sal_Bool bRet = sal_False; 748cdf0e10cSrcweir sal_uInt32 exitCode = 0; 749cdf0e10cSrcweir Options aOptions; 750cdf0e10cSrcweir 751cdf0e10cSrcweir try 752cdf0e10cSrcweir { 753cdf0e10cSrcweir if ( !parseOptions(argc, argv, aOptions, sal_False) ) 754cdf0e10cSrcweir { 755cdf0e10cSrcweir exit(1); 756cdf0e10cSrcweir } 757cdf0e10cSrcweir } 758cdf0e10cSrcweir catch ( IllegalArgument& e) 759cdf0e10cSrcweir { 760cdf0e10cSrcweir fprintf(stderr, "ERROR: %s\n", e.m_message.getStr()); 761cdf0e10cSrcweir exit(1); 762cdf0e10cSrcweir } 763cdf0e10cSrcweir 764cdf0e10cSrcweir if( ! aOptions.sRegName.getLength() ) 765cdf0e10cSrcweir { 766cdf0e10cSrcweir fprintf( stderr, "ERROR: target registry missing (-r option)\n" ); 767cdf0e10cSrcweir exit( 1 ); 768cdf0e10cSrcweir } 769cdf0e10cSrcweir if ( aOptions.sComponentUrls.getLength() == 0 ) 770cdf0e10cSrcweir { 771cdf0e10cSrcweir fprintf(stderr, "ERROR: no component url is specified!\n"); 772cdf0e10cSrcweir exit(1); 773cdf0e10cSrcweir } 774cdf0e10cSrcweir 775cdf0e10cSrcweir Reference< XMultiServiceFactory > xSMgr; 776cdf0e10cSrcweir Reference< XSimpleRegistry > xReg; 777cdf0e10cSrcweir try 778cdf0e10cSrcweir { 779cdf0e10cSrcweir bootstrap( aOptions, xSMgr ,xReg ); 780cdf0e10cSrcweir } 781cdf0e10cSrcweir catch( Exception& e ) 782cdf0e10cSrcweir { 783cdf0e10cSrcweir fprintf(stderr, "ERROR: create ServiceManager failed!\n"); 784cdf0e10cSrcweir if ( e.Message.getLength() ) 785cdf0e10cSrcweir { 786cdf0e10cSrcweir fprintf(stderr, "ERROR description: %s\n", 787cdf0e10cSrcweir OUStringToOString(e.Message, osl_getThreadTextEncoding()).getStr()); 788cdf0e10cSrcweir } 789cdf0e10cSrcweir exit(1); 790cdf0e10cSrcweir } 791cdf0e10cSrcweir 792cdf0e10cSrcweir Reference<XImplementationRegistration2> xImplRegistration( 793cdf0e10cSrcweir xSMgr->createInstance( 794cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM( 795cdf0e10cSrcweir "com.sun.star.registry.ImplementationRegistration"))), 796cdf0e10cSrcweir UNO_QUERY); 797cdf0e10cSrcweir 798cdf0e10cSrcweir if (xImplRegistration.is()) 799cdf0e10cSrcweir { 800cdf0e10cSrcweir sal_Int32 index = 0; 801cdf0e10cSrcweir vector<OUString> urls; 802cdf0e10cSrcweir 803cdf0e10cSrcweir OUString urlListWithSemikolon = aOptions.sComponentUrls; 804cdf0e10cSrcweir do { 805cdf0e10cSrcweir OUString aToken = urlListWithSemikolon.getToken( 0, ';', index); 806cdf0e10cSrcweir fprintf(stderr, "%s\n", OUStringToOString(aToken, osl_getThreadTextEncoding()).getStr()); 807cdf0e10cSrcweir urls.push_back(aToken); 808cdf0e10cSrcweir } while ( index >= 0 ); 809cdf0e10cSrcweir 810cdf0e10cSrcweir 811cdf0e10cSrcweir OString sRegName = OUStringToOString( aOptions.sRegName, osl_getThreadTextEncoding() ); 812cdf0e10cSrcweir if(aOptions.bRegister || aOptions.bRevoke) 813cdf0e10cSrcweir { 814cdf0e10cSrcweir for_each(urls.begin(), urls.end(), 815cdf0e10cSrcweir DoIt(aOptions.bRegister, aOptions.bRevoke, aOptions.bSilent, 816cdf0e10cSrcweir aOptions.bPrefix, aOptions.sPrefix, 817cdf0e10cSrcweir xReg, sRegName, xImplRegistration, 818cdf0e10cSrcweir aOptions.sLoaderName, &exitCode)); 819cdf0e10cSrcweir } 820cdf0e10cSrcweir else 821cdf0e10cSrcweir { 822cdf0e10cSrcweir ++ exitCode; 823cdf0e10cSrcweir usingRegisterImpl(); 824cdf0e10cSrcweir } 825cdf0e10cSrcweir } 826cdf0e10cSrcweir else 827cdf0e10cSrcweir { 828cdf0e10cSrcweir fprintf(stderr, "Component registration service could not be loaded!\n"); 829cdf0e10cSrcweir exitCode++; 830cdf0e10cSrcweir } 831cdf0e10cSrcweir 832cdf0e10cSrcweir if (!bRet && xReg.is() && xReg->isValid()) 833cdf0e10cSrcweir xReg->close(); 834cdf0e10cSrcweir 835cdf0e10cSrcweir Reference< XComponent > xComponent( xSMgr, UNO_QUERY ); 836cdf0e10cSrcweir if ( xComponent.is() ) 837cdf0e10cSrcweir xComponent->dispose(); 838cdf0e10cSrcweir 839cdf0e10cSrcweir return exitCode; 840cdf0e10cSrcweir } 841cdf0e10cSrcweir 842cdf0e10cSrcweir 843