summaryrefslogtreecommitdiff
path: root/cpputools
diff options
context:
space:
mode:
authorDaniel Boelzle <dbo@openoffice.org>2002-09-10 08:39:15 +0000
committerDaniel Boelzle <dbo@openoffice.org>2002-09-10 08:39:15 +0000
commit4d8914188520c48ad9f6a744685014214046b6e3 (patch)
tree9431da76d2fbecac60a53bf24ffb839d91a6c979 /cpputools
parent513c2d27f137f38f3392fba85d46324f07bbc847 (diff)
new tool for writing singleton entries into a rdb file
Diffstat (limited to 'cpputools')
-rw-r--r--cpputools/source/regsingleton/makefile.mk114
-rw-r--r--cpputools/source/regsingleton/regsingleton.cxx136
2 files changed, 250 insertions, 0 deletions
diff --git a/cpputools/source/regsingleton/makefile.mk b/cpputools/source/regsingleton/makefile.mk
new file mode 100644
index 000000000..966a5f6fd
--- /dev/null
+++ b/cpputools/source/regsingleton/makefile.mk
@@ -0,0 +1,114 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: dbo $ $Date: 2002-09-10 09:39:15 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=cpputools
+TARGET=regsingleton
+TARGETTYPE=CUI
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+UNOUCRDEP=$(SOLARBINDIR)$/udkapi.rdb
+UNOUCRRDB=$(SOLARBINDIR)$/udkapi.rdb
+
+UNOUCROUT=$(OUT)$/inc
+INCPRE+=$(OUT)$/inc
+CPPUMAKERFLAGS+= -C
+
+UNOTYPES= \
+ com.sun.star.uno.TypeClass \
+ com.sun.star.uno.XAggregation \
+ com.sun.star.uno.XWeak \
+ com.sun.star.uno.XComponentContext \
+ com.sun.star.lang.XTypeProvider \
+ com.sun.star.lang.XComponent \
+ com.sun.star.lang.XSingleServiceFactory \
+ com.sun.star.lang.XSingleComponentFactory \
+ com.sun.star.lang.XMultiServiceFactory \
+ com.sun.star.lang.XMultiComponentFactory \
+ com.sun.star.container.XHierarchicalNameAccess \
+ com.sun.star.registry.XSimpleRegistry \
+ com.sun.star.registry.XRegistryKey
+
+# --- Files --------------------------------------------------------
+
+CXXFILES= \
+ regsingleton.cxx
+
+APP1TARGET=$(TARGET)
+APP1OBJS= \
+ $(OBJ)$/regsingleton.obj
+
+APP1STDLIBS= \
+ $(SALLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB)
+
+.INCLUDE : target.mk
+
diff --git a/cpputools/source/regsingleton/regsingleton.cxx b/cpputools/source/regsingleton/regsingleton.cxx
new file mode 100644
index 000000000..eb7672de8
--- /dev/null
+++ b/cpputools/source/regsingleton/regsingleton.cxx
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * $RCSfile: regsingleton.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dbo $ $Date: 2002-09-10 09:39:15 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+
+#include <osl/diagnose.h>
+#include <osl/file.h>
+
+#include <cppuhelper/bootstrap.hxx>
+
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+
+#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
+
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+
+//==================================================================================================
+extern "C" int SAL_CALL main( int argc, char const * argv [] )
+{
+ if (argc < 3)
+ {
+ fprintf(
+ stderr, "\nusage: regsingleton registry_file singleton_name1=service_name1 ...\n" );
+ return 1;
+ }
+
+ OUString sys_path( OUString::createFromAscii( argv[ 1 ] ) );
+ OUString file_url;
+ oslFileError rc = osl_getFileURLFromSystemPath( sys_path.pData, &file_url.pData );
+ if (osl_File_E_None != rc)
+ {
+ fprintf( stderr, "\nerror: cannot make file url out of %s\n", argv[ 1 ] );
+ return 1;
+ }
+
+ try
+ {
+ Reference< registry::XSimpleRegistry > xSimReg( ::cppu::createSimpleRegistry() );
+ xSimReg->open( file_url, sal_False, sal_True );
+ Reference< registry::XRegistryKey > xRoot( xSimReg->getRootKey() );
+ Reference< registry::XRegistryKey > xKey( xRoot->openKey( OUSTR("SINGLETONS") ) );
+ if (! xKey.is())
+ xKey = xRoot->createKey( OUSTR("SINGLETONS") );
+
+ for ( int nPos = 2; nPos < argc; ++nPos )
+ {
+ OUString singleton( OUString::createFromAscii( argv[ nPos ] ) );
+ sal_Int32 eq = singleton.indexOf( '=' );
+ if (eq < 0)
+ {
+ OString entry( OUStringToOString( singleton, RTL_TEXTENCODING_ASCII_US ) );
+ fprintf( stderr, "skipping %s: no service name given!\n", entry.getStr() );
+ }
+ else
+ {
+ OUString service( singleton.copy( eq +1 ) );
+ singleton = singleton.copy( 0, eq );
+
+ Reference< registry::XRegistryKey > xEntry( xKey->openKey( singleton ) );
+ if (! xEntry.is())
+ xEntry = xKey->createKey( singleton );
+ xEntry->setStringValue( service );
+ }
+ }
+
+ return 0;
+ }
+ catch (Exception & rExc)
+ {
+ OString msg( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ fprintf( stderr, "\nerror: %s\n", msg.getStr() );
+ return 1;
+ }
+}