From f3de0f63df974b9ca01817d46d5fc8c831f72918 Mon Sep 17 00:00:00 2001 From: Juergen Schmidt Date: Fri, 1 Oct 2010 14:20:45 +0200 Subject: jsc340: i14847: clean up cmdline help fo devtools --- registry/tools/checksingleton.cxx | 4 ++-- registry/tools/regcompare.cxx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'registry') diff --git a/registry/tools/checksingleton.cxx b/registry/tools/checksingleton.cxx index 4353721ad0b0..75ea3ec7958a 100644 --- a/registry/tools/checksingleton.cxx +++ b/registry/tools/checksingleton.cxx @@ -311,8 +311,8 @@ OString Options::prepareHelp() OString Options::prepareVersion() { - OString version("\nSun Microsystems (R) "); - version += m_program + " Version 1.0\n\n"; + OString version(m_program); + version += " Version 1.0\n\n"; return version; } diff --git a/registry/tools/regcompare.cxx b/registry/tools/regcompare.cxx index 4e95d884de30..d4bbe8c21ee2 100644 --- a/registry/tools/regcompare.cxx +++ b/registry/tools/regcompare.cxx @@ -405,8 +405,8 @@ OString Options::prepareHelp() OString Options::prepareVersion() { - OString version("\nSun Microsystems (R) "); - version += m_program + " Version 1.0\n\n"; + OString version(m_program); + version += " Version 1.0\n\n"; return version; } -- cgit From b15f7fcbde3db69e60f9a9ccabb4ae1b7c5f8dee Mon Sep 17 00:00:00 2001 From: Juergen Schmidt Date: Mon, 15 Nov 2010 13:38:30 +0100 Subject: jsc340: i114887: remove old not used draft types --- registry/tools/makefile.mk | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'registry') diff --git a/registry/tools/makefile.mk b/registry/tools/makefile.mk index bb7d448b86e6..1f0f75f0ecbc 100644 --- a/registry/tools/makefile.mk +++ b/registry/tools/makefile.mk @@ -75,6 +75,14 @@ APP4STDLIBS=\ $(SALHELPERLIB) \ $(REGLIB) -OBJFILES = $(APP1OBJS) $(APP2OBJS) $(APP3OBJS) $(APP4OBJS) +APP5TARGET= rdbedit +APP5OBJS= $(OBJ)$/rdbedit.obj + +APP5STDLIBS=\ + $(SALLIB) \ + $(SALHELPERLIB) \ + $(REGLIB) + +OBJFILES = $(APP1OBJS) $(APP2OBJS) $(APP3OBJS) $(APP4OBJS) $(APP5OBJS) .INCLUDE : target.mk -- cgit From a1b5f0fc8194645e05fc61b6640b5bf5247de3ca Mon Sep 17 00:00:00 2001 From: Juergen Schmidt Date: Mon, 3 Jan 2011 13:41:57 +0100 Subject: new helper tool --- registry/tools/rdbedit.cxx | 318 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 318 insertions(+) create mode 100644 registry/tools/rdbedit.cxx (limited to 'registry') diff --git a/registry/tools/rdbedit.cxx b/registry/tools/rdbedit.cxx new file mode 100644 index 000000000000..c2b3d6a3dcf3 --- /dev/null +++ b/registry/tools/rdbedit.cxx @@ -0,0 +1,318 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_registry.hxx" + +#include +#include + +#include "registry/registry.hxx" +#include "registry/reflread.hxx" +#include +#include +#include +#include +#include +#include + +#ifdef SAL_UNX +#define SEPARATOR '/' +#else +#define SEPARATOR '\\' +#endif + +using namespace ::rtl; +using namespace ::osl; + +sal_Bool isFileUrl(const OString& fileName) +{ + if (fileName.indexOf("file://") == 0 ) + return sal_True; + return sal_False; +} + +OUString convertToFileUrl(const OString& fileName) +{ + if ( isFileUrl(fileName) ) + { + return OStringToOUString(fileName, osl_getThreadTextEncoding()); + } + + OUString uUrlFileName; + OUString uFileName(fileName.getStr(), fileName.getLength(), osl_getThreadTextEncoding()); + if ( fileName.indexOf('.') == 0 || fileName.indexOf(SEPARATOR) < 0 ) + { + OUString uWorkingDir; + if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None) + { + OSL_ASSERT(false); + } + if (FileBase::getAbsoluteFileURL(uWorkingDir, uFileName, uUrlFileName) + != FileBase::E_None) + { + OSL_ASSERT(false); + } + } else + { + if (FileBase::getFileURLFromSystemPath(uFileName, uUrlFileName) + != FileBase::E_None) + { + OSL_ASSERT(false); + } + } + + return uUrlFileName; +} + +#define U2S( s ) \ + OUStringToOString(s, RTL_TEXTENCODING_UTF8).getStr() +#define S2U( s ) \ + OStringToOUString(s, RTL_TEXTENCODING_UTF8) + +struct LessString +{ + sal_Bool operator()(const OUString& str1, const OUString& str2) const + { + return (str1 < str2); + } +}; + +enum Command { + DELETEKEY +}; + +class Options +{ +public: + Options() + : m_bVerbose(false) + {} + ~Options() + {} + + bool initOptions(int ac, char* av[]); + + OString prepareHelp(); + OString prepareVersion(); + + const OString& getProgramName() + { return m_program; } + const OString& getTypeReg() + { return m_typeRegName; } + const OString& getKeyName() + { return m_keyName; } + const Command getCommand() + { return m_command; } + bool verbose() + { return m_bVerbose; } +protected: + OString m_program; + OString m_typeRegName; + OString m_keyName; + Command m_command; + bool m_bVerbose; +}; + +bool Options::initOptions(int ac, char* av[]) +{ + bool bRet = true; + sal_uInt16 i=1; + + if (ac < 2) + { + fprintf(stderr, "%s", prepareHelp().getStr()); + bRet = sal_False; + } + + m_program = av[0]; + sal_Int32 index = -1; + if ((index=m_program.lastIndexOf(SEPARATOR)) > 0) + m_program = av[0]+index+1; + + char *s=NULL; + for (; i < ac; i++) + { + if (av[i][0] == '-') + { + switch (av[i][1]) + { + case 'r': + case 'R': + if (av[i][2] == '\0') + { + if (i < ac - 1 && av[i+1][0] != '-') + { + i++; + s = av[i]; + } else + { + fprintf(stderr, "%s: invalid option '%s'\n", m_program.getStr(), av[i]); + bRet = sal_False; + break; + } + } else + { + s = av[i] + 2; + } + m_typeRegName = OString(s); + break; + case 'd': + case 'D': + if (av[i][2] == '\0') + { + if (i < ac - 1 && av[i+1][0] != '-') + { + i++; + s = av[i]; + } else + { + fprintf(stderr, "%s: invalid option '%s'\n", m_program.getStr(), av[i]); + bRet = sal_False; + break; + } + } else + { + s = av[i] + 2; + } + m_keyName = OString(s); + break; + case 'v': + case 'V': + if (av[i][2] != '\0') + { + fprintf(stderr, "%s: invalid option '%s'\n", m_program.getStr(), av[i]); + bRet = sal_False; + } + m_bVerbose = true; + break; + case 'h': + case '?': + if (av[i][2] != '\0') + { + fprintf(stderr, "%s: invalid option '%s'\n", m_program.getStr(), av[i]); + bRet = false; + } else + { + fprintf(stdout, "%s", prepareHelp().getStr()); + exit(0); + } + break; + default: + fprintf(stderr, "%s: unknown option '%s'\n", m_program.getStr(), av[i]); + bRet = false; + break; + } + } else + { + fprintf(stderr, "%s: unknown option '%s'\n", m_program.getStr(), av[i]); + bRet = false; + } + } + + return bRet; +} + +OString Options::prepareHelp() +{ + OString help("\nusing: "); + help += m_program + " -r \n"; + help += " -r = filename specifies the name of the type registry.\n"; + help += "Commands:\n"; + help += " -d = delete the specified key from the registry. Keyname\n"; + help += " specifies the name of the key that get deleted.\n"; + help += " -v = verbose output.\n"; + help += " -h|-? = print this help message and exit.\n"; + help += prepareVersion(); + + return help; +} + +OString Options::prepareVersion() +{ + OString version(m_program); + version += " Version 1.0\n\n"; + return version; +} + +static Options options; + + +#if (defined UNX) || (defined OS2) || (defined __MINGW32__) +int main( int argc, char * argv[] ) +#else +int _cdecl main( int argc, char * argv[] ) +#endif +{ + if ( !options.initOptions(argc, argv) ) + { + exit(1); + } + + OUString typeRegName( convertToFileUrl(options.getTypeReg()) ); + + Registry typeReg; + + if ( typeReg.open(typeRegName, REG_READWRITE) ) + { + fprintf(stderr, "%s: open registry \"%s\" failed\n", + options.getProgramName().getStr(), options.getTypeReg().getStr()); + exit(2); + } + + RegistryKey typeRoot; + if ( typeReg.openRootKey(typeRoot) ) + { + fprintf(stderr, "%s: open root key of registry \"%s\" failed\n", + options.getProgramName().getStr(), options.getTypeReg().getStr()); + exit(3); + } + + if ( options.getCommand() == DELETEKEY ) + { + if ( typeRoot.deleteKey(S2U(options.getKeyName())) ) + { + fprintf(stderr, "%s: delete key \"%s\" of registry \"%s\" failed\n", + options.getProgramName().getStr(), options.getKeyName().getStr(), options.getTypeReg().getStr()); + exit(4); + } else { + if (options.verbose()) + fprintf(stderr, "%s: delete key \"%s\" of registry \"%s\"\n", + options.getProgramName().getStr(), options.getKeyName().getStr(), options.getTypeReg().getStr()); + } + } + + typeRoot.releaseKey(); + if ( typeReg.close() ) + { + fprintf(stderr, "%s: closing registry \"%s\" failed\n", + options.getProgramName().getStr(), options.getTypeReg().getStr()); + exit(5); + } +} + + -- cgit From 228e4d2915a12802bf08303b750494c0f88e3d4a Mon Sep 17 00:00:00 2001 From: Juergen Schmidt Date: Thu, 24 Feb 2011 10:51:05 +0100 Subject: jsc340: i114847: fix name --- registry/tools/regcompare.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'registry') diff --git a/registry/tools/regcompare.cxx b/registry/tools/regcompare.cxx index d4bbe8c21ee2..ec8cdaa9e1a6 100644 --- a/registry/tools/regcompare.cxx +++ b/registry/tools/regcompare.cxx @@ -172,7 +172,9 @@ sal_Bool Options::initOptions(int ac, char* av[], sal_Bool bCmdFile) { bCmdFile = sal_True; - m_program = av[0]; + OString name(av[0]); + sal_Int32 index = name.lastIndexOf(SEPARATOR); + m_program = name.copy((index > 0 ? index+1 : 0)); if (ac < 2) { @@ -397,7 +399,7 @@ OString Options::prepareHelp() help += " incompatible to r1. But if a service in r2 supports more properties as\n"; help += " in r1 and the new properties are 'optonal' it is compatible.\n"; help += " -u|U = additionally check types that are unpublished in registry 1.\n"; - help += " -h|-? = print this help message and exit.\n"; + help += " -h|-? = print this help message and exit.\n\n"; help += prepareVersion(); return help; -- cgit