update dev300-m58
[ooovba.git] / cpputools / source / registercomponent / registercomponent.cxx
blobd0c031b8893aa7c984d315c3fefbaed2cc9de10e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: registercomponent.cxx,v $
10 * $Revision: 1.21 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <string.h>
34 #include <vector>
36 #include "sal/main.h"
37 #include <rtl/strbuf.hxx>
38 #include <rtl/ustrbuf.hxx>
40 #include <cppuhelper/servicefactory.hxx>
41 #include <cppuhelper/shlib.hxx>
43 #include <com/sun/star/container/XSet.hpp>
44 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
45 #include <com/sun/star/registry/XImplementationRegistration2.hpp>
46 #include <com/sun/star/registry/XSimpleRegistry.hpp>
47 #include <com/sun/star/lang/XComponent.hpp>
49 #include <algorithm>
50 #include <osl/process.h>
51 #include <osl/diagnose.h>
52 #include <osl/thread.h>
53 #include <osl/file.hxx>
55 #ifdef SAL_UNX
56 #define SEPARATOR '/'
57 #else
58 #define SEPARATOR '\\'
59 #endif
61 using namespace ::rtl;
62 using namespace ::osl;
63 using namespace ::cppu;
64 using namespace ::std;
65 using namespace ::com::sun::star::uno;
66 using namespace ::com::sun::star::lang;
67 using namespace ::com::sun::star::registry;
68 using com::sun::star::container::XSet;
69 using com::sun::star::container::XContentEnumerationAccess;
70 using com::sun::star::container::XEnumeration;
72 #ifdef SAL_W32
73 #define putenv _putenv
74 #endif
76 namespace {
78 OUString replacePrefix(OUString const & url, OUString const & prefix) {
79 sal_Int32 i = url.lastIndexOf('/');
80 // Backward compatibility with stoc/source/implementationregistration/
81 // implreg.cxx:1.27 l. 1892:
82 if (i == -1) {
83 i = url.lastIndexOf('\\');
85 return prefix + url.copy(i + 1);
90 sal_Bool isFileUrl(const OUString& fileName)
92 if (fileName.indexOf(OUString::createFromAscii("file://")) == 0 )
93 return sal_True;
94 return sal_False;
97 OUString convertToFileUrl(const OUString& fileName)
99 if ( isFileUrl(fileName) )
101 return fileName;
104 OUString uUrlFileName;
105 if ( fileName.indexOf('.') == 0 || fileName.indexOf(SEPARATOR) < 0 )
107 OUString uWorkingDir;
108 if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None) {
109 OSL_ASSERT(false);
111 if (FileBase::getAbsoluteFileURL(uWorkingDir, fileName, uUrlFileName)
112 != FileBase::E_None)
114 OSL_ASSERT(false);
116 } else
118 if (FileBase::getFileURLFromSystemPath(fileName, uUrlFileName)
119 != FileBase::E_None)
121 OSL_ASSERT(false);
125 return uUrlFileName;
127 static void usingRegisterImpl()
129 fprintf(stderr, "usage: regcomp -register|revoke -r registryfile -c locationUrl [-br registryfile] [-l componentLoaderUrl] [-s] [-classpath path]\n");
130 fprintf(stderr, " Parameters:\n");
131 fprintf(stderr, " -register\n"
132 " register a new component.\n");
133 fprintf(stderr, " -revoke\n"
134 " revoke a component.\n");
135 fprintf(stderr, " -br registryfile\n"
136 " the name of the registry used for bootstrapping\n"
137 " regcomp. The option can be given twice, each\n"
138 " one followed by exactly one registry file.\n"
139 " The registries are used to access both types and\n"
140 " registered components.\n");
141 fprintf(stderr, " -r registryfile\n"
142 " the name of the target registry (will be created\n"
143 " if it does not exists). The file name may match\n"
144 " with one of the filenames given with the -br option.\n");
145 fprintf(stderr, " -c locationUrls\n"
146 " the location of a component (a url to a shared\n"
147 " library or a absolute url to a .jar file) or a\n"
148 " list of urls seperated by ';' or ' '. Note if a\n"
149 " list of urls is specified, the components must\n"
150 " all need the same loader (quoting is possible with\n"
151 " \\ or \"\").\n");
152 fprintf(stderr, " -l componentLoaderUrl\n"
153 " the name of the needed loader. If no loader is\n"
154 " specified and the components have a .jar suffix,\n"
155 " the default is com.sun.star.loader.Java2.\n"
156 " Otherwise, the default is\n"
157 " com.sun.star.loader.SharedLibrary\n"
158 " -s\n"
159 " silent, regcomp prints messages only on error.\n"
160 " -wop\n"
161 " register the component name only without path\n"
162 " -wop=prefix\n"
163 " register the component name with path replaced\n"
164 " by given prefix\n"
165 " -classpath path\n"
166 " sets the java classpath to path (overwriting the\n"
167 " current classpath environment variable). Note that\n"
168 " in case you start regcomp e.g. within an office\n"
169 " environment, the classpath entries in the\n"
170 " configuration still have precedence over this\n"
171 " option.\n");
174 class IllegalArgument
176 public:
177 IllegalArgument(const OString& rMessage)
178 : m_message(rMessage)
181 OString m_message;
184 struct Options
186 Options()
187 : bRegister(sal_False)
188 , bRevoke(sal_False)
189 , bSilent( sal_False )
190 , bPrefix( sal_False )
193 sal_Bool bRegister;
194 sal_Bool bRevoke;
195 sal_Bool bSilent;
196 sal_Bool bPrefix;
197 OUString sPrefix;
198 OUString sProgramName;
199 OUString sBootRegName;
200 OUString sBootRegName2;
201 OUString sRegName;
202 OUString sComponentUrls;
203 OUString sLoaderName;
206 sal_Bool parseOptions(int ac, char* av[], Options& rOptions, sal_Bool bCmdFile)
207 throw( IllegalArgument )
209 sal_Bool ret = sal_True;
210 sal_uInt16 i=0;
211 sal_Bool bLoaderExplicitlyGiven = sal_False;
213 rOptions.sProgramName = OUString::createFromAscii(av[i++]);
215 if (!bCmdFile)
217 bCmdFile = sal_True;
219 if (ac < 2)
221 usingRegisterImpl();
222 ret = sal_False;
226 for (; i < ac; i++)
228 if (av[i][0] == '-')
230 switch (av[i][1])
232 case 'r':
233 if (strcmp(av[i], "-register") == 0)
235 rOptions.bRegister = sal_True;
236 } else
237 if (strcmp(av[i], "-revoke") == 0)
239 rOptions.bRevoke = sal_True;
240 } else
241 if (av[i][2] == '\0')
243 if (i < ac - 1 && av[i+1][0] != '-')
245 i++;
246 rOptions.sRegName = OStringToOUString(av[i], osl_getThreadTextEncoding());
247 } else
249 OString tmp("'-r', please check");
250 if (i <= ac - 1)
252 tmp += " your input '" + OString(av[i+1]) + "'";
254 throw IllegalArgument(tmp);
256 } else
258 rOptions.sRegName = OStringToOUString(av[i]+2, osl_getThreadTextEncoding());
260 break;
261 case 'b':
262 if (av[i][2] != 'r')
264 OString tmp("'-b', invalid option!");
265 throw IllegalArgument(tmp);
267 if (av[i][3] == '\0')
269 if (i < ac - 1 && av[i+1][0] != '-')
271 i++;
272 OUString regName = OStringToOUString(av[i], osl_getThreadTextEncoding());
273 if( ! rOptions.sBootRegName.getLength() )
275 rOptions.sBootRegName = regName;
277 else
279 rOptions.sBootRegName2 = regName;
281 } else
283 OString tmp("'-br', please check");
284 if (i <= ac - 1)
286 tmp += " your input '" + OString(av[i+1]) + "'";
288 throw IllegalArgument(tmp);
290 } else
292 rOptions.sBootRegName = OStringToOUString(av[i]+3, osl_getThreadTextEncoding());
294 break;
295 case 'c':
297 OUString sUrls;
298 if (av[i][2] == '\0')
300 if (i < ac - 1 && av[i+1][0] != '-')
302 i++;
303 sUrls = OStringToOUString(av[i], osl_getThreadTextEncoding());
304 } else
306 OString tmp("'-c', please check");
307 if (i <= ac - 1)
309 tmp += " your input '" + OString(av[i+1]) + "'";
311 throw IllegalArgument(tmp);
314 else if( 0 == strncmp( av[i] , "-classpath" ,10 ) )
316 i++;
317 if( i < ac )
319 // leak this string as some platforms assume to own
320 // the pointer
321 sal_Char * p = (sal_Char *) rtl_allocateMemory( 13+ strlen( av[i] ) );
322 p[0] = 0;
323 strcat( p, "CLASSPATH=" ); // #100211# - checked
324 strcat( p, av[i] ); // #100211# - checked
326 putenv( p );
328 break;
330 else
332 sUrls = OStringToOUString(av[i]+2, osl_getThreadTextEncoding());
335 if (rOptions.sComponentUrls.getLength())
337 OUString tmp(rOptions.sComponentUrls + OUString(";", 1, osl_getThreadTextEncoding()) + sUrls);
338 rOptions.sComponentUrls = tmp;
339 } else
341 rOptions.sComponentUrls = sUrls;
343 break;
345 case 'l':
347 if (av[i][2] == '\0')
349 if (i < ac - 1 && av[i+1][0] != '-')
351 i++;
352 rOptions.sLoaderName = OUString::createFromAscii(av[i]);
353 bLoaderExplicitlyGiven = sal_True;
354 } else
356 OString tmp("'-l', please check");
357 if (i <= ac - 1)
359 tmp += " your input '" + OString(av[i+1]) + "'";
361 throw IllegalArgument(tmp);
363 } else
365 bLoaderExplicitlyGiven = sal_True;
366 rOptions.sLoaderName = OUString::createFromAscii(av[i]+2);
368 break;
370 case 's':
372 if( av[i][2] == 0 )
374 rOptions.bSilent = sal_True;
376 else
378 rtl::OStringBuffer buf;
379 buf.append( "Unknown error " );
380 buf.append( av[i] );
381 throw IllegalArgument( av[i] );
383 break;
385 case 'e':
387 if( av[i][2] == 'n' && av[i][3] == 'v' && av[i][4] == ':' )
389 // bootstrap variable, ignore it
390 break;
393 case 'w':
395 if (strcmp(av[i], "-wop") == 0)
397 rOptions.bPrefix = sal_True;
398 rOptions.sPrefix = OUString();
399 // in case there are multiple -wops
400 break;
402 else if (
403 strncmp(av[i], "-wop=", RTL_CONSTASCII_LENGTH("-wop="))
404 == 0)
406 rOptions.bPrefix = sal_True;
407 rOptions.sPrefix = OStringToOUString(
408 av[i] + RTL_CONSTASCII_LENGTH("-wop="),
409 osl_getThreadTextEncoding());
410 break;
413 default:
415 OString tmp( "unknown option " );
416 tmp += av[i];
417 throw IllegalArgument( tmp );
420 } else
422 if (av[i][0] == '@')
424 FILE* cmdFile = fopen(av[i]+1, "r");
425 if( cmdFile == NULL )
427 usingRegisterImpl();
428 ret = sal_False;
429 } else
431 fseek( cmdFile , 0 , SEEK_END );
432 sal_Int32 nLen = ftell( cmdFile);
433 fseek( cmdFile, 0, SEEK_SET );
435 // 2 chars per string is a upper limit for the number of
436 // substrings ( at least one separator char needed for fscanf).
437 char ** rargv = (char **)rtl_allocateMemory( nLen * sizeof( char* ) /2);
438 if( ! rargv )
440 OStringBuffer buf;
441 buf.append( "Not enough memory for reading command file " );
442 buf.append( av[i] +1 );
443 buf.append( " with length " );
444 buf.append( nLen );
445 buf.append( "." );
446 throw IllegalArgument( buf.makeStringAndClear() );
448 char *buffer = ( char * )rtl_allocateMemory( nLen +1 );
449 if( ! buffer )
451 OStringBuffer buf;
452 buf.append( "Not enough memory for reading command file " );
453 buf.append( av[i] +1 );
454 buf.append( " with length " );
455 buf.append( nLen );
456 buf.append( "." );
457 throw IllegalArgument( buf.makeStringAndClear() );
460 // we start at one to omit argv[0]
461 sal_Int32 rargc = 1;
462 rargv[0] = av[0];
463 while ( fscanf(cmdFile, "%s", buffer) != EOF )
465 rargv[rargc]= (char * )rtl_allocateMemory( strlen( buffer ) +1 );
466 if( ! rargv[rargc] )
468 OStringBuffer buf;
469 buf.append( "Not enough memory for reading command file " );
470 buf.append( av[i] +1 );
471 buf.append( " with length " );
472 buf.append( nLen );
473 buf.append( "." );
474 throw IllegalArgument( buf.makeStringAndClear() );
476 strcpy( rargv[rargc] , buffer ); // #100211# - checked
477 rargc++;
479 fclose(cmdFile);
481 parseOptions(rargc, rargv, rOptions, bCmdFile);
483 for (long j=1; j < rargc; j++)
485 rtl_freeMemory(rargv[j]);
487 rtl_freeMemory( buffer );
488 rtl_freeMemory( rargv );
490 } else
492 usingRegisterImpl();
493 ret = sal_False;
498 if( ! bLoaderExplicitlyGiven )
500 if ( rOptions.sComponentUrls.getLength() > 4 &&
501 rOptions.sComponentUrls.matchAsciiL(
502 ".jar" , 4 , rOptions.sComponentUrls.getLength() - 4 ) )
504 if( ! rOptions.bSilent )
506 printf( "using loader com.sun.star.loader.Java2\n" );
508 rOptions.sLoaderName = OUString(
509 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.Java2"));
511 else
513 rOptions.sLoaderName = OUString(
514 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.SharedLibrary") );
518 return ret;
522 struct DoIt
524 sal_Bool _bRegister;
525 sal_Bool _bRevoke;
526 sal_Bool _bSilent;
527 sal_Bool _bPrefix;
528 OUString _sPrefix;
529 OString _sRegName;
530 OUString _sLoaderName;
531 Reference<XImplementationRegistration2> _xImplRegistration;
532 Reference<XSimpleRegistry> _xReg;
533 sal_uInt32 * _exitCode;
535 DoIt(sal_Bool bRegister,
536 sal_Bool bRevoke,
537 sal_Bool bSilent,
538 sal_Bool bPrefix,
539 const OUString & sPrefix,
540 const Reference<XSimpleRegistry> & xReg,
541 const OString & sRegName,
542 const Reference<XImplementationRegistration2> & xImplRegistration,
543 const OUString & sLoaderName,
544 sal_uInt32 * exitCode)
545 throw();
547 void operator()(const OUString & url) throw();
550 DoIt::DoIt(sal_Bool bRegister,
551 sal_Bool bRevoke,
552 sal_Bool bSilent,
553 sal_Bool bPrefix,
554 const OUString & sPrefix,
555 const Reference<XSimpleRegistry> & xReg,
556 const OString & sRegName,
557 const Reference<XImplementationRegistration2> & xImplRegistration,
558 const OUString & sLoaderName,
559 sal_uInt32 * exitCode) throw()
560 : _bRegister(bRegister),
561 _bRevoke(bRevoke),
562 _bSilent( bSilent ),
563 _bPrefix( bPrefix ),
564 _sPrefix( sPrefix ),
565 _sRegName(sRegName),
566 _sLoaderName(sLoaderName),
567 _xImplRegistration(xImplRegistration),
568 _xReg(xReg),
569 _exitCode(exitCode)
572 void DoIt::operator() (const OUString & url) throw()
574 OString sUrl = OUStringToOString(url, osl_getThreadTextEncoding());
576 if (_bRegister)
580 Reference<XImplementationRegistration2> _xImplRegistration2(_xImplRegistration, UNO_QUERY);
581 if ( _bPrefix ) {
582 _xImplRegistration->registerImplementationWithLocation(
583 _sLoaderName, url, replacePrefix(url, _sPrefix), _xReg);
584 } else {
585 _xImplRegistration->registerImplementation(_sLoaderName, url, _xReg);
588 if ( ! _bSilent )
590 fprintf(stderr, "register component '%s' in registry '%s' succesful!\n", sUrl.getStr(), _sRegName.getStr());
594 catch(CannotRegisterImplementationException & cannotRegisterImplementationException) {
595 OString aMessage(OUStringToOString(cannotRegisterImplementationException.Message, RTL_TEXTENCODING_ASCII_US));
596 fprintf(stderr, "register component '%s' in registry '%s' failed!\n", sUrl.getStr(), _sRegName.getStr());
597 fprintf(stderr, "error (CannotRegisterImplementationException): %s\n", aMessage.getStr());
599 ++ (*_exitCode);
601 catch( RuntimeException & e )
603 OString aMessage(OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US));
604 fprintf(stderr, "register component '%s' in registry '%s' failed!\n", sUrl.getStr(), _sRegName.getStr());
605 fprintf(stderr, "error (RuntimeException): %s\n", aMessage.getStr());
607 ++ (*_exitCode);
610 else if(_bRevoke)
614 sal_Bool bRet = _xImplRegistration->revokeImplementation(url, _xReg);
616 if (bRet)
618 if ( ! _bSilent )
619 fprintf(stderr, "revoke component '%s' from registry '%s' succesful!\n", sUrl.getStr(), _sRegName.getStr());
621 else
623 fprintf(stderr, "revoke component '%s' from registry '%s' failed!\n", sUrl.getStr(), _sRegName.getStr());
624 ++ (*_exitCode);
627 catch( RuntimeException & e )
629 OString aMessage(OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US));
630 fprintf( stderr,
631 "revoke component '%s' from registry '%s' failed!\n",
632 sUrl.getStr(),
633 _sRegName.getStr() );
634 fprintf( stderr, "RuntimeException: %s\n" , aMessage.getStr());
635 ++ (*_exitCode);
640 static bool hasService(
641 const Reference< XMultiServiceFactory > &xSMgr,
642 const sal_Char * service )
644 bool ret = false;
646 Reference< XContentEnumerationAccess > access( xSMgr, UNO_QUERY );
647 if( access.is( ))
649 Reference< XEnumeration > enumeration = access->createContentEnumeration(
650 OUString::createFromAscii( service ) );
652 if( enumeration.is() && enumeration->hasMoreElements() )
654 ret = true;
657 return ret;
660 static void bootstrap(
661 Options & opt ,
662 Reference< XMultiServiceFactory > &xSMgr,
663 Reference< XSimpleRegistry > & reg ) throw ( Exception )
665 if( opt.sRegName.equals( opt.sBootRegName2 ) )
667 OUString tmp2 = opt.sBootRegName;
668 opt.sBootRegName = opt.sBootRegName2;
669 opt.sBootRegName2 = tmp2;
672 if ( opt.sRegName.equals(opt.sBootRegName) )
674 if( opt.sBootRegName2.getLength() )
676 xSMgr = createRegistryServiceFactory(
677 convertToFileUrl(opt.sRegName),
678 convertToFileUrl(opt.sBootRegName2),
679 sal_False );
681 else
683 xSMgr = createRegistryServiceFactory(
684 convertToFileUrl(opt.sRegName) , sal_False );
687 else
689 if( opt.sBootRegName2.getLength() )
691 xSMgr = createRegistryServiceFactory(
692 convertToFileUrl( opt.sBootRegName2 ),
693 convertToFileUrl( opt.sBootRegName ),
694 sal_True );
696 else if ( opt.sBootRegName.getLength() )
698 xSMgr = createRegistryServiceFactory(
699 convertToFileUrl( opt.sBootRegName ),
700 sal_True );
702 else
704 xSMgr = createServiceFactory();
706 reg = Reference< XSimpleRegistry >(
707 xSMgr->createInstance(
708 rtl::OUString::createFromAscii("com.sun.star.registry.SimpleRegistry")), UNO_QUERY);
710 if (reg.is())
714 reg->open( convertToFileUrl(opt.sRegName), sal_False, sal_True);
715 if (!reg->isValid())
717 fprintf(stderr, "ERROR: open|create registry '%s' failed!\n",
718 OUStringToOString(opt.sRegName, osl_getThreadTextEncoding() ).getStr());
719 exit(1);
722 catch( InvalidRegistryException & e)
724 OString o = OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US );
725 fprintf(stderr,
726 "ERROR: create registry '%s' failed!\n"
727 "InvalidRegistryException: %s\n",
728 OUStringToOString( opt.sRegName, osl_getThreadTextEncoding()).getStr(),
729 o.getStr() );
730 exit(1);
735 if( ! opt.sLoaderName.compareToAscii( "com.sun.star.loader.Java2" ) &&
736 ! hasService( xSMgr, "com.sun.star.loader.Java2" ) )
738 // we know our java loader, so we check, whether a java-loader is
739 // registered
740 Reference< XInterface > r = loadSharedLibComponentFactory(
741 OUString::createFromAscii( "javavm.uno" SAL_DLLEXTENSION ),
742 OUString(),
743 OUString::createFromAscii( "com.sun.star.comp.stoc.JavaVirtualMachine" ),
744 xSMgr,
745 Reference< XRegistryKey > () );
746 Reference< XInterface > r2 = loadSharedLibComponentFactory(
747 OUString::createFromAscii( "javaloader.uno" SAL_DLLEXTENSION ),
748 OUString(),
749 OUString::createFromAscii(( "com.sun.star.comp.stoc.JavaComponentLoader" ) ),
750 xSMgr,
751 Reference< XRegistryKey > () );
752 Reference <XSet> xSet( xSMgr, UNO_QUERY );
753 if( r.is() && r2.is() && xSet.is() )
755 xSet->insert( makeAny( r ) );
756 xSet->insert( makeAny( r2 ) );
761 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
763 sal_Bool bRet = sal_False;
764 sal_uInt32 exitCode = 0;
765 Options aOptions;
769 if ( !parseOptions(argc, argv, aOptions, sal_False) )
771 exit(1);
774 catch ( IllegalArgument& e)
776 fprintf(stderr, "ERROR: %s\n", e.m_message.getStr());
777 exit(1);
780 if( ! aOptions.sRegName.getLength() )
782 fprintf( stderr, "ERROR: target registry missing (-r option)\n" );
783 exit( 1 );
785 if ( aOptions.sComponentUrls.getLength() == 0 )
787 fprintf(stderr, "ERROR: no component url is specified!\n");
788 exit(1);
791 Reference< XMultiServiceFactory > xSMgr;
792 Reference< XSimpleRegistry > xReg;
795 bootstrap( aOptions, xSMgr ,xReg );
797 catch( Exception& e )
799 fprintf(stderr, "ERROR: create ServiceManager failed!\n");
800 if ( e.Message.getLength() )
802 fprintf(stderr, "ERROR description: %s\n",
803 OUStringToOString(e.Message, osl_getThreadTextEncoding()).getStr());
805 exit(1);
808 Reference<XImplementationRegistration2> xImplRegistration(
809 xSMgr->createInstance(
810 OUString(RTL_CONSTASCII_USTRINGPARAM(
811 "com.sun.star.registry.ImplementationRegistration"))),
812 UNO_QUERY);
814 if (xImplRegistration.is())
816 sal_Int32 index = 0;
817 vector<OUString> urls;
819 OUString urlListWithSemikolon = aOptions.sComponentUrls;
820 do {
821 OUString aToken = urlListWithSemikolon.getToken( 0, ';', index);
822 fprintf(stderr, "%s\n", OUStringToOString(aToken, osl_getThreadTextEncoding()).getStr());
823 urls.push_back(aToken);
824 } while ( index >= 0 );
827 OString sRegName = OUStringToOString( aOptions.sRegName, osl_getThreadTextEncoding() );
828 if(aOptions.bRegister || aOptions.bRevoke)
830 for_each(urls.begin(), urls.end(),
831 DoIt(aOptions.bRegister, aOptions.bRevoke, aOptions.bSilent,
832 aOptions.bPrefix, aOptions.sPrefix,
833 xReg, sRegName, xImplRegistration,
834 aOptions.sLoaderName, &exitCode));
836 else
838 ++ exitCode;
839 usingRegisterImpl();
842 else
844 fprintf(stderr, "Component registration service could not be loaded!\n");
845 exitCode++;
848 if (!bRet && xReg.is() && xReg->isValid())
849 xReg->close();
851 Reference< XComponent > xComponent( xSMgr, UNO_QUERY );
852 if ( xComponent.is() )
853 xComponent->dispose();
855 return exitCode;