Compare commits

..
1 Commits
Author SHA1 Message Date
Alexander Shaduri ad85368aa1 Tagging 0.8.0rc3:
Added support for udevless Linux distributions by providing a fallback
        /proc/partitions-based drive detection method. The new method adds
        support for Linux 2.4 and older systems. Thanks to Paul Marwick for
        reporting and testing.
    Fixed invalid error messages with directory-related operations.
    Fixed invalid verbosity levels of console output of debug messages in
        non-debug builds.
    Improved rpm spec file - now supports building on OpenSUSE build
        service with various distributions as targets.
2010-12-26 18:50:20 +00:00
296 changed files with 16179 additions and 31453 deletions
+1 -3
View File
@@ -8,11 +8,9 @@ config.guess
config.sub
aclocal.m4
config.h.in
compile
ar-lib
missing
install-sh
*.glade.cpp
*.ui.cpp
*.txt.cpp
.kdev4
gsmartcontrol.spec
-1
View File
@@ -1 +0,0 @@
svn propset svn:ignore -F .svnignore.txt .
+1 -1
View File
@@ -1 +1 @@
See the NEWS file.
See NEWS file.
-1743
View File
File diff suppressed because it is too large Load Diff
-25
View File
@@ -1,25 +0,0 @@
Copyright (c) 2006-2008 Alexander Chemeris
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+2 -5
View File
@@ -18,15 +18,12 @@ If not, see <http://www.gnu.org/licenses/>.
See LICENSE_gpl2.txt and LICENSE_gpl3.txt for details.
All files which don't have any copyright notices, as well as tests and
examples are covered under the Unlicense. See LICENSE_unlicense.txt for
details.
Portions of this software are copyright Google Inc. See LICENSE_pcrecpp.txt
for details.
This product includes the HZ library (or portions of it). See LICENSE_hz.txt
for details.
This product includes icons from Crystal Project,
copyright 2006-2007 Everaldo Coelho.
http://www.everaldo.com/crystal, http://www.yellowicon.com .
+6 -22
View File
@@ -4,37 +4,21 @@ HZ Library License
The HZ library contains software licensed under several different licenses.
This is due to HZ including portions of other software.
All original code is licensed under the Zlib License. See LICENSE_zlib.txt for
details.
All original code (except for the tests) is licensed under the Zlib License.
See LICENSE_zlib.txt for details.
All tests and examples are covered under the Unlicense. See
LICENSE_unlicense.txt for details.
Portions of this software are copyright Regents of the University of
California, see LICENSE_bsd-ucb.txt for details.
Portions of this software are copyright Alexander Chemeris, see
LICENSE_bsd-ac.txt for details.
Portions of this software are copyright Regents of the University of California,
see LICENSE_bsd-ucb.txt for details.
Portions of this software are licensed under Boost Software License, see
LICENSE_boost_1_0.txt and individual source files for copyright information.
Each source file contains its copyright information.
If you intend to use HZ in your product, please note that you MUST include
these licenses somewhere in your distribution (simply redistributing the
license files or reproducing their texts in documentation and/or other
supplied materials is OK):
license files or reproducing their texts in documentation and/or other supplied
materials is OK):
* LICENSE_zlib.txt (source distributions only);
* LICENSE_bsd-ucb.txt (source and binary distributions);
* LICENSE_boost_1_0.txt (source distributions only).
If you use only portions of HZ, you may ignore this requirement for files you
don't use. For example, if you don't use any of the Boost-licensed files, you
are not required to distribute the Boost license.
+28
View File
@@ -0,0 +1,28 @@
Copyright (c) 2005, Google Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-25
View File
@@ -1,25 +0,0 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
+22 -223
View File
@@ -2,11 +2,11 @@
# Add autoconf.m4 directory to local macro search path
ACLOCAL_AMFLAGS = -I autoconf.m4
SUBDIRS = data debian.dist src
SUBDIRS = src data
# These files are actually needed for compilation.
noinst_DATA = AUTHORS.txt LICENSE_gsmartcontrol.txt
noinst_DATA = AUTHORS.txt LICENSE_gsmartcontrol.txt README.txt
# For the files to be bundled with the distribution, specify them in
@@ -16,247 +16,46 @@ noinst_DATA = AUTHORS.txt LICENSE_gsmartcontrol.txt
# Some of these files are actually needed for compilation (see src/res/Makefile.am).
dist_doc_DATA = AUTHORS.txt ChangeLog NEWS README.txt \
LICENSE_boost_1_0.txt \
LICENSE_bsd-ac.txt \
LICENSE_bsd-ucb.txt \
LICENSE_gpl2.txt \
LICENSE_gpl3.txt \
LICENSE_gsmartcontrol.txt \
LICENSE_hz.txt \
LICENSE_unlicense.txt \
LICENSE_pcrecpp.txt \
LICENSE_zlib.txt
# nobase_ preserves their directory names.
nobase_dist_doc_DATA = contrib/cron-based_noadmin/README \
contrib/cron-based_noadmin/cron_gather_smart.sh \
contrib/cron-based_noadmin/crontab.example \
contrib/cron-based_noadmin/smartctl_subst.sh
# Extra files bundled with distribution.
# file2csource.sh is needed for building but not installed.
EXTRA_DIST = COPYING INSTALL configure autogen.sh \
gsmartcontrol.kdev4 \
EXTRA_DIST = COPYING TODO INSTALL configure autogen.sh \
baqup gsmartcontrol.kdevelop \
templates \
file2csource.sh \
gsmartcontrol.spec
# PCH support
global_macros.h.gch: $(top_srcdir)/src/global_macros.h
$(CXX) $(CXXFLAGS) $(DEFS) -x "c++-header" $(top_srcdir)/src/global_macros.h -o global_macros.h.gch
gch: global_macros.h.gch
gch-clean:
rm -f global_macros.h.gch
distclean-local: gch-clean
# rpm support
src-rpm: dist
rpmbuild -ts $(distdir).tar.bz2
# NSIS installer support.
# Requires installed NSIS, smartctl-nc.exe, smartctl.exe, update-smart-drivedb.exe.
# Gtkmm and pcre dlls are required if linking against them.
# dos2unix on build machine.
# Execute only with win32 build present.
WIN_ZIP_NAME = $(PACKAGE)-$(VERSION)-@WINDOWS_SUFFIX@
win-dist: win-dist-nocleanup win-dist-cleanup
win-dist-nocleanup: win-dist-prepare nsis-dist-nocleanup win-zip-dist-nocleanup
win-dist-cleanup: win-zip-dist-cleanup nsis-dist-cleanup
rm -rf win-dist
win-dist-clean: win-dist-cleanup
rm -f gsmartcontrol-*.exe gsmartcontrol-*.zip
win-dist-prepare-all: nsis-dist-prepare win-zip-dist-prepare
# All of GTK+
GTK_BIN_FILES = gdk-pixbuf-query-loaders.exe \
gspawn-win32-helper-console.exe \
gspawn-win32-helper.exe \
gspawn-win64-helper-console.exe \
gspawn-win64-helper.exe \
gtk-query-immodules-3.0.exe \
gtk-update-icon-cache-3.0.exe \
libatk-1.*.dll \
libatkmm-1.*.dll \
libbz2-*.dll \
libcairo-*.dll \
libcairomm-1*.dll \
libepoxy-*.dll \
libffi-*.dll \
libexpat-*.dll \
libfontconfig-*.dll \
libfreetype-*.dll \
libgdk-3*.dll \
libgdk_pixbuf-2.*.dll \
libgdkmm-3.*.dll \
libgio-2.*.dll \
libgiomm-2.*.dll \
libglib-2.*.dll \
libglibmm*2.*.dll \
libgmodule-2.*.dll \
libgobject-2.*.dll \
libgraphite*.dll \
libgthread-2.*.dll \
libgtk-3*.dll \
libgtkmm-3*.dll \
libharfbuzz*.dll \
libiconv*.dll \
libintl*.dll \
libjasper*.dll \
libjpeg*.dll \
liblzma*.dll \
libpango*-1.*.dll \
libpixman*.dll \
libpng16-*.dll \
libsigc-2.*.dll \
libstdc++-*.dll \
libtiff-*.dll \
libwinpthread-*.dll \
libxml2-*.dll \
zlib1.dll
# Don't strip smartctl (it will only change the header), and
# don't strip update-smart-drivedb (it will break its CRC check).
win-dist-prepare: all
$(MKDIR_P) win-dist
cp $(top_srcdir)/data/icon_*.png win-dist/
$(MKDIR_P) win-dist/doc
cp data/nsis/distribution.txt win-dist/doc/
cp $(top_srcdir)/AUTHORS.txt $(top_srcdir)/LICENSE_* $(top_srcdir)/README.txt win-dist/doc/
cp $(top_srcdir)/NEWS win-dist/doc/NEWS.txt
cp src/gsmartcontrol.exe src/gsmartcontrol.exe.manifest win-dist/
unix2dos win-dist/doc/*.txt
cp -p "@WINDOWS_SYSROOT@"/bin/drivedb.h win-dist/
cp -p "@WINDOWS_SYSROOT@"/bin/smartctl-nc.exe win-dist/
cp -p "@WINDOWS_SYSROOT@"/bin/smartctl.exe win-dist/
cp -p "@WINDOWS_SYSROOT@"/bin/update-smart-drivedb.exe win-dist/
for file in $(GTK_BIN_FILES); do for f in "@WINDOWS_SYSROOT@/bin/"$$file; do if test -f "$${f}"; then cp -p "$${f}" win-dist/; fi; done; done
# <prefix>/etc/gtk-3.0/ should contain settings.ini with a win32 theme.
$(MKDIR_P) win-dist/etc
$(MKDIR_P) win-dist/etc/fonts
$(MKDIR_P) win-dist/etc/gtk-3.0
cp -p "@WINDOWS_SYSROOT@"/etc/fonts/fonts.conf win-dist/etc/fonts/
# cp -p "@WINDOWS_SYSROOT@"/etc/gtk-3.0/im-multipress.conf win-dist/etc/gtk-3.0/
cp -p "@WINDOWS_SYSROOT@"/etc/gtk-3.0/settings.ini win-dist/etc/gtk-3.0/
$(MKDIR_P) win-dist/share
cp -p -r "@WINDOWS_SYSROOT@"/share/themes win-dist/share
# needed for file chooser
$(MKDIR_P) win-dist/share/glib-2.0
cp -p -r "@WINDOWS_SYSROOT@"/share/glib-2.0/schemas win-dist/share/glib-2.0
# $(MKDIR_P) win-dist/share/icons
# cp -p "@WINDOWS_SYSROOT@"/share/icons/hicolor win-dist/share/icons
# needed for window titlebar (if using client-side decorations),
# tree sorting indicators, GUI icons.
$(MKDIR_P) win-dist/share/icons/Adwaita/16x16/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/16x16/actions/window-close-symbolic.symbolic.png win-dist/share/icons/Adwaita/16x16/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/16x16/actions/window-maximize-symbolic.symbolic.png win-dist/share/icons/Adwaita/16x16/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/16x16/actions/window-minimize-symbolic.symbolic.png win-dist/share/icons/Adwaita/16x16/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/16x16/actions/window-restore-symbolic.symbolic.png win-dist/share/icons/Adwaita/16x16/actions
cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/16x16/actions/pan-down-symbolic.symbolic.png win-dist/share/icons/Adwaita/16x16/actions
cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/16x16/actions/pan-up-symbolic.symbolic.png win-dist/share/icons/Adwaita/16x16/actions
$(MKDIR_P) win-dist/share/icons/Adwaita/16x16/status
cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/16x16/status/dialog-information.png win-dist/share/icons/Adwaita/16x16/status
$(MKDIR_P) win-dist/share/icons/Adwaita/22x22/status
cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/22x22/status/dialog-information.png win-dist/share/icons/Adwaita/22x22/status
$(MKDIR_P) win-dist/share/icons/Adwaita/24x24/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/24x24/actions/window-close-symbolic.symbolic.png win-dist/share/icons/Adwaita/24x24/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/24x24/actions/window-maximize-symbolic.symbolic.png win-dist/share/icons/Adwaita/24x24/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/24x24/actions/window-minimize-symbolic.symbolic.png win-dist/share/icons/Adwaita/24x24/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/24x24/actions/window-restore-symbolic.symbolic.png win-dist/share/icons/Adwaita/24x24/actions
cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/24x24/actions/pan-down-symbolic.symbolic.png win-dist/share/icons/Adwaita/24x24/actions
cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/24x24/actions/pan-up-symbolic.symbolic.png win-dist/share/icons/Adwaita/24x24/actions
$(MKDIR_P) win-dist/share/icons/Adwaita/24x24/status
cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/24x24/status/dialog-information.png win-dist/share/icons/Adwaita/24x24/status
$(MKDIR_P) win-dist/share/icons/Adwaita/32x32/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/32x32/actions/window-close-symbolic.symbolic.png win-dist/share/icons/Adwaita/32x32/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/32x32/actions/window-maximize-symbolic.symbolic.png win-dist/share/icons/Adwaita/32x32/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/32x32/actions/window-minimize-symbolic.symbolic.png win-dist/share/icons/Adwaita/32x32/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/32x32/actions/window-restore-symbolic.symbolic.png win-dist/share/icons/Adwaita/32x32/actions
cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/32x32/actions/pan-down-symbolic.symbolic.png win-dist/share/icons/Adwaita/32x32/actions
cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/32x32/actions/pan-up-symbolic.symbolic.png win-dist/share/icons/Adwaita/32x32/actions
$(MKDIR_P) win-dist/share/icons/Adwaita/32x32/status
cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/32x32/status/dialog-information.png win-dist/share/icons/Adwaita/32x32/status
$(MKDIR_P) win-dist/share/icons/Adwaita/48x48/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/48x48/actions/window-close-symbolic.symbolic.png win-dist/share/icons/Adwaita/48x48/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/48x48/actions/window-maximize-symbolic.symbolic.png win-dist/share/icons/Adwaita/48x48/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/48x48/actions/window-minimize-symbolic.symbolic.png win-dist/share/icons/Adwaita/48x48/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/48x48/actions/window-restore-symbolic.symbolic.png win-dist/share/icons/Adwaita/48x48/actions
cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/48x48/actions/pan-down-symbolic.symbolic.png win-dist/share/icons/Adwaita/48x48/actions
cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/48x48/actions/pan-up-symbolic.symbolic.png win-dist/share/icons/Adwaita/48x48/actions
$(MKDIR_P) win-dist/share/icons/Adwaita/48x48/status
cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/48x48/status/dialog-information.png win-dist/share/icons/Adwaita/48x48/status
$(MKDIR_P) win-dist/share/icons/Adwaita/64x64/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/64x64/actions/window-close-symbolic.symbolic.png win-dist/share/icons/Adwaita/64x64/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/64x64/actions/window-maximize-symbolic.symbolic.png win-dist/share/icons/Adwaita/64x64/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/64x64/actions/window-minimize-symbolic.symbolic.png win-dist/share/icons/Adwaita/64x64/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/64x64/actions/window-restore-symbolic.symbolic.png win-dist/share/icons/Adwaita/64x64/actions
cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/64x64/actions/pan-down-symbolic.symbolic.png win-dist/share/icons/Adwaita/64x64/actions
cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/64x64/actions/pan-up-symbolic.symbolic.png win-dist/share/icons/Adwaita/64x64/actions
# $(MKDIR_P) win-dist/share/icons/Adwaita/64x64/status
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/64x64/status/dialog-information.png win-dist/share/icons/Adwaita/64x64/status
$(MKDIR_P) win-dist/share/icons/Adwaita/96x96/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/96x96/actions/window-close-symbolic.symbolic.png win-dist/share/icons/Adwaita/96x96/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/96x96/actions/window-maximize-symbolic.symbolic.png win-dist/share/icons/Adwaita/96x96/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/96x96/actions/window-minimize-symbolic.symbolic.png win-dist/share/icons/Adwaita/96x96/actions
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/96x96/actions/window-restore-symbolic.symbolic.png win-dist/share/icons/Adwaita/96x96/actions
cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/96x96/actions/pan-down-symbolic.symbolic.png win-dist/share/icons/Adwaita/96x96/actions
cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/96x96/actions/pan-up-symbolic.symbolic.png win-dist/share/icons/Adwaita/96x96/actions
# $(MKDIR_P) win-dist/share/icons/Adwaita/96x96/status
# cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/96x96/status/dialog-information.png win-dist/share/icons/Adwaita/96x96/status
$(MKDIR_P) win-dist/share/icons/Adwaita/256x256/status
cp -p "@WINDOWS_SYSROOT@"/share/icons/Adwaita/256x256/status/dialog-information.png win-dist/share/icons/Adwaita/256x256/status
# other
cp -p "@WINDOWS_SYSROOT@"/bin/libgcc_s_*.dll win-dist/
cp -p "@WINDOWS_SYSROOT@"/bin/libpcre-1.dll win-dist/
cp -p "@WINDOWS_SYSROOT@"/bin/libpcrecpp-0.dll win-dist/
nsis-dist-prepare: win-dist-prepare
cp -a win-dist nsis-dist
cp $(top_srcdir)/data/gsmartcontrol.ico nsis-dist/
cp data/nsis/*.nsi $(top_srcdir)/data/nsis/nsi_* nsis-dist/
unix2dos nsis-dist/*.nsi
nsis-dist-nocleanup: nsis-dist-prepare
cd nsis-dist && @NSIS_EXEC@ gsmartcontrol.nsi
mv nsis-dist/$(PACKAGE)-$(VERSION)-@WINDOWS_SUFFIX@.exe .
nsis-dist-cleanup:
rm -rf nsis-dist
nsis-dist: nsis-dist-prepare nsis-dist-nocleanup nsis-dist-cleanup
win-zip-dist-prepare: win-dist-prepare
cp -a win-dist $(WIN_ZIP_NAME)
win-zip-dist-nocleanup: win-zip-dist-prepare
zip -K -9r $(WIN_ZIP_NAME).zip $(WIN_ZIP_NAME)
win-zip-dist-cleanup:
rm -rf $(WIN_ZIP_NAME)
win-zip-dist: win-zip-dist-prepare win-zip-dist-nocleanup win-zip-dist-cleanup
distclean-local: win-dist-clean
# Don't use this - it does something weird, and gcc errors out with "long long long" errors, etc...
#rpm: dist
# rpmbuild -ta $(distdir).tar.bz2
-212
View File
@@ -1,215 +1,3 @@
Version 1.1.3, released on 2017-11-12
Fixed gsmartcontrol-root not launching if GDK_* variables are not set.
Version 1.1.2, released on 2017-11-11
Fixed gsmartcontrol-root not passing GDK_SCALE and GDK_DPI_SCALE variables
to gsmartcontrol when using PolKit.
Fixed blurriness of icons in the main window with GDK_SCALE=2.
Tweaked the main window interface.
Windows: Show volume labels beside drive letters in icon tooltips.
Version 1.1.1, released on 2017-09-25
Windows: Use Adwaita GTK+ theme for systems which support Classic Windows
theme, since the default win32 GTK+ theme is broken in it; this
includes Windows 7 and Windows Server.
Statistics entry values are formatted with commas for readability.
Moved help information to website.
Version 1.1.0, released on 2017-09-07
New Statistics, Temperature Log, Error Recovery, Physical and Directory
tabs.
General tab shows non-SMART device settings as well.
Attributes tab shows entries in "brief" format.
Error Log tab shows Extended error log by default (if supported).
Self-Test Log tab now shows Extended self-test log by default (if
supported).
GSmartControl now uses "-x" equivalent for retrieving data (as upposed to
"-a"); loading "-x" outputs as virtual drives is also supported.
Implemented ability to copy rows in CSV format from Attribute, Statistics
and Self-Test Log tables.
Implemented "Update Drive Database" functionality.
Windows: Drive letters are shown for each drive.
Scan time is shown under virtual drive icons.
Polkit is supported with gsmartcontrol-root script now.
Pcrecpp is no longer bundled, use system-installed one instead.
Smartmontools version 5.43 is required at runtime.
Other minor improvements and fixes.
Version 1.0.2, released on 2017-07-21
Fixed incomplete capturing of smartctl output under Windows.
Added missing icons under Windows.
Fixed being able to turn on AODC even if unsupported.
Version 1.0.1, released on 2017-06-19
Fixed compilation under macOS.
Fixed compilation under Fedora Rawhide.
Don't use -mtune=generic for all targets.
Version 1.0.0, released on 2017-06-16
Ported to GTK+ 3.
Tweaked the user interface a bit.
Dropped support for Windows XP, 2000 and 2003 (they are no longer
supported by GTK+).
Fixed detection of newer system-installed smartmontools under Windows.
Version 0.9.0, released on 2017-05-11
Implemented (untested) support for Linux-based Areca controllers with
enclosures.
Implemented (untested) support for Windows-based Areca controllers (thanks
to Richard Kagerer).
Implemented (untested) support for Linux-based HP controllers with cciss
and hpsa/hpahcisr drivers (thanks to Fabrice Bacchella).
Changes in Preferences no longer fail silently until rescan/restart.
Better drive detection under Windows after removable drives are detached.
Windows version is no longer marked as "dpi aware" since it's not
supported that well.
Drive attribute descriptions have been updated (including clarifications
for SSDs).
Added support for SSD-only and HDD-only vendor attributes.
Devices having only basic info can be displayed now in the info window.
Fixed BDRW drive detection (it was detected as a HDD).
Other minor improvements.
A number of issues have been fixed (including a crash).
Version 0.8.7, released on 2012-08-11
Implemented support for Adaptec RAID 5805 controller and possibly other
Adaptec models as well (Linux).
Implemented support for Areca RAID controller detection under Linux
(untested).
Implemented support for 3ware 3w-sas-supported (twl) RAID controller
detection under Linux (untested).
Implemented support for systems with several different 3ware controllers
(twa/twe/twl).
Fixed invalid parsing of tw_cli output which caused non-detection of
drives and controllers with controller or port numbers greater than 9
if tw_cli was found (3ware linux, windows).
The duplicate drives are no longer shown for some Intel matrix controllers
under Windows; Intel RAID controllers are fully supported under
Windows now.
Added options to show device name and serial number under drive icons.
Updated SMART attribute definitions and added warnings for SSD lifetime
attributes.
gsmartcontrol-root has a new argument "--desktop=..." which replaces the
old positional argument; compatibility with the old invocation syntax
has been retained.
Completely documented the source using doxygen tags.
Added support for Fedora's consolehelper.
Made GSmartControl DPI-aware under Windows.
Fixed compilation issues with clang and gcc 4.7, as well as glib 2.31.x
and newer.
Fixed minor issues in NSIS installer.
Fixed other minor bugs and made minor improvements.
Version 0.8.6, released on 2011-06-12
Support detecting drives behind 3ware controllers (Linux, Windows),
including tw_cli/cx/px mode in Windows. Having tw_cli is recommended
but not required.
Added support for specifying -d option and extra parameters via command
line, "Add Device" and "Preferences" dialogs. This change effectively
adds full support for multiple drives behind a single device name.
Beesu and su-to-root are supported by gsmartcontrol-root script now.
Completely revamped the attribute database and its handling, should be a
lot more usable and forward-compatible now; SSD attributes are also
included.
In-program help has been expanded considerably.
General improvements to user interface have been implemented (better GNOME
HIG compliance, better tooltips, dialogs, etc...).
Added ability to show smartctl output for devices whose info could not be
parsed fully.
Attributes in "brief" format are supported now.
The parser has been updated to reflect the recent changes in smartctl.
Quit and rescan operations are no longer denied without confirmation when
tests are running.
The Windows NSIS installer has been vastly improved.
Better support for Windows Vista and 7.
Changed copyright notices for files with Whatever License to use Unlicense.
Added other minor features and fixed quite a few bugs.
Version 0.8.5, released on 2009-09-05
GSmartControl now uses XDG config directory for per-user configuration on
UNIX and CSIDL_PROFILE directory on Windows. Existing configuration is
migrated automatically.
The names are shown correctly for unsupported devices even with the latest
smartctl snapshots now.
Smartctl SVN revision is shown (if available).
The progress bars update properly when parallel tests are run.
Windows: GSmartControl should be able to operate on any valid filesystem
path (not just locale-representable ones).
Windows: GSmartControl is now officially compilable on x86_64 via mingw64.
Fixed compilation under very old gtkmm/libglademm, and with gcc 4.4.
Fixed parsing of multiple error types in SMART error log.
Added minor features and fixed miscellaneous bugs.
Version 0.8.4, released on 2009-03-23
Linux Software RAID devices are blacklisted now. (backported from Debian).
Attributes tab is before the capabilities tab now.
A man page has been generously contributed by Giuseppe Iuculano
<giuseppe@iuculano.it>.
Smartctl version now includes the CVS snapshot date (if available).
Windows: Look for "smartctl-nc.exe" instead of "smartctl.exe" by default.
Windows: Use smartmontools-supplied smartctl-nc.exe by default (if found).
Other minor changes (mainly Debian backports).
Version 0.8.3, released on 2008-12-27
A random "Smartctl returned an empty output" error on Windows was fixed.
Thanks to Zurab Khetsuriani for testing.
Fixed a parser issue which prevented running self-tests in Windows.
The supplied icon (hopefully) shows correctly in Windows 2000 now.
This release adds an official support for Windows 2000 SP4.
Added scripts to allow GSmartControl to read smartctl data from
cron-generated files. This allows users to read somewhat recent
smartctl information without having to run GSmartControl as root.
Generously contributed by Alex Butcher <alex dot butcher 'at'
assursys.co.uk>.
Configure script correctly aborts instead of printing a warning if gtkmm
or libglademm (if needed) is not found.
Configure script now accepts --enable-windows-console,
--disable-abort-if-no-gtkmm, --disable-abort-if-no-glade-reader,
as well as Windows-supporting "auto" for --enable-nsis-wine and
--with-nsis.
Configure's --with-win32-env has been renamed to --with-windows-dlls.
The "About" dialog shows version information now.
Minor bugs were fixed.
Version 0.8.2, released on 2008-12-10
Fixed gsmartcontrol_root.sh script to support distributions with no
/usr/sbin in their users' paths (thanks to Erwan Velu).
Added desktop auto-detection to gsmartcontrol_root.sh script. This allows
us to use only one desktop file (thanks to Erwan Velu).
Added Debian package directory (named "debian.dist" for now to avoid
control file conflicts with Build Service).
Renamed gsmartcontrol_root.sh to gsmartcontrol-root, to make Debian happy.
Added make targets for Windows packages (zip and NSIS).
Fixed Windows-related issues (Vista is fully supported now).
Fixed minor bugs:
Smartctl parser is win32-locale-aware now.
No more unnecessary parsing.
No segfault on exit under Windows and Solaris.
A friendlier message is displayed if smartctl was not found.
No highlighted labels when switching tabs in Information window.
Version 0.8.1, released on 2008-11-11
Disabled Linux "by-id" drive detection - it's unreliable on some broken
systems.
Added some more attribute descriptions.
Our names for attributes override smartctls' now.
Added a proper "Add Device" dialog for Windows.
Added an icon and resource file for Windows.
Fixed minor bugs.
Version 0.8.0rc4, released on 2008-10-20
FreeBSD support (tested with DesktopBSD 1.6 (FreeBSD 6.3) / x86).
NetBSD support (tested with NetBSD 4.0.1 / x86).
OpenBSD support (tested with OpenBSD 4.3 / x86-64 / gcc-3.3.5).
Solaris/gcc support (tested with Solaris 10 / x86 / gcc-3.4.3 / blastwave).
Solaris/sunstudio support (tested with Solaris 10 / x86 / sunstudio12 /
sunfreeware).
Code to support Windows, Mac OS X, QNX.
Support of older pcre versions (at least 4.5, maybe older too).
Added gsmartcontrol_root.sh script to easily run gsmartcontrol as root.
Improved .desktop files.
License for tests and examples is legally more correct now.
Minor bugfixes.
Version 0.8.0rc3, released on 2008-10-08
Added support for udevless Linux distributions by providing a fallback
+273 -63
View File
@@ -1,101 +1,311 @@
About GSmartControl
GSmartControl - Hard disk drive and SSD health inspection tool.
GSmartControl - Hard disk drive health inspection tool.
GSmartControl is a graphical user interface for smartctl (from smartmontools
package, see https://www.smartmontools.org/), which is a tool for
package, see http://smartmontools.sourceforge.net), which is a tool for
querying and controlling SMART (Self-Monitoring, Analysis, and Reporting
Technology) data on modern hard disk and solid-state drives. It allows you to
inspect the drive's SMART data to determine its health, as well as run various
tests on it.
Technology) data on modern hard disk drives. It allows you to inspect the
drive's SMART data to determine its health, as well as run various tests on
it.
GSmartControl supports ATA drives (both PATA and SATA), various USB to
ATA bridges and drives behind some RAID controllers:
* Adaptec (Linux, some models only)
* Areca (Linux, Windows)
* HP CCISS (Linux)
* HP hpsa / hpahcisr (Linux)
* Intel Matrix Storage (CSMI) (Linux, Windows, FreeBSD)
* LSI 3ware (Linux, Windows)
* LSI MegaRAID (Windows)
Note: Only ATA drives (both PATA and SATA) are supported for now.
Note: Smartmontools supports even more RAID Controllers. The drives
behind such controllers can be manually added to GSmartControl using
"Add Device..." functionality or --add-device command-line option.
See https://www.smartmontools.org/wiki/Supported_RAID-Controllers .
http://gsmartcontrol.berlios.de
https://gsmartcontrol.sourceforge.io/
Features
Automatically report and hilight any abnormal SMART information.
Ability to enable / disable SMART.
Ability to enable / disable Automatic Offline Data Collection - A short
self-check that the drive will perform automatically every four hours with no
impact on performance.
Ability to set global and per-drive options for smartctl.
Display drive identity, capabilities, attributes, error and self-test logs.
Perform SMART self-tests.
Ability to load smartctl output as a "virtual" device, which acts just like a
real (read-only) device.
Extensive help information.
What is SMART?
Short answer: SMART is a technology which provides hard disk drives with
methods to predict certain kinds of failures with certain chance of success.
Long answer: read below.
Self-Monitoring, Analysis, and Reporting Technology, or SMART, is a
monitoring system for hard drives to detect and report various indicators of
reliability, in the hope of anticipating failures. It is implemented inside
the drives SMART provides several ways of monitoring hard drive health. It
may provide information about general health, various drive attributes (for
example, number of unreadable sectors), error logs, and so on. It may also
provide ways to instruct the drive to run various self-tests, which may report
valuable information. It may even automatically scan the disk surface in when
the drive is idle, and repair the defects, reallocating the data to more safe
areas.
While having SMART sounds really good, there are some nuances to consider. One
of the commond pitfalls is that it may create a false sense of security. That
is, a perfectly good SMART data is NOT an indication that the drive won't fail
the next minute. The reverse is also true - some drives may function perfectly
even with not-so-good-looking SMART data. However, as studies indicate, given
a large population of drives, some SMART attributes may reliably predict
drive failures within up to two months.
Another common mistake is to assume that the attribute values are the real
physical values, as experienced by the drive. As manufacturers do not
necessarily agree on precise attribute definitions and measurement units, the
exact meaning of the attributes may vary greatly across different drive
models.
At present SMART is implemented individually by manufacturers, and while some
aspects are standardized for compatibility, others are not. In fact, most
manufacturers refer the users to their own health monitoring utilities, and
advice against taking SMART data seriously. Nevertheless, SMART may prove an
effective measure against data loss.
Yet another issue is that quite often the drives have bugs which prevent
correct SMART usage. This is usually due to buggy firmware, or the
manufacturer ignoring the standard. Luckily, smartmontools usually detects
these bugs and works around them.
Software Requirements
Note: If using the official Windows package, no additional software is required.
So far, only Linux systems are supported.
Build requirements:
* pcre 1 - http://www.pcre.org .
* GTK+, version 3.4 or higher - see http://www.gtk.org .
* Gtkmm, version 3.4 or higher - see http://www.gtkmm.org .
You need to have the following software installed:
Runtime requirements:
* smartmontools - see https://www.smartmontools.org/ .
* xterm
* pcre - http://www.pcre.org .
The following operating systems are supported:
* Linux - All the popular configurations should work.
* FreeBSD - Tested with DesktopBSD / x86.
* NetBSD - Tested with NetBSD / x86.
* OpenBSD - Tested with OpenBSD / x86-64.
* DragonFlyBSD - Code written but no testing has been performed yet. Expected
to work without any issues.
* Windows Vista SP2 (32-bit and 64-bit), Windows 7 SP1, Windows Server 2008,
Windows 8.1, Windows 10. The Windows port uses pd0, pd1, etc...
for physical drives 0, 1, etc... .
* Mac OS X.
* Solaris.
* QNX - Code written but no testing has been performed yet.
* smartmontools - see http://smartmontools.sourceforge.net .
* GTK+, version 2.6 or higher - see http://www.gtk.org .
* Gtkmm, version 2.6 or higher - see http://www.gtkmm.org .
* libglademm, version 2.4 or higher - see http://www.gtkmm.org .
libglademm is not needed when using GTK 2.12 and Gtkmm 2.12.
Note that GTK+ 2.12 and Gtkmm 2.12 are HIGHLY recommended. While earlier
versions may work, they may produce ugly results and buggy behaviour.
Libglademm is not needed when using GTK / Gtkmm 2.12.
Most of these packages are probably already provided by your distribution. For
example, to build this program on OpenSUSE, you just need to install
smartmontools, gtkmm2-devel and pcre-devel - the rest is installed
automatically by the package manager's dependency resolver.
Command Line Options
Installation
GSmartControl inherits options from GTK+ and other libraries, so be sure to
run it with --help option to get a full list of accepted parameters.
Note: The Windows version may not have a text output at all, so --help and
similar arguments won't have any effect.
Short answer: ./configure; make; make install
The most important parameters are:
Long answer: read below.
-?, --help - Show help options.
First, check if you can find a pre-built package for your distribution or
operating system - they usually provide the best integration and the easiest
installation procedure. One option is to try OpenSUSE Build Service - it
provides ready-to-install packages for various popular Linux distributions
(OpenSUSE, Fedora, etc...). See
http://download.opensuse.org/repositories/home:/alex_sh/ .
-l, --no-locale - Don't use system locale.
If you want to compile from source, check that you have all the required
dependencies (see Software Requirements section). Then the usual
-V, --version - Display version information.
./configure; make; make install
--no-scan - Don't scan devices on startup.
will build and install it. Installation usually requires root privileges, but
you don't need to install the program in order to run it directly from the
compilation directory.
--no-hide-tabs - Don't hide non-identity tabs when SMART is disabled. Useful
for debugging.
--add-virtual - Load smartctl data from file, creating a virtual drive. You
can specify this option multiple times.
--add-device - Add this device to device list. The format of the device is
"<device>::<type>::<extra_args>", where type and extra_args are optional. This
option is useful with --no-scan to list certain drives only. You can specify
this option multiple times.
Example: --add-device /dev/sda --add-device /dev/twa0::3ware,2 --add-device
'/dev/sdb::::-T permissive'.
Permission Problems
-v, --verbose - Enable verbose logging; same as --verbosity-level 5.
Short answer: you need to be root. In X11, use kdesu, gnomesu, sux or similar.
-q, --quiet - Disable logging; same as --verbosity-level 0.
Long answer: read below.
-b, --verbosity-level - Set verbosity level [0-5].
Most operating systems prohibit direct access to hardware to users with
non-administrative privileges. Unfortunately, to access SMART data, smartctl
needs to directly access the hard drive.
The provided desktop and menu icons should show the "Please enter the root
password" dialog boxes, and, after correct information is entered, should run
this program with root privileges. The dialogs should be available in most
commonly used X11 desktop environments.
However, in case the described method is somehow inaccessible, you need to
manually invoke the program with kdesu, gnomesu, sux or similar programs. For
example,
kdesu -u root -c gsmartcontrol
will ask for root password and run gsmartcontrol with root privileges. Replace
"kdesu" with "gnomesu" if using Gnome. The "sux" command may also help, if
neither KDE or GNOME are available.
Another method would be to set the "setuid" flag on smartctl binary, for
example (run as root):
chmod 4755 `which smartctl`
This method is not recommended, however, and is considered a security risk.
Also, some systems may reset the change automatically, unless explicitly
instructed otherwise.
Enable SMART Permanently
Specifications say that once you set a SMART-related property, it will be
preserved across reboots. So, when you, say, enable SMART and Automatic
Offline Data Collection, both will stay enabled until you disable them.
However, BIOS, your operating system, your other operating systems (if
present), and various startup programs may affect that. For example, BIOS may
enable SMART each time you start your computer, so if you disabled SMART
previously, it will be re-enabled on reboot.
The easiest way to work around this is to set the desired settings on system
startup. You may use smartctl or smartd to do that. For example, to enable
both SMART and Automatic Offline Data Collection on /dev/sda, one would write
the following to his/her boot.local, rc.local or similar:
smartctl --smart=on --offlineauto=on /dev/sda
For more information, see smartctl and smartd documentation.
Known Issues
Only ATA (both PATA and SATA) disks are supported for now. The main reasons
are:
* We can't support drives which don't work with smartmontools. This affects
drives which don't support SMART or don't export SMART data correctly (e.g.
USB enclosures, RAIDs, etc...).
* Smartctl's output for SCSI drives is completely different compared to ATA.
Also, SCSI drives are rarely found in desktop systems and the servers rarely
have X11 / Gtkmm running, so this is a low priority task.
* I only have ATA drives, so testing would be almost impossible.
Immediate Offline Tests are not supported. I haven't found a way to reliably
monitor them.
You may run several tests on different drives in parallel, but you will only
see the progress information of the last executing test. So, if you run tests
on drives A, B and C (in that order), you won't be able to monitor the tests
on A and B until C completes. And you won't be able to see any progress on A
until both B and C complete their tests.
Testing is only supported on drives which correctly report their progress
information in capabilities.
Not all drives support disabling Automatic Offline Data Collection, even if
they report otherwise.
Running on GTK+ / Gtkmm versions earlier than 2.12 may cause visual artifacts,
usability issues (especially with tooltips and icons), instability, etc...
The texts probably contain a lot of grammatical errors, English being my third
language and all.
Reporting Bugs
First, please collect the following information about your system. Without it
it may be very hard or impossible to fix the bug.
* Which operating system you use (for example, OpenSUSE Linux 11.0).
* What version of GTK and Gtkmm you have installed. Finding this out is very
distribution-specific. For example, on OpenSUSE it would be
"rpm -q gtk2 gtkmm2". Some distributions have gtkmm24 instead. You may also
search them in your distribution's graphical package manager, if there is one.
* Execution log from the program, if possible. To obtain it, run the program
with -v option, e.g. (type the following in terminal emulator or Run dialog):
kdesu -- biocalcon -v
Perform the steps needed to reproduce the bug, then go to
"Options -> View Execution Log", and click "Save All".
* Detailed description of steps you performed when the bug occurred.
Once you have this information, send an email to me, Alexander Shaduri
<ashaduri 'at' gmail.com>. Note that I may refer you to smartmontools support
if it's a bug in smartmontools and not GSmartControl. Normally, I won't
redirect your support request to them myself, because they may ask questions
which only you have the answers to.
Please read the "License and Copyright" and "Patch Licensing" sections before
sending any patches.
License and Copyright
For license information, see LICENSE_gsmartcontrol.txt file.
You may notice that GSmartControl is not licensed under "GNU GPL version X or
later", but under "GNU GPL version X and Y". I firmly believe that it's unwise
to license a piece of code under non-existant licenses, whatever anyone else
might say. The reason for this is that one simply CANNOT know that, say, in 20
years FSF won't be bought by some corporation who will release GPL version Z
which will completely reverse the reasons GPL was created for.
The removal of "or later" clause somewhat imposes responsibility on the
copyright holders to review every future version of the license once it's
released, and, if deemed acceptable, re-license the code under the new license
(possibly retaining the old licenses). Unfortunately, this is a necessary
inconvenience we will have to deal with.
Patch Licensing
Due to reasons described in "License and Copyright" section, to make it
possible to re-license the code without tracking down all the people who ever
wrote a patch, the copyrights of all minor patches must be assigned to the
central copyright holder of the project. If the patch is major enough (that
is, it forms a significant part of the program source code), the author may
retain the copyright, if he or she chooses to do so. However, unless the
author plans to maintain his part of the source code, he / she is humbly asked
to consider assigning away his / her copyright. A simple "I disclaim all
copyright to this patch" by the author is sufficient. All credits will be
mentioned in product documentation, whatever the size of the patch is.
Please note that centralization of copyright is needed to maintain a
reasonably healthy legal status of the project. Also note that this method is
not unique - FSF and many other organizations require exactly the same thing.
Some contributors may have reasonable doubts about the future status of this
project. Let me assure you that this project will never have more restrictive
license than GPLv2. If, some time in the future, the GPL is somehow
invalidated in court, the project will be re-licensed under similar (in
spirit) license, if possible, or a license less restrictive than GPL (for
example, the three-clause BSD license).
+126 -20
View File
@@ -15,35 +15,141 @@ local scope destruction also works if using stack variables.
}
A treeview (also iconview, combobox) from glade comes
with existing model, which should be unset
--------------------------------------------------------
GTKMM problems:
Lots of gtk_, GTK_, g_ in documentation.
no ComboBox::unset_model() and IconView::unset_model().
--------------------------------------------------------
TODO:
-l defects support? (smartctl 6.6)
if -q is passed, Execution log doesn't contain libdebug log. fix.
Don't rely on smartctl return code (2), parse the output instead.
This will allow us to show the Info page.
Need usage cases.
Drive detection - any cross-platform way to do it?
Testing:
If ETA time has elapsed, but it's still only at 10% completion,
ETA 0 is displayed. Fix.
Detect running tests on launch (maybe ask the user too? some tests
may be stuck due to bad firmware, e.g. 3ware/windows).
If smartctl outputs gibberish while testing, the GUI hangs.
FreeBSD: /dev/ad[0-3], partitions - /dev/ad[]
http://www.freebsd.org/doc/en/books/handbook/disks-naming.html
Non-existent devices give ENXIO (6, Device not configured).
In Linux ENXIO has name (6, No such device or address).
/dev/ad0s1b none swap sw 0 0
/dev/ad0s1a / ufs rw 1 1
/dev/acd0c /cdrom cd9660 ro,noauto 0 0
Do NOT open cd devices - it may cause hang on music cd, etc... .
In the slice case the drive will be added as /dev/da1s1e. This is read as:
SCSI disk, unit number 1 (second SCSI disk), slice 1 (PC BIOS partition 1),
and e BSD partition. In the dedicated case, the drive will be added simply as /dev/da1e.
Support RAID for these controllers (supported by smartctl 6.5):
https://www.smartmontools.org/wiki/Supported_RAID-Controllers
Adaptec (Windows, Linux using "-d aacraid")
HighPoint RocketRAID (Linux, FreeBSD (analyze sent info))
LSI MegaRAID (Linux, FreeBSD)
3ware (FreeBSD)
Areca (FreeBSD)
HP CCISS (FreeBSD)
iphone:
/dev/disk0
/dev/disk0s1, /dev/disk0s2
desktop files: gnomesu / gtksu wrapper.
desktop_other - find suitable su.
----------- Feature List ----------
+Autodetect available devices (through /proc / /sys ?).
win32 support for autodetection (what about different smartctl drivers?).
+Select current device (from autodetected list; manually whitelist devices).
+Smartctl binary (text entries in Options - binary, default command line options).
+ Global command-line options for smartctl.
+ Command-line options per-device in settings (e.g. -d ata).
+ Search smartctl binary on startup (try to execute it with --version). If it's not there, alert the user.
+Indicate which of the devices has SMART supported / enabled.
+ Enable / disable smart on devices.
+ Indicate that this is until shutdown (but may be preserved on reboot).
+ Direct them to smartd / smartctl documentation for permanent enabling.
+ NOTE: SMART is sometimes preserved across power cycles.
+Enable / disable Automatic Offline Data Collection for devices. (-o on)
+ Show its status in the main window.
+Show identity information for device (aka short info), --info.
+Show all SMART information for device (--all), includes:
+ * Short info (--info)
+ * SMART DATA
+ * overall-health (-H, --health) - may check this automatically as well.
+ * General SMART Values, aka Capabilities (-c, --capabilities)
+ * Attributes (-A, --attributes). These need decoding.
+ * Error Log (-l error)
+ * Self-test log (-l selftest)
+ * Selective self-test log and settings
* SCT status and other stuff
Display temperature somewhere (use SCT or Attr 194 for this).
Which one is updated more frequently, SCT or attr 194?
+ * Ability to save this information to a file.
+ * On info window show: Ask to turn SMART on if it's disabled
+Program error reporting:
+ invalid smartmontools version.
+ cannot parse output - show log.
+ smartctl exited with error - look it up in error map.
SCT Temperatures (do we use these?)
-l scttemp prints temperature and history.
-t scttempint,N[,p] (N - count, p - preserve across reset or not).
This configures temperature logging interval (1 min by default) and clears the history.
Tests:
Ability to detect a testing drive on boot, show its info with testing tab.
Run one-time Immediate Offline test (-t offline).
Offline tests only update Attributes, and if errors are found they will
appear in SMART error log. Self-test logs are unaffected.
Abort (-X). Abort works with Offline only if there's
"Abort Offline collection upon new command" capability.
If the drive has "Suspend Offline collection upon new command" capability,
immediate offline test may be tracked through --capabilities (not on mine!).
If it's "Abort Offline collection upon new command", then the test
will abort on --capabilities or --abort.
Polling time
The self-test routine recommended polling time shall be equal to the number of minutes that is the minimum
recommended time before which the host should first poll for test completion status. Actual test time could
be several times this value. Polling before this time could extend the self-test execution time or abort the test
depending on the state of bit 2 of the off-line data capability bits.
Autosave
This command enables and disables the optional attribute autosave feature of the device. This command
may either allow the device, after some vendor specified event, to save the device updated attribute values
to non-volatile memory; or this command may cause the autosave feature to be disabled. The state of the
attribute autosave feature (either enabled or disabled) shall be preserved by the device across power cycles.
A value of zero written by the host into the device’s Sector Count register before issuing this command shall
cause this feature to be disabled. Disabling this feature does not preclude the device from saving SMART
data to non-volatile memory during some other normal operation such as during a power-on or power-off
sequence or during an error recovery sequence.
A value of F1h written by the host into the device’s Sector Count register before issuing this command shall
cause this feature to be enabled. Any other meaning of this value or any other non-zero value written by the
host into this register before issuing this command may differ from device to device. The meaning of any
non-zero value written to this register at this time shall be preserved by the device across power cycles.
+8 -19
View File
@@ -26,23 +26,12 @@
AC_DEFUN([AC_CXX_EXCEPTIONS],
[AC_CACHE_CHECK(whether the compiler supports exceptions,
ac_cv_cxx_exceptions,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],
[[try { throw 1; } catch (int i) { return i; }]])],
[ac_cv_cxx_exceptions=yes], [ac_cv_cxx_exceptions=no])
AC_LANG_POP([])
])
if test "$ac_cv_cxx_exceptions" = yes; then
AC_DEFINE(HAVE_EXCEPTIONS, 1,
[defined to 1 if the compiler supports exceptions, 0 otherwise])
else
AC_DEFINE(HAVE_EXCEPTIONS, 0,
[defined to 1 if the compiler supports exceptions, 0 otherwise])
fi
ac_cv_cxx_exceptions,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[try { throw 1; } catch (int i) { return i; }]])],[ac_cv_cxx_exceptions=yes],[ac_cv_cxx_exceptions=no])
AC_LANG_POP([])
])
if test "$ac_cv_cxx_exceptions" = yes; then
AC_DEFINE(HAVE_EXCEPTIONS,,[define if the compiler supports exceptions])
fi
])
+8 -18
View File
@@ -26,22 +26,12 @@
AC_DEFUN([AC_CXX_NAMESPACES],
[AC_CACHE_CHECK(whether the compiler implements namespaces,
ac_cv_cxx_namespaces,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[namespace Outer { namespace Inner { int i = 0; }}]],
[[using namespace Outer::Inner; return i;]])],
[ac_cv_cxx_namespaces=yes], [ac_cv_cxx_namespaces=no])
AC_LANG_POP([])
])
if test "$ac_cv_cxx_namespaces" = yes; then
AC_DEFINE(HAVE_NAMESPACES, 1,
[defined to 1 if the compiler implements namespaces, 0 otherwise])
else
AC_DEFINE(HAVE_NAMESPACES, 0,
[defined to 1 if the compiler implements namespaces, 0 otherwise])
fi
ac_cv_cxx_namespaces,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[namespace Outer { namespace Inner { int i = 0; }}]], [[using namespace Outer::Inner; return i;]])],[ac_cv_cxx_namespaces=yes],[ac_cv_cxx_namespaces=no])
AC_LANG_POP([])
])
if test "$ac_cv_cxx_namespaces" = yes; then
AC_DEFINE(HAVE_NAMESPACES,,[define if the compiler implements namespaces])
fi
])
+21 -31
View File
@@ -26,35 +26,25 @@
AC_DEFUN([AC_CXX_RTTI],
[AC_CACHE_CHECK(whether the compiler supports Run-Time Type Identification,
ac_cv_cxx_rtti,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <typeinfo>
class Base {
public:
Base () {}
virtual int f () { return 0; }
};
class Derived : public Base {
public :
Derived () {}
virtual int f () { return 1; }
};
]], [[
Derived d;
Base* ptr = &d;
return typeid (*ptr) == typeid (Derived);
]])],
[ac_cv_cxx_rtti=yes], [ac_cv_cxx_rtti=no])
AC_LANG_POP([])
])
if test "$ac_cv_cxx_rtti" = yes; then
AC_DEFINE(HAVE_RTTI, 1,
[defined to 1 if the compiler supports Run-Time Type Identification, 0 otherwise])
else
AC_DEFINE(HAVE_RTTI, 0,
[defined to 1 if the compiler supports Run-Time Type Identification, 0 otherwise])
fi
ac_cv_cxx_rtti,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <typeinfo>
class Base { public :
Base () {}
virtual int f () { return 0; }
};
class Derived : public Base { public :
Derived () {}
virtual int f () { return 1; }
};
]], [[Derived d;
Base *ptr = &d;
return typeid (*ptr) == typeid (Derived);
]])],[ac_cv_cxx_rtti=yes],[ac_cv_cxx_rtti=no])
AC_LANG_POP([])
])
if test "$ac_cv_cxx_rtti" = yes; then
AC_DEFINE(HAVE_RTTI,,
[define if the compiler supports Run-Time Type Identification])
fi
])
+16
View File
@@ -0,0 +1,16 @@
AC_DEFUN([AC_CXX_VAR_FUNC],
[AC_CACHE_CHECK(whether $CXX recognizes __func__,
ac_cv_cxx_var_func,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[const char* s = __func__;]])],[ac_cv_cxx_var_func=yes],[ac_cv_cxx_var_func=no])
AC_LANG_POP([])
])
if test "$ac_cv_cxx_var_func" = yes; then
AC_DEFINE(HAVE_CXX__FUNC,,[Define if the C++ complier supports __func__])
fi
])
+12 -21
View File
@@ -25,25 +25,16 @@
AC_DEFUN([AC_CXX_VERBOSE_TERMINATE_HANDLER],
[AC_CACHE_CHECK(whether the compiler has __gnu_cxx::__verbose_terminate_handler,
ac_cv_verbose_terminate_handler,
[
AC_REQUIRE([AC_CXX_EXCEPTIONS])
AC_REQUIRE([AC_CXX_NAMESPACES])
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[#include <exception>]],
[[std::set_terminate(__gnu_cxx::__verbose_terminate_handler);]])],
[ac_cv_verbose_terminate_handler=yes], [ac_cv_verbose_terminate_handler=no])
AC_LANG_POP([])
])
if test "$ac_cv_verbose_terminate_handler" = yes; then
AC_DEFINE(HAVE_VERBOSE_TERMINATE_HANDLER, 1,
[defined to 1 if the compiler has __gnu_cxx::__verbose_terminate_handler, 0 otherwise])
else
AC_DEFINE(HAVE_VERBOSE_TERMINATE_HANDLER, 0,
[defined to 1 if the compiler has __gnu_cxx::__verbose_terminate_handler, 0 otherwise])
fi
ac_cv_verbose_terminate_handler,
[
AC_REQUIRE([AC_CXX_EXCEPTIONS])
AC_REQUIRE([AC_CXX_NAMESPACES])
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <exception>]], [[std::set_terminate(__gnu_cxx::__verbose_terminate_handler);]])],[ac_cv_verbose_terminate_handler=yes],[ac_cv_verbose_terminate_handler=no
])
AC_LANG_POP([])
])
if test "$ac_cv_verbose_terminate_handler" = yes; then
AC_DEFINE(HAVE_VERBOSE_TERMINATE_HANDLER, , [define if the compiler has __gnu_cxx::__verbose_terminate_handler])
fi
])
-34
View File
@@ -1,34 +0,0 @@
############################################################################
# Copyright:
# (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################
# APP_AUTO_CLEAR_FLAGS()
# Clear user-specified CFLAGS / CXXFLAGS / LIBS / LDFLAGS if requested.
# You should call this macro before any of AC_PROG_C(XX) checks to
# avoid checking with user-specified options.
AC_DEFUN([APP_AUTO_CLEAR_FLAGS], [
AC_ARG_ENABLE(user-flags, AS_HELP_STRING([--disable-user-flags],
[ignore user-supplied compiler flags (default: user flags are enabled)]),
[app_cv_compiler_user_flags=${enableval}], [app_cv_compiler_user_flags=yes])
AC_MSG_NOTICE([Enable user-specified compiler flags: $app_cv_compiler_user_flags])
# Reset user-supplied flags if requested.
if test "x$app_cv_compiler_user_flags" = "xno"; then
CFLAGS="";
CXXFLAGS="";
LIBS="";
LDFLAGS="";
fi
])
-302
View File
@@ -1,302 +0,0 @@
############################################################################
# Copyright:
# (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################
# APP_COMPILER_OPTIONS([flags_prefix])
# This macro enables various compiler flags (common warnings, optimization,
# debug, etc...), controllable through configure options.
# flags_prefixCFLAGS, flags_prefixCXXFLAGS and flags_prefixLDFLAGS
# will be initialized (or appended to) with the results.
# DEBUG and DEBUG_BUILD will be exported to config.h in case of debug builds.
# You must call AX_COMPILER_VENDOR, APP_DETECT_OS_KERNEL([target], ...)
# and APP_DETECT_OS_ENV([target], ...) before using this macro.
AC_DEFUN([APP_COMPILER_OPTIONS], [
# These requirements check compile-time presence, not that they were called
AC_REQUIRE([AX_COMPILER_VENDOR])
AC_REQUIRE([APP_DETECT_OS_ENV])
app_cv_compiler_options_cflags="";
app_cv_compiler_options_cxxflags="";
app_cv_compiler_options_ldflags="";
# ---- Common compiler options (warnings, etc...)
AC_ARG_ENABLE(common-options, AS_HELP_STRING([--enable-common-options=<compiler>|auto|none],
[enable useful compilation options (warnings, mostly). Accepted values are auto, none, gnu, clang, intel, sun. (Default: auto)]),
[app_cv_compiler_common_options=${enableval}], [app_cv_compiler_common_options=none])
# the default value is "yes" (if no value given after =), treat it as auto.
if test "x$app_cv_compiler_common_options" = "xyes" || test "x$app_cv_compiler_common_options" = "xauto"; then
app_cv_compiler_common_options="$ax_cv_cxx_compiler_vendor";
fi
if test "x$app_cv_compiler_common_options" = "xno"; then
# for pretty message
app_cv_compiler_common_options="none";
fi
AC_MSG_NOTICE([Enable common compiler flags for: $app_cv_compiler_common_options])
if test "x$app_cv_compiler_common_options" != "xnone"; then
# gcc (or clang) / gnu environment, mingw, cygwin.
if test "x$app_cv_compiler_common_options" = "xgnu" || test "x$app_cv_compiler_common_options" = "xclang"; then
if test "x$app_cv_target_os_env" = "xmingw32" || test "x$app_cv_target_os_env" = "xmingw64" \
|| test "x$app_cv_target_os_env" = "xcygwin"; then
# mingw gcc options:
# -mno-cygwin - generate non-cygwin executables in cygwin's mingw.
# -mms-bitfields - make structures compatible with msvc. recommended default for non-cygwin. Default for mingw.
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -mms-bitfields"
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -mms-bitfields"
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -mms-bitfields"
fi
app_cv_compiler_tmp_var="-Wall -Wcast-align -Wcast-qual -Wconversion \
-Wfloat-equal -Wnon-virtual-dtor -Woverloaded-virtual \
-Wpointer-arith -Wshadow -Wsign-compare -Wsign-promo -Wundef -Wwrite-strings";
if test "x$app_cv_compiler_common_options" = "xclang"; then
# these are really annoying
app_cv_compiler_tmp_var="$app_cv_compiler_tmp_var -Wno-sign-conversion -Wno-format-security"
fi
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags $app_cv_compiler_tmp_var";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags $app_cv_compiler_tmp_var";
# intel / gnu environment
elif test "x$app_cv_compiler_common_options" = "xintel" && test "x$app_cv_target_os_env" = "xgnu"; then
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -w1";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags \
-ftrapuv -fstack-security-check -early-template-check -static-libgcc -static-intel \
-Wcomment -Wdeprecated -Wextra-tokens -Wformat -Wmissing-prototypes -Wnon-virtual-dtor \
-Wpointer-arith -Wreturn-type -Wshadow -Wtrigraphs -Wuninitialized -w1";
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -static-libgcc -static-intel";
# suncc
elif test "x$app_cv_compiler_common_options" = "xsun"; then
# Enable useful language extensions (e.g. __func__ in C++). Details at
# http://docs.sun.com/app/docs/doc/820-7599/bkapy?a=view
# Additional options: "-staticlib=Crun -staticlib=Cstd" - link statically to
# C++ runtime and standard libraries.
# http://docs.sun.com/app/docs/doc/820-7599/bkaws?a=view
# STLport seems to be more standards-compliant, but incompatible
# with default Cstd. Also, it's not guaranteed to keep compatibility
# between versions. Select it with "-library=stlport4".
# http://docs.sun.com/app/docs/doc/820-7599/bkakg?a=view
# http://developers.sun.com/solaris/articles/cmp_stlport_libCstd.html
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags \
+w -errtags -erroff=notemsource,notused -features=extensions";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags \
+w -errtags -erroff=notemsource,notused -features=extensions";
fi
fi
# ---- Compiler options for debug builds
AC_ARG_ENABLE(debug-options, AS_HELP_STRING([--enable-debug-options=<compiler>|auto|none],
[enable debug build options. Accepted values are auto, none, gnu, clang, intel, sun. (Default: none)]),
[app_cv_compiler_debug_options=${enableval}], [app_cv_compiler_debug_options=none])
# the default value is "yes" (if no value given after =), treat it as auto.
if test "x$app_cv_compiler_debug_options" = "xyes" || test "x$app_cv_compiler_debug_options" = "xauto"; then
app_cv_compiler_debug_options="$ax_cv_cxx_compiler_vendor";
fi
if test "x$app_cv_compiler_debug_options" = "xno"; then
# for pretty message
app_cv_compiler_debug_options="none";
fi
AC_MSG_NOTICE([Enable debug build flags for: $app_cv_compiler_debug_options])
if test "x$app_cv_compiler_debug_options" != "xnone"; then
# Define DEBUG and DEBUG_BUILD for debug builds (through config.h).
AC_DEFINE([DEBUG], [1], [Defined for debug builds])
AC_DEFINE([DEBUG_BUILD], [1], [Defined for debug builds])
# gcc, mingw
if test "x$app_cv_compiler_debug_options" = "xgnu" || test "x$app_cv_compiler_debug_options" = "xclang"; then
# We could put libstdc++ debug options here, but it generates binary-incompatible
# C++ code, which leads to runtime errors with e.g. libsigc++.
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -g3 -O0";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -g3 -O0";
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -g3 -O0";
# intel / gnu
elif test "x$app_cv_compiler_debug_options" = "xintel" && test "x$app_cv_target_os_env" = "xgnu"; then
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -g3 -O0";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -g3 -O0";
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -g3 -O0";
# suncc
elif test "x$app_cv_compiler_debug_options" = "xsun"; then
# There's no -O0, it's the default. Debug format is stabs by default, but can be switched
# to dwarf by -xdebugformat=dwarf.
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -xs -g";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -xs -g";
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -xs -g";
fi
fi
# ---- Compiler options for optimized builds
AC_ARG_ENABLE(optimize-options, AS_HELP_STRING([--enable-optimize-options=<compiler>|auto|none],
[enable optimized build options. Accepted values are auto, none, gnu, clang, intel, sun. (Default: none)]),
[app_cv_compiler_optimize_options=${enableval}], [app_cv_compiler_optimize_options=none])
# the default value is "yes" (if no value given after =), treat it as auto.
if test "x$app_cv_compiler_optimize_options" = "xyes" || test "x$app_cv_compiler_optimize_options" = "xauto"; then
app_cv_compiler_optimize_options="$ax_cv_cxx_compiler_vendor";
fi
if test "x$app_cv_compiler_optimize_options" = "xno"; then
# for pretty message
app_cv_compiler_optimize_options="none";
fi
AC_MSG_NOTICE([Enable optimized build flags for: $app_cv_compiler_optimize_options])
if test "x$app_cv_compiler_optimize_options" != "xnone"; then
# gcc, mingw
if test "x$app_cv_compiler_optimize_options" = "xgnu" || test "x$app_cv_compiler_optimize_options" = "xclang"; then
# -mtune=generic is since gcc 4.0 iirc
if test "x$app_cv_target_os_env" = "xmingw32"; then
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -g0 -O3 -s -march=i686";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -g0 -O3 -s -march=i686";
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -g0 -O3 -s -march=i686";
else # mingw64, cygwin (they have new gcc), others.
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -g0 -O3 -s";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -g0 -O3 -s";
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -g0 -O3 -s";
fi
# -mtune=generic is only for x86*
case "$target" in
i686-*)
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -mtune=generic";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -mtune=generic";
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -mtune=generic";
;;
x86_64-*)
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -mtune=generic";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -mtune=generic";
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -mtune=generic";
;;
esac
# intel / gnu
elif test "x$app_cv_compiler_optimize_options" = "xintel" && test "x$app_cv_target_os_env" = "xgnu"; then
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -g0 -O3 -s";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -g0 -O3 -s";
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -g0 -O3 -s";
# suncc
elif test "x$app_cv_compiler_optimize_options" = "xsun"; then
# There's no -O0, it's the default. Debug format is stabs by default, but can be switched
# to dwarf by -xdebugformat=dwarf.
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -xO5";
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -xO5";
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -s";
fi
fi
# ---- Compiler options for GCC pch support
AC_ARG_ENABLE(gcc-pch,
AS_HELP_STRING([--enable-gcc-pch],[enable precompiled header support (pch make target) (GCC only) (default: disabled)
(use "make gch" to speed up the compilation, but don't enable it if you don't intend to use it - it will slow things down)]),
[app_cv_compiler_gcc_pch=${enableval}], [app_cv_compiler_gcc_pch=no])
AC_MSG_NOTICE([Enable GCC precompiled header usage: $app_cv_compiler_gcc_pch])
# Don't check the vendor here - it's disabled by default, so it's on the user.
if test "x$app_cv_compiler_gcc_pch" = "xyes"; then
app_cv_compiler_options_cflags="$app_cv_compiler_options_cflags -Winvalid-pch -DENABLE_PCH"
app_cv_compiler_options_cxxflags="$app_cv_compiler_options_cxxflags -Winvalid-pch -DENABLE_PCH"
fi
# ---- Compiler options for Mingw's mwindows/mconsole
# -mwindows - hide console window. possibly suppresses any std output / error.
# -mconsole - opposite of -mwindows, default.
AC_ARG_ENABLE(windows-console, AS_HELP_STRING([--enable-windows-console=yes|no|auto],
[enable windows console (MinGW and Cygwin only). Accepted values are yes, no, auto. ]
[Auto means disabled for optimized builds, enabled for all others. (Default: auto)]),
[app_cv_compiler_windows_console=${enableval}], [app_cv_compiler_windows_console=auto])
if test "x$app_cv_compiler_windows_console" = "xauto"; then
# disable console for optimized builds.
if test "x$app_cv_compiler_optimize_options" != "xnone"; then
app_cv_compiler_windows_console="no";
else
app_cv_compiler_windows_console="yes";
fi
fi
if test "x$app_cv_target_os_env" = "xmingw32" || test "x$app_cv_target_os_env" = "xmingw64" \
|| test "x$app_cv_target_os_env" = "xcygwin"; then
if test "x$app_cv_compiler_windows_console" = "xno"; then
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -mwindows";
else
# specify -mconsole even if it's the default - it should override the user-supplied setting
app_cv_compiler_options_ldflags="$app_cv_compiler_options_ldflags -mconsole";
fi
AC_MSG_NOTICE([Enable windows console: $app_cv_compiler_windows_console])
fi
# ---- Export our variables
if test "x$$1[]CFLAGS" = "x"; then
$1[]CFLAGS="$app_cv_compiler_options_cflags";
else
$1[]CFLAGS="$$1[]CFLAGS $app_cv_compiler_options_cflags";
fi
if test "x$$1[]CXXFLAGS" = "x"; then
$1[]CXXFLAGS="$app_cv_compiler_options_cxxflags";
else
$1[]CXXFLAGS="$$1[]CXXFLAGS $app_cv_compiler_options_cxxflags";
fi
if test "x$$1[]LDFLAGS" = "x"; then
$1[]LDFLAGS="$app_cv_compiler_options_ldflags";
else
$1[]LDFLAGS="$$1[]LDFLAGS $app_cv_compiler_options_ldflags";
fi
AC_MSG_NOTICE([Compiler-specific build options:])
AC_MSG_NOTICE([CFLAGS: $app_cv_compiler_options_cflags])
AC_MSG_NOTICE([CXXFLAGS: $app_cv_compiler_options_cxxflags])
AC_MSG_NOTICE([LDFLAGS: $app_cv_compiler_options_ldflags])
])
-51
View File
@@ -1,51 +0,0 @@
############################################################################
# Copyright:
# (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################
# Check whether C++ compiler supports overloading of functions
# with function pointer argument differing only in extern "C" specification,
# that is, extern "C" function pointer and C++ function pointer. GCC and
# Intel treat them equally, so no overloads are needed (or accepted)
# there.
# SunCC accepts C++-to-C function pointer assignment in function
# parameters, but not in constructor parameters. To make such
# code work an additional C-function-pointer constructor must be
# specified. Then the constructor itself can make the conversion
# (with a compiler warning though).
# SunCC also disallows C-to-C++ function pointer specification
# for template parameters (I don't remember the exact details).
# If such overloading support is found,
# HAVE_CXX_EXTERN_C_OVERLOAD is defined.
AC_DEFUN([APP_CXX_EXTERN_C_OVERLOAD], [
AC_CACHE_CHECK(whether $CXX accepts extern C function pointer overload, ac_cv_cxx_extern_c_overload, [
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
extern "C" { typedef void (*c_func_t)(void); }
typedef void (*cpp_func_t)(void);
void f1(c_func_t f) { }
void f1(cpp_func_t f) { }
]], [[]])],
[ac_cv_cxx_extern_c_overload=yes], [ac_cv_cxx_extern_c_overload=no])
AC_LANG_POP([])
])
if test "x$ac_cv_cxx_extern_c_overload" = "xyes"; then
AC_DEFINE(HAVE_CXX_EXTERN_C_OVERLOAD, 1,
[Defined to 1 if the C++ complier accepts extern C function pointer overload, 0 otherwise])
else
AC_DEFINE(HAVE_CXX_EXTERN_C_OVERLOAD, 0,
[Defined to 1 if the C++ complier accepts extern C function pointer overload, 0 otherwise])
fi
])
-50
View File
@@ -1,50 +0,0 @@
############################################################################
# Copyright:
# (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################
# Check whether C++ compiler supports C99 __func__.
AC_DEFUN([APP_CXX___func__], [
AC_CACHE_CHECK(whether $CXX recognizes __func__, app_cv_cxx___func__, [
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],
[[const char* s = __func__;]])],
[app_cv_cxx___func__=yes], [app_cv_cxx___func__=no])
AC_LANG_POP([])
])
if test "x$app_cv_cxx___func__" = "xyes"; then
AC_DEFINE(HAVE_CXX___func__, 1,
[Defined to 1 if the C++ complier supports __func__, 0 otherwise])
else
AC_DEFINE(HAVE_CXX___func__, 0,
[Defined to 1 if the C++ complier supports __func__, 0 otherwise])
fi
])
# Check whether C++ compiler supports __FUNCTION__.
AC_DEFUN([APP_CXX___FUNCTION__], [
AC_CACHE_CHECK(whether $CXX recognizes __FUNCTION__, app_cv_cxx___FUNCTION__, [
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],
[[const char* s = __FUNCTION__;]])],
[app_cv_cxx___FUNCTION__=yes], [app_cv_cxx___FUNCTION__=no])
AC_LANG_POP([])
])
if test "x$app_cv_cxx___FUNCTION__" = "xyes"; then
AC_DEFINE(HAVE_CXX___FUNCTION__, 1,
[Defined to 1 if the C++ complier supports __FUNCTION__, 0 otherwise])
else
AC_DEFINE(HAVE_CXX___FUNCTION__, 0,
[Defined to 1 if the C++ complier supports __FUNCTION__, 0 otherwise])
fi
])
-375
View File
@@ -1,375 +0,0 @@
############################################################################
# Copyright:
# (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################
# APP_DETECT_OS_KERNEL(triplet_name, define_macro_prefix)
# Check target OS kernel.
# triplet_name is target, host or build.
# You must call AX_COMPILER_VENDOR before using this macro.
# If you call
# APP_DETECT_OS_KERNEL([target], [CONFIG_KERNEL])
# you will get CONFIG_KERNEL_LINUX C macro exported to config.h
# (on gcc/linux).
# If no define_macro_prefix is specified, no C macro prefix will be used.
# app_cv_target_os_kernel will be set to kernel name (lowercase).
# app_cv_target_os_kernel_macro will be set to kernel name (all caps).
# TARGET_OS_KERNEL_LINUX automake conditional will be set to true.
# Note: Some operating systems / compilers have built-in defines.
# For gcc, check with
# $ gcc -dM -E - < /dev/null
AC_DEFUN([APP_DETECT_OS_KERNEL], [
# These requirements check compile-time presence, not that they were called
AC_REQUIRE([AX_COMPILER_VENDOR])
AC_MSG_CHECKING([for $1 OS kernel])
app_cv_[]$1[]_os_kernel="";
app_cv_[]$1[]_os_kernel_macro="";
# If vendor is not recognized, it's set to "unknown".
# NOTE: This works only on target compilers!
if test "x${ax_cv_cxx_compiler_vendor}" = "x"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[ax_cv_cxx_compiler_vendor] not set.])
fi
# "build" - the type of system on which the package is being configured and compiled.
# "host" - the type of system on which the package runs. Specifying it enables the
# cross-compilation mode. "target" defaults to this too.
if test "x$1" != "xbuild" && test "x$1" != "xhost" && test "x$1" != "xtarget"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[Triplet name must be build, host or target.]])
fi
case "$$1" in
*linux*)
# gcc defines __linux__ on linux. Other defines include: __linux, __unix__, __gnu_linux__,
# linux, unix, __i386__, i386.
app_cv_[]$1[]_os_kernel="linux";
app_cv_[]$1[]_os_kernel_macro="LINUX";
;;
i*86-*mingw* | i*86-*cygwin*)
# mingw defines _WIN32. msvc defines _WIN32 (built-in), and WIN32 via windows.h.
# Other mingw defines include: __WINNT, __WINNT__, __WIN32__, __i386, _X86_,
# i386, __i386__, WIN32, __MINGW32__, WINNT (all equal to 1).
app_cv_[]$1[]_os_kernel="windows32";
app_cv_[]$1[]_os_kernel_macro="WINDOWS32";
;;
x86_64-*-mingw* | x86_64-*-cygwin*)
# mingw64 defines the same stuff as 32-bit one, plus _WIN64, __MINGW64__, etc... .
# Keep in mind that if you're generating a 32-bit application, the kernel will
# be windows32 even if you run it on 64-bit Windows.
app_cv_[]$1[]_os_kernel="windows64";
app_cv_[]$1[]_os_kernel_macro="WINDOWS64";
;;
*interix*)
# Interix is a kernel on top of windows, so we treat it separately.
app_cv_[]$1[]_os_kernel="interix";
app_cv_[]$1[]_os_kernel_macro="INTERIX";
;;
# This includes debian gnu/kfreebsd. Dragonfly is checked separately.
*freebsd*)
# gcc built-in defines (to check for freebsd kernel):
# defined(__FreeBSD__) || defined(__FreeBSD_kernel__).
# See http://glibc-bsd.alioth.debian.org/porting/PORTING .
app_cv_[]$1[]_os_kernel="freebsd";
app_cv_[]$1[]_os_kernel_macro="FREEBSD";
;;
*dragonfly*)
app_cv_[]$1[]_os_kernel="dragonfly";
app_cv_[]$1[]_os_kernel_macro="DRAGONFLY";
;;
*openbsd*)
app_cv_[]$1[]_os_kernel="openbsd";
app_cv_[]$1[]_os_kernel_macro="OPENBSD";
;;
# This includes debian gnu/netbsd.
*netbsd*)
app_cv_[]$1[]_os_kernel="netbsd";
app_cv_[]$1[]_os_kernel_macro="NETBSD";
;;
*solaris*)
app_cv_[]$1[]_os_kernel="solaris";
app_cv_[]$1[]_os_kernel_macro="SOLARIS";
;;
*darwin*)
app_cv_[]$1[]_os_kernel="darwin";
app_cv_[]$1[]_os_kernel_macro="DARWIN";
;;
*qnx*)
app_cv_[]$1[]_os_kernel="qnx";
app_cv_[]$1[]_os_kernel_macro="QNX";
;;
*)
app_cv_[]$1[]_os_kernel="unknown";
app_cv_[]$1[]_os_kernel_macro="UNKNOWN";
;;
esac
# Assign this - we may use this in configure itself.
if test "x$2" != "x"; then
app_cv_[]$1[]_os_kernel_macro="$2[]_${app_cv_[]$1[]_os_kernel_macro}";
fi
# config.h macros (yes, we need this many. otherwise config.h will be incorrect).
if test "x${app_cv_[]$1[]_os_kernel}" = "xlinux"; then
AC_DEFINE($2[]LINUX, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xwindows32"; then
AC_DEFINE($2[]WINDOWS32, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xwindows64"; then
AC_DEFINE($2[]WINDOWS64, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xinterix"; then
AC_DEFINE($2[]INTERIX, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xfreebsd"; then
AC_DEFINE($2[]FREEBSD, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xdragonfly"; then
AC_DEFINE($2[]DRAGONFLY, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xopenbsd"; then
AC_DEFINE($2[]OPENBSD, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xnetbsd"; then
AC_DEFINE($2[]NETBSD, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xsolaris"; then
AC_DEFINE($2[]SOLARIS, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xdarwin"; then
AC_DEFINE($2[]DARWIN, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xqnx"; then
AC_DEFINE($2[]QNX, 1, [$1 OS kernel])
fi
if test "x${app_cv_[]$1[]_os_kernel}" = "xunknown"; then
AC_DEFINE($2[]UNKNOWN, 1, [$1 OS kernel])
fi
# Export to Makefile.am's.
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_LINUX, [test "x${app_cv_[]$1[]_os_kernel}" = "xlinux"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_WINDOWS32, [test "x${app_cv_[]$1[]_os_kernel}" = "xwindows32"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_WINDOWS64, [test "x${app_cv_[]$1[]_os_kernel}" = "xwindows64"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_INTERIX, [test "x${app_cv_[]$1[]_os_kernel}" = "xinterix"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_FREEBSD, [test "x${app_cv_[]$1[]_os_kernel}" = "xfreebsd"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_DRAGONFLY, [test "x${app_cv_[]$1[]_os_kernel}" = "xdragonfly"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_OPENBSD, [test "x${app_cv_[]$1[]_os_kernel}" = "xopenbsd"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_NETBSD, [test "x${app_cv_[]$1[]_os_kernel}" = "xnetbsd"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_SOLARIS, [test "x${app_cv_[]$1[]_os_kernel}" = "xsolaris"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_DARWIN, [test "x${app_cv_[]$1[]_os_kernel}" = "xdarwin"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_QNX, [test "x${app_cv_[]$1[]_os_kernel}" = "xqnx"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_UNKNOWN, [test "x${app_cv_[]$1[]_os_kernel}" = "xunknown"])
# composite ones, for easy checking
AM_CONDITIONAL(m4_toupper($1)[]_OS_KERNEL_FAMILY_WINDOWS, \
[test "x${app_cv_[]$1[]_os_kernel}" = "xwindows32" || test "x${app_cv_[]$1[]_os_kernel}" = "xwindows64" \
|| test "x${app_cv_[]$1[]_os_kernel}" = "xinterix"])
if test "x${app_cv_[]$1[]_os_kernel}" = "xwindows32" || test "x${app_cv_[]$1[]_os_kernel}" = "xwindows64" \
|| test "x${app_cv_[]$1[]_os_kernel}" = "xinterix"; then
AC_DEFINE($2[]FAMILY_WINDOWS, 1, [$1 OS kernel family])
fi
AC_MSG_RESULT([${app_cv_[]$1[]_os_kernel}])
])
# APP_DETECT_OS_ENV(triplet_name, define_macro_prefix)
# Check target OS userland environment (mainly glibc).
# triplet_name is target, host or build.
# You must call AX_COMPILER_VENDOR before using this macro.
# If you call
# APP_DETECT_OS_ENV([target], [COMPILER], [CONFIG_OS_ENV])
# you will get CONFIG_OS_ENV_LINUX C macro exported to config.h
# (on gcc/linux).
# If no define_macro_prefix is specified, no C macro prefix will be used.
# app_cv_target_os_env will be set to env name (lowercase).
# app_cv_target_os_env_macro will be set to env name (all caps).
# TARGET_OS_ENV_LINUX automake conditional will be set to true.
AC_DEFUN([APP_DETECT_OS_ENV], [
# These requirements check compile-time presence, not that they were called
AC_REQUIRE([AX_COMPILER_VENDOR])
AC_MSG_CHECKING([for $1 OS userland environment])
app_cv_[]$1[]_os_env="";
app_cv_[]$1[]_os_env_macro="";
# If vendor is not recognized, it's set to "unknown".
# NOTE: This works only on target compilers!
if test "x${ax_cv_cxx_compiler_vendor}" = "x"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[ax_cv_cxx_compiler_vendor] not set.])
fi
# "build" - the type of system on which the package is being configured and compiled.
# "host" - the type of system on which the package runs. Specifying it enables the
# cross-compilation mode. "target" defaults to this too.
if test "x$1" != "xbuild" && test "x$1" != "xhost" && test "x$1" != "xtarget"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[Triplet name must be build, host or target.]])
fi
case "$$1" in
*cygwin*)
app_cv_[]$1[]_os_env="cygwin";
app_cv_[]$1[]_os_env_macro="CYGWIN";
;;
i*86-*mingw*)
app_cv_[]$1[]_os_env="mingw32";
app_cv_[]$1[]_os_env_macro="MINGW32";
;;
x86_64-*-mingw*)
app_cv_[]$1[]_os_env="mingw64";
app_cv_[]$1[]_os_env_macro="MINGW64";
;;
*interix*)
app_cv_[]$1[]_os_env="interix";
app_cv_[]$1[]_os_env_macro="INTERIX";
;;
# This includes gnu/linux, debian gnu/kfreebsd, debian gnu/netbsd...
*-gnu | gnu*)
app_cv_[]$1[]_os_env="gnu";
app_cv_[]$1[]_os_env_macro="GNU";
;;
# Freebsd libc
*freebsd*)
app_cv_[]$1[]_os_env="freebsd";
app_cv_[]$1[]_os_env_macro="FREEBSD";
;;
*dragonfly*)
app_cv_[]$1[]_os_env="dragonfly";
app_cv_[]$1[]_os_env_macro="DRAGONFLY";
;;
*openbsd*)
app_cv_[]$1[]_os_env="openbsd";
app_cv_[]$1[]_os_env_macro="OPENBSD";
;;
*netbsd*)
app_cv_[]$1[]_os_env="netbsd";
app_cv_[]$1[]_os_env_macro="NETBSD";
;;
*solaris*)
app_cv_[]$1[]_os_env="solaris";
app_cv_[]$1[]_os_env_macro="SOLARIS";
;;
*darwin*)
app_cv_[]$1[]_os_env="darwin";
app_cv_[]$1[]_os_env_macro="DARWIN";
;;
*qnx*)
app_cv_[]$1[]_os_env="qnx";
app_cv_[]$1[]_os_env_macro="QNX";
;;
*)
app_cv_[]$1[]_os_env="unknown";
app_cv_[]$1[]_os_env_macro="UNKNOWN";
;;
esac
# Assign this even if not using flags - we may use this in configure itself.
if test "x$2" != "x"; then
app_cv_[]$1[]_os_env_macro="$2[]_${app_cv_[]$1[]_os_env_macro}";
fi
# config.h macros (yes, we need this many. otherwise config.h will be incorrect).
if test "x${app_cv_[]$1[]_os_env}" = "xcygwin"; then
AC_DEFINE($2[]CYGWIN, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xmingw32"; then
AC_DEFINE($2[]MINGW32, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xmingw64"; then
AC_DEFINE($2[]MINGW64, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xinterix"; then
AC_DEFINE($2[]INTERIX, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xgnu"; then
AC_DEFINE($2[]GNU, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xfreebsd"; then
AC_DEFINE($2[]FREEBSD, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xdragonfly"; then
AC_DEFINE($2[]DRAGONFLY, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xopenbsd"; then
AC_DEFINE($2[]OPENBSD, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xnetbsd"; then
AC_DEFINE($2[]NETBSD, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xsolaris"; then
AC_DEFINE($2[]SOLARIS, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xdarwin"; then
AC_DEFINE($2[]DARWIN, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xqnx"; then
AC_DEFINE($2[]QNX, 1, [$1 OS userspace environment])
fi
if test "x${app_cv_[]$1[]_os_env}" = "xunknown"; then
AC_DEFINE($2[]UNKNOWN, 1, [$1 OS userspace environment])
fi
# Export to Makefile.am's.
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_CYGWIN, [test "x${app_cv_[]$1[]_os_env}" = "xcygwin"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_MINGW32, [test "x${app_cv_[]$1[]_os_env}" = "xmingw32"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_MINGW64, [test "x${app_cv_[]$1[]_os_env}" = "xmingw64"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_INTERIX, [test "x${app_cv_[]$1[]_os_env}" = "xinterix"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_GNU, [test "x${app_cv_[]$1[]_os_env}" = "xgnu"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_FREEBSD, [test "x${app_cv_[]$1[]_os_env}" = "xfreebsd"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_DRAGONFLY, [test "x${app_cv_[]$1[]_os_env}" = "xdragonfly"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_OPENBSD, [test "x${app_cv_[]$1[]_os_env}" = "xopenbsd"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_NETBSD, [test "x${app_cv_[]$1[]_os_env}" = "xnetbsd"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_SOLARIS, [test "x${app_cv_[]$1[]_os_env}" = "xsolaris"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_DARWIN, [test "x${app_cv_[]$1[]_os_env}" = "xdarwin"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_QNX, [test "x${app_cv_[]$1[]_os_env}" = "xqnx"])
AM_CONDITIONAL(m4_toupper($1)[]_OS_ENV_UNKNOWN, [test "x${app_cv_[]$1[]_os_env}" = "xunknown"])
AC_MSG_RESULT([${app_cv_[]$1[]_os_env}])
])
-208
View File
@@ -1,208 +0,0 @@
############################################################################
# Copyright:
# (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################
# APP_GET_MT_FLAGS(flags_prefix[, action-if-not-found])
# This macro detects compiler flags which are needed to compile a multi-threaded
# (preferably pthreads-based) applications on target OS. flags_prefixCFLAGS,
# flags_prefixCXXFLAGS and flags_prefixLIBS will be initialized (or appended to)
# with the correct flags.
# You must call AX_COMPILER_VENDOR, APP_DETECT_OS_KERNEL([target], ...)
# and APP_DETECT_OS_ENV([target], ...) before using this macro.
AC_DEFUN([APP_GET_MT_FLAGS], [
# These requirements check compile-time presence, not that they were called
AC_REQUIRE([AX_COMPILER_VENDOR])
AC_REQUIRE([APP_DETECT_OS_KERNEL])
AC_REQUIRE([APP_DETECT_OS_ENV])
AC_MSG_CHECKING([for target thread support flags])
app_cv_target_thread_cflags="";
app_cv_target_thread_cxxflags="";
app_cv_target_thread_libs="";
app_cv_target_thread_found="no";
# If vendor is not recognized, it's set to "unknown".
# NOTE: This works only on target compilers!
if test "x${ax_cv_cxx_compiler_vendor}" = "x"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[ax_cv_cxx_compiler_vendor] not set.])
fi
if test "x${app_cv_target_os_kernel}" = "x"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[app_cv_target_os_kernel] not set.])
fi
if test "x${app_cv_target_os_env}" = "x"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[app_cv_target_os_env] not set.])
fi
# Compilers use at least 3 defines to enable thread-safe support:
# _THREAD_SAFE, _MT, _REENTRANT.
# We use the ones that are required for detected platform.
case "$app_cv_target_os_kernel" in
linux)
# glibc manual says that defining either _REENTRANT or _THREAD_SAFE
# enables some thread-safe implementations of glibc functions.
if test "$ax_cv_cxx_compiler_vendor" = "gnu" || test "$ax_cv_cxx_compiler_vendor" = "clang" \
|| test "$ax_cv_cxx_compiler_vendor" = "intel" || test "$ax_cv_cxx_compiler_vendor" = "pathscale"; then
app_cv_target_thread_cflags="-pthread -D_MT -D_THREAD_SAFE"
app_cv_target_thread_cxxflags="-pthread -D_MT -D_THREAD_SAFE"
app_cv_target_thread_libs="-pthread"
app_cv_target_thread_found="yes";
elif test "$ax_cv_cxx_compiler_vendor" = "sun"; then
# suncc's -mt expands to:
# "-D_REENTRANT -lpthread" on Linux, uses pthreads (pthread.h);
# "-D_REENTRANT -lthread" on Solaris, uses Solaris threads (thread.h).
# To use pthreads on Solaris, use "-mt -lpthread".
# http://docs.sun.com/app/docs/doc/820-7598/bjapp?a=view
app_cv_target_thread_cflags="-mt"
app_cv_target_thread_cxxflags="-mt"
app_cv_target_thread_libs="-mt"
app_cv_target_thread_found="yes";
fi
;;
windows*)
# NOTE: Not sure about cygwin or clang.
# NOTE: This only enables multithreaded code generation. For linking
# with pthreads-win32 you need additional flags.
# gcc man page: -mthreads: Support thread-safe exception handling on Mingw32.
# -mthreads defines -D_MT, and links with -lmingwthrd.
if test "$ax_cv_cxx_compiler_vendor" = "gnu" || test "$ax_cv_cxx_compiler_vendor" = "clang"; then
app_cv_target_thread_cflags="-mthreads -D_THREAD_SAFE"
app_cv_target_thread_cxxflags="-mthreads -D_THREAD_SAFE"
app_cv_target_thread_libs="-mthreads"
app_cv_target_thread_found="yes"
fi
;;
interix)
# Interix kernel is implemented on top of windows kernel.
# Interix uses -D_REENTRANT for pthreads, automatically enabling -lpthread.
if test "$ax_cv_cxx_compiler_vendor" = "gnu"; then
app_cv_target_thread_cflags="-D_REENTRANT"
app_cv_target_thread_cxxflags="-D_REENTRANT"
app_cv_target_thread_found="yes"
fi
;;
freebsd | dragonfly)
# NOTE: Not sure about debian gnu/kfreebsd and gnu/netbsd.
# Freebsd had -kthread, but it has been discontinued (afaik).
# For freebsd -pthread replaces libc with libc_r.
if test "$ax_cv_cxx_compiler_vendor" = "gnu" || test "$ax_cv_cxx_compiler_vendor" = "clang"; then
app_cv_target_thread_cflags="-pthread -D_MT -D_THREAD_SAFE"
app_cv_target_thread_cxxflags="-pthread -D_MT -D_THREAD_SAFE"
app_cv_target_thread_libs="-pthread"
app_cv_target_thread_found="yes";
fi
;;
openbsd)
if test "$ax_cv_cxx_compiler_vendor" = "gnu" || test "$ax_cv_cxx_compiler_vendor" = "clang"; then
app_cv_target_thread_cflags="-pthread -D_REENTRANT"
app_cv_target_thread_cxxflags="-pthread -D_REENTRANT"
app_cv_target_thread_libs="-pthread"
app_cv_target_thread_found="yes";
fi
;;
netbsd)
# See sys/featuretest.h
if test "$ax_cv_cxx_compiler_vendor" = "gnu" || test "$ax_cv_cxx_compiler_vendor" = "clang"; then
app_cv_target_thread_cflags="-pthread -D_REENTRANT"
app_cv_target_thread_cxxflags="-pthread -D_REENTRANT"
app_cv_target_thread_libs="-pthread"
app_cv_target_thread_found="yes";
fi
;;
solaris)
if test "$ax_cv_cxx_compiler_vendor" = "gnu" || test "$ax_cv_cxx_compiler_vendor" = "clang"; then
# gnu documentation mentions -threads (and its aliases, -pthreads and -pthread).
# _REENTRANT is needed to enable some thread-safe equivalents of standard
# functions.
# http://docs.sun.com/app/docs/doc/805-8005-04/6j7hcvqs4?l=ko&a=view
app_cv_target_thread_cflags="-pthreads -D_MT -D_THREAD_SAFE -D_REENTRANT"
app_cv_target_thread_cxxflags="-pthreads -D_MT -D_THREAD_SAFE -D_REENTRANT"
app_cv_target_thread_libs="-pthreads"
app_cv_target_thread_found="yes"
elif test "$ax_cv_cxx_compiler_vendor" = "sun"; then
# suncc's -mt expands to:
# "-D_REENTRANT -lpthread" on Linux, uses pthreads (pthread.h);
# "-D_REENTRANT -lthread" on Solaris, uses Solaris threads (thread.h).
# To use pthreads on Solaris, use "-mt -lpthread".
# http://docs.sun.com/app/docs/doc/820-7598/bjapp?a=view
# http://docs.sun.com/app/docs/doc/816-5175/pthreads-5?a=view
# http://docs.sun.com/app/docs/doc/816-5137/compile-74765?a=view
# We use POSIX threads, so append -lpthread.
app_cv_target_thread_cflags="-mt -lpthread"
app_cv_target_thread_cxxflags="-mt -lpthread"
app_cv_target_thread_libs="-mt -lpthread"
app_cv_target_thread_found="yes"
fi
;;
darwin)
if test "$ax_cv_cxx_compiler_vendor" = "gnu" || test "$ax_cv_cxx_compiler_vendor" = "clang"; then
# Darwin produces mt code by default, and -pthread is an error.
app_cv_target_thread_found="yes"
fi
;;
qnx)
if test "$ax_cv_cxx_compiler_vendor" = "gnu" || test "$ax_cv_cxx_compiler_vendor" = "clang"; then
# afaik, gcc/qnx produces mt code by default (at least on newer qnx releases),
# so no flags are needed.
app_cv_target_thread_found="yes"
fi
;;
esac
if test "$app_cv_target_thread_found" = "no"; then
AC_MSG_WARN([Cannot detect compiler thread support. Set CFLAGS, CXXFLAGS and LIBS manually.])
m4_ifvaln([$2],[$2])dnl
else
AC_MSG_RESULT([CFLAGS: $app_cv_target_thread_cflags; CXXFLAGS: $app_cv_target_thread_cxxflags; LIBS: $app_cv_target_thread_libs])
if test "x$$1[]CFLAGS" = "x"; then
$1[]CFLAGS="$app_cv_target_thread_cflags";
else
$1[]CFLAGS="$$1[]CFLAGS $app_cv_target_thread_cflags";
fi
if test "x$$1[]CXXFLAGS" = "x"; then
$1[]CXXFLAGS="$app_cv_target_thread_cxxflags";
else
$1[]CXXFLAGS="$$1[]CXXFLAGS $app_cv_target_thread_cxxflags";
fi
if test "x$$1[]LIBS" = "x"; then
$1[]LIBS="$app_cv_target_thread_libs";
else
$1[]LIBS="$$1[]LIBS $app_cv_target_thread_libs";
fi
fi
])
-137
View File
@@ -1,137 +0,0 @@
############################################################################
# Copyright:
# (C) 2008 - 2009 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################
# APP_USE_SYSTEM_EXTENSIONS([flags_prefix])
# This macro detects compiler flags which are needed to enable
# system-specific library extensions. For example, on GNU platforms
# it's -D_GNU_SOURCE, on solaris it's -D__EXTENSIONS__, etc...
# Basically, it's the same as AC_USE_SYSTEM_EXTENSIONS,
# but uses compiler flag approach instead of config.h.
# The extensions used bring the system closer to the GNU,
# X/Open (a superset of POSIX) and POSIX systems.
# You must call AX_COMPILER_VENDOR
# and APP_DETECT_OS_ENV([target], ...) before using this macro.
# More info:
# http://www.gnu.org/software/autoconf/manual/autoconf.html#Posix-Variants
# http://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
# http://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.predefined
# http://docs.sun.com/app/docs/doc/817-3946/6mjgmt4o8?l=en&a=view
AC_DEFUN([APP_USE_SYSTEM_EXTENSIONS], [
# These requirements check compile-time presence, not that they were called
AC_REQUIRE([AX_COMPILER_VENDOR])
AC_REQUIRE([APP_DETECT_OS_ENV])
AC_MSG_CHECKING([for target system extension flags])
app_cv_target_extension_cflags="";
app_cv_target_extension_cxxflags="";
app_cv_target_extension_libs="";
# If vendor is not recognized, it's set to "unknown".
# NOTE: This works only on target compilers!
if test "x${ax_cv_cxx_compiler_vendor}" = "x"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[ax_cv_cxx_compiler_vendor] not set.])
fi
if test "x${app_cv_target_os_kernel}" = "x"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[app_cv_target_os_kernel] not set.])
fi
if test "x${app_cv_target_os_env}" = "x"; then
# msg_result is needed to print the checking... message.
AC_MSG_RESULT([error])
AC_MSG_ERROR([[app_cv_target_os_env] not set.])
fi
case "$app_cv_target_os_env" in
gnu)
# glibc all-extensions macro: _GNU_SOURCE.
# gcc automatically defines it in later versions.
# suncc needs the flag explicitly.
# http://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
app_cv_target_extension_cflags="-D_GNU_SOURCE"
app_cv_target_extension_cxxflags="-D_GNU_SOURCE"
;;
solaris)
# The problem with solaris is that it has too many incompatible
# feature test macros, and there is no enable-all macro. Autoconf
# assumes that __EXTENSIONS__ is the one, but it should be defined
# _in addition_ to feature test macros. Note that on its own, __EXTENSIONS__
# still enables some useful stuff like _LARGEFILE64_SOURCE.
# To support some posix macros, additional link objects are also required.
# Some *_SOURCE feature test macros may be incompatible with C++.
# http://docs.sun.com/app/docs/doc/816-5175/standards-5?a=view
app_cv_target_extension_cflags="-D__EXTENSIONS__"
app_cv_target_extension_cxxflags="-D__EXTENSIONS__"
;;
netbsd)
# There is no enable-all macro.
# (_XOPEN_SOURCE >= 500 || _NETBSD_SOURCE) is recommended.
# The default is _NETBSD_SOURCE, _XOPEN_SOURCE overrides it.
# The manual says that rename() will behave posix-like if _POSIX_C_SOURCE
# is defined. However, stdio.h uses (_XOPEN_SOURCE <= 2) condition,
# which is really bogus.
# See sys/featuretest.h
;;
mingw*)
# This enables standards-compliant stdio behaviour (regarding printf and
# friends), as opposed to msvc-compatible one. This is usually enabled
# by default if one of the usual macros are encountered (_XOPEN_SOURCE,
# _GNU_SOURCE, etc...).
# Also, we make the win2k API available (includes console functions, etc...).
# Other things to consider: _NO_OLDNAMES (disable "deprecated"
# non-underscored names like chdir (use _chdir), etc...).
# See _mingw.h for details.
app_cv_target_extension_cflags="-D__USE_MINGW_ANSI_STDIO=1 -DWINVER=0x0600" # Since Vista
app_cv_target_extension_cxxflags="-D__USE_MINGW_ANSI_STDIO=1 -DWINVER=0x0600"
;;
interix)
# As per AC_USE_SYSTEM_EXTENSIONS.
app_cv_target_extension_cflags="-D_ALL_SOURCE"
app_cv_target_extension_cxxflags="-D_ALL_SOURCE"
;;
esac
AC_MSG_RESULT([CFLAGS: $app_cv_target_extension_cflags; CXXFLAGS: $app_cv_target_extension_cxxflags; LIBS: $app_cv_target_extension_libs])
if test "x$$1[]CFLAGS" = "x"; then
$1[]CFLAGS="$app_cv_target_extension_cflags";
else
$1[]CFLAGS="$$1[]CFLAGS $app_cv_target_extension_cflags";
fi
if test "x$$1[]CXXFLAGS" = "x"; then
$1[]CXXFLAGS="$app_cv_target_extension_cxxflags";
else
$1[]CXXFLAGS="$$1[]CXXFLAGS $app_cv_target_extension_cxxflags";
fi
if test "x$$1[]LIBS" = "x"; then
$1[]LIBS="$app_cv_target_extension_libs";
else
$1[]LIBS="$$1[]LIBS $app_cv_target_extension_libs";
fi
])
+1 -1
View File
@@ -53,7 +53,7 @@ AC_DEFUN([AX_COMPILER_VENDOR],
AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
[ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown
# note: don't check for gcc first since some other compilers define __GNUC__
for ventest in clang:__clang__ intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ pathscale:__PATHCC__,__PATHSCALE__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do
for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ pathscale:__PATHCC__,__PATHSCALE__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do
vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
#if !($vencpp)
-982
View File
@@ -1,982 +0,0 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the specified
# version of the C++ standard. If necessary, add switches to CXX and
# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard)
# or '14' (for the C++14 standard).
#
# The second argument, if specified, indicates whether you insist on an
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
# -std=c++11). If neither is specified, you get whatever works, with
# preference for an extended mode.
#
# The third argument, if specified 'mandatory' or if left unspecified,
# indicates that baseline support for the specified C++ standard is
# required and that the macro should error out if no mode with that
# support is found. If specified 'optional', then configuration proceeds
# regardless, after defining HAVE_CXX${VERSION} if and only if a
# supporting mode is found.
#
# LICENSE
#
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
# Copyright (c) 2016 Krzesimir Nowak <qdlacz@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 7
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
dnl (serial version number 13).
AX_REQUIRE_DEFINED([AC_MSG_WARN])
AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
[$1], [14], [ax_cxx_compile_alternatives="14 1y"],
[$1], [17], [ax_cxx_compile_alternatives="17 1z"],
[m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
m4_if([$2], [], [],
[$2], [ext], [],
[$2], [noext], [],
[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl
m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true],
[$3], [mandatory], [ax_cxx_compile_cxx$1_required=true],
[$3], [optional], [ax_cxx_compile_cxx$1_required=false],
[m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])])
AC_LANG_PUSH([C++])dnl
ac_success=no
AC_CACHE_CHECK(whether $CXX supports C++$1 features by default,
ax_cv_cxx_compile_cxx$1,
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
[ax_cv_cxx_compile_cxx$1=yes],
[ax_cv_cxx_compile_cxx$1=no])])
if test x$ax_cv_cxx_compile_cxx$1 = xyes; then
ac_success=yes
fi
m4_if([$2], [noext], [], [dnl
if test x$ac_success = xno; then
for alternative in ${ax_cxx_compile_alternatives}; do
switch="-std=gnu++${alternative}"
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
$cachevar,
[ac_save_CXX="$CXX"
CXX="$CXX $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXX="$ac_save_CXX"])
if eval test x\$$cachevar = xyes; then
CXX="$CXX $switch"
if test -n "$CXXCPP" ; then
CXXCPP="$CXXCPP $switch"
fi
ac_success=yes
break
fi
done
fi])
m4_if([$2], [ext], [], [dnl
if test x$ac_success = xno; then
dnl HP's aCC needs +std=c++11 according to:
dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
dnl Cray's crayCC needs "-h std=c++11"
for alternative in ${ax_cxx_compile_alternatives}; do
for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
$cachevar,
[ac_save_CXX="$CXX"
CXX="$CXX $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXX="$ac_save_CXX"])
if eval test x\$$cachevar = xyes; then
CXX="$CXX $switch"
if test -n "$CXXCPP" ; then
CXXCPP="$CXXCPP $switch"
fi
ac_success=yes
break
fi
done
if test x$ac_success = xyes; then
break
fi
done
fi])
AC_LANG_POP([C++])
if test x$ax_cxx_compile_cxx$1_required = xtrue; then
if test x$ac_success = xno; then
AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.])
fi
fi
if test x$ac_success = xno; then
HAVE_CXX$1=0
AC_MSG_NOTICE([No compiler with C++$1 support was found])
else
HAVE_CXX$1=1
AC_DEFINE(HAVE_CXX$1,1,
[define if the compiler supports basic C++$1 syntax])
fi
AC_SUBST(HAVE_CXX$1)
m4_if([$1], [17], [AC_MSG_WARN([C++17 is not yet standardized, so the checks may change in incompatible ways anytime])])
])
dnl Test body for checking C++11 support
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
)
dnl Test body for checking C++14 support
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
)
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
)
dnl Tests for new features in C++11
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
// If the compiler admits that it is not ready for C++11, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 201103L
#error "This is not a C++11 compiler"
#else
namespace cxx11
{
namespace test_static_assert
{
template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
}
namespace test_final_override
{
struct Base
{
virtual void f() {}
};
struct Derived : public Base
{
virtual void f() override {}
};
}
namespace test_double_right_angle_brackets
{
template < typename T >
struct check {};
typedef check<void> single_type;
typedef check<check<void>> double_type;
typedef check<check<check<void>>> triple_type;
typedef check<check<check<check<void>>>> quadruple_type;
}
namespace test_decltype
{
int
f()
{
int a = 1;
decltype(a) b = 2;
return a + b;
}
}
namespace test_type_deduction
{
template < typename T1, typename T2 >
struct is_same
{
static const bool value = false;
};
template < typename T >
struct is_same<T, T>
{
static const bool value = true;
};
template < typename T1, typename T2 >
auto
add(T1 a1, T2 a2) -> decltype(a1 + a2)
{
return a1 + a2;
}
int
test(const int c, volatile int v)
{
static_assert(is_same<int, decltype(0)>::value == true, "");
static_assert(is_same<int, decltype(c)>::value == false, "");
static_assert(is_same<int, decltype(v)>::value == false, "");
auto ac = c;
auto av = v;
auto sumi = ac + av + 'x';
auto sumf = ac + av + 1.0;
static_assert(is_same<int, decltype(ac)>::value == true, "");
static_assert(is_same<int, decltype(av)>::value == true, "");
static_assert(is_same<int, decltype(sumi)>::value == true, "");
static_assert(is_same<int, decltype(sumf)>::value == false, "");
static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
return (sumf > 0.0) ? sumi : add(c, v);
}
}
namespace test_noexcept
{
int f() { return 0; }
int g() noexcept { return 0; }
static_assert(noexcept(f()) == false, "");
static_assert(noexcept(g()) == true, "");
}
namespace test_constexpr
{
template < typename CharT >
unsigned long constexpr
strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
{
return *s ? strlen_c_r(s + 1, acc + 1) : acc;
}
template < typename CharT >
unsigned long constexpr
strlen_c(const CharT *const s) noexcept
{
return strlen_c_r(s, 0UL);
}
static_assert(strlen_c("") == 0UL, "");
static_assert(strlen_c("1") == 1UL, "");
static_assert(strlen_c("example") == 7UL, "");
static_assert(strlen_c("another\0example") == 7UL, "");
}
namespace test_rvalue_references
{
template < int N >
struct answer
{
static constexpr int value = N;
};
answer<1> f(int&) { return answer<1>(); }
answer<2> f(const int&) { return answer<2>(); }
answer<3> f(int&&) { return answer<3>(); }
void
test()
{
int i = 0;
const int c = 0;
static_assert(decltype(f(i))::value == 1, "");
static_assert(decltype(f(c))::value == 2, "");
static_assert(decltype(f(0))::value == 3, "");
}
}
namespace test_uniform_initialization
{
struct test
{
static const int zero {};
static const int one {1};
};
static_assert(test::zero == 0, "");
static_assert(test::one == 1, "");
}
namespace test_lambdas
{
void
test1()
{
auto lambda1 = [](){};
auto lambda2 = lambda1;
lambda1();
lambda2();
}
int
test2()
{
auto a = [](int i, int j){ return i + j; }(1, 2);
auto b = []() -> int { return '0'; }();
auto c = [=](){ return a + b; }();
auto d = [&](){ return c; }();
auto e = [a, &b](int x) mutable {
const auto identity = [](int y){ return y; };
for (auto i = 0; i < a; ++i)
a += b--;
return x + identity(a + b);
}(0);
return a + b + c + d + e;
}
int
test3()
{
const auto nullary = [](){ return 0; };
const auto unary = [](int x){ return x; };
using nullary_t = decltype(nullary);
using unary_t = decltype(unary);
const auto higher1st = [](nullary_t f){ return f(); };
const auto higher2nd = [unary](nullary_t f1){
return [unary, f1](unary_t f2){ return f2(unary(f1())); };
};
return higher1st(nullary) + higher2nd(nullary)(unary);
}
}
namespace test_variadic_templates
{
template <int...>
struct sum;
template <int N0, int... N1toN>
struct sum<N0, N1toN...>
{
static constexpr auto value = N0 + sum<N1toN...>::value;
};
template <>
struct sum<>
{
static constexpr auto value = 0;
};
static_assert(sum<>::value == 0, "");
static_assert(sum<1>::value == 1, "");
static_assert(sum<23>::value == 23, "");
static_assert(sum<1, 2>::value == 3, "");
static_assert(sum<5, 5, 11>::value == 21, "");
static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
}
// http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
// Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
// because of this.
namespace test_template_alias_sfinae
{
struct foo {};
template<typename T>
using member = typename T::member_type;
template<typename T>
void func(...) {}
template<typename T>
void func(member<T>*) {}
void test();
void test() { func<foo>(0); }
}
} // namespace cxx11
#endif // __cplusplus >= 201103L
]])
dnl Tests for new features in C++14
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
// If the compiler admits that it is not ready for C++14, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 201402L
#error "This is not a C++14 compiler"
#else
namespace cxx14
{
namespace test_polymorphic_lambdas
{
int
test()
{
const auto lambda = [](auto&&... args){
const auto istiny = [](auto x){
return (sizeof(x) == 1UL) ? 1 : 0;
};
const int aretiny[] = { istiny(args)... };
return aretiny[0];
};
return lambda(1, 1L, 1.0f, '1');
}
}
namespace test_binary_literals
{
constexpr auto ivii = 0b0000000000101010;
static_assert(ivii == 42, "wrong value");
}
namespace test_generalized_constexpr
{
template < typename CharT >
constexpr unsigned long
strlen_c(const CharT *const s) noexcept
{
auto length = 0UL;
for (auto p = s; *p; ++p)
++length;
return length;
}
static_assert(strlen_c("") == 0UL, "");
static_assert(strlen_c("x") == 1UL, "");
static_assert(strlen_c("test") == 4UL, "");
static_assert(strlen_c("another\0test") == 7UL, "");
}
namespace test_lambda_init_capture
{
int
test()
{
auto x = 0;
const auto lambda1 = [a = x](int b){ return a + b; };
const auto lambda2 = [a = lambda1(x)](){ return a; };
return lambda2();
}
}
namespace test_digit_separators
{
constexpr auto ten_million = 100'000'000;
static_assert(ten_million == 100000000, "");
}
namespace test_return_type_deduction
{
auto f(int& x) { return x; }
decltype(auto) g(int& x) { return x; }
template < typename T1, typename T2 >
struct is_same
{
static constexpr auto value = false;
};
template < typename T >
struct is_same<T, T>
{
static constexpr auto value = true;
};
int
test()
{
auto x = 0;
static_assert(is_same<int, decltype(f(x))>::value, "");
static_assert(is_same<int&, decltype(g(x))>::value, "");
return x;
}
}
} // namespace cxx14
#endif // __cplusplus >= 201402L
]])
dnl Tests for new features in C++17
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
// If the compiler admits that it is not ready for C++17, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus <= 201402L
#error "This is not a C++17 compiler"
#else
#if defined(__clang__)
#define REALLY_CLANG
#else
#if defined(__GNUC__)
#define REALLY_GCC
#endif
#endif
#include <initializer_list>
#include <utility>
#include <type_traits>
namespace cxx17
{
#if !defined(REALLY_CLANG)
namespace test_constexpr_lambdas
{
// TODO: test it with clang++ from git
constexpr int foo = [](){return 42;}();
}
#endif // !defined(REALLY_CLANG)
namespace test::nested_namespace::definitions
{
}
namespace test_fold_expression
{
template<typename... Args>
int multiply(Args... args)
{
return (args * ... * 1);
}
template<typename... Args>
bool all(Args... args)
{
return (args && ...);
}
}
namespace test_extended_static_assert
{
static_assert (true);
}
namespace test_auto_brace_init_list
{
auto foo = {5};
auto bar {5};
static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
static_assert(std::is_same<int, decltype(bar)>::value);
}
namespace test_typename_in_template_template_parameter
{
template<template<typename> typename X> struct D;
}
namespace test_fallthrough_nodiscard_maybe_unused_attributes
{
int f1()
{
return 42;
}
[[nodiscard]] int f2()
{
[[maybe_unused]] auto unused = f1();
switch (f1())
{
case 17:
f1();
[[fallthrough]];
case 42:
f1();
}
return f1();
}
}
namespace test_extended_aggregate_initialization
{
struct base1
{
int b1, b2 = 42;
};
struct base2
{
base2() {
b3 = 42;
}
int b3;
};
struct derived : base1, base2
{
int d;
};
derived d1 {{1, 2}, {}, 4}; // full initialization
derived d2 {{}, {}, 4}; // value-initialized bases
}
namespace test_general_range_based_for_loop
{
struct iter
{
int i;
int& operator* ()
{
return i;
}
const int& operator* () const
{
return i;
}
iter& operator++()
{
++i;
return *this;
}
};
struct sentinel
{
int i;
};
bool operator== (const iter& i, const sentinel& s)
{
return i.i == s.i;
}
bool operator!= (const iter& i, const sentinel& s)
{
return !(i == s);
}
struct range
{
iter begin() const
{
return {0};
}
sentinel end() const
{
return {5};
}
};
void f()
{
range r {};
for (auto i : r)
{
[[maybe_unused]] auto v = i;
}
}
}
namespace test_lambda_capture_asterisk_this_by_value
{
struct t
{
int i;
int foo()
{
return [*this]()
{
return i;
}();
}
};
}
namespace test_enum_class_construction
{
enum class byte : unsigned char
{};
byte foo {42};
}
namespace test_constexpr_if
{
template <bool cond>
int f ()
{
if constexpr(cond)
{
return 13;
}
else
{
return 42;
}
}
}
namespace test_selection_statement_with_initializer
{
int f()
{
return 13;
}
int f2()
{
if (auto i = f(); i > 0)
{
return 3;
}
switch (auto i = f(); i + 4)
{
case 17:
return 2;
default:
return 1;
}
}
}
#if !defined(REALLY_CLANG)
namespace test_template_argument_deduction_for_class_templates
{
// TODO: test it with clang++ from git
template <typename T1, typename T2>
struct pair
{
pair (T1 p1, T2 p2)
: m1 {p1},
m2 {p2}
{}
T1 m1;
T2 m2;
};
void f()
{
[[maybe_unused]] auto p = pair{13, 42u};
}
}
#endif // !defined(REALLY_CLANG)
namespace test_non_type_auto_template_parameters
{
template <auto n>
struct B
{};
B<5> b1;
B<'a'> b2;
}
#if !defined(REALLY_CLANG)
namespace test_structured_bindings
{
// TODO: test it with clang++ from git
int arr[2] = { 1, 2 };
std::pair<int, int> pr = { 1, 2 };
auto f1() -> int(&)[2]
{
return arr;
}
auto f2() -> std::pair<int, int>&
{
return pr;
}
struct S
{
int x1 : 2;
volatile double y1;
};
S f3()
{
return {};
}
auto [ x1, y1 ] = f1();
auto& [ xr1, yr1 ] = f1();
auto [ x2, y2 ] = f2();
auto& [ xr2, yr2 ] = f2();
const auto [ x3, y3 ] = f3();
}
#endif // !defined(REALLY_CLANG)
#if !defined(REALLY_CLANG)
namespace test_exception_spec_type_system
{
// TODO: test it with clang++ from git
struct Good {};
struct Bad {};
void g1() noexcept;
void g2();
template<typename T>
Bad
f(T*, T*);
template<typename T1, typename T2>
Good
f(T1*, T2*);
static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
}
#endif // !defined(REALLY_CLANG)
namespace test_inline_variables
{
template<class T> void f(T)
{}
template<class T> inline T g(T)
{
return T{};
}
template<> inline void f<>(int)
{}
template<> int g<>(int)
{
return 5;
}
}
} // namespace cxx17
#endif // __cplusplus <= 201402L
]])
+21 -32
View File
@@ -28,40 +28,29 @@
AC_DEFUN([AX_CXX_GCC_ABI_DEMANGLE],
[AC_CACHE_CHECK(whether the compiler supports GCC C++ ABI name demangling,
ac_cv_cxx_gcc_abi_demangle,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <typeinfo>
#include <cxxabi.h>
#include <string>
#include <stdlib.h> /* not cstdlib */
ac_cv_cxx_gcc_abi_demangle,
[AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <typeinfo>
#include <cxxabi.h>
#include <string>
template<typename TYPE>
class A {};
]], [[
A<int> instance;
int status = 0;
char* c_name = 0;
template<typename TYPE>
class A {};
]], [[A<int> instance;
int status = 0;
char* c_name = 0;
c_name = abi::__cxa_demangle(typeid(instance).name(), 0, 0, &status);
c_name = abi::__cxa_demangle(typeid(instance).name(), 0, 0, &status);
std::string name(c_name);
free(c_name); /* not std::free() */
std::string name(c_name);
free(c_name);
return name == "A<int>";
]])],
[ac_cv_cxx_gcc_abi_demangle=yes], [ac_cv_cxx_gcc_abi_demangle=no])
AC_LANG_POP([])
])
if test "$ac_cv_cxx_gcc_abi_demangle" = yes; then
AC_DEFINE(HAVE_GCC_ABI_DEMANGLE, 1,
[defined to 1 if the compiler supports GCC C++ ABI name demangling, 0 otherwise])
else
AC_DEFINE(HAVE_GCC_ABI_DEMANGLE, 0,
[defined to 1 if the compiler supports GCC C++ ABI name demangling, 0 otherwise])
fi
return name == "A<int>";
]])],[ac_cv_cxx_gcc_abi_demangle=yes],[ac_cv_cxx_gcc_abi_demangle=no])
AC_LANG_POP([])
])
if test "$ac_cv_cxx_gcc_abi_demangle" = yes; then
AC_DEFINE(HAVE_GCC_ABI_DEMANGLE,1,
[define if the compiler supports GCC C++ ABI name demangling])
fi
])
+1 -1
View File
@@ -16,7 +16,7 @@
# autoconf
autoreconf --verbose --install -W all --force
autoreconf --verbose --install -W all
rm -f config.cache
Executable
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
stamp="../gsmartcontrol-`date +%F`"
echo $stamp
mkdir $stamp
cp -dp * $stamp/
rm -f $stamp/*pcs # kdevelop persistent store files
cp -a autoconf.m4/ $stamp/
cp -a data/ $stamp/
cp -a src/ $stamp/
cp -a templates/ $stamp/
# cp -a test-data/ $stamp/
tar cvf $stamp.tar $stamp
bzip2 -9 $stamp.tar
-83
View File
@@ -1,83 +0,0 @@
#!/bin/bash
# Configure a build directory according to developer flags
type="$1";
configure_script="$2";
if [ "$type" == "" ]; then
echo "Usage: $0 <type> [<configure_script>]"
echo "where <type> is one of:"
echo "none debug optimized gcc-debug clang-debug icc-debug sun win32-cross win32-cross-debug \
win64-cross win64-cross-debug win32-msys win32-msys-debug win64-msys win64-msys-debug";
echo "<configure_script> is ../configure by default"
exit 1;
fi
if [ "$configure_script" == "" ]; then
configure_script="../configure";
fi
flags="";
case $type in
none)
flags="--enable-tests" ;;
debug)
flags="--enable-debug-options --enable-tests" ;;
optimized)
flags="--enable-optimize-options --enable-tests" ;;
gcc-debug)
flags="CC=gcc CXX=g++ --enable-common-options=gnu --enable-debug-options --enable-tests" ;;
clang-debug)
flags="CC=clang CXX=clang++ --enable-common-options=clang --enable-debug-options --enable-tests" ;;
icc-debug)
flags="CC=icc64 CXX=icpc64 --enable-common-options=intel --enable-debug-options --enable-tests" ;;
sun)
flags="CC=suncc CXX=sunCC --enable-common-options=sun CFLAGS=\"-errwarn=%all -I/opt/sun/target64/include\" \
CXXFLAGS=\"-I/opt/sun/target64/include\" PATH=\"/opt/sun/sunstudio/bin:$PATH\" \
LDFLAGS=\"-R/opt/sun/target64/lib64 -L/opt/sun/target64/lib64\" \
PKG_CONFIG_PATH=\"/opt/sun/target64/lib64/pkgconfig:/usr/lib64/pkgconfig\" \
PKG_CONFIG_LIBDIR=\"\" --enable-tests" ;;
win32-cross)
flags="PATH=\"/usr/i686-w64-mingw32/bin:/usr/i686-w64-mingw32/sys-root/mingw/bin:$PATH\" \
--with-nsis=/usr/bin/makensis --with-windows-sysroot=/usr/i686-w64-mingw32/sys-root/mingw \
--enable-optimize-options --enable-tests --host=i686-w64-mingw32" ;;
win32-cross-debug)
flags="PATH=\"/usr/i686-w64-mingw32/bin:/usr/i686-w64-mingw32/sys-root/mingw/bin:$PATH\" \
--enable-debug-options --enable-tests --host=i686-w64-mingw32" ;;
win64-cross)
flags="PATH=\"/usr/x86_64-w64-mingw32/bin:/usr/x86_64-w64-mingw32/sys-root/mingw/bin:$PATH\" \
--with-nsis=/usr/bin/makensis --with-windows-sysroot=/usr/x86_64-w64-mingw32/sys-root/mingw \
--enable-optimize-options --enable-tests --host=x86_64-w64-mingw32" ;;
win64-cross-debug)
flags="PATH=\"/usr/x86_64-w64-mingw32/bin:/usr/x86_64-w64-mingw32/sys-root/mingw/bin:$PATH\" \
--enable-debug-options --enable-tests --host=x86_64-w64-mingw32" ;;
win32-msys)
flags="PATH=\"/mingw32/i686-w64-mingw32:/mingw32/bin:$PATH\" \
--with-nsis=/mingw32/bin/makensis.exe --with-windows-sysroot=/mingw32 \
--enable-optimize-options --enable-tests --host=i686-w64-mingw32" ;;
win32-msys-debug)
flags="PATH=\"/mingw32/i686-w64-mingw32:/mingw32/bin:$PATH\" \
--enable-debug-options --enable-tests --host=i686-w64-mingw32" ;;
win64-msys)
flags="PATH=\"/mingw64/x86_64-w64-mingw32:/mingw64/bin:$PATH\" \
--with-nsis=/mingw64/bin/makensis.exe --with-windows-sysroot=/mingw64 \
--enable-optimize-options --enable-tests --host=x86_64-w64-mingw32" ;;
win64-msys-debug)
flags="PATH=\"/mingw64/x86_64-w64-mingw32:/mingw64/bin:$PATH\" \
--enable-debug-options --enable-tests --host=x86_64-w64-mingw32" ;;
esac
echo "Running:"
echo $configure_script $flags;
$configure_script $flags
exit $?
+358 -272
View File
@@ -1,16 +1,13 @@
AC_INIT([GSmartControl],[1.1.3],[],[gsmartcontrol])
AC_INIT([GSmartControl], [0.8.0rc3], [], [gsmartcontrol])
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_HEADERS([config.h])
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([foreign no-dist-gzip dist-bzip2 -Wall])
# Clear *FLAGS, LIBS, LDFLAGS if requested through configure option.
APP_AUTO_CLEAR_FLAGS()
# disable portability warnings because of pattern rules in src/res.
AM_INIT_AUTOMAKE([foreign no-dist-gzip dist-bzip2 -Wall,no-portability])
# C compiler, C preprocessor
AC_PROG_CC
@@ -22,71 +19,51 @@ AC_PROG_CXX
#AC_PROG_CXXCPP
#AM_PROG_LIBTOOL
AM_PROG_AR
# C++ support in checks
#AC_LANG([C])
AC_LANG([C++])
# Needed for generating static libs
# to be able to generate static libs
AC_CHECK_TOOL(RANLIB, ranlib)
# Win32 resource file compilation
AC_CHECK_TOOL(WINDRES, windres)
# Win32 external dll stripping (already detected by autoconf)
# AC_CHECK_TOOL(STRIP, strip)
# Defines LN_S, needed for man page installation.
AC_PROG_LN_S
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
# ------------- Detect compiler, OS, environment. Enable system features.
# Various compiler features
# detect compiler vendor (sets $ax_cv_cxx_compiler_vendor)
AX_COMPILER_VENDOR
# Detect target OS kernel and userspace and export to config.h
# (also define automake conditionals).
APP_DETECT_OS_KERNEL([target], [CONFIG_KERNEL_])
APP_DETECT_OS_ENV([target], [CONFIG_OS_ENV_])
APP_DETECT_OS_KERNEL([build], [CONFIG_HOST_KERNEL_])
# detect RTTI (defines HAVE_RTTI)
AC_CXX_RTTI
# Detect common (warning, debug, optimize) compiler flags and
# export them to C(XX)FLAGS, LDFLAGS.
# We don't use prefix because this way the flags will be used for tests,
# which is important for some compatibility flags (e.g. __func__ visibility, etc...).
APP_COMPILER_OPTIONS([])
# detect exception support (defines HAVE_EXCEPTIONS)
AC_CXX_EXCEPTIONS
# Enable C++11 support. This is implied by gtkmm3, but CentOS7 fails to add it
# to gtkmm flags, so we have to enable it manually. Make it optional for Debian 7 (gcc 4.7).
AX_CXX_COMPILE_STDCXX([11], [], [optional])
# detect abi::__cxa_demangle (defines HAVE_GCC_ABI_DEMANGLE)
AX_CXX_GCC_ABI_DEMANGLE
# Thread support for known configurations.
# Sun compiler (at least on linux) has some runtime issues with stringstream
# unless we use the thread flags. Also, Linux-based gdb fails to debug
# a gcc-compiled binary for some reason.
# Do this for all systems except mingw.
if test "$app_cv_target_os_env" != "mingw32" && test "$app_cv_target_os_env" != "mingw64"; then
APP_GET_MT_FLAGS([])
fi
# detect __gnu_cxx::__verbose_terminate_handler (defines HAVE_VERBOSE_TERMINATE_HANDLER.)
AC_CXX_VERBOSE_TERMINATE_HANDLER
# Enable _GNU_SOURCE, etc...
APP_USE_SYSTEM_EXTENSIONS([])
# detect __func__ support (defines HAVE_CXX__FUNC)
AC_CXX_VAR_FUNC
# Arrange large file support (define _FILE_OFFSET_BITS 64, etc...)
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
# Portability stuff
# arrange large file support (define _FILE_OFFSET_BITS 64, etc...)
AC_SYS_LARGEFILE
# ------------- Correct incomplete standard libraries
# define int8_t and friends if the standard doesn't have them
AC_TYPE_INT8_T
AC_TYPE_UINT8_T
@@ -102,42 +79,17 @@ AC_TYPE_UINTMAX_T
AC_TYPE_LONG_LONG_INT
AC_TYPE_UNSIGNED_LONG_LONG_INT
# ------------- Language / Standard Library checks
# detect RTTI (defines HAVE_RTTI)
AC_CXX_RTTI
# detect exception support (defines HAVE_EXCEPTIONS)
AC_CXX_EXCEPTIONS
# detect abi::__cxa_demangle (defines HAVE_GCC_ABI_DEMANGLE)
AX_CXX_GCC_ABI_DEMANGLE
# detect __gnu_cxx::__verbose_terminate_handler (defines HAVE_VERBOSE_TERMINATE_HANDLER.)
AC_CXX_VERBOSE_TERMINATE_HANDLER
# detect __func__ support (defines HAVE_CXX___func__)
APP_CXX___func__
# detect __FUNCTION__ support (defines HAVE_CXX___FUNCTION__)
APP_CXX___FUNCTION__
# detect if the compiler accepts extern "C" function pointer overloads
# (defines HAVE_CXX_EXTERN_C_OVERLOAD)
APP_CXX_EXTERN_C_OVERLOAD
# This may be needed for pch support
AC_CHECK_HEADERS([stdc++.h])
# pcrecpp needs this (break on first function found)
AC_CHECK_FUNCS([strtoll _strtoi64], [break])
# Non-C99 systems don't have strtof and strtold. some have strtodf for strtof,
# but let's ignore it. Note: They may be supported by system libc,
# but not enabled by default (e.g. by glibc feature macros). In that case,
# but unsupported by headers (e.g. sun studio on linux). In that case,
# defining them still leads to undefined symbols at link time, so we don't do it.
# Header check is the best way to determine availability.
# This defines HAVE_DECL_<symbol> to 1 or 0.
# header / link check:
AC_CHECK_DECLS([strtof, strtold], [], [], [[#include <stdlib.h>]])
# link check only:
# AC_CHECK_FUNCS([strtof strtold])
@@ -148,10 +100,273 @@ AC_CHECK_DECLS([strtof, strtold], [], [], [[#include <stdlib.h>]])
# -------------------------------------------------------------------------------------
# Non-standard feature checks
# "build" - the type of system on which the package is being configured and compiled.
ac_windows_build="no"
ac_linux_build="no"
case "${host}" in
*mingw*)
ac_windows_build="yes"
;;
*linux*)
ac_linux_build="yes"
;;
esac
# getrawpartition() for netbsd and openbsd in -lutil.
AC_CHECK_LIB(util, getrawpartition, [ LIBS="$LIBS -lutil" ])
# export to Makefile.am-s
AM_CONDITIONAL([WINDOWS_BUILD], [test "$ac_windows_build" = "yes"])
AM_CONDITIONAL([LINUX_BUILD], [test "$ac_linux_build" = "yes"])
# "host" - the type of system on which the package runs. Specifying it enables the
# cross-compilation mode. "target" defaults to this too.
ac_windows_target="no"
ac_linux_target="no"
case "${target}" in
*mingw*)
ac_windows_target="yes"
;;
*linux*)
ac_linux_target="yes"
;;
esac
# export to Makefile.am-s
AM_CONDITIONAL([WINDOWS_TARGET], [test "$ac_windows_target" = "yes"])
AM_CONDITIONAL([LINUX_TARGET], [test "$ac_linux_target" = "yes"])
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
COMPILER_CXXFLAGS=""
COMPILER_LDFLAGS=""
# reset original user-supplied *FLAGS
RESET_ORIGINAL="no"
AC_ARG_ENABLE(default-gcc-options,
AS_HELP_STRING([--enable-default-gcc-options],[enable default compilation options (warnings, mostly) (GCC only) (default: disabled)]),
[default_gcc_options=${enableval}], [default_gcc_options=no])
if test "$default_gcc_options" = "yes"; then
if test "$ac_windows_target" = "yes"; then
COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS -mms-bitfields -mwindows"
COMPILER_LDFLAGS="$COMPILER_CXXFLAGS -mms-bitfields"
fi
COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS \
-Wall -Wcast-align -Wcast-qual -Wconversion \
-Wctor-dtor-privacy -Wfloat-equal -Wnon-virtual-dtor -Woverloaded-virtual \
-Wpointer-arith -Wshadow -Wsign-compare -Wsign-promo -Wundef -Wwrite-strings"
RESET_ORIGINAL="yes";
fi
AC_ARG_ENABLE(gcc-debug,
AS_HELP_STRING([--enable-gcc-debug],[enable debug build (GCC only) (default: disabled)]),
[gcc_debug=${enableval}], [gcc_debug=no])
if test "$gcc_debug" = "yes"; then
COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS -g3 -O0 -DDEBUG -DDEBUG_BUILD"
COMPILER_LDFLAGS="$COMPILER_LDFLAGS -g3 -O0"
RESET_ORIGINAL="yes";
fi
AC_ARG_ENABLE(gcc-optimize,
AS_HELP_STRING([--enable-gcc-optimize],[enable optimized build (GCC only) (default: disabled)]),
[gcc_optimize=${enableval}], [gcc_optimize=no])
if test "$gcc_optimize" = "yes"; then
# Note: Do NOT put CPU flags here - they make the program non-portable.
if test "$ac_windows_target" = "yes"; then
COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS -g0 -O3 -s"
COMPILER_LDFLAGS="$COMPILER_LDFLAGS -s"
else
COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS -g0 -O3 -s -mtune=generic"
COMPILER_LDFLAGS="$COMPILER_LDFLAGS -s -mtune=generic"
fi
RESET_ORIGINAL="yes";
fi
AC_ARG_ENABLE(gcc_pch,
AS_HELP_STRING([--enable-gcc-pch],[enable precompiled header support (pch make target) (GCC only) (default: disabled)
(use "make gch" to speed up the compilation)]),
[gcc_pch=${enableval}], [gcc_pch=no])
if test "$gcc_pch" = "yes"; then
COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS -Winvalid-pch -DENABLE_PCH"
fi
# define LINUX for linux target
if test "$ac_linux_target" = "yes"; then
COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS -DLINUX"
fi
# Reset user-supplied flags if one of the above options is present.
# We append COMPILER_* counterparts in the end, to override any
# previous options.
if test "$RESET_ORIGINAL" = "yes"; then
CFLAGS=""
CXXFLAGS=""
LIBS=""
LDFLAGS=""
fi
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
# Enable compiler thread switches for known platforms.
AC_MSG_NOTICE([checking thread support flags...])
THREAD_CFLAGS=""
THREAD_LIBS=""
THREAD_FOUND="no"
if test "$ac_windows_target" = "yes"; then
if test "$ax_cv_cxx_compiler_vendor" = "gnu"; then
THREAD_CFLAGS="-mthreads -D_THREAD_SAFE"
THREAD_LIBS="-mthreads"
THREAD_FOUND="yes"
fi
elif test "$ac_linux_target" = "yes"; then
if test "$ax_cv_cxx_compiler_vendor" = "gnu" || test "$ax_cv_cxx_compiler_vendor" = "intel"; then
THREAD_CFLAGS="-pthread -D_MT -D_THREAD_SAFE"
THREAD_LIBS="-pthread"
THREAD_FOUND="yes"
elif test "$ax_cv_cxx_compiler_vendor" = "sun"; then
THREAD_CFLAGS="-mt"
THREAD_LIBS="-mt"
THREAD_FOUND="yes"
fi
fi
if test "$THREAD_FOUND" = "no"; then
AC_MSG_NOTICE([Cannot detect compiler thread support. Set CXXFLAGS and LDFLAGS manually.])
else
AC_MSG_NOTICE([CFLAGS: $THREAD_CFLAGS; LIBS: $THREAD_LIBS])
CXXFLAGS="$CXXFLAGS $THREAD_CFLAGS"
LIBS="$LIBS $THREAD_LIBS"
fi
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
# iconview is available since 2.6.0. gthread is not enabled by default.
pkg_modules="gtkmm-2.4 >= 2.6.0 gthread-2.0 >= 2.0"
# define ENABLE_GLIB and friends if it's found.
gtkmm_found="no"
PKG_CHECK_MODULES([GTKMM], [$pkg_modules], [
AC_DEFINE([ENABLE_GLIB], [], [Whether GLib is installed])
AC_DEFINE([ENABLE_GLIBMM], [], [Whether GLibmm is installed])
gtkmm_found="yes"
], [
AC_MSG_WARN([$GTKMM_PKG_ERRORS])
AC_MSG_WARN([The program will be unable to compile fully.])
])
# use this instead of the above one to enable abort-on-not-found behaviour.
# PKG_CHECK_MODULES([GTKMM], [$pkg_modules])
# GTK flags must be prepended, or glib_config.h conflict between
# gtk 2.x and 1.2 may occur.
#CFLAGS="$GTKMM_CFLAGS $CFLAGS"
CXXFLAGS="$GTKMM_CFLAGS $CXXFLAGS"
LIBS="$GTKMM_LIBS $LIBS"
# needed for in-code checks (AC_DEFINE() takes care of these above, no need of them here)
# CXXFLAGS="$CXXFLAGS -DENABLE_GLIB -DENABLE_GLIBMM"
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
gld_found=no; # equals to "gtkbuilder" or "libglademm" after tests
#if test "gtkmm_found" = "yes"; then
# Check whether we should use Gtk::Builder (gtkmm >= 2.12) or libglademm.
AC_ARG_ENABLE(libglademm, AS_HELP_STRING([--enable-libglademm],
[use libglademm instead of GtkBuilder (default: auto)]), [with_libglademm=${enableval}], [with_libglademm=auto])
# try gtkbuilder first
if test "$with_libglademm" = "no" || test "$with_libglademm" = "auto"; then
PKG_CHECK_EXISTS([gtkmm-2.4 >= 2.12.0], [gld_found=gtkbuilder])
fi
if test "$with_libglademm" = "no" && test "$gld_found" = "no"; then
AC_MSG_ERROR([GtkBuilder support not found (you need gtkmm version 2.12 or higher). Try using libglademm instead.])
fi
# libglade specified, or auto and no gtkbuilder. gtkmm2.4-compatible libglade is >= 2.4.0.
if test "$gld_found" = "no"; then
PKG_CHECK_MODULES([LIBGLADEMM], [libglademm-2.4 >= 2.4.0], [gld_found="libglademm"],
[AC_MSG_WARN([$LIBGLADEMM_PKG_ERRORS])])
fi
if test "$with_libglademm" = "yes" && test "$gld_found" = "no"; then
AC_MSG_ERROR([Libglademm not found. Try building with GtkBuilder support (you need gtkmm version 2.12 or higher).])
fi
# still not found.
if test "$gld_found" = "no"; then
AC_MSG_WARN([Neither GtkBuilder nor libglademm found. The program will be unable to compile fully.])
fi
AC_MSG_NOTICE([Glade file support through: $gld_found])
# merge libglademm flags
if test "$gld_found" = "libglademm"; then
CXXFLAGS="$LIBGLADEMM_CFLAGS $CXXFLAGS"
LIBS="$LIBGLADEMM_LIBS $LIBS"
fi
#fi
# export to automake.am-s
AM_CONDITIONAL([ENABLE_LIBGLADEMM], [test "$gld_found" = "libglademm"])
AM_CONDITIONAL([ENABLE_GTKBUILDER], [test "$gld_found" = "gtkbuilder"])
# export to config.h
if test "$gld_found" = "libglademm"; then
AC_DEFINE(ENABLE_LIBGLADEMM, 1, [Use libglademm instead of GtkBuilder])
fi
if test "$gld_found" = "gtkbuilder"; then
AC_DEFINE(ENABLE_GTKBUILDER, 1, [Use GtkBuilder instead of libglademm])
fi
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
pkg_modules="libpcre"
PKG_CHECK_MODULES(PCRE, [$pkg_modules])
#CFLAGS="$PCRE_CFLAGS $CFLAGS"
CXXFLAGS="$PCRE_CFLAGS $CXXFLAGS"
LIBS="$PCRE_LIBS $LIBS"
# -------------------------------------------------------------------------------------
@@ -171,159 +386,25 @@ AM_CONDITIONAL([ENABLE_TESTS], [test "$with_tests" = "yes"])
# -------------------------------------------------------------------------------------
AC_ARG_ENABLE(abort-if-no-gtkmm, AS_HELP_STRING([--disable-abort-if-no-gtkmm],
[disable abort if no gtkmm is found (default: configure aborts when gtkmm is not found)]),
[app_cv_abort_if_no_gtkmm=${enableval}], [app_cv_abort_if_no_gtkmm=yes])
AC_MSG_NOTICE([Abort if no gtkmm is found: $app_cv_abort_if_no_gtkmm])
pkg_modules="gtkmm-3.0 >= 3.4.0"
# define ENABLE_GLIB and friends if it's found.
gtkmm_found="no"
PKG_CHECK_MODULES([GTKMM], [$pkg_modules],
[gtkmm_found="yes"], [gtkmm_found="no"])
if test "x$gtkmm_found" = "xyes"; then
AC_DEFINE([ENABLE_GLIB], [1], [Defined to 1 if GLib is installed, 0 otherwise])
AC_DEFINE([ENABLE_GLIBMM], [1], [Defined to 1 if glibmm is installed, 0 otherwise])
else
AC_DEFINE([ENABLE_GLIB], [0], [Defined to 1 if GLib is installed, 0 otherwise])
AC_DEFINE([ENABLE_GLIBMM], [0], [Defined to 1 if glibmm is installed, 0 otherwise])
fi
if test "x$gtkmm_found" = "xno"; then
if test "x$app_cv_abort_if_no_gtkmm" = "xno"; then
AC_MSG_WARN([$GTKMM_PKG_ERRORS])
AC_MSG_WARN([The program will be unable to compile fully.])
else
AC_MSG_ERROR([$GTKMM_PKG_ERRORS])
fi
fi
#CFLAGS="$GTKMM_CFLAGS $CFLAGS"
CXXFLAGS="$GTKMM_CFLAGS $CXXFLAGS"
LIBS="$GTKMM_LIBS $LIBS"
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
PCRECPP_CFLAGS="";
PCRECPP_LIBS="";
# try pkg-config first
PKG_CHECK_MODULES(PCRECPP, [libpcrecpp], [pcrecpp_found=yes], [pcrecpp_found=no])
# if not found, try pcre-config (solaris had it but not pkg-config).
if test "x$pcrecpp_found" = "xno"; then
AC_PATH_PROG(pcre_config_binary, [pcre-config])
if test "x$pcre_config_binary" != "x"; then
PCRE_CFLAGS="`pcre-config --cflags`"
PCRE_LIBS="`pcre-config --libs-cpp`"
else
# AC_MSG_ERROR([Could not find pcrecpp through pkg-config and pcre-config. Make sure the pcre and pcrecpp libraries are installed])
AC_MSG_ERROR([$PCRECPP_PKG_ERRORS])
fi
fi
CFLAGS="$CFLAGS $PCRECPP_CFLAGS"
CXXFLAGS="$CXXFLAGS $PCRECPP_CFLAGS"
LIBS="$LIBS $PCRECPP_LIBS"
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
# Win32 distribution support (NSIS, zip)
AC_ARG_WITH([nsis], [AS_HELP_STRING([--with-nsis=<location>|auto],
[specify makensis.exe location to support making NSIS packages]
[ (default: "C:\Program Files\NSIS\makensis.exe" for windows, ]
["~/.wine/drive_c/Program Files/NSIS/Unicode/makensis.exe" for others)])],
[with_nsis=${withval}], [with_nsis=auto])
AC_ARG_ENABLE([nsis-wine], [AS_HELP_STRING([--enable-nsis-wine=yes|no],
[use wine to run makensis.exe when making NSIS packages (default: no)])],
[with_nsis_wine=${enableval}], [with_nsis_wine=no])
AC_ARG_WITH([windows-sysroot], [AS_HELP_STRING([--with-windows-sysroot],
[specify location of Windows system root directory when making Windows packages (default: /mingw32)])],
[with_windows_sysroot=${withval}], [with_windows_sysroot=auto])
if test "x$with_nsis" = "xauto" || test "x$with_nsis" = "x"; then
# if building on windows, use native paths
if test "x$app_cv_build_os_kernel" = "xwindows32" || test "x$app_cv_build_os_kernel" = "xwindows64"; then
with_nsis="\"C:\\Program Files\\NSIS\\makensis.exe\"";
else
with_nsis="~/\".wine/drive_c/Program Files/NSIS/Unicode/makensis.exe\"";
fi
fi
NSIS_EXEC="$with_nsis";
if test "x$with_nsis_wine" = "xyes"; then
NSIS_EXEC="wine $with_nsis";
fi
if test "x$with_windows_sysroot" = "xauto" || test "x$with_windows_sysroot" = "x"; then
with_windows_sysroot="/mingw32"
fi
WINDOWS_SYSROOT="$with_windows_sysroot";
WINDOWS_SUFFIX="";
if test "x$app_cv_target_os_kernel" = "xwindows32"; then
WINDOWS_SUFFIX="win32"
elif test "x$app_cv_target_os_kernel" = "xwindows64"; then
WINDOWS_SUFFIX="win64"
fi
AC_SUBST(NSIS_EXEC)
AC_SUBST(WINDOWS_SYSROOT)
AC_SUBST(WINDOWS_SUFFIX)
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
# Win32 security manifest support
WINDOWS_ARCH=""
if test "x$app_cv_target_os_kernel" = "xwindows32"; then
WINDOWS_ARCH="x86"
elif test "x$app_cv_target_os_kernel" = "xwindows64"; then
WINDOWS_ARCH="amd64"
fi
AC_SUBST(WINDOWS_ARCH)
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
RES_FILES="src/res/gsc_about_dialog.ui \
src/res/gsc_add_device_window.ui \
src/res/gsc_executor_log_window.ui \
src/res/gsc_info_window.ui \
src/res/gsc_main_window.ui \
src/res/gsc_preferences_window.ui \
src/res/gsc_text_window.ui \
AUTHORS.txt LICENSE_gsmartcontrol.txt"
RES_FILES="src/res/gsc_about_dialog.glade \
src/res/gsc_executor_log_window.glade \
src/res/gsc_help_window.glade \
src/res/gsc_info_window.glade \
src/res/gsc_main_window.glade \
src/res/gsc_preferences_window.glade \
src/res/gsc_text_window.glade \
AUTHORS.txt LICENSE_gsmartcontrol.txt README.txt"
# Unfortunately, _SOURCES can't contain substitutions, so we use LIBADD.
RES_LIBADD="" # .o file to put into .a, libres_a_LIBADD, libres_a_DEPENDENCIES.
RES_DIST="" # only files in "res" directory, EXTRA_DIST
RES_TARGETS="" # entry for each file in makefile
RES_GLD_EXT="glade"
if test "$gld_found" = "gtkbuilder"; then
RES_GLD_EXT="ui"
fi
for RES_FILE in $RES_FILES;
do # on separate line for portability
RES_BASE=`echo "$RES_FILE" | sed 's/.*\///'` # "a/b/c" -> "c", "c" -> "c"
@@ -339,14 +420,28 @@ do # on separate line for portability
RES_FILE_CANON="\$(srcdir)/$RES_BASE" # shorter path, better make behaviour
fi
if test "$RES_BASE_EXT" = "ui"; then
RES_LIBADD="$RES_LIBADD $RES_BASE_NOEXT.ui.$ac_objext" # file.ui.o
# We use separate source files for gtkbuilder and libglademm, because
# make dist should be able to bundle both of them separately.
if test "$RES_BASE_EXT" = "glade"; then
RES_LIBADD="$RES_LIBADD $RES_BASE_NOEXT.$RES_GLD_EXT.$ac_objext" # file.ui.o or file.glade.o
# Output both glade and ui rules. This way make dist will be able
# to build cpp files of both of them.
RES_TARGETS="$RES_TARGETS
$RES_BASE_NOEXT.ui.cpp: $RES_FILE_CANON
\"\$(top_srcdir)/file2csource.sh\" \"$RES_FILE_CANON\" \"$RES_BASE_NOEXT.ui.cpp\" \"$RES_BASE_NOEXT\"_ui
gtk-builder-convert \"$RES_FILE_CANON\" \"$RES_BASE_NOEXT\".tmp_ui
\"\$(top_srcdir)/file2csource.sh\" \"$RES_BASE_NOEXT\".tmp_ui \"$RES_BASE_NOEXT.ui.cpp\" \"$RES_BASE_NOEXT\"_ui
"
RES_TARGETS="$RES_TARGETS
$RES_BASE_NOEXT.glade.cpp: $RES_FILE_CANON
\"\$(top_srcdir)/file2csource.sh\" \"$RES_FILE_CANON\" \"$RES_BASE_NOEXT.glade.cpp\" \"$RES_BASE_NOEXT\"_ui
"
else # txt, etc...
SRC_FILE="$RES_BASE.cpp"
RES_LIBADD="$RES_LIBADD $RES_BASE.$ac_objext" # file.txt.o
@@ -373,39 +468,36 @@ _AM_SUBST_NOTMAKE([RES_TARGETS])
# -------------------------------------------------------------------------------------
# Export some configure variables as defines for the source code.
# Note: Autoconf manual says that AC_DEFINE won't work here.
# Export some configure variables as defines for the source code
ADDITIONAL_FLAGS="-DPACKAGE_PKGDATA_DIR=\"\\\"\$(pkgdatadir)\\\"\" \
-DPACKAGE_SYSCONF_DIR=\"\\\"\$(sysconfdir)\\\"\" \
-DTOP_SRC_DIR=\"\\\"\$(top_srcdir)\\\"\" \
-DHZ_USE_GLOBAL_MACROS=1"
-DTOP_SRC_DIR=\"\\\"\$(top_srcdir)\\\"\""
#CFLAGS="$CFLAGS $ADDITIONAL_FLAGS"
CXXFLAGS="$CXXFLAGS $ADDITIONAL_FLAGS"
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
# Top src dir should always be in include path, before other includes.
# Add global configuration file. Note: It must be searched in top_builddir
# first (that's why -I is the first flag), for precompiled headers to work.
ADDITIONAL_INCLUDES="-I\$(top_builddir) -I\$(top_srcdir)/src"
# Add pcrecpp too, because its files use #<file> on each other.
ADDITIONAL_INCLUDES="-I\$(top_builddir) -I\$(top_srcdir)/src -I\$(top_srcdir)/src/pcrecpp"
# -include works with gcc, intel, pathscale and sunstudio since 12u1, but doesn't work
# with pgi and older sunstudio (the one in solaris10, for example).
# Note: some gcc-frontend-based compilers may have to be added here
# (e.g. gccfss (gcc frontend / sun backend), etc...).
# We use -include only when using pch.
# if test "x$app_cv_compiler_gcc_pch" = "xyes"; then
# if test "$ax_cv_cxx_compiler_vendor" = "gnu" || test "$ax_cv_cxx_compiler_vendor" = "clang" \
# || test "$ax_cv_cxx_compiler_vendor" = "intel" || test "$ax_cv_cxx_compiler_vendor" = "pathscale"; then
# # This auto-includes this file when compiling any file. Benefits include pch support.
# ADDITIONAL_INCLUDES="$ADDITIONAL_INCLUDES -include global_macros.h"
# fi
# fi
# -include doesn't work with sun and pgi, but works with intel and gcc.
# we don't whitelist intel/gcc, because there are some gcc-frontend-based
# compilers we don't want to break (pathscale, gccfss (gcc frontend / sun backend), etc...).
if test "$ax_cv_cxx_compiler_vendor" != "sun" && test "$ax_cv_cxx_compiler_vendor" != "portland"; then
ADDITIONAL_INCLUDES="$ADDITIONAL_INCLUDES -include global_macros.h"
fi
# our flags must be before all the others
#CFLAGS="$ADDITIONAL_INCLUDES $CFLAGS"
# our flags must be before all the others
CXXFLAGS="$ADDITIONAL_INCLUDES $CXXFLAGS"
@@ -414,12 +506,23 @@ CXXFLAGS="$ADDITIONAL_INCLUDES $CXXFLAGS"
# -------------------------------------------------------------------------------------
# final setup
# Append compiler flags to CXXFLAGS, so that they override
# whatever the user has set.
CXXFLAGS="$CXXFLAGS $COMPILER_CXXFLAGS"
LIBS="$LIBS $COMPILER_LDFLAGS"
# This macro should be defined by ./configure automatically.
# However, sometimes it's not (e.g. win32, why?), so we define it manually.
CXXFLAGS="$CXXFLAGS -DHAVE_CONFIG_H"
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
# final setup
#CFLAGS="$CFLAGS $USER_INCLUDES"
#CXXFLAGS="$CXXFLAGS $USER_INCLUDES"
#LIBS="$LIBS $USER_LDFLAGS"
@@ -432,8 +535,6 @@ AC_SUBST(LIBS)
AC_SUBST(LDFLAGS)
# -------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------
@@ -450,15 +551,11 @@ AC_SUBST(LDFLAGS)
# print them out for debug purposes
# print'em out for debug purposes
AC_MSG_NOTICE([
CXX:
$CXX
CXXFLAGS:
$CXXFLAGS
LDFLAGS:
$LDFLAGS
LIBS:
$LIBS
])
@@ -469,30 +566,19 @@ $LIBS
AC_SUBST(AUTODIRS)
# -------------------------------------------------------------------------------------
# ----------------------------------------------------
# -------------------------------------------------------------------------------------
AC_CONFIG_FILES([ data/gsmartcontrol.desktop data/gsmartcontrol.appdata.xml \
data/nsis/distribution.txt data/nsis/gsmartcontrol.nsi \
debian.dist/changelog \
src/gsc_winres.rc src/gsmartcontrol.exe.manifest \
AC_CONFIG_FILES([ data/gsmartcontrol_gnome.desktop data/gsmartcontrol_kde.desktop \
data/gsmartcontrol_other.desktop \
gsmartcontrol.spec version compilation_flags ])
AC_CONFIG_FILES([data/gsmartcontrol-root], [chmod +x data/gsmartcontrol-root])
# these are all the makefiles to generate
AC_CONFIG_FILES([Makefile src/Makefile src/applib/Makefile src/res/Makefile src/hz/Makefile \
src/libdebug/Makefile src/rconfig/Makefile src/rmn/Makefile \
src/libdebug/Makefile src/pcrecpp/Makefile src/rconfig/Makefile src/rmn/Makefile \
data/Makefile data/16/Makefile data/22/Makefile data/24/Makefile data/32/Makefile \
data/48/Makefile data/64/Makefile data/128/Makefile data/256/Makefile data/nsis/Makefile \
debian.dist/Makefile])
data/48/Makefile data/64/Makefile data/128/Makefile])
AC_OUTPUT
-17
View File
@@ -1,17 +0,0 @@
This directory contains scripts and an example crontab to allow GSmartControl
to read smartctl data from cron-generated files. This allows users to read
somewhat recent smartctl information without having to run GSmartControl as
root.
Put the scripts into /usr/local/bin, run GSmartControl and set smartctl path
to "/usr/local/bin/smartctl_subst.sh" (without quotes). An example crontab
runs cron_gather_smart.sh script every 10 minutes, storing its output to
"/var/run/smart-$devname". The smartctl_subst.sh script prints the contents of
this file instead of running smartctl, thus eliminating the need to run
GSmartControl as root when reading SMART values.
Note: These scripts provide read-only capabilities only, they don't allow
changing SMART settings or running self-tests.
Contributed by Alex Butcher <alex dot butcher 'at' assursys.co.uk>.
@@ -1,22 +0,0 @@
#!/bin/bash
############################################################################
# Copyright:
# (C) 2008 - 2010 Alex Butcher <alex dot butcher 'at' assursys.co.uk>
# (C) 2008 - 2010 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_unlicense.txt file
############################################################################
device="$1";
if [ "$device" = "" ]; then
echo "Usage: $0 <device>"
exit 1;
fi
dev_base="`basename \"$device\"`"
out_file=/var/run/smart-"$dev_base"
# Change the path to smartctl if necessary.
smartctl -a "$device" 2>&1 > "$out_file"
chmod 644 "$out_file"
@@ -1,2 +0,0 @@
*/10 * * * * root /usr/local/bin/cron-smart.sh /dev/sda
*/10 * * * * root /usr/local/bin/cron-smart.sh /dev/sdb
@@ -1,27 +0,0 @@
#!/bin/bash
############################################################################
# Copyright:
# (C) 2008 - 2010 Alex Butcher <alex dot butcher 'at' assursys.co.uk>
# (C) 2008 - 2010 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_unlicense.txt file
############################################################################
if [ "$1" = "-V" ]; then
smartctl -V 2>&1
exit
fi
while [ $# -ge 1 ]; do
device="$1"
shift
done
if [ "$device" = "" ]; then
echo "Usage: $0 <device>"
exit 1;
fi
dev_base="`basename \"$device\"`"
out_file=/var/run/smart-"$dev_base"
cat "$out_file"
-4
View File
@@ -1,4 +0,0 @@
appicondir = $(datadir)/icons/hicolor/256x256/apps
appicon_DATA = gsmartcontrol.png
EXTRA_DIST = $(appicon_DATA)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

+10 -39
View File
@@ -1,23 +1,9 @@
SUBDIRS = 16 22 24 32 48 64 128
SUBDIRS = 16 22 24 32 48 64 128 256 nsis
dist_man_MANS = gsmartcontrol.1
install-extra-mans:
cd $(DESTDIR)$(mandir)/man1 && $(LN_S) -f gsmartcontrol.1 gsmartcontrol-root.1
uninstall-extra-mans:
cd $(DESTDIR)$(mandir)/man1 && rm -f gsmartcontrol-root.1
# This command is needed if installing with make install (the cache
# file is ignored for rpms).
gtk_update_icon_cache = gtk-update-icon-cache-3.0 -f -t $(datadir)/icons/hicolor
install-data-hook: install-extra-mans update-icon-cache
uninstall-hook: uninstall-extra-mans update-icon-cache
gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
install-data-hook: update-icon-cache
uninstall-hook: update-icon-cache
update-icon-cache:
@-if test -z "$(DESTDIR)"; then \
echo "Updating GTK icon cache."; \
@@ -28,7 +14,7 @@ update-icon-cache:
fi
# Application data, installs to /usr/share/appname
# installs to /usr/share/appname
appdatadir = $(pkgdatadir)
appdata_DATA = icon_cddvd.png icon_hdd.png
@@ -36,30 +22,15 @@ appdata_DATA = icon_cddvd.png icon_hdd.png
# pkgdatadir = $(datadir)/gsmartcontrol
# pkgdata_DATA =
# Desktop files
desktopdir = $(datadir)/applications
desktop_DATA = gsmartcontrol.desktop
# Appdata files
metainfodir = $(datadir)/metainfo
metainfo_DATA = gsmartcontrol.appdata.xml
# PolKit files
polkitdir = $(datadir)/polkit-1/actions
polkit_DATA = org.gsmartcontrol.policy
desktop_DATA = gsmartcontrol_gnome.desktop gsmartcontrol_kde.desktop \
gsmartcontrol_other.desktop
# Application pixmap (fallback icon for desktop files).
# Same as 48/gsmartcontrol.png.
# Also, xpm for debian menu, 32x32.
# Same as 48/gsmartcontrol.png
pixmapsdir = $(datadir)/pixmaps
pixmaps_DATA = 48/gsmartcontrol.png gsmartcontrol.xpm
pixmaps_DATA = 48/gsmartcontrol.png
# Put everything inside the distribution
EXTRA_DIST = $(appdata_DATA) $(polkit_DATA) gsmartcontrol.ico gsmartcontrol.xpm
bin_SCRIPTS = gsmartcontrol-root
CLEANFILES = $(bin_SCRIPTS)
EXTRA_DIST = $(appdata_DATA) $(pixmaps_DATA)
-171
View File
@@ -1,171 +0,0 @@
#!/usr/bin/env bash
############################################################################
# Copyright:
# (C) 2008 - 2014 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################
# Run gsmartcontrol with root, asking for root password first.
# export GSMARTCONTROL_SU to override a su command (e.g. "kdesu -c").
EXEC_BIN="@prefix@/sbin/gsmartcontrol";
prog_name="gsmartcontrol"
# Preserve quotes in arguments
final_args_quoted="";
for i in "$@";do
final_args_quoted="$final_args_quoted \"${i//\"/\\\"}\"";
done;
DESKTOP="auto";
# Compatibility with old syntax:
# gsmartcontrol-root [<desktop> [program_options]]
if [ "$1" == "auto" ] || [ "$1" == "kde" ] || [ "$1" == "gnome" ] || [ "$1" == "other" ]; then
DESKTOP="$1";
shift; # remove $1
else
# New syntax:
# gsmartcontrol-root [--desktop=<auto|kde|gnome|other>] [program_options]
for arg in $*; do
case $arg in
--desktop=*)
DESKTOP="${arg#*=}";
final_args_quoted="${final_args_quoted/\"$arg\"/}";
;;
*)
# unknown option
;;
esac
done
fi
if [ "$DESKTOP" != "auto" ] && [ "$DESKTOP" != "kde" ] && \
[ "$DESKTOP" != "gnome" ] && [ "$DESKTOP" != "other" ]; then
echo "Usage: $0 [--desktop=<auto|kde|gnome|other>] [<${prog_name}_options>]";
exit 1;
fi
# Auto-detect current desktop if auto was specified.
if [ "$DESKTOP" = "auto" ]; then
# KDE_SESSION_UID is present on kde3 and kde4.
# Note that it may be empty (but still set)
if [ "${KDE_SESSION_UID+set}" = "set" ]; then
DESKTOP="kde";
# same with gnome
elif [ "${GNOME_DESKTOP_SESSION_ID+set}" = "set" ]; then
DESKTOP="gnome";
else
DESKTOP="other";
fi
fi
# echo $DESKTOP;
# They're basically the same, only the order is different.
# pkexec is for PolKit.
# sux requires xterm to ask for the password.
# xdg-su is basically like this script, except worse :)
# su-to-root is a debian/ubuntu official method (although gksu is available).
gnome_sus="pkexec su-to-root gnomesu gksu kdesu beesu xdg-su sux";
kde_sus="pkexec su-to-root kdesu gnomesu gksu beesu xdg-su sux";
other_sus="$gnome_sus";
candidates="";
found_su=""
if [ "$DESKTOP" = "gnome" ]; then
candidates="$gnome_sus";
elif [ "$DESKTOP" = "kde" ]; then
candidates="$kde_sus";
elif [ "$DESKTOP" = "other" ]; then
candidates="$other_sus";
fi
if [ "$GSMARTCONTROL_SU" = "" ]; then
for subin in $candidates; do
which $subin &>/dev/null
if [ $? -eq 0 ]; then
found_su="$subin";
break;
fi
done
if [ "$found_su" = "" ]; then
xmessage "Error launching ${prog_name}: No suitable su mechanism found.
Try installing PolKit, kdesu, gnomesu, gksu, beesu or sux first.";
exit 1;
fi
fi
# gnomesu and gksu (but not kdesu, not sure about others) fail to adopt
# root's PATH. Since the user's PATH may not contain /usr/sbin (with smartctl)
# on some distributions (e.g. mandriva), add it manually. We also add
# /usr/local/sbin, since that's the default location of custom-compiled smartctl.
# Add these directories _before_ existing PATH, so that the user is not
# tricked into running it from some other path (we're running as root with
# the user's env after all).
# Add @prefix@/sbin as well (freebsd seems to require it).
# Note that beesu won't show a GUI login box if /usr/sbin is before /usr/bin,
# so add it first as well.
EXTRA_PATHS="/usr/bin:/usr/sbin:/usr/local/sbin:@prefix@/sbin";
export PATH="$EXTRA_PATHS:$PATH"
# echo $found_su;
# Examples:
# gnomesu -c 'gsmartcontrol --no-scan'
# kdesu -c 'gsmartcontrol --no-scan'
# beesu -P 'gsmartcontrol --no-scan'
# su-to-root -X -c 'gsmartcontrol --no-scan'
# xterm -e sux -c 'gsmartcontrol --no-scan' # sux asks for password in a terminal
full_cmd="";
if [ "$GSMARTCONTROL_SU" != "" ]; then
full_cmd="$GSMARTCONTROL_SU '$EXEC_BIN $final_args_quoted'";
elif [ "$found_su" = "pkexec" ]; then
if [ "$GDK_SCALE" != "" ]; then
final_args_quoted="$final_args_quoted --gdk-scale='$GDK_SCALE'"
fi
if [ "$GDK_DPI_SCALE" != "" ]; then
final_args_quoted="$final_args_quoted --gdk-dpi-scale='$GDK_DPI_SCALE'"
fi
full_cmd="pkexec --disable-internal-agent $EXEC_BIN $final_args_quoted";
elif [ "$found_su" = "sux" ]; then
full_cmd="xterm -e sux -c '$EXEC_BIN $final_args_quoted'";
elif [ "$found_su" = "gksu" ]; then
full_cmd="$found_su '$EXEC_BIN $final_args_quoted'";
elif [ "$found_su" = "beesu" ]; then
full_cmd="$found_su -P '$EXEC_BIN $final_args_quoted'";
elif [ "$found_su" = "su-to-root" ]; then
full_cmd="$found_su -X -c '$EXEC_BIN $final_args_quoted'";
else # gnomesu, kdesu, xdg-su
full_cmd="$found_su -c '$EXEC_BIN $final_args_quoted'";
fi
# echo $full_cmd
eval $full_cmd
-81
View File
@@ -1,81 +0,0 @@
.TH GSmartControl "1" "" "gsmartcontrol " "User Commands"
.SH NAME
GSmartControl \- Hard disk drive and SSD health inspection tool
.SH SYNOPSIS
\fBgsmartcontrol\fP [OPTIONS]
\fBgsmartcontrol\-root\fP [--desktop=\fI<desktop>\fP] [OPTIONS]
.SH DESCRIPTION
\fBGSmartControl\fP is a graphical user interface for smartctl (from
smartmontools), which is a tool for querying and controlling SMART
(Self-Monitoring, Analysis, and Reporting Technology) data on modern hard disk
and solid-state drives. It allows you to inspect the drive's SMART data to
determine its health, as well as run various tests on it.
.PP
This manual page documents briefly the \fBgsmartcontrol\fP and
\fBgsmartcontrol\-root\fP commands.
.PP
\fBgsmartcontrol\-root\fP command launches \fBgsmartcontrol\fP with
administrative privileges. The \fIdesktop\fP argument specifies which desktop
is currently running, for automatic selection of native su mechanism. Valid
values for \fIdesktop\fP are \fBauto\fP, \fBkde\fP, \fBgnome\fP, \fBother\fP.
.SH OPTIONS
.SS "Help Options:"
.TP
\fB\-?\fP, \fB\-\-help\fP
Show help options
.TP
\fB\-\-help\-all\fP
Show all help options
.TP
\fB\-\-help\-gtk\fP
Show GTK+ options
.TP
\fB\-\-help\-debug\fR
Show logging options
.SS "Application Options:"
.TP
\fB\-l\fP, \fB\-\-no\-locale\fP
Don't use system locale
.TP
\fB\-V\fP, \fB\-\-version\fP
Display version information
.TP
\fB\-\-no\-scan\fP
Don't scan devices on startup
.TP
\fB\-\-no\-hide\-tabs\fP
Don't hide non\-identity tabs when SMART is disabled. Useful for debugging.
.TP
\fB\-\-add\-virtual\fP
Load smartctl data from file, creating a virtual drive. You
can specify this option multiple times.
.TP
\fB\-\-add\-device\fP
Add this device to device list. The format of the device is
\fI<device>::<type>::<extra_args>\fP, where type and extra_args are optional.
This option is useful with \fB\-\-no\-scan\fP to list certain drives only. You
can specify this option multiple times. Example:\fR
.nf
\-\-add\-device /dev/sda \-\-add\-device /dev/twa0::3ware,2 \-\-add\-device '/dev/sdb::::-T permissive'
.fi
.TP
\fB\-\-display\fP=\fIDISPLAY\fP
X display to use
.TP
\fB\-v\fP, \fB\-\-verbose\fP
Enable verbose logging; same as \fB\-\-verbosity\-level\fP 5
.TP
\fB\-q\fP, \fB\-\-quiet\fP
Disable logging; same as \fB\-\-verbosity\-level\fP 0
.TP
\fB\-b\fP, \fB\-\-verbosity\-level\fP
Set verbosity level [0\-5]
.PP
.SH COPYRIGHT
Copyright \(co 2008 \- 2012 Alexander Shaduri <ashaduri \'at\' gmail.com>
.PP
.SH AUTHOR
This manual page was originally written by Giuseppe Iuculano
<giuseppe@iuculano.it> for the Debian project.
-34
View File
@@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2017 GSmartControl developers -->
<component type="desktop">
<id>gsmartcontrol</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0 and GPL-3.0</project_license>
<name>GSmartControl</name>
<summary>Hard Disk and SSD Health Inspection</summary>
<description>
<p>
GSmartControl is a graphical user interface for smartctl, which is a tool for
querying and controlling SMART (Self-Monitoring, Analysis, and Reporting
Technology) data in hard disk and solid-state drives. It allows you to inspect
the drive's SMART data to determine its health, as well as run various tests
on it.
</p>
</description>
<launchable type="desktop-id">gsmartcontrol.desktop</launchable>
<url type="homepage">https://gsmartcontrol.sourceforge.io</url>
<screenshots>
<screenshot type="default">
<caption>Main window</caption>
<image>https://gsmartcontrol.sourceforge.io/home/images/main_ok.png</image>
</screenshot>
<screenshot>
<caption>Drive identity information</caption>
<image>https://gsmartcontrol.sourceforge.io/home/images/info_identity.png</image>
</screenshot>
<screenshot>
<caption>Attribute list of a failing drive</caption>
<image>https://gsmartcontrol.sourceforge.io/home/images/info_failing.png</image>
</screenshot>
</screenshots>
</component>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

-394
View File
@@ -1,394 +0,0 @@
/* XPM */
static char * gsmartcontrol_xpm[] = {
"32 32 359 2",
" c None",
". c #ABAAAA",
"+ c #CCCCCC",
"@ c #C5C4C4",
"# c #C2C1C1",
"$ c #D2D1D1",
"% c #C8C7C7",
"& c #C8C7C8",
"* c #C9C8C8",
"= c #CAC8C9",
"- c #CAC9C9",
"; c #C8C6C7",
"> c #C7C6C6",
", c #CFCDCE",
"' c #D1D0D0",
") c #C6C5C6",
"! c #CFCECE",
"~ c #B9B7B7",
"{ c #D4D4D4",
"] c #DCDBDC",
"^ c #D8D7D7",
"/ c #D6D5D5",
"( c #D6D5D6",
"_ c #D7D6D6",
": c #D9D8D8",
"< c #DBDADB",
"[ c #DAD9DA",
"} c #D7D7D7",
"| c #D6D6D6",
"1 c #DAD9D9",
"2 c #E2E1E1",
"3 c #B0AFAF",
"4 c #D3D2D2",
"5 c #CDCCCC",
"6 c #CDCDCD",
"7 c #CECDCD",
"8 c #CECECE",
"9 c #CFCFCF",
"0 c #D0CFCF",
"a c #C0BFBF",
"b c #9C9A9B",
"c c #6E6B6B",
"d c #807E7F",
"e c #C8C8C8",
"f c #CAC9CA",
"g c #CACACA",
"h c #CBCACA",
"i c #CCCBCB",
"j c #CCCBCC",
"k c #D0CECF",
"l c #C3C2C2",
"m c #A09E9F",
"n c #B5B4B4",
"o c #AFADAE",
"p c #787576",
"q c #8D8B8B",
"r c #D4D3D3",
"s c #C7C6C7",
"t c #C7C7C7",
"u c #C9C8C9",
"v c #C9C9C9",
"w c #CACAC9",
"x c #BFBEBE",
"y c #A3A1A2",
"z c #A09D9E",
"A c #B4B2B2",
"B c #B6B4B4",
"C c #827F80",
"D c #969595",
"E c #C4C3C3",
"F c #C4C4C4",
"G c #C5C5C5",
"H c #C6C5C5",
"I c #C6C6C6",
"J c #C9C7C8",
"K c #B9B7B8",
"L c #A5A4A4",
"M c #A4A3A3",
"N c #A7A5A5",
"O c #B3B1B2",
"P c #BFBDBD",
"Q c #8D8A8B",
"R c #A09F9F",
"S c #DDDCDC",
"T c #C0C0C0",
"U c #C3C1C2",
"V c #C3C2C3",
"W c #C3C3C3",
"X c #C4C3C4",
"Y c #B2B1B1",
"Z c #A8A7A7",
"` c #ABA9A9",
" . c #CFCECF",
".. c #C2C0C1",
"+. c #989697",
"@. c #A8A6A7",
"#. c #DEDDDD",
"$. c #DEDDDE",
"%. c #C1C0C0",
"&. c #C2C1C2",
"*. c #B1B0B0",
"=. c #ADACAC",
"-. c #AFAEAE",
";. c #BDBCBC",
">. c #B3B2B2",
",. c #B4B3B4",
"'. c #B8B8B8",
"). c #D5D4D4",
"!. c #C0BFBE",
"~. c #C1C0C1",
"{. c #C3C1C1",
"]. c #C4C4C3",
"^. c #B2B0B1",
"/. c #B3B2B3",
"(. c #B4B3B3",
"_. c #A1A0A0",
":. c #B9B8B8",
"<. c #C4C2C3",
"[. c #BDBBBC",
"}. c #B5B4B3",
"|. c #B6B4B5",
"1. c #B7B5B6",
"2. c #B7B6B7",
"3. c #B8B7B7",
"4. c #B8B7B8",
"5. c #BCBABB",
"6. c #BBBABA",
"7. c #BFBEBF",
"8. c #C1C1C1",
"9. c #C1BFC0",
"0. c #BCBBBB",
"a. c #BEBCBD",
"b. c #BEBDBD",
"c. c #9B999A",
"d. c #9D9B9B",
"e. c #C2C2C2",
"f. c #D4D3D4",
"g. c #CECDCE",
"h. c #C7C5C5",
"i. c #A4A2A3",
"j. c #A19F9F",
"k. c #C6C4C5",
"l. c #DCDCDC",
"m. c #D0CFD0",
"n. c #CECCCD",
"o. c #A2A1A1",
"p. c #939292",
"q. c #E1E0E0",
"r. c #E3E3E3",
"s. c #B3B3B3",
"t. c #CCCACB",
"u. c #D2D2D2",
"v. c #D5D3D4",
"w. c #A7A6A6",
"x. c #959494",
"y. c #E3E2E2",
"z. c #DCDBDB",
"A. c #CBC9CA",
"B. c #E1E0E1",
"C. c #DFDEDE",
"D. c #CECCCC",
"E. c #CDCCCD",
"F. c #D2D0D0",
"G. c #D2D0D1",
"H. c #B5B4B5",
"I. c #B1AFB0",
"J. c #EDECEC",
"K. c #D1CFCF",
"L. c #CDCBCC",
"M. c #D5D5D5",
"N. c #DCDADA",
"O. c #C5C4C5",
"P. c #D2D1D2",
"Q. c #D5D4D5",
"R. c #DADADA",
"S. c #DBDADA",
"T. c #DDDCDD",
"U. c #D7D6D7",
"V. c #E8E7E7",
"W. c #D8D8D8",
"X. c #D8D6D6",
"Y. c #D9D8D9",
"Z. c #DBDBDB",
"`. c #DDDDDD",
" + c #474747",
".+ c #ECEBEB",
"++ c #F3F3F3",
"@+ c #E4E3E3",
"#+ c #E0DFDF",
"$+ c #E5E5E5",
"%+ c #EFEFEF",
"&+ c #EBEAEB",
"*+ c #E6E5E5",
"=+ c #E0E0E0",
"-+ c #E4E4E4",
";+ c #E5E4E4",
">+ c #ECECEC",
",+ c #666666",
"'+ c #585757",
")+ c #D9D9DA",
"!+ c #E2E2E2",
"~+ c #E6E5E6",
"{+ c #E1E1E1",
"]+ c #E6E6E6",
"^+ c #E7E7E7",
"/+ c #898989",
"(+ c #767575",
"_+ c #E0DFE0",
":+ c #E9E9E9",
"<+ c #BDBDBD",
"[+ c #B6B6B6",
"}+ c #B0B0B0",
"|+ c #ACACAC",
"1+ c #ACABAC",
"2+ c #A7A7A7",
"3+ c #DFDFDF",
"4+ c #E5E5E4",
"5+ c #E9E8E8",
"6+ c #E8E8E8",
"7+ c #E3E2E3",
"8+ c #D7D5D5",
"9+ c #8E8D8D",
"0+ c #807F7F",
"a+ c #494848",
"b+ c #5A5758",
"c+ c #605E5F",
"d+ c #646262",
"e+ c #555354",
"f+ c #1F1F1F",
"g+ c #282626",
"h+ c #323031",
"i+ c #3D3C3C",
"j+ c #494748",
"k+ c #555353",
"l+ c #5A5959",
"m+ c #3E3D3D",
"n+ c #434242",
"o+ c #444343",
"p+ c #414041",
"q+ c #3E3E3E",
"r+ c #4A4949",
"s+ c #706D6E",
"t+ c #6B6969",
"u+ c #6A6869",
"v+ c #696469",
"w+ c #656065",
"x+ c #595757",
"y+ c #A5A5A5",
"z+ c #767676",
"A+ c #8A8888",
"B+ c #4B4849",
"C+ c #5C5A5A",
"D+ c #686565",
"E+ c #524F50",
"F+ c #000000",
"G+ c #090607",
"H+ c #171415",
"I+ c #262324",
"J+ c #363334",
"K+ c #454343",
"L+ c #4A4748",
"M+ c #212020",
"N+ c #2A292A",
"O+ c #2C2B2B",
"P+ c #272626",
"Q+ c #242424",
"R+ c #242323",
"S+ c #3C3B3B",
"T+ c #726F70",
"U+ c #6C696A",
"V+ c #6B676A",
"W+ c #7A916C",
"X+ c #7B926B",
"Y+ c #605F60",
"Z+ c #9C9B9C",
"`+ c #606060",
" @ c #8F8D8D",
".@ c #494747",
"+@ c #595657",
"@@ c #615E5F",
"#@ c #656162",
"$@ c #525050",
"%@ c #020101",
"&@ c #0C0A0A",
"*@ c #1A1818",
"=@ c #282525",
"-@ c #454243",
";@ c #494647",
">@ c #2A2929",
",@ c #393838",
"'@ c #363536",
")@ c #323131",
"!@ c #2B292A",
"~@ c #282727",
"{@ c #444243",
"]@ c #696666",
"^@ c #666268",
"/@ c #709D48",
"(@ c #7BAD4A",
"_@ c #68686A",
":@ c #8F8E8F",
"<@ c #4E4D4E",
"[@ c #8E8C8D",
"}@ c #484546",
"|@ c #555253",
"1@ c #5D595A",
"2@ c #5F5B5C",
"3@ c #514F50",
"4@ c #0F0D0D",
"5@ c #211E1F",
"6@ c #312E2F",
"7@ c #413D3E",
"8@ c #222121",
"9@ c #2E2D2D",
"0@ c #312F30",
"a@ c #262425",
"b@ c #464344",
"c@ c #696667",
"d@ c #666263",
"e@ c #5F5E5F",
"f@ c #5A5B5B",
"g@ c #797577",
"h@ c #7A7A7A",
"i@ c #4C4A4A",
"j@ c #2A2728",
"k@ c #2C292A",
"l@ c #302D2E",
"m@ c #312F2F",
"n@ c #2E2C2C",
"o@ c #100F0F",
"p@ c #110F10",
"q@ c #141212",
"r@ c #1B1919",
"s@ c #242222",
"t@ c #2D2B2B",
"u@ c #322F30",
"v@ c #2F2D2D",
"w@ c #2B2829",
"x@ c #292728",
"y@ c #363233",
"z@ c #332F30",
"A@ c #312D2F",
"B@ c #2A2627",
"C@ c #424040",
"D@ c #454444",
"E@ c #737373",
"F@ c #828282",
"G@ c #939293",
"H@ c #9C9C9C",
"I@ c #A3A3A3",
"J@ c #A9A9A9",
"K@ c #ADADAD",
"L@ c #B2B2B2",
"M@ c #B5B5B5",
"N@ c #A4A4A4",
"O@ c #959595",
"P@ c #8C8C8C",
"Q@ c #707070",
"R@ c #FFFFFF",
" ",
" . + @ # $ % & * = - ; > * - - - * , ' ) ! ~ ",
" = { ' ] ^ { / / ( _ : < [ ^ ^ } ^ | 1 2 } 3 ",
" - 4 ' ' 5 6 6 6 7 7 8 9 ! ! 9 9 0 0 $ 5 a b c ",
" d 4 [ * e - - f g h h h i i j + 5 5 k l m n o p ",
" q _ r @ > > s s t % % * * u v - w 5 x y z A B C ",
" D 1 7 l E F @ @ G H H I > > > J * K L M N O P Q ",
" R S % T U U l V W E X F @ @ > E Y Z ` > .* ..+. ",
" @.#.$.W %.# # # &.l l V E G T *.=.-.*.5 ;.>.,.Z ",
" n '.).[ !.T ~.# ..{.U l ].x Y ^.>.A /.(.x ;.O _. ",
" :.^.<.h a %.%.# # # &.U [.}.|.1.2.3.4.K K a 5.N ",
" 6.i H 7.%.8.# &.# l * % E 9.[.5.0.[.;.a.b.;., %.c. ",
" d.> 0 a # &.e.V V % ^ f.j g - % %.....&.l V l g.h.i. ",
" j./ i # E E @ k.H l.g.%.# l E H <.b.; > % % % m.n.o. ",
" p.q.7 @ ) > % % - r.) > % * * g f s.5 t.i i i u.v.w. ",
" x.y.z.> u - g A.- B.C.D.E.! 0 7 (.6.$ ' ' F.G.).^ H. ",
" I.7 J.K.L.7 7 ! ! m.S 1 m.- %.3.8./ ).M./ | _ : N.; ",
" O., F.f.P.4 4 4 f.f.r / Q.4 4 ^ R.: : 1 [ S.< S T.U. ",
" 4 V.| ).| _ W._ X.^ : Y.1 S.Z.z.] S S `.#.C.C.2 V.q. + ",
" S..+++@+`.#+$+%+&+*+2 #+=+q.y.-+-+-+;+$+$+*+>+++Z.*+,+ ",
" '+S.# $ >+r.m.e.# 6 )+!+~+*+@+B.=+{+-+]+]+^+]+^+j 5 y./+ ",
" (+b.3 _+! m.#+:+q.r > <+[+}+|+3 '.b.8.> e 5 7 ! ^+j 1+2+ ",
" x.] ! r / ^ W.R.S 3+2 y.@+4+5+6+^+~+*+;+7+#+C.#.S.8+: V ",
" 9+0+a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+n+p+q+r+s+t+u+v+w+x+y+ ",
" z+A+B+C+d+D+E+F+G+H+I+J+K+L+M+N+O+P+Q+R+S+T+U+V+W+X+Y+Z+ ",
" `+ @.@+@@@#@$@%@&@*@=@J+-@;@>@,@'@)@!@~@{@c ]@^@/@(@_@:@ ",
" <@[@}@|@1@2@3@F+%@4@5@6@7@-@8@9@9@0@~@a@b@c@#@d@e@f@g@h@ ",
" i@j@k@l@m@n@o@p@q@r@s@t@u@!@l@v@v@w@x@l@y@z@6@A@B@C@D@ ",
" E@F@G@H@I@J@K@}+L@M@M@M@s.}+|+N@H@O@P@F@Q@ ",
" R@R@R@R@R@R@R@R@R@ ",
" ",
" "};
+26
View File
@@ -0,0 +1,26 @@
[Desktop Entry]
# Desktop file for gnome only.
OnlyShowIn=GNOME;
# desktop file version
Version=1.0
Type=Application
Categories=System;GTK;
# Categories=Settings;HardwareSettings;
Name=GSmartControl
# short description, usually shown in parentheses after Name
GenericName=Hard Disk Health Inspection
# tooltip
Comment=Monitor and control SMART data on hard disks
# If it's a name only, it looks for "name.[png|xpm]" file in
# $XDG_DATA_DIRS/icons and /usr/share/pixmaps.
# An absolute file path is also supported.
Icon=gsmartcontrol
# Run with root permissions. Some desktop files used gksu,
# but it doesn't seem available on my system.
Exec=gnomesu -c "@prefix@/bin/gsmartcontrol"
@@ -1,19 +1,20 @@
[Desktop Entry]
# Desktop file for kde only.
OnlyShowIn=KDE;
# desktop file version
Version=1.0
Type=Application
Categories=System;Monitor;
Categories=System;GTK;
# Categories=Settings;HardwareSettings;
Name=GSmartControl
# short description, usually shown in parentheses after Name
GenericName=Hard Disk and SSD Health Inspection
GenericName[fr]=Inspecteur de santé de disque dur et de SSD
GenericName=Hard Disk Health Inspection
# tooltip
Comment=Monitor and control SMART data on hard disk and solid-state drives
Comment[fr]=Surveille et contrôle les données SMART des disques durs et des SSD
Comment=Monitor and control SMART data on hard disks
# If it's a name only, it looks for "name.[png|xpm]" file in
# $XDG_DATA_DIRS/icons and /usr/share/pixmaps.
@@ -25,5 +26,4 @@ Icon=gsmartcontrol
#X-KDE-SubstituteUID=true
#X-KDE-RootOnly=true
# Run with root permissions.
Exec="@prefix@/bin/gsmartcontrol-root"
Exec=kdesu "@prefix@/bin/gsmartcontrol"
+28
View File
@@ -0,0 +1,28 @@
[Desktop Entry]
# Desktop file for non-gnome and non-kde only.
NotShowIn=GNOME;KDE;
# desktop file version
Version=1.0
Type=Application
Categories=System;GTK;
# Categories=Settings;HardwareSettings;
Name=GSmartControl
# short description, usually shown in parentheses after Name
GenericName=Hard Disk Health Inspection
# tooltip
Comment=Monitor and control SMART data on hard disks
# If it's a name only, it looks for "name.[png|xpm]" file in
# $XDG_DATA_DIRS/icons and /usr/share/pixmaps.
# An absolute file path is also supported.
Icon=gsmartcontrol
# Run with root permissions using gnomesu (from libgnomesu).
# There is also kdesu (kdebase3-runtime, kdebase4-runtime), in different paths.
# There is also xdg-su, which doesn't work at all on my machine.
Exec=gnomesu -c "@prefix@/bin/gsmartcontrol"
# Exec=kdesu -u root "@prefix@/bin/gsmartcontrol"
Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

-2
View File
@@ -1,2 +0,0 @@
EXTRA_DIST = distribution.txt.in gsmartcontrol.nsi.in nsi_install.ico nsi_uninstall.ico
-24
View File
@@ -1,24 +0,0 @@
GSmartControl - Hard disk drive and SSD health inspection tool
Version @VERSION@
The latest version of this distribution, as well as the source code of
GSmartControl, can be found at
https://gsmartcontrol.sourceforge.io
and
https://sourceforge.net/projects/gsmartcontrol/files/
This distribution includes:
* GSmartControl binary (gsmartcontrol.exe) and associated resources.
The binary was compiled against Gtkmm (http://www.gtkmm.org/), GTK+
(http://gtk.org/) and related libraries, and PCRE (http://www.pcre.org/).
* Smartctl binaries (from smartmontools 6.6, http://smartmontools.sf.net/)
- smartctl-nc.exe (compiled without console output), smartctl.exe (compiled
with console output), update-smart-drivedb.exe (drive database updater).
The combined distribution is multi-licensed under GNU GPL versions 2 and 3.
See LICENSE_gpl2.txt and LICENSE_gpl3.txt for details.
-319
View File
@@ -1,319 +0,0 @@
; NSIS2 Script
; by Alexander Shaduri <ashaduri 'at' gmail.com>.
; Compatible with NSIS Unicode 2.45.
; Public Domain
!define PRODUCT_VERSION "@VERSION@"
!define PRODUCT_NAME "GSmartControl"
!define PRODUCT_NAME_SMALL "gsmartcontrol"
!define PRODUCT_PUBLISHER "Alexander Shaduri"
!define PRODUCT_WEB_SITE "https://gsmartcontrol.sourceforge.io"
;!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\AppMainExe.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!include "FileFunc.nsh" ; GetOptions
; --------------- General Settings
; This is needed for proper start menu item manipulation (for all users) in vista
RequestExecutionLevel admin
; This compressor gives us the best results
SetCompressor /SOLID lzma
; Do a CRC check before installing
CRCCheck On
; This is used in titles
Name "${PRODUCT_NAME}" ; ${PRODUCT_VERSION}
; Output File Name
OutFile "${PRODUCT_NAME_SMALL}-${PRODUCT_VERSION}-@WINDOWS_SUFFIX@.exe"
; The Default Installation Directory:
; Try to install to the same directory as runtime.
InstallDir "$PROGRAMFILES64\${PRODUCT_NAME}"
; If already installed, try here
InstallDirRegKey HKLM "SOFTWARE\${PRODUCT_NAME}" "InstallationDirectory"
ShowInstDetails show
ShowUnInstDetails show
; --------------------- MUI INTERFACE
; MUI 2.0 compatible install
!include "MUI2.nsh"
!include "InstallOptions.nsh" ; section description macros
; Backgound Colors. uncomment to enable fullscreen.
; BGGradient 0000FF 000000 FFFFFF
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "nsi_install.ico"
!define MUI_UNICON "nsi_uninstall.ico"
; Things that need to be extracted on first (keep these lines before any File command!).
; Only useful for BZIP2 compression.
;!insertmacro MUI_RESERVEFILE_LANGDLL
;!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; Language Selection Dialog Settings
;!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
;!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
;!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
!define LICENSE_FILE "doc\distribution.txt"
; Pages to show during installation
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "${LICENSE_FILE}"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
;!define MUI_FINISHPAGE_RUN "$INSTDIR\gsmartcontrol.exe"
;!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\Example.file"
;!define MUI_FINISHPAGE_RUN_NOTCHECKED
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!insertmacro MUI_PAGE_FINISH
; Uninstaller page
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "English"
; --------------- END MUI
LangString TEXT_IO_TITLE ${LANG_ENGLISH} "GSmartControl"
var install_option_removeold ; uninstall the old version first (if present): yes (default), no.
; ----------------- INSTALLATION TYPES
; InstType "Recommended"
; InstType "Full"
; InstType "Minimal"
Section "!GSmartControl" SecMain
SectionIn 1 RO
SetShellVarContext all ; use all user variables as opposed to current user
SetOutPath "$INSTDIR"
SetOverwrite Off ; don't overwrite the config file
; File "gsmartcontrol.conf"
SetOverwrite On
File *.exe
File *.dll
File gsmartcontrol.exe.manifest
File gsmartcontrol.ico
File icon_*.png
File drivedb.h
; Include the "doc" directory completely.
File /r doc
; GTK and stuff
File /r etc
File /r share
; Add Shortcuts (this inherits the exe's run permissions)
CreateShortCut "$SMPROGRAMS\GSmartControl.lnk" "$INSTDIR\gsmartcontrol.exe" "" \
"$INSTDIR\gsmartcontrol.ico" "" SW_SHOWNORMAL "" "GSmartControl - Hard disk drive and SSD health inspection tool"
SectionEnd
; Executed on installation start
Function .onInit
SetShellVarContext all ; use all user variables as opposed to current user
${GetOptions} "$CMDLINE" "/removeold=" $install_option_removeold
Call PreventMultipleInstances
Call DetectPrevInstallation
FunctionEnd
; ------------------ POST INSTALL
Section -post
SetShellVarContext all ; use all user variables as opposed to current user
WriteRegStr HKLM "SOFTWARE\${PRODUCT_NAME}" "InstallationDirectory" "$INSTDIR"
WriteRegStr HKLM "SOFTWARE\${PRODUCT_NAME}" "Vendor" "${PRODUCT_PUBLISHER}"
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayName" "${PRODUCT_NAME}"
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\gsmartcontrol_uninst.exe"
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\gsmartcontrol.ico"
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegDWORD HKLM "${PRODUCT_UNINST_KEY}" "NoModify" 1
WriteRegDWORD HKLM "${PRODUCT_UNINST_KEY}" "NoRepair" 1
; We don't need this, MUI takes care for us
; WriteRegStr HKCU "Software\${PRODUCT_NAME}" "Installer Language" $sUAGE
; write out uninstaller
WriteUninstaller "$INSTDIR\gsmartcontrol_uninst.exe"
; uninstall shortcut
;CreateDirectory "$SMPROGRAMS\GSmartControl"
;CreateShortCut "$SMPROGRAMS\GSmartControl\Uninstall GSmartControl.lnk" "$INSTDIR\gsmartcontrol_uninst.exe" "" ""
SectionEnd ; post
; ---------------- UNINSTALL
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." /SD IDOK
FunctionEnd
Section Uninstall
SetShellVarContext all ; use all user variables as opposed to current user
SetAutoClose false
; add delete commands to delete whatever files/registry keys/etc you installed here.
Delete "$INSTDIR\gsmartcontrol_uninst.exe"
DeleteRegKey HKLM "SOFTWARE\${PRODUCT_NAME}"
DeleteRegKey HKLM "${PRODUCT_UNINST_KEY}"
Delete "$INSTDIR\*.exe"
Delete "$INSTDIR\*.dll"
Delete "$INSTDIR\gsmartcontrol.exe.manifest"
Delete "$INSTDIR\gsmartcontrol.ico"
Delete "$INSTDIR\icon_*.png"
; update-smart-drivedb may leave these
Delete "$INSTDIR\drivedb.h"
Delete "$INSTDIR\drivedb.h.*"
RMDir /r "$INSTDIR\doc"
; GTK and stuff
RMDir /r "$INSTDIR\etc"
RMDir /r "$INSTDIR\share"
; clean up generated stuff
Delete "$INSTDIR\*stdout.txt"
Delete "$INSTDIR\*stderr.txt"
RMDir "$INSTDIR" ; only if empty
Delete "$SMPROGRAMS\GSmartControl.lnk"
;Delete "$SMPROGRAMS\GSmartControl\Uninstall GSmartControl.lnk"
SectionEnd ; end of uninstall section
; --------------- Helpers
; Detect previous installation
Function DetectPrevInstallation
; if /removeold=no option is given, don't check anything.
StrCmp $install_option_removeold "no" old_detect_done
SetShellVarContext all ; use all user variables as opposed to current user
push $R0
; detect previous installation
ReadRegStr $R0 HKLM "${PRODUCT_UNINST_KEY}" "UninstallString"
StrCmp $R0 "" old_detect_done
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"${PRODUCT_NAME} is already installed. $\n$\nClick `OK` to remove the \
previous version or `Cancel` to continue anyway." \
/SD IDOK IDOK old_uninst
; Abort
goto old_detect_done
; Run the old uninstaller
old_uninst:
ClearErrors
IfSilent old_silent_uninst old_nosilent_uninst
old_nosilent_uninst:
ExecWait '$R0'
goto old_uninst_continue
old_silent_uninst:
ExecWait '$R0 /S _?=$INSTDIR'
old_uninst_continue:
IfErrors old_no_remove_uninstaller
; You can either use Delete /REBOOTOK in the uninstaller or add some code
; here to remove to remove the uninstaller. Use a registry key to check
; whether the user has chosen to uninstall. If you are using an uninstaller
; components page, make sure all sections are uninstalled.
old_no_remove_uninstaller:
old_detect_done: ; old installation not found, all ok
pop $R0
FunctionEnd
; Prevent running multiple instances of the installer
Function PreventMultipleInstances
Push $R0
System::Call 'kernel32::CreateMutexA(i 0, i 0, t ${PRODUCT_NAME}) ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running." /SD IDOK
Abort
Pop $R0
FunctionEnd
; eof
Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

-19
View File
@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
<action id="org.gsmartcontrol">
<message>Authentication is required to run GSmartControl</message>
<icon_name>gsmartcontrol</icon_name>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/sbin/gsmartcontrol</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig>
-6
View File
@@ -1,6 +0,0 @@
noinst_DATA = changelog.in compat control copyright menu postinst postrm rules
# include the generated file too
EXTRA_DIST=changelog.in changelog compat control copyright menu postinst \
postrm rules
-5
View File
@@ -1,5 +0,0 @@
gsmartcontrol (@VERSION@+nmu1) unstable; urgency=low
* Permanently Initial Release.
-- Alexander Shaduri <ashaduriREMOVETHIS@gmail.com> Sat, 15 Nov 2008 00:12:04 +0400
-1
View File
@@ -1 +0,0 @@
5
-18
View File
@@ -1,18 +0,0 @@
Source: gsmartcontrol
Section: utils
Priority: extra
Homepage: https://gsmartcontrol.sourceforge.io/
Maintainer: Alexander Shaduri <ashaduriREMOVETHIS@gmail.com>
Build-Depends: debhelper (>= 5), autotools-dev,
libpcre3-dev, libgtkmm-3.0-dev (>= 3.4.0)
Standards-Version: 3.7.3
Package: gsmartcontrol
Architecture: any
Depends: ${shlibs:Depends}, smartmontools (>= 5.43), xterm, menu
Description: Hard disk drive and SSD health inspection tool
GSmartControl is a graphical user interface for smartctl (from smartmontools
package), which is a tool for querying and controlling SMART
(Self-Monitoring, Analysis, and Reporting Technology) data on modern hard
disk and solid-state drives. It allows you to inspect the drive's SMART data
to determine its health, as well as run various tests on it.
-32
View File
@@ -1,32 +0,0 @@
This package was debianized by Alexander Shaduri <ashaduri 'at' gmail.com> on
Sat, 15 Nov 2008 00:12:04 +0400.
It was downloaded from <https://gsmartcontrol.sourceforge.io/>
Copyright:
Copyright (C) 2008 - 2017 Alexander Shaduri <ashaduri 'at' gmail.com>
License:
This product is multi-licensed under GNU GPL versions 2 and 3.
You are free to choose which one you use.
This program is free software: you can redistribute it and/or modify it under
the terms of either version 2 or (at your option) version 3 of the GNU General
Public License as published by the Free Software Foundation.
This program 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 Licenses for more details.
You should have received copies of these licenses along with this program.
If not, see <http://www.gnu.org/licenses/>.
On Debian systems, the complete text of the GNU General
Public Licenses can be found in `/usr/share/common-licenses/GPL-2' and
`/usr/share/common-licenses/GPL-3'.
The Debian packaging is (C) 2008 - 2017 Alexander Shaduri <ashaduri 'at' gmail.com> and
is licensed under the GPLv2 and GPLv3, see above.
-4
View File
@@ -1,4 +0,0 @@
?package(gsmartcontrol):needs="X11" section="Applications/System/Hardware"\
title="GSmartControl" command="/usr/bin/gsmartcontrol-root"\
longtitle="Hard Disk and SSD Health Inspection"\
icon="/usr/share/pixmaps/gsmartcontrol.xpm"
-14
View File
@@ -1,14 +0,0 @@
#!/bin/sh
set -e
if test -x /usr/bin/update-menus; then update-menus; fi
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
-14
View File
@@ -1,14 +0,0 @@
#!/bin/sh
set -e
if test -x /usr/bin/update-menus; then update-menus; fi
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
-102
View File
@@ -1,102 +0,0 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
config.status: configure
dh_testdir
# Add here commands to configure the package.
ifneq "$(wildcard /usr/share/misc/config.sub)" ""
cp -f /usr/share/misc/config.sub config.sub
endif
ifneq "$(wildcard /usr/share/misc/config.guess)" ""
cp -f /usr/share/misc/config.guess config.guess
endif
./configure --host=$(DEB_HOST_GNU_TYPE) \
--build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man \
--infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs"
# Add --enable-optimize-options=auto to configure line
# for optimized build (may not work on older gcc versions).
build: build-stamp
build-stamp: config.status
dh_testdir
# Add here commands to compile the package.
$(MAKE)
#docbook-to-man debian/gsmartcontrol.sgml > gsmartcontrol.1
touch $@
clean:
dh_testdir
dh_testroot
rm -f build-stamp
# Add here commands to clean up after the build process.
-$(MAKE) clean
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# Add here commands to install the package into debian/gsmartcontrol.
$(MAKE) DESTDIR=$(CURDIR)/debian/gsmartcontrol install-strip
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs ChangeLog
dh_installdocs
# dh_installexamples
# dh_install
dh_installmenu
# dh_installdebconf
# dh_installlogrotate
# dh_installemacsen
# dh_installpam
# dh_installmime
# dh_python
# dh_installinit
# dh_installcron
# dh_installinfo
dh_installman
dh_link
dh_strip
dh_compress
dh_fixperms
# dh_perl
# dh_makeshlibs
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install
-35
View File
@@ -1,35 +0,0 @@
/**************************************************************************
Copyright:
(C) 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
// This file is for generating documentation only. Do NOT include it.
/// \file
/// \author Alexander Shaduri
/**
\mainpage GSmartControl Index
\section intro_section Introduction
This is GSmartControl internal documentation.
*/
// Group definitions and titles.
/**
\addtogroup applib Application-Specific Components
\addtogroup applib_tests Tests of Application-Specific Components
\addtogroup hz HZ Common System Components
\addtogroup hz_tests Tests for HZ Common System Components
\addtogroup libdebug LibDebug Flexible Debug Logging
\addtogroup libdebug_tests Tests for LibDebug Flexible Debug Logging
\addtogroup rmn Resource Manager
\addtogroup rmn_tests Tests for Resource Manager
\addtogroup rconfig Resource Manager-Based Configuration
\addtogroup rconfig_tests Tests for Resource Manager-Based Configuration
\addtogroup gsc GSmartControl Application
*/
+2 -6
View File
@@ -1,14 +1,10 @@
#!/bin/bash
#!/bin/sh
############################################################################
# Copyright:
# (C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
# (C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
# License: See LICENSE_zlib.txt file
############################################################################
# We use #!/bin/bash of #!/bin/sh because freebsd (tested with 6.3) in its
# infinite wisdom has csh-like /bin/sh (even though the SUS says it
# must be bourne-compatible).
if [ "$1" == "" ] | [ "$2" == "" ] | [ "$3" == "" ]; then
echo "Usage: $0 <input_file> <cpp_file> <symbol_name>";
-3
View File
@@ -1,3 +0,0 @@
[Project]
Manager=KDevCustomBuildSystem
Name=gsmartcontrol
+21 -89
View File
@@ -22,7 +22,7 @@
<kdevautoproject>
<general>
<activetarget>src/gsmartcontrol</activetarget>
<useconfiguration>open64</useconfiguration>
<useconfiguration>debuggy</useconfiguration>
</general>
<run>
<mainprogram>/10/devel/projects/gsmartcontrol/current/gsmartcontrol/debuggy</mainprogram>
@@ -66,7 +66,7 @@
<cflags/>
<cxxflags/>
<envvars/>
<configargs>--disable-user-flags --enable-optimize-options --enable-tests</configargs>
<configargs>--enable-default-gcc-options --enable-gcc-optimize --enable-gcc-pch --enable-tests</configargs>
<topsourcedir/>
<cppflags/>
<ldflags/>
@@ -76,7 +76,7 @@
<f77flags/>
</optimized>
<debuggy>
<configargs>--enable-debug-options --enable-tests</configargs>
<configargs>--enable-default-gcc-options --enable-gcc-debug --enable-tests</configargs>
<builddir>debuggy</builddir>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
@@ -87,31 +87,31 @@
<topsourcedir/>
<cppflags/>
<ldflags/>
<ccompilerbinary>gcc-4.4</ccompilerbinary>
<cxxcompilerbinary>g++-4.4</cxxcompilerbinary>
<ccompilerbinary/>
<cxxcompilerbinary/>
<f77compilerbinary/>
<f77flags/>
</debuggy>
<icc>
<envvars/>
<configargs>--disable-user-flags --enable-tests</configargs>
<configargs>--disable-default-gcc-options --enable-tests</configargs>
<builddir>icc</builddir>
<topsourcedir/>
<cppflags/>
<ldflags/>
<ldflags>-s -static-libgcc -static-intel</ldflags>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
<ccompilerbinary>icc64</ccompilerbinary>
<cxxcompilerbinary>icpc64</cxxcompilerbinary>
<ccompilerbinary>icc</ccompilerbinary>
<cxxcompilerbinary>icpc</cxxcompilerbinary>
<f77compilerbinary/>
<cflags/>
<cxxflags/>
<cflags>-w1</cflags>
<cxxflags>-g0 -O3 -m32 -ftrapuv -fstack-security-check -early-template-check -static-libgcc -static-intel -Wcomment -Wdeprecated -Wextra-tokens -Wformat -Wmissing-prototypes -Wnon-virtual-dtor -Wpointer-arith -Wreturn-type -Wshadow -Wtrigraphs -Wuninitialized -w1</cxxflags>
<f77flags/>
</icc>
<win32>
<envvars/>
<configargs>--with-windows-gtk-name=gtk2-runtime-2.16.6-2010-02-24-ash --disable-user-flags --enable-optimize-options --enable-tests --build=i686-linux --host=i386-pc-mingw32 PKG_CONFIG_PATH=/cross/w32/target/lib/pkgconfig PKG_CONFIG_LIBDIR=&quot;&quot; PATH=&quot;/cross/w32/gcc-bin:/cross/w32/target/bin:$PATH&quot;</configargs>
<configargs>--enable-default-gcc-options --enable-gcc-optimize --enable-gcc-pch --enable-tests --target=i386-mingw32msvc --host=i386-mingw32msvc --build=i686-linux PKG_CONFIG_PATH=/target/lib/pkgconfig PKG_CONFIG_LIBDIR=/target/lib PATH=&quot;/opt/cross-tools/bin:/target/bin:$PATH&quot;</configargs>
<builddir>win32</builddir>
<topsourcedir/>
<cppflags/>
@@ -119,8 +119,8 @@
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
<ccompilerbinary>i386-pc-mingw32-gcc</ccompilerbinary>
<cxxcompilerbinary>i386-pc-mingw32-g++</cxxcompilerbinary>
<ccompilerbinary>&quot;i386-mingw32msvc-gcc -mms-bitfields&quot;</ccompilerbinary>
<cxxcompilerbinary>&quot;i386-mingw32msvc-g++ -mms-bitfields&quot;</cxxcompilerbinary>
<f77compilerbinary/>
<cflags/>
<cxxflags/>
@@ -128,21 +128,21 @@
</win32>
<suncc>
<envvars>
<envvar value="/opt/sun/sunstudio/bin:$PATH" name="PATH" />
<envvar value="/opt/sun/sunstudio12/bin:$PATH" name="PATH" />
</envvars>
<configargs>--enable-tests PKG_CONFIG_PATH=&quot;/opt/sun/target64/lib64/pkgconfig:/usr/lib64/pkgconfig&quot; PKG_CONFIG_LIBDIR=&quot;&quot;</configargs>
<configargs>--disable-default-gcc-options --enable-tests</configargs>
<builddir>suncc</builddir>
<topsourcedir/>
<cppflags/>
<ldflags>-R/opt/sun/target64/lib64 -L/opt/sun/target64/lib64</ldflags>
<ldflags>-s</ldflags>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
<ccompilerbinary>suncc</ccompilerbinary>
<cxxcompilerbinary>sunCC</cxxcompilerbinary>
<f77compilerbinary/>
<cflags>-errwarn=%all -I/opt/sun/target64/include</cflags>
<cxxflags>-I/opt/sun/target64/include</cxxflags>
<cflags>-DDEBUG -DDEBUG_BUILD</cflags>
<cxxflags>+w -errtags -erroff=notemsource,notused -features=extensions -DHZ_FORCE_GLOBAL_MACROS -DDEBUG -DDEBUG_BUILD -DGLIBMM_HAVE_SUN_REVERSE_ITERATOR -DSIGC_HAVE_SUN_REVERSE_ITERATOR</cxxflags>
<f77flags/>
</suncc>
<portland>
@@ -151,7 +151,7 @@
<builddir>portland</builddir>
<topsourcedir/>
<cppflags/>
<ldflags>-s</ldflags>
<ldflags/>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
@@ -159,77 +159,9 @@
<cxxcompilerbinary>pgCC</cxxcompilerbinary>
<f77compilerbinary/>
<cflags>-Minform=warn -Bstatic_pgi</cflags>
<cxxflags>-Minform=warn -Bstatic_pgi -noswitcherror -define_macro=HZ_NO_COMPILER_AUTOINCLUDE</cxxflags>
<cxxflags>-Minform=warn -Bstatic_pgi -noswitcherror -define_macro=HZ_FORCE_GLOBAL_MACROS</cxxflags>
<f77flags/>
</portland>
<win32-debug>
<envvars/>
<configargs>--disable-user-flags --enable-debug-options --enable-tests --build=i686-linux --host=i386-pc-mingw32 PKG_CONFIG_PATH=/cross/w32/target/lib/pkgconfig PKG_CONFIG_LIBDIR=&quot;&quot; PATH=&quot;/cross/w32/gcc-bin:/cross/w32/target/bin:$PATH&quot;</configargs>
<builddir>win32-debug</builddir>
<topsourcedir/>
<cppflags/>
<ldflags/>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
<ccompilerbinary>i386-pc-mingw32-gcc</ccompilerbinary>
<cxxcompilerbinary>i386-pc-mingw32-g++</cxxcompilerbinary>
<f77compilerbinary/>
<cflags/>
<cxxflags/>
<f77flags/>
</win32-debug>
<win64-debug>
<envvars/>
<configargs>--disable-user-flags --enable-optimize-options --enable-tests --build=i686-linux --host=x86_64-pc-mingw32 PKG_CONFIG_PATH=/cross/w64/target/lib/pkgconfig PKG_CONFIG_LIBDIR=&quot;&quot; PATH=&quot;/cross/w64/gcc-bin:/cross/w64/target/bin:$PATH&quot;</configargs>
<builddir>win64-debug</builddir>
<topsourcedir/>
<cppflags/>
<ldflags/>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
<ccompilerbinary>x86_64-pc-mingw32-gcc</ccompilerbinary>
<cxxcompilerbinary>x86_64-pc-mingw32-g++</cxxcompilerbinary>
<f77compilerbinary/>
<cflags/>
<cxxflags/>
<f77flags/>
</win64-debug>
<default>
<envvars/>
<configargs/>
<builddir/>
<topsourcedir/>
<cppflags/>
<ldflags/>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
<ccompilerbinary/>
<cxxcompilerbinary/>
<f77compilerbinary/>
<cflags/>
<cxxflags/>
<f77flags/>
</default>
<open64>
<envvars/>
<configargs>--enable-tests</configargs>
<builddir>open64</builddir>
<topsourcedir/>
<cppflags/>
<ldflags/>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
<ccompilerbinary>/opt/open64/bin/opencc</ccompilerbinary>
<cxxcompilerbinary>/opt/open64/bin/openCC</cxxcompilerbinary>
<f77compilerbinary/>
<cflags/>
<cxxflags>-Wall</cxxflags>
<f77flags/>
</open64>
</configurations>
<make>
<envvars>
+68 -63
View File
@@ -1,33 +1,32 @@
# This spec file is for openSUSE Build Service.
# Supported distributions: openSUSE, Fedora, CentOS, RHEL.
Name: gsmartcontrol
Version: @VERSION@
Release: 0
License: GPL-2.0 AND GPL-3.0
Url: https://gsmartcontrol.sourceforge.io/
Version: @VERSION@
Release: 1as
License: GPLv2, GPLv3
Vendor: Alexander Shaduri <ashaduri 'at' gmail.com>
# Packager: Alexander Shaduri <ashaduri 'at' gmail.com>
Source: http://sourceforge.net/projects/gsmartcontrol/files/%{version}/%{name}-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Summary: GSmartControl - Hard Disk Drive and SSD Health Inspection Tool
Url: http://gsmartcontrol.berlios.de
Packager: Alexander Shaduri <ashaduri 'at' gmail.com>
Group: Hardware/Other
# Empty debug packages cause errors in new RPM. Disable them.
%global debug_package %{nil}
Source: gsmartcontrol-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Summary: GSmartControl - Hard Disk Health Inspection Tool
# Dependencies for various distributions. The actual deps are:
# smartmontools, pcre, (gtkmm2 >= 2.12 || (gtkmm2 >= 2.6.0 && libglademm >= 2.4.0))
# (with the respective -devel packages of the libraries for build requirements).
# For non-specified distributions we don't specify any dependencies to avoid errors.
# SUSE / OpenSUSE. SLES also defines the correct suse_version.
# SUSE, OpenSUSE. SLES also defines the correct suse_version.
%if 0%{?suse_version}
Requires: smartmontools >= 5.43, polkit, bash, xterm
BuildRequires: gcc-c++, libstdc++-devel, pcre-devel, gtkmm3-devel >= 3.4.0
BuildRequires: update-desktop-files
BuildRequires: fdupes
%if %suse_version >= 1030
Requires: smartmontools, pcre, gtkmm2 >= 2.12.0
BuildRequires: gcc-c++ libstdc++-devel pcre-devel, gtkmm2-devel >= 2.12.0
%else
Requires: smartmontools, pcre, gtkmm2 >= 2.6.0, libglademm >= 2.4.0
BuildRequires: gcc-c++ libstdc++-devel pcre-devel, gtkmm2-devel >= 2.6.0, libglademm-devel >= 2.4.0
%endif
%endif
@@ -35,8 +34,28 @@ BuildRequires: fdupes
# Fedora, CentOS, RHEL
%if 0%{?fedora_version} || 0%{?rhel_version} || 0%{?centos_version}
Requires: smartmontools >= 5.43, polkit, bash, xterm
BuildRequires: gcc-c++, pcre-devel, gtkmm30-devel >= 3.4.0
# I'm not sure about centos and rhel versions
%if 0%{?fedora_version} >= 8 || 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
Requires: smartmontools, pcre, gtkmm24 >= 2.12.0
BuildRequires: gcc-c++ pcre-devel, gtkmm24-devel >= 2.12.0
%else
Requires: smartmontools, pcre, gtkmm24 >= 2.6.0, libglademm24 >= 2.4.0
BuildRequires: gcc-c++ pcre-devel, gtkmm24-devel >= 2.6.0, libglademm24-devel >= 2.4.0
%endif
%endif
# Mandriva
%if 0%{?mandriva_version}
%if 0%{?mandriva_version} >= 2008
Requires: smartmontools, libpcre0, libgtkmm2.4_1 >= 2.12.0
BuildRequires: gcc-c++ gcc-cpp libpcre-devel, libgtkmm2.4-devel >= 2.12.0
%else
Requires: smartmontools, libpcre0, libgtkmm2.4_1 >= 2.6.0, libglademm2.4_1 >= 2.4.0
BuildRequires: gcc-c++ gcc-cpp libpcre-devel, libgtkmm2.4-devel >= 2.6.0, libglademm2.4_1-devel >= 2.4.0
%endif
%endif
@@ -44,46 +63,32 @@ BuildRequires: gcc-c++, pcre-devel, gtkmm30-devel >= 3.4.0
%description
GSmartControl is a graphical user interface for smartctl, which is a tool for
querying and controlling SMART (Self-Monitoring, Analysis, and Reporting
Technology) data in hard disk and solid-state drives. It allows you to inspect
the drive's SMART data to determine its health, as well as run various tests
on it.
Technology) data in hard disk drives. It allows you to inspect the drive's
SMART data to determine its health, as well as run various tests on it.
%prep
%setup -q
%configure
# Don't use configure parameters - let rpm set them.
# --prefix=/usr --enable-default-gcc-options --enable-gcc-optimize
%build
make %{?_smp_mflags}
# Setup for parallel builds
numprocs=`egrep -c ^cpu[0-9]+ /proc/stat || :`
if [ "$numprocs" = "0" ]; then
numprocs=1
fi
make -j$numprocs
#make
%install
# %%makeinstall
make DESTDIR=%buildroot install-strip
# Remove the icon cache file "make install" generates, to avoid package conflicts.
rm -f $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/icon-theme.cache
%if 0%{?suse_version}
%suse_update_desktop_file -n %{name}
# There are some png file duplicates, hardlink them.
%fdupes
# We install icons, so this is needed.
%if 0%{?suse_version} >= 1140
%post
%icon_theme_cache_post
%postun
%icon_theme_cache_postun
%endif
# endif suse
%endif
# %makeinstall
make DESTDIR=%buildroot install
%clean
@@ -93,23 +98,23 @@ rm -rf %buildroot
%files
%defattr(-,root,root)
%attr(0755,root,root) %{_bindir}/gsmartcontrol-root
%attr(0755,root,root) %{_sbindir}/gsmartcontrol
# %%attr(0644,root,root) %%config(noreplace) %%{_sysconfdir}/*
%attr(0755,root,root) %{_bindir}/*
#%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/*
%doc %{_datadir}/doc/gsmartcontrol
%doc %{_mandir}/man1/*
%{_datadir}/gsmartcontrol
# %%{_datadir}/gsmartcontrol/*
%{_datadir}/applications/*.desktop
%{_datadir}/metainfo
%{_datadir}/metainfo/gsmartcontrol.appdata.xml
%{_datadir}/polkit-1
%{_datadir}/polkit-1/actions
%{_datadir}/polkit-1/actions/org.gsmartcontrol.policy
%{_datadir}/gsmartcontrol/*
%{_datadir}/applications/*
%{_datadir}/icons/*
%{_datadir}/pixmaps/*
%changelog
* Mon Oct 06 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
- Updated .spec file to support OpenSUSE < 10.3, Fedora and friends,
Mandriva (for OpenSUSE Build Service).
* Mon Sep 15 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
- Initial .spec file.
+9 -31
View File
@@ -1,39 +1,17 @@
AM_CPPFLAGS = $(all_includes)
METASOURCES = AUTO
SUBDIRS = libdebug hz rmn rconfig applib res
bin_PROGRAMS = gsmartcontrol
if TARGET_OS_KERNEL_FAMILY_WINDOWS
WINRES_OBJ = gsc_winres_win32.o
endif
# use different name for object file to avoid make auto-rules
gsc_winres_win32.o: $(top_srcdir)/data/gsmartcontrol.ico gsc_winres.rc
cp -f $(top_srcdir)/data/gsmartcontrol.ico .
$(WINDRES) gsc_winres.rc gsc_winres_win32.o
mostlyclean-local:
rm -f gsmartcontrol.ico
noinst_DATA = gsc_winres.rc.in gsmartcontrol.exe.manifest.in
# if TARGET_OS_KERNEL_FAMILY_WINDOWS
# WIN_MAIN_SRC = win_main.cpp
# endif
sbin_PROGRAMS = gsmartcontrol
SUBDIRS = libdebug hz rmn rconfig pcrecpp applib res
gsmartcontrol_LDADD = $(top_builddir)/src/applib/libapplib.a \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/res/libres.a $(WINRES_OBJ)
$(top_builddir)/src/pcrecpp/libpcrecpp.a $(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/res/libres.a
noinst_HEADERS = global_macros.h gsc_about_dialog.h gsc_add_device_window.h gsc_executor_error_dialog.h \
gsc_executor_log_window.h gsc_info_window.h gsc_init.h gsc_main_window.h \
noinst_HEADERS = global_macros.h gsc_about_dialog.h gsc_executor_error_dialog.h \
gsc_executor_log_window.h gsc_help_window.h gsc_info_window.h gsc_init.h gsc_main_window.h \
gsc_main_window_iconview.h gsc_preferences_window.h gsc_settings.h gsc_text_window.h
gsmartcontrol_SOURCES = $(WIN_MAIN_SRC) gsc_about_dialog.cpp gsc_add_device_window.cpp \
gsc_executor_error_dialog.cpp gsc_executor_log_window.cpp gsc_info_window.cpp \
gsc_init.cpp gsc_main.cpp gsc_main_window.cpp gsc_preferences_window.cpp
gsmartcontrol_SOURCES = gsc_about_dialog.cpp gsc_executor_error_dialog.cpp \
gsc_executor_log_window.cpp gsc_help_window.cpp gsc_info_window.cpp gsc_init.cpp gsc_main.cpp \
gsc_main_window.cpp gsc_preferences_window.cpp
+15 -24
View File
@@ -1,24 +1,21 @@
AM_CPPFLAGS = $(all_includes)
METASOURCES = AUTO
noinst_LIBRARIES = libapplib.a
libapplib_a_SOURCES = app_gtkmm_utils.cpp app_pango_utils.cpp cmdex.cpp \
cmdex_sync.cpp cmdex_sync_gui.cpp executor_factory.cpp gui_utils.cpp selftest.cpp smartctl_executor.cpp \
smartctl_parser.cpp storage_detector.cpp storage_detector_linux.cpp storage_detector_other.cpp \
storage_detector_win32.cpp storage_device.cpp storage_property.cpp \
storage_property_descr.cpp
noinst_HEADERS = app_gtkmm_features.h app_gtkmm_utils.h app_pango_utils.h \
app_pcrecpp.h app_ui_res_utils.h cli_executors.h cmdex.h cmdex_sync.h cmdex_sync_gui.h executor_factory.h gui_utils.h \
selftest.h smartctl_executor.h smartctl_executor_gui.h smartctl_parser.h \
storage_detector.h storage_detector_helpers.h storage_detector_linux.h storage_detector_other.h \
storage_detector_win32.h storage_device.h storage_property.h storage_property_colors.h \
storage_property_descr.h storage_settings.h
libapplib_a_SOURCES = app_gtkmm_utils.cpp cmdex.cpp cmdex_sync.cpp \
cmdex_sync_gui.cpp gui_utils.cpp selftest.cpp smartctl_parser.cpp storage_detector.cpp \
storage_device.cpp storage_property.cpp storage_property_descr.cpp
noinst_HEADERS = app_gtkmm_features.h app_gtkmm_utils.h app_pcrecpp.h \
app_ui_res_utils.h cmdex.h cmdex_sync.h cmdex_sync_gui.h gui_utils.h selftest.h smartctl_executor.h \
smartctl_executor_gui.h smartctl_parser.h storage_detector.h storage_device.h \
storage_property.h storage_property_colors.h storage_property_descr.h storage_settings.h \
wrapping_label.h
# don't use absolute path for the current dir's .a, because the make
# dependency resolver won't get it (needed for parallel builds)
app_ui_res_utils_test_SOURCES = app_ui_res_utils_test.cpp app_ui_res_utils_test_data.cpp
app_ui_res_utils_test_LDADD = libapplib.a \
$(top_builddir)/src/libdebug/libdebug.a
storage_detector_test_SOURCES = storage_detector_test.cpp
storage_detector_test_LDADD = libapplib.a \
$(top_builddir)/src/pcrecpp/libpcrecpp.a $(top_builddir)/src/libdebug/libdebug.a
smartctl_executor_test_SOURCES = smartctl_executor_test.cpp
smartctl_executor_test_LDADD = libapplib.a \
@@ -26,23 +23,17 @@ smartctl_executor_test_LDADD = libapplib.a \
smartctl_parser_test_SOURCES = smartctl_parser_test.cpp
smartctl_parser_test_LDADD = libapplib.a \
$(top_builddir)/src/libdebug/libdebug.a
storage_detector_test_SOURCES = storage_detector_test.cpp
storage_detector_test_LDADD = libapplib.a \
$(top_builddir)/src/libdebug/libdebug.a
spawn_test_SOURCES = spawn_test.cpp
$(top_builddir)/src/pcrecpp/libpcrecpp.a $(top_builddir)/src/libdebug/libdebug.a
# Build them first
SUBDIRS=../libdebug
SUBDIRS=../libdebug ../pcrecpp
# we don't list them in a separate variable because otherwise kdevelop won't see them.
noinst_PROGRAMS =
if ENABLE_TESTS
noinst_PROGRAMS += app_ui_res_utils_test smartctl_executor_test smartctl_parser_test \
storage_detector_test spawn_test
noinst_PROGRAMS += smartctl_executor_test smartctl_parser_test \
storage_detector_test
endif
tests: $(noinst_PROGRAMS)
+18 -18
View File
@@ -1,22 +1,16 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#ifndef APP_GTKMM_FEATURES_H
#define APP_GTKMM_FEATURES_H
#include <gtkmm.h>
#include <gtkmmconfig.h>
/// \def APP_GTKMM_CHECK_VERSION(major, minor, micro)
/// Similar to GTK_CHECK_VERSION, but for gtkmm, which lacks this for some reason.
// Similar to GTK_CHECK_VERSION, but for gtkmm (this should have been in it)
#ifndef APP_GTKMM_CHECK_VERSION
#define APP_GTKMM_CHECK_VERSION(major, minor, micro) \
(GTKMM_MAJOR_VERSION > (major) \
@@ -29,6 +23,13 @@
// New tooltip API is available since 2.12
#if !APP_GTKMM_CHECK_VERSION(2, 12, 0)
#define APP_GTKMM_OLD_TOOLTIPS
#endif
// If default virtual on_* members are disabled in gtkmm, use this in constructors
// to connect on_signal_name methods.
@@ -50,13 +51,14 @@
*/
/// Connect to a signal _before_ the default handler. That is, if you want
/// to have, say, on_delete_event() in your window-inherited class, define
/// on_delete_event_before() instead and return true (handled) from it
/// if it's X event handler.
/// This method will work regardless of presence of default virtual handlers
/// in parent class. It will also avoid calling the handler twice (one from
/// signal, another from default virtual handler).
// Connect to a signal _before_ the default handler. That is, if you want
// to have, say, on_delete_event() in your window-inherited class, define
// on_delete_event_before() instead and return true (handled) from it
// if it's X event handler.
// This method will work regardless of presence of default virtual handlers
// in parent class. It will also avoid calling the handler twice (one from
// signal, another from default virtual handler).
#define APP_GTKMM_CONNECT_VIRTUAL(signal_name) \
this->signal_ ## signal_name ().connect(sigc::mem_fun(*this, &self_type::on_ ## signal_name ## _before), false)
@@ -66,5 +68,3 @@
#endif
/// @}
+127 -67
View File
@@ -1,21 +1,19 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#include <gtkmm.h>
#include <glibmm.h>
#include <glib.h>
#include <cstring> // std::strlen
#include <gtk/gtk.h> // gtk_* stuff
#include <vector>
#include "app_pango_utils.h" // app_pango_strip_markup()
#include "app_gtkmm_features.h" // APP_GTKMM_OLD_TOOLTIPS
#ifdef APP_GTKMM_OLD_TOOLTIPS
#include <gtk/gtk.h> // gtk_tooltips_*
#endif
#include "app_gtkmm_utils.h"
@@ -54,98 +52,162 @@ Gtk::Widget* app_gtkmm_labelize_column(Gtk::TreeViewColumn& column)
void app_gtkmm_set_widget_tooltip(Gtk::Widget& widget,
const Glib::ustring& tooltip_text, bool use_markup)
{
// set_tooltip_* is available since 2.12
#ifndef APP_GTKMM_OLD_TOOLTIPS
if (use_markup) {
widget.set_tooltip_markup(tooltip_text);
} else {
widget.set_tooltip_text(tooltip_text);
}
#else // use the old tooltips api
Gtk::Widget* toplevel = widget.get_toplevel();
if (toplevel && toplevel->is_toplevel()) { // orphan widgets return themselves, so check toplevelness.
GtkTooltips* tooltips = static_cast<GtkTooltips*>(toplevel->get_data("window_tooltips"));
if (tooltips) {
if (use_markup) {
// strip markup
gchar* stripped = 0;
if (pango_parse_markup(tooltip_text.c_str(), -1, 0, NULL, &stripped, NULL, NULL) && stripped) {
gtk_tooltips_set_tip(tooltips, widget.gobj(), stripped, "");
}
g_free(stripped);
// alternate method, check if it works (AttrList has bool() since gtkmm 2.10):
// char dummy = 0;
// Glib::ustring stripped;
// if (Pango::AttrList(tooltip_text, 0, stripped, dummy).gobj()) ...
} else {
gtk_tooltips_set_tip(tooltips, widget.gobj(), tooltip_text.c_str(), "");
}
}
}
#endif
}
// unset model on treeview, cross-gtkmm-version.
void app_gtkmm_treeview_unset_model(Gtk::TreeView* treeview)
{
// gtkmm's TreeView::unset_model() is since gtkmm 2.8
// (and there's no version info in docs), so use this instead.
if (treeview)
gtk_tree_view_set_model(treeview->gobj(), 0);
}
// unset model on combobox, cross-gtkmm-version.
void app_gtkmm_combobox_unset_model(Gtk::ComboBox* box)
{
// there's no ComboBox::unset_model() in gtkmm (huh?)
if (box)
gtk_combo_box_set_model(box->gobj(), 0);
}
#ifdef APP_GTKMM_OLD_TOOLTIPS
namespace {
/// This has been copied from _g_utf8_make_valid() (glib-2.20.4).
/// _g_utf8_make_valid() is GLib's private function for auto-correcting
/// the potentially invalid utf-8 data.
inline gchar* gsc_g_utf8_make_valid (const gchar* name)
// helper function for gtkmm_set_treeview_tooltip_column()
inline bool app_on_treeview_motion_notify_event_tooltip(GdkEventMotion* event, Gtk::TreeView* treeview,
Gtk::TreeModelColumn<Glib::ustring> tooltip_column)
{
GString* str;
const gchar* remainder, *invalid;
gint remaining_bytes, valid_bytes;
// debug_out_dump("app", DBG_FUNC_MSG << "x=" << int(event->x) << ", y=" << int(event->y) << "\n");
g_return_val_if_fail (name != NULL, NULL);
Gtk::TreePath path;
Gtk::TreeViewColumn* mouse_column = 0;
int cell_x = 0, cell_y = 0;
str = NULL;
remainder = name;
remaining_bytes = gint(std::strlen(name));
while (remaining_bytes != 0) {
if (g_utf8_validate (remainder, remaining_bytes, &invalid))
break;
valid_bytes = gint(invalid - remainder);
if (str == NULL)
str = g_string_sized_new (remaining_bytes);
g_string_append_len (str, remainder, valid_bytes);
/* append U+FFFD REPLACEMENT CHARACTER */
g_string_append (str, "\357\277\275");
remaining_bytes -= valid_bytes + 1;
remainder = invalid + 1;
if (treeview->get_path_at_pos(static_cast<int>(event->x), static_cast<int>(event->y),
path, mouse_column, cell_x, cell_y)) { // returns true if we're on a cell
app_gtkmm_set_widget_tooltip(*treeview, (*(treeview->get_model()->get_iter(path)))[tooltip_column], true);
}
if (str == NULL)
return g_strdup (name);
return false; // continue handling (no conflicts there?)
}
g_string_append (str, remainder);
g_assert (g_utf8_validate (str->str, -1, NULL));
// helper function for gtkmm_set_iconview_tooltip_column()
inline bool app_on_iconview_motion_notify_event_tooltip(GdkEventMotion* event, Gtk::IconView* iconview,
Gtk::TreeModelColumn<Glib::ustring> tooltip_column, Glib::RefPtr<Gtk::ListStore> model)
{
// debug_out_dump("app", DBG_FUNC_MSG << "x=" << int(event->x) << ", y=" << int(event->y) << "\n");
return g_string_free (str, FALSE);
// don't use get_item_at_pos() - it's not available in gtkmm < 2.8.
Gtk::TreePath tpath = iconview->get_path_at_pos(static_cast<int>(event->x), static_cast<int>(event->y));
if (tpath.gobj() && !tpath.empty()) { // without gobj() check gtkmm 2.6 (but not 2.12) prints lots of errors
// somehow, getting model from iconview doesn't work (segfault).
// Glib::RefPtr<Gtk::TreeModel> model = iconview->get_model();
if (tpath.gobj())
app_gtkmm_set_widget_tooltip(*iconview, (*(model->get_iter(tpath)))[tooltip_column], true);
}
return false; // continue handling (no conflicts there?)
}
}
#endif
Glib::ustring app_ustring_from_gchar(gchar* str)
void gtkmm_set_treeview_tooltip_column(Gtk::TreeView* treeview,
Gtk::TreeModelColumn<Glib::ustring>& col_tooltip)
{
if (!str) {
return Glib::ustring();
}
Glib::ustring ustr(str);
g_free(str);
return ustr;
if (!treeview)
return;
#ifndef APP_GTKMM_OLD_TOOLTIPS
treeview->set_tooltip_column(col_tooltip.index()); // gtkmm has only index-based api here
#else // manually set tooltips when hovering over cells
treeview->signal_motion_notify_event().connect( // connect before other events, or we'll get some screwed event data
sigc::bind(sigc::bind(sigc::ptr_fun(&app_on_treeview_motion_notify_event_tooltip), col_tooltip), treeview), false);
#endif
}
Glib::ustring app_utf8_make_valid(const Glib::ustring& str)
void gtkmm_set_iconview_tooltip_column(Gtk::IconView* iconview,
Gtk::TreeModelColumn<Glib::ustring>& col_tooltip, Glib::RefPtr<Gtk::ListStore> model)
{
char* s = gsc_g_utf8_make_valid(str.c_str());
if (!s) {
return Glib::ustring();
}
Glib::ustring res(s);
g_free(s);
return res;
if (!iconview)
return;
#ifndef APP_GTKMM_OLD_TOOLTIPS
iconview->set_tooltip_column(col_tooltip.index()); // gtkmm has only index-based api here
#else // manually set tooltips when hovering over cells
iconview->signal_motion_notify_event().connect( // connect before other events, or we'll get some screwed event data
sigc::bind(sigc::bind(sigc::bind(sigc::ptr_fun(&app_on_iconview_motion_notify_event_tooltip), model), col_tooltip), iconview), false);
#endif
}
Glib::ustring app_output_make_valid(const Glib::ustring& str)
bool app_gtkmm_icon_theme_has_icon(Glib::RefPtr<Gtk::IconTheme> theme,
const Glib::ustring& icon_name, int size)
{
#ifdef _WIN32
try {
return app_utf8_make_valid(Glib::locale_to_utf8(str));
} catch (Glib::ConvertError& e) {
// nothing, try to fix as it is
if (!theme || !theme->has_icon(icon_name)) // check if it exists first, or exception may be thrown.
return false;
std::vector<int> sizes = theme->get_icon_sizes(icon_name);
for (std::vector<int>::const_iterator iter = sizes.begin(); iter != sizes.end(); ++iter) {
if (*iter == size || *iter == -1) // -1 means scalable
return true;
}
#endif
return app_utf8_make_valid(str);
return false;
}
@@ -153,5 +215,3 @@ Glib::ustring app_output_make_valid(const Glib::ustring& str)
/// @}
+56 -49
View File
@@ -1,91 +1,98 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#ifndef APP_GTKMM_UTILS_H
#define APP_GTKMM_UTILS_H
#include <string>
#include <gtkmm.h>
#include <gtkmm/widget.h>
#include <gtkmm/treeviewcolumn.h>
#include <gtkmm/treemodelcolumn.h>
#include <gtkmm/treeview.h>
#include <gtkmm/combobox.h>
#include <gtkmm/cellrenderertext.h>
#include <gtkmm/iconview.h>
#include <gtkmm/liststore.h>
#include <gtkmm/icontheme.h> // must include (even if gtkmm.h is included) for older gtkmm (at least 2.6, but not 2.12)
#include "hz/down_cast.h"
/// Get column header widget of a tree view column.
/// Note: This works only if the column has custom widget set.
// Note: This works only if the column has custom widget set.
Gtk::Widget* app_gtkmm_get_column_header(Gtk::TreeViewColumn& column);
/// Read column header text and create a label with that text. Set the label as
/// column's custom widget and return it.
// Read column header text and create a label with that text, set it as column's custom widget.
Gtk::Widget* app_gtkmm_labelize_column(Gtk::TreeViewColumn& column);
/// A wrapper around set_tooltip_*() for portability across different gtkmm versions.
// unset model on treeview, cross-gtkmm-version.
void app_gtkmm_treeview_unset_model(Gtk::TreeView* treeview);
// unset model on combobox (there's no straight way to do it in gtkmm, I think)
void app_gtkmm_combobox_unset_model(Gtk::ComboBox* box);
// A wrapper around set_tooltip_*() for portability across different gtkmm versions.
void app_gtkmm_set_widget_tooltip(Gtk::Widget& widget,
const Glib::ustring& tooltip_text, bool use_markup = false);
// A portable wrapper around TreeView::set_tooltip_column().
void gtkmm_set_treeview_tooltip_column(Gtk::TreeView* treeview,
Gtk::TreeModelColumn<Glib::ustring>& col_tooltip);
/// Convenience function for creating a TreeViewColumn .
template<typename T>
// A portable wrapper around IconView::set_tooltip_column().
void gtkmm_set_iconview_tooltip_column(Gtk::IconView* iconview,
Gtk::TreeModelColumn<Glib::ustring>& col_tooltip, Glib::RefPtr<Gtk::ListStore> model);
// Convenience function for creating a TreeViewColumn .
template<typename T> inline
int app_gtkmm_create_tree_view_column(Gtk::TreeModelColumn<T>& mcol, Gtk::TreeView& treeview,
const Glib::ustring& title, const Glib::ustring& tooltip_text, bool sortable = false, bool cell_markup = false)
{
int num_tree_cols = treeview.append_column(title, mcol);
Gtk::TreeViewColumn* tcol = treeview.get_column(num_tree_cols - 1);
if (tcol) {
if (sortable)
tcol->set_sort_column(mcol);
int num_tree_cols = treeview.append_column(title, mcol);
Gtk::TreeViewColumn* tcol = treeview.get_column(num_tree_cols - 1);
if (tcol) {
if (sortable)
tcol->set_sort_column(mcol);
app_gtkmm_labelize_column(*tcol);
tcol->set_reorderable(true);
tcol->set_resizable(true);
}
Gtk::Widget* header = app_gtkmm_get_column_header(*tcol);
if (header)
app_gtkmm_set_widget_tooltip(*header, tooltip_text);
if (cell_markup) {
Gtk::CellRendererText* cr_type = hz::down_cast<Gtk::CellRendererText*>(treeview.get_column_cell_renderer(num_tree_cols - 1));
if (cr_type) { // may not be true if it's not Text (unless static_cast is used, in which case we're screwed)
treeview.get_column(num_tree_cols - 1)->clear_attributes(*cr_type); // clear "text" attribute. "markup" won't work without this.
treeview.get_column(num_tree_cols - 1)->add_attribute(cr_type->property_markup(), mcol); // render col_type as markup.
app_gtkmm_labelize_column(*tcol);
tcol->set_reorderable(true);
tcol->set_resizable(true);
}
}
return num_tree_cols;
Gtk::Widget* header = app_gtkmm_get_column_header(*tcol);
if (header)
app_gtkmm_set_widget_tooltip(*header, tooltip_text);
if (cell_markup) {
Gtk::CellRendererText* cr_type = hz::down_cast<Gtk::CellRendererText*>(treeview.get_column_cell_renderer(num_tree_cols - 1));
if (cr_type) { // may not be true if it's not Text (unless static_cast is used, in which case we're screwed)
treeview.get_column(num_tree_cols - 1)->clear_attributes(*cr_type); // clear "text" attribute. "markup" won't work without this.
treeview.get_column(num_tree_cols - 1)->add_attribute(cr_type->property_markup(), mcol); // render col_type as markup.
}
}
return num_tree_cols;
}
/// Get Glib::ustring from gchar*, freeing gchar*.
Glib::ustring app_ustring_from_gchar(gchar* str);
bool app_gtkmm_icon_theme_has_icon(Glib::RefPtr<Gtk::IconTheme> theme,
const Glib::ustring& icon_name, int size);
/// Convert a possibly invalid utf-8 string to valid utf-8.
/// \param str string to test and fix.
Glib::ustring app_utf8_make_valid(const Glib::ustring& str);
/// Make command output a valid utf-8 string. Essentially, this calls app_utf8_make_valid(),
/// supplying true for \c in_locale under Win32, and false under other systems.
/// The reason for this is that in Win32 we can't execute commands under C locale,
/// but we do execute them under C in other systems.
Glib::ustring app_output_make_valid(const Glib::ustring& str);
#endif
/// @}
-57
View File
@@ -1,57 +0,0 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#include <pango/pango.h> // pango_parse_markup()
#include "app_pango_utils.h"
// Returns true if markup was successfully stripped
bool app_pango_strip_markup(const Glib::ustring& str, Glib::ustring& stripped)
{
gchar* gstripped = 0;
bool ok = false;
if (pango_parse_markup(str.c_str(), -1, 0, NULL, &gstripped, NULL, NULL) && gstripped) {
stripped = gstripped;
ok = true;
}
g_free(gstripped);
// alternative method, check if it works (AttrList has bool() cast since gtkmm 2.10):
// char dummy = 0;
// if (Pango::AttrList(str, 0, stripped, dummy).gobj()) {
// return true;
// }
return ok;
}
bool app_pango_strip_markup(const std::string& str, std::string& stripped)
{
gchar* gstripped = 0;
bool ok = false;
if (pango_parse_markup(str.c_str(), -1, 0, NULL, &gstripped, NULL, NULL) && gstripped) {
stripped = gstripped;
ok = true;
}
g_free(gstripped);
return ok;
}
/// @}
-35
View File
@@ -1,35 +0,0 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#ifndef APP_PANGO_UTILS_H
#define APP_PANGO_UTILS_H
#include <string>
#include <glibmm.h> // ustring
/// Strip a string of all markup tags.
/// \return false if there was some error.
bool app_pango_strip_markup(const Glib::ustring& str, Glib::ustring& stripped);
/// Strip a string of all markup tags.
/// \return false if there was some error.
bool app_pango_strip_markup(const std::string& str, std::string& stripped);
#endif
/// @}
+28 -60
View File
@@ -1,46 +1,32 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#ifndef APP_PCRECPP_H
#define APP_PCRECPP_H
// A wrapper header for pcrecpp
// A wrapper header for bundled pcrecpp
// disable all that declspec BS
#ifndef PCRE_STATIC
# define PCRE_STATIC
#endif
#include "pcrecpp/pcrecpp_internal.h"
#include "pcrecpp/pcrecpp.h"
#include <pcrecpp.h>
#include <string>
#include "hz/debug.h"
/// Take a string of characters where each character represents a modifier
/// and return the appropriate pcre options.
/// - i - case insensitive match.
/// - m - multiline, read past the first line.
/// - s - dot matches newlines.
/// - E - $ matches only the end of the string (D in php, not available in perl).
/// - X - strict escape parsing (not available in perl).
/// - x - ignore whitespaces.
/// - 8 - handles UTF8 characters in pattern (u in php, not available in perl).
/// - U - ungreedy, reverses * and *? (not available in perl).
/// - N - disables matching parentheses (not available in perl or php).
inline pcrecpp::RE_Options app_pcre_get_options(const char* modifiers)
{
// ANYCRLF means any of crlf, cr, lf. Used in ^ and $.
// This overrides the build-time newline setting of pcre.
#ifdef PCRE_NEWLINE_ANYCRLF
pcrecpp::RE_Options options(PCRE_NEWLINE_ANYCRLF);
#else
pcrecpp::RE_Options options;
#endif
if (modifiers) {
char c = '\0';
@@ -67,12 +53,11 @@ inline pcrecpp::RE_Options app_pcre_get_options(const char* modifiers)
/// Accept pattern in form of "/pattern/modifiers".
/// Note: Slashes should be escaped within the pattern.
/// If the string doesn't start with a slash, it is treated as an ordinary pattern
/// without modifiers.
/// This function will make a RE object with ANYCRLF option set for portability
/// across various pcre builds.
// Accept pattern in form of "/pattern/modifiers".
// Note: Slashes should be escaped within the pattern.
// If the string doesn't start with a slash, it is treated as an ordinary pattern
// without modifiers.
inline pcrecpp::RE app_pcre_re(const std::string& perl_pattern)
{
if (perl_pattern.size() >= 2 && perl_pattern[0] == '/') {
@@ -86,12 +71,12 @@ inline pcrecpp::RE app_pcre_re(const std::string& perl_pattern)
app_pcre_get_options(perl_pattern.substr(endpos + 1).c_str()));
}
return pcrecpp::RE(perl_pattern, app_pcre_get_options(0));
return pcrecpp::RE(perl_pattern);
}
/// Match a string against a pattern in "/pattern/modifiers" format.
inline bool app_pcre_match(const std::string& perl_pattern, const std::string& str,
const pcrecpp::Arg& ptr1 = pcrecpp::RE::no_arg,
const pcrecpp::Arg& ptr2 = pcrecpp::RE::no_arg,
@@ -115,9 +100,7 @@ inline bool app_pcre_match(const std::string& perl_pattern, const std::string& s
}
/// Match a string against a pattern in "/pattern/modifiers" format.
/// This overload is needed to avoid confusion with RE.
// This is needed to avoid confusion with RE.
inline bool app_pcre_match(const char* perl_pattern, const std::string& str,
const pcrecpp::Arg& ptr1 = pcrecpp::RE::no_arg,
const pcrecpp::Arg& ptr2 = pcrecpp::RE::no_arg,
@@ -141,8 +124,6 @@ inline bool app_pcre_match(const char* perl_pattern, const std::string& str,
}
/// Match a string against a pattern in "/pattern/modifiers" format.
inline bool app_pcre_match(const pcrecpp::RE& re, const std::string& str,
const pcrecpp::Arg& ptr1 = pcrecpp::RE::no_arg,
const pcrecpp::Arg& ptr2 = pcrecpp::RE::no_arg,
@@ -167,23 +148,22 @@ inline bool app_pcre_match(const pcrecpp::RE& re, const std::string& str,
/// Replace every occurence of pattern with replacement string in \c subject.
/// The pattern is in "/pattern/modifiers" format.
// Replaces every occurence of pattern with replacement in subject.
inline int app_pcre_replace(const std::string& perl_pattern, const std::string& replacement, std::string& subject)
{
return app_pcre_re(perl_pattern).GlobalReplace(replacement, &subject);
}
/// Replace every occurence of pattern with replacement string in \c subject.
/// The pattern is in "/pattern/modifiers" format.
// Replaces every occurence of pattern with replacement in subject.
inline int app_pcre_replace(const char* perl_pattern, const std::string& replacement, std::string& subject)
{
return app_pcre_replace(std::string(perl_pattern), replacement, subject);
}
/// Replace every occurence of pattern with replacement string in \c subject.
// Replaces every occurence of pattern with replacement in subject.
inline int app_pcre_replace(const pcrecpp::RE& re, const std::string& replacement, std::string& subject)
{
return re.GlobalReplace(replacement, &subject);
@@ -191,25 +171,22 @@ inline int app_pcre_replace(const pcrecpp::RE& re, const std::string& replacemen
/// Replace the first occurence of pattern with replacement string in \c subject.
/// The pattern is in "/pattern/modifiers" format.
// Replaces first occurence of pattern with replacement in subject.
inline bool app_pcre_replace_once(const std::string& perl_pattern, const std::string& replacement, std::string& subject)
{
return app_pcre_re(perl_pattern).Replace(replacement, &subject);
}
/// Replace the first occurence of pattern with replacement string in \c subject.
/// The pattern is in "/pattern/modifiers" format.
// Replaces first occurence of pattern with replacement in subject.
inline bool app_pcre_replace_once(const char* perl_pattern, const std::string& replacement, std::string& subject)
{
return app_pcre_replace_once(std::string(perl_pattern), replacement, subject);
}
/// Replace first occurence of pattern with replacement string in \c subject.
// Replaces first occurence of pattern with replacement in subject.
inline bool app_pcre_replace_once(const pcrecpp::RE& re, const std::string& replacement, std::string& subject)
{
return re.Replace(replacement, &subject);
@@ -217,17 +194,8 @@ inline bool app_pcre_replace_once(const pcrecpp::RE& re, const std::string& repl
/// Escape a string to be used inside a regular expression. The result
/// won't contain any special expression characters.
inline std::string app_pcre_escape(const std::string& str)
{
return pcrecpp::RE::QuoteMeta(str);
}
#endif
/// @}
+217 -87
View File
@@ -1,28 +1,31 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#ifndef APP_UI_RES_UTILS_H
#define APP_UI_RES_UTILS_H
#include <string>
#include <gtkmm.h>
#include <gtkmm/window.h>
#include "hz/hz_config.h" // feature test macros (ENABLE_*)
#if defined ENABLE_LIBGLADEMM
#include <libglademm.h>
#elif defined ENABLE_GTKBUILDER
#include <gtkmm/builder.h>
#endif
// Old glibmm versions had exceptions but didn't define this at all.
// New ones define it to 0 if there are no glibmm exceptions.
#if !defined GLIBMM_EXCEPTIONS_ENABLED || GLIBMM_EXCEPTIONS_ENABLED
#if GLIBMM_EXCEPTIONS_ENABLED
#include <memory> // std::auto_ptr
#endif
#include "app_gtkmm_features.h" // APP_GTKMM_OLD_TOOLTIPS
#ifdef APP_GTKMM_OLD_TOOLTIPS
#include <gtk/gtk.h> // gtk_tooltips_*
#endif
#include "hz/debug.h"
#include "hz/instance_manager.h"
#include "hz/down_cast.h"
@@ -32,68 +35,159 @@
/// \def APP_UI_RES_DATA_INIT(res_name)
/// Use these in window class definitions to declare ui resources.
/// E.g. APP_UI_RES_DATA_INIT(main_window) will search for
/// main_window.ui in data file search paths.
/// Or, if you're using compiled-in buffers, it will make them available.
#define APP_UI_RES_DATA_INIT(res_name) \
HZ_RES_DATA_INIT_NAMED(res_name##_ui, #res_name ".ui", UIResDataBase); \
struct UIResData : public UIResDataBase { \
UIResData() \
{ \
UIResDataBase::root_name = #res_name; /* we need original name here, not with _ui */ \
} \
}
// Use these in window class definitions to declare ui resources.
// E.g. HZ_RES_DATA_INIT(main_window) will search for
// main_window.glade or main_window.ui (depending on whether
// you're using libglade or gtkbuilder) in data file search paths.
// Or, if you're using compiled-in buffers, it will make them available.
#if defined ENABLE_LIBGLADEMM
/// \typedef app_ui_res_ref_t
/// A reference-counting pointer to application UI resource
typedef Glib::RefPtr<Gtk::Builder> app_ui_res_ref_t;
#define APP_UI_RES_DATA_INIT(res_name) \
HZ_RES_DATA_INIT_NAMED(res_name##_ui, #res_name ".glade", UIResDataBase); \
struct UIResData : public UIResDataBase { \
UIResData() \
{ \
UIResDataBase::root_name = #res_name; /* we need original name here, not with _ui */ \
} \
};
/// \fn bool app_ui_res_create_from(app_ui_res_ref_t& ref, const unsigned char* buf, unsigned int buf_size, std::string& error_msg)
/// Create application UI resource from a static buffer.
inline bool app_ui_res_create_from(app_ui_res_ref_t& ref,
const unsigned char* buf, unsigned int buf_size, std::string& error_msg)
{
if (!buf_size || !buf || !buf[0]) {
error_msg = "Cannot load data buffers.";
return false;
}
#elif defined ENABLE_GTKBUILDER
#if !defined GLIBMM_EXCEPTIONS_ENABLED || GLIBMM_EXCEPTIONS_ENABLED
try {
// ref->add_from_file("main_window.ui");
ref->add_from_string(reinterpret_cast<const char*>(buf), static_cast<gsize>(buf_size));
}
catch (Gtk::BuilderError& ex) { // the docs say Glib::MarkupError, but examples say otherwise.
error_msg = ex.what();
return false;
}
#define APP_UI_RES_DATA_INIT(res_name) \
HZ_RES_DATA_INIT_NAMED(res_name##_ui, #res_name ".ui", UIResDataBase); \
struct UIResData : public UIResDataBase { \
UIResData() \
{ \
UIResDataBase::root_name = #res_name; /* we need original name here, not with _ui */ \
} \
};
#else
std::auto_ptr<Glib::BuilderError> error;
ref->add_from_string(reinterpret_cast<const char*>(buf), static_cast<gsize>(buf_size),"", "", error);
#else // none, just avoid errors
#define APP_UI_RES_DATA_INIT(res_name) \
HZ_RES_DATA_DUMMY_INIT_NAMED(res_name##_ui, 0, UIResDataBase); \
struct UIResData : public UIResDataBase { \
UIResData() \
{ \
UIResDataBase::root_name = #res_name; /* we need original name here, not with _ui */ \
} \
};
if (error.get()) {
error_msg = error->what();
return false;
}
#endif
return true;
}
#if defined ENABLE_LIBGLADEMM
typedef Glib::RefPtr<Gnome::Glade::Xml> app_ui_res_ref_t;
inline bool app_ui_res_create_from(app_ui_res_ref_t& ref,
const unsigned char* buf, unsigned int buf_size, std::string& error_msg)
{
if (!buf_size || !buf || !buf[0]) {
error_msg = "Cannot load data buffers.";
return false;
}
#if GLIBMM_EXCEPTIONS_ENABLED
try {
// Glib::RefPtr<Gnome::Glade::Xml> ref = Gnome::Glade::Xml::create("main_window.glade");
ref = Gnome::Glade::Xml::create_from_buffer(reinterpret_cast<const char*>(buf),
static_cast<int>(buf_size));
}
catch (Gnome::Glade::XmlError& ex) {
error_msg = ex.what();
return false;
}
#else
std::auto_ptr<Gnome::Glade::XmlError> error;
ref = Gnome::Glade::Xml::create_from_buffer(reinterpret_cast<const char*>(buf),
static_cast<int>(buf_size),"", "", error);
if (error.get()) {
error_msg = error->what();
return false;
}
#endif
return true;
}
#elif defined ENABLE_GTKBUILDER
typedef Glib::RefPtr<Gtk::Builder> app_ui_res_ref_t;
inline bool app_ui_res_create_from(app_ui_res_ref_t& ref,
const unsigned char* buf, unsigned int buf_size, std::string& error_msg)
{
if (!buf_size || !buf || !buf[0]) {
error_msg = "Cannot load data buffers.";
return false;
}
#if GLIBMM_EXCEPTIONS_ENABLED
try {
// ref->add_from_file("main_window.ui");
ref->add_from_string(reinterpret_cast<const char*>(buf), static_cast<gsize>(buf_size));
}
catch (Gtk::BuilderError& ex) { // the docs say Glib::MarkupError, but examples say otherwise.
error_msg = ex.what();
return false;
}
#else
std::auto_ptr<Glib::BuilderError> error;
ref->add_from_string(reinterpret_cast<const char*>(buf), static_cast<gsize>(buf_size),"", "", error);
if (error.get()) {
error_msg = error->what();
return false;
}
#endif
return true;
}
#else // none, just avoid compilation errors
struct AppUIResDummy {
template<typename T>
void get_widget_derived(const Glib::ustring& name, T*& widget)
{ }
template<typename T>
void get_widget(const Glib::ustring& name, T*& widget)
{ }
};
typedef AppUIResDummy* app_ui_res_ref_t;
inline bool app_ui_res_create_from(app_ui_res_ref_t& ref,
const unsigned char* buf, unsigned int buf_size, std::string& error_msg)
{
return false;
}
#endif
// These allow easy attaching of gtkbuilder widget signals to member functions
// These allow easy attaching of glade widget signals to member functions
/// Connect member function (callback) to signal \c signal_name on widget
/// \c ui_element, where \c ui_element is the widget's gtkbuilder name.
// Connect member function (callback) to signal signal_name on widget
// widget_name, where widget_name is the widget's glade/gtkbuilder name.
#define APP_UI_RES_CONNECT(ui_element, signal_name, callback) \
if (true) { \
if (!ui_element) \
@@ -104,9 +198,7 @@ inline bool app_ui_res_create_from(app_ui_res_ref_t& ref,
} else (void)0
/// Connect member function (callback) with a name of \c on_<widget_name>_<signal_name>
/// to signal \c signal_name on widget \c ui_element, where \c ui_element is the
/// widget's gtkbuilder name.
// Same as above, but default callback name to on_<widget_name>_<signal_name>.
#define APP_UI_RES_AUTO_CONNECT(ui_element, signal_name) \
APP_UI_RES_CONNECT(ui_element, signal_name, on_ ## ui_element ## _ ## signal_name)
@@ -114,29 +206,38 @@ inline bool app_ui_res_create_from(app_ui_res_ref_t& ref,
/// Inherit this when using GtkBuilder-enabled windows (or any other GtkBuilder-enabled objects).
/// \c Child is the child class that inherits all the functionality of having instance lifetime
/// management and other benefits.
/// If \c MultiInstance is false, create() will return the same instance each time.
// Inherit from this when using Glade-enabled windows (or any other objects).
template<class Child, bool MultiInstance, class WidgetType = Gtk::Window>
class AppUIResWidget : public WidgetType, public hz::InstanceManager<Child, MultiInstance> {
public:
/// Instance class type, which is also the parent class.
typedef hz::InstanceManager<Child, MultiInstance> instance_class;
#if defined ENABLE_LIBGLADEMM
friend class Gnome::Glade::Xml; // allow construction through libglade
#elif defined ENABLE_GTKBUILDER
friend class Gtk::Builder; // allow construction through gtkbuilder
#endif
friend class hz::InstanceManager<Child, MultiInstance>; // allow construction through instance class
/// Override parent hz::InstanceManager's function because of non-trivial constructor
// overload parent's function because of non-trivial constructor
static Child* create()
{
if (hz::InstanceManager<Child, MultiInstance>::has_single_instance()) // for single-instance objects
return hz::InstanceManager<Child, MultiInstance>::get_single_instance();
std::string error;
#if defined ENABLE_LIBGLADEMM
app_ui_res_ref_t ui;
#elif defined ENABLE_GTKBUILDER
app_ui_res_ref_t ui = Gtk::Builder::create();
const typename Child::UIResData data; // this holds the GtkBuilder data
#else // none, just avoid compilation errors
app_ui_res_ref_t ui = 0;
#endif
const typename Child::UIResData data; // this holds the glade data
// this does the actual object construction
bool success = app_ui_res_create_from(ui, data.buf, data.size, error);
@@ -166,21 +267,19 @@ class AppUIResWidget : public WidgetType, public hz::InstanceManager<Child, Mult
}
/// Get UI resource
app_ui_res_ref_t get_ui()
{
return ref_ui_;
}
/// Find a widget in UI and return it.
Gtk::Widget* lookup_widget(const Glib::ustring& name)
{
return lookup_widget<Gtk::Widget*>(name);
}
/// Find a widget in UI and return it.
template<typename WidgetPtr>
WidgetPtr lookup_widget(const Glib::ustring& name)
{
@@ -188,8 +287,6 @@ class AppUIResWidget : public WidgetType, public hz::InstanceManager<Child, Mult
return lookup_widget(name, w);
}
/// Find a widget in UI and return it.
template<typename WidgetPtr>
WidgetPtr lookup_widget(const Glib::ustring& name, WidgetPtr& w)
{
@@ -198,14 +295,17 @@ class AppUIResWidget : public WidgetType, public hz::InstanceManager<Child, Mult
}
/// Find an object in UI and return it.
Glib::Object* lookup_object(const Glib::ustring& name)
{
#if defined ENABLE_LIBGLADEMM
return static_cast<Glib::Object*>(lookup_widget(name)); // all glade objects are widgets, it's an upcast
#elif defined ENABLE_GTKBUILDER
return ref_ui_->get_object(name).operator->(); // silly RefPtr doesn't have get().
#else // none, just avoid compilation errors
return 0;
#endif
}
/// Find an object in UI and return it.
template<typename ObjectPtr>
ObjectPtr lookup_object(const Glib::ustring& name)
{
@@ -213,8 +313,6 @@ class AppUIResWidget : public WidgetType, public hz::InstanceManager<Child, Mult
return lookup_object(name, obj);
}
/// Find an object in UI and return it.
template<typename ObjectPtr>
ObjectPtr lookup_object(const Glib::ustring& name, ObjectPtr& obj)
{
@@ -225,21 +323,28 @@ class AppUIResWidget : public WidgetType, public hz::InstanceManager<Child, Mult
protected:
typedef Child self_type; ///< This is needed by APP_UI_ macros
typedef WidgetType widget_type; ///< This is needed by APP_UI_ macros
// This is needed by APP_GLADE_ macros
typedef Child self_type;
// protected constructor / destructor, use create() / destroy() instead of new / delete.
/// GtkBuilder needs this constructor in a child.
/// BaseObjectType is a C type, defined in specific Gtk:: widget class.
// glade needs this constructor in a child.
// BaseObjectType is a C type, defined in specific Gtk:: widget class.
AppUIResWidget(typename WidgetType::BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui)
: WidgetType(gtkcobj), ref_ui_(ref_ui)
{
// if gtkmm is older than 2.12, use the old tooltips API
#ifdef APP_GTKMM_OLD_TOOLTIPS
// attach it to the window
this->create_tooltips_data(this);
#endif
// manually connecting signals:
// this->signal_delete_event().connect(sigc::mem_fun(*this, &MainWindow::on_main_window_delete));
// signals of GtkBuilder-created objects:
// signals of glade-created objects:
// Gtk::ToolButton* rescan_devices_toolbutton = 0;
// APP_UI_RES_AUTO_CONNECT(rescan_devices_toolbutton, clicked);
@@ -247,14 +352,39 @@ class AppUIResWidget : public WidgetType, public hz::InstanceManager<Child, Mult
}
/// Virtual destructor
virtual ~AppUIResWidget()
{ }
#ifdef APP_GTKMM_OLD_TOOLTIPS
// differentiate Window and its children from other widgets through overloading
void create_tooltips_data(Gtk::Window* window)
{
if (window) {
// gtkmm tooltips api is somewhat broken (no create?), so use gtk
if (!window->get_data("window_tooltips")) {
window->set_data("window_tooltips", gtk_tooltips_new());
}
}
}
void create_tooltips_data(Gtk::Object* o)
{ }
#endif
protected:
// void on_rescan_devices_toolbutton_clicked()
// {
// }
private:
app_ui_res_ref_t ref_ui_; ///< UI resource
app_ui_res_ref_t ref_ui_;
};
@@ -263,6 +393,6 @@ class AppUIResWidget : public WidgetType, public hz::InstanceManager<Child, Mult
#endif
/// @}
#endif
-110
View File
@@ -1,110 +0,0 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_unlicense.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib_tests
/// \weakgroup applib_tests
/// @{
#include <iostream>
#include <gtkmm.h>
#include "app_ui_res_utils.h"
// #include "hz/instance_manager.h"
class AppUiResTestWindow;
/// Window for the resource utilities test
class AppUiResTestWindow : public AppUIResWidget<AppUiResTestWindow, false>
{
public:
// name of ui file without a .ui extension and quotes
APP_UI_RES_DATA_INIT(app_ui_res_test_window);
/// Action types
enum action_t {
action_quit ///< Quit action
};
/// Constructor
AppUiResTestWindow(BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui)
: AppUIResWidget<AppUiResTestWindow, false>(gtkcobj, ref_ui)
{
Gtk::Box* vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 5));
add(*vbox);
Gtk::Button* button = Gtk::manage(new Gtk::Button("Clicky"));
vbox->pack_start(*button, Gtk::PACK_SHRINK);
// button->signal_clicked().connect(sigc::mem_fun(*this, &AppUiResTestWindow::on_button_clicked));
button->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &AppUiResTestWindow::on_button_clicked2), action_quit));
Gtk::Label* label = Gtk::manage(new Gtk::Label("test"));
vbox->pack_start(*label, Gtk::PACK_SHRINK);
this->signal_delete_event().connect(sigc::mem_fun(*this, &AppUiResTestWindow::on_delete_event));
show_all();
}
/// Virtual destructor
virtual ~AppUiResTestWindow()
{ }
private:
/// Action callback
void on_button_clicked()
{
std::cerr << "AppUiResTestWindow::on_button_clicked()\n";
}
/// Action callback
void on_button_clicked2(action_t action_type)
{
std::cerr << "AppUiResTestWindow::on_button_clicked2()\n";
}
/// Action callback
bool on_delete_event(GdkEventAny* e)
{
Gtk::Main::quit();
return true; // action handled
}
};
/// Main function of the test
int main(int argc, char *argv[])
{
Gtk::Main m(&argc, &argv);
// AppUiResTestWindow* app = new AppUiResTestWindow();
AppUiResTestWindow::create();
m.run();
// delete app;
AppUiResTestWindow::destroy();
return(0);
}
/// @}
-242
View File
@@ -1,242 +0,0 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_unlicense.txt
***************************************************************************/
// A simple empty window definition
extern const unsigned char app_ui_res_test_window_ui[] = {
0x3C,
0x3F,
0x78,
0x6D,
0x6C,
0x20,
0x76,
0x65,
0x72,
0x73,
0x69,
0x6F,
0x6E,
0x3D,
0x22,
0x31,
0x2E,
0x30,
0x22,
0x3F,
0x3E,
0xA,
0x3C,
0x69,
0x6E,
0x74,
0x65,
0x72,
0x66,
0x61,
0x63,
0x65,
0x3E,
0xA,
0x20,
0x20,
0x3C,
0x6F,
0x62,
0x6A,
0x65,
0x63,
0x74,
0x20,
0x63,
0x6C,
0x61,
0x73,
0x73,
0x3D,
0x22,
0x47,
0x74,
0x6B,
0x57,
0x69,
0x6E,
0x64,
0x6F,
0x77,
0x22,
0x20,
0x69,
0x64,
0x3D,
0x22,
0x61,
0x70,
0x70,
0x5F,
0x75,
0x69,
0x5F,
0x72,
0x65,
0x73,
0x5F,
0x74,
0x65,
0x73,
0x74,
0x5F,
0x77,
0x69,
0x6E,
0x64,
0x6F,
0x77,
0x22,
0x3E,
0xA,
0x20,
0x20,
0x20,
0x20,
0x3C,
0x70,
0x72,
0x6F,
0x70,
0x65,
0x72,
0x74,
0x79,
0x20,
0x6E,
0x61,
0x6D,
0x65,
0x3D,
0x22,
0x74,
0x69,
0x74,
0x6C,
0x65,
0x22,
0x20,
0x74,
0x72,
0x61,
0x6E,
0x73,
0x6C,
0x61,
0x74,
0x61,
0x62,
0x6C,
0x65,
0x3D,
0x22,
0x79,
0x65,
0x73,
0x22,
0x3E,
0x54,
0x65,
0x73,
0x74,
0x3C,
0x2F,
0x70,
0x72,
0x6F,
0x70,
0x65,
0x72,
0x74,
0x79,
0x3E,
0xA,
0x20,
0x20,
0x20,
0x20,
0x3C,
0x63,
0x68,
0x69,
0x6C,
0x64,
0x3E,
0xA,
0x20,
0x20,
0x20,
0x20,
0x20,
0x20,
0x3C,
0x70,
0x6C,
0x61,
0x63,
0x65,
0x68,
0x6F,
0x6C,
0x64,
0x65,
0x72,
0x2F,
0x3E,
0xA,
0x20,
0x20,
0x20,
0x20,
0x3C,
0x2F,
0x63,
0x68,
0x69,
0x6C,
0x64,
0x3E,
0xA,
0x20,
0x20,
0x3C,
0x2F,
0x6F,
0x62,
0x6A,
0x65,
0x63,
0x74,
0x3E,
0xA,
0x3C,
0x2F,
0x69,
0x6E,
0x74,
0x65,
0x72,
0x66,
0x61,
0x63,
0x65,
0x3E,
0xA,
0x0 };
extern const unsigned int app_ui_res_test_window_ui_size = 224;
-247
View File
@@ -1,247 +0,0 @@
/**************************************************************************
Copyright:
(C) 2011 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#ifndef CLI_EXECUTORS_H
#define CLI_EXECUTORS_H
#include "cmdex.h"
#include "cmdex_sync.h"
/// Executor for tw_cli (3ware utility)
template<class ExecutorSync>
class TwCliExecutorGeneric : public ExecutorSync {
public:
/// Constructor
TwCliExecutorGeneric(const std::string& cmd, const std::string& cmdargs)
: ExecutorSync(cmd, cmdargs)
{
this->construct();
}
/// Constructor
TwCliExecutorGeneric()
{
this->construct();
}
/// Virtual destructor
virtual ~TwCliExecutorGeneric()
{ }
protected:
/// Called from constructors
void construct()
{
ExecutorSync::get_command_executor().set_exit_status_translator(&TwCliExecutorGeneric::translate_exit_status, NULL);
this->set_error_header("An error occurred while executing tw_cli:\n\n");
}
/// Exit status translate handler
static std::string translate_exit_status(int status, void* user_data)
{
return std::string();
}
/// Import the last error from command executor and clear all errors there
virtual void import_error()
{
Cmdex& cmdex = this->get_command_executor();
cmdex.errors_lock();
Cmdex::error_list_t errors = cmdex.get_errors(false); // these are not clones
hz::ErrorBase* e = 0;
// find the last relevant error.
// note: const_reverse_iterator doesn't work on gcc 3, so don't do it.
for (Cmdex::error_list_t::reverse_iterator iter = errors.rbegin(); iter != errors.rend(); ++iter) {
// ignore iochannel errors, they may mask the real errors
if ((*iter)->get_type() != "giochannel" && (*iter)->get_type() != "custom") {
e = (*iter)->clone();
break;
}
}
cmdex.clear_errors(false); // and clear them
cmdex.errors_unlock();
if (e) { // if error is present, alert the user
on_error_warn(e);
}
}
/// This is called when an error occurs in command executor.
/// Note: The warnings are already printed via debug_* in cmdex.
virtual void on_error_warn(hz::ErrorBase* e)
{
if (!e)
return;
// import the error only if it's relevant.
std::string error_type = e->get_type();
// ignore giochannel errors - higher level errors will be triggered, and they more user-friendly.
if (error_type == "giochannel" || error_type == "custom") {
return;
}
this->set_error_msg(e->get_message());
}
};
/// tw_cli executor without GUI support
typedef TwCliExecutorGeneric<CmdexSync> TwCliExecutor;
/// A reference-counting pointer to TwCliExecutor
typedef hz::intrusive_ptr<TwCliExecutor> TwCliExecutorRefPtr;
/// tw_cli executor with GUI support
typedef TwCliExecutorGeneric<CmdexSyncGui> TwCliExecutorGui;
/// A reference-counting pointer to TwCliExecutorGui
typedef hz::intrusive_ptr<TwCliExecutorGui> TwCliExecutorGuiRefPtr;
/// Executor for cli (Areca utility)
template<class ExecutorSync>
class ArecaCliExecutorGeneric : public ExecutorSync {
public:
/// Constructor
ArecaCliExecutorGeneric(const std::string& cmd, const std::string& cmdargs)
: ExecutorSync(cmd, cmdargs)
{
this->construct();
}
/// Constructor
ArecaCliExecutorGeneric()
{
this->construct();
}
/// Virtual destructor
virtual ~ArecaCliExecutorGeneric()
{ }
protected:
/// Called from constructors
void construct()
{
ExecutorSync::get_command_executor().set_exit_status_translator(&ArecaCliExecutorGeneric::translate_exit_status, NULL);
this->set_error_header("An error occurred while executing Areca cli:\n\n");
}
/// Exit status translate handler
static std::string translate_exit_status(int status, void* user_data)
{
return std::string();
}
/// Import the last error from command executor and clear all errors there
virtual void import_error()
{
Cmdex& cmdex = this->get_command_executor();
cmdex.errors_lock();
Cmdex::error_list_t errors = cmdex.get_errors(false); // these are not clones
hz::ErrorBase* e = 0;
// find the last relevant error.
// note: const_reverse_iterator doesn't work on gcc 3, so don't do it.
for (Cmdex::error_list_t::reverse_iterator iter = errors.rbegin(); iter != errors.rend(); ++iter) {
// ignore iochannel errors, they may mask the real errors
if ((*iter)->get_type() != "giochannel" && (*iter)->get_type() != "custom") {
e = (*iter)->clone();
break;
}
}
cmdex.clear_errors(false); // and clear them
cmdex.errors_unlock();
if (e) { // if error is present, alert the user
on_error_warn(e);
}
}
/// This is called when an error occurs in command executor.
/// Note: The warnings are already printed via debug_* in cmdex.
virtual void on_error_warn(hz::ErrorBase* e)
{
if (!e)
return;
// import the error only if it's relevant.
std::string error_type = e->get_type();
// ignore giochannel errors - higher level errors will be triggered, and they more user-friendly.
if (error_type == "giochannel" || error_type == "custom") {
return;
}
this->set_error_msg(e->get_message());
}
};
/// tw_cli executor without GUI support
typedef ArecaCliExecutorGeneric<CmdexSync> ArecaCliExecutor;
/// A reference-counting pointer to ArecaCliExecutor
typedef hz::intrusive_ptr<ArecaCliExecutor> ArecaCliExecutorRefPtr;
/// tw_cli executor with GUI support
typedef ArecaCliExecutorGeneric<CmdexSyncGui> ArecaCliExecutorGui;
/// A reference-counting pointer to ArecaCliExecutorGui
typedef hz::intrusive_ptr<ArecaCliExecutorGui> ArecaCliExecutorGuiRefPtr;
#endif
/// @}
+318 -240
View File
@@ -1,35 +1,31 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#include <sys/types.h>
#include <cerrno> // errno (not std::errno, it may be a macro)
#ifdef _WIN32
// #include <io.h> // close()
#include <io.h> // close()
#else
#include <sys/wait.h> // waitpid()'s W* macros
// #include <unistd.h> // close()
#include <unistd.h> // close()
#endif
#include "hz/process_signal.h" // hz::process_signal_send, win32's W*
#include <glibmm/shell.h>
#include <glibmm/miscutils.h> // get_current_dir()
#include <glibmm/convert.h>
#include "hz/tls.h"
#include "hz/tls_policy_glib.h"
#include "hz/debug.h"
#include "hz/string_num.h" // hz::number_to_string()
#include "hz/env_tools.h" // hz::ScopedEnv
#include "hz/scoped_ptr.h"
#include "cmdex.h"
using hz::Error;
using hz::ErrorLevel;
@@ -42,29 +38,43 @@ extern "C" {
// callbacks
/// Child process watcher callback
inline void cmdex_child_watch_handler(GPid arg_pid, int waitpid_status, gpointer data)
// NOTE: These functions are called in a separate threads!
inline void command_executor_child_watch_handler(GPid arg_pid, int waitpid_status, gpointer data)
{
Cmdex::on_child_watch_handler(arg_pid, waitpid_status, data);
}
/// Child process stdout handler callback
inline gboolean cmdex_on_channel_io_stdout(GIOChannel* source, GIOCondition cond, gpointer data)
inline gboolean command_executor_on_channel_io_stdout_as_available(GIOChannel* source, GIOCondition cond, gpointer data)
{
return Cmdex::on_channel_io(source, cond, static_cast<Cmdex*>(data), Cmdex::channel_type_stdout);
return Cmdex::on_channel_io_as_available(source, cond, static_cast<Cmdex*>(data), Cmdex::channel_type_stdout);
}
inline gboolean command_executor_on_channel_io_stderr_as_available(GIOChannel* source, GIOCondition cond, gpointer data)
{
return Cmdex::on_channel_io_as_available(source, cond, static_cast<Cmdex*>(data), Cmdex::channel_type_stderr);
}
/// Child process stderr handler callback
inline gboolean cmdex_on_channel_io_stderr(GIOChannel* source, GIOCondition cond, gpointer data)
inline gboolean command_executor_on_channel_io_stdout_buffered(GIOChannel* source, GIOCondition cond, gpointer data)
{
return Cmdex::on_channel_io(source, cond, static_cast<Cmdex*>(data), Cmdex::channel_type_stderr);
return Cmdex::on_channel_io_buffered(source, cond, static_cast<Cmdex*>(data), Cmdex::channel_type_stdout);
}
inline gboolean command_executor_on_channel_io_stderr_buffered(GIOChannel* source, GIOCondition cond, gpointer data)
{
return Cmdex::on_channel_io_buffered(source, cond, static_cast<Cmdex*>(data), Cmdex::channel_type_stderr);
}
/// Child process termination timeout handler
inline gboolean cmdex_on_term_timeout(gpointer data)
inline void command_executor_on_buffered_source_destroy(gpointer data);
// this is executed in another thread!
inline gboolean command_executor_on_term_timeout(gpointer data)
{
DBG_FUNCTION_ENTER_MSG;
Cmdex* self = static_cast<Cmdex*>(data);
@@ -73,12 +83,12 @@ extern "C" {
}
/// Child process kill timeout handler
inline gboolean cmdex_on_kill_timeout(gpointer data)
// this is executed in another thread!
inline gboolean command_executor_on_kill_timeout(gpointer data)
{
DBG_FUNCTION_ENTER_MSG;
Cmdex* self = static_cast<Cmdex*>(data);
self->try_stop(hz::SIGNAL_SIGKILL);
self->try_stop(hz::SIGNAL_SIGTERM);
return false; // one-time call
}
@@ -92,157 +102,132 @@ extern "C" {
bool Cmdex::execute()
{
DBG_FUNCTION_ENTER_MSG;
if (this->running_ || this->stopped_cleanup_needed()) {
ScopedLock locker(object_mutex_);
if (this->running || this->stopped_cleanup_needed(false))
return false;
}
cleanup_members();
clear_errors();
str_stdout_.clear();
str_stderr_.clear();
clear_errors(false); // don't lock
str_stdout.clear();
str_stderr.clear();
std::string cmd = command_exec_ + " " + command_args_;
std::string cmd = command_exec + " " + command_args;
std::deque<std::string> child_argv;
// Make command vector
hz::scoped_ptr<gchar*> argvp(0, g_strfreev); // args vector
{
int argcp = 0; // number of args
hz::scoped_ptr<GError> shell_error(0, g_error_free);
if (!g_shell_parse_argv(cmd.c_str(), &argcp, &argvp.get_ref(), &shell_error.get_ref())) {
push_error(Error<void>("gshell", ErrorLevel::error, shell_error->message), false);
return false;
}
try {
child_argv = Glib::shell_parse_argv(cmd);
}
// Set the locale for a child to Classic - otherwise it may mangle the output.
// TODO: make this controllable.
bool change_lang = true;
#ifdef _WIN32
// LANG is posix-only, so it has no effect on win32.
// Unfortunately, I was unable to find a way to execute a child with a different
// locale in win32. Locale seems to be non-inheritable, so setting it here won't help.
change_lang = false;
#endif
hz::ScopedEnv lang_env("LANG", "C", change_lang);
debug_out_info("app", DBG_FUNC_MSG << "Executing \"" << cmd << "\".\n");
/*
if (argvp) {
debug_out_dump("app", DBG_FUNC_MSG << "Dumping argvp:\n");
gchar** elem = argvp.get();
while (*elem) {
debug_out_dump("app", *elem << "\n");
++elem;
}
}
*/
// Execute the command
hz::scoped_ptr<gchar> curr_dir(g_get_current_dir(), g_free);
hz::scoped_ptr<GError> spawn_error(0, g_error_free);
/*
#if defined APP_CMDEX_USE_SYNC && APP_CMDEX_USE_SYNC
hz::scoped_ptr<gchar*> stdout_str(0, g_free);
hz::scoped_ptr<gchar*> stderr_str(0, g_free);
gint exit_status = 0;
g_timer_start(timer_); // start the timer
if (!g_spawn_sync(curr_dir.get(), argvp.get(), NULL,
GSpawnFlags(G_SPAWN_SEARCH_PATH),
NULL, NULL, // child setup function
&stdout_str.get_ref(), &stderr_str.get_ref(), &exit_status, &spawn_error.get_ref()))
{
// no data is returned to &-parameters on error.
push_error(Error<void>("gspawn", ErrorLevel::error, spawn_error->message), false);
catch (Glib::ShellError& e) {
push_error(Error<Glib::ShellError>("gshell", ErrorLevel::error, e, e.what()), false);
return false;
}
#else // async way:
*/
if (!g_spawn_async_with_pipes(curr_dir.get(), argvp.get(), NULL,
GSpawnFlags(G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD),
NULL, NULL, // child setup function
&this->pid_, 0, &fd_stdout_, &fd_stderr_, &spawn_error.get_ref()))
{
// no data is returned to &-parameters on error.
push_error(Error<void>("gspawn", ErrorLevel::error, spawn_error->message), false);
// Reset the locale - otherwise it may mangle the output.
bool old_lang_set = false;
std::string old_lang = Glib::getenv("LANG", old_lang_set);
if (old_lang_set)
Glib::setenv("LANG", "C");
try {
// execute the command
debug_out_info("app", DBG_FUNC_MSG << "Executing \"" << cmd << "\".\n");
Glib::spawn_async_with_pipes(Glib::get_current_dir(), child_argv,
Glib::SPAWN_SEARCH_PATH | Glib::SPAWN_DO_NOT_REAP_CHILD,
sigc::slot<void>(), &this->pid,
0, &fd_stdout, &fd_stderr);
}
catch (Glib::SpawnError& e) {
push_error(Error<Glib::SpawnError>("gspawn", ErrorLevel::error, e, e.what()), false);
if (old_lang_set)
Glib::setenv("LANG", old_lang);
return false;
}
g_timer_start(timer_); // start the timer
// #endif
if (old_lang_set)
Glib::setenv("LANG", old_lang);
#ifdef _WIN32
channel_stdout_ = g_io_channel_win32_new_fd(fd_stdout_);
channel_stderr_ = g_io_channel_win32_new_fd(fd_stderr_);
#else
channel_stdout_ = g_io_channel_unix_new(fd_stdout_);
channel_stderr_ = g_io_channel_unix_new(fd_stderr_);
#endif
this->timer.start(); // start the timer
#ifdef _WIN32
channel_stdout = Glib::IOChannel::create_from_win32_fd(fd_stdout);
channel_stderr = Glib::IOChannel::create_from_win32_fd(fd_stderr);
#else
channel_stdout = Glib::IOChannel::create_from_fd(fd_stdout);
channel_stderr = Glib::IOChannel::create_from_fd(fd_stderr);
#endif
// The internal encoding is always UTF8. To read command output correctly, use
// "" for binary data, or set io encoding to current locale.
// If using locales, call g_locale_to_utf8() or g_convert() afterwards.
// If using locales, call Glib::locale_to_utf8() or Glib::convert() afterwards.
// blocking writes if the pipe is full helps for small-pipe systems (see man 7 pipe).
int channel_flags = ~G_IO_FLAG_NONBLOCK;
// std::string charset;
// Glib::get_charset(charset);
try {
channel_stdout->set_encoding(""); // binary IO
channel_stderr->set_encoding(""); // binary IO
// Note about GError's here:
// What do we do? The command is already running, so let's ignore these
// errors - it's better to get a slightly mangled buffer than to abort the
// command in the mid-run.
if (channel_stdout_) {
// Since we invoke shutdown() manually before unref(), this would cause
// a double-shutdown.
// g_io_channel_set_close_on_unref(channel_stdout_, true); // close() on fd
g_io_channel_set_encoding(channel_stdout_, NULL, 0); // binary IO
g_io_channel_set_flags(channel_stdout_, GIOFlags(g_io_channel_get_flags(channel_stdout_) & channel_flags), 0);
g_io_channel_set_buffer_size(channel_stdout_, channel_stdout_buffer_size_);
// blocking writes if the pipe is full helps for small-pipe systems (see man 7 pipe).
Glib::IOFlags flags = ~Glib::IO_FLAG_NONBLOCK;
channel_stdout->set_flags(flags);
channel_stderr->set_flags(flags);
channel_stdout->set_buffer_size(channel_stdout_buffer_size);
channel_stderr->set_buffer_size(channel_stderr_buffer_size);
}
if (channel_stderr_) {
// g_io_channel_set_close_on_unref(channel_stderr_, true); // close() on fd
g_io_channel_set_encoding(channel_stderr_, NULL, 0); // binary IO
g_io_channel_set_flags(channel_stderr_, GIOFlags(g_io_channel_get_flags(channel_stderr_) & channel_flags), 0);
g_io_channel_set_buffer_size(channel_stderr_, channel_stderr_buffer_size_);
catch (Glib::IOChannelError& e) {
// What do we do? The command is already running, so let's ignore these
// errors - it's better to get a slightly mangled buffer than to abort the
// command in the mid-run.
}
// Note: glib callbacks _are_ invoked in separate threads,
// so proper locking is necessary.
// This is different from gtk callbacks, which are directly invoked from main loop
// in the same thread.
// this doesn't really work
// Glib::signal_io().connect(sigc::bind(sigc::ptr_fun(&io_handler), this), channel_stdout, cond);
GIOCondition cond = GIOCondition(G_IO_IN | G_IO_PRI | G_IO_HUP | G_IO_ERR | G_IO_NVAL);
// Channel reader callback must be called before other stuff so that the loss is minimal.
gint io_priority = G_PRIORITY_HIGH;
gint io_thread_priority = G_PRIORITY_HIGH; // channel reader callback thread must read enough so that the loss is minimal
this->event_source_id_stdout_ = g_io_add_watch_full(channel_stdout_, io_priority, cond,
&cmdex_on_channel_io_stdout, this, NULL);
// g_io_channel_unref(channel_stdout_); // g_io_add_watch_full() holds its own reference
if (this->stdout_make_str_as_available) {
this->event_source_id_stdout = g_io_add_watch_full(channel_stdout->gobj(), io_thread_priority, cond,
&command_executor_on_channel_io_stdout_as_available, this, NULL);
} else {
this->event_source_id_stdout = g_io_add_watch_full(channel_stdout->gobj(), io_thread_priority, cond,
&command_executor_on_channel_io_stdout_buffered, this, command_executor_on_buffered_source_destroy);
}
this->event_source_id_stderr_ = g_io_add_watch_full(channel_stderr_, io_priority, cond,
&cmdex_on_channel_io_stderr, this, NULL);
// g_io_channel_unref(channel_stderr_); // g_io_add_watch_full() holds its own reference
if (this->stderr_make_str_as_available) {
this->event_source_id_stderr = g_io_add_watch_full(channel_stderr->gobj(), io_thread_priority, cond,
&command_executor_on_channel_io_stderr_as_available, this, NULL);
} else {
this->event_source_id_stderr = g_io_add_watch_full(channel_stderr->gobj(), io_thread_priority, cond,
&command_executor_on_channel_io_stderr_buffered, this, command_executor_on_buffered_source_destroy);
}
// If using SPAWN_DO_NOT_REAP_CHILD, this is needed to avoid zombies.
// Note: Do NOT use glibmm slot, it doesn't work here.
// The watch function is protected by mutex and won't be called before execute() exits.
// This is AFTER the channels so that it doesn't get called before the channels are attached (is this needed?).
// (the child stops being a zombie as soon as wait*() exits and this handler is called).
g_child_watch_add(this->pid_, &cmdex_child_watch_handler, this);
g_child_watch_add(static_cast<GPid>(this->pid), &command_executor_child_watch_handler, this);
this->running_ = true; // the process is running now.
DBG_FUNCTION_EXIT_MSG;
this->running = true; // process is running now.
// actually, it may be already stopped, but the watcher function is blocked
// until we exit, so the actions are serialized.
return true;
}
@@ -252,61 +237,53 @@ bool Cmdex::execute()
// send SIGTERM(15) (terminate)
bool Cmdex::try_stop(hz::signal_t sig)
{
DBG_FUNCTION_ENTER_MSG;
if (!this->running_ || this->pid_ <= 0)
ScopedLock locker(object_mutex_);
if (!this->running || this->pid <= 0)
return false;
// other variants: SIGHUP(1) (terminal closed), SIGINT(2) (Ctrl-C),
// SIGKILL(9) (kill).
// Note that SIGKILL cannot be trapped by any process.
if (process_signal_send(this->pid_, sig) == 0) { // success
this->kill_signal_sent_ = static_cast<int>(sig); // just the number to compare later.
if (process_signal_send(this->pid, sig) == 0) { // success
this->kill_signal_sent = static_cast<int>(sig); // just the number to compare later.
return true; // the rest is done by a handler
}
// Possible: EPERM (no permissions), ESRCH (no such process, or zombie)
push_error(Error<int>("errno", ErrorLevel::error, errno), false);
DBG_FUNCTION_EXIT_MSG;
return false;
}
bool Cmdex::try_kill()
{
DBG_TRACE_POINT_AUTO;
return try_stop(hz::SIGNAL_SIGKILL);
}
void Cmdex::set_stop_timeouts(int term_timeout_msec, int kill_timeout_msec)
{
DBG_FUNCTION_ENTER_MSG;
DBG_ASSERT(term_timeout_msec == 0 || kill_timeout_msec == 0 || kill_timeout_msec > term_timeout_msec);
ScopedLock locker(object_mutex_); // member access / serialization lock
if (!this->running_) // process not running
if (!this->running) // process not running
return;
unset_stop_timeouts();
unset_stop_timeouts(false);
if (term_timeout_msec != 0)
event_source_id_term = g_timeout_add(term_timeout_msec, &cmdex_on_term_timeout, this);
event_source_id_term = g_timeout_add(term_timeout_msec, &command_executor_on_term_timeout, this);
if (kill_timeout_msec != 0)
event_source_id_kill = g_timeout_add(kill_timeout_msec, &cmdex_on_kill_timeout, this);
DBG_FUNCTION_EXIT_MSG;
event_source_id_kill = g_timeout_add(kill_timeout_msec, &command_executor_on_kill_timeout, this);
}
void Cmdex::unset_stop_timeouts()
void Cmdex::unset_stop_timeouts(bool do_lock)
{
DBG_FUNCTION_ENTER_MSG;
ScopedLock locker(object_mutex_, do_lock); // member access / serialization lock
if (event_source_id_term) {
GSource* source_term = g_main_context_find_source_by_id(NULL, event_source_id_term);
if (source_term)
@@ -320,7 +297,6 @@ void Cmdex::unset_stop_timeouts()
g_source_destroy(source_kill);
event_source_id_kill = 0;
}
DBG_FUNCTION_EXIT_MSG;
}
@@ -328,31 +304,33 @@ void Cmdex::unset_stop_timeouts()
// executed in main thread, manually by the caller.
void Cmdex::stopped_cleanup()
{
DBG_FUNCTION_ENTER_MSG;
if (this->running_ || !this->stopped_cleanup_needed()) // huh?
// DBG_FUNCTION_ENTER_MSG;
ScopedLock locker(object_mutex_); // member access / serialization lock
if (this->running || !this->stopped_cleanup_needed(false)) // huh?
return;
// remove stop timeout callbacks
unset_stop_timeouts();
unset_stop_timeouts(false);
// various statuses (see waitpid (2)):
if (WIFEXITED(waitpid_status_)) { // exited normally
int exit_status = WEXITSTATUS(waitpid_status_);
if (WIFEXITED(waitpid_status)) { // exited normally
int exit_status = WEXITSTATUS(waitpid_status);
if (exit_status != 0) {
// translate the exit_code into a message
std::string msg = (translator_func_ ? translator_func_(exit_status, translator_func_data_)
: "[no translator function, exit code: " + hz::number_to_string(exit_status));
Glib::ustring msg = signal_exit_status_translator.emit(exit_status);
push_error(Error<int>("exit", ErrorLevel::warn, exit_status, msg), false);
}
} else {
if (WIFSIGNALED(waitpid_status_)) { // exited by signal
int sig_num = WTERMSIG(waitpid_status_);
if (WIFSIGNALED(waitpid_status)) { // exited by signal
int sig_num = WTERMSIG(waitpid_status);
// If it's not our signal, treat as error.
// Note: they will never match under win32
if (sig_num != this->kill_signal_sent_) {
if (sig_num != this->kill_signal_sent) {
push_error(Error<int>("signal", ErrorLevel::error, sig_num), false);
} else { // it's our signal, treat as warning
push_error(Error<int>("signal", ErrorLevel::warn, sig_num), false);
@@ -360,72 +338,62 @@ void Cmdex::stopped_cleanup()
}
}
g_spawn_close_pid(this->pid_); // needed to avoid zombies
Glib::spawn_close_pid(this->pid); // needed to avoid zombies
cleanup_members();
this->running_ = false;
DBG_FUNCTION_EXIT_MSG;
this->running = false;
}
// Called when child exits
// NOTE: This function is called in a separate thread!
void Cmdex::on_child_watch_handler(GPid arg_pid, int waitpid_status, gpointer data)
{
// DBG_FUNCTION_ENTER_MSG;
Cmdex* self = static_cast<Cmdex*>(data);
g_timer_stop(self->timer_); // stop the timer
self->lock();
self->waitpid_status_ = waitpid_status;
self->child_watch_handler_called_ = true;
self->running_ = false; // process is not running anymore
self->timer.stop(); // stop the timer
// These are needed because Windows doesn't read the remaining data otherwise.
g_io_channel_flush(self->channel_stdout_, NULL);
on_channel_io(self->channel_stdout_, GIOCondition(0), self, channel_type_stdout);
// wait until the IO channels are closed
// while (!(self->event_source_stdout_closed && self->event_source_stderr_closed)) {
// self->unlock();
// Glib::usleep(75*1000); // 75ms
// self->lock();
// }
g_io_channel_flush(self->channel_stderr_, NULL);
on_channel_io(self->channel_stderr_, GIOCondition(0), self, channel_type_stderr);
self->waitpid_status = waitpid_status;
self->child_watch_handler_called = true;
self->running = false; // process is not running anymore
if (self->channel_stdout_) {
g_io_channel_shutdown(self->channel_stdout_, false, NULL);
g_io_channel_unref(self->channel_stdout_);
self->channel_stdout_ = 0;
}
if (self->channel_stderr_) {
g_io_channel_shutdown(self->channel_stderr_, false, NULL);
g_io_channel_unref(self->channel_stderr_);
self->channel_stderr_ = 0;
}
// Remove fd IO callbacks. They may actually be removed already (note sure about this).
// Remove fd IO callbacks. They may actually be removed already.
// This will force calling the iochannel callback (they may not be called
// otherwise at all if there was no output).
if (self->event_source_id_stdout_) {
GSource* source_stdout = g_main_context_find_source_by_id(NULL, self->event_source_id_stdout_);
if (self->event_source_id_stdout) {
GSource* source_stdout = g_main_context_find_source_by_id(NULL, self->event_source_id_stdout);
if (source_stdout)
g_source_destroy(source_stdout);
}
if (self->event_source_id_stderr_) {
GSource* source_stderr = g_main_context_find_source_by_id(NULL, self->event_source_id_stderr_);
if (self->event_source_id_stderr) {
GSource* source_stderr = g_main_context_find_source_by_id(NULL, self->event_source_id_stderr);
if (source_stderr)
g_source_destroy(source_stderr);
}
// Close std pipes.
// The channel closes them now.
// close(self->fd_stdout_);
// close(self->fd_stderr_);
// Cose std pipes
close(self->fd_stdout);
close(self->fd_stderr);
if (self->exited_callback_)
self->exited_callback_(self->exited_callback_data_);
self->signal_exited.emit(); // ALL slots are called in non-main thread!
self->unlock();
// DBG_FUNCTION_EXIT_MSG;
}
@@ -433,11 +401,13 @@ void Cmdex::on_child_watch_handler(GPid arg_pid, int waitpid_status, gpointer da
gboolean Cmdex::on_channel_io(GIOChannel* channel,
// NOTE: This function is called in a separate thread!
// This means that all data access must be guarded by mutexes, etc...
gboolean Cmdex::on_channel_io_as_available(GIOChannel* source,
GIOCondition cond, Cmdex* self, channel_t type)
{
// DBG_FUNCTION_ENTER_MSG;
// debug_out_dump("app", "Cmdex::on_channel_io("
// debug_out_dump("app", "Cmdex::on_channel_io_as_available("
// << (type == channel_type_stdout ? "STDOUT" : "STDERR") << ") " << int(cond) << "\n");
bool continue_events = true;
@@ -451,35 +421,157 @@ gboolean Cmdex::on_channel_io(GIOChannel* channel,
// read the bytes one by one. without this, a buffered iochannel hangs while waiting for data.
// we don't use unbuffered iochannels - they may lose data on program exit.
const gsize count = 1;
gchar buf[count] = {0};
char buf[count] = {0};
Cmdex::ScopedLock locker(self->object_mutex_);
Glib::RefPtr<Glib::IOChannel> channel;
std::string* output_str = 0;
if (type == channel_type_stdout) {
output_str = &self->str_stdout_;
channel = self->channel_stdout;
output_str = &self->str_stdout;
} else if (type == channel_type_stderr) {
output_str = &self->str_stderr_;
channel = self->channel_stderr;
output_str = &self->str_stderr;
}
// while there's anything to read, read it
do {
hz::scoped_ptr<GError> channel_error(0, g_error_free);
gsize bytes_read = 0;
GIOStatus status = g_io_channel_read_chars(channel, buf, count, &bytes_read, &channel_error.get_ref());
if (bytes_read)
output_str->append(buf, bytes_read);
try { // read() may throw something
if (channel_error) {
self->push_error(Error<void>("giochannel", ErrorLevel::error, channel_error->message), false);
break; // stop on next invocation (is this correct?)
}
// while there's anything to read, read it
do {
gsize bytes_read = 0;
Glib::IOStatus status = channel->read(buf, count, bytes_read);
if (bytes_read)
output_str->append(buf, bytes_read);
// IO_STATUS_NORMAL and IO_STATUS_AGAIN (resource unavailable) are continuable.
if (status == Glib::IO_STATUS_ERROR || status == Glib::IO_STATUS_EOF) {
continue_events = false;
break;
}
} while (channel->get_buffer_condition() & Glib::IO_IN);
}
catch (Glib::IOChannelError& e) {
self->push_error(Error<Glib::IOChannelError>("giochannel", ErrorLevel::error, e, e.what()), false);
}
catch (Glib::ConvertError& e) { // no conversion in binary mode, shouldn't happen
self->push_error(Error<void>("custom", ErrorLevel::error,
"Cmdex::on_channel_io_as_available(): Glib::ConvertError thrown."), false);
}
// false if the source should be removed, true otherwise.
return continue_events;
}
namespace {
// this must be thread-local, because many instances of Cmdex may call this
// from various threads. stdout and stderr are in different threads, so they won't get mixed.
// there's one-channel-per-thread situation here, so thread-local works well.
static hz::thread_local_ptr<std::string, hz::TlsPolicyGlib> s_final_str;
}
// The problem with final_str is that it may acummulate data if this function
// is never called with (continue_events = false) condition. This may
// actually happen with terminated spawned programs.
// So, we clean final_str manually from source_destroy callback.
// This callback is executed from in the same thread as on_channel_io_buffered,
// so we get the same variable (tests show cleared s_final_str, but is this really
// so? this function is executed during on_child_watch_handler (if spawn-terminated)).
inline void command_executor_on_buffered_source_destroy(gpointer data)
{
// DBG_FUNCTION_ENTER_MSG;
s_final_str.reset(); // .reset(), not ->clear - we don't want memory leaks in stopped threads.
}
// NOTE: This function is called in a separate thread!
// This means that all data access must be guarded by mutexes, etc...
gboolean Cmdex::on_channel_io_buffered(GIOChannel* source,
GIOCondition cond, Cmdex* self, channel_t type)
{
// debug_out_dump("app", "Cmdex::on_channel_io_buffered("
// << (type == channel_type_stdout ? "STDOUT" : "STDERR") << ") " << int(cond) << "\n");
bool continue_events = true;
if ((cond & G_IO_ERR) || (cond & G_IO_HUP) || (cond & G_IO_NVAL)) {
continue_events = false; // there'll be no more data
}
if (!s_final_str.get()) {
s_final_str.reset(new std::string);
s_final_str->reserve(g_io_channel_get_buffer_size(source));
}
// const gsize count = 4 * 1024;
// read the bytes one by one. without this, a buffered iochannel hangs while waiting for data.
// we don't use unbuffered iochannels - they may lose data on program exit.
const gsize count = 1;
static char buf[count] = {0};
// Glib::RefPtr<Glib::IOChannel> channel = Glib::wrap(source); // this segfaults on large data (?)
// while there's anything to read, read it
GError* error = 0;
do {
gsize bytes_read = 0;
GIOStatus status = g_io_channel_read_chars(source, buf, count, &bytes_read, &error);
if (bytes_read)
s_final_str->append(buf, bytes_read);
// IO_STATUS_NORMAL and IO_STATUS_AGAIN (resource unavailable) are continuable.
if (status == G_IO_STATUS_ERROR || status == G_IO_STATUS_EOF) {
continue_events = false;
break;
}
} while (g_io_channel_get_buffer_condition(channel) & G_IO_IN);
if (error)
break;
} while (g_io_channel_get_buffer_condition(source) & G_IO_IN);
if (!continue_events || error) { // these conditions need locking
Cmdex::ScopedLock locker(self->object_mutex_);
if (error) {
try {
Glib::Error::throw_exception(error); // convert GError to exception for easy storage.
}
catch (Glib::IOChannelError& e) {
self->push_error(Error<Glib::IOChannelError>("giochannel", ErrorLevel::error, e, e.what()), false);
}
catch (Glib::ConvertError& e) { // no conversion in binary mode, shouldn't happen
self->push_error(Error<void>("custom", ErrorLevel::error,
"Cmdex::on_channel_io_buffered(): Glib::ConvertError thrown."), false);
}
}
if (!continue_events) {
if (type == channel_type_stdout) {
// set the source to be closed (the actual closing is done when we return false).
// this is needed for the caller to wait until all the channels are stopped.
self->str_stdout = *s_final_str;
} else if (type == channel_type_stderr) {
self->str_stderr = *s_final_str;
}
// glib may re-use this thread, so do a TLS cleanup.
// also, manual cleanup is needed for policies which don't support automatic one.
// source_destroy callback already does this, but it won't hurt.
s_final_str.reset(); // this will delete the previous contents.
}
}
// DBG_FUNCTION_EXIT_MSG;
@@ -489,21 +581,7 @@ gboolean Cmdex::on_channel_io(GIOChannel* channel,
void Cmdex::cleanup_members()
{
kill_signal_sent_ = 0;
child_watch_handler_called_ = false;
pid_ = 0;
waitpid_status_ = 0;
event_source_id_stdout_ = 0;
event_source_id_stderr_ = 0;
fd_stdout_ = 0;
fd_stderr_ = 0;
}
/// @}
+220 -139
View File
@@ -1,210 +1,272 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
#ifndef APP_CMDEX_H
#define APP_CMDEX_H
#include <glib.h>
#include <string>
#include <sigc++/sigc++.h>
#include <glibmm/iochannel.h>
#include <glibmm/thread.h>
#include <glibmm/timer.h> // Timer
#include <glibmm/spawn.h> // Pid
#include <glib.h> // G*, g_*
#include "hz/process_signal.h" // hz::SIGNAL_*
#include "hz/process_signal.h" // hz::SIGNAL_*, hz::process_signal_send (cpp), win32's W* (cpp)
#include "hz/error_holder.h"
#include "hz/sync.h" // hz::SyncPolicyNone
#include "hz/sync.h"
#include "hz/sync_policy_glib.h"
/// Command executor.
/// There are two ways to detect when the command exits:
/// 1. Add a callback to signal_exited.
/// 2. Manually poll stopped_cleanup_needed() (from the same thread).
/// In both cases, stopped_cleanup() must be called afterwards
/// (from the main thread).
class Cmdex : public hz::ErrorHolder<hz::SyncPolicyNone> {
/*
There are two ways to detect when the command exits:
1. Add a callback to signal_exited. The callback will be executed
in non-main thread, which means that all data access MUST be
very carefully evaluated (and locked in both threads).
2. Manually poll stopped_cleanup_needed() from the main thread.
In both cases, stopped_cleanup() must be called afterwards,
from the _main_ thread.
*/
// inheriting from sigc::trackable automatically disconnects this class's
// slots upon destruction.
class Cmdex : public hz::ErrorHolder<hz::SyncPolicyGlib>, public sigc::trackable {
public:
using hz::ErrorHolder<hz::SyncPolicyNone>::ptr_error_list_t; ///< Auto-deleting pointer container
using hz::ErrorHolder<hz::SyncPolicyNone>::error_list_t; ///< Error list type
using hz::ErrorHolder<hz::SyncPolicyGlib>::ptr_error_list_t; // auto-deleting container
using hz::ErrorHolder<hz::SyncPolicyGlib>::error_list_t;
/// A function that translates the exit error code into a readable string
typedef std::string (*exit_status_translator_func_t)(int, void*);
/// A function that is called whenever a process exits.
typedef void (*exited_callback_func_t)(void*);
typedef hz::ErrorHolder<hz::SyncPolicyGlib>::ErrorScopedLock ScopedLock;
typedef hz::ErrorHolder<hz::SyncPolicyGlib>::ErrorLockPolicy LockPolicy;
/// Constructor
Cmdex(exited_callback_func_t exited_cb = NULL, void* exited_cb_data = NULL)
: running_(false), kill_signal_sent_(0), child_watch_handler_called_(false),
pid_(0), waitpid_status_(0),
timer_(g_timer_new()),
event_source_id_term(0), event_source_id_kill(0),
fd_stdout_(0), fd_stderr_(0), channel_stdout_(0), channel_stderr_(0),
channel_stdout_buffer_size_(100 * 1024), channel_stderr_buffer_size_(10 * 1024), // 100K and 10K
event_source_id_stdout_(0), event_source_id_stderr_(0),
translator_func_(0), translator_func_data_(0),
exited_callback_(exited_cb), exited_callback_data_(exited_cb_data)
{ }
Cmdex(
//const sigc::slot<Glib::ustring, int>& slot_exit_status_translator,
const sigc::slot<void>& slot_exited = sigc::slot<void>()
)
: object_mutex_(error_object_mutex_),
running(false), kill_signal_sent(0), child_watch_handler_called(false),
pid(0), waitpid_status(0),
event_source_id_term(0), event_source_id_kill(0),
fd_stdout(0), fd_stderr(0),
channel_stdout_buffer_size(100 * 1024), channel_stderr_buffer_size(10 * 1024), // 100K and 10K
event_source_id_stdout(0), event_source_id_stderr(0),
stdout_make_str_as_available(false), stderr_make_str_as_available(true)
{
// signal_exit_status_translator.connect(slot_exit_status_translator);
if (!slot_exited.empty())
signal_exited.connect(slot_exited);
}
/// Destructor. Don't destroy this object unless the child has exited. It will leak stuff
/// and possibly crash, etc... .
// Please don't destroy this object unless the child has exited. It will leak stuff
// and possibly crash, etc... .
~Cmdex()
{
// This will help if object is destroyed after the command has exited, but before
// stopped_cleanup() has been called.
stopped_cleanup();
g_timer_destroy(timer_);
// no need to destroy the channels - stopped_cleanup() calls
// cleanup_members(), which deletes them.
}
/// Set the command to execute. Call before execute().
/// Note: The command and the arguments _must_ be shell-escaped.
/// Use g_shell_quote() or Glib::shell_quote(). Note that each argument
/// must be escaped separately.
void set_command(const std::string& command_exec, const std::string& command_args)
// Call before execute.
void set_command(const std::string& command_exec_, const std::string& command_args_)
{
command_exec_ = command_exec;
command_args_ = command_args;
command_exec = command_exec_;
command_args = command_args_;
}
/// Launch the command.
// launch the command.
bool execute();
/// Send SIGTERM(15) (terminate) to the child process.
/// Use only after execute(). Using it after the command has exited has no effect.
// send SIGTERM(15) (terminate).
// use after execute(). using it after the command has exited has no effect.
bool try_stop(hz::signal_t sig = hz::SIGNAL_SIGTERM);
/// Send SIGKILL(9) (kill) to the child process. Same as
/// try_stop(hz::SIGNAL_SIGKILL).
/// Note that SIGKILL cannot be overridden in child process.
bool try_kill();
// Send SIGKILL(9) (kill). This signal cannot be overridden in child process.
// use after execute(). using it after the command has exited has no effect.
bool try_kill()
{
return try_stop(hz::SIGNAL_SIGKILL);
}
/// Set a timeout (since call to this function) to terminate the child process,
/// kill it or both (use 0 to ignore the parameter).
/// The timeouts will be unset automatically when the command exits.
/// This has an effect only if the command is running (after execute()).
// set a timeout (since call to this function) to terminate, kill or both (use 0 to ignore the parameter).
// the timeouts will be unset automatically when the command exits.
// This has an effect only if the command is running (after execute()).
void set_stop_timeouts(int term_timeout_msec = 0, int kill_timeout_msec = 0);
/// Unset the terminate / kill timeouts. This will stop the timeout counters.
/// This has an effect only if the command is running (after execute()).
void unset_stop_timeouts();
// Unset timeouts. This will stop the timeout counters.
// This has an effect only if the command is running (after execute()).
// do_lock is kind of private and indicates that mutex should be locked prior to
// accessing the object members.
void unset_stop_timeouts(bool do_lock = true);
/// If stopped_cleanup_needed() returned true, call this. The command
/// should be exited by this time. Must be called before the next execute().
// If stopped_cleanup_needed() returned true, call this. The command
// should be exited by this time. Must be called before the next execute().
void stopped_cleanup();
/// Returns true if command has stopped.
/// Call repeatedly in a waiting function, after execute().
/// When it returns true, call stopped_cleanup().
bool stopped_cleanup_needed()
// Returns true if command has stopped.
// Call repeatedly in a waiting function, after execute(). When returns true, call stopped_cleanup().
// do_lock is private, set to false only if you already hold the object lock.
bool stopped_cleanup_needed(bool do_lock = true)
{
return (child_watch_handler_called_);
ScopedLock locker(object_mutex_, do_lock);
return (child_watch_handler_called);
}
/// Check if the process is running. Note that if this returns false, it doesn't mean that
/// the io channels have been closed or that the data may be read safely. Poll
/// stopped_cleanup_needed() instead.
// The process is running. Note that if this returns false, it doesn't mean that
// the io channels have been closed or that the data may be read safely. Poll
// stopped_cleanup_needed() instead.
bool is_running() const
{
return running_;
ScopedLock locker(object_mutex_);
return running;
}
/// Call this before execution. There is a race-like condition - when the command
/// outputs something, the io channel reads it from fd to its buffer and the event
/// source callback is called. If the command dies, the io channel callback reads
/// the remaining data to the channel buffer.
/// Since the event source callbacks (which read from the buffer and empty it)
/// happen rather sporadically (from the glib loop), the buffer may not get read and
/// emptied at all (before the command exits). This is why it's necessary to have
/// a buffer size which potentially can hold _all_ the command output.
/// A way to fight this is to increase event source priority (which may not help).
/// Another way is to delay the command exit so that the event source callback
/// catches on and reads the buffer.
// Use 0 to ignore the parameter. Call this before execute().
// Call this before execution. There is a race-like condition - when the command
// outputs something, the io channel reads it from fd to its buffer and the event
// source callback is called. If the command dies, the io channel thread reads
// the remaining data to the channel buffer.
// Since the event source callbacks (which read from the buffer and empty it)
// happen rather sporadically in another thread, the buffer may not get read and
// emptied at all (before the command exits). This is why it's necessary to have
// a buffer size which potentially can hold _all_ the command output.
// A way to fight this is to increase event source thread priority (which may not help).
// Another way is to delay the command exit so that the event source thread
// catches on and reads the buffer.
// Use 0 to ignore the parameter. Call before execute().
void set_buffer_sizes(int stdout_buffer_size = 0, int stderr_buffer_size = 0)
{
ScopedLock locker(object_mutex_);
if (stdout_buffer_size)
channel_stdout_buffer_size_ = stdout_buffer_size; // 100K by default
channel_stdout_buffer_size = stdout_buffer_size; // 100K by default
if (stderr_buffer_size)
channel_stderr_buffer_size_ = stderr_buffer_size; // 10K by default
channel_stderr_buffer_size = stderr_buffer_size; // 10K by default
}
// Set the flags for child stdout and stderr. If stdout_str_as_available is true,
// then get_stdout_str() will return the stdout string as it becomes available,
// while false will make it available only after the command exits. Note that
// if the command outputs a lot of data in a very short period of time and
// then exits, false is much better choice because it's much faster.
// If you want to monitor the data as it becomes available and clean it to
// save some memory, use true.
// Call before execute().
void set_str_available(bool stdout_str_as_available = false, bool stderr_str_as_available = true)
{
ScopedLock locker(object_mutex_);
stdout_make_str_as_available = stdout_str_as_available;
stderr_make_str_as_available = stderr_str_as_available;
}
/// If stdout_make_str_as_available_ is false, call this after stopped_cleanup(),
/// before next execute(). If it's true, you may call this before the command has
/// stopped, but it will decrease performance significantly.
// If stdout_make_str_as_available is false, call this after stopped_cleanup(),
// before next execute(). If it's true, you may call this before the command has
// stopped, but it will decrease performance significantly.
std::string get_stdout_str(bool clear_existing = false)
{
// debug_out_dump("app", str_stdout_);
ScopedLock locker(object_mutex_);
// debug_out_dump("app", str_stdout);
if (clear_existing) {
std::string ret = str_stdout_;
str_stdout_.clear();
std::string ret = str_stdout;
str_stdout.clear();
return ret;
}
return str_stdout_;
return str_stdout;
}
/// See notes on get_stdout_str().
// See notes on get_stdout_str().
std::string get_stderr_str(bool clear_existing = false)
{
ScopedLock locker(object_mutex_);
if (clear_existing) {
std::string ret = str_stderr_;
str_stderr_.clear();
std::string ret = str_stderr;
str_stderr.clear();
return ret;
}
return str_stderr_;
return str_stderr;
}
/// Return execution time, in seconds. Call this after execute().
double get_execution_time()
// don't return sigc::connection - it's better for thread-safety this way.
// this will disconnect earlier slots. Call before execute().
void set_exit_status_translator(const sigc::slot<Glib::ustring, int>& slot_exit_status_translator)
{
gulong microsec = 0;
return g_timer_elapsed(timer_, &microsec);
ScopedLock locker(object_mutex_);
signal_exit_status_translator.slots().erase(signal_exit_status_translator.slots().begin(), signal_exit_status_translator.slots().end());
signal_exit_status_translator.connect(slot_exit_status_translator);
}
/// Set exit status translator callback, disconnecting the old one.
/// Call only before execute().
void set_exit_status_translator(exit_status_translator_func_t func, void* user_data)
// Returns sigc::connection; you must use lock() / unlock() before modifying it.
// NOTE: The slot will be called in non-main thread! (the call is enclosed
// in lock/unlock).
// Don't use this unless absolutely necessary, use stopped_cleanup_needed()
// polling instead.
sigc::connection connect_signal_exited(const sigc::slot<void>& slot_exited)
{
translator_func_ = func;
translator_func_data_ = user_data;
ScopedLock locker(object_mutex_);
return signal_exited.connect(slot_exited);
}
/// Set exit notifier callback, disconnecting the old one.
/// You can poll stopped_cleanup_needed() instead of using this function.
void set_exited_callback(exited_callback_func_t func, void* user_data)
// use lock() / unlock() if using members of this class outside of it.
void lock()
{
exited_callback_ = func;
exited_callback_data_ = user_data;
errors_lock(); // defer to parent's mutex - we use it for the whole object.
}
void unlock()
{
errors_unlock();
}
// protect all member variable access by this mutex, as well as
// serialize event callback execution (in respect of main thread too).
// it's possible to implement mutexes for each member individually, but
// it's impractical.
// mutable allows the definition of const member functions - they only
// read the data, but do it in a lock-protected manner.
// mutable Glib::Mutex object_mutex; // aka access serializer mutex
// use ErrorHolder's mutex
// these are sorta-private
/// Channel type, for passing to callbacks
// for passing to callback
enum channel_t {
channel_type_stdout,
channel_type_stderr
@@ -213,65 +275,84 @@ class Cmdex : public hz::ErrorHolder<hz::SyncPolicyNone> {
// Callbacks (Note: These are called by the real callbacks)
/// Child watch handler
static void on_child_watch_handler(GPid arg_pid, int waitpid_status, gpointer data);
/// Channel I/O handler
static gboolean on_channel_io(GIOChannel* channel, GIOCondition cond, Cmdex* self, Cmdex::channel_t type);
static gboolean on_channel_io_buffered(GIOChannel* source,
GIOCondition cond, Cmdex* self, channel_t type);
static gboolean on_channel_io_as_available(GIOChannel* source,
GIOCondition cond, Cmdex* self, channel_t type);
private:
/// Clean up the member variables and shut down the channels if needed.
void cleanup_members();
// The object MUST be locked by the caller.
void cleanup_members()
{
// ScopedLock locker(object_mutex_);
kill_signal_sent = 0;
child_watch_handler_called = false;
pid = 0;
waitpid_status = 0;
channel_stdout.clear();
channel_stderr.clear();
event_source_id_stdout = 0;
event_source_id_stderr = 0;
fd_stdout = 0;
fd_stderr = 0;
}
mutable ErrorLockPolicy::Mutex& object_mutex_; // reference to parent's member
// default command and its args. std::strings, not ustrings.
std::string command_exec_; /// Binary name to execute. NOT affected by cleanup_members().
std::string command_args_; /// Arguments that always go with the binary. NOT affected by cleanup_members().
std::string command_exec; // binary name. NOT affected by cleanup().
std::string command_args; // args that always go with binary. NOT affected by cleanup().
bool running_; ///< If true, the child process is running now. NOT affected by cleanup_members().
int kill_signal_sent_; ///< If non-zero, the process has been sent this signal to terminate
bool child_watch_handler_called_; ///< true after child_watch_handler callback, before stopped_cleanup().
bool running; // child process is running now. NOT affected by cleanup().
int kill_signal_sent; // command has been sent this signal to terminate
bool child_watch_handler_called; // true after child_watch_handler callback, before stopped_cleanup().
GPid pid_; ///< Process ID. int in Unix, pointer in win32
int waitpid_status_; ///< After the command is stopped, before cleanup, this will be available (waitpid() status).
Glib::Pid pid; // int in Unix, pointer in win32
int waitpid_status; // after the command is stopped, before cleanup, this will be available.
GTimer* timer_; ///< Keeps track of elapsed time since command execution. Value is not used by this class, but may be handy.
Glib::Timer timer; // keep track of elapsed time since command execution. not used by this class, but may be handy.
int event_source_id_term; ///< Timeout event source ID for SIGTERM.
int event_source_id_kill; ///< Timeout event source ID for SIGKILL.
int event_source_id_term;
int event_source_id_kill;
int fd_stdout_; ///< stdout file descriptor
int fd_stderr_; ///< stderr file descriptor
int fd_stdout;
int fd_stderr;
GIOChannel* channel_stdout_; ///< stdout channel
GIOChannel* channel_stderr_; ///< stderr channel
Glib::RefPtr<Glib::IOChannel> channel_stdout;
Glib::RefPtr<Glib::IOChannel> channel_stderr;
int channel_stdout_buffer_size_; ///< stdout channel buffer size. NOT affected by cleanup_members().
int channel_stderr_buffer_size_; ///< stderr channel buffer size. NOT affected by cleanup_members().
int channel_stdout_buffer_size; // NOT affected by cleanup().
int channel_stderr_buffer_size; // NOT affected by cleanup().
int event_source_id_stdout_; ///< IO watcher event source ID for stdout
int event_source_id_stderr_; ///< IO watcher event source ID for stderr
int event_source_id_stdout;
int event_source_id_stderr;
std::string str_stdout_; ///< stdout data read during execution. NOT affected by cleanup_members().
std::string str_stderr_; ///< stderr data read during execution. NOT affected by cleanup_members().
int stdout_make_str_as_available; // NOT affected by cleanup().
int stderr_make_str_as_available; // NOT affected by cleanup().
std::string str_stdout; // NOT affected by cleanup().
std::string str_stderr; // NOT affected by cleanup().
// signals
// convert command exit status to message string
exit_status_translator_func_t translator_func_; ///< Exit status translator function. NOT affected by cleanup_members().
void* translator_func_data_; ///< Data to supply to the exit status translator function.
sigc::signal<Glib::ustring, int> signal_exit_status_translator; // NOT affected by cleanup().
// command exited signal
sigc::signal<void> signal_exited; // NOT affected by cleanup().
// "command exited" signal callback.
exited_callback_func_t exited_callback_; ///< Exit notifier function. NOT affected by cleanup_members().
void* exited_callback_data_; ///< Data to supply to the exit notifier function.
};
+4 -16
View File
@@ -1,15 +1,10 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#include <glib.h> // g_usleep()
#include <glibmm/timer.h> // usleep()
#include "cmdex_sync.h"
@@ -17,16 +12,13 @@
namespace {
/// "Execution finished" signal
static sigc::signal<void, const CmdexSyncCommandInfo&> s_cmdex_sync_signal_execute_finish;
/// Mutex for "Execution finished" signal
static hz::SyncPolicyMtDefault::Mutex s_cmdex_sync_signal_execute_finish_mutex;
}
cmdex_signal_execute_finish_type cmdex_sync_signal_execute_finish()
{
return cmdex_signal_execute_finish_type(s_cmdex_sync_signal_execute_finish,
@@ -95,15 +87,13 @@ bool CmdexSync::execute()
}
// Without this, no event sources will be processed and the program will
// without this, no event sources will be processed and the program will
// hang waiting for the child to exit (the watch handler won't be called).
// Note: If you have an idle callback, g_main_context_pending() will
// always return true (until the idle callback returns false and unregisters itself).
while(g_main_context_pending(NULL)) {
g_main_context_iteration(NULL, false);
}
g_usleep(50*1000); // 50 msec. avoids 100% CPU usage.
Glib::usleep(50*1000); // 50 msec. avoids 100% CPU usage.
}
// command exited, do a cleanup.
@@ -145,5 +135,3 @@ void CmdexSync::import_error()
/// @}
+74 -104
View File
@@ -1,19 +1,14 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#ifndef APP_CMDEX_SYNC_H
#define APP_CMDEX_SYNC_H
#include <sigc++/sigc++.h>
#include <string>
#include <glibmm/ustring.h> // ustring
#include "hz/error.h"
#include "hz/intrusive_ptr.h"
@@ -25,65 +20,64 @@
/// Information about finished command (structure for storing it).
/// Supports intrusive_ptr for memory-efficient storage.
// Information about finished command (structure for storing).
// Supports intrusive_ptr for memory-efficient storage.
struct CmdexSyncCommandInfoCopy : public hz::intrusive_ptr_referenced {
CmdexSyncCommandInfoCopy(const std::string& c, const std::string& p,
const std::string& so, const std::string& se, const std::string& em)
: command(c), parameters(p), std_output(so), std_error(se), error_msg(em)
{ }
std::string command; ///< Executed command
std::string parameters; ///< Command parameters
std::string std_output; ///< Stdout data
std::string std_error; ///< Stderr data
std::string error_msg; ///< Execution error message
std::string command;
std::string parameters;
std::string std_output;
std::string std_error;
std::string error_msg;
};
/// A reference-counting pointer to CmdexSyncCommandInfoCopy
typedef hz::intrusive_ptr<CmdexSyncCommandInfoCopy> CmdexSyncCommandInfoRefPtr;
/// Information about a finished command.
// Information about finished command.
struct CmdexSyncCommandInfo {
CmdexSyncCommandInfo(const std::string& c, const std::string& p,
const std::string& so, const std::string& se, const std::string& em)
: command(c), parameters(p), std_output(so), std_error(se), error_msg(em)
{ }
/// Make a copy of this structure for storage.
// make a copy for storage.
CmdexSyncCommandInfoRefPtr copy() const
{
return new CmdexSyncCommandInfoCopy(command, parameters, std_output, std_error, error_msg);
}
const std::string& command; ///< Executed command
const std::string& parameters; ///< Command parameters
const std::string& std_output; ///< Stdout data
const std::string& std_error; ///< Stderr data
const std::string& error_msg; ///< Execution error message
const std::string& command;
const std::string& parameters;
const std::string& std_output;
const std::string& std_error;
const std::string& error_msg;
};
/// cmdex_sync_signal_execute_finish() return type, mt-synchronized signal.
typedef hz::sync_lock_ptr< sigc::signal<void, const CmdexSyncCommandInfo&>&,
hz::SyncPolicyMtDefault::ScopedLock > cmdex_signal_execute_finish_type;
/// This signal is emitted every time execute() finishes.
// Emitted every time execute() finishes.
cmdex_signal_execute_finish_type cmdex_sync_signal_execute_finish();
/// Synchronous Cmdex (command executor) with ticking support.
// Synchronious Cmdex (command executor) with ticking
class CmdexSync : public hz::intrusive_ptr_referenced, public sigc::trackable {
public:
/// Constructor
CmdexSync(const std::string& command_exec, const std::string& command_args)
{
construct();
@@ -91,19 +85,24 @@ class CmdexSync : public hz::intrusive_ptr_referenced, public sigc::trackable {
}
/// Constructor
CmdexSync()
{
construct();
}
/// Virtual destructor
void construct()
{
forced_kill_timeout_msec = 3 * 1000; // 3 sec default
running_msg_ = "Running %s..."; // %s will be replaced by command basename
set_error_header("An error occurred while executing the command:\n\n");
}
virtual ~CmdexSync()
{ }
/// Set command to execute and its parameters
void set_command(const std::string& command_name, const std::string& command_args)
{
cmdex_.set_command(command_name, command_args);
@@ -113,102 +112,96 @@ class CmdexSync : public hz::intrusive_ptr_referenced, public sigc::trackable {
}
/// Get command to execute
std::string get_command_name() const
{
return command_name_;
}
/// Get command arguments
std::string get_command_args() const
{
return command_args_;
}
/// Execute the command. The function will return only after the command exits.
/// Calls signal_execute_tick signal repeatedly while doing stuff.
/// Note: If the command _was_ executed, but there was an error,
/// this will return true. Check get_error_msg() for emptiness.
/// \c return false if failed to execute, true otherwise.
// Returns false if failed to execute, true otherwise.
// The function will return only after the command exits.
// Calls signal_execute_tick signal repeatedly while doing stuff.
// Note: If the command _was_ executed, but there was an error,
// this will return true. Check get_error_msg() emptiness.
virtual bool execute();
/// Set timeout (in ms) to send SIGKILL after sending SIGTERM.
/// Used if manual stop was requested through ticker.
// Timeout to send SIGKILL after sending SIGTERM.
// Used if manual stop was requested through ticker.
void set_forced_kill_timeout(int timeout_msec)
{
forced_kill_timeout_msec = timeout_msec;
}
/// Try to stop the process. Call this from ticker slot while executing.
// Call from slot while executing.
bool try_stop(hz::signal_t sig = hz::SIGNAL_SIGTERM)
{
return cmdex_.try_stop(sig);
}
/// Same as try_stop(hz::SIGNAL_SIGKILL).
// Call from slot while executing.
bool try_kill()
{
return cmdex_.try_kill();
}
/// Set a timeout (since call to this function) to terminate, kill or both (use 0 to ignore the parameter).
/// the timeouts will be unset automatically when the command exits.
/// Call from ticker slot while executing.
// Call from slot while executing.
// set a timeout (since call to this function) to terminate, kill or both (use 0 to ignore the parameter).
// the timeouts will be unset automatically when the command exits.
void set_stop_timeouts(int term_timeout_msec = 0, int kill_timeout_msec = 0)
{
cmdex_.set_stop_timeouts(term_timeout_msec, kill_timeout_msec);
}
/// Unset terminate / kill timeouts. This will stop the timeout counters.
/// Call from ticker slot while executing.
// Call from slot while executing.
// Unset timeouts. This will stop the timeout counters.
void unset_stop_timeouts()
{
cmdex_.unset_stop_timeouts();
}
/// Check if the child process is running. See Cmdex::is_running().
/// Call from ticker slot while executing.
// Call from slot while executing.
bool is_running() const
{
return cmdex_.is_running();
}
/// See Cmdex::set_buffer_sizes() for details. Call this before execute().
// Use 0 to ignore the parameter. Call before execute().
// See Cmdex for details.
void set_buffer_sizes(int stdout_buffer_size = 0, int stderr_buffer_size = 0)
{
cmdex_.set_buffer_sizes(stdout_buffer_size, stderr_buffer_size);
}
/// See Cmdex::get_stdout_str() for details.
// Call before execute().
// See Cmdex for details.
void set_str_available(bool stdout_str_as_available = false, bool stderr_str_as_available = true)
{
cmdex_.set_str_available(stdout_str_as_available, stderr_str_as_available);
}
std::string get_stdout_str(bool clear_existing = false)
{
return cmdex_.get_stdout_str(clear_existing);
}
/// See Cmdex::get_stderr_str() for details.
std::string get_stderr_str(bool clear_existing = false)
{
return cmdex_.get_stderr_str(clear_existing);
}
/// See Cmdex::set_exit_status_translator() for details.
void set_exit_status_translator(Cmdex::exit_status_translator_func_t func, void* user_data)
void set_exit_status_translator(const sigc::slot<Glib::ustring, int>& slot_exit_status_translator)
{
cmdex_.set_exit_status_translator(func, user_data);
cmdex_.set_exit_status_translator(slot_exit_status_translator);
}
/// Get command execution error message. If \c with_header
/// is true, a header set using set_error_header() will be displayed first.
std::string get_error_msg(bool with_header = false) const
{
if (with_header)
@@ -216,22 +209,16 @@ class CmdexSync : public hz::intrusive_ptr_referenced, public sigc::trackable {
return error_msg_;
}
/// Set a message to display when running. %s in \c msg will be replaced by the command.
void set_running_msg(const std::string& msg)
void set_running_msg(const Glib::ustring& msg)
{
running_msg_ = msg;
}
/// Set error header string. See get_error_msg()
void set_error_header(const std::string& msg)
{
error_header_ = msg;
}
/// Get error header string. See get_error_msg()
std::string get_error_header()
{
return error_header_;
@@ -241,39 +228,28 @@ class CmdexSync : public hz::intrusive_ptr_referenced, public sigc::trackable {
// ----------------- Signals
/// Status flags for signal_execute_tick slots, along with possible return values.
// status flags for signal_execute_tick slots, along with possible return values.
enum tick_status_t {
status_starting, ///< Return status will indicate whether to proceed with the execution
status_failed, ///< The execution failed
status_running, ///< Return status will indicate whether to abort the execution
status_stopping, ///< The child has been sent a signal
status_stopped ///< The child exited
status_starting, // return status will indicate whether to proceed with the execution
status_failed, // the execution failed
status_running, // return status will indicate whether to abort the execution
status_stopping, // the child has been sent a signal
status_stopped // the child exited
};
/// This signal is emitted whenever something happens with the execution
/// (the status is changed), and periodically while the process is running.
// this signal is emitted whenever something happens with the execution.
sigc::signal<bool, tick_status_t> signal_execute_tick;
protected:
/// Initialize the members (constructor calls this)
void construct()
{
forced_kill_timeout_msec = 3 * 1000; // 3 sec default
running_msg_ = "Running %s..."; // %s will be replaced by command basename
set_error_header("An error occurred while executing the command:\n\n");
}
/// Import the last error from cmdex_ and clear all errors there.
// import the last error from cmdex_ and clear all errors there
virtual void import_error();
/// The warnings are already printed via debug_* in cmdex.
/// Override if needed.
// The warnings are already printed via debug_* in cmdex.
// Override if needed.
virtual void on_error_warn(hz::ErrorBase* e)
{
if (e) {
@@ -282,41 +258,37 @@ class CmdexSync : public hz::intrusive_ptr_referenced, public sigc::trackable {
}
/// Set error message
void set_error_msg(const std::string& error_msg)
{
error_msg_ = error_msg;
}
/// Get "running" message
std::string get_running_msg() const
Glib::ustring get_running_msg() const
{
return running_msg_;
}
/// Get command executor object
Cmdex& get_command_executor()
{
return cmdex_;
}
private:
Cmdex cmdex_; ///< Command executor
Cmdex cmdex_;
std::string command_name_; ///< Command name
std::string command_args_; ///< Command arguments
std::string command_name_;
std::string command_args_;
std::string running_msg_; ///< "Running" message (to show in the dialogs, etc...)
Glib::ustring running_msg_; // message to show in the dialogs, etc...
int forced_kill_timeout_msec; ///< Kill timeout in ms.
int forced_kill_timeout_msec;
std::string error_msg_; ///< Execution error message
std::string error_header_; ///< The error message may have this prepended to it.
hz::ErrorBase* error_; ///< Error holder.
std::string error_msg_;
std::string error_header_;
hz::ErrorBase* error_;
};
@@ -326,5 +298,3 @@ class CmdexSync : public hz::intrusive_ptr_referenced, public sigc::trackable {
#endif
/// @}
+22 -15
View File
@@ -1,20 +1,15 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#include <gtkmm.h> // Gtk::Main
#include <gdkmm.h>
#include <gtkmm/main.h> // Gtk::Main
#include "hz/fs_path.h"
#include "hz/string_sprintf.h"
#include "app_gtkmm_features.h" // APP_GTKMM_CHECK_VERSION
#include "cmdex_sync_gui.h"
@@ -28,8 +23,15 @@ bool CmdexSyncGui::execute()
}
#define CMDEX_DIALOG_MESSAGE_TYPE Gtk::MESSAGE_OTHER
#define CMDEX_DIALOG_HINT_TYPE Gdk::WINDOW_TYPE_HINT_NOTIFICATION
#if APP_GTKMM_CHECK_VERSION(2, 10, 0)
// these are available since gtkmm 2.10
#define CMDEX_DIALOG_MESSAGE_TYPE Gtk::MESSAGE_OTHER
// not present in Gdk:: in 2.10 (it's in 2.12), use we have to use GDK_
#define CMDEX_DIALOG_HINT_TYPE GDK_WINDOW_TYPE_HINT_NOTIFICATION
#else
#define CMDEX_DIALOG_MESSAGE_TYPE Gtk::MESSAGE_INFO
#define CMDEX_DIALOG_HINT_TYPE GDK_WINDOW_TYPE_HINT_UTILITY
#endif
@@ -54,7 +56,9 @@ Gtk::MessageDialog* CmdexSyncGui::create_running_dialog(Gtk::Window* parent, con
&CmdexSyncGui::on_running_dialog_response));
running_dialog_->set_decorated(false);
running_dialog_->set_deletable(false);
#if APP_GTKMM_CHECK_VERSION(2, 10, 0)
running_dialog_->set_deletable(false); // since 2.10
#endif
running_dialog_->set_skip_pager_hint(true);
running_dialog_->set_skip_taskbar_hint(true);
running_dialog_->set_type_hint(Gdk::WindowTypeHint(CMDEX_DIALOG_HINT_TYPE));
@@ -88,11 +92,11 @@ void CmdexSyncGui::show_hide_dialog(bool show)
void CmdexSyncGui::update_dialog_show_timer()
{
double timeout = 2.; // 2 sec for normal dialogs
double timeout = 0.600; // 0.6 sec for normal dialogs
if (running_dialog_abort_mode_)
timeout = 0.4; // 0.4 sec for aborting... dialogs
timeout = 0.150; // 0.15 sec for aborting... dialogs
if (!running_dialog_shown_ && running_dialog_timer_.elapsed() > timeout) {
if (!running_dialog_shown_ && running_dialog_timer_.elapsed() > 1.000) { // 1 sec
// without first making it sensitive, the "whole label selected" problem may occur.
running_dialog_->set_response_sensitive(Gtk::RESPONSE_CANCEL, true);
@@ -142,6 +146,9 @@ void CmdexSyncGui::set_running_dialog_abort_mode(bool aborting)
// this function is called every time something happens
// with the executor.
bool CmdexSyncGui::execute_tick_func(tick_status_t status)
{
if (status == status_starting) {
@@ -233,4 +240,4 @@ bool CmdexSyncGui::execute_tick_func(tick_status_t status)
/// @}
+29 -35
View File
@@ -1,13 +1,8 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#ifndef APP_CMDEX_SYNC_GUI_H
#define APP_CMDEX_SYNC_GUI_H
@@ -21,78 +16,78 @@
/// Same as CmdexSync, but with GTK UI support.
/// This one is noncopyable, because we can't copy the dialogs, etc...
// CmdexSync with GUI support
// same as CmdexSync, but with GTK UI stuff.
// this one is noncopyable, because we don't copy the dialogs, etc...
class CmdexSyncGui : public CmdexSync, public hz::noncopyable {
public:
/// Constructor
CmdexSyncGui(const std::string& cmd, const std::string& cmdargs)
: CmdexSync(cmd, cmdargs), execution_running_(false), should_abort_(false),
: CmdexSync(cmd, cmdargs), execution_running_(false), should_abort_(false),
running_dialog_(0), running_dialog_shown_(false), running_dialog_abort_mode_(false)
{
signal_execute_tick.connect(sigc::mem_fun(*this, &CmdexSyncGui::execute_tick_func));
}
/// Constructor
CmdexSyncGui()
: execution_running_(false), should_abort_(false),
: execution_running_(false), should_abort_(false),
running_dialog_(0), running_dialog_shown_(false), running_dialog_abort_mode_(false)
{
signal_execute_tick.connect(sigc::mem_fun(*this, &CmdexSyncGui::execute_tick_func));
}
/// Destructor
~CmdexSyncGui()
{
delete running_dialog_;
}
// Reimplemented from CmdexSync
virtual bool execute();
/// UI callbacks may use this to abort execution.
// UI callbacks may use this to abort execution.
void set_should_abort()
{
should_abort_ = true;
}
/// Create a "running" dialog or return already existing one.
/// The dialog will be auto-created and displayed on execute().
/// You need the function only if you intend to modify it before execute().
// create a dialog or return already existing one.
// the dialog will be auto-created and displayed on execute().
// you need the function only if you intend to modify it before execute().
Gtk::MessageDialog* create_running_dialog(Gtk::Window* parent = 0, const Glib::ustring& msg = "");
/// Return the "running" dialog
Gtk::MessageDialog* get_running_dialog()
{
return running_dialog_;
}
/// Show or hide the "running" dialog.
/// This actually shows the dialog only after some time has passed,
/// to avoid very quick show/hide in case the command exits very quickly.
// this actually shows the dialog only after some time has passed,
// to avoid very quick show/hide.
void show_hide_dialog(bool show);
/// This function is called from ticker function in running mode
/// to show the dialog when requested time elapses.
// called from ticker function in running mode, to show the dialog when requested time elapses.
void update_dialog_show_timer();
/// Switch the dialog to "aborting..." mode
// switch the dialog to "Aborting..." mode
void set_running_dialog_abort_mode(bool aborting);
private:
/// Dialog response callback.
// dialog callback.
void on_running_dialog_response(int response_id)
{
// Try to abort if Cancel was clicked
@@ -101,17 +96,18 @@ class CmdexSyncGui : public CmdexSync, public hz::noncopyable {
}
/// This function is attached to CmdexSync::signal_execute_tick.
// this function is called every time something happens
// with the executor.
bool execute_tick_func(tick_status_t status);
bool execution_running_; ///< If true, the execution is still in progress
bool should_abort_; ///< GUI callbacks may set this to abort the execution
bool execution_running_;
bool should_abort_; // GUI callbacks may set this to abort the execution
Gtk::MessageDialog* running_dialog_; ///< "Running" dialog
bool running_dialog_shown_; ///< If true, the "running" dialog is visible
bool running_dialog_abort_mode_; ///< If true, the "running" dialog is in "aborting..." mode.
Glib::Timer running_dialog_timer_; ///< "Running" dialog show timer.
Gtk::MessageDialog* running_dialog_;
bool running_dialog_shown_;
bool running_dialog_abort_mode_;
Glib::Timer running_dialog_timer_;
};
@@ -122,5 +118,3 @@ class CmdexSyncGui : public CmdexSync, public hz::noncopyable {
#endif
/// @}
-67
View File
@@ -1,67 +0,0 @@
/**************************************************************************
Copyright:
(C) 2011 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#include "hz/debug.h"
#include "executor_factory.h"
#include "smartctl_executor_gui.h"
#include "cli_executors.h"
ExecutorFactory::ExecutorFactory(bool use_gui, Gtk::Window* parent)
: use_gui_(use_gui), parent_(parent)
{ }
hz::intrusive_ptr<CmdexSync> ExecutorFactory::create_executor(ExecutorFactory::Type type)
{
switch (type) {
case ExecutorSmartctl:
{
if (use_gui_) {
SmartctlExecutorGuiRefPtr ex = SmartctlExecutorGuiRefPtr(new SmartctlExecutorGui());
ex->create_running_dialog(parent_); // dialog parent
return ex;
}
return SmartctlExecutorRefPtr(new SmartctlExecutor());
}
case ExecutorTwCli:
{
if (use_gui_) {
TwCliExecutorGuiRefPtr ex = TwCliExecutorGuiRefPtr(new TwCliExecutorGui());
ex->create_running_dialog(parent_); // dialog parent
return ex;
}
return TwCliExecutorRefPtr(new TwCliExecutor());
}
case ExecutorArecaCli:
{
if (use_gui_) {
ArecaCliExecutorGuiRefPtr ex = ArecaCliExecutorGuiRefPtr(new ArecaCliExecutorGui());
ex->create_running_dialog(parent_); // dialog parent
return ex;
}
return ArecaCliExecutorRefPtr(new ArecaCliExecutor());
}
}
DBG_ASSERT(0);
return hz::intrusive_ptr<CmdexSync>();
}
/// @}
-64
View File
@@ -1,64 +0,0 @@
/**************************************************************************
Copyright:
(C) 2011 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#ifndef EXECUTOR_FACTORY_H
#define EXECUTOR_FACTORY_H
#include "cmdex_sync.h"
#include "hz/intrusive_ptr.h"
// Forward declaration
namespace Gtk {
class Window;
}
/// This class allows you to create new executors for different commands,
/// without carrying the GUI/CLI stuff manually.
class ExecutorFactory : public hz::intrusive_ptr_referenced {
public:
/// Executor type for create_executor()
enum Type {
ExecutorSmartctl,
ExecutorTwCli,
ExecutorArecaCli
};
/// Constructor. If \c use_gui is true, specify \c parent for the GUI dialogs.
ExecutorFactory(bool use_gui, Gtk::Window* parent = 0);
/// Create a new executor instance according to \c type and the constructor parameters.
hz::intrusive_ptr<CmdexSync> create_executor(Type type);
private:
bool use_gui_; ///< Whether to construct GUI executors or not.
Gtk::Window* parent_; ///< Parent window for dialogs
};
/// A reference-counting pointer to ExecutorFactory
typedef hz::intrusive_ptr<ExecutorFactory> ExecutorFactoryRefPtr;
#endif
/// @}
+5 -98
View File
@@ -1,21 +1,17 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#include "app_pango_utils.h" // app_pango_strip_markup()
#include <gtkmm/messagedialog.h>
#include "gui_utils.h"
namespace {
namespace
{
/// Show a message dialog
inline void show_dialog(const std::string& message, const std::string& sec_message,
Gtk::Window* parent, Gtk::MessageType type, bool sec_msg_markup)
{
@@ -79,94 +75,5 @@ void gui_show_info_dialog(const std::string& message, const std::string& sec_mes
// Returns false if Cancel was clicked. Puts the user-entered string into result otherwise.
bool gui_show_text_entry_dialog(const std::string& title, const std::string& message,
std::string& result, const std::string& default_str, Gtk::Window* parent)
{
return gui_show_text_entry_dialog(title, message, "", result, default_str, parent, false);
}
bool gui_show_text_entry_dialog(const std::string& title, const std::string& message, const std::string& sec_message,
std::string& result, const std::string& default_str, Gtk::Window* parent, bool sec_msg_markup)
{
int response = 0;
std::string input_str;
{ // the dialog hides at the end of scope
Gtk::Dialog dialog(title, true); // modal
dialog.set_resizable(false);
dialog.set_skip_taskbar_hint(true);
dialog.set_border_width(5);
if (parent) {
dialog.set_transient_for(*parent);
dialog.set_position(Gtk::WIN_POS_CENTER_ON_PARENT);
} else {
dialog.set_position(Gtk::WIN_POS_MOUSE);
}
Gtk::Label main_label;
main_label.set_markup("<big><b>" + Glib::Markup::escape_text(message)
+ (sec_message.empty() ? "\n" : "") + "</b></big>");
main_label.set_line_wrap(true);
main_label.set_selectable(true);
main_label.set_alignment(Gtk::ALIGN_START);
Gtk::Label sec_label;
if (sec_msg_markup) {
sec_label.set_markup(sec_message);
} else {
sec_label.set_text(sec_message);
}
sec_label.set_line_wrap(true);
sec_label.set_selectable(true);
sec_label.set_alignment(Gtk::ALIGN_START);
Gtk::Entry input_entry;
input_entry.set_activates_default(true);
Gtk::Box vbox;
vbox.set_spacing(12);
vbox.pack_start(main_label, false, false, 0);
vbox.pack_start(sec_label, true, true, 0);
vbox.pack_start(input_entry, true, true, 0);
vbox.show_all();
dialog.get_action_area()->set_border_width(5);
dialog.get_action_area()->set_spacing(6);
dialog.get_vbox()->set_spacing(14); // as in MessageDialog
dialog.get_vbox()->pack_start(vbox, false, false, 0);
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
Gtk::Button ok_button(Gtk::Stock::OK);
ok_button.set_can_default(true);
ok_button.show_all();
dialog.add_action_widget(ok_button, Gtk::RESPONSE_OK);
ok_button.grab_default(); // make it the default widget
response = dialog.run(); // blocks until the dialog is closed
input_str = input_entry.get_text();
}
if (response == Gtk::RESPONSE_OK) {
result = input_str;
return true;
}
return false;
}
/// @}
+2 -29
View File
@@ -1,66 +1,39 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#ifndef GUI_UTILS_H
#define GUI_UTILS_H
#include <string>
#include <gtkmm.h>
#include <gtkmm/window.h>
// These functions won't return until the dialogs are closed.
// Messages must not contain any markup.
/// Show an error dialog
void gui_show_error_dialog(const std::string& message, Gtk::Window* parent = 0);
/// Show an error dialog with a (possibly markupped) secondary message
void gui_show_error_dialog(const std::string& message, const std::string& sec_message,
Gtk::Window* parent = 0, bool sec_msg_markup = false);
/// Show a warning dialog
void gui_show_warn_dialog(const std::string& message, Gtk::Window* parent = 0);
/// Show a warning dialog with a (possibly markupped) secondary message
void gui_show_warn_dialog(const std::string& message, const std::string& sec_message,
Gtk::Window* parent = 0, bool sec_msg_markup = false);
/// Show an informational dialog
void gui_show_info_dialog(const std::string& message, Gtk::Window* parent = 0);
/// Show an informational dialog with a (possibly markupped) secondary message
void gui_show_info_dialog(const std::string& message, const std::string& sec_message,
Gtk::Window* parent = 0, bool sec_msg_markup = false);
/// Show a text entry dialog. \c result is filled with the user-entered string on success.
/// \return false if Cancel was clicked.
bool gui_show_text_entry_dialog(const std::string& title, const std::string& message,
std::string& result, const std::string& default_str, Gtk::Window* parent = 0);
/// Show a text entry dialog with a (possibly markupped) secondary message.
/// \c result is filled with the user-entered string on success.
/// \return false if Cancel was clicked.
bool gui_show_text_entry_dialog(const std::string& title, const std::string& message, const std::string& sec_message,
std::string& result, const std::string& default_str, Gtk::Window* parent = 0, bool sec_msg_markup = false);
#endif
/// @}
+12 -18
View File
@@ -1,13 +1,8 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#include <algorithm> // std::max, std::min
#include <cmath> // std::floor
@@ -26,7 +21,7 @@ int64_t SelfTest::get_remaining_seconds() const
if (total <= 0)
return -1; // unknown
double gran = (double(total) / 9.); // seconds per 10%
double gran = (total / 9.); // seconds per 10%
// since remaining_percent_ may be manually set to 100, we limit from the above.
double rem_seconds_at_last_change = std::min(double(total), gran * remaining_percent_ / 10.);
double rem = rem_seconds_at_last_change - timer_.elapsed();
@@ -108,7 +103,7 @@ std::string SelfTest::start(hz::intrusive_ptr<CmdexSync> smartctl_ex)
return "Invalid test specified";
std::string output;
std::string error_msg = drive_->execute_device_smartctl("--test=" + test_param, smartctl_ex, output);
std::string error_msg = drive_->execute_smartctl("--test=" + test_param, smartctl_ex, output);
if (!error_msg.empty()) // checks for empty output too
return error_msg;
@@ -168,7 +163,7 @@ std::string SelfTest::force_stop(hz::intrusive_ptr<CmdexSync> smartctl_ex)
// To abort non-captive short, long and conveyance tests, use "--abort".
std::string output;
std::string error_msg = drive_->execute_device_smartctl("--abort", smartctl_ex, output);
std::string error_msg = drive_->execute_smartctl("--abort", smartctl_ex, output);
if (!error_msg.empty()) // checks for empty output too
return error_msg;
@@ -207,15 +202,14 @@ std::string SelfTest::update(hz::intrusive_ptr<CmdexSync> smartctl_ex)
return "Invalid drive given.";
std::string output;
// std::string error_msg = drive_->execute_device_smartctl("--log=selftest", smartctl_ex, output);
std::string error_msg = drive_->execute_device_smartctl("--capabilities", smartctl_ex, output);
// std::string error_msg = drive_->execute_smartctl("--log=selftest", smartctl_ex, output);
std::string error_msg = drive_->execute_smartctl("--capabilities", smartctl_ex, output);
if (!error_msg.empty()) // checks for empty output too
return error_msg;
StorageAttribute::DiskType disk_type = drive_->get_is_hdd() ? StorageAttribute::DiskHDD : StorageAttribute::DiskSSD;
SmartctlParser ps;
if (!ps.parse_full(output, disk_type)) { // try to parse it
if (!ps.parse_full(output)) { // try to parse it
return ps.get_error_msg();
}
@@ -257,8 +251,7 @@ std::string SelfTest::update(hz::intrusive_ptr<CmdexSync> smartctl_ex)
poll_in_seconds_ = 30; // just a guess
} else {
// seconds per 10%. use double, because e.g. 60sec test gives silly values with int.
double gran = (double(total) / 9.);
double gran = (total / 9.); // seconds per 10%. use double, because e.g. 60sec test gives silly values with int.
// Add 1/10 for disk load delays, etc... . Limit to 15sec, in case of very quick tests.
poll_in_seconds_ = std::max(int64_t(15), int64_t(gran / 3. + (gran / 10.)));
@@ -269,8 +262,7 @@ std::string SelfTest::update(hz::intrusive_ptr<CmdexSync> smartctl_ex)
poll_in_seconds_ = std::max(int64_t(1*60), int64_t(gran / 10.)); // that's 2 min for 180min extended test
debug_out_dump("app", DBG_FUNC_MSG << "total: " << total << ", gran: " << gran
<< ", poll in: " << poll_in_seconds_ << ", remaining secs: " << get_remaining_seconds()
<< ", remaining %: " << int(remaining_percent_) << ", last seen %: " << int(last_seen_percent_) << ".\n");
<< ", poll_in: " << poll_in_seconds_ << ", remaining: " << get_remaining_seconds() << ".\n");
}
} else {
@@ -290,4 +282,6 @@ std::string SelfTest::update(hz::intrusive_ptr<CmdexSync> smartctl_ex)
/// @}
+27 -46
View File
@@ -1,21 +1,15 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#ifndef SELFTEST_H
#define SELFTEST_H
#include <glibmm.h>
#include <string>
#include <stdint.h>
#include "hz/cstdint.h"
#include "hz/intrusive_ptr.h"
#include "storage_device.h"
@@ -23,20 +17,16 @@
/// SMART self-test runner.
class SelfTest : public hz::intrusive_ptr_referenced {
public:
/// Test type
enum test_t {
type_ioffline, ///< Immediate offline, not supported
type_short, ///< Short self-test
type_long, ///< Extended (a.k.a. long) self-test
type_conveyance ///< Conveyance self-test
type_ioffline, // immediate offline, not supported yet
type_short,
type_long,
type_conveyance
};
/// Get displayable name for a test type
static std::string get_test_name(test_t t)
{
switch (t) {
@@ -49,7 +39,7 @@ class SelfTest : public hz::intrusive_ptr_referenced {
}
/// Constructor. \c drive must have the capabilities present in its properties.
// The drive must have the capabilities present in properties.
SelfTest(StorageDeviceRefPtr drive, test_t type)
: drive_(drive), type_(type)
{
@@ -57,8 +47,7 @@ class SelfTest : public hz::intrusive_ptr_referenced {
}
/// Clear results of previous test
void clear()
void clear() // clear results of previous test
{
status_ = StorageSelftestEntry::status_unknown;
remaining_percent_ = -1;
@@ -68,94 +57,86 @@ class SelfTest : public hz::intrusive_ptr_referenced {
}
/// Check if the test is currently active
bool is_active() const
{
return (status_ == StorageSelftestEntry::status_in_progress);
}
/// Get remaining time percent until the test completion.
/// \return -1 if N/A or unknown.
// returns -1 if n/a or unknown.
int8_t get_remaining_percent() const
{
return remaining_percent_;
}
/// Get estimated time of completion for the test.
/// \return -1 if N/A or unknown. Note that 0 is a valid value.
// Returns estimated time of completion for the test. returns -1 if n/a or unknown. 0 is a valid value.
int64_t get_remaining_seconds() const;
/// Get test type
test_t get_test_type() const
{
return type_;
}
/// Get test status
StorageSelftestEntry::status_t get_status() const
{
return status_;
}
/// Get the number of seconds after which the caller should call update().
// get the number of seconds after which the caller should call update().
int64_t get_poll_in_seconds() const
{
return poll_in_seconds_;
}
/// Get a constant "test duration during idle" capability drive's stored capabilities. -1 if N/A.
// gets a constant "test duration during idle" capability drive's stored capabilities. -1 if N/A.
int64_t get_min_duration_seconds() const;
/// Gets the current test type support status from drive's stored capabilities.
// gets the current test type support status from drive's stored capabilities.
bool is_supported() const;
/// Start the test.
/// \return error message on error, empty string on success.
// These return an error message, or empty string if no error.
// start the test
std::string start(hz::intrusive_ptr<CmdexSync> smartctl_ex = 0);
/// Abort the running test.
/// \return error message on error, empty string on success.
// abort the running test
std::string force_stop(hz::intrusive_ptr<CmdexSync> smartctl_ex = 0);
/// Update status variables. The user should call this every get_poll_in_seconds() seconds.
/// \return error message on error, empty string on success.
// update status variables
std::string update(hz::intrusive_ptr<CmdexSync> smartctl_ex = 0);
private:
StorageDeviceRefPtr drive_;
StorageDeviceRefPtr drive_; ///< Drive to run the tests on
test_t type_; ///< Test type
test_t type_;
// status variables:
StorageSelftestEntry::status_t status_; ///< Current status of the test as reported by the drive
int8_t remaining_percent_; ///< Remaining %. 0 means unknown, -1 means N/A. This is set to 100 on start.
int8_t last_seen_percent_; ///< Last reported %, to detect changes in percentage (needed for timer update).
mutable int64_t total_duration_; ///< Total duration needed for the test, as reported by the drive. Constant. This variable acts as a cache.
int64_t poll_in_seconds_; ///< The user is asked to poll after this much seconds have passed.
StorageSelftestEntry::status_t status_;
int8_t remaining_percent_; // 0 means unknown, -1 means n/a. Set to 100 on start.
int8_t last_seen_percent_; // to detect changes in percentage (needed for timer update)
mutable int64_t total_duration_; // total duration needed for the test, as reported by drive. constant. this is a cache.
int64_t poll_in_seconds_; // the user is asked to poll after this much seconds have passed.
Glib::Timer timer_; ///< Counts time since the last percent change
Glib::Timer timer_; // counts time since the last percent change
};
/// A reference-counting pointer to SelfTest
typedef hz::intrusive_ptr<SelfTest> SelfTestPtr;
#endif
/// @}
-145
View File
@@ -1,145 +0,0 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#include <glibmm.h> // Glib::shell_quote()
#include "smartctl_executor.h"
#include "hz/fs_path.h"
#include "hz/win32_tools.h"
#include "rconfig/rconfig_mini.h"
#include "app_pcrecpp.h"
std::string get_smartctl_binary()
{
std::string smartctl_binary;
rconfig::get_data("system/smartctl_binary", smartctl_binary);
#ifdef _WIN32
// look in smartmontools installation directory.
do {
bool use_smt = false;
rconfig::get_data("system/win32_search_smartctl_in_smartmontools", use_smt);
if (!use_smt)
break;
std::string smt_regpath, smt_regpath_wow, smt_regkey, smt_smartctl;
rconfig::get_data("system/win32_smartmontools_regpath", smt_regpath);
rconfig::get_data("system/win32_smartmontools_regpath_wow", smt_regpath_wow); // same as above, but with WOW6432Node
rconfig::get_data("system/win32_smartmontools_regkey", smt_regkey);
rconfig::get_data("system/win32_smartmontools_smartctl_binary", smt_smartctl);
if ((smt_regpath.empty() && smt_regpath_wow.empty()) || smt_regkey.empty() || smt_smartctl.empty())
break;
std::string smt_inst_dir;
hz::win32_get_registry_value_string(HKEY_LOCAL_MACHINE, smt_regpath, smt_regkey, smt_inst_dir);
if (smt_inst_dir.empty()) {
hz::win32_get_registry_value_string(HKEY_LOCAL_MACHINE, smt_regpath_wow, smt_regkey, smt_inst_dir);
}
if (smt_inst_dir.empty()) {
debug_out_info("app", DBG_FUNC_MSG << "Smartmontools installation not found in \"HKLM\\"
<< smt_regpath << "\\" << smt_regkey << "\".\n");
break;
}
debug_out_info("app", DBG_FUNC_MSG << "Smartmontools installation found at \"" << smt_inst_dir
<< "\", using \"" << smt_smartctl << "\".\n");
hz::FsPath p(smt_inst_dir);
p.append(smt_smartctl);
if (!p.exists() || !p.is_file())
break;
smartctl_binary = p.str();
} while (false);
#endif
return smartctl_binary;
}
std::string execute_smartctl(const std::string& device, const std::string& device_opts,
const std::string& command_options,
hz::intrusive_ptr<CmdexSync> smartctl_ex, std::string& smartctl_output)
{
#ifndef _WIN32 // win32 doesn't have slashes in devices names
{
std::string::size_type pos = device.rfind('/'); // find basename
if (pos == std::string::npos) {
debug_out_error("app", DBG_FUNC_MSG << "Invalid device name \"" << device << "\".\n");
return "Invalid device name specified.";
}
}
#endif
if (!smartctl_ex) // if it doesn't exist, create a default one
smartctl_ex = new SmartctlExecutor(); // will be auto-deleted
std::string smartctl_binary = get_smartctl_binary();
if (smartctl_binary.empty()) {
debug_out_error("app", DBG_FUNC_MSG << "Smartctl binary is not set in config.\n");
return "Smartctl binary is not specified in configuration.";
}
std::string smartctl_def_options;
rconfig::get_data("system/smartctl_options", smartctl_def_options);
if (!smartctl_def_options.empty())
smartctl_def_options += " ";
std::string device_specific_options = device_opts;
if (!device_specific_options.empty())
device_specific_options += " ";
smartctl_ex->set_command(Glib::shell_quote(smartctl_binary),
smartctl_def_options + device_specific_options + command_options
+ " " + Glib::shell_quote(device));
if (!smartctl_ex->execute() || !smartctl_ex->get_error_msg().empty()) {
debug_out_warn("app", DBG_FUNC_MSG << "Smartctl binary did not execute cleanly.\n");
smartctl_output = hz::string_trim_copy(hz::string_any_to_unix_copy(smartctl_ex->get_stdout_str()));
// check if it's a device permission error.
// Smartctl open device: /dev/sdb failed: Permission denied
if (app_pcre_match("/Smartctl open device.+Permission denied/mi", smartctl_output)) {
return "Permission denied while opening device.";
}
// smartctl_output = smartctl_ex->get_stdout_str();
return smartctl_ex->get_error_msg();
}
// any_to_unix is needed for windows
smartctl_output = hz::string_trim_copy(hz::string_any_to_unix_copy(smartctl_ex->get_stdout_str()));
if (smartctl_output.empty()) {
debug_out_error("app", DBG_FUNC_MSG << "Smartctl returned an empty output.\n");
return "Smartctl returned an empty output.";
}
return std::string();
}
/// @}
+25 -50
View File
@@ -1,28 +1,25 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#ifndef SMARTCTL_EXECUTOR_H
#define SMARTCTL_EXECUTOR_H
#include <sigc++/sigc++.h>
#include "cmdex.h"
#include "cmdex_sync.h"
/// Smartctl executor template.
// Executor inherits from sigc::trackable
template<class ExecutorSync>
class SmartctlExecutorGeneric : public ExecutorSync {
public:
/// Constructor
SmartctlExecutorGeneric(const std::string& cmd, const std::string& cmdargs)
: ExecutorSync(cmd, cmdargs)
{
@@ -30,14 +27,12 @@ class SmartctlExecutorGeneric : public ExecutorSync {
}
/// Constructor
SmartctlExecutorGeneric()
{
this->construct();
}
/// Virtual destructor
virtual ~SmartctlExecutorGeneric()
{ }
@@ -45,28 +40,27 @@ class SmartctlExecutorGeneric : public ExecutorSync {
protected:
/// Called by constructors
void construct()
{
ExecutorSync::get_command_executor().set_exit_status_translator(&SmartctlExecutorGeneric::translate_exit_status, NULL);
ExecutorSync::cmdex_.set_exit_status_translator(sigc::mem_fun(this,
&SmartctlExecutorGeneric::translate_exit_status));
this->set_error_header("An error occurred while executing smartctl:\n\n");
}
enum {
exit_cant_parse = 1 << 0, ///< Smartctl error code bit
exit_open_failed = 1 << 1, ///< Smartctl error code bit
exit_smart_failed = 1 << 2, ///< Smartctl error code bit
exit_disk_failing = 1 << 3, ///< Smartctl error code bit
exit_prefail_threshold = 1 << 4, ///< Smartctl error code bit
exit_threshold_in_past = 1 << 5, ///< Smartctl error code bit
exit_error_log = 1 << 6, ///< Smartctl error code bit
exit_self_test_log = 1 << 7 ///< Smartctl error code bit
exit_cant_parse = 1 << 0,
exit_open_failed = 1 << 1,
exit_smart_failed = 1 << 2,
exit_disk_failing = 1 << 3,
exit_prefail_threshold = 1 << 4,
exit_threshold_in_past = 1 << 5,
exit_error_log = 1 << 6,
exit_self_test_log = 1 << 7
};
/// Translate smartctl error code to a readable message
static std::string translate_exit_status(int status, void* user_data)
Glib::ustring translate_exit_status(int status)
{
const char* table[] = {
"Command line did not parse.",
@@ -79,7 +73,7 @@ class SmartctlExecutorGeneric : public ExecutorSync {
"The device self-test log contains records of errors."
};
std::string str;
Glib::ustring str;
// check every bit
for (unsigned int i = 0; i <= 7; i++) {
@@ -94,7 +88,7 @@ class SmartctlExecutorGeneric : public ExecutorSync {
}
/// Import the last error from command executor and clear all errors there
// import the last error from cmdex_ and clear all errors there
virtual void import_error()
{
Cmdex& cmdex = this->get_command_executor();
@@ -124,8 +118,7 @@ class SmartctlExecutorGeneric : public ExecutorSync {
/// This is called when an error occurs in command executor.
/// Note: The warnings are already printed via debug_* in cmdex.
// The warnings are already printed via debug_* in cmdex.
virtual void on_error_warn(hz::ErrorBase* e)
{
if (!e)
@@ -139,15 +132,11 @@ class SmartctlExecutorGeneric : public ExecutorSync {
if (error_type == "exit") {
int exit_code = 0;
e->get_code(exit_code);
// Ignore everyone except this.
// Note that we don't treat exit_open_failed as failure because:
// * It may be returned from a DVD that returns product info but has no disk inside;
// * It may be returned from a usb flash drive with -d scsi;
// * exit_cant_parse is returned when opening unsupported usb drives without -d scsi.
if ( !(exit_code & exit_cant_parse) )
// ignore everyone except these
if ( !((exit_code & exit_cant_parse) || (exit_code & exit_open_failed)) )
return;
// ignore giochannel errors - higher level errors will be triggered, and they more user-friendly.
// ignore giochannel errors - higher level errors will be triggered, and they more user-friendly.
} else if (error_type == "giochannel" || error_type == "custom") {
return;
}
@@ -155,33 +144,19 @@ class SmartctlExecutorGeneric : public ExecutorSync {
this->set_error_msg(e->get_message());
}
};
/// Smartctl executor without GUI support
typedef SmartctlExecutorGeneric<CmdexSync> SmartctlExecutor;
/// A reference-counting pointer to SmartctlExecutor
typedef hz::intrusive_ptr<SmartctlExecutor> SmartctlExecutorRefPtr;
/// Get smartctl binary (from config, etc...). Returns an empty string if not found.
std::string get_smartctl_binary();
/// Execute smartctl on device \c device.
/// \return error message on error, empty string on success.
std::string execute_smartctl(const std::string& device, const std::string& device_opts,
const std::string& command_options,
hz::intrusive_ptr<CmdexSync> smartctl_ex, std::string& smartctl_output);
#endif
/// @}
+1 -10
View File
@@ -1,13 +1,8 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#ifndef SMARTCTL_EXECUTOR_GUI_H
#define SMARTCTL_EXECUTOR_GUI_H
@@ -19,16 +14,12 @@
/// Smartctl executor with GUI support
typedef SmartctlExecutorGeneric<CmdexSyncGui> SmartctlExecutorGui;
/// A reference-counting pointer to SmartctlExecutor
typedef hz::intrusive_ptr<SmartctlExecutorGui> SmartctlExecutorGuiRefPtr;
#endif
/// @}
+8 -19
View File
@@ -1,36 +1,27 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_unlicense.txt
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: Public Domain
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib_tests
/// \weakgroup applib_tests
/// @{
#include <iostream>
#include <gtkmm.h>
#include <gtkmm/main.h>
// #include "smartctl_executor_gui.h"
#include "smartctl_executor.h"
#include "smartctl_executor_gui.h"
/// Main function of the test
int main(int argc, char** argv)
{
// Glib::thread_init();
Glib::thread_init();
Gtk::Main m(argc, argv);
// NOTE: Don't use long options (e.g. --info). Use short ones (e.g. -i),
// because long options may be unsupported on some platforms.
// SmartctlExecutor ex("smartctl", "-i /dev/sda");
// SmartctlExecutor ex("smartctl", "--info /dev/sda");
// SmartctlExecutorGui ex("ls", "-l --color=no -R /dev");
// SmartctlExecutorGui ex("lsa", "-1 --color=no /sys/block");
// SmartctlExecutorGui ex("../../../0test_binary.sh", "");
SmartctlExecutor ex("../../../0test_binary.sh", "");
SmartctlExecutorGui ex("../../../0test_binary.sh", "");
// SmartctlExecutor ex("../../../0test_binary.sh", "");
ex.execute();
@@ -57,5 +48,3 @@ int main(int argc, char** argv)
/// @}
File diff suppressed because it is too large Load Diff
+32 -54
View File
@@ -1,13 +1,8 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_gsmartcontrol.txt
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib
/// \weakgroup applib
/// @{
#ifndef SMARTCTL_PARSER_H
#define SMARTCTL_PARSER_H
@@ -19,73 +14,64 @@
/// Smartctl parser.
/// Note: ALL parse_* functions (except parse_full() and parse_version())
/// expect data in unix-newline format!
class SmartctlParser {
public:
/// Property list
typedef std::vector<StorageProperty> prop_list_t;
/// Constructor
SmartctlParser();
// Note: ALL parse_* functions (except parse_full() and parse_version())
// expect data in unix-newline format!
/// Parse full "smartctl -x" output
bool parse_full(const std::string& s, StorageAttribute::DiskType disk_type);
// Parse full "smartctl -a" output
bool parse_full(const std::string& s);
/// Supply any output of smartctl here, the smartctl version will be retrieved.
static bool parse_version(const std::string& s, std::string& version, std::string& version_full);
// supply output of "smartctl --version" here.
// returns empty string on failure.
static std::string parse_version(const std::string& s);
/// Check that the version of smartctl output can be parsed with this parser.
static bool check_parsed_version(const std::string& version_str, const std::string& version_full_str);
// check that the version of smartctl output can be parsed with this parser.
static bool check_version(const std::string& version_str);
/// Convert e.g. "1,000,204,886,016 bytes" to 1.00 TiB [931.51 GB, 1000204886016 bytes]
// convert e.g. "1,000,204,886,016 bytes" to 1.00 TiB [931.51 GB, 1000204886016 bytes]
static std::string parse_byte_size(const std::string& str, uint64_t& bytes, bool extended);
// You don't really need to call these functions, use the ones above.
/// Parse the section part (with "=== .... ===" header) - info or data sections.
// Parse the section part (with "=== .... ===" header) - info or data sections.
bool parse_section(const std::string& header, const std::string& body);
/// Parse the info section (without "===" header).
/// This includes --info and --get=all.
// Parse the info section (without "===" header)
bool parse_section_info(const std::string& body);
/// Parse a component (one line) of the info section
// Parse a component (one line) of the info section
bool parse_section_info_property(StorageProperty& p);
/// Parse the Data section (without "===" header)
// Parse the Data section (without "===" header)
bool parse_section_data(const std::string& body);
/// Parse subsections of Data section
// Parse subsections of Data section
bool parse_section_data_subsection_health(const std::string& sub);
bool parse_section_data_subsection_capabilities(const std::string& sub);
bool parse_section_data_subsection_attributes(const std::string& sub);
bool parse_section_data_subsection_directory_log(const std::string& sub);
bool parse_section_data_subsection_error_log(const std::string& sub);
bool parse_section_data_subsection_selftest_log(const std::string& sub);
bool parse_section_data_subsection_selective_selftest_log(const std::string& sub);
bool parse_section_data_subsection_scttemp_log(const std::string& sub);
bool parse_section_data_subsection_scterc_log(const std::string& sub);
bool parse_section_data_subsection_devstat(const std::string& sub);
bool parse_section_data_subsection_sataphy(const std::string& sub);
/// Check the capabilities for internal properties we can use.
// Check the capabilities for internal properties we can use.
bool parse_section_data_internal_capabilities(StorageProperty& cap);
/// Clear parsed data
void clear()
{
data_full_.clear();
@@ -97,12 +83,10 @@ class SmartctlParser {
}
/// Get "full" data, as passed to parse_full().
std::string get_data_full() const
{
return data_full_;
}
/*
std::string get_data_section_info() const
{
@@ -114,16 +98,12 @@ class SmartctlParser {
return data_section_data_;
}
*/
/// Get parse error message. Call this only if parsing doesn't succeed,
/// to get a friendly error message.
std::string get_error_msg() const
{
return "Cannot parse smartctl output: " + error_msg_;
}
/// Get parse result properties
const prop_list_t& get_properties() const
{
return properties_;
@@ -134,32 +114,26 @@ class SmartctlParser {
private:
/// Add a property into property list, look up and set its description
// adds a property into property list, looks up and sets its description
void add_property(StorageProperty p);
/// Set "full" data ("smartctl -x" output)
void set_data_full(const std::string& s)
{
data_full_ = s;
}
/// Set "info" section data ("smartctl -i" output, or the first part of "smartctl -x" output)
void set_data_section_info(const std::string& s)
{
data_section_info_ = s;
}
/// Parse "data" section data (the second part of "smartctl -x" output).
void set_data_section_data(const std::string& s)
{
data_section_data_ = s;
}
/// Set error message
void set_error_msg(const std::string& s)
{
error_msg_ = s;
@@ -167,15 +141,15 @@ class SmartctlParser {
prop_list_t properties_; ///< Parsed data properties
prop_list_t properties_;
std::string data_full_; ///< full data, filled by parse_full()
std::string data_section_info_; ///< "info" section data, filled by parse_section_info()
std::string data_section_data_; ///< "data" section data, filled by parse_section_data()
// These are filled by the appropriate parse_* functions
std::string data_full_;
std::string data_section_info_;
std::string data_section_data_;
std::string error_msg_; ///< This will be filled with some displayable message on error
std::string error_msg_; // on error this will be filled with displayable message
StorageAttribute::DiskType disk_type_; ///< Disk type (HDD, SSD)
};
@@ -184,6 +158,10 @@ class SmartctlParser {
#endif
/// @}
#endif
+4 -14
View File
@@ -1,13 +1,8 @@
/**************************************************************************
Copyright:
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
License: See LICENSE_unlicense.txt
(C) 2008 Alexander Shaduri <ashaduri 'at' gmail.com>
License: Public Domain
***************************************************************************/
/// \file
/// \author Alexander Shaduri
/// \ingroup applib_tests
/// \weakgroup applib_tests
/// @{
#undef HZ_USE_LIBDEBUG
#define HZ_USE_LIBDEBUG 0
@@ -18,14 +13,13 @@
#include <iostream>
#include <cstdlib>
#include "libdebug/libdebug.h"
#include "hz/debug.h"
#include "hz/fs_file.h"
#include "storage_property.h"
#include "smartctl_parser.h"
/// Main function of the test
int main(int argc, char** argv)
{
if (argc < 2) {
@@ -33,8 +27,6 @@ int main(int argc, char** argv)
return EXIT_FAILURE;
}
debug_register_domain("app");
std::string file_str = argv[1];
hz::File file(file_str);
@@ -47,7 +39,7 @@ int main(int argc, char** argv)
SmartctlParser sp;
if (!sp.parse_full(contents, StorageAttribute::DiskAny)) {
if (!sp.parse_full(contents)) {
debug_out_error("app", "Cannot parse file contents: " << sp.get_error_msg() << "\n");
return EXIT_FAILURE;
}
@@ -86,5 +78,3 @@ int main()
/// @}

Some files were not shown because too many files have changed in this diff Show More