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/tools') 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/tools') 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 0ff6b9a26dd3916e7e5f29f37ec2220b95bf5180 Mon Sep 17 00:00:00 2001 From: "Matthias Huetsch [mhu]" Date: Thu, 25 Nov 2010 14:22:01 +0100 Subject: #i115784# registry: fix memory errors uncovered by valgrind and other tools. --- registry/tools/checksingleton.cxx | 459 ++++------- registry/tools/fileurl.cxx | 90 +++ registry/tools/fileurl.hxx | 43 + registry/tools/makefile.mk | 8 +- registry/tools/options.cxx | 153 ++++ registry/tools/options.hxx | 67 ++ registry/tools/regcompare.cxx | 1555 +++++++++++++++---------------------- registry/tools/regmerge.cxx | 277 +++---- registry/tools/regview.cxx | 72 +- 9 files changed, 1240 insertions(+), 1484 deletions(-) create mode 100644 registry/tools/fileurl.cxx create mode 100644 registry/tools/fileurl.hxx create mode 100644 registry/tools/options.cxx create mode 100644 registry/tools/options.hxx (limited to 'registry/tools') diff --git a/registry/tools/checksingleton.cxx b/registry/tools/checksingleton.cxx index 4353721ad0b0..b4fb1d6b04b2 100644 --- a/registry/tools/checksingleton.cxx +++ b/registry/tools/checksingleton.cxx @@ -28,297 +28,150 @@ // 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 +#include "fileurl.hxx" +#include "options.hxx" -using namespace ::rtl; -using namespace ::osl; +#include "rtl/ustring.hxx" +#include "osl/diagnose.h" -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()); - } +#include +#include - 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); - } - } +#include +#include - return uUrlFileName; -} +using namespace rtl; +using namespace registry::tools; #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); - } -}; - -class Options +class Options_Impl : public Options { public: - Options() - : m_bForceOutput(sal_False) - {} - ~Options() + explicit Options_Impl(char const * program) + : Options (program), m_bForceOutput(false) {} - sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False); - - OString prepareHelp(); - OString prepareVersion(); - - const OString& getProgramName() - { return m_program; } - const OString& getIndexReg() + std::string const & getIndexReg() const { return m_indexRegName; } - const OString& getTypeReg() + std::string const & getTypeReg() const { return m_typeRegName; } - sal_Bool hasBase() - { return m_base.getLength() > 0; } - const OString& getBase() + bool hasBase() const + { return (m_base.getLength() > 0); } + const OString & getBase() const { return m_base; } - sal_Bool forceOutput() + bool forceOutput() const { return m_bForceOutput; } + protected: - OString m_program; - OString m_indexRegName; - OString m_typeRegName; + virtual void printUsage_Impl() const; + virtual bool initOptions_Impl (std::vector< std::string > & rArgs); + + std::string m_indexRegName; + std::string m_typeRegName; OString m_base; - sal_Bool m_bForceOutput; + bool m_bForceOutput; }; -sal_Bool Options::initOptions(int ac, char* av[], sal_Bool bCmdFile) +// virtual +void Options_Impl::printUsage_Impl() const { - sal_Bool bRet = sal_True; - sal_uInt16 i=0; + std::string const & rProgName = getProgramName(); + fprintf(stderr, + "Usage: %s -r -o [-options] | @\n", rProgName.c_str() + ); + fprintf(stderr, + " -o = filename specifies the name of the new singleton index registry.\n" + " -r = filename specifies the name of the type registry.\n" + " @ = filename specifies a command file.\n" + "Options:\n" + " -b = name specifies the name of a start key. The types will be searched\n" + " under this key in the type registry.\n" + " -f = force the output of all found singletons.\n" + " -h|-? = print this help message and exit.\n" + ); + fprintf(stderr, + "\nSun Microsystems (R) %s Version 1.0\n\n", rProgName.c_str() + ); +} - if (!bCmdFile) +// virtual +bool Options_Impl::initOptions_Impl(std::vector< std::string > & rArgs) +{ + std::vector< std::string >::const_iterator first = rArgs.begin(), last = rArgs.end(); + for (; first != last; ++first) { - bCmdFile = sal_True; - - m_program = av[0]; - - if (ac < 2) + std::string option (*first); + if ((*first)[0] != '-') { - fprintf(stderr, "%s", prepareHelp().getStr()); - bRet = sal_False; + return badOption("invalid", option.c_str()); } - - i = 1; - } else - { - i = 0; - } - - char *s=NULL; - for (; i < ac; i++) - { - if (av[i][0] == '-') + switch ((*first)[1]) { - switch (av[i][1]) + case 'r': + case 'R': + { + if (!((++first != last) && ((*first)[0] != '-'))) + { + return badOption("invalid", option.c_str()); + } + m_typeRegName = OString((*first).c_str(), (*first).size()); + break; + } + case 'o': + case 'O': { - 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 'o': - case 'O': - 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_indexRegName = OString(s); - break; - case 'b': - case 'B': - 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_base = OString(s); - break; - case 'f': - case 'F': - if (av[i][2] != '\0') - { - fprintf(stderr, "%s: invalid option '%s'\n", m_program.getStr(), av[i]); - bRet = sal_False; - } - m_bForceOutput = sal_True; - break; - case 'h': - case '?': - if (av[i][2] != '\0') - { - fprintf(stderr, "%s: invalid option '%s'\n", m_program.getStr(), av[i]); - bRet = sal_False; - } else - { - fprintf(stdout, "%s", prepareHelp().getStr()); - exit(0); - } - break; - default: - fprintf(stderr, "%s: unknown option '%s'\n", m_program.getStr(), av[i]); - bRet = sal_False; - break; + if (!((++first != last) && ((*first)[0] != '-'))) + { + return badOption("invalid", option.c_str()); + } + m_indexRegName = (*first); + break; } - } else - { - if (av[i][0] == '@') + case 'b': + case 'B': { - FILE* cmdFile = fopen(av[i]+1, "r"); - if( cmdFile == NULL ) - { - fprintf(stderr, "%s", prepareHelp().getStr()); - bRet = sal_False; - } else + if (!((++first != last) && ((*first)[0] != '-'))) { - int rargc=0; - char* rargv[512]; - char buffer[512]; - - while ( fscanf(cmdFile, "%s", buffer) != EOF ) - { - rargv[rargc]= strdup(buffer); - rargc++; - } - fclose(cmdFile); - - bRet = initOptions(rargc, rargv, bCmdFile); - - for (long j=0; j < rargc; j++) - { - free(rargv[j]); - } + return badOption("invalid", option.c_str()); + } + m_base = OString((*first).c_str(), (*first).size()); + break; + } + case 'f': + case 'F': + { + if ((*first)[2] != 0) + { + return badOption("invalid", option.c_str()); } - } else + m_bForceOutput = sal_True; + break; + } + case 'h': + case '?': { - fprintf(stderr, "%s: unknown option '%s'\n", m_program.getStr(), av[i]); - bRet = sal_False; + if ((*first)[2] != 0) + { + return badOption("invalid", option.c_str()); + } + return printUsage(); + break; } + default: + return badOption("unknown", option.c_str()); + break; } } - - return bRet; -} - -OString Options::prepareHelp() -{ - OString help("\nusing: "); - help += m_program + " -r -o [-options] | @\n"; - help += " -o = filename specifies the name of the new singleton index registry.\n"; - help += " -r = filename specifies the name of the type registry.\n"; - help += " @ = filename specifies a command file.\n"; - help += "Options:\n"; - help += " -b = name specifies the name of a start key. The types will be searched\n"; - help += " under this key in the type registry.\n"; - help += " -f = force the output of all found singletons.\n"; - help += " -h|-? = print this help message and exit.\n"; - help += prepareVersion(); - - return help; + return true; } -OString Options::prepareVersion() -{ - OString version("\nSun Microsystems (R) "); - version += m_program + " Version 1.0\n\n"; - return version; -} - -static Options options; - -static sal_Bool checkSingletons(RegistryKey& singletonKey, RegistryKey& typeKey) +static sal_Bool checkSingletons(Options_Impl const & options, RegistryKey& singletonKey, RegistryKey& typeKey) { RegValueType valueType = RG_VALUETYPE_NOT_DEFINED; sal_uInt32 size = 0; @@ -326,24 +179,22 @@ static sal_Bool checkSingletons(RegistryKey& singletonKey, RegistryKey& typeKey) sal_Bool bRet = sal_False; RegError e = typeKey.getValueInfo(tmpName, &valueType, &size); - - if ( e != REG_VALUE_NOT_EXISTS && e != REG_INVALID_VALUE && valueType == RG_VALUETYPE_BINARY) + if ((e != REG_VALUE_NOT_EXISTS) && (e != REG_INVALID_VALUE) && (valueType == RG_VALUETYPE_BINARY)) { - RegistryKey entryKey; - RegValue value = rtl_allocateMemory(size); - - typeKey.getValue(tmpName, value); - - RegistryTypeReader reader((sal_uInt8*)value, size, sal_False); + std::vector< sal_uInt8 > value(size); + typeKey.getValue(tmpName, value.data()); // @@@ broken api: write to buffer w/o buffer size. + RegistryTypeReader reader(value.data(), value.size(), sal_False); if ( reader.isValid() && reader.getTypeClass() == RT_TYPE_SINGLETON ) { - OUString singletonName = reader.getTypeName().replace('/', '.'); + RegistryKey entryKey; + OUString singletonName = reader.getTypeName().replace('/', '.'); if ( singletonKey.createKey(singletonName, entryKey) ) { fprintf(stderr, "%s: could not create SINGLETONS entry for \"%s\"\n", - options.getProgramName().getStr(), U2S( singletonName )); - } else + options.getProgramName().c_str(), U2S( singletonName )); + } + else { bRet = sal_True; OUString value2 = reader.getSuperTypeName(); @@ -352,30 +203,26 @@ static sal_Bool checkSingletons(RegistryKey& singletonKey, RegistryKey& typeKey) (RegValue)value2.getStr(), sizeof(sal_Unicode)* (value2.getLength()+1)) ) { fprintf(stderr, "%s: could not create data entry for singleton \"%s\"\n", - options.getProgramName().getStr(), U2S( singletonName )); + options.getProgramName().c_str(), U2S( singletonName )); } if ( options.forceOutput() ) { fprintf(stderr, "%s: create SINGLETON entry for \"%s\" -> \"%s\"\n", - options.getProgramName().getStr(), U2S( singletonName ), U2S(value2)); + options.getProgramName().c_str(), U2S( singletonName ), U2S(value2)); } } } - - rtl_freeMemory(value); } RegistryKeyArray subKeys; - typeKey.openSubKeys(tmpName, subKeys); sal_uInt32 length = subKeys.getLength(); - RegistryKey elementKey; for (sal_uInt32 i = 0; i < length; i++) { - elementKey = subKeys.getElement(i); - if ( checkSingletons(singletonKey, elementKey) ) + RegistryKey elementKey = subKeys.getElement(i); + if ( checkSingletons(options, singletonKey, elementKey) ) { bRet = sal_True; } @@ -389,69 +236,85 @@ int main( int argc, char * argv[] ) int _cdecl main( int argc, char * argv[] ) #endif { - if ( !options.initOptions(argc, argv) ) + std::vector< std::string > args; + for (int i = 1; i < argc; i++) { - exit(1); + int result = Options::checkArgument(args, argv[i], strlen(argv[i])); + if (result != 0) + { + // failure. + return (result); + } } - OUString indexRegName( convertToFileUrl(options.getIndexReg()) ); - OUString typeRegName( convertToFileUrl(options.getTypeReg()) ); + Options_Impl options(argv[0]); + if (!options.initOptions(args)) + { + options.printUsage(); + return (1); + } + OUString indexRegName( convertToFileUrl(options.getIndexReg().c_str(), options.getIndexReg().size()) ); Registry indexReg; - Registry typeReg; - if ( indexReg.open(indexRegName, REG_READWRITE) ) { if ( indexReg.create(indexRegName) ) { fprintf(stderr, "%s: open registry \"%s\" failed\n", - options.getProgramName().getStr(), options.getIndexReg().getStr()); - exit(2); + options.getProgramName().c_str(), options.getIndexReg().c_str()); + return (2); } } + + OUString typeRegName( convertToFileUrl(options.getTypeReg().c_str(), options.getTypeReg().size()) ); + Registry typeReg; if ( typeReg.open(typeRegName, REG_READONLY) ) { fprintf(stderr, "%s: open registry \"%s\" failed\n", - options.getProgramName().getStr(), options.getTypeReg().getStr()); - exit(3); + options.getProgramName().c_str(), options.getTypeReg().c_str()); + return (3); } - RegistryKey indexRoot, typeRoot; + RegistryKey indexRoot; if ( indexReg.openRootKey(indexRoot) ) { fprintf(stderr, "%s: open root key of registry \"%s\" failed\n", - options.getProgramName().getStr(), options.getIndexReg().getStr()); - exit(4); + options.getProgramName().c_str(), options.getIndexReg().c_str()); + return (4); } + + RegistryKey typeRoot; if ( typeReg.openRootKey(typeRoot) ) { fprintf(stderr, "%s: open root key of registry \"%s\" failed\n", - options.getProgramName().getStr(), options.getTypeReg().getStr()); - exit(5); + options.getProgramName().c_str(), options.getTypeReg().c_str()); + return (5); } - RegistryKey singletonKey, typeKey; + RegistryKey typeKey; if ( options.hasBase() ) { if ( typeRoot.openKey(S2U(options.getBase()), typeKey) ) { fprintf(stderr, "%s: open base key of registry \"%s\" failed\n", - options.getProgramName().getStr(), options.getTypeReg().getStr()); - exit(6); + options.getProgramName().c_str(), options.getTypeReg().c_str()); + return (6); } - } else + } + else { typeKey = typeRoot; } + RegistryKey singletonKey; if ( indexRoot.createKey(OUString::createFromAscii("SINGLETONS"), singletonKey) ) { fprintf(stderr, "%s: open/create SINGLETONS key of registry \"%s\" failed\n", - options.getProgramName().getStr(), options.getIndexReg().getStr()); - exit(7); + options.getProgramName().c_str(), options.getIndexReg().c_str()); + return (7); } - sal_Bool bSingletonsExist = checkSingletons(singletonKey, typeKey); + sal_Bool bSingletonsExist = checkSingletons(options, singletonKey, typeKey); indexRoot.releaseKey(); typeRoot.releaseKey(); @@ -460,24 +323,22 @@ int _cdecl main( int argc, char * argv[] ) if ( indexReg.close() ) { fprintf(stderr, "%s: closing registry \"%s\" failed\n", - options.getProgramName().getStr(), options.getIndexReg().getStr()); - exit(9); + options.getProgramName().c_str(), options.getIndexReg().c_str()); + return (9); } if ( !bSingletonsExist ) { if ( indexReg.destroy(OUString()) ) { fprintf(stderr, "%s: destroy registry \"%s\" failed\n", - options.getProgramName().getStr(), options.getIndexReg().getStr()); - exit(10); + options.getProgramName().c_str(), options.getIndexReg().c_str()); + return (10); } } if ( typeReg.close() ) { fprintf(stderr, "%s: closing registry \"%s\" failed\n", - options.getProgramName().getStr(), options.getTypeReg().getStr()); - exit(11); + options.getProgramName().c_str(), options.getTypeReg().c_str()); + return (11); } } - - diff --git a/registry/tools/fileurl.cxx b/registry/tools/fileurl.cxx new file mode 100644 index 000000000000..e3561888c674 --- /dev/null +++ b/registry/tools/fileurl.cxx @@ -0,0 +1,90 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +#include "fileurl.hxx" + +#include "rtl/ustring.hxx" +#include "osl/diagnose.h" +#include "osl/file.hxx" +#include "osl/process.h" +#include "osl/thread.h" + +#include + +#ifdef SAL_UNX +#define SEPARATOR '/' +#else +#define SEPARATOR '\\' +#endif + +using rtl::OUString; +using osl::FileBase; + +namespace registry +{ +namespace tools +{ + +OUString convertToFileUrl(char const * filename, size_t length) +{ + OUString const uFileName(filename, length, osl_getThreadTextEncoding()); + if (strncmp(filename, "file://", 7) == 0) + { + // already a FileUrl. + return uFileName; + } + + OUString uFileUrl; + if (length > 0) + { + if ((filename[0] == '.') || (filename[0] != SEPARATOR)) + { + // relative path name. + OUString uWorkingDir; + if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None) + { + OSL_ASSERT(false); + } + if (FileBase::getAbsoluteFileURL(uWorkingDir, uFileName, uFileUrl) != FileBase::E_None) + { + OSL_ASSERT(false); + } + } + else + { + // absolute path name. + if (FileBase::getFileURLFromSystemPath(uFileName, uFileUrl) != FileBase::E_None) + { + OSL_ASSERT(false); + } + } + } + return uFileUrl; +} + +} // namespace tools +} // namespace registry diff --git a/registry/tools/fileurl.hxx b/registry/tools/fileurl.hxx new file mode 100644 index 000000000000..bbaa218f32e6 --- /dev/null +++ b/registry/tools/fileurl.hxx @@ -0,0 +1,43 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +#ifndef INCLUDED_REGISTRY_TOOLS_FILEURL_HXX +#define INCLUDED_REGISTRY_TOOLS_FILEURL_HXX + +#include "rtl/ustring.hxx" + +namespace registry +{ +namespace tools +{ + +rtl::OUString convertToFileUrl(char const * filename, size_t length); + +} // namespace tools +} // namespace registry + +#endif /* INCLUDED_REGISTRY_TOOLS_FILEURL_HXX */ diff --git a/registry/tools/makefile.mk b/registry/tools/makefile.mk index bb7d448b86e6..e05a791425f9 100644 --- a/registry/tools/makefile.mk +++ b/registry/tools/makefile.mk @@ -43,7 +43,7 @@ ENABLE_EXCEPTIONS := TRUE CDEFS += -DDLL_VERSION=$(EMQ)"$(DLLPOSTFIX)$(EMQ)" APP1TARGET= $(TARGET) -APP1OBJS= $(OBJ)$/regmerge.obj +APP1OBJS= $(OBJ)$/regmerge.obj $(OBJ)/fileurl.obj $(OBJ)/options.obj APP1RPATH= UREBIN APP1STDLIBS=\ @@ -51,7 +51,7 @@ APP1STDLIBS=\ $(REGLIB) APP2TARGET= regview -APP2OBJS= $(OBJ)$/regview.obj +APP2OBJS= $(OBJ)$/regview.obj $(OBJ)/fileurl.obj APP2RPATH= UREBIN APP2STDLIBS=\ @@ -59,7 +59,7 @@ APP2STDLIBS=\ $(REGLIB) APP3TARGET= regcompare -APP3OBJS= $(OBJ)$/regcompare.obj +APP3OBJS= $(OBJ)$/regcompare.obj $(OBJ)/fileurl.obj $(OBJ)/options.obj APP3RPATH= SDK APP3STDLIBS=\ @@ -68,7 +68,7 @@ APP3STDLIBS=\ $(REGLIB) APP4TARGET= checksingleton -APP4OBJS= $(OBJ)$/checksingleton.obj +APP4OBJS= $(OBJ)$/checksingleton.obj $(OBJ)/fileurl.obj $(OBJ)/options.obj APP4STDLIBS=\ $(SALLIB) \ diff --git a/registry/tools/options.cxx b/registry/tools/options.cxx new file mode 100644 index 000000000000..d851825ebfb6 --- /dev/null +++ b/registry/tools/options.cxx @@ -0,0 +1,153 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +#include "options.hxx" + +#include "osl/diagnose.h" + +#include +#include + +namespace registry +{ +namespace tools +{ + +Options::Options (char const * program) + : m_program (program) +{} + +Options::~Options() +{} + +// static +bool Options::checkArgument(std::vector< std::string> & rArgs, char const * arg, size_t len) +{ + bool result = ((arg != 0) && (len > 0)); + OSL_PRECOND(result, "registry::tools::Options::checkArgument(): invalid arguments"); + if (result) + { + OSL_TRACE("registry::tools:Options::checkArgument(): \"%s\"", arg); + switch (arg[0]) + { + case '@': + if ((result = (len > 1)) == true) + { + // "@" + result = Options::checkCommandFile(rArgs, &(arg[1])); + } + break; + case '-': + if ((result = (len > 1)) == true) + { + // "-