diff -ruN yapet-0.4.bak/csv2yapet/main.cc yapet-0.4/csv2yapet/main.cc --- yapet-0.4.bak/csv2yapet/main.cc 2009-07-10 20:35:57.000000000 +0200 +++ yapet-0.4/csv2yapet/main.cc 2009-07-19 11:18:59.764674296 +0200 @@ -64,6 +64,7 @@ # include #endif +#include #include "csvimport.h" #if defined(HAVE_TERMIOS_H) && defined (HAVE_TCSETATTR) && defined (HAVE_TCGETATTR) @@ -269,8 +270,10 @@ return ERR_CMDLINE; } - if ( dstfile.find(".pet", dstfile.length() - 4) == std::string::npos ) - dstfile += ".pet"; + if ( dstfile.find(Consts::getDefaultSuffix(), + dstfile.length() - Consts::getDefaultSuffix().length()) + == std::string::npos ) + dstfile += Consts::getDefaultSuffix(); if (access(dstfile.c_str(), F_OK) == 0) { std::cerr << dstfile << " already exists. Aborting." << std::endl; diff -ruN yapet-0.4.bak/csv2yapet/Makefile.am yapet-0.4/csv2yapet/Makefile.am --- yapet-0.4.bak/csv2yapet/Makefile.am 2009-07-06 23:47:32.000000000 +0200 +++ yapet-0.4/csv2yapet/Makefile.am 2009-07-19 11:11:07.420602586 +0200 @@ -2,9 +2,9 @@ bin_PROGRAMS = csv2yapet -csv2yapet_SOURCES = main.cc csvimport.h csvimport.cc +csv2yapet_SOURCES = main.cc csvimport.h csvimport.cc $(top_srcdir)/yapet/consts.cc -csv2yapet_CPPFLAGS = -I$(top_srcdir)/crypt -DLOCALEDIR=\"$(localedir)\" +csv2yapet_CPPFLAGS = -I$(top_srcdir)/yapet -I$(top_srcdir)/crypt -DLOCALEDIR=\"$(localedir)\" if USE_INCLUDED_LIBINTL csv2yapet_CPPFLAGS += -I$(top_srcdir)/intl diff -ruN yapet-0.4.bak/csv2yapet/Makefile.in yapet-0.4/csv2yapet/Makefile.in --- yapet-0.4.bak/csv2yapet/Makefile.in 2009-07-11 22:54:56.000000000 +0200 +++ yapet-0.4/csv2yapet/Makefile.in 2009-07-19 11:11:33.796622981 +0200 @@ -64,7 +64,7 @@ binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_csv2yapet_OBJECTS = csv2yapet-main.$(OBJEXT) \ - csv2yapet-csvimport.$(OBJEXT) + csv2yapet-csvimport.$(OBJEXT) csv2yapet-consts.$(OBJEXT) csv2yapet_OBJECTS = $(am_csv2yapet_OBJECTS) csv2yapet_DEPENDENCIES = $(top_builddir)/crypt/libgpcrypt.a DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@ @@ -235,8 +235,8 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -csv2yapet_SOURCES = main.cc csvimport.h csvimport.cc -csv2yapet_CPPFLAGS = -I$(top_srcdir)/crypt \ +csv2yapet_SOURCES = main.cc csvimport.h csvimport.cc $(top_srcdir)/yapet/consts.cc +csv2yapet_CPPFLAGS = -I$(top_srcdir)/yapet -I$(top_srcdir)/crypt \ -DLOCALEDIR=\"$(localedir)\" $(am__append_1) csv2yapet_LDADD = $(top_builddir)/crypt/libgpcrypt.a @LIBINTL@ all: all-am @@ -305,6 +305,7 @@ distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/csv2yapet-consts.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/csv2yapet-csvimport.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/csv2yapet-main.Po@am__quote@ @@ -350,6 +351,20 @@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(csv2yapet_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o csv2yapet-csvimport.obj `if test -f 'csvimport.cc'; then $(CYGPATH_W) 'csvimport.cc'; else $(CYGPATH_W) '$(srcdir)/csvimport.cc'; fi` +csv2yapet-consts.o: $(top_srcdir)/yapet/consts.cc +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(csv2yapet_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT csv2yapet-consts.o -MD -MP -MF $(DEPDIR)/csv2yapet-consts.Tpo -c -o csv2yapet-consts.o `test -f '$(top_srcdir)/yapet/consts.cc' || echo '$(srcdir)/'`$(top_srcdir)/yapet/consts.cc +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/csv2yapet-consts.Tpo $(DEPDIR)/csv2yapet-consts.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(top_srcdir)/yapet/consts.cc' object='csv2yapet-consts.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(csv2yapet_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o csv2yapet-consts.o `test -f '$(top_srcdir)/yapet/consts.cc' || echo '$(srcdir)/'`$(top_srcdir)/yapet/consts.cc + +csv2yapet-consts.obj: $(top_srcdir)/yapet/consts.cc +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(csv2yapet_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT csv2yapet-consts.obj -MD -MP -MF $(DEPDIR)/csv2yapet-consts.Tpo -c -o csv2yapet-consts.obj `if test -f '$(top_srcdir)/yapet/consts.cc'; then $(CYGPATH_W) '$(top_srcdir)/yapet/consts.cc'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/yapet/consts.cc'; fi` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/csv2yapet-consts.Tpo $(DEPDIR)/csv2yapet-consts.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(top_srcdir)/yapet/consts.cc' object='csv2yapet-consts.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(csv2yapet_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o csv2yapet-consts.obj `if test -f '$(top_srcdir)/yapet/consts.cc'; then $(CYGPATH_W) '$(top_srcdir)/yapet/consts.cc'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/yapet/consts.cc'; fi` + ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ diff -ruN yapet-0.4.bak/yapet/cfgfile.cc yapet-0.4/yapet/cfgfile.cc --- yapet-0.4.bak/yapet/cfgfile.cc 2009-07-06 19:57:20.000000000 +0200 +++ yapet-0.4/yapet/cfgfile.cc 2009-07-19 11:21:07.596643249 +0200 @@ -42,6 +42,7 @@ #include #endif +#include "consts.h" #include "cfgfile.h" std::string ConfigFile::cfgfile(".yapet"); @@ -89,6 +90,10 @@ if (l.find(needle,0) == 0) { l.erase(0,needle.length()); filetoload = l; + if ( filetoload.find(Consts::getDefaultSuffix(), + filetoload.length() - Consts::getDefaultSuffix().length()) + == std::string::npos ) + filetoload += Consts::getDefaultSuffix(); continue; } needle = "locktimeout="; diff -ruN yapet-0.4.bak/yapet/consts.cc yapet-0.4/yapet/consts.cc --- yapet-0.4.bak/yapet/consts.cc 1970-01-01 01:00:00.000000000 +0100 +++ yapet-0.4/yapet/consts.cc 2009-07-19 11:10:02.160602989 +0200 @@ -0,0 +1,28 @@ +// $Id$ +// +// Copyright (C) 2009 Rafael Ostertag +// +// This file is part of YAPET. +// +// YAPET is free software: you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation, either version 3 of the License, or (at your option) any later +// version. +// +// YAPET 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 General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// YAPET. If not, see . +// + +#include "consts.h" + +const std::string Consts::default_suffix(".pet"); + +const std::string& +Consts::getDefaultSuffix() { + return default_suffix; +} diff -ruN yapet-0.4.bak/yapet/consts.h yapet-0.4/yapet/consts.h --- yapet-0.4.bak/yapet/consts.h 1970-01-01 01:00:00.000000000 +0100 +++ yapet-0.4/yapet/consts.h 2009-07-19 11:10:35.856643257 +0200 @@ -0,0 +1,54 @@ +// -*- c++ -*- +// +// $Id$ +// +// Copyright (C) 2009 Rafael Ostertag +// +// This file is part of YAPET. +// +// YAPET is free software: you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation, either version 3 of the License, or (at your option) any later +// version. +// +// YAPET 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 General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// YAPET. If not, see . +// + +/** + * @file + * + * Header file for constant values. + */ + +#ifndef _CONSTS_H +#define _CONSTS_H + +#ifdef HAVE_CONFIG_H +# include +#endif + +#ifdef HAVE_STRING +# include +#endif + +class Consts { + private: + //! Holds the default suffix for yapet files + static const std::string default_suffix; + inline Consts() {} + inline ~Consts() {} + inline Consts(const Consts&) {} + inline const Consts& operator=(const Consts&) { return *this; } + + public: + //! Return the default suffix for yapet files + static const std::string& getDefaultSuffix(); +}; + +#endif // _CONSTS_H diff -ruN yapet-0.4.bak/yapet/fileopen.cc yapet-0.4/yapet/fileopen.cc --- yapet-0.4.bak/yapet/fileopen.cc 2009-07-05 15:23:32.000000000 +0200 +++ yapet-0.4/yapet/fileopen.cc 2009-07-19 11:09:06.344643435 +0200 @@ -51,6 +51,7 @@ #include "../intl.h" #include #include +#include "consts.h" #include "fileopen.h" void @@ -112,7 +113,7 @@ d.push_back(de->d_name); } else if (S_ISREG(st.st_mode)) { std::string tmp(de->d_name); - if (endswith(tmp, ".pet") ) + if (endswith(tmp, Consts::getDefaultSuffix()) ) f.push_back(de->d_name); } } @@ -362,8 +363,8 @@ std::string FileOpen::getFilepath() { - if (!endswith(filename, ".pet")) - filename+=".pet"; + if (!endswith(filename, Consts::getDefaultSuffix().c_str())) + filename+=Consts::getDefaultSuffix().c_str(); std::string tmp_filename(filename.c_str()); std::string tmp_directory(directory.c_str()); diff -ruN yapet-0.4.bak/yapet/fileopen.h yapet-0.4/yapet/fileopen.h --- yapet-0.4.bak/yapet/fileopen.h 2009-07-05 19:18:14.000000000 +0200 +++ yapet-0.4/yapet/fileopen.h 2009-07-19 11:05:45.336602657 +0200 @@ -74,7 +74,6 @@ bool canceled; - inline FileOpen(const FileOpen&) {} inline const FileOpen& operator=(const FileOpen&) { return *this; } diff -ruN yapet-0.4.bak/yapet/main.cc yapet-0.4/yapet/main.cc --- yapet-0.4.bak/yapet/main.cc 2009-07-08 22:30:25.000000000 +0200 +++ yapet-0.4/yapet/main.cc 2009-07-19 11:08:19.900603293 +0200 @@ -87,9 +87,10 @@ #endif #include "../intl.h" -#include "fileopen.h" // for the endswith() functions +#include "fileopen.h" #include "mainwindow.h" #include "cfgfile.h" +#include "consts.h" /** * @file @@ -296,8 +297,8 @@ if (optind < argc) { filename = argv[optind]; - if (!endswith(filename, ".pet")) - filename+=".pet"; + if (!endswith(filename, Consts::getDefaultSuffix())) + filename+=Consts::getDefaultSuffix(); } YAPETUI::BaseWindow::initCurses(); diff -ruN yapet-0.4.bak/yapet/Makefile.am yapet-0.4/yapet/Makefile.am --- yapet-0.4.bak/yapet/Makefile.am 2009-07-06 21:40:50.000000000 +0200 +++ yapet-0.4/yapet/Makefile.am 2009-07-19 11:07:06.992602871 +0200 @@ -5,7 +5,7 @@ yapet_SOURCES = mainwindow.h statusbar.h fileopen.h passworddialog.h \ passwordrecord.h main.cc mainwindow.cc statusbar.cc fileopen.cc \ passworddialog.cc passwordrecord.cc searchdialog.h searchdialog.cc cfgfile.h \ -cfgfile.cc +cfgfile.cc consts.h consts.cc yapet_CPPFLAGS = -I$(top_srcdir)/crypt -I$(top_srcdir)/ui -DLOCALEDIR=\"$(localedir)\" diff -ruN yapet-0.4.bak/yapet/Makefile.in yapet-0.4/yapet/Makefile.in --- yapet-0.4.bak/yapet/Makefile.in 2009-07-11 22:54:58.000000000 +0200 +++ yapet-0.4/yapet/Makefile.in 2009-07-19 11:07:56.292604469 +0200 @@ -66,7 +66,8 @@ am_yapet_OBJECTS = yapet-main.$(OBJEXT) yapet-mainwindow.$(OBJEXT) \ yapet-statusbar.$(OBJEXT) yapet-fileopen.$(OBJEXT) \ yapet-passworddialog.$(OBJEXT) yapet-passwordrecord.$(OBJEXT) \ - yapet-searchdialog.$(OBJEXT) yapet-cfgfile.$(OBJEXT) + yapet-searchdialog.$(OBJEXT) yapet-cfgfile.$(OBJEXT) \ + yapet-consts.$(OBJEXT) yapet_OBJECTS = $(am_yapet_OBJECTS) yapet_DEPENDENCIES = $(top_builddir)/crypt/libgpcrypt.a \ $(top_builddir)/ui/libui.a @@ -241,7 +242,7 @@ yapet_SOURCES = mainwindow.h statusbar.h fileopen.h passworddialog.h \ passwordrecord.h main.cc mainwindow.cc statusbar.cc fileopen.cc \ passworddialog.cc passwordrecord.cc searchdialog.h searchdialog.cc cfgfile.h \ -cfgfile.cc +cfgfile.cc consts.h consts.cc yapet_CPPFLAGS = -I$(top_srcdir)/crypt -I$(top_srcdir)/ui \ -DLOCALEDIR=\"$(localedir)\" $(am__append_1) @@ -313,6 +314,7 @@ -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yapet-cfgfile.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yapet-consts.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yapet-fileopen.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yapet-main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yapet-mainwindow.Po@am__quote@ @@ -447,6 +449,20 @@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yapet_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yapet-cfgfile.obj `if test -f 'cfgfile.cc'; then $(CYGPATH_W) 'cfgfile.cc'; else $(CYGPATH_W) '$(srcdir)/cfgfile.cc'; fi` +yapet-consts.o: consts.cc +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yapet_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yapet-consts.o -MD -MP -MF $(DEPDIR)/yapet-consts.Tpo -c -o yapet-consts.o `test -f 'consts.cc' || echo '$(srcdir)/'`consts.cc +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/yapet-consts.Tpo $(DEPDIR)/yapet-consts.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='consts.cc' object='yapet-consts.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yapet_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yapet-consts.o `test -f 'consts.cc' || echo '$(srcdir)/'`consts.cc + +yapet-consts.obj: consts.cc +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yapet_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT yapet-consts.obj -MD -MP -MF $(DEPDIR)/yapet-consts.Tpo -c -o yapet-consts.obj `if test -f 'consts.cc'; then $(CYGPATH_W) 'consts.cc'; else $(CYGPATH_W) '$(srcdir)/consts.cc'; fi` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/yapet-consts.Tpo $(DEPDIR)/yapet-consts.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='consts.cc' object='yapet-consts.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(yapet_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o yapet-consts.obj `if test -f 'consts.cc'; then $(CYGPATH_W) 'consts.cc'; else $(CYGPATH_W) '$(srcdir)/consts.cc'; fi` + ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \