From 1a4615a891172a58eff43f5ef0cd150b67798f4e Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 27 Jan 2013 01:03:32 -0600 Subject: Rename a number of libraries and executables to avoid conflicts with KDE4 --- libtdegames/highscore/Makefile.am | 10 +-- libtdegames/highscore/kconfigrawbackend.cpp | 62 ----------------- libtdegames/highscore/kconfigrawbackend.h | 58 ---------------- libtdegames/highscore/kexthighscore_gui.cpp | 4 +- libtdegames/highscore/kexthighscore_internal.cpp | 4 +- libtdegames/highscore/kexthighscore_internal.h | 2 +- libtdegames/highscore/kfilelock.cpp | 88 ------------------------ libtdegames/highscore/kfilelock.h | 53 -------------- libtdegames/highscore/khighscore.cpp | 4 +- libtdegames/highscore/kscoredialog.cpp | 2 +- libtdegames/highscore/tdeconfigrawbackend.cpp | 62 +++++++++++++++++ libtdegames/highscore/tdeconfigrawbackend.h | 58 ++++++++++++++++ libtdegames/highscore/tdefilelock.cpp | 88 ++++++++++++++++++++++++ libtdegames/highscore/tdefilelock.h | 53 ++++++++++++++ libtdegames/kchatbase.cpp | 2 +- libtdegames/kstdgameaction.cpp | 2 +- 16 files changed, 276 insertions(+), 276 deletions(-) delete mode 100644 libtdegames/highscore/kconfigrawbackend.cpp delete mode 100644 libtdegames/highscore/kconfigrawbackend.h delete mode 100644 libtdegames/highscore/kfilelock.cpp delete mode 100644 libtdegames/highscore/kfilelock.h create mode 100644 libtdegames/highscore/tdeconfigrawbackend.cpp create mode 100644 libtdegames/highscore/tdeconfigrawbackend.h create mode 100644 libtdegames/highscore/tdefilelock.cpp create mode 100644 libtdegames/highscore/tdefilelock.h (limited to 'libtdegames') diff --git a/libtdegames/highscore/Makefile.am b/libtdegames/highscore/Makefile.am index 6fa18cc0..3635c3b5 100644 --- a/libtdegames/highscore/Makefile.am +++ b/libtdegames/highscore/Makefile.am @@ -2,8 +2,8 @@ noinst_LTLIBRARIES = libkhighscore.la INCLUDES = $(all_includes) -libkhighscore_la_SOURCES = kconfigrawbackend.cpp \ - kfilelock.cpp khighscore.cpp kscoredialog.cpp \ +libkhighscore_la_SOURCES = tdeconfigrawbackend.cpp \ + tdefilelock.cpp khighscore.cpp kscoredialog.cpp \ kexthighscore_item.cpp kexthighscore_internal.cpp \ kexthighscore_tab.cpp kexthighscore_gui.cpp \ kexthighscore.cpp @@ -11,9 +11,9 @@ libkhighscore_la_SOURCES = kconfigrawbackend.cpp \ include_HEADERS = khighscore.h kscoredialog.h \ kexthighscore_item.h kexthighscore.h -noinst_HEADERS = kconfigrawbackend.h \ - kfilelock.h kexthighscore_internal.h kexthighscore_tab.h \ +noinst_HEADERS = tdeconfigrawbackend.h \ + tdefilelock.h kexthighscore_internal.h kexthighscore_tab.h \ kexthighscore_gui.h -METASOURCES = kconfigrawbackend.moc khighscore.moc kscoredialog.moc \ +METASOURCES = tdeconfigrawbackend.moc khighscore.moc kscoredialog.moc \ kexthighscore_tab.moc kexthighscore_gui.moc diff --git a/libtdegames/highscore/kconfigrawbackend.cpp b/libtdegames/highscore/kconfigrawbackend.cpp deleted file mode 100644 index 7f75ed5d..00000000 --- a/libtdegames/highscore/kconfigrawbackend.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - This file is part of the TDE games library - Copyright (C) 2003 Nicolas Hadacek - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "kconfigrawbackend.h" -#include "kconfigrawbackend.moc" - -#include -#include - - -TDEConfigRawBackEnd::TDEConfigRawBackEnd(TDEConfigBase *_config, int fd) - : TDEConfigINIBackEnd(_config, TQString(), "config", false), - _fd(fd), _stream(0) -{ - _file.open(IO_ReadOnly, _fd); -} - -TDEConfigRawBackEnd::~TDEConfigRawBackEnd() -{ - if (_stream) fclose(_stream); -} - -bool TDEConfigRawBackEnd::parseConfigFiles() -{ - _file.reset(); - parseSingleConfigFile(_file); - return true; -} - -void TDEConfigRawBackEnd::sync(bool bMerge) -{ - // write-sync is only necessary if there are dirty entries - if ( !pConfig->isDirty() || pConfig->isReadOnly() ) return; - - _file.reset(); - KEntryMap aTempMap; - getEntryMap(aTempMap, false, bMerge ? &_file : 0); - - if ( _stream==0 ) { - _stream = fdopen(_fd, "w"); - if ( _stream==0 ) return; - } - ftruncate(_fd, 0); - writeEntries(_stream, aTempMap); - fflush(_stream); -} diff --git a/libtdegames/highscore/kconfigrawbackend.h b/libtdegames/highscore/kconfigrawbackend.h deleted file mode 100644 index 249fa22b..00000000 --- a/libtdegames/highscore/kconfigrawbackend.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - This file is part of the TDE games library - Copyright (C) 2003 Nicolas Hadacek - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef _KCONFIGRAWBACKEND_H -#define _KCONFIGRAWBACKEND_H - -#include - -#include -#include - - -class TDEConfigRawBackEnd : public TDEConfigINIBackEnd -{ -public: - TDEConfigRawBackEnd(TDEConfigBase *_config, int fd); - ~TDEConfigRawBackEnd(); - - bool parseConfigFiles(); - - void sync(bool bMerge = true); - -private: - int _fd; - FILE *_stream; - TQFile _file; - - class TDEConfigRawBackEndPrivate; - TDEConfigRawBackEndPrivate *d; -}; - -class KRawConfig : public KSimpleConfig -{ - Q_OBJECT - -public: - KRawConfig(int fd, bool readOnly) - : KSimpleConfig(new TDEConfigRawBackEnd(this, fd), readOnly) {} -}; - - -#endif diff --git a/libtdegames/highscore/kexthighscore_gui.cpp b/libtdegames/highscore/kexthighscore_gui.cpp index fa1a1887..a66050a6 100644 --- a/libtdegames/highscore/kexthighscore_gui.cpp +++ b/libtdegames/highscore/kexthighscore_gui.cpp @@ -31,9 +31,9 @@ #include #include #include -#include +#include #include -#include +#include #include #include "kexthighscore_internal.h" diff --git a/libtdegames/highscore/kexthighscore_internal.cpp b/libtdegames/highscore/kexthighscore_internal.cpp index dae5be91..05c51562 100644 --- a/libtdegames/highscore/kexthighscore_internal.cpp +++ b/libtdegames/highscore/kexthighscore_internal.cpp @@ -28,8 +28,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/libtdegames/highscore/kexthighscore_internal.h b/libtdegames/highscore/kexthighscore_internal.h index f6924662..fd690b07 100644 --- a/libtdegames/highscore/kexthighscore_internal.h +++ b/libtdegames/highscore/kexthighscore_internal.h @@ -21,7 +21,7 @@ #define KEXTHIGHSCORE_INTERNAL_H #include -#include +#include #include #include diff --git a/libtdegames/highscore/kfilelock.cpp b/libtdegames/highscore/kfilelock.cpp deleted file mode 100644 index 4f632f02..00000000 --- a/libtdegames/highscore/kfilelock.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - This file is part of the TDE games library - Copyright (C) 2003 Nicolas Hadacek - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "kfilelock.h" - -#include -#include -#include - -#include - - -KFileLock::KFileLock(int fd) - : _fd(fd), _locked(false) -{} - -int KFileLock::lock() -{ - kdDebug(11002) << "lock fd=" << _fd << endl; -#ifdef F_SETLK -# ifndef SEEK_SET -# define SEEK_SET 0 -# endif - struct flock lock_data; - lock_data.l_type = F_WRLCK; - lock_data.l_whence = SEEK_SET; - lock_data.l_start = lock_data.l_len = 0; - if ( fcntl(_fd, F_SETLK, &lock_data)==-1 ) { - if ( errno==EAGAIN ) return -2; - return -1; - } -#else -# ifdef LOCK_EX - if ( flock (_fd, LOCK_EX|LOCK_NB)==-1 ) { - if ( errno==EWOULDBLOCK ) return -2; - return -1; - } -# else - if ( lockf(_fd, F_TLOCK, 0)==-1 ) { - if ( errno==EACCES ) return -2; - return -1; - } -# endif -#endif - _locked = true; - return 0; -} - -KFileLock::~KFileLock() -{ - unlock(); -} - -void KFileLock::unlock() -{ - if ( !_locked ) return; - kdDebug(11002) << "unlock" << endl; -# ifdef F_SETLK - struct flock lock_data; - lock_data.l_type = F_UNLCK; - lock_data.l_whence = SEEK_SET; - lock_data.l_start = lock_data.l_len = 0; - (void)fcntl(_fd, F_SETLK, &lock_data); -# else -# ifdef F_ULOCK - lockf(_fd, F_ULOCK, 0); -# else - flock(_fd, LOCK_UN); -# endif -# endif - _locked = false; -} diff --git a/libtdegames/highscore/kfilelock.h b/libtdegames/highscore/kfilelock.h deleted file mode 100644 index de47f945..00000000 --- a/libtdegames/highscore/kfilelock.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - This file is part of the TDE games library - Copyright (C) 2003 Nicolas Hadacek - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ -#ifndef KFILELOCK_H -#define KFILELOCK_H - - -class KFileLock -{ -public: - KFileLock(int fd); - - /** Call unlock(). */ - ~KFileLock(); - - /** @return the file descriptor. */ - int fd() const { return _fd; } - - /* - * Lock the file. - * @return 0 on success, -1 on failure (no permission) and -2 if another - * process is currently locking the file. - */ - int lock(); - - /** Unlock the file. */ - void unlock(); - - /** @return true if we currently lock the file. */ - bool isLocked() const { return _locked; } - -private: - int _fd; - bool _locked; -}; - - -#endif diff --git a/libtdegames/highscore/khighscore.cpp b/libtdegames/highscore/khighscore.cpp index 8a36a748..3555c76e 100644 --- a/libtdegames/highscore/khighscore.cpp +++ b/libtdegames/highscore/khighscore.cpp @@ -36,8 +36,8 @@ #include #include "khighscore.h" -#include "kconfigrawbackend.h" -#include "kfilelock.h" +#include "tdeconfigrawbackend.h" +#include "tdefilelock.h" #define GROUP "KHighscore" diff --git a/libtdegames/highscore/kscoredialog.cpp b/libtdegames/highscore/kscoredialog.cpp index 1c3d241a..8db70fee 100644 --- a/libtdegames/highscore/kscoredialog.cpp +++ b/libtdegames/highscore/kscoredialog.cpp @@ -33,7 +33,7 @@ this software. #include #include -#include +#include #include #include diff --git a/libtdegames/highscore/tdeconfigrawbackend.cpp b/libtdegames/highscore/tdeconfigrawbackend.cpp new file mode 100644 index 00000000..80b4da96 --- /dev/null +++ b/libtdegames/highscore/tdeconfigrawbackend.cpp @@ -0,0 +1,62 @@ +/* + This file is part of the TDE games library + Copyright (C) 2003 Nicolas Hadacek + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "tdeconfigrawbackend.h" +#include "tdeconfigrawbackend.moc" + +#include +#include + + +TDEConfigRawBackEnd::TDEConfigRawBackEnd(TDEConfigBase *_config, int fd) + : TDEConfigINIBackEnd(_config, TQString(), "config", false), + _fd(fd), _stream(0) +{ + _file.open(IO_ReadOnly, _fd); +} + +TDEConfigRawBackEnd::~TDEConfigRawBackEnd() +{ + if (_stream) fclose(_stream); +} + +bool TDEConfigRawBackEnd::parseConfigFiles() +{ + _file.reset(); + parseSingleConfigFile(_file); + return true; +} + +void TDEConfigRawBackEnd::sync(bool bMerge) +{ + // write-sync is only necessary if there are dirty entries + if ( !pConfig->isDirty() || pConfig->isReadOnly() ) return; + + _file.reset(); + KEntryMap aTempMap; + getEntryMap(aTempMap, false, bMerge ? &_file : 0); + + if ( _stream==0 ) { + _stream = fdopen(_fd, "w"); + if ( _stream==0 ) return; + } + ftruncate(_fd, 0); + writeEntries(_stream, aTempMap); + fflush(_stream); +} diff --git a/libtdegames/highscore/tdeconfigrawbackend.h b/libtdegames/highscore/tdeconfigrawbackend.h new file mode 100644 index 00000000..53cfd174 --- /dev/null +++ b/libtdegames/highscore/tdeconfigrawbackend.h @@ -0,0 +1,58 @@ +/* + This file is part of the TDE games library + Copyright (C) 2003 Nicolas Hadacek + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _KCONFIGRAWBACKEND_H +#define _KCONFIGRAWBACKEND_H + +#include + +#include +#include + + +class TDEConfigRawBackEnd : public TDEConfigINIBackEnd +{ +public: + TDEConfigRawBackEnd(TDEConfigBase *_config, int fd); + ~TDEConfigRawBackEnd(); + + bool parseConfigFiles(); + + void sync(bool bMerge = true); + +private: + int _fd; + FILE *_stream; + TQFile _file; + + class TDEConfigRawBackEndPrivate; + TDEConfigRawBackEndPrivate *d; +}; + +class KRawConfig : public KSimpleConfig +{ + Q_OBJECT + +public: + KRawConfig(int fd, bool readOnly) + : KSimpleConfig(new TDEConfigRawBackEnd(this, fd), readOnly) {} +}; + + +#endif diff --git a/libtdegames/highscore/tdefilelock.cpp b/libtdegames/highscore/tdefilelock.cpp new file mode 100644 index 00000000..b5f56dfd --- /dev/null +++ b/libtdegames/highscore/tdefilelock.cpp @@ -0,0 +1,88 @@ +/* + This file is part of the TDE games library + Copyright (C) 2003 Nicolas Hadacek + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "tdefilelock.h" + +#include +#include +#include + +#include + + +KFileLock::KFileLock(int fd) + : _fd(fd), _locked(false) +{} + +int KFileLock::lock() +{ + kdDebug(11002) << "lock fd=" << _fd << endl; +#ifdef F_SETLK +# ifndef SEEK_SET +# define SEEK_SET 0 +# endif + struct flock lock_data; + lock_data.l_type = F_WRLCK; + lock_data.l_whence = SEEK_SET; + lock_data.l_start = lock_data.l_len = 0; + if ( fcntl(_fd, F_SETLK, &lock_data)==-1 ) { + if ( errno==EAGAIN ) return -2; + return -1; + } +#else +# ifdef LOCK_EX + if ( flock (_fd, LOCK_EX|LOCK_NB)==-1 ) { + if ( errno==EWOULDBLOCK ) return -2; + return -1; + } +# else + if ( lockf(_fd, F_TLOCK, 0)==-1 ) { + if ( errno==EACCES ) return -2; + return -1; + } +# endif +#endif + _locked = true; + return 0; +} + +KFileLock::~KFileLock() +{ + unlock(); +} + +void KFileLock::unlock() +{ + if ( !_locked ) return; + kdDebug(11002) << "unlock" << endl; +# ifdef F_SETLK + struct flock lock_data; + lock_data.l_type = F_UNLCK; + lock_data.l_whence = SEEK_SET; + lock_data.l_start = lock_data.l_len = 0; + (void)fcntl(_fd, F_SETLK, &lock_data); +# else +# ifdef F_ULOCK + lockf(_fd, F_ULOCK, 0); +# else + flock(_fd, LOCK_UN); +# endif +# endif + _locked = false; +} diff --git a/libtdegames/highscore/tdefilelock.h b/libtdegames/highscore/tdefilelock.h new file mode 100644 index 00000000..de47f945 --- /dev/null +++ b/libtdegames/highscore/tdefilelock.h @@ -0,0 +1,53 @@ +/* + This file is part of the TDE games library + Copyright (C) 2003 Nicolas Hadacek + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef KFILELOCK_H +#define KFILELOCK_H + + +class KFileLock +{ +public: + KFileLock(int fd); + + /** Call unlock(). */ + ~KFileLock(); + + /** @return the file descriptor. */ + int fd() const { return _fd; } + + /* + * Lock the file. + * @return 0 on success, -1 on failure (no permission) and -2 if another + * process is currently locking the file. + */ + int lock(); + + /** Unlock the file. */ + void unlock(); + + /** @return true if we currently lock the file. */ + bool isLocked() const { return _locked; } + +private: + int _fd; + bool _locked; +}; + + +#endif diff --git a/libtdegames/kchatbase.cpp b/libtdegames/kchatbase.cpp index 5422c552..14395d1e 100644 --- a/libtdegames/kchatbase.cpp +++ b/libtdegames/kchatbase.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include diff --git a/libtdegames/kstdgameaction.cpp b/libtdegames/kstdgameaction.cpp index 8e94a908..368b26ff 100644 --- a/libtdegames/kstdgameaction.cpp +++ b/libtdegames/kstdgameaction.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include -- cgit v1.2.1