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