dfc-3.1.0/AUTHORS.md000644 001750 000144 00000001050 13072400202 014210 0ustar00robinusers000000 000000 ## AUTHOR: * Robin Hahling ## CONTRIBUTORS: * Adam Borowski * Alexandre Perrin * Baptiste Daroussin * Cyril Roelandt * Frank Villaro-Dixon * Kevin Gillieron * Landry Breuil * Matthieu Le Jeune * Sylvain Laperche * Tobias Patzl * Michiel Pater ## TRANSLATORS: French: * Robin Hahling Swedish: * Andreas Rönnquist Dutch: * Michiel Pater dfc-3.1.0/CHANGELOG.md000644 001750 000144 00000016651 13072400202 014367 0ustar00robinusers000000 000000 # CHANGELOG ## version 3.1.0 BUGS: * fix type not respecting -W flag * fix alignment issue when both -M and -o options are specified * plug a few memory leaks * escape mount options with "" when exporting to CSV as mount options may typically contain a "," * linux: avoid stat'ing remote file system when local flag is given * consider nfs4 a remote filesystem * correctly link math library (fixes build on Ubuntu) * remove a few extra incorrect CSV separators in CSV export mode * silently ignore EACCESS error on statvfs * fix build failure on Hurd * fix build failure on kFreeBSD FEATURES: * Solaris support * allow CSV separator to be specified via the configuration file * major code refactoring: now, platform specific code is clearly separated and the way to compute required terminal width and display has been vastly improved * add JSON export option * add support for bold font via the configuration file * add -M option to disable "Mounted On" information * add Dutch translation * add git revision in development versions of dfc INCOMPATIBLE CHANGES: * remove "GRIM" compile option - compile flags previously set by "grim" are now defaults * stop translating color names in the configuration file - now, only "english" names are understood ## version 3.0.5 BUGS: * fixed initialization of LFS (see v3.0.2 release notes). LFS option as existing in v3.0.2-v3.0.4 was just wrong: setting LFS option to false would actually enable LFS option... * do not install translated configuration files and man pages when NLS option is disabled * fixed typos in the man ## version 3.0.4 BUGS: * fixed compilation error on *BSD systems introduced in dfc version 3.0.3 ## version 3.0.3 BUGS: * fixed warning message wrongly displayed when calling 'dfc -u h' * fixed various typo fixes * fixed some memory management issues * fixed if tests on potentially NULL values * fixed potential security holes (potentially exploitable buffer overflows caused by misuse of printf function) * fixed dfc hang on no more accessible remote file systems * display a warning in any case when file system cannot be stated instead of exiting on error MISCELLANEOUS: * updated license header and copyright year ## version 3.0.2 BUGS: * fixed dfc failing when getting volume size information from volume >= 4 To on 32-bit hosts (added LFS option, which can be triggered on or off but is on by default) * fixed missing separator on CSV export when -T and -s options where triggered ## version 3.0.1 BUGS: * fixed CMake minimal required version * fixed hyphens and spelling mistakes in manpages FEATURES: * added this changelog file ## version 3.0.0 BUGS: * fixed wrong usage values for FreeBSD * fixed wrong inodes count on FreeBSD FEATURES: * DragonFly BSD support * NetBSD support * OpenBSD support * implemented -o option for Mac OSX * internationalization support * french translation * added an optional configuration file * improved auto-adjust feature * new option that shows used size using -d * new option that allows export to other formats (CSV, HTML, TeX) * new option that allows to show information only for locally mounted file systems using -l * new option to filter based on file system name using -p * new option that allows to sort the output based on file system name using -q Code has also been reorganised and the build system has switched from a simple makefile to using CMake ## version 2.5.0 BUGS: * paths that have more than 3 / are not weirdly truncated anymore * no more overlap when using the -o option * various minor bug fixes and optimizations FEATURES: * Makefile is now compatible with BSD-make * Mac OSX support (still misses the -o option) * -o option support for FreeBSD * new option that prevents the names from being truncated by using -W * sign used to draw the graph has changed from a * to an = sign ## version 2.4.0 FEATURES: * FreeBSD support * reorganised code to make it less monolithic ## version 2.3.0 BUGS: * fixed width of display when aflag not triggered FEATURES: * strings that are too long to be displayed correctly are now truncated and a + sign indicates it. Example: "/dev/mapper/foo-lv_lxc23764-home" ==> "+pper/foo-lv_lxc23764-home" * auto-adjust output based on terminal width * new option to force display (disable auto-adjust mode) * implemented negative matching on file system filtering * various small optimizations ## version 2.2.0 BUGS: * various small bug fixes FEATURES: * color option is now improved: you can choose between 3 modes (auto, always, never); by default, auto is activated * multiple selection is now possible when filtering with -t option ## version 2.1.0 BUGS: * -s option now sum the total of inodes when -i option is triggered * when using human readable, sizes in bytes were displayed like so 3.0B which does not make sense at all cause there is no half-byte FEATURES: * color is now automatically in "color-auto" mode * unit option has been completely reorganized; they have all been replaced by the new -u option * support Tio, Pio, Eio, Zio and Yio units (and as such, To, Po, Eo, Zo, Yo) * when using -i option, a k is now appended to the number of inodes and this number is divided by 1000 * new option (-b) allows you to not display the graph bar * new option (-T) shows the filesystem type (filesystem type is not displayed by default anymore) * new option (-t) allows you to perform filtering on filesystem type ## version 2.0.2 BUGS: * fixed a bug messing up display of information when have gvfs-fuse-daemon ## version 2.0.1 BUGS: * fixed display error when using humanize * fixed a bug causing some special devices not to be skipped * updated manpage ## version 2.0.0 FEATURES: * color support (enabled by default but can be disabled using -c option) * new option (-o) shows information about mount options ## version 1.2.0 FEATURES: * filesystem name is now being less truncated * default behavior is now to print size in human-readable format * new option (-b) to display size in bytes (used to be the default display) * new option (-i) that prints information about the number of inodes and the amount of available ones ## version 1.1.4 BUGS: * fixed a graphical bug that occured when displaying fsname and type ## version 1.1.3 BUGS: * fixed a bug that was causing header to be messed up when using -K, -M or -G option when producing the grand total ## version 1.1.2 BUGS: * fixed percentage calculation for the total ## version 1.1.1 BUGS: * fixed a bug in the function that truncates str * fixed bogus display when using -n option ## version 1.1.0 BUGS: * large filesystem names should now be truncated to avoid messing up what is displayed * Makefile now supports the DESTDIR option FEATURES: * proc, sys and devpts are not displayed anymore * new option to hide the filesystem type by using -t * first decimal is now displayed when using Mio and Mo * new option to display the size in Ko, Mo and Go instead of Kio, Mio and Gio * new option to display a wider bar by using -w * new option that display the total usage by using -s * new option that allows to skip displaying the header ## version 1.0.1 BUGS: * fixed bugs in Makefile ## version 1.0.0 * initial release dfc-3.1.0/CMakeLists.txt000644 001750 000144 00000017334 13072400202 015315 0ustar00robinusers000000 000000 cmake_minimum_required(VERSION 2.8.4) # project informations project(dfc C) set(PACKAGE ${CMAKE_PROJECT_NAME}) set(VERSION_MAJOR 3) set(VERSION_MINOR 1) set(VERSION_PATCH 0) execute_process( COMMAND git rev-parse --short HEAD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE VERSION_REVISION ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE ) # prepend "-" to version_revision if(VERSION_REVISION) set(VERSION_REVISION "-${VERSION_REVISION}") endif() set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_REVISION}) # supported platforms if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(BSD true) elseif(${CMAKE_SYSTEM_NAME} MATCHES "DragonFly") set(BSD true) elseif(${CMAKE_SYSTEM_NAME} MATCHES "kFreeBSD") set(LINUX true) elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") set(BSD true) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") set(LINUX true) elseif(${CMAKE_SYSTEM_NAME} MATCHES "NetBSD") set(BSD true) elseif(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") set(BSD true) elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS") set(SOLARIS true) elseif(${CMAKE_SYSTEM_NAME} MATCHES "GNU") set(LINUX true) else() message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}") endif() # useful defines set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) set(BUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin/${CMAKE_BUILD_TYPE}) set(MAN_DIR ${CMAKE_CURRENT_SOURCE_DIR}/man) set(CONF_DIR ${CMAKE_CURRENT_SOURCE_DIR}/conf) set(PO_DIR ${CMAKE_CURRENT_SOURCE_DIR}/po) include_directories("src") # defines for installation if(DEFINED PREFIX) set(PREFIX ${PREFIX} CACHE PATH "install prefix") set(CMAKE_INSTALL_PREFIX ${PREFIX}) else() set(PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "install prefix") endif() # use a sysconfdir if specified if(DEFINED SYSCONFDIR) set(SYSCONFDIR ${SYSCONFDIR} CACHE PATH "config directory") else() set(SYSCONFDIR ${PREFIX}/etc CACHE PATH "config directory") endif() # share directory if(DEFINED SHAREDIR) set(SHAREDIR ${SHAREDIR} CACHE PATH "share directory") else() set(SHAREDIR ${PREFIX}/share CACHE PATH "share directory") endif() # locale if(DEFINED LOCALEDIR) set(LOCALEDIR ${LOCALEDIR} CACHE PATH "locale directory") else() set(LOCALEDIR ${SHAREDIR}/locale CACHE PATH "locale directory") endif() # if XDG Config Dir is specified, use it if(DEFINED XDG_CONFIG_DIR) set(XDG_CONFIG_DIR ${XDG_CONFIG_DIR} CACHE PATH "xdg config directory") else() set(XDG_CONFIG_DIR ${SYSCONFDIR}/xdg CACHE PATH "xdf config directory") endif() # man path if(DEFINED MAN_PATH) set(MAN_PATH ${MAN_PATH} CACHE PATH "manpage directory") else() set(MAN_PATH ${SHAREDIR}/man CACHE PATH "manpage directory") endif() # doc path if(DEFINED DOC_PATH) set(DFC_DOC_PATH ${DFC_DOC_PATH} CACHE PATH "doc directory") else() set(DFC_DOC_PATH ${SHAREDIR}/doc/${PACKAGE} CACHE PATH "doc directory") endif() # Check for libintl find_package(Libintl) if (LIBINTL_FOUND) option(NLS_ENABLED "Translation support with gettext" on) else() option(NLS_ENABLED "Translation support with gettext" off) endif() option(LFS_ENABLED "Enable macros for Large File Source. Required on 32-bit systems but should not cause any problems if defined on non 32-bit systems anyway, thus enabled by default." on) # set compiler flags set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") if(LINUX) ADD_DEFINITIONS(-D_XOPEN_SOURCE=600) elseif(SOLARIS) ADD_DEFINITIONS(-D__EXTENSIONS__) endif() include(CheckCCompilerFlag) check_c_compiler_flag(-Wsign-conversion HAS_WSIGN_CONVERSION) check_c_compiler_flag(-Wdouble-promotion HAS_WDOUBLE_PROMOTION) check_c_compiler_flag(-Wlogical-op HAS_WLOGICAL_OP) check_c_compiler_flag(-Wjump-misses-init HAS_WJUMP_MISSES_INIT) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -Wconversion -Wstrict-prototypes -Wcast-qual -Wcast-align -Wshadow -Wredundant-decls -Wundef -Wfloat-equal -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wpointer-arith -Wbad-function-cast -Wnested-externs -Wold-style-definition -Wformat=2 -Winit-self -Wwrite-strings -Wmissing-prototypes -pipe") if(HAS_WSIGN_CONVERSION) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wsign-conversion") endif() if(HAS_WDOUBLE_PROMOTION) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wdouble-promotion") endif() if(HAS_WLOGICAL_OP) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wlogical-op") endif() if(HAS_WJUMP_MISSES_INIT) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wjump-misses-init") endif() set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O2 -DNDEBUG") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g3 -ggdb3 -Wpadded -Wpacked") if(CMAKE_COMPILER_IS_GNUCC) # gcc warns about strftime format when using std=c99. According to # strftime(3), it is safe to remove this warning set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format-y2k") endif() # platform specific source files if(BSD) set(SERVICE_SRC_FILE "${SOURCE_DIR}/platform/services-bsd.c") elseif(LINUX) set(SERVICE_SRC_FILE "${SOURCE_DIR}/platform/services-linux.c") elseif(SOLARIS) set(SERVICE_SRC_FILE "${SOURCE_DIR}/platform/services-solaris.c") else() message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}") endif() set(EXECUTABLE_NAME ${CMAKE_PROJECT_NAME}) SET(SRCS ${SOURCE_DIR}/dotfile.c ${SOURCE_DIR}/dfc.c ${SOURCE_DIR}/list.c ${SOURCE_DIR}/util.c ${SOURCE_DIR}/export/csv.c ${SOURCE_DIR}/export/html.c ${SOURCE_DIR}/export/json.c ${SOURCE_DIR}/export/tex.c ${SOURCE_DIR}/export/text.c ${SERVICE_SRC_FILE} ) add_executable( ${EXECUTABLE_NAME} ${SRCS} ) if(LFS_ENABLED) add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64) endif() if(NLS_ENABLED) add_definitions(-DNLS_ENABLED) # load gettext module for translation set(GettextTranslate_ALL true) set(GettextTranslate_GMO_BINARY true) include(GettextTranslate) add_subdirectory(po) include_directories(${LIBINTL_INCLUDE_DIR}) target_link_libraries(${EXECUTABLE_NAME} ${LIBINTL_LIBRARIES}) endif() # link libraries target_link_libraries(${EXECUTABLE_NAME} m) add_definitions(-DPACKAGE="${PACKAGE}" -DVERSION="${VERSION}" -DLOCALEDIR="${LOCALEDIR}") set(DFC_DOC_FILES AUTHORS.md CHANGELOG.md HACKING.md LICENSE README.md TRANSLATORS.md ) mark_as_advanced(CMAKE_INSTALL_PREFIX) set(DFC_SYSCONFDIR ${XDG_CONFIG_DIR}/${PACKAGE}) file(STRINGS ${PO_DIR}/LINGUAS LINGUAS REGEX "^[^#].*") string(REGEX MATCHALL "[^ ]+" languages ${LINGUAS}) # rule to generate a source tarball set(CPACK_SOURCE_GENERATOR "TGZ") set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${VERSION}") set(CPACK_SOURCE_IGNORE_FILES "~$" ".directory" ".swp$" "^${PROJECT_SOURCE_DIR}/.git/" "^${PROJECT_SOURCE_DIR}/build/" "${PROJECT_SOURCE_DIR}/.gitignore$" "${PROJECT_SOURCE_DIR}/po/dfc.pot$" "${CPACK_SOURCE_IGNORE_FILES}") include(CPack) add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) # installation install(TARGETS ${EXECUTABLE_NAME} RUNTIME DESTINATION bin) install(FILES ${MAN_DIR}/dfc.1 DESTINATION ${MAN_PATH}/man1) install(FILES ${CONF_DIR}/dfcrc DESTINATION ${DFC_SYSCONFDIR}) if(NLS_ENABLED) foreach(lang ${languages}) install(FILES ${MAN_DIR}/${lang}/${PACKAGE}.1 DESTINATION ${MAN_PATH}/${lang}/man1) install(FILES ${CONF_DIR}/${lang}/dfcrc DESTINATION ${DFC_SYSCONFDIR}/${lang}) endforeach() endif() install(FILES ${DFC_DOC_FILES} DESTINATION ${DFC_DOC_PATH}) # uninstall target configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) dfc-3.1.0/HACKING.md000644 001750 000144 00000001325 13072400202 014134 0ustar00robinusers000000 000000 Patches are welcome! Just keep in mind the following: * keep the same coding style * your code must fit in 80 columns wide with a TAB of 8 * always check what a function returns if it is non-void. If you do not care about what is returned, explicitly declare it by casting it to void. * preferably use 'git format-patch' to generate your patch You can send your patch via email to the author: Robin Hahling: Or register to the official website: https://projects.gw-computing.net/projects/dfc and add an issue with your patch attached. Pull requests on the Github mirror are also welcomed. Thanks for your contribution! dfc-3.1.0/LICENSE000644 001750 000144 00000002736 13072400202 013562 0ustar00robinusers000000 000000 Copyright (c) 2012-2017, Robin Hahling 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 the author 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 HOLDER 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. dfc-3.1.0/Makefile000644 001750 000144 00000000543 13072400202 014207 0ustar00robinusers000000 000000 all: release release: _mkdir_build cd build && cmake -DCMAKE_BUILD_TYPE=RELEASE .. && make debug: _mkdir_build cd build && cmake -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_VERBOSE_MAKEFILE=YES .. && make clean: rm -rf build install: release $(MAKE) -C build install _mkdir_build: test -d build || mkdir build .PHONY: all release debug _mkdir_build clean dfc-3.1.0/README.md000644 001750 000144 00000007564 13072400202 014040 0ustar00robinusers000000 000000 # README `dfc` is a tool to report file system space usage information. When the output is a terminal, it uses color and graphs by default. It has a lot of features such as HTML, JSON and CSV export, multiple filtering options, the ability to show mount options and so on. ## BUILD `cmake` is required to build `dfc`. For convenience, a simple `Makefile` (which calls `cmake` under the hood) is provided. I suggest you create a `build` directory in which you compile `dfc`. This is of course not required but it will prevent files from being created everywhere in the source folder. ### BUILD STEPS Create the build directory: mkdir build Navigate into it: cd build Run the `cmake` command to generate a `Makefile` that works for your OS: cmake .. Now you can use the make command to build `dfc`: make The `dfc` binary will be placed into a `bin` sub-directory. ### BUILD OPTIONS Several options can be tweaked before you compile `dfc`. To activate / deactivate or change them, you need to do it at the `cmake` step. Note that you may also use `ccmake` instead which gives you a `curses` interface to tweak the options. By default, translations are enabled. They require `gettext` to be installed on the system. You can however easily disable them in which case no translations nor language translated configuration files will be installed. cmake .. -DNLS_ENABLED=false `dfc` has also the `LFS` option enabled by default. This option activates compile flags in order to support listing of large file systems (over 4G) on 32-bit hosts. This will not harm 64-bit systems if activated but if you feel the need to deactivate it, use the following: cmake .. -DLFS_ENABLED=false Different types of build are available. Most people will only care about `RELEASE` which is the build type that shall be used when distributing the software as binary or installing it as it adds some optimization flags. To enable `RELEASE` build use the following: cmake .. -DCMAKE_BUILD_TYPE=RELEASE Developers might care about `DEBUG` build when debugging the program as it adds debug flags such as `-g3`. Enable it like so: cmake .. -DCMAKE_BUILD_TYPE=DEBUG Note that by default, `dfc` build with very strict compilers flags. ## RUN Once built, you can run `dfc` by typing: ./dfc from within the directory where `dfc` is located. See `./dfc -h` for quick options and usage overview or read the manual page. ## INSTALL By default, `dfc` binary will be installed in `/usr/local/bin`. As `root`, type: make install You can also choose some standards parameters like where the files need to be installed. This needs to be done when using the `cmake` command. Example (from the previously created build directory): cmake .. -DPREFIX=/usr -DSYSSCONFDIR=/etc -DCMAKE_BUILD_TYPE=RELEASE Then run the `make install` and it will install `dfc` according to what you chose in the previous step. ## CONFIGURATION FILE The configuration file found in `conf/dfcrc` needs to be placed here if one desires to use it: $XDG_CONFIG_HOME/dfc/dfcrc Note that if, for instance, French is the language you use, you should then use the configuration file that has been translated into French (found in `conf/fr/dfcrc`) and so on for any language into which `dfc` has been translated. If your operating system does not support `XDG Base Directory Specification` it can then be placed in this directory: $HOME/.config/dfc/dfcrc Or, last choice, directly in `$HOME` (but the name has to be preceded by a dot): $HOME/.dfcrc ## INFORMATION FOR PACKAGERS Here is the list of dependencies: * standard C library Yep, that should be it. :) Please, note that `gettext` is required in order to build translations. If you do not want to package `dfc` with translation support, use the option to disable translation as explained in the build section. Of course, `cmake` is a build dependency. dfc-3.1.0/TRANSLATORS.md000644 001750 000144 00000006412 13072400202 014706 0ustar00robinusers000000 000000 # INFORMATION FOR TRANSLATORS First, thanks for taking the time to translate dfc :-) You will find instructions here about how you should proceed to perform the translation. If you want to translate dfc, there are three things to translate: * The program itself * The manpage * The configuration file Once you translated all of this, send those three file to the author: * The po file * The translated manpage * The tanslated configuration file Read the instructions below carefully in order to be able to produce a nice translation. ## TRANSLATE THE PROGRAM **IMPORTANT NOTES:** * Symbols like %s, \n, etc must remain untouched. * Strings from the file text.c that are completely capitalized, like "FILESYSTEM " for instance, must be translated in a string of the same length. If not, the output of dfc will be messed up. So, just find a way and truncate the name if required. For instance, in French, I would translate it this way: "SYS. FICH. " Completely capitalized strings from other files than text.c can be translated as usual. ### CREATE A NEW TRANSLATION Here are the steps you need to follow in order to translate dfc into a new language: * Build dfc as explained in the README file. This will generate an updated dfc.pot file in the po directory which you will use to generate a po file for your own language. * Navigate to the po directory. * Generate a new po file for the language you want to translate into. In the example below, I assume it will be translated into French: msginit -l fr -i dfc.pot -o fr.po **Note:** -l option is required only if you want to translate into another locale than the one used on your computer. * Now you can start translating all the strings in the *.po file with any text editor or *.po file editor (poedit for instance). You should then check your translation (see next step). ### CHECKING YOUR TRANSLATION Simply use this command to check your translation for errors and completeness (here, I assume you want to check the french translation): msgfmt -c --statistics fr.po -o /dev/null If you get this error message when running the command: "invalid multibyte sequence" make sure charset is set to "utf-8" (and not ASCII or something else) in the po file: "Content-Type: text/plain; charset=utf-8\n" ### UPDATING A TRANSLATION * Build dfc as explained in the README file in order to generate the dfc.pot file. * Issue this command to merge the existing po file (here, I assume it is French): msgmerge --update fr.po dfc.pot * Open the *.po file and update translation. Once done, as usual, check your translation. ### ADDING THE TRANSLATION Add a space and the language code to po/LINGUAS. For example: if you add Dutch (nl): fr nl ## TRANSLATE THE MANPAGE Simply translate the file 'dfc.1' located in 'man' folder using your favorite text editor. ## TRANSLATE THE CONFIGURATION FILE Simply translate the file 'dfcrc' located in 'conf' folder using your favorite text editor. Two things though: * Colors value must have exactly the same translation as the one you did for the po file. * Do NOT translate the values before the equal sign: * color_header * color_low * color_medium * ... dfc-3.1.0/cmake/000755 001750 000144 00000000000 13072400264 013635 5ustar00robinusers000000 000000 dfc-3.1.0/cmake/cmake_uninstall.cmake.in000644 001750 000144 00000001765 13072400202 020416 0ustar00robinusers000000 000000 if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) string(REGEX REPLACE "\n" ";" files "${files}") list(REVERSE files) foreach (file ${files}) message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") if (EXISTS "$ENV{DESTDIR}${file}") execute_process( COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}" OUTPUT_VARIABLE rm_out RESULT_VARIABLE rm_retval ) if(NOT ${rm_retval} EQUAL 0) message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") endif (NOT ${rm_retval} EQUAL 0) else (EXISTS "$ENV{DESTDIR}${file}") message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") endif (EXISTS "$ENV{DESTDIR}${file}") endforeach(file) dfc-3.1.0/cmake/modules/000755 001750 000144 00000000000 13072400264 015305 5ustar00robinusers000000 000000 dfc-3.1.0/cmake/modules/COPYING-CMAKE-SCRIPTS000644 001750 000144 00000002457 13072400202 020303 0ustar00robinusers000000 000000 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 copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the 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 not 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. dfc-3.1.0/cmake/modules/FindLibintl.cmake000644 001750 000144 00000002453 13072400202 020501 0ustar00robinusers000000 000000 # Try to find Libintl functionality # Once done this will define # # LIBINTL_FOUND - system has Libintl # LIBINTL_INCLUDE_DIR - Libintl include directory # LIBINTL_LIBRARIES - Libraries needed to use Libintl # # Copyright (c) 2006, Chusslove Illich, # Copyright (c) 2007, Alexander Neundorf, # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if(LIBINTL_INCLUDE_DIR AND LIBINTL_LIB_FOUND) set(Libintl_FIND_QUIETLY TRUE) endif(LIBINTL_INCLUDE_DIR AND LIBINTL_LIB_FOUND) find_path(LIBINTL_INCLUDE_DIR libintl.h) set(LIBINTL_LIB_FOUND FALSE) if(LIBINTL_INCLUDE_DIR) include(CheckFunctionExists) check_function_exists(gettext LIBINTL_LIBC_HAS_GETTEXT) if (LIBINTL_LIBC_HAS_GETTEXT) set(LIBINTL_LIBRARIES) set(LIBINTL_LIB_FOUND TRUE) else (LIBINTL_LIBC_HAS_GETTEXT) find_library(LIBINTL_LIBRARIES NAMES intl libintl ) if(LIBINTL_LIBRARIES) set(LIBINTL_LIB_FOUND TRUE) endif(LIBINTL_LIBRARIES) endif (LIBINTL_LIBC_HAS_GETTEXT) endif(LIBINTL_INCLUDE_DIR) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Libintl DEFAULT_MSG LIBINTL_INCLUDE_DIR LIBINTL_LIB_FOUND) mark_as_advanced(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARIES LIBINTL_LIBC_HAS_GETTEXT LIBINTL_LIB_FOUND) dfc-3.1.0/cmake/modules/GettextTranslate.cmake000644 001750 000144 00000022647 13072400202 021614 0ustar00robinusers000000 000000 # Copyright (c) 2012, Jarryd Beck # 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. # # 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 HOLDER 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. # This module creates build rules for updating translation files made # with gettext # In your top level CMakeLists.txt, do # include(GettextTranslate) # then in any po directory where you want things to be translated, write # GettextTranslate() # # This module also finds the gettext binaries. If these are in a non-standard # location, you can define the following variables to provide paths to search # in # GettextTranslate_BINARIES --- a path in which to look for every program # GettextTranslate_XGETTEXT --- the xgettext program # GettextTranslate_MSGINIT --- the msginit program # GettextTranslate_MSGFILTER --- the msgfilter program # GettextTranslate_MSGCONV --- the msgconv program # GettextTranslate_MSGMERGE --- the msgmerge program # GettextTranslate_MSGFMT --- the msgfmt program # these are searched first before $PATH, so set this if you have your own # version that overrides the system version # # it reads variables from Makevars, one of the most important being DOMAIN # it reads the languages to generate from LINGUAS # # it adds the following targets # update-po # update-gmo # ${DOMAIN}-pot.update # generate-${DOMAIN}-${lang}-po # generate-${DOMAIN}-${lang}-gmo # # where ${DOMAIN} is the DOMAIN variable read from Makevars # and ${lang} is each language mentioned in LINGUAS # # if you want update-gmo to be added to the "all" target, then define the # variable GettextTranslate_ALL before including this file # # by default, the gmo files are built in the source directory. If you want # them to be built in the binary directory, then define the variable # GettextTranslate_GMO_BINARY # add the update-po and update-gmo targets, the actual files that need to # depend on this will be added as we go if (DEFINED GettextTranslate_ALL) set(_addToALL "ALL") endif() add_custom_target(update-po) add_custom_target(update-gmo ${_addToALL}) #look for all the programs #xgettext, msginit, msgfilter, msgconv, msgmerge, msgfmt function(REQUIRE_BINARY binname varname) if (defined ${${varname}-NOTFOUND}) message(FATAL_ERROR "Could not find " binname) endif() endfunction() find_program(GettextTranslate_XGETTEXT_EXECUTABLE xgettext HINTS ${GettextTranslate_XGETTEXT} ${GettextTranslate_BINARIES} ) REQUIRE_BINARY(xgettext GettextTranslate_XGETTEXT_EXECUTABLE) find_program(GettextTranslate_MSGINIT_EXECUTABLE msginit HINTS ${GettextTranslate_MSGINIT} ${GettextTranslate_BINARIES} ) REQUIRE_BINARY(msginit GettextTranslate_MSGINIT_EXECUTABLE) find_program(GettextTranslate_MSGFILTER_EXECUTABLE msgfilter HINTS ${GettextTranslate_MSGFILTER} ${GettextTranslate_BINARIES} ) REQUIRE_BINARY(msgfilter GettextTranslate_MSGFILTER_EXECUTABLE) find_program(GettextTranslate_MSGCONV_EXECUTABLE msgconv HINTS ${GettextTranslate_MSGCONV} ${GettextTranslate_BINARIES} ) REQUIRE_BINARY(msgconv GettextTranslate_MSGCONV_EXECUTABLE) find_program(GettextTranslate_MSGMERGE_EXECUTABLE msgmerge HINTS ${GettextTranslate_MSGMERGE} ${GettextTranslate_BINARIES} ) REQUIRE_BINARY(msgmerge GettextTranslate_MSGMERGE_EXECUTABLE) find_program(GettextTranslate_MSGFMT_EXECUTABLE msgfmt HINTS ${GettextTranslate_MSGFMT} ${GettextTranslate_BINARIES} ) REQUIRE_BINARY(msgfmt GettextTranslate_MSGFMT_EXECUTABLE) mark_as_advanced( GettextTranslate_MSGCONV_EXECUTABLE GettextTranslate_MSGFILTER_EXECUTABLE GettextTranslate_MSGFMT_EXECUTABLE GettextTranslate_MSGINIT_EXECUTABLE GettextTranslate_MSGMERGE_EXECUTABLE GettextTranslate_XGETTEXT_EXECUTABLE ) macro(GettextTranslate) if(GettextTranslate_GMO_BINARY) set (GMO_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}) else() set (GMO_BUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR}) endif() if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/POTFILES.in) message(FATAL_ERROR "There is no POTFILES.in in ${CMAKE_CURRENT_SOURCE_DIR}") endif() if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Makevars) message(FATAL_ERROR "There is no Makevars in ${CMAKE_CURRENT_SOURCE_DIR}") endif() file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/Makevars makevars REGEX "^[^=]+=(.*)$" ) foreach(makevar ${makevars}) string(REGEX REPLACE "^([^= ]+) =[ ]?(.*)$" "\\1" MAKEVAR_KEY ${makevar}) string(REGEX REPLACE "^([^= ]+) =[ ]?(.*)$" "\\2" MAKEVAR_${MAKEVAR_KEY} ${makevar}) endforeach() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/POTFILES.in ${CMAKE_CURRENT_BINARY_DIR}/POTFILES COPYONLY ) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/LINGUAS ${CMAKE_CURRENT_BINARY_DIR}/LINGUAS COPYONLY ) #set the directory to not clean set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY CLEAN_NO_CUSTOM true) file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/POTFILES.in potfiles REGEX "^[^#].*" ) foreach(potfile ${potfiles}) list(APPEND source_translatable ${CMAKE_CURRENT_SOURCE_DIR}/${MAKEVAR_top_builddir}/${potfile}) endforeach() set(TEMPLATE_FILE ${MAKEVAR_DOMAIN}.pot) set(TEMPLATE_FILE_ABS ${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_FILE}) add_custom_target(${MAKEVAR_DOMAIN}.pot-update DEPENDS ${TEMPLATE_FILE_ABS} ) string(REGEX MATCHALL "[^ ]+" XGETTEXT_OPTS ${MAKEVAR_XGETTEXT_OPTIONS}) add_custom_command(OUTPUT ${TEMPLATE_FILE_ABS} COMMAND ${GettextTranslate_XGETTEXT_EXECUTABLE} ${XGETTEXT_OPTS} -o ${TEMPLATE_FILE_ABS} --default-domain=${MAKEVAR_DOMAIN} --add-comments=TRANSLATORS: --copyright-holder=${MAKEVAR_COPYRIGHT_HOLDER} --msgid-bugs-address="${MAKEVAR_MSGID_BUGS_ADDRESS}" --directory=${MAKEVAR_top_builddir} --files-from=${CMAKE_CURRENT_BINARY_DIR}/POTFILES --package-version=${VERSION} --package-name=${CMAKE_PROJECT_NAME} DEPENDS ${source_translatable} ${CMAKE_CURRENT_SOURCE_DIR}/POTFILES.in WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) add_dependencies(update-po ${MAKEVAR_DOMAIN}.pot-update) file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/LINGUAS LINGUAS REGEX "^[^#].*") string(REGEX MATCHALL "[^ ]+" languages ${LINGUAS}) foreach(lang ${languages}) set(PO_FILE_NAME "${CMAKE_CURRENT_SOURCE_DIR}/${lang}.po") set(GMO_FILE_NAME "${GMO_BUILD_DIR}/${lang}.gmo") set(PO_TARGET "generate-${MAKEVAR_DOMAIN}-${lang}-po") set(GMO_TARGET "generate-${MAKEVAR_DOMAIN}-${lang}-gmo") list(APPEND po_files ${PO_TARGET}) list(APPEND gmo_files ${GMO_TARGET}) if(${lang} MATCHES "en@(.*)quot") add_custom_command(OUTPUT ${lang}.insert-header COMMAND sed -e "'/^#/d'" -e 's/HEADER/${lang}.header/g' ${CMAKE_CURRENT_SOURCE_DIR}/insert-header.sin > ${lang}.insert-header ) #generate the en@quot files add_custom_command(OUTPUT ${PO_FILE_NAME} COMMAND ${GettextTranslate_MSGINIT_EXECUTABLE} -i ${TEMPLATE_FILE_ABS} --no-translator -l ${lang} -o - 2>/dev/null | sed -f ${CMAKE_CURRENT_BINARY_DIR}/${lang}.insert-header | ${GettextTranslate_MSGCONV_EXECUTABLE} -t UTF-8 | ${GettextTranslate_MSGFILTER_EXECUTABLE} sed -f ${CMAKE_CURRENT_SOURCE_DIR}/`echo ${lang} | sed -e 's/.*@//'`.sed 2>/dev/null > ${PO_FILE_NAME} DEPENDS ${lang}.insert-header ${TEMPLATE_FILE_ABS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) else() add_custom_command(OUTPUT ${PO_FILE_NAME} COMMAND ${GettextTranslate_MSGMERGE_EXECUTABLE} --lang=${lang} ${PO_FILE_NAME} ${TEMPLATE_FILE_ABS} -o ${PO_FILE_NAME}.new COMMAND mv ${PO_FILE_NAME}.new ${PO_FILE_NAME} DEPENDS ${TEMPLATE_FILE_ABS} ) endif() add_custom_command(OUTPUT ${GMO_FILE_NAME} COMMAND ${GettextTranslate_MSGFMT_EXECUTABLE} -c --statistics --verbose -o ${GMO_FILE_NAME} ${PO_FILE_NAME} DEPENDS ${PO_TARGET} ) add_custom_target(${GMO_TARGET} DEPENDS ${GMO_FILE_NAME}) add_custom_target(${PO_TARGET} DEPENDS ${PO_FILE_NAME}) add_dependencies(${PO_TARGET} ${MAKEVAR_DOMAIN}.pot-update) install(FILES ${GMO_FILE_NAME} DESTINATION ${LOCALEDIR}/${lang}/LC_MESSAGES RENAME ${MAKEVAR_DOMAIN}.mo ) endforeach() add_dependencies(update-po ${po_files}) add_dependencies(update-gmo ${gmo_files}) #string(REGEX MATCH "^[^=]+=(.*)$" parsed_variables ${makevars}) endmacro() dfc-3.1.0/conf/000755 001750 000144 00000000000 13072400264 013502 5ustar00robinusers000000 000000 dfc-3.1.0/conf/dfcrc000644 001750 000144 00000003210 13072400202 014472 0ustar00robinusers000000 000000 # Optional configuration file for dfc # Colors used for the default text output # Possible values are: # - black # - red # - green # - yellow # - blue # - magenta # - cyan # - white # Note: it only concerns foreground colors # Display bold font or extra light colors # Note: This might work differently on some terminals # Use either "yes" or "no" bold_font = no # Header color color_header = blue # Color when usage is low color_low = green # Color when usage is medium color_medium = yellow # Color when usage is high color_high = red # Values in percent when color changes in the graph # starting value from which usage is considered medium graph_medium = 50 # starting value from which usage is considered high graph_high = 75 # Symbol used for the graph (can be any ASCII symbol) graph_symbol = = # You can also choose the colors for the HTML export # Color values can take any of html recognized value # For instance, this is white: #FFFFFF # This is red: #FF0000 # Etc. # NOTE: you MUST ommit the # sign when setting it here # (white becomes FFFFFF and so on) # Header background color (also used in footer) html_color_header_bg = 970000 # Header font color (also used in footer) html_color_header_fg = FFFFFF # Cell background color html_color_cell_bg = E9E9E9 # Cell font color html_color_cell_fg = 000000 # Background color on mouse hover html_color_hover_bg = FFFFFF # Font color on mouse hover html_color_hover_fg = 000000 # Color when usage is low html_color_low = 348017 # Color when usage is medium html_color_medium = FDD017 # Color when usage is high html_color_high = F62217 # separator for CSV export csv_separator = , # vim: set noet syn=conf dfc-3.1.0/conf/fr/000755 001750 000144 00000000000 13072400264 014111 5ustar00robinusers000000 000000 dfc-3.1.0/conf/fr/dfcrc000644 001750 000144 00000004213 13072400202 015105 0ustar00robinusers000000 000000 # Fichier de configuration optionnel pour dfc # Couleurs utilisées pour l'affichage par défaut en mode texte # Les valeurs possibles sont les suivantes: # - black (noir) # - red (rouge) # - green (vert) # - yellow (jaune) # - blue (bleu) # - magenta (magenta) # - cyan (cyan) # - white (blanc) # Note: cela concerne uniquement les couleurs en premier-plan # Afficher en gras ou couleurs claires # Note: Cela peut ne pas fonctionner avec certains terminaux # "yes"="oui"; "no"="non" bold_font = no # Couleur de l'entête color_header = blue # Couleur lorsque le taux d'utilisation est faible color_low = green # Couleur lorsque le taux d'utilisation est moyen color_medium = yellow # Couleur lorsque le taux d'utilisation est élevé color_high = red # Valeur en pourcent déterminant le changement de couleur dans le graphe # valeur de départ pour laquelle le taux d'utilisation est considéré moyen graph_medium = 50 # valeur de départ pour laquelle le taux d'utilisation est considéré élevé graph_high = 75 # Symbole utilisé pour le graphe (cela peut être n'importe quel symbole ASCII) graph_symbol = = # Vous pouvez également choisir les couleurs pour l'export HTML # Les couleurs peuvent prendre n'importe quelle valeur html reconnue # Par exemple, ceci est blanc: #FFFFFF # Ceci est rouge: #FF0000 # Etc. # NOTE: vous DEVEZ omettre le symbole # ici # (blanc devient FFFFF etc.) # Couleur de fond de l'entête (valable également pour le pied de page) html_color_header_bg = 970000 # Couleur de la police de l'entête (valable également pour le pied de page) html_color_header_fg = FFFFFF # Couleur de fond des cellules html_color_cell_bg = E9E9E9 # Couleur de police des cellules html_color_cell_fg = 000000 # Couleur de fond au survol de la souris html_color_hover_bg = FFFFFF # Couleur de la police au survol de la souris html_color_hover_fg = 000000 # Couleur lorsque le taux d'utilisation est faible html_color_low = 348017 # Couleur lorsque le taux d'utilisation est moyen html_color_medium = FDD017 # Couleur lorsque le taux d'utilisation est élevé html_color_high = F62217 # Séparateur pour l'export en CSV csv_separator = , # vim: set noet syn=conf dfc-3.1.0/conf/nl/000755 001750 000144 00000000000 13072400264 014113 5ustar00robinusers000000 000000 dfc-3.1.0/conf/nl/dfcrc000644 001750 000144 00000003717 13072400202 015117 0ustar00robinusers000000 000000 # Optioneel configuratiebestand voor dfc # Kleuren die gebruikt worden voor de standaard tekst output # Mogelijke waarden zijn: # - black (zwart) # - red (rood) # - green (groen) # - yellow (geel) # - blue (blauw) # - magenta (magenta) # - cyan (cyaan) # - white (wit) # Opmerking: Dit geldt alleen voor voorgrondkleuren # Gebruik dikgedrukte lettertype of extra lichte kleurweergave # Opmerking: Dit werkt mogelijk anders op sommige terminals # Gebruik "yes" voor ja, of "no" voor nee bold_font = no # Kleur van koptekst color_header = blue # Kleur wanneer het gebruik laag is color_low = green # Kleur wanneer het gebruik gemiddeld is color_medium = yellow # Kleur wanneer het gebruik hoog is color_high = red # Waarden in procent wanneer kleuren veranderen in de grafiek # Startwaarde vanaf wanneer het gebruikt wordt gezien als gemiddeld graph_medium = 50 # Startwaarde vanaf wanneer het gebruikt wordt gezien als hoog graph_high = 75 # Symbool dat gebruikt wordt voor de grafiek (kan elk ASCII symbool zijn) graph_symbol = = # U kunt ook de kleuren kiezen voor de HTML export # Waarden van kleuren kunnen elke bekende html waarde zijn # Dit is bijvoorbeeld wit: #FFFFFF # En dit is rood: #FF0000 # Etc. # OPMERKING: U MOET het # teken weglaten wanneer u het hier instelt # (wit wordt FFFFFF enzovoort) # # HTML waarden: # # Koptekst achtergrondkleur (wordt ook gebruikt als voettekst) html_color_header_bg = 970000 # Koptekst voorgrondkleur (also used in footer) html_color_header_fg = FFFFFF # Cel achtergrondkleur html_color_cell_bg = E9E9E9 # Cel voorgrondkleur html_color_cell_fg = 000000 # Achtergrondkleur bij mouse hover html_color_hover_bg = FFFFFF # Voorgrondkleur bij mouse hover html_color_hover_fg = 000000 # Kleur wanneer het gebruik laag is html_color_low = 348017 # Kleur wanneer het gebruik gemiddeld is html_color_medium = FDD017 # Kleur wanneer het gebruik hoog is html_color_high = F62217 # scheidingsteken voor CSV export csv_separator = : # vim: set noet syn=conf dfc-3.1.0/man/000755 001750 000144 00000000000 13072400264 013330 5ustar00robinusers000000 000000 dfc-3.1.0/man/dfc.1000644 001750 000144 00000013545 13072400202 014146 0ustar00robinusers000000 000000 .TH dfc 1 "April 09, 2017" "version 3.1.0" "USER COMMANDS" .SH NAME dfc \- report file system space usage information with style .SH SYNOPSIS .B dfc [OPTION(S)] [\-c WHEN] [\-e FORMAT] [\-p FSNAME] [\-q SORTBY] [\-t FSTYPE] [\-u UNIT] .SH DESCRIPTION dfc(1) is a tool similar to df(1) except that it is able to show a graph along with the data and is able to use color (color mode is "color\-auto" by default but you can change this with "\-c" option). The available size corresponds to the space available from a user point of view and not from root's perspective (ie: use f_bavail instead of f_bfree). Without any argument, size is displayed in human\-readable format. Be aware that when using human\-readable format, there might be some rounding when computing the size. If you want maximum precision, use the "\-u" option and choose the unit. dfc(1) also has a built in feature that makes the output auto adjust based on terminal width. If you want to override this behavior, use the "\-f" option. .SH OPTIONS .TP \-a Show all (do not omit any file system). .TP \-b Do not show the graph bar. .TP \-c [WHEN] Choose color mode where WHEN is one of the following sub\-option: "always": Color will always be used, no matter what "stdout" is. "auto": This is default when "\-c" is not activated. Color is used only if "stdout" is a terminal. For instance, color will be disabled with this option if you pipe the output of dfc(1) into another command. "never": Color will never be used. .TP \-d Show used size. .TP \-e [FORMAT] Allows you to export dfc(1) output to specified FORMAT. FORMAT is one of the following: "csv": Output as "comma separated value" file type. Example usage: dfc \-e csv > foo.csv "html": Output is HTML formated. Example usage: dfc \-e html \-Tadiso \-c always > index.html "json": Output is JSON formated. Example usage: dfc \-e json \-Tisod > report.json "tex": Output is TeX formated. Example usage: dfc \-e tex \-c always > report.tex "text": Text output (default). .TP \-f Override auto\-adjust behavior by forcing information to be displayed. This option can be useful when redirecting dfc(1) output. .TP \-h Show a short help text. .TP \-i Show information about inodes. .TP \-l Only show information about locally mount file systems. .TP \-m Use SI units (metric) (ie: size is computed using powers of 10 instead of powers of 2). .TP \-M Do not print "mounted on". .TP \-n Do not print header. .TP \-o Show mount options. .TP \-p [FSNAME] Allows you to perform filtering on file system name. FSNAME can be anything. For instance, if you want to see only file system which name starts with "/dev", you would use the following: dfc \-p /dev This will output only file systems which names are, for instance, "/dev/sda1", "/dev/root", "/dev", etc. Multiple selection is supported. In this case, FSNAME needs to be a comma separated list (without spaces). For instance, if you want to filter "/dev" and "tmpfs", you would use the following: dfc \-p /dev,tmpfs You can also use negative matching to filter the output. To do so, you just need to prepend a "\-" to FSNAME. In the following example, dfc(1) will display all file system names except those mentioned: dfc \-p \-proc,/dev/sdc,run .TP \-q [SORTBY] Allows you to sort the output based on SORTBY. SORTBY can take one of those three values: "name", "type", "mount". When using "name", the output is sorted by file system name. When using "type", the output is sorted by file system type. When using "mount", the output is sorted by mount points. .TP \-s Sum the total usage. .TP \-t [FSTYPE] Allows you to perform filtering on file system type. FSTYPE could take any known file system value. For instance, "ext4", "ufs", "tmpfs", "reiserfs", etc. You can also use wildcard filtering, just as with the \-p option. For instance, if you use the following: dfc \-t ext This will allow any file system type with name starting with "ext" to pass through the filter, for instance, "ext2", "ext3" and "ext4". Multiple selection on file system is also possible. In this case, FSTYPE needs to be a comma separated list (without spaces). For instance, if you want to filter "ext4" and "tmpfs", you would use the following: dfc \-t ext4,tmpfs You can also use negative matching to filter the output. To do so, you just need to prepend a "\-" to FSTYPE. In the following example, dfc(1) will display all file system types except those mentioned: dfc \-t \-rootfs,tmpfs .TP \-T Show file system type. .TP \-u [UNIT] Show size using the unit specified. UNIT can take one of the following values: "h": Human readable (default when not using "\-u" option). "b": Show bytes. "k": Show size using Kio. "m": Show size using Mio. "g": Show size using Gio. "t": Show size using Tio. "p": Show size using Pio. "e": Show size using Eio. "z": Show size using Zio. "y": Show size using Yio. NOTE: When using "\-u" option along with "\-m" option, those suboptions are replaced by their SI counterparts. .TP \-v Print dfc(1) version and exit. .TP \-w Use a wider bar for the graph. .TP \-W Wide path name (avoid truncation of file name). May require a larger display. .SH CONFIGURATION FILE The configuration file is optional. It allows you to change dfc(1) default colors, values when colors change and graph symbol in text mode and modify colors used in html export. If you want to use it, place it here: $XDG_CONFIG_HOME/dfc/dfcrc If your operating system does not support XDG Base Directory Specification, it should then be placed here: $HOME/.config/dfc/dfcrc Or, last choice: $HOME/.dfcrc NOTE: The last two choices can be chosen only if your OS does not support XDG Base Directory Specification. .SH BUGS If you find one, please contact the author and explain what you encounter. .SH AUTHORS Robin Hahling .SH COPYRIGHT Copyright \(co 2012-2017 Robin Hahling .SH LICENSE BSD 3-clause .SH SEE ALSO df(1), du(1) dfc-3.1.0/man/fr/000755 001750 000144 00000000000 13072400264 013737 5ustar00robinusers000000 000000 dfc-3.1.0/man/fr/dfc.1000644 001750 000144 00000016240 13072400202 014550 0ustar00robinusers000000 000000 .TH dfc 1 "Le 09 Avril 2017" "version 3.1.0" "COMMANDES UTILISATEURS" .SH NOM dfc \- rapporte avec style l'utilisation de l'espace disque des systèmes de fichiers .SH SYNOPSIS .B dfc [OPTION(S)] [\-c WHEN] [\-e FORMAT] [\-p FSNAME] [\-q SORTBY] [\-t FSTYPE] [\-u UNIT] .SH DESCRIPTION dfc(1) est un outil similaire à df(1) mise à part le fait qu'il est capable d'afficher un graphe en plus des données et qu'il peut utiliser des couleurs (le mode couleur par défaut est "automatique" mais il peut être changé par le biais de l'option "\-c"). La taille disponible correspond à l'espace disponible du point de vue de l'utilisateur et non de la perspective de l'utilisateur root (càd: dfc(1) utilise f_bavail au lieu de f_bfree). Sans option, la taille est affichée dans un format lisible par l'être humain. Faites attention au fait qu'en utilisant ce format, quelques erreurs d'arrondis peuvent survenir lors du calcul de la taille. Si vous souhaitez une précision maximale, utilisez l'option "\-u" et choisissez l'unité désirée. dfc(1) possède également une fonctionnalité permettant à l'affichage de s'auto\-ajuster en fonction de la taille du terminal. Si vous désirez outrepasser ce comportement, utilisez l'option "\-f". .SH OPTIONS .TP \-a Affiche tout (n'omet aucun système de fichiers). .TP \-b Désactive l'affichage du graphe. .TP \-c [WHEN] Permet de choisir la couleur où WHEN est une des sous\-options suivantes: "always": Les couleurs seront toujours utilisées, peu importe "stdout". "auto": Il s'agit de l'option par défaut lorsque "\-c" n'est pas activée. Les couleurs sont utilisées seulement si "stdout" est un terminal. Par exemple, les couleurs seront désactivées avec cette option si vous faites une redirection de la sortie de dfc(1) vers une autre commande. "never": Les couleurs ne seront jamais utilisées. .TP \-d Affiche la taille utilisée. .TP \-e [FORMAT] Permet d'exporter la sortie de dfc(1) dans le format spécifié FORMAT. FORMAT est un des suivant: "csv": Exporte vers le format CSV. Exemple d'utilisation: dfc \-e csv > foo.csv "html": Exporte vers le format HTML. Exemple d'utilisation: dfc \-e html \-Tadiso \-c always > index.html "json": Export vers le format JSON. Exemple d'utilisation: dfc \-e json \-Tisod > report.json "tex": Exporte vers le format TeX. Exemple d'utilisation: dfc \-e tex \-c always > report.tex "text": Sortie texte (défaut). .TP \-f Outrepasse le comportement d'auto\-ajustement en forçant l'affichage des informations. Cette option peut être utile lorsque vous redirigez la sortie de dfc(1). .TP \-h Affiche une brève aide. .TP \-i Affiche des informations sur les inodes. .TP \-l Affiche les informations uniquement sur les systèmes de fichiers montés localement. .TP \-M Désactive l'affichage de "monté sur" .TP \-m Utilise les unités SI (càd: la taille est calculée en utilisant des puissances de 10 au lieu de 2). .TP \-n Désactive l'affichage de l'entête. .TP \-o Affiche les options de montage. .TP \-p [FSNAME] Permet de filtrer par nom de système de fichiers. FSNAME peut prendre n'importe quelle valeur. Par exemple, si vous souhaitez afficher uniquement les systèmes de fichiers dont le nom commence par "/dev", vous utiliseriez la commande suivante: dfc \-p /dev Cela affichera uniquement les systèmes de fichiers dont le nom est, par exemple, "/dev/sda1", "/dev/root", "/dev", etc. Une sélection multiple est également possible. Dans ce cas, FSNAME doit être sous forme d'une liste séparée par des virgules (sans espaces). Par exemple, si vous souhaitez filtrer "/dev" et "tmpfs", vous utiliseriez la commande suivante: dfc \-p /dev,tmpfs Il est également possible d'utiliser la correspondance négative afin de filtrer la sortie. Dans ce cas, il faut ajouter un "\-" au début de FSNAME. Dans l'exemple suivant, dfc(1) affichera tous les systèmes de fichiers exceptés ceux mentionnés: dfc \-p \-proc,/dev/sdc,run .TP \-q [SORTBY] Permet de filtrer la sortie en fonction de SORTBY. SORTBY peut prendre une de ces trois valeurs: "name", "type", "mount". En utilisant "name", la sortie est triée par nom de système de fichiers. En utilisant "type", la sortie est triée par type de système de fichiers. En utilisant "mount", la sortie est triée par point de montage. .TP \-s Somme l'utilisation totale. .TP \-t [FSTYPE] Permet de filtrer en fonction du type de système de fichier. FSTYPE peut prendre n'importe quelle valeur connue d'un système de fichiers. Par exemple, "ext4", "ufs", "tmpfs", "reiserfs", etc. Il est également possible de filtrer avec en fournissant un nom partiel, de la même manière qu'avec l'option \-p. Par exemple, si vous utilisez la commande suivante: dfc \-t ext Cela filtrera tout type de système de fichier dont le nom commence par "ext", comme, par exemple, "ext2", "ext3" et "ext4". Une sélection multiple est également possible. Dans ce cas, FSTYPE doit être une liste séparée par des virgules (sans espaces). Par exemple, si vous souhaitez filtrer "ext4" et "tmpfs", vous utiliseriez la commande suivante: dfc \-t ext4,tmpfs Il est également possible d'utiliser la correspondance négative afin de filtrer la sortie. Dans ce cas, il faut ajouter un "\-" au début de FSTYPE. Dans l'exemple suivant, dfc(1) affichera tous les systèmes de fichiers à part ceux mentionnés: dfc \-t \-rootfs,tmpfs .TP \-T Affiche le type de système de fichiers. .TP \-u [UNIT] Affiche la taille dans l'unité spécifiée. UNIT peut prendre n'importe laquelle des valeurs suivantes: "h": Format lisible par l'être humain (par défaut lorsque l'option "\-u" n'est pas utilisée). "b": Affiche le nombre d'octets. "k": Affiche la taille en Kio. "m": Affiche la taille en Mio. "g": Affiche la taille en Gio. "t": Affiche la taille en Tio. "p": Affiche la taille en Pio. "e": Affiche la taille en Eio. "z": Affiche la taille en Zio. "y": Affiche la taille en Yio. NOTE: Lorsque l'option "\-u" est utilisée en même temps que l'option "\-m", ces sous\-options sont remplacées par leur équivalent SI. .TP \-v Affiche la version de dfc(1) et quitte. .TP \-w Utilise une barre plus large pour le graphe. .TP \-W Noms de fichiers larges (évite de tronquer des noms de fichiers). Peut nécessiter un affichage plus large. .SH FICHIER DE CONFIGURATION Le fichier de configuration est optionnel. Il permet de changer les couleurs par défaut, les valeurs à partir desquelles les couleurs changent et le symbole du graphe de dfc(1) en mode texte ainsi que modifier les couleurs utilisées lors de l'export vers html. Si vous souhaitez l'utiliser, il faut le placer dans ce répertoire: $XDG_CONFIG_HOME/dfc/dfcrc Si votre système d'exploitation ne supporte pas les spécifications de dossiers XDG, alors il devrait être placé dans ce répertoire: $HOME/.config/dfc/dfcrc Ou, dernier choix: $HOME/.dfcrc NOTE: Les deux derniers choix ne peuvent être choisis que lorsque votre OS ne supporte pas les spécifications XDG. .SH BOGUES Si vous en trouvez un, merci de contacter l'auteur de lui expliquez le problème rencontré. .SH AUTEUR Robin Hahling .SH COPYRIGHT Copyright \(co 2012-2017 Robin Hahling .SH LICENCE BSD 3 Clauses .SH VOIR AUSSI df(1), du(1) dfc-3.1.0/man/nl/000755 001750 000144 00000000000 13072400264 013741 5ustar00robinusers000000 000000 dfc-3.1.0/man/nl/dfc.1000644 001750 000144 00000015656 13072400202 014564 0ustar00robinusers000000 000000 .TH dfc 1 "09 April, 2017" "version 3.1.0" "USER COMMANDS" .SH NAME dfc \- geef het gebruik van het bestandssysteem weer met behulp van grafieken en kleuren .SH SYNOPSIS .B dfc [OPTION(S)] [\-c WHEN] [\-e FORMAT] [\-p FSNAME] [\-q SORTBY] [\-t FSTYPE] [\-u UNIT] .SH DESCRIPTION dfc(1) is een tool vergelijkbaar met df(1) behalve dat het grafieken kan laten zien samen met data en het kan kleuren gebruiken (kleur-modus is standaard "color\-auto" maar u kunt dit veranderen met de "\-c" optie). De beschikbare grootte komt overeen met de beschikbare ruimte vanuit het oogpunt van een gebruiker en niet vanuit het perspectief van root (bijvoorbeeld: gebruik f_bavail in plaats van f_bfree). Zonder argument, is de grootte weergegeven in een voor mensen leesbaar formaat. Let erop, dat wanneer het voor mensen leesbare formaat wordt gebruikt, er wat getallen afgerond worden wanneer de grootte berekend wordt. Als u maximale precisie wilt, gebruik dan de "\-u" optie en kies de eenheid. dfc(1) heeft ook een ingebouwde feature die de output automatisch aanpast op basis van de breedte van de terminal. Als u dit gedrag wilt overschrijven, gebruik dan de "\-f" optie. .SH OPTIONS .TP \-a Laat alles zien (verberg geen enkel bestandssysteem). .TP \-b Laat de grafische balk niet zien. .TP \-c [WHEN] Kies de kleur\-modus waar WHEN één van de volgende sub\-opties is: "always": De kleuren worden altijd gebruikt. Het maakt niet uit wat "stdout" is. "auto": Dit is standaard wanneer "\-c" niet is geactiveerd. Kleuren worden alleen gebruikt als "stdout" een terminal is. Bijvoorbeeld: kleur wordt uitgeschakeld met deze optie als u de output van dfc(1) met een ander commando tegelijkertijd uitvoerd (piped). "never": Kleur wordt nooit gebruikt. .TP \-d Laat de gebruikte grootte zien. .TP \-e [FORMAT] Maakt het mogelijk om de output van dfc(1) te exporteren naar een gespecificeerd FORMAT. FORMAT is één van de onderstaande: "csv": Output als "comma separated value" bestandstype. Voorbeeld van gebruik: dfc \-e csv > foo.csv "html": Output als HTML formaat. Voorbeeld van gebruik: dfc \-e html \-Tadiso \-c always > index.html "tex": Output als TeX formaat. Voorbeeld van gebruik: dfc \-e tex \-c always > report.tex "text": Output als tekst (standaard). .TP \-f Overschrijf het automatisch\-aanpassingsgedrag door het forceren van het weergeven van informatie. Deze optie kan handig zijn wanneer output van dfc(1) wordt doorgestuurd. .TP \-h Geef een korte hulptekst weer. .TP \-i Laat informatie zien over inodes. .TP \-l Geef alleen informatie weer over lokaal-gemountte bestandssystemen. .TP \-m Gebruik SI eenheden (metric) (dwz: grootte is berekend met behulp van machten van 10 in plaats van machten van 2). .TP \-M Laat "mounted on" niet zien. .TP \-n Laat de koptekst niet zien. .TP \-o Geef mountopties weer. .TP \-p [FSNAME] Staat u toe om te filteren op naam van bestandssysteem. FSNAME kan alles zijn. Als u bijvoorbeeld alleen bestandssystemen wilt zien waarvan de naam begint met "/dev", dan gebruikt u het volgende commando: dfc \-p /dev Dit output alleen bestandssystemen waarvan de namen als bijvoorbeeld zijn: "/dev/sda1", "/dev/root", "/dev", etc. het selecteren van meerdere namen wordt ook ondersteund. In dit geval moet FSNAME een met comma gescheiden lijst zijn (zonder spaties). Als u bijvoorbeeld wilt filteren op "/dev" en "tmpfs", gebruikt u het volgende commando: dfc \-p /dev,tmpfs U kunt ook negatieve matching gebruiken om de output te filteren. Om dit te doen, kunt u simpelweg een "\-" voor FSNAME plaatsen. In het volgende voorbeeld geeft dfc(1) alle namen van bestandssystemen weer, behalve degene die worden genoemd: dfc \-p \-proc,/dev/sdc,run .TP \-q [SORTBY] Geeft u de mogelijkheid om de output te sorteren op SORTBY. SORTBY kan één van de volgende drie waarden hebben: "name", "type", "mount". De output wordt gestorteert op naam van het bestandssysteem wanneer "name" wordt gebruikt. De output wordt gestorteert op type van het bestandssysteem wanneer "type" wordt gebruikt. De output wordt gestorteert op mount points wanneer "mount" wordt gebruikt. .TP \-s Laat de som van het totale gebruik zien. .TP \-t [FSTYPE] Staat u toe om te filteren op type bestandssysteem. FSTYPE kan elk bekend bestandssysteemtype zijn. Bijvoorbeeld "ext4", "ufs", "tmpfs", "reiserfs", etc. U kunt ook jokerfilters gebruiken, zoals bij de \-p optie. Bijvoorbeeld als u het volgende commando gebruikt: dfc \-t ext Dit staat elk bestandssysteemtype toe met een naam die start met "ext" om door de filter te komen. Bijvoorbeeld: "ext2", "ext3" and "ext4". Meerdere selecties op bestandssysteem is ook mogelijk. In dit geval moet FSTYPE een comma gescheiden lijst (zonder spaties) zijn. Als u bijvoorbeeld wilt filteren op "ext4" en "tmpfs", gebruikt u het volgende commando: dfc \-t ext4,tmpfs U kunt ook negatieve matching gebruiken om de output te filteren. Om dit te doen, kunt u simpelweg een "\-" voor FSTYPE plaatsen. In het volgende voorbeeld geeft dfc(1) alle typen van bestandssystemen weer, behalve degene die worden genoemd: dfc \-t \-rootfs,tmpfs .TP \-T Geef bestandssysteemtypen weer. .TP \-u [UNIT] Geef grootte weer in de gespecificeerde eenheid. UNIT kan één van de volgende waarden zijn: "h": mensen leesbaar formaat (Human readable) (standaard wanneer de "\-u" optie niet wordt gebruikt). "b": Geef grootte in aantal bytes weer. "k": Geef grootte in aantal Kio weer. "m": Geef grootte in aantal Mio weer. "g": Geef grootte in aantal Gio weer. "t": Geef grootte in aantal Tio weer. "p": Geef grootte in aantal Pio weer. "e": Geef grootte in aantal Eio weer. "z": Geef grootte in aantal Zio weer. "y": Geef grootte in aantal Yio weer. NOTE: Wanneer u de "\-u" optie gebruikt samen met de "\-m" optie, worden de subopties vervangen door hun SI tegenhangers. .TP \-v Laat de versie van dfc(1) zien en beëindig het programma. .TP \-w Gebruik een bredere balk voor de grafiek. .TP \-W Laat brede bestandsnamen zien (voorkom dat de bestandsnamen afgekort worden). Dit kan een groter scherm vereisen. .SH CONFIGURATION FILE Het configuratiebestand is optioneel. Het staat u toe om instellingen van dfc(1) te veranderen. De standaardkleuren, waarden wanneer kleuren veranderen en de grafische symbolen in tekst\-modus en het aanpassen van kleuren die gebruikt worden in html export. Als u het wilt gebruiken, plaats het dan hier: $XDG_CONFIG_HOME/dfc/dfcrc Als uw besturingssysteem geen XDG Base Directory Specification ondersteund, zou het hier geplaatst moeten worden: $HOME/.config/dfc/dfcrc Als dat niet werkt, kunt u deze locatie nog proberen: $HOME/.dfcrc NOTE: De laatste twee keuzes kunnen alleen gekozen worden als uw besturingssysteem geen XDG Base Directory Specification ondersteund. .SH BUGS Als u een fout vindt, neem dan alstublieft contact op met de auteur en omschrijf wat u tegenkomt. .SH AUTHORS Robin Hahling .SH COPYRIGHT Copyright \(co 2012-2017 Robin Hahling .SH LICENSE BSD 3-clause .SH SEE ALSO df(1), du(1) dfc-3.1.0/po/000755 001750 000144 00000000000 13072400264 013173 5ustar00robinusers000000 000000 dfc-3.1.0/po/CMakeLists.txt000644 001750 000144 00000000023 13072400202 015716 0ustar00robinusers000000 000000 GettextTranslate() dfc-3.1.0/po/LINGUAS000644 001750 000144 00000000005 13072400202 014203 0ustar00robinusers000000 000000 fr nldfc-3.1.0/po/Makevars000644 001750 000144 00000000343 13072400202 014657 0ustar00robinusers000000 000000 DOMAIN = dfc subdir = po top_builddir = .. XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ -w 80 --from-code=UTF-8 COPYRIGHT_HOLDER = Robin Hahling MSGID_BUGS_ADDRESS = robin.hahling@gw-computing.net EXTRA_LOCALE_CATEGORIES = dfc-3.1.0/po/POTFILES.in000644 001750 000144 00000000243 13072400202 014737 0ustar00robinusers000000 000000 src/dfc.c src/dotfile.c src/util.c src/export/csv.c src/export/html.c src/export/tex.c src/export/text.c src/platform/services-bsd.c src/platform/services-linux.c dfc-3.1.0/po/sv.po000644 001750 000144 00000022157 13072400202 014162 0ustar00robinusers000000 000000 # Swedish translations for dfc package # Svenska översättningar för paket dfc. # Copyright (C) 2012 Robin Hahling # This file is distributed under the same license as the dfc package. # Andreas Rönnquist , 2012. # msgid "" msgstr "" "Project-Id-Version: dfc 3.0.0\n" "Report-Msgid-Bugs-To: robin.hahling@gw-computing.net\n" "POT-Creation-Date: 2012-08-19 22:51+0200\n" "PO-Revision-Date: 2012-08-19 20:01+0200\n" "Last-Translator: Andreas Rönnquist \n" "Language-Team: Swedish\n" "Language: sv\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: src/csv.c:91 #, c-format msgid "FILESYSTEM," msgstr "FILSYSTEM, " #: src/csv.c:94 #, c-format msgid "TYPE," msgstr "TYP, " #: src/csv.c:96 #, c-format msgid "%%USED," msgstr "%%ANVÄNT," #: src/csv.c:99 #, c-format msgid "USED," msgstr "ANVÄNT," #: src/csv.c:101 #, c-format msgid "AVAILABLE," msgstr "TILLGÄNGLIGT," #: src/csv.c:103 #, c-format msgid "TOTAL," msgstr "TOTALT," #: src/csv.c:106 #, c-format msgid "#INODES," msgstr "#INODES," #: src/csv.c:107 src/html.c:164 src/tex.c:154 #, c-format msgid "AV.INODES," msgstr "AV.INODES," #: src/csv.c:110 src/html.c:167 src/tex.c:156 #, c-format msgid "MOUNTED ON" msgstr "MONTERAD PÅ" #: src/csv.c:113 #, c-format msgid ",MOUNT OPTIONS" msgstr ",MONTERINGS-ALTERNATIV" #: src/csv.c:140 #, c-format msgid "SUM:," msgstr "SUM:," #: src/dfc.c:201 #, c-format msgid "-c: illegal sub option %s\n" msgstr "-c: ogiltigt underalternativ %s\n" #: src/dfc.c:234 #, c-format msgid "-e: illegal sub option %s\n" msgstr "-e: ogiltigt underalternativ %s\n" #: src/dfc.c:282 #, c-format msgid "-q: illegal sub option %s\n" msgstr "-q: ogiltigt underalternativ %s\n" #: src/dfc.c:336 #, c-format msgid "-u: illegal sub option %s\n" msgstr "-u: ogiltigt underalternativ %s\n" #: src/dfc.c:378 #, c-format msgid "Error reading the configuration file: %s\n" msgstr "Fel vid läsning av konfigurationsfilen: %s\n" #: src/dfc.c:413 msgid "Try dfc -h for more information\n" msgstr "Använd dfc -h för mer information\n" #: src/dfc.c:416 msgid "" "Usage: dfc [OPTIONS(S)] [-c WHEN] [-e FORMAT] [-p FSNAME] [-q SORTBY] [-t " "FSTYPE]\n" "\t[-u UNIT]\n" "Available options:\n" "\t-a\tprint all mounted filesystem\n" "\t-b\tdo not show the graph bar\n" "\t-c\tchoose color mode. Read the manpage\n" "\t\tfor details\n" "\t-d\tshow used size\n" "\t-e\texport to specified format. Read the manpage\n" "\t\tfor details\n" "\t-f\tdisable auto-adjust mode (force display)\n" "\t-h\tprint this message\n" "\t-i\tinfo about inodes\n" "\t-l\tonly show information about locally mounted\n" "\t\tfile systems\n" msgstr "" "Användning: dfc [INSTÄLLNING(AR)] [-c NÄR] [-e FORMAT] [-p FSNAMN] [-q " "SORTERAEFTER] [-t FSTYP]\n" "\t[-u ENHET]\n" "Tillgängliga inställningar:\n" "\t-a\tskriv ut alla monterade filsystem\n" "\t-b\tvisa inte diagrammet\n" "\t-c\tvälj färg-mod. Läs man-sidan\n" "\t\tför detaljer\n" "\t-d\tvisa använd storlek\n" "\t-e\texportera till specificerat format. Läs the man-sidan\n" "\t\tför detailjer\n" "\t-f\tinaktivera auto-adjust-mod (tvinga display)\n" "\t-h\tskriv ut denna information\n" "\t-i\tinfo om inoder\n" "\t-l\tvisa bara information om lokalt monterade\n" "\t\tfilsystem\n" #: src/dfc.c:434 msgid "" "\t-m\tuse metric (SI unit)\n" "\t-n\tdo not print header\n" "\t-o\tshow mount flags\n" "\t-p\tfilter by file system name. Read the manpage\n" "\t\tfor details\n" "\t-q\tsort the output. Read the manpage\n" "\t\tfor details\n" "\t-s\tsum the total usage\n" "\t-t\tfilter by file system type. Read the manpage\n" "\t\tfor details\n" "\t-T\tshow filesystem type\n" "\t-u\tchoose the unit in which\n" "\t\tto show the values. Read the manpage\n" "\t\tfor details\n" "\t-v\tprint program version\n" "\t-w\tuse a wider bar\n" "\t-W\twide filename (un truncate)\n" msgstr "" "\t-m\tanvänd metriskt system (SI-enhet)\n" "\t-n\tskriv inte ut tabellhuvud\n" "\t-o\tvisa monterings-flaggor\n" "\t-p\tfiltrera efter filsystems-namn. Läs man-sidan\n" "\t\tför detaljer\n" "\t-q\tsortera utskrift. Läs man-sidan\n" "\t\tför detaljer\n" "\t-s\tsummera total användning\n" "\t-t\tfiltrera efter filsystem-typ. Läs man-sidan\n" "\t\tför detaljer\n" "\t-T\tvisa filsystems-typ\n" "\t-u\tvälj enhet att använda för att\n" "\t\tvisa värden. Läs man-sidan\n" "\t\tför detaljer\n" "\t-v\tskriv ut programversion\n" "\t-w\tvisa längre mätare\n" "\t-W\tlångt filnamn (klipp inte av)\n" #: src/dfc.c:501 #, c-format msgid "WARNING: %s was skipped because it cannot be stated" msgstr "VARNING: %s skippades eftersom information om den inte kunde hämtas " #: src/dfc.c:945 #, c-format msgid "Could not retrieve mount flags for %s\n" msgstr "Kunde inte hämta monterings-flaggor för %s\n" #: src/dfc.c:981 #, c-format msgid "Truncating mount options for %s\n" msgstr "Trunkerar monterings-inställningar för %s\n" #: src/dotfile.c:147 #, c-format msgid "Error: no value for %s in configuration file\n" msgstr "Fel: inget värde för %s i konfigurations-filen\n" #: src/dotfile.c:212 src/dotfile.c:232 #, c-format msgid "" "Value conversion failed for graph_medium: %s. What were you expecting with " "such a thing anyway?\n" msgstr "" "Värde-konvertering misslyckades för graph_medium: %s. Vad hade du väntat dig " "med en sån sak?\n" #: src/dotfile.c:217 #, c-format msgid "Medium value cannot be set below 0: %s\n" msgstr "Medium-värdet kan inte sättas under 0: %s\n" #: src/dotfile.c:220 #, c-format msgid "Medium value cannot be set above 100: %s\n" msgstr "Medium-värdet kan inte sättas över 100: %s\n" #: src/dotfile.c:237 #, c-format msgid "High value cannot be set below 0: %s\n" msgstr "Höga värdet kan inte sättas under 0: %s\n" #: src/dotfile.c:240 #, c-format msgid "High value cannot be set above 100: %s\n" msgstr "Höga värdet kan inte sättas över 100: %s\n" #: src/dotfile.c:250 #, c-format msgid "Wrong symbol value: %s\n" msgstr "Felaktig symbol-värde: %s\n" #: src/dotfile.c:346 #, c-format msgid "Error: unknown option in configuration file: %s\n" msgstr "Fel: okänd inställning i konfigurationsfilen: %s\n" #: src/dotfile.c:355 #, c-format msgid "Unknown color value: %s\n" msgstr "Okänt färg-värde: %s\n" #: src/dotfile.c:360 #, c-format msgid "Not a valid HTML color: %s\n" msgstr "Inte en giltig HTML-färg: %s\n" #: src/html.c:143 msgid "Unknown date" msgstr "Okänt datum" #: src/html.c:146 #, c-format msgid "Generated by %s-%s on %s" msgstr "Genererad av %s-%s på %s" #: src/html.c:149 src/tex.c:142 msgid "FILESYSTEM" msgstr "FILSYSTEM" #: src/html.c:152 src/tex.c:144 msgid "TYPE" msgstr "TYP" #: src/html.c:156 msgid "%USED" msgstr "%ANVÄNT" #: src/html.c:158 src/tex.c:149 src/text.c:131 #, c-format msgid "USED" msgstr "ANVÄNT" #: src/html.c:159 src/tex.c:150 src/text.c:141 #, c-format msgid "AVAILABLE" msgstr " TILLG" #: src/html.c:160 src/tex.c:151 src/text.c:151 #, c-format msgid "TOTAL" msgstr "TOTAL" #: src/html.c:163 msgid "#INODES" msgstr "#INODES" #: src/html.c:170 src/tex.c:158 msgid "MOUNT OPTIONS" msgstr "MONTERINGS-ALTERNATIV" #: src/tex.c:146 msgid "USAGE" msgstr "ANVÄNDNING" #: src/tex.c:147 msgid "\\%USED" msgstr "\\%ANVÄNT" #: src/tex.c:153 msgid "\\#INODES" msgstr "\\#INODES" #: src/text.c:98 #, c-format msgid "FILESYSTEM " msgstr "FILSYSTEM " #: src/text.c:103 #, c-format msgid " TYPE" msgstr " TYP " #: src/text.c:116 #, c-format msgid " (=) USED" msgstr " ANVÄNT " #: src/text.c:119 #, c-format msgid "FREE (-) " msgstr " LEDIGT " #: src/text.c:122 #, c-format msgid "%%USED" msgstr " %%ANV" #: src/text.c:154 #, c-format msgid " #INODES" msgstr " #INODES" #: src/text.c:155 #, c-format msgid " AV.INODES" msgstr " AV.INODES" #: src/text.c:158 #, c-format msgid " MOUNTED ON " msgstr " MONTERAT PÅ" #: src/text.c:163 #, c-format msgid "MOUNT OPTIONS\n" msgstr "MONTERINGS-ALTERNATIV\n" #: src/text.c:194 #, c-format msgid "SUM:" msgstr "TOT:" #: src/util.c:638 msgid "" "WARNING: TTY too narrow. Some options have been disabled to make dfc output " "fit (use -f to override).\n" msgstr "" "VARNING: TTYn är för smal. Några inställningar har blivit deaktiverade för " "att få dfc att få plats (använd -f för att åsidosätta).\n" #: src/util.c:691 msgid "WARNING: Output still messed up. Enlarge your terminal if you can...\n" msgstr "" "VARNING: Utskriften är fortfarande felaktig. Gör din terminal större om du " "kan...\n" #: src/util.c:834 msgid "black" msgstr "svart" #: src/util.c:837 msgid "red" msgstr "röd" #: src/util.c:840 msgid "green" msgstr "grön" #: src/util.c:843 msgid "yellow" msgstr "gul" #: src/util.c:846 msgid "blue" msgstr "blå" #: src/util.c:849 msgid "magenta" msgstr "magenta" #: src/util.c:852 msgid "cyan" msgstr "cyan" #: src/util.c:855 msgid "white" msgstr "vit" dfc-3.1.0/po/nl.po000644 001750 000144 00000022452 13072400255 014151 0ustar00robinusers000000 000000 # Dutch translations for dfc package. # Copyright (C) 2016 Robin Hahling # This file is distributed under the same license as the dfc package. # Michiel Pater , 2016-2017. # msgid "" msgstr "" "Project-Id-Version: dfc 3.1.0\n" "Report-Msgid-Bugs-To: robin.hahling@gw-computing.net\n" "POT-Creation-Date: 2017-04-09 11:36+0200\n" "PO-Revision-Date: 2016-04-15 02:02+0200\n" "Last-Translator: Michiel Pater \n" "Language-Team: Dutch\n" "Language: nl\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: src/dfc.c:214 #, c-format msgid "-c: illegal sub option %s\n" msgstr "-c: ongeldige suboptie %s\n" #: src/dfc.c:251 #, c-format msgid "-e: illegal sub option %s\n" msgstr "-e: ongeldige suboptie %s\n" #: src/dfc.c:302 #, c-format msgid "-q: illegal sub option %s\n" msgstr "-q: ongeldige suboptie %s\n" #: src/dfc.c:363 #, c-format msgid "-u: illegal sub option %s\n" msgstr "-u: ongeldige suboptie %s\n" #: src/dfc.c:406 #, c-format msgid "Error reading the configuration file: %s\n" msgstr "Fout bij het lezen van het configuratiebestand: %s\n" #: src/dfc.c:445 msgid "Try dfc -h for more information\n" msgstr "Probeer dfc -h voor meer informatie\n" #: src/dfc.c:448 msgid "" "Usage: dfc [OPTION(S)] [-c WHEN] [-e FORMAT] [-p FSNAME] [-q SORTBY] [-t " "FSTYPE] [-u UNIT]\n" "Available options:\n" "\t-a\tprint all mounted filesystem\n" "\t-b\tdo not show the graph bar\n" "\t-c\tchoose color mode. Read the manpage for details\n" "\t-d\tshow used size\n" "\t-e\texport to specified format. Read the manpage for details\n" "\t-f\tdisable auto-adjust mode (force display)\n" "\t-h\tprint this message\n" "\t-i\tinfo about inodes\n" "\t-l\tonly show information about locally mounted file systems\n" msgstr "" "Gebruik: dfc [OPTION(S)] [-c WHEN] [-e FORMAT] [-p FSNAME] [[-q SORTBY] -t " "FSTYPE] [-u UNIT]\n" "Beschikbare opties:\n" "\t-a\tlaat alles zien (verberg geen enkel bestandssysteem)\n" "\t-b\tlaat de grafische balk niet zien\n" "\t-c\tkies de kleur-modus. Lees de man pagina voor details\n" "\t-d\tlaat de gebruikte grootte zien\n" "\t-e\texporteer naar een gespecificeerd FORMAT. Lees de man pagina voor " "details\n" "\t-f\toverschrijf het automatisch-aanpassingsgedrag (forceer weergave)\n" "\t-h\tgeef een korte hulptekst weer\n" "\t-i\tlaat informatie zien over inodes\n" "\t-l\tgeef alleen informatie weer over lokaal-gemountte bestandssystemen\n" #: src/dfc.c:466 msgid "" "\t-m\tuse metric (SI unit)\n" "\t-M\tdo not print \"mounted on\"\n" "\t-n\tdo not print header\n" "\t-o\tshow mount flags\n" "\t-p\tfilter by file system name. Read the manpage for details\n" "\t-q\tsort the output. Read the manpage for details\n" "\t-s\tsum the total usage\n" "\t-t\tfilter by file system type. Read the manpage for details\n" "\t-T\tshow filesystem type\n" "\t-u\tchoose the unit in which to show the values. Read the manpage for " "details\n" "\t-v\tprint program version\n" "\t-w\tuse a wider bar\n" "\t-W\twide filename (un truncate)\n" msgstr "" "\t-m\tgebruik SI eenheden (metric)\n" "\t-M\tLaat \"mounted on\" niet zien.\n" "\t-n\tlaat de koptekst niet zien\n" "\t-o\tgeef mountopties weer\n" "\t-p\tstaat u toe om te filteren op naam van bestandssysteem lees de man " "pagina voor details\n" "\t-q\tgeeft u de mogelijkheid om de output te sorteren op SORTBY. Lees de " "man pagina voor details\n" "\t-s\tlaat de som van het totale gebruik zien\n" "\t-t\tstaat u toe om te filteren op type bestandssysteem lees de man pagina " "voor details\n" "\t-T\tgeef bestandssysteemtypen weer\n" "\t-u\tgeef grootte weer in de gespecificeerde eenheid lees de man pagina " "voor details\n" "\t-v\tlaat de versie van dfc zien en beeindig het programma\n" "\t-w\tgebruik een bredere balk voor de grafiek\n" "\t-W\tlaat brede bestandsnamen zien\n" #: src/dotfile.c:122 #, c-format msgid "" "Config file path is longer than %lu and was truncated. Please, open a bug " "report.\n" msgstr "" #: src/dotfile.c:159 #, c-format msgid "Error: no value for %s in configuration file\n" msgstr "Fout: geen waarde voor %s in configuratiebestand\n" #: src/dotfile.c:225 src/dotfile.c:245 #, c-format msgid "" "Value conversion failed for graph_medium: %s. What were you expecting with " "such a thing anyway?\n" msgstr "" "Waarde conversie mislukt voor graph_medium: %s. Wat had u verwacht metzoiets " "hoe dan ook?\n" #: src/dotfile.c:230 #, c-format msgid "Medium value cannot be set below 0: %s\n" msgstr "Gemiddelde waarde kan niet worden ingesteld beneden 0: %s\n" #: src/dotfile.c:233 #, c-format msgid "Medium value cannot be set above 100: %s\n" msgstr "Gemiddelde waarde kan niet worden ingesteld boven 100: %s\n" #: src/dotfile.c:250 #, c-format msgid "High value cannot be set below 0: %s\n" msgstr "Hoge waarde kan niet worden ingesteld beneden 0: %s\n" #: src/dotfile.c:253 #, c-format msgid "High value cannot be set above 100: %s\n" msgstr "Hoge waarde kan niet worden ingesteld boven 100: %s\n" #: src/dotfile.c:263 #, c-format msgid "Wrong symbol value: %s\n" msgstr "Onjuiste waarde voor symbool %s\n" #: src/dotfile.c:344 #, c-format msgid "Wrong csv separator: %s\n" msgstr "Onjuist csv scheidingsteken: %s\n" #: src/dotfile.c:349 #, c-format msgid "Error: unknown option in configuration file: %s\n" msgstr "Fout: onbekende optie in configuratiebestand: %s\n" #: src/dotfile.c:358 #, c-format msgid "Unknown boolean value: %s\n" msgstr "Onbekende booleanwaarde: %s\n" #: src/dotfile.c:363 #, c-format msgid "Unknown color value: %s\n" msgstr "Onbekende kleurwaarde: %s\n" #: src/dotfile.c:368 #, c-format msgid "Not a valid HTML color: %s\n" msgstr "Ongeldige HTML kleurcode: %s\n" #: src/dotfile.c:373 #, c-format msgid "Could not assign value from configuration file: %s\n" msgstr "Kan geen waarde lezen uit configuratiebestand: %s\n" #: src/util.c:509 src/export/html.c:157 src/export/tex.c:140 #: src/export/text.c:101 msgid "FILESYSTEM" msgstr "BEST.SYS." #: src/util.c:510 src/export/html.c:160 src/export/tex.c:142 #: src/export/text.c:104 msgid "TYPE" msgstr "TYPE" #: src/util.c:512 src/export/html.c:164 src/export/text.c:114 msgid "%USED" msgstr "%GEBR" #: src/util.c:513 src/export/html.c:166 src/export/tex.c:147 #: src/export/text.c:117 msgid "USED" msgstr "GEBR" #: src/util.c:514 src/export/html.c:167 src/export/tex.c:148 #: src/export/text.c:119 msgid "AVAILABLE" msgstr "BESCH." #: src/util.c:515 src/export/csv.c:104 src/export/html.c:168 #: src/export/tex.c:149 src/export/text.c:120 #, c-format msgid "TOTAL" msgstr "TOT." #: src/util.c:516 src/export/html.c:171 src/export/text.c:123 msgid "#INODES" msgstr "#INODES" #: src/util.c:517 src/export/csv.c:108 src/export/html.c:172 #: src/export/text.c:124 #, c-format msgid "AV.INODES" msgstr "BB.INODES" #: src/util.c:518 src/export/csv.c:112 src/export/html.c:176 #: src/export/tex.c:155 src/export/text.c:131 msgid "MOUNTED ON" msgstr "MOUNT" #: src/util.c:519 src/export/html.c:179 src/export/tex.c:157 #: src/export/text.c:134 msgid "MOUNT OPTIONS" msgstr "MOUNT OPTIES" #: src/util.c:544 msgid "Cannot compute required width\n" msgstr "Kan vereiste breedte niet berekenen\n" #: src/util.c:620 msgid "" "WARNING: TTY too narrow. Some options have been disabled to make dfc output " "fit (use -f to override).\n" msgstr "" "WAARSCHUWING: TTY te smal. Sommige opties zijn uitgeschakeld om dfc output " "te laten passen (gebruik -f om te overschrijven).\n" #: src/util.c:666 msgid "WARNING: Output still messed up. Enlarge your terminal if you can...\n" msgstr "" "WAARSCHUWING: Output nog steeds te breed. Probeer uw terminal te\n" "vergroten\n" #: src/export/csv.c:92 #, c-format msgid "FILESYSTEM%c" msgstr "BESTANDSSYSTEEM%c" #: src/export/csv.c:95 #, c-format msgid "TYPE%c" msgstr "TYPE%c" #: src/export/csv.c:97 #, c-format msgid "%%USED%c" msgstr "%%GEBR%c" #: src/export/csv.c:100 #, c-format msgid "USED%c" msgstr "GEBR%c" #: src/export/csv.c:102 #, c-format msgid "AVAILABLE%c" msgstr "BESCHIKBAAR%c" #: src/export/csv.c:107 #, c-format msgid "%c#INODES%c" msgstr "%c#INODES%c" #: src/export/csv.c:115 #, c-format msgid "%cMOUNT OPTIONS" msgstr "%cMOUNT OPTIES" #: src/export/csv.c:137 #, c-format msgid "SUM:%c" msgstr "TOTAAL:%c" #: src/export/html.c:146 msgid "Unknown date" msgstr "Onbekende datum" #: src/export/html.c:154 #, c-format msgid "Generated by %s-%s on %s" msgstr "Gegenereerd door %s-%s op %s" #: src/export/tex.c:144 msgid "USAGE" msgstr "GEBR" #: src/export/tex.c:145 msgid "\\%USED" msgstr "\\%GEBR" #: src/export/tex.c:151 msgid "\\#INODES" msgstr "\\#INODES" #: src/export/tex.c:152 msgid "AV.INODES," msgstr "BB.INODES," #: src/export/text.c:107 src/export/text.c:109 msgid "(=) USED" msgstr "(=) GEBR" #: src/export/text.c:109 src/export/text.c:111 msgid "FREE (-)" msgstr "VRIJ (-)" #: src/export/text.c:165 msgid "SUM:" msgstr "TOTAAL:" #: src/platform/services-bsd.c:350 #, c-format msgid "Could not retrieve mount flags for %s\n" msgstr "Kan mount flags niet ontvangen voor %s\n" #: src/platform/services-bsd.c:379 #, c-format msgid "Truncating mount options for %s\n" msgstr "Mount opties inkorten voor %s\n" #: src/platform/services-linux.c:110 #, c-format msgid "WARNING: %s was skipped because it could not be stated" msgstr "WAARSCHUWING: %s werd overgeslagen, omdat het niet kon wordenvermeldt" #~ msgid "TOTAL%c" #~ msgstr "TOT.%c" #~ msgid "AV.INODES%c" #~ msgstr "BB.INODES%c" dfc-3.1.0/po/fr.po000644 001750 000144 00000023030 13072400256 014141 0ustar00robinusers000000 000000 # French translations for dfc package. # Copyright (C) 2012 THE dfc'S COPYRIGHT HOLDER # This file is distributed under the same license as the dfc package. # Robin Hahling , 2012-2017. # msgid "" msgstr "" "Project-Id-Version: dfc 3.0.0-devel\n" "Report-Msgid-Bugs-To: robin.hahling@gw-computing.net\n" "POT-Creation-Date: 2017-04-09 11:36+0200\n" "PO-Revision-Date: 2012-04-15 13:52+0200\n" "Last-Translator: Robin Hahling \n" "Language-Team: French\n" "Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: src/dfc.c:214 #, c-format msgid "-c: illegal sub option %s\n" msgstr "-c: sous-option illégale %s\n" #: src/dfc.c:251 #, c-format msgid "-e: illegal sub option %s\n" msgstr "-e: sous-option illégale %s\n" #: src/dfc.c:302 #, c-format msgid "-q: illegal sub option %s\n" msgstr "-q: sous-option illégale %s\n" #: src/dfc.c:363 #, c-format msgid "-u: illegal sub option %s\n" msgstr "-u: sous-option illégale %s\n" #: src/dfc.c:406 #, c-format msgid "Error reading the configuration file: %s\n" msgstr "Erreur pendant la lecture du fichier de configuration: %s\n" #: src/dfc.c:445 msgid "Try dfc -h for more information\n" msgstr "Essayez dfc -h pour plus d'informations\n" #: src/dfc.c:448 msgid "" "Usage: dfc [OPTION(S)] [-c WHEN] [-e FORMAT] [-p FSNAME] [-q SORTBY] [-t " "FSTYPE] [-u UNIT]\n" "Available options:\n" "\t-a\tprint all mounted filesystem\n" "\t-b\tdo not show the graph bar\n" "\t-c\tchoose color mode. Read the manpage for details\n" "\t-d\tshow used size\n" "\t-e\texport to specified format. Read the manpage for details\n" "\t-f\tdisable auto-adjust mode (force display)\n" "\t-h\tprint this message\n" "\t-i\tinfo about inodes\n" "\t-l\tonly show information about locally mounted file systems\n" msgstr "" "Utilisation: dfc [OPTION(S)] [-c WHEN] [-e FORMAT] [-p FSNAME] [-q SORTBY] " "[-t FSTYPE] [-u UNIT]\n" "Options disponibles:\n" "\t-a\taffiche tous les systèmes de fichiers montés\n" "\t-b\tdésactive l'affichage du graphe\n" "\t-c\tpermet de choisir le mode pour la couleur. Lisez le manuel pour les " "détails\n" "\t-d\taffiche la taille de l'utilisation\n" "\t-e\texporte dans le format spécifié. Lisez le manuel pour les détails\n" "\t-f\tdésactive le mode d'auto-ajustement (force l'affichage)\n" "\t-h\taffiche ce message\n" "\t-i\tinformations sur les inodes\n" "\t-l\taffiche les informations sur les systèmes de fichiers montés " "localement uniquement\n" #: src/dfc.c:466 msgid "" "\t-m\tuse metric (SI unit)\n" "\t-M\tdo not print \"mounted on\"\n" "\t-n\tdo not print header\n" "\t-o\tshow mount flags\n" "\t-p\tfilter by file system name. Read the manpage for details\n" "\t-q\tsort the output. Read the manpage for details\n" "\t-s\tsum the total usage\n" "\t-t\tfilter by file system type. Read the manpage for details\n" "\t-T\tshow filesystem type\n" "\t-u\tchoose the unit in which to show the values. Read the manpage for " "details\n" "\t-v\tprint program version\n" "\t-w\tuse a wider bar\n" "\t-W\twide filename (un truncate)\n" msgstr "" "\t-m\tutilise les unités métriques (unités SI)\n" "\t-M\tdésactive l'affichage de \"monté sur\"\n" "\t-n\tdésactive l'affichage du titre\n" "\t-o\taffiche les options de montage\n" "\t-p\tfiltre par nom de système de fichiers. Lisez le manuel pour les " "détails\n" "\t-q\ttrie l'affichage. Lisez le manuel pour les détails.\n" "\t-s\tsomme l'utilisation totale\n" "\t-t\tfiltre par type de système de fichiers. Lisez le manuel pour les " "détails\n" "\t-T\taffiche le type de système de fichiers\n" "\t-u\tpermet de choisir l'unité dans laquelle les valeurs sont affichées. " "Lisez le manuel pour les détails\n" "\t-v\taffiche la version du programme\n" "\t-w\tutilise une barre plus large\n" "\t-W\tlong nom de fichiers (dé-tronque)\n" #: src/dotfile.c:122 #, c-format msgid "" "Config file path is longer than %lu and was truncated. Please, open a bug " "report.\n" msgstr "" #: src/dotfile.c:159 #, c-format msgid "Error: no value for %s in configuration file\n" msgstr "Erreur: aucune valeur pour %s dans le fichier de configuration\n" #: src/dotfile.c:225 src/dotfile.c:245 #, c-format msgid "" "Value conversion failed for graph_medium: %s. What were you expecting with " "such a thing anyway?\n" msgstr "" "La conversion de la valeur a échoué pour graph_medium: %s. Qu'espériez-vous " "de toute façon?\n" #: src/dotfile.c:230 #, c-format msgid "Medium value cannot be set below 0: %s\n" msgstr "La valeur medianne ne peut pas être fixée en dessous de 0: %s\n" #: src/dotfile.c:233 #, c-format msgid "Medium value cannot be set above 100: %s\n" msgstr "La valeur médianne ne peut pas être fixée en dessus de 100: %s\n" #: src/dotfile.c:250 #, c-format msgid "High value cannot be set below 0: %s\n" msgstr "La valeur haute ne peut pas être fixée en dessous de 0: %s\n" #: src/dotfile.c:253 #, c-format msgid "High value cannot be set above 100: %s\n" msgstr "La valeur haute ne peut pas être fixée en dessus de 100: %s\n" #: src/dotfile.c:263 #, c-format msgid "Wrong symbol value: %s\n" msgstr "Symbole impossible: %s\n" #: src/dotfile.c:344 #, c-format msgid "Wrong csv separator: %s\n" msgstr "Séparateur csv invalide: %s\n" #: src/dotfile.c:349 #, c-format msgid "Error: unknown option in configuration file: %s\n" msgstr "Erreur: option inconnue dans le fichier de configuration: %s\n" #: src/dotfile.c:358 #, c-format msgid "Unknown boolean value: %s\n" msgstr "Valeur booléenne inconnue: %s\n" #: src/dotfile.c:363 #, c-format msgid "Unknown color value: %s\n" msgstr "Couleur inconnue: %s\n" #: src/dotfile.c:368 #, c-format msgid "Not a valid HTML color: %s\n" msgstr "Couleur HTML invalide: %s\n" #: src/dotfile.c:373 #, c-format msgid "Could not assign value from configuration file: %s\n" msgstr "" "Impossible d'assigner une valeur depuis le fichier de configuration: %s\n" #: src/util.c:509 src/export/html.c:157 src/export/tex.c:140 #: src/export/text.c:101 msgid "FILESYSTEM" msgstr "SYSTÈME DE FICHIERS" #: src/util.c:510 src/export/html.c:160 src/export/tex.c:142 #: src/export/text.c:104 msgid "TYPE" msgstr "TYPE" #: src/util.c:512 src/export/html.c:164 src/export/text.c:114 msgid "%USED" msgstr "%UTILISÉ" #: src/util.c:513 src/export/html.c:166 src/export/tex.c:147 #: src/export/text.c:117 msgid "USED" msgstr " UT." #: src/util.c:514 src/export/html.c:167 src/export/tex.c:148 #: src/export/text.c:119 msgid "AVAILABLE" msgstr "DISPO." #: src/util.c:515 src/export/csv.c:104 src/export/html.c:168 #: src/export/tex.c:149 src/export/text.c:120 #, c-format msgid "TOTAL" msgstr "TOTAL" #: src/util.c:516 src/export/html.c:171 src/export/text.c:123 msgid "#INODES" msgstr "#INODES" #: src/util.c:517 src/export/csv.c:108 src/export/html.c:172 #: src/export/text.c:124 #, c-format msgid "AV.INODES" msgstr "INODES DISP." #: src/util.c:518 src/export/csv.c:112 src/export/html.c:176 #: src/export/tex.c:155 src/export/text.c:131 msgid "MOUNTED ON" msgstr "MONTÉ SUR" #: src/util.c:519 src/export/html.c:179 src/export/tex.c:157 #: src/export/text.c:134 msgid "MOUNT OPTIONS" msgstr "OPTIONS DE MONTAGE" #: src/util.c:544 msgid "Cannot compute required width\n" msgstr "Impossible de calculer la largeur requise\n" #: src/util.c:620 msgid "" "WARNING: TTY too narrow. Some options have been disabled to make dfc output " "fit (use -f to override).\n" msgstr "" "AVERTISSEMENT: le TTY est trop étroit. Certaines options ont été désactivées " "afin d'ajuster l'affichage (utilisez -f afin d'outrepasser).\n" #: src/util.c:666 msgid "WARNING: Output still messed up. Enlarge your terminal if you can...\n" msgstr "" "AVERTISSEMENT: l'affichage est toujours perturbé. Agrandissez votre terminal " "si cela est possible...\n" #: src/export/csv.c:92 #, c-format msgid "FILESYSTEM%c" msgstr "SYSTÈME DE FICHIERS%c" #: src/export/csv.c:95 #, c-format msgid "TYPE%c" msgstr "TYPE%c" #: src/export/csv.c:97 #, c-format msgid "%%USED%c" msgstr " %%UT.%c" #: src/export/csv.c:100 #, c-format msgid "USED%c" msgstr " UT.%c" #: src/export/csv.c:102 #, c-format msgid "AVAILABLE%c" msgstr "DISPO.%c" #: src/export/csv.c:107 #, c-format msgid "%c#INODES%c" msgstr "%c#INODES%c" #: src/export/csv.c:115 #, c-format msgid "%cMOUNT OPTIONS" msgstr "%cOPTIONS DE MONTAGE" #: src/export/csv.c:137 #, c-format msgid "SUM:%c" msgstr "SOM:%c" #: src/export/html.c:146 msgid "Unknown date" msgstr "Date inconnue" #: src/export/html.c:154 #, c-format msgid "Generated by %s-%s on %s" msgstr "Généré par %s-%s le %s" #: src/export/tex.c:144 msgid "USAGE" msgstr "UTILISATION" #: src/export/tex.c:145 msgid "\\%USED" msgstr "\\%UTILISÉ" #: src/export/tex.c:151 msgid "\\#INODES" msgstr "\\#INODES" #: src/export/tex.c:152 msgid "AV.INODES," msgstr "INODES DISP.," #: src/export/text.c:107 src/export/text.c:109 msgid "(=) USED" msgstr "(=) UT." #: src/export/text.c:109 src/export/text.c:111 msgid "FREE (-)" msgstr "LIB. (-)" #: src/export/text.c:165 msgid "SUM:" msgstr "SOM:" #: src/platform/services-bsd.c:350 #, c-format msgid "Could not retrieve mount flags for %s\n" msgstr "Impossible de récupérer les options de montage pour %s\n" #: src/platform/services-bsd.c:379 #, c-format msgid "Truncating mount options for %s\n" msgstr "Troncation des options de montage pour %s\n" #: src/platform/services-linux.c:110 #, c-format msgid "WARNING: %s was skipped because it could not be stated" msgstr "AVERTISSEMENT: %s a été ignoré car il ne peut pas être lu" #~ msgid "TOTAL%c" #~ msgstr "TOTAL%c" #~ msgid "AV.INODES%c" #~ msgstr "INODES DISP.%c" dfc-3.1.0/src/000755 001750 000144 00000000000 13072400264 013344 5ustar00robinusers000000 000000 dfc-3.1.0/src/dfc.c000644 001750 000144 00000032731 13072400202 014242 0ustar00robinusers000000 000000 /* * Copyright (c) 2012-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ /* * dfc.c * * Displays free disk space in an elegant manner. */ #include #include #include #include #include "dfc.h" #ifdef NLS_ENABLED #include #include #endif /* NLS_ENABLED */ /* global variables definition, see declaration in extern.h */ char g_unknown_str[] = "unknown"; char g_none_str[] = "none"; struct conf cnf; struct maxwidths max; int aflag, bflag, cflag, dflag, eflag, fflag, hflag, iflag, lflag, mflag, nflag, oflag, pflag, qflag, sflag, tflag, uflag, vflag, wflag; int Mflag, Tflag, Wflag; char unitflag; int main(int argc, char *argv[]) { struct list queue; struct display sdisp; int ch; int tty_width; int ret = EXIT_SUCCESS; char *fsnfilter = NULL; char *fstfilter = NULL; char *subopts; char *value; char *cfgfile; /* enum for suboptions flags; first letter corresponds to option flag */ enum { CALWAYS = 0, CNEVER = 1, CAUTO = 2, ETEXT = 0, ECSV = 1, EHTML = 2, ETEX = 3, EJSON = 4, SFSNAME = 0, SFSTYPE = 1, SFSDIR = 2, UH = 0, UB = 1, UK = 2, UM = 3, UG = 4, UT = 5, UP = 6, UE = 7, UZ = 8, UY = 9 }; static char always_str[] = "always"; static char never_str[] = "never"; static char auto_str[] = "auto"; char *const color_opts[] = { always_str, never_str, auto_str, NULL }; static char text_str[] = "text"; static char csv_str[] = "csv"; static char html_str[] = "html"; static char tex_str[] = "tex"; static char json_str[] = "json"; char *const export_opts[] = { text_str, csv_str, html_str, tex_str, json_str, NULL }; static char name_str[] = "name"; static char type_str[] = "type"; static char mount_str[] = "mount"; char *const sort_opts[] = { name_str, type_str, mount_str, NULL }; static char h_str[] = "h"; static char b_str[] = "b"; static char k_str[] = "k"; static char m_str[] = "m"; static char g_str[] = "g"; static char t_str[] = "t"; static char p_str[] = "p"; static char e_str[] = "e"; static char z_str[] = "z"; static char y_str[] = "y"; char *const unit_opts[] = { h_str, b_str, k_str, m_str, g_str, t_str, p_str, e_str, z_str, y_str, NULL }; #ifdef NLS_ENABLED /* translation support */ if (setlocale(LC_ALL, "") == NULL) { (void)fputs("Locale cannot be set\n", stderr); ret = EXIT_FAILURE; } if (bindtextdomain(PACKAGE, LOCALEDIR) == NULL) { (void)fputs("Cannot bind locale\n", stderr); ret = EXIT_FAILURE; } if (bind_textdomain_codeset(PACKAGE, "") == NULL) { (void)fputs("Cannot bind locale codeset\n", stderr); ret = EXIT_FAILURE; } if (textdomain(PACKAGE) == NULL) { (void)fputs("Cannot set translation domain\n", stderr); ret = EXIT_FAILURE; } #endif /* NLS_ENABLED */ /* default value for those globals */ cflag = 1; /* color enabled by default */ /* * Now use -u option for choosing the size (b, k, m, etc.) * When using the flag, should specifie the unit used (h is default). * Have a look at unit_opts for the possible values. */ unitflag = 'h'; /* Init default colors and symbol sign */ init_conf(&cnf); while ((ch = getopt(argc, argv, "abc:de:fhilmMnop:q:st:Tu:vwW")) != -1) { switch (ch) { case 'a': aflag = 1; break; case 'b': bflag = 1; break; case 'c': subopts = optarg; while (*subopts) { switch (getsubopt(&subopts, color_opts, &value)) { case CALWAYS: cflag = 2; break; case CNEVER: cflag = 0; break; case CAUTO: cflag = 1; break; case -1: /* FALLTHROUGH */ default: (void)fprintf(stderr, _("-c: illegal sub option %s\n"), subopts); ret = EXIT_FAILURE; goto out; } } break; case 'd': dflag = 1; break; case 'e': eflag = 1; subopts = optarg; while (*subopts) { switch (getsubopt(&subopts, export_opts, &value)) { case ETEXT: eflag = 0; break; case ECSV: Wflag = 1; init_disp_csv(&sdisp); break; case EHTML: Wflag = 1; init_disp_html(&sdisp); break; case ETEX: Wflag = 1; init_disp_tex(&sdisp); break; case EJSON: Wflag = 1; init_disp_json(&sdisp); break; case -1: /* FALLTHROUGH */ default: (void)fprintf(stderr, _("-e: illegal sub option %s\n"), subopts); ret = EXIT_FAILURE; goto out; } } break; case 'f': fflag = 1; break; case 'h': hflag = 1; break; case 'i': iflag = 1; break; case 'l': lflag = 1; break; case 'm': mflag = 1; break; case 'M': Mflag = 1; break; case 'n': nflag = 1; break; case 'o': oflag = 1; break; case 'p': pflag = 1; fsnfilter = strdup(optarg); break; case 'q': subopts = optarg; while (*subopts) { switch (getsubopt(&subopts, sort_opts, &value)) { case SFSNAME: qflag = 1; break; case SFSTYPE: qflag = 2; break; case SFSDIR: qflag = 3; break; case -1: /* FALLTHROUGH */ default: (void)fprintf(stderr, _("-q: illegal sub option %s\n"), subopts); ret = EXIT_FAILURE; goto out; } } break; case 's': sflag = 1; break; case 't': tflag = 1; fstfilter = strdup(optarg); break; case 'T': Tflag = 1; break; case 'u': uflag = 1; subopts = optarg; while (*subopts) { switch (getsubopt(&subopts, unit_opts, &value)) { case UH: /* * disable uflag since conversion to * human readable format is computed * very differently from other formats */ uflag = 0; unitflag = 'h'; break; case UB: unitflag = 'b'; break; case UK: unitflag = 'k'; break; case UM: unitflag = 'm'; break; case UG: unitflag = 'g'; break; case UT: unitflag = 't'; break; case UP: unitflag = 'p'; break; case UE: unitflag = 'e'; break; case UZ: unitflag = 'z'; break; case UY: unitflag = 'y'; break; case -1: /* FALLTHROUGH */ default: (void)fprintf(stderr, _("-u: illegal sub option %s\n"), subopts); ret = EXIT_FAILURE; goto out; } } break; case 'v': vflag = 1; break; case 'w': wflag = 1; break; case 'W': Wflag = 1; break; case '?': default: usage(EXIT_FAILURE); } } if (hflag) usage(EXIT_SUCCESS); if (vflag) { (void)printf("%s %s\n", PACKAGE, VERSION); ret = EXIT_SUCCESS; goto out; } /* init default max required width */ init_maxwidths(); tty_width = getttywidth(); /* if fd is not a terminal and color mode is not "always", disable color */ if (tty_width == 0 && cflag != 2) cflag = 0; /* change cnf value according to config file, if it exists */ if ((cfgfile = config_file()) != NULL) { if (update_conf(cfgfile) == -1) { (void)fprintf(stderr, _("Error reading the configuration" " file: %s\n"), cfgfile); ret = EXIT_FAILURE; } free(cfgfile); } /* if nothing specified, text output is default */ if (!eflag) init_disp_text(&sdisp); /* initializes the queue */ init_queue(&queue); /* fetch information about the currently mounted filesystems */ fetch_info(&queue); /* cannot display all information if tty is too narrow */ if (!fflag && tty_width > 0 && !eflag) auto_adjust(tty_width); /* actually displays the info we have got */ disp(&queue, fstfilter, fsnfilter, &sdisp); out: free(fstfilter); free(fsnfilter); return ret; } /* * Display usage. * param: status --> status code (EXIT_SUCCESS, EXIT_FAILURE, ...) */ void usage(int status) { if (status != 0) (void)fputs(_("Try dfc -h for more information\n"), stderr); else { /* 2 fputs because string length limit is 509 */ (void)fputs(_("Usage: dfc [OPTION(S)] [-c WHEN] [-e FORMAT] " "[-p FSNAME] [-q SORTBY] [-t FSTYPE] " "[-u UNIT]\n" "Available options:\n" "\t-a\tprint all mounted filesystem\n" "\t-b\tdo not show the graph bar\n" "\t-c\tchoose color mode. Read the manpage for " "details\n" "\t-d\tshow used size\n" "\t-e\texport to specified format. Read the manpage " "for details\n" "\t-f\tdisable auto-adjust mode (force display)\n" "\t-h\tprint this message\n" "\t-i\tinfo about inodes\n" "\t-l\tonly show information about locally mounted " "file systems\n"), stdout); (void)fputs(_( "\t-m\tuse metric (SI unit)\n" "\t-M\tdo not print \"mounted on\"\n" "\t-n\tdo not print header\n" "\t-o\tshow mount flags\n" "\t-p\tfilter by file system name. Read the manpage " "for details\n" "\t-q\tsort the output. Read the manpage for " "details\n" "\t-s\tsum the total usage\n" "\t-t\tfilter by file system type. Read the manpage " "for details\n" "\t-T\tshow filesystem type\n" "\t-u\tchoose the unit in which to show the values. " "Read the manpage for details\n" "\t-v\tprint program version\n" "\t-w\tuse a wider bar\n" "\t-W\twide filename (un truncate)\n"), stdout); } exit(status); /* NOTREACHED */ } /* * Actually displays infos in nice manner * @lst: queue containing all required information * @fstfilter: fstype to filter (can be NULL) * @fsnfilter: fsname to filter (can be NULL) * @sdisp: display structure that points to the respective functions regarding * the selected output type */ void disp(struct list *lst, const char *fstfilter, const char *fsnfilter, struct display *sdisp) { struct fsmntinfo *p = NULL; int n; int nmt = 0; int nmn = 0; double stot, atot, utot, ifitot, ifatot; stot = atot = utot = ifitot = ifatot = n = 0; /* activate negative matching on fs type? */ if (tflag) { if (fstfilter && fstfilter[0] == '-') { nmt = 1; fstfilter++; } } /* activate negative matching on fs name? */ if (pflag) { if (fsnfilter && fsnfilter[0] == '-') { nmn = 1; fsnfilter++; } } /* only required for html, json and tex export */ if (sdisp->init) sdisp->init(); /* legend on top */ if (!nflag) sdisp->print_header(); /* sort the list */ if (qflag) lst->head = msort(lst->head); for (p = lst->head; p; p = p->next) { /* ignored unless proven otherwise */ p->ignored = 1; /* ignore when needed */ if (!aflag && (is_mnt_ignore(p) == 1)) { continue; } /* filtering on fs type */ if (tflag && (fsfilter(p->fstype, fstfilter, nmt) == 0)) { continue; } /* filtering on fs name */ if (pflag && (fsfilter(p->fsname, fsnfilter, nmn) == 0)) { continue; } /* skip remote file systems */ if (lflag && is_remote(p)) { continue; } p->ignored = 0; } p = lst->head; while (p != NULL) { if (p->ignored) { p = delete_struct_and_get_next(p); continue; } /* filesystem */ sdisp->print_fs(p->fsname); /* type */ if (Tflag) { sdisp->print_type(p->fstype); } if (sflag) { stot += p->total; atot += p->avail; utot += p->used; } if (!bflag) sdisp->print_bar(p->perctused); /* %used */ sdisp->print_perct(p->perctused); /* format to requested format */ if (uflag) { p->total = cvrt(p->total); p->avail = cvrt(p->avail); if (dflag) p->used = cvrt(p->used); } if (dflag) sdisp->print_used(p->used, p->perctused, max.used); sdisp->print_avail(p->avail, p->perctused, max.avail); sdisp->print_total(p->total, p->perctused, max.total); /* info about inodes */ if (iflag) { ifitot += (double)p->files; ifatot += (double)p->favail; #if defined(__linux__) || defined(__GLIBC__) sdisp->print_inodes((uint64_t)(p->files), (uint64_t)(p->favail)); #else sdisp->print_inodes((uint64_t)(p->files), (uint64_t)( p->ffree)); #endif /* __linux__ */ } /* mounted on */ if (!Mflag) sdisp->print_mount(p->mntdir); /* info about mount option */ if (oflag) sdisp->print_mopt(p->mntopts); /* new line character depending on export type */ sdisp->print_ln_end(); p = delete_struct_and_get_next(p); } if (sflag) sdisp->print_sum(stot, atot, utot, ifitot, ifatot); /* only required for html and tex export (csv and text point to NULL) */ if (sdisp->deinit) sdisp->deinit(); } dfc-3.1.0/src/dfc.h000644 001750 000144 00000003703 13072400202 014244 0ustar00robinusers000000 000000 /* * Copyright (c) 2012-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ #ifndef H_DFC #define H_DFC /* * dfc.h * * header file for dfc.c */ #include "dotfile.h" #include "extern.h" #include "list.h" #include "util.h" #include "export/display.h" #include "export/export.h" #include "platform/services.h" /* function declaration */ void usage(int status); void disp(struct list *lst, const char *fsfilter, const char *fsnfilter, struct display *sdisp); #endif /* ndef DFC_H */ dfc-3.1.0/src/dotfile.c000644 001750 000144 00000024440 13072400202 015132 0ustar00robinusers000000 000000 /* * Copyright (c) 2012-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ /* * dotfile.c * * Handle configuration file */ #include #include #include #include #include #include #include #include #include #include "dotfile.h" #ifdef NLS_ENABLED #include #endif /* static functions declaration */ static int get_boolean_value(const char *val); static int set_conf(const char *key, const char *val); /* * Get boolean value from a string like ("yes"/"true" or "no"/"false") * Return 1 if "yes"/"true", 0 if "no"/"false", or -1 if not a boolean. * Note that this function is NOT case sensitive. * @val: value to check */ static int get_boolean_value(const char *val) { if ((strcasecmp(val, "yes") == 0) || (strcasecmp(val, "true") == 0)) return 1; else if ((strcasecmp(val, "no") == 0) || (strcasecmp(val, "false") == 0)) return 0; else return -1; } /* * Finds the configuration file and returns its path. * NULL is returned when no configuration file is found. * Configuration file follows XDG Base Directory Specification * http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html */ char * config_file(void) { char *xdg_home, *home; char conf[PATH_MAX]; int ret; xdg_home = getenv("XDG_CONFIG_HOME"); if (xdg_home && *xdg_home) { ret = snprintf(conf, sizeof(conf), "%s/dfc/dfcrc", xdg_home); if (ret < 0) return NULL; if ((size_t)ret >= sizeof(conf)) goto trunc_err; if (access(conf, F_OK) == 0) return strdup(conf); } home = getenv("HOME"); if (home && *home) { ret = snprintf(conf, sizeof(conf), "%s/.config/dfc/dfcrc", home); if (ret < 0) return NULL; if ((size_t)ret >= sizeof(conf)) goto trunc_err; if (access(conf, F_OK) == 0) return strdup(conf); ret = snprintf(conf, sizeof(conf), "%s/.dfcrc", home); if (ret < 0) return NULL; if ((size_t)ret >= sizeof(conf)) goto trunc_err; if (access(conf, F_OK) == 0) return strdup(conf); } return NULL; trunc_err: (void)fprintf( stderr, _("Config file path is longer than %lu and was truncated. " "Please, open a bug report.\n"), sizeof(conf) ); return NULL; } /* * Parse the configuration file and update options * return -1 in case of error, otherwise, 0 is returned * @conf: path to the configuration file */ int update_conf(const char *conf) { FILE *fd; char line[255]; char *key, *val; int ret = 0; if ((fd = fopen(conf, "r")) == NULL) { (void)fprintf(stderr, "Cannot read file %s", conf); perror(" "); return -1; } while ((fgets(line, (int)sizeof(line), fd)) != NULL) { /* skip empty lines and lines beginning with # */ if (!strlen(strtrim(line)) || line[0] == '#') continue; key = strtok(line, "="); val = strtok(NULL, ""); key = strtrim(key); if ((val = strtrim(val)) == NULL) { (void)fprintf(stderr, _("Error: no value for %s in " "configuration file\n"), key); if (fclose(fd) == EOF) perror("Could not close configuration file "); return -1; } ret += set_conf(key, val); } if (fclose(fd) == EOF) perror("Could not close configuration file "); if (ret < 0) return -1; return ret; } /* * Set configuration values taken from the configuration file * Return 0 if no error occurred, -1 otherwise. * @key: key in configuration file * @val: value corresponding to the key */ static int set_conf(const char *key, const char *val) { int tmp; int ret = 0; char *tmpc = NULL; if (strcmp(key, "bold_font") == 0) { if ((tmp = get_boolean_value(val)) == -1) goto unknown_boolean_value; else if (tmp == 1) cnf.font_type = BOLD_FONT; else if (tmp == 0) cnf.font_type = REGULAR_FONT; } else if (strcmp(key, "color_header") == 0) { if ((tmp = colortoint(val)) == -1) goto unknown_color_value; else cnf.chead = tmp; } else if (strcmp(key, "color_low") == 0) { if ((tmp = colortoint(val)) == -1) goto unknown_color_value; else cnf.clow = tmp; } else if (strcmp(key, "color_medium") == 0) { if ((tmp = colortoint(val)) == -1) goto unknown_color_value; else cnf.cmedium = tmp; } else if (strcmp(key, "color_high") == 0) { if ((tmp = colortoint(val)) == -1) goto unknown_color_value; else cnf.chigh = tmp; } else if (strcmp(key, "graph_medium") == 0) { ret = -1; /* reset errno value for strtol (see strtol(3)) */ errno = 0; tmp = (int)strtol(val, (char **) NULL, 10); if (errno) (void)fprintf(stderr, _("Value conversion failed" " for graph_medium: %s. What were you " "expecting with such a thing anyway?\n"), val); else if (tmp < 0) (void)fprintf(stderr, _("Medium value cannot be" " set below 0: %s\n"), val); else if (tmp > 100) (void)fprintf(stderr, _("Medium value cannot be" " set above 100: %s\n"), val); else { ret = 0; cnf.gmedium = tmp; } } else if (strcmp(key, "graph_high") == 0) { ret = -1; /* reset errno value for strtol (see strtol(3)) */ errno = 0; tmp = (int)strtol(val, (char **) NULL, 10); if (errno) (void)fprintf(stderr, _("Value conversion failed" " for graph_medium: %s. What were you " "expecting with such a thing anyway?\n"), val); else if (tmp < 0) (void)fprintf(stderr, _("High value cannot be" " set below 0: %s\n"), val); else if (tmp > 100) (void)fprintf(stderr, _("High value cannot be" " set above 100: %s\n"), val); else { ret = 0; cnf.ghigh = tmp; } } else if (strcmp(key, "graph_symbol") == 0) { if (strlen(val) == 1) cnf.gsymbol = val[0]; else { (void)fprintf(stderr, _("Wrong symbol value: " "%s\n"), val); ret = -1; } } else if (strcmp(key, "html_color_header_bg") == 0) { if (chk_html_colorcode(val) == 0) { if (!(tmpc = strdup(val))) goto strdup_failed; else cnf.hcheadbg = tmpc; } else goto non_valid_html_color; } else if (strcmp(key, "html_color_header_fg") == 0) { if (chk_html_colorcode(val) == 0) { if (!(tmpc = strdup(val))) goto strdup_failed; else cnf.hcheadfg = tmpc; } else goto non_valid_html_color; } else if (strcmp(key, "html_color_cell_bg") == 0) { if (chk_html_colorcode(val) == 0) { if (!(tmpc = strdup(val))) goto strdup_failed; else cnf.hccellbg = tmpc; } else goto non_valid_html_color; } else if (strcmp(key, "html_color_cell_fg") == 0) { if (chk_html_colorcode(val) == 0) { if (!(tmpc = strdup(val))) goto strdup_failed; else cnf.hccellfg = tmpc; } else goto non_valid_html_color; } else if (strcmp(key, "html_color_hover_bg") == 0) { if (chk_html_colorcode(val) == 0) { if (!(tmpc = strdup(val))) goto strdup_failed; else cnf.hchoverbg = tmpc; } else goto non_valid_html_color; } else if (strcmp(key, "html_color_hover_fg") == 0) { if (chk_html_colorcode(val) == 0) { if (!(tmpc = strdup(val))) goto strdup_failed; else cnf.hchoverfg = tmpc; } else goto non_valid_html_color; } else if (strcmp(key, "html_color_low") == 0) { if (chk_html_colorcode(val) == 0) { if (!(tmpc = strdup(val))) goto strdup_failed; else cnf.hclow = tmpc; } else goto non_valid_html_color; } else if (strcmp(key, "html_color_medium") == 0) { if (chk_html_colorcode(val) == 0) { if (!(tmpc = strdup(val))) goto strdup_failed; else cnf.hcmedium = tmpc; } else goto non_valid_html_color; } else if (strcmp(key, "html_color_high") == 0) { if (chk_html_colorcode(val) == 0) { if (!(tmpc = strdup(val))) goto strdup_failed; else cnf.hchigh = tmpc; } else goto non_valid_html_color; } else if (strcmp(key, "csv_separator") == 0) { if (strlen(val) == 1) cnf.csvsep = val[0]; else { (void)fprintf(stderr, _("Wrong csv separator: " "%s\n"), val); ret = -1; } } else { (void)fprintf(stderr, _("Error: unknown option in configuration" " file: %s\n"), key); ret = -1; } free(tmpc); return ret; unknown_boolean_value: (void)fprintf(stderr, _("Unknown boolean value: %s\n"), val); free(tmpc); return -1; unknown_color_value: (void)fprintf(stderr, _("Unknown color value: %s\n"), val); free(tmpc); return -1; non_valid_html_color: (void)fprintf(stderr, _("Not a valid HTML color: %s\n"), val); free(tmpc); return -1; strdup_failed: (void)fprintf(stderr, _("Could not assign value from configuration " "file: %s\n"), val); free(tmpc); return -1; } /* * init a conf structure * @cnf: structure to be initiated */ void init_conf(struct conf *config) { config->chead = BLUE; config->clow = GREEN; config->cmedium = YELLOW; config->chigh = RED; config->gmedium = 50; config->ghigh = 75; config->gsymbol = '='; config->hcheadbg = "970000"; config->hcheadfg = "FFFFFF"; config->hccellbg = "E9E9E9"; config->hccellfg = "000000"; config->hchoverbg = "FFFFFF"; config->hchoverfg = "000000"; config->hclow = "348017"; config->hcmedium = "FDD017"; config->hchigh = "F62217"; config->csvsep = ','; } dfc-3.1.0/src/dotfile.h000644 001750 000144 00000003472 13072400202 015141 0ustar00robinusers000000 000000 /* * Copyright (c) 2012-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ #ifndef H_DOTFILE #define H_DOTFILE /* * dotfile.h * * Header for dotfile.c */ #include "extern.h" #include "util.h" /* function declaration */ char *config_file(void); int update_conf(const char *dfcrc); void init_conf(struct conf *config); #endif /* ndef H_DOTFILE */ dfc-3.1.0/src/export/000755 001750 000144 00000000000 13072400264 014665 5ustar00robinusers000000 000000 dfc-3.1.0/src/export/csv.c000644 001750 000144 00000015345 13072400202 015624 0ustar00robinusers000000 000000 /* * Copyright (c) 2012-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ /* * csv.c * * CSV display functions * NB: color and graph do not make sense in CSV format so we just do not care * about those */ #include #include "extern.h" #include "export.h" #include "display.h" #include "list.h" #include "util.h" #ifdef NLS_ENABLED #include #endif /* static function declaration */ static void csv_disp_header(void); static void csv_disp_sum(double stot, double utot, double ftot, double ifitot, double ifatot); static void csv_disp_bar(double perct); static void csv_disp_uat(double n, double perct, int req_width); static void csv_disp_fs(const char *fsname); static void csv_disp_type(const char *type); static void csv_disp_inodes(uint64_t files, uint64_t favail); static void csv_disp_mount(const char *dir); static void csv_disp_mopt(const char *opts); static void csv_disp_perct(double perct); static void csv_disp_ln_end(void); /* init pointers from display structure to the functions found here */ void init_disp_csv(struct display *disp) { disp->init = NULL; /* not required --> not implemented here */ disp->deinit = NULL; /* not required --> not implemented here */ disp->print_header = csv_disp_header; disp->print_sum = csv_disp_sum; disp->print_bar = csv_disp_bar; disp->print_used = csv_disp_uat; disp->print_avail = csv_disp_uat; disp->print_total = csv_disp_uat; disp->print_fs = csv_disp_fs; disp->print_type = csv_disp_type; disp->print_inodes = csv_disp_inodes; disp->print_mount = csv_disp_mount; disp->print_mopt = csv_disp_mopt; disp->print_perct = csv_disp_perct; disp->print_ln_end = csv_disp_ln_end; } /* * Display header */ static void csv_disp_header(void) { (void)printf(_("FILESYSTEM%c"), cnf.csvsep); if (Tflag) (void)printf(_("TYPE%c"), cnf.csvsep); (void)printf(_("%%USED%c"), cnf.csvsep); if (dflag) (void)printf(_("USED%c"), cnf.csvsep); (void)printf(_("AVAILABLE%c"), cnf.csvsep); (void)printf(_("TOTAL")); if (iflag) { (void)printf(_("%c#INODES%c"), cnf.csvsep, cnf.csvsep); (void)printf(_("AV.INODES")); } if (!Mflag) (void)printf("%c%s", cnf.csvsep, _("MOUNTED ON")); if (oflag) (void)printf(_("%cMOUNT OPTIONS"), cnf.csvsep); (void)printf("\n"); } /* * Display the sum (useful when -s option is used * @stot: total size of "total" * @atot: total size of "available" * @utot: total size of "used" * @ifitot: total number of inodes * @ifatot: total number of available inodes */ static void csv_disp_sum(double stot, double atot, double utot, double ifitot, double ifatot) { double ptot = 0; if ((int)stot == 0) ptot = 100.0; else ptot = (utot / stot) * 100.0; (void)printf(_("SUM:%c"), cnf.csvsep); if (Tflag) (void)printf("%c", cnf.csvsep); csv_disp_perct(ptot); if (uflag) { stot = cvrt(stot); atot = cvrt(atot); if (dflag) utot = cvrt(utot); } if (dflag) csv_disp_uat(utot, ptot, 0); csv_disp_uat(atot, ptot, 0); csv_disp_uat(stot, ptot, 0); if (iflag) csv_disp_inodes((uint64_t)ifitot, (uint64_t)ifatot); (void)printf("\n"); } /* * Should display the nice usage bar but this makes no sense in CSV export * Therefore, this is a dummy function that does nothing when called from * dfc.c but it is required in order to avoid stupid checks in dfc.c * @perct: is ignored */ static void csv_disp_bar(double perct) { (void)perct; /* DUMMY */ } /* * Display available and total correctly formatted * @n: number to print * @perct: ignored here * @req_width: ignored here */ static void csv_disp_uat(double n, double perct, int req_width) { int i; (void)perct; (void)req_width; (void)printf("%c", cnf.csvsep); if (unitflag == 'h') { i = humanize(&n); (void)printf(i == 0 ? "%.f" : "%.1f", n); print_unit(i, 1); } else { if (unitflag == 'b') (void)printf("%f", n); else if (unitflag == 'k') (void)printf("%f", n); else (void)printf("%.1f", n); print_unit(0, 1); } } /* * Display file system * @fsname: list of the file system to print */ static void csv_disp_fs(const char *fsname) { (void)printf("%s%c",fsname, cnf.csvsep); } /* * Display file system type * @type: the file system type to print */ static void csv_disp_type(const char *type) { (void)printf("%s%c", type, cnf.csvsep); } /* * Display inodes *@files: number of inodes *@favail: number of available inodes */ static void csv_disp_inodes(uint64_t files, uint64_t favail) { int i; if (unitflag == 'h') { i = humanize_i(&files); (void)printf("%c%" PRIu64, cnf.csvsep, files); print_unit(i, 0); i = humanize_i(&favail); (void)printf("%c%" PRIu64, cnf.csvsep, favail); print_unit(i, 0); } else { (void)printf("%c%" PRIu64, cnf.csvsep, files); (void)printf("%c%" PRIu64, cnf.csvsep, favail); } } /* * Display mount point * @dir: mount point */ static void csv_disp_mount(const char *dir) { (void)printf("%c%s", cnf.csvsep, dir); } /* * Display mount options * @opts: mount options */ static void csv_disp_mopt(const char *opts) { (void)printf("%c\"%s\"", cnf.csvsep, opts); } /* * Display percentage * @perct: percentage */ static void csv_disp_perct(double perct) { (void)printf("%.f%%", perct); } /* * Display line ending */ static void csv_disp_ln_end(void) { (void)printf("\n"); } dfc-3.1.0/src/export/display.h000644 001750 000144 00000004537 13072400202 016504 0ustar00robinusers000000 000000 /* * Copyright (c) 2012-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ #ifndef H_DISPLAY #define H_DISPLAY #include #include /* Structure to handle the display interface. */ struct display { /* Some interfaces may need to initialize/deinitialize stuff */ void (*init) (void); void (*deinit) (void); void (*print_header) (void); void (*print_sum) (double, double, double, double, double); void (*print_bar) (double); void (*print_used) (double, double, int); void (*print_avail) (double, double, int); void (*print_total) (double, double, int); void (*print_fs) (const char *); void (*print_type) (const char *); void (*print_inodes) (uint64_t, uint64_t); void (*print_mount) (const char *); void (*print_mopt) (const char *); void (*print_perct) (double); void (*print_ln_end) (void); }; #endif /* ndef H_DISPLAY */ dfc-3.1.0/src/export/export.h000644 001750 000144 00000003621 13072400202 016351 0ustar00robinusers000000 000000 /* * Copyright (c) 2012-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ #ifndef H_EXPORT #define H_EXPORT /* * export.h * * Header file for public export functions */ #include "display.h" void init_disp_csv(struct display *disp); void init_disp_html(struct display *disp); void init_disp_json(struct display *disp); void init_disp_tex(struct display *disp); void init_disp_text(struct display *disp); #endif /* ndef H_EXPORT */ dfc-3.1.0/src/export/html.c000644 001750 000144 00000024636 13072400202 016000 0ustar00robinusers000000 000000 /* * Copyright (c) 2012-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ /* * html.c * * HTML display functions */ #include #include #include #include "extern.h" #include "export.h" #include "display.h" #include "list.h" #include "util.h" #ifdef NLS_ENABLED #include #endif /* static functions declaration */ static void html_disp_init(void); static void html_disp_deinit(void); static void html_disp_header(void); static void html_disp_sum(double stot, double utot, double ftot, double ifitot, double ifatot); static void html_disp_bar(double perct); static void html_disp_uat(double n, double perct, int req_width); static void html_disp_fs(const char *fsname); static void html_disp_type(const char *type); static void html_disp_inodes(uint64_t files, uint64_t favail); static void html_disp_mount(const char *dir); static void html_disp_mopt(const char *opts); static void html_disp_perct(double perct); static void html_disp_ln_end(void); /* init pointers from display structure to the functions found here */ void init_disp_html(struct display *disp) { disp->init = html_disp_init; disp->deinit = html_disp_deinit; disp->print_header = html_disp_header; disp->print_sum = html_disp_sum; disp->print_bar = html_disp_bar; disp->print_used = html_disp_uat; disp->print_avail = html_disp_uat; disp->print_total = html_disp_uat; disp->print_fs = html_disp_fs; disp->print_type = html_disp_type; disp->print_inodes = html_disp_inodes; disp->print_mount = html_disp_mount; disp->print_mopt = html_disp_mopt; disp->print_perct = html_disp_perct; disp->print_ln_end = html_disp_ln_end; } /* * Print DOCTYPE and everything that is required before the html body */ static void html_disp_init(void) { (void)puts(""); (void)puts(""); (void)puts(" "); (void)puts(" "); (void)puts(" "); (void)printf(" \n", PACKAGE, VERSION); (void)puts(" "); (void)puts(" "); (void)printf(" %s-%s", PACKAGE, VERSION); (void)puts(" \n "); } /* * Close all open html tag that need to be closed after html body */ static void html_disp_deinit(void) { (void)puts("\t"); if (sflag) (void)puts("\t"); (void)puts(" \n \n"); } /* * Display header */ static void html_disp_header(void) { char *date; if ((date = fetchdate()) == NULL) { if ((date = strdup(_("Unknown date"))) == NULL) { perror("strdup "); exit(EXIT_FAILURE); /* NOTREACHED */ } } (void)printf(" \n "); (void)puts("\t\n\t"); (void)printf("\t \n", _("FILESYSTEM")); if (Tflag) (void)printf("\t \n", _("TYPE")); if (!bflag) (void)printf("\t \n"); (void)printf("\t \n", _("%USED")); if (dflag) (void)printf("\t \n", _("USED")); (void)printf("\t \n", _("AVAILABLE")); (void)printf("\t \n", _("TOTAL")); if (iflag) { (void)printf("\t \n", _("#INODES")); (void)printf("\t \n", _("AV.INODES")); } if (!Mflag) (void)printf("\t \n", _("MOUNTED ON")); if (oflag) (void)printf("\t \n", _("MOUNT OPTIONS")); (void)puts("\t\n\t"); free(date); } /* * Display the sum (useful when -s option is used * @stot: total size of "total" * @atot: total size of "available" * @utot: total size of "used" * @ifitot: total number of inodes * @ifatot: total number of available inodes */ static void html_disp_sum(double stot, double atot, double utot, double ifitot, double ifatot) { double ptot = 0; if ((int)stot == 0) ptot = 100.0; else ptot = (utot / stot) * 100.0; (void)puts("\t\n\t\n\t\n\t "); if (Tflag) (void)puts("\t "); if (!bflag) html_disp_bar(ptot); html_disp_perct(ptot); if (uflag) { stot = cvrt(stot); atot = cvrt(atot); if (dflag) utot = cvrt(utot); } if (dflag) html_disp_uat(utot, ptot, 0); html_disp_uat(atot, ptot, 0); html_disp_uat(stot, ptot, 0); if (iflag) html_disp_inodes((uint64_t)ifitot, (uint64_t)ifatot); /* keep same amount of columns in table */ (void)puts("\t "); if (oflag) (void)puts("\t "); } /* * Display the nice usage bar * @perct: percentage value */ static void html_disp_bar(double perct) { int barwidth = 100; /* In pixels */ int barheight = 25; /* In pixels */ int size; (void)puts("\t "); } /* * Display available and total correctly formatted * @n: number to print * @perct: ignored here * @req_width: ignored here */ static void html_disp_uat(double n, double perct, int req_width) { int i; (void)perct; (void)req_width; (void)printf("\t "); } /* * Display file system * @fsname: list of the file system to print */ static void html_disp_fs(const char *fsname) { static int must_close = 0; if (must_close == 1) (void)puts("\t"); (void)printf("\t\n\t \n", fsname); must_close = 1; } /* * Display file system type * @type: the file system type to print */ static void html_disp_type(const char *type) { (void)printf("\t \n", type); } /* * Display inodes *@files: number of inodes *@favail: number of available inodes */ static void html_disp_inodes(uint64_t files, uint64_t favail) { int i; if (unitflag == 'h') { i = humanize_i(&files); (void)printf("\t \n"); i = humanize_i(&favail); (void)printf("\t \n"); } else { (void)printf("\t \n", files); (void)printf("\t \n", favail); } } /* * Display mount point * @dir: mount point */ static void html_disp_mount(const char *dir) { (void)printf("\t \n", dir); } /* * Display mount options * @opts: mount options */ static void html_disp_mopt(const char *opts) { (void)printf("\t \n", opts); } /* * Display percentage * @perct: percentage */ static void html_disp_perct(double perct) { (void)printf("\t \n", perct); } /* * Display line ending */ static void html_disp_ln_end(void) { } dfc-3.1.0/src/export/json.c000644 001750 000144 00000014035 13072400202 015775 0ustar00robinusers000000 000000 /* * Copyright (c) 2016-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ /* * json.c * * JSON export functions * NB: color and graph do not make sense in JSON format so we just do not care * about those */ #include #include #include "extern.h" #include "export.h" #include "display.h" #include "list.h" #include "util.h" #ifdef NLS_ENABLED #include #endif static int first_element; /* static function declaration */ static void json_disp_init(void); static void json_disp_deinit(void); static void json_disp_header(void); static void json_disp_sum(double stot, double utot, double ftot, double ifitot, double ifatot); static void json_disp_bar(double perct); static void json_disp_uat(double n, const char *key); static void json_disp_used(double used, double perct, int req_width); static void json_disp_avail(double avail, double perct, int req_width); static void json_disp_total(double total, double perct, int req_width); static void json_disp_fs(const char *fsname); static void json_disp_type(const char *type); static void json_disp_inodes(uint64_t files, uint64_t favail); static void json_disp_mount(const char *dir); static void json_disp_mopt(const char *opts); static void json_disp_perct(double perct); static void json_disp_ln_end(void); /* init pointers from display structure to the functions found here */ void init_disp_json(struct display *disp) { disp->init = json_disp_init; disp->deinit = json_disp_deinit; disp->print_header = json_disp_header; disp->print_sum = json_disp_sum; disp->print_bar = json_disp_bar; disp->print_used = json_disp_used; disp->print_avail = json_disp_avail; disp->print_total = json_disp_total; disp->print_fs = json_disp_fs; disp->print_type = json_disp_type; disp->print_inodes = json_disp_inodes; disp->print_mount = json_disp_mount; disp->print_mopt = json_disp_mopt; disp->print_perct = json_disp_perct; disp->print_ln_end = json_disp_ln_end; } static void json_disp_init(void) { (void)printf("{\"filesystems\":["); first_element = 1; } static void json_disp_deinit(void) { if (sflag) (void)printf("}\n"); /* sum func closes the list of fs */ else (void)printf("]}\n"); } static void json_disp_header(void) { /* DUMMY */ } static void json_disp_sum(double stot, double atot, double utot, double ifitot, double ifatot) { double ptot = 0.0; if ((int)stot == 0) ptot = 100.0; else ptot = (utot / stot) * 100.0; (void)printf("],\"sum\":{\"usage\":\"%f%%\"", ptot); if (uflag) { stot = cvrt(stot); atot = cvrt(atot); if (dflag) utot = cvrt(utot); } if (dflag) json_disp_uat(utot, "used"); json_disp_uat(atot, "available"); json_disp_uat(stot, "total"); if (iflag) json_disp_inodes((uint64_t)ifitot, (uint64_t)ifatot); (void)printf("}"); } static void json_disp_bar(double perct) { (void)perct; /* DUMMY */ } static void json_disp_uat(double n, const char *key) { int i; i = 0; if (unitflag == 'h') i = humanize(&n); (void)printf(",\"%s\":\"", key); (void)printf(i == 0 ? "%.f" : "%.1f", n); print_unit(i, 1); (void)printf("\""); } static void json_disp_used(double used, double perct, int req_width) { (void)perct; (void)req_width; json_disp_uat(used, "used"); } static void json_disp_avail(double avail, double perct, int req_width) { (void)perct; (void)req_width; json_disp_uat(avail, "available"); } static void json_disp_total(double total, double perct, int req_width) { (void)perct; (void)req_width; json_disp_uat(total, "total"); } static void json_disp_fs(const char *fsname) { if (!first_element) (void)printf(","); (void)printf("{\"filesystem\":\"%s\",", fsname); if (first_element) first_element = 0; } static void json_disp_type(const char *type) { (void)printf("\"type\":\"%s\",", type); } static void json_disp_inodes(uint64_t files, uint64_t favail) { int i; if (unitflag == 'h') { i = humanize_i(&files); (void)printf(",\"inodes_count\":\"%" PRIu64, files); print_unit(i, 0); (void)printf("\""); i = humanize_i(&favail); (void)printf(",\"inodes_available\":\"%" PRIu64, favail); print_unit(i, 0); (void)printf("\""); } else { (void)printf(",\"inodes_count\":\"%" PRIu64 "\"", files); (void)printf(",\"inodes_available\":%" PRIu64 "\"", favail); } } static void json_disp_mount(const char *dir) { (void)printf(",\"mount_point\":\"%s\"", dir); } static void json_disp_mopt(const char *opts) { (void)printf(",\"mount_options\":\"%s\"", opts); } static void json_disp_perct(double perct) { (void)printf("\"usage\":\"%f%%\"", perct); } static void json_disp_ln_end(void) { (void)printf("}"); } dfc-3.1.0/src/export/tex.c000644 001750 000144 00000022120 13072400202 015616 0ustar00robinusers000000 000000 /* * Copyright (c) 2012-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ /* * tex.c * * TeX display functions */ #include #include #include "extern.h" #include "export.h" #include "display.h" #include "list.h" #include "util.h" #ifdef NLS_ENABLED #include #endif /* static function declaration */ static void tex_disp_init(void); static void tex_disp_deinit(void); static void tex_disp_header(void); static void tex_disp_sum(double stot, double utot, double ftot, double ifitot, double ifatot); static void tex_disp_bar(double perct); static void tex_disp_uat(double n, double perct, int req_width); static void tex_disp_fs(const char *fsname); static void tex_disp_type(const char *type); static void tex_disp_inodes(uint64_t files, uint64_t favail); static void tex_disp_mount(const char *dir); static void tex_disp_mopt(const char *opts); static void tex_disp_perct(double perct); static void tex_disp_ln_end(void); /* init pointers from display structure to the functions found here */ void init_disp_tex(struct display *disp) { disp->init = tex_disp_init; disp->deinit = tex_disp_deinit; disp->print_header = tex_disp_header; disp->print_sum = tex_disp_sum; disp->print_bar = tex_disp_bar; disp->print_used = tex_disp_uat; disp->print_avail = tex_disp_uat; disp->print_total = tex_disp_uat; disp->print_fs = tex_disp_fs; disp->print_type = tex_disp_type; disp->print_inodes = tex_disp_inodes; disp->print_mount = tex_disp_mount; disp->print_mopt = tex_disp_mopt; disp->print_perct = tex_disp_perct; disp->print_ln_end = tex_disp_ln_end; } /* * Print all that is required for the TeX file like documentclass and so on * Also, computes and print the required amount of columns for the table. */ static void tex_disp_init(void) { int i; int ncolumns = 5; (void)puts("\\documentclass[a4]{report}"); (void)puts("\\usepackage[landscape]{geometry}"); if (cflag) (void)puts("\\usepackage{color}"); (void)puts("\\begin{document}"); if (Tflag) ncolumns++; if (!bflag) ncolumns++; if (dflag) ncolumns++; if (iflag) ncolumns += 2; if (oflag) ncolumns++; (void)printf("\\begin{tabular}{"); for (i = 0; i < ncolumns; i++) (void)printf("|l"); printf("|}\n"); } /* * Close TeX file (end document and so on) */ static void tex_disp_deinit(void) { (void)puts("\\\\"); (void)puts("\\hline"); (void)puts("\\end{tabular}"); (void)puts("\\end{document}"); } /* * Display header */ static void tex_disp_header(void) { (void)puts("\\hline"); (void)printf("%s", _("FILESYSTEM")); if (Tflag) (void)printf(" & %s", _("TYPE")); if (!bflag) (void)printf(" & %s", _("USAGE")); (void)printf(" & %s", _("\\%USED")); if (dflag) (void)printf(" & %s", _("USED")); (void)printf(" & %s ", _("AVAILABLE")); (void)printf(" & %s ", _("TOTAL")); if (iflag) { (void)printf(" & %s ", _("\\#INODES")); (void)printf(" & %s ", _("AV.INODES,")); } if (!Mflag) (void)printf(" & %s ", _("MOUNTED ON")); if (oflag) (void)printf(" & %s ", _("MOUNT OPTIONS")); (void)puts("\\\\"); (void)puts("\\hline"); } /* * Display the sum (useful when -s option is used * @stot: total size of "total" * @atot: total size of "available" * @utot: total size of "used" * @ifitot: total number of inodes * @ifatot: total number of available inodes */ static void tex_disp_sum(double stot, double atot, double utot, double ifitot, double ifatot) { double ptot = 0; if ((int)stot == 0) ptot = 100.0; else ptot = (utot / stot) * 100.0; (void)printf("\\\\ SUM"); if (Tflag) (void)printf(" & N/A"); if (!bflag) tex_disp_bar(ptot); tex_disp_perct(ptot); if (uflag) { stot = cvrt(stot); atot = cvrt(atot); if (dflag) utot = cvrt(utot); } if (dflag) tex_disp_uat(utot, ptot, 0); tex_disp_uat(atot, ptot, 0); tex_disp_uat(stot, ptot, 0); if (iflag) tex_disp_inodes((uint64_t)ifitot, (uint64_t)ifatot); /* keep same amount of columns in table */ (void)printf(" & NA"); if (oflag) (void)printf(" & NA "); } /* * Display the nice usage bar * @perct: percentage value */ static void tex_disp_bar(double perct) { /* * It could be nice to have a non-ASCII graph bar but it requires TeX * packages usually using postscript and so on. So stick with ASCII for * now until someone shows up with a better idea. */ int i, j; int barinc = 5; (void)printf(" & "); /* option to display a wider bar */ if (wflag) { barinc = 2; } if (!cflag) { for (i = 0; i < perct; i += barinc) (void)printf("%c", cnf.gsymbol); for (j = i; j < 100; j += barinc) (void)printf("\\-"); } else { /* color */ /* green */ (void)printf("\\textcolor{%s}{", colortostr(cnf.clow)); for (i = 0; (i < cnf.gmedium) && (i < perct); i += barinc) (void)printf("%c", cnf.gsymbol); /* yellow */ (void)printf("}\\textcolor{%s}{", colortostr(cnf.cmedium)); for (; (i < cnf.ghigh) && (i < perct); i += barinc) (void)printf("%c", cnf.gsymbol); /* red */ (void)printf("}\\textcolor{%s}{", colortostr(cnf.chigh)); for (; (i < 100) && (i < perct); i += barinc) (void)printf("%c", cnf.gsymbol); (void)printf("}"); for (j = i; j < 100; j += barinc) (void)printf("\\-"); } } /* * Display available and total correctly formatted * @n: number to print * @perct: percentage (useful for finding which color to use) * @req_width: ignored here */ static void tex_disp_uat(double n, double perct, int req_width) { int i; (void)perct; (void)req_width; if (unitflag == 'h') { i = humanize(&n); (void)printf(i == 0 ? " & %.f" : " & %.1f", n); print_unit(i, 1); } else { if (unitflag == 'b' || unitflag == 'k') (void)printf(" & %.f", n); else (void)printf(" & %.1f", n); print_unit(0, 1); } } /* * Display file system * @fsname: list of the file system to print */ static void tex_disp_fs(const char *fsname) { static int must_close = 0; char *cleaned_fsname = sanitizestr(fsname); if (cleaned_fsname == NULL) { (void)fputs("Cannot print file system name\n", stderr); return; } if (must_close == 1) (void)puts("\\\\"); (void)printf("%s", cleaned_fsname); free(cleaned_fsname); must_close = 1; } /* * Display file system type * @type: the file system type to print */ static void tex_disp_type(const char *type) { char *cleaned_type = sanitizestr(type); if (cleaned_type == NULL) { (void)fputs("Cannot print type\n", stderr); return; } (void) printf(" & %s", cleaned_type); free(cleaned_type); } /* * Display inodes *@files: number of inodes *@favail: number of available inodes */ static void tex_disp_inodes(uint64_t files, uint64_t favail) { int i; if (unitflag == 'h') { i = humanize_i(&files); (void)printf(" & %" PRIu64, files); print_unit(i, 0); i = humanize_i(&favail); (void)printf(" & %" PRIu64, favail); print_unit(i, 0); } else (void)printf(" & %" PRIu64 " & %" PRIu64, files, favail); } /* * Display mount point * @dir: mount point */ static void tex_disp_mount(const char *dir) { char *cleaned_dir = sanitizestr(dir); if (cleaned_dir == NULL) { (void)fputs("Cannot print mount point\n", stderr); return; } (void)printf(" & %s", cleaned_dir); free(cleaned_dir); } /* * Display mount options * @opts: mount options */ static void tex_disp_mopt(const char *opts) { char *cleaned_opts = sanitizestr(opts); if (cleaned_opts == NULL) { (void)fputs("Cannot print mount options\n", stderr); return; } (void)printf(" & %s", cleaned_opts); free(cleaned_opts); } /* * Display percentage * @perct: percentage */ static void tex_disp_perct(double perct) { (void)printf(" & %.f\\%%", perct); } /* * Display line ending */ static void tex_disp_ln_end(void) { (void)printf("\n"); } dfc-3.1.0/src/export/text.c000644 001750 000144 00000021542 13072400202 016011 0ustar00robinusers000000 000000 /* * Copyright (c) 2012-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ /* * text.c * * Text display functions */ #include #include #include "display.h" #include "dotfile.h" #include "export.h" #include "extern.h" #include "list.h" #include "util.h" #ifdef NLS_ENABLED #include #endif /* static function declaration */ static void text_disp_header(void); static void text_disp_sum(double stot, double utot, double ftot, double ifitot, double ifatot); static void text_disp_bar(double perct); static void text_disp_uat(double n, double perct, int req_width); static void text_disp_fs(const char *fsname); static void text_disp_type(const char *type); static void text_disp_inodes(uint64_t files, uint64_t favail); static void text_disp_mount(const char *dir); static void text_disp_mopt(const char *opts); static void text_disp_perct(double perct); static void text_disp_ln_end(void); static void change_color(double perct); static void reset_color(void); /* init pointers from display structure to the functions found here */ void init_disp_text(struct display *disp) { disp->init = NULL; /* not required --> not implemented here */ disp->deinit = NULL; /* not required --> not implemented here */ disp->print_header = text_disp_header; disp->print_sum = text_disp_sum; disp->print_bar = text_disp_bar; disp->print_used = text_disp_uat; disp->print_avail = text_disp_uat; disp->print_total = text_disp_uat; disp->print_fs = text_disp_fs; disp->print_type = text_disp_type; disp->print_inodes = text_disp_inodes; disp->print_mount = text_disp_mount; disp->print_mopt = text_disp_mopt; disp->print_perct = text_disp_perct; disp->print_ln_end = text_disp_ln_end; } /* * Display header */ static void text_disp_header(void) { int gap; /* use color option if triggered */ if (cflag) (void)printf("\033[%d;%dm", cnf.font_type , cnf.chead); (void)printf("%-*s", max.fsname, _("FILESYSTEM")); if (Tflag) (void)printf("%-*s", max.fstype, _("TYPE")); if (!bflag) { (void)printf("%s", _("(=) USED")); gap = max.bar - (int)strlen(_("(=) USED")) - (int)strlen(_("FREE (-)")); (void)printf("%*s", gap, ""); (void)printf("%s", _("FREE (-)")); } (void)printf("%*s", max.perctused + 1, _("%USED")); if (dflag) (void)printf("%*s", max.used, _("USED")); (void)printf("%*s", max.avail, _("AVAILABLE")); (void)printf("%*s", max.total, _("TOTAL")); if (iflag) { (void)printf("%*s", max.nbinodes, _("#INODES")); (void)printf("%*s", max.avinodes, _("AV.INODES")); } /* add a space because previous colum is right aligned */ (void)printf(" "); if (!Mflag) (void)printf("%-*s", max.mntdir, _("MOUNTED ON")); if (oflag) (void)printf("%-*s", max.mntopts, _("MOUNT OPTIONS")); (void)printf("\n"); reset_color(); } /* * Display the sum (useful when -s option is used * @stot: total size of "total" * @atot: total size of "available" * @utot: total size of "used" * @ifitot: total number of inodes * @ifatot: total number of available inodes */ static void text_disp_sum(double stot, double atot, double utot, double ifitot, double ifatot) { double ptot = 0; int width; width = Tflag ? max.fsname + max.fstype : max.fsname; if ((int)stot == 0) ptot = 100.0; else ptot = (utot / stot) * 100.0; /* use color option if triggered */ if (cflag) (void)printf("\033[%d;%dm", cnf.font_type , cnf.chead); (void)printf("%-*s", width, _("SUM:")); reset_color(); if (!bflag) text_disp_bar(ptot); text_disp_perct(ptot); if (uflag) { stot = cvrt(stot); atot = cvrt(atot); if (dflag) utot = cvrt(utot); } if (dflag) text_disp_uat(utot, ptot, max.used); text_disp_uat(atot, ptot, max.avail); text_disp_uat(stot, ptot, max.total); if (iflag) text_disp_inodes((uint64_t)ifitot, (uint64_t)ifatot); (void)printf("\n"); } /* * Display the nice usage bar * @perct: percentage value */ static void text_disp_bar(double perct) { int i, j; int barinc = 5; /* option to display a wider bar */ if (wflag) { barinc = 2; } /* used (*) */ (void)printf("["); if (!cflag) { for (i = 0; i < perct; i += barinc) (void)printf("%c", cnf.gsymbol); for (j = i; j < 100; j += barinc) (void)printf("-"); } else { /* color */ /* green */ (void)printf("\033[%d;%dm", cnf.font_type , cnf.clow); for (i = 0; (i < cnf.gmedium) && (i < perct); i += barinc) (void)printf("%c", cnf.gsymbol); /* yellow */ (void)printf("\033[%d;%dm", cnf.font_type , cnf.cmedium); for (; (i < cnf.ghigh) && (i < perct); i += barinc) (void)printf("%c", cnf.gsymbol); /* red */ (void)printf("\033[%d;%dm", cnf.font_type , cnf.chigh); for (; (i < 100) && (i < perct); i += barinc) (void)printf("%c", cnf.gsymbol); reset_color(); for (j = i; j < 100; j += barinc) (void)printf("-"); } (void)printf("]"); } /* * Display used, available and total correctly formatted * @n: number to print * @perct: percentage (useful for finding which color to use) * @req_width: required width (used for terminal display, otherwise can be 0) */ static void text_disp_uat(double n, double perct, int req_width) { int i; i = 0; if (unitflag == 'h') i = humanize(&n); change_color(perct); (void)printf("%*.1f", req_width - 1, n); /* -1 for the unit symbol */ reset_color(); print_unit(i, 1); } /* * Display file system * @fsname: list of the file system to print */ static void text_disp_fs(const char *fsname) { (void)printf("%-*s", max.fsname, fsname); } /* * Display file system type * @type: the file system type to print */ static void text_disp_type(const char *type) { (void)printf("%-*s", max.fstype, type); } /* * Display inodes *@files: number of inodes *@favail: number of available inodes */ static void text_disp_inodes(uint64_t files, uint64_t favail) { int i; if (unitflag == 'h') { i = humanize_i(&files); (void)printf("%*" PRIu64, max.nbinodes - 1, files); print_unit(i, 0); i = humanize_i(&favail); (void)printf("%*" PRIu64, max.avinodes - 1, favail); print_unit(i, 0); } else { (void)printf(" %*" PRIu64, max.nbinodes - 1, files); (void)printf(" %*" PRIu64, max.avinodes - 1, favail); } } /* * Display mount point * @dir: mount point */ static void text_disp_mount(const char *dir) { /* preceded by a space because previous colum is right aligned */ (void)printf(" %-*s", max.mntdir, dir); } /* * Display mount options * @opts: mount options */ static void text_disp_mopt(const char *opts) { /* add space when prevous column is right aligned */ if (Mflag) (void)printf(" "); (void)printf("%-*s", max.mntopts, opts); } /* * Display percentage * @perct: percentage */ static void text_disp_perct(double perct) { change_color(perct); (void)printf("%*.1f", max.perctused, perct); reset_color(); (void)printf("%%"); } /* * Display line ending */ static void text_disp_ln_end(void) { (void)printf("\n"); } /* * Change color according to perct * @perct: percentage */ static void change_color(double perct) { if (cflag) { if (perct < (double)cnf.gmedium) /* green */ (void)printf("\033[%d;%dm", cnf.font_type, cnf.clow); else if (perct < (double)cnf.ghigh) /* yellow */ (void)printf("\033[%d;%dm", cnf.font_type, cnf.cmedium); else /* red */ (void)printf("\033[%d;%dm", cnf.font_type, cnf.chigh); } } /* * Reset color attribute to default */ static void reset_color(void) { if (cflag) (void)printf("\033[;m"); } dfc-3.1.0/src/extern.h000644 001750 000144 00000010406 13072400202 015013 0ustar00robinusers000000 000000 /* * Copyright (c) 2012-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ #ifndef H_EXTERN #define H_EXTERN /* * extern.h * * Globals and dfc version declaration */ #ifndef PACKAGE #define PACKAGE "dfc" #endif /* ndef PACKAGE */ #ifndef VERSION #define VERSION "(unknown version)" #endif /* ndef VERSION */ /* too ugly to use gettext in each string that needs translation... */ #ifdef NLS_ENABLED #define _(STRING) gettext(STRING) #else #define _(STRING) STRING #endif /* def NLS_ENABLED */ /* font defines */ #define REGULAR_FONT 0 #define BOLD_FONT 1 /* color defines */ #define BLACK 30 #define RED 31 #define GREEN 32 #define YELLOW 33 #define BLUE 34 #define MAGENTA 35 #define CYAN 36 #define WHITE 37 /* possible lengths of the graph bar */ #define GRAPHBAR_SHORT 22 #define GRAPHBAR_WIDE 52 /* html color code length (type of #FF0000, etc.) without the # */ #define HTMLCOLORCODELENGTH 6 struct conf { int font_type; /* set font type (regular/bold/etc) */ int chead; /* color used for the header */ int clow; /* color when usage low */ int cmedium; /* color when usage medium */ int chigh; /* color when usage high */ int gmedium; /* starting value from which usage is considered medium */ int ghigh; /* starting value from which usage is considered high */ const char *hcheadbg; /* background color for header and footer (html) */ const char *hcheadfg; /* font color used in header and footer (html) */ const char *hccellbg; /* background color for cells (html) */ const char *hccellfg; /* font color for cells (html) */ const char *hchoverbg; /* background color on hover (html) */ const char *hchoverfg; /* font color on hover (html) */ const char *hclow; /* color when usage is low (html) */ const char *hcmedium; /* color when usage is medium (html) */ const char *hchigh; /* color when usage is high (html) */ char gsymbol; /* symbol used to draw the graph */ char csvsep; /* separator used for csv export */ }; struct maxwidths { int fsname; int fstype; int bar; int perctused; int used; int avail; int total; int nbinodes; int avinodes; int mntdir; int mntopts; }; /* * These two variables are used when we do not need to alloc some mem for the * fsmntinfo struct. So we can know that and do not free the pointers */ extern char g_unknown_str[]; extern char g_none_str[]; /* struct to store specific configuration from config file */ extern struct conf cnf; /* struct to store maximum required widths (useful only in text export mode) */ extern struct maxwidths max; /* set flags for options */ extern int aflag, bflag, cflag, dflag, eflag, fflag, hflag, iflag, lflag, mflag, nflag, oflag, pflag, qflag, sflag, tflag, uflag, vflag, wflag; extern int Mflag, Tflag, Wflag; /* flag that determines which unit is in use (Ko, Mo, etc.) */ extern char unitflag; #endif /* ndef EXTERN_H */ dfc-3.1.0/src/list.c000644 001750 000144 00000007012 13072400202 014453 0ustar00robinusers000000 000000 /* * Copyright (c) 2012-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ /* * list.c * * Manipulate list */ #include #include #include "list.h" #include "extern.h" /* * Initializes a queue structure * @lst: queue pointer */ void init_queue(struct list *lst) { lst->head = NULL; lst->tail = NULL; } /* * Checks if a queue is empty * @lst: queue * Returns: * --> 1 (true) if the queue is empty * --> 0 if not */ int is_empty(struct list lst) { if (lst.head == NULL) return 1; else return 0; } /* * Enqueues an element into a queue * @lst: queue pointer * @elt: element * Returns: * --> -1 on error * --> 0 on success */ int enqueue(struct list *lst, struct fsmntinfo fmi) { struct fsmntinfo *new_fmi = malloc(sizeof(struct fsmntinfo)); if (new_fmi == NULL) { (void)fputs("Error while allocating memory to fmi", stderr); return -1; } /* initialize the new element to be inserted in the queue */ *new_fmi = fmi; if (is_empty((*lst))) lst->head = new_fmi; else lst->tail->next = new_fmi; lst->tail = new_fmi; return 0; } /* * Inits an fsmntinfo to some defaults values * Returns: * --> fsmntinfo that has been initialized */ struct fsmntinfo fmi_init(void) { struct fsmntinfo fmi; fmi.fsname = g_unknown_str; fmi.fstype = g_unknown_str; fmi.mntdir = g_unknown_str; fmi.mntopts = g_none_str; fmi.perctused = 0.0; fmi.total = 0.0; fmi.avail = 0.0; fmi.used = 0.0; fmi.flags = 0; fmi.bsize = 0; fmi.frsize = 0; fmi.blocks = 0; fmi.bfree = 0; fmi.bavail = 0; fmi.files = 0; fmi.ffree = 0; fmi.favail = 0; fmi.next = NULL; return fmi; } struct fsmntinfo *delete_struct_and_get_next(struct fsmntinfo *p) { struct fsmntinfo *next; if(p == NULL) /* sanity check, we never know */ return NULL; next = p->next; if(p->fsname != g_unknown_str) /* we malloc'd a string */ free(p->fsname); if(p->fstype != g_unknown_str) free(p->fstype); if(p->mntdir != g_unknown_str) free(p->mntdir); if(p->mntopts != g_none_str) free(p->mntopts); free(p); return next; } dfc-3.1.0/src/list.h000644 001750 000144 00000013362 13072400202 014465 0ustar00robinusers000000 000000 /* * Copyright (c) 2012-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ #ifndef H_LIST #define H_LIST /* * list.h * * list structure */ #include /* * Structure to store information about mounted fs */ struct fsmntinfo { /* infos to get from getmntent(3) */ char *fsname; /* name of mounted file system */ char *fstype; /* mount type */ char *mntdir; /* file system path prefix */ char *mntopts; /* mount options (see mntent.h) */ double perctused; /* fs usage in % */ double total; /* fs total size */ double avail; /* fs available size */ double used; /* fs used size */ /* infos to get from statvfs(3) */ #if defined(__linux__) || defined(__GLIBC__) int flags; /* XXX: does not exist on Linux */ unsigned long bsize; /* file system block size */ unsigned long frsize; /* fragment size */ fsblkcnt_t blocks; /* size of fs in frsize unit */ fsblkcnt_t bfree; /* # of free blocks */ fsblkcnt_t bavail; /* # of available blocks */ fsfilcnt_t files; /* # of inodes */ fsfilcnt_t ffree; /* # of free inodes */ fsfilcnt_t favail; /* # of available inodes */ #endif /* __linux__ */ #if defined(__NetBSD__) unsigned long flags; /* mount exported flags */ unsigned long bsize; /* file system block size */ unsigned long frsize; /* fragment size */ fsblkcnt_t blocks; /* size of fs in frsize unit */ fsblkcnt_t bfree; /* # of free blocks */ fsblkcnt_t bavail; /* # of available blocks */ fsfilcnt_t files; /* # of inodes */ fsfilcnt_t ffree; /* # of free inodes */ fsfilcnt_t favail; /* # of available inodes */ #endif /* __NetBSD__ */ #if defined(__FreeBSD__) uint64_t flags; /* mount exported flags */ uint64_t bsize; /* file system block size */ unsigned long frsize; /* XXX: does not exist on FreeBSD */ uint64_t blocks; /* size of fs in frsize unit */ uint64_t bfree; /* # of free blocks */ int64_t bavail; /* # of available blocks */ uint64_t files; /* # of inodes */ int64_t ffree; /* # of free nodes to non super-user */ unsigned long favail; /* XXX: does not exist on FreeBSD */ #endif /* __FreeBSD__ */ #if defined(__OpenBSD__) u_int32_t flags; /* mount exported flags */ u_int32_t bsize; /* file system block size */ unsigned long frsize; /* XXX: does not exist on OpenBSD */ u_int64_t blocks; /* size of fs in frsize unit */ u_int64_t bfree; /* # of free blocks */ int64_t bavail; /* # of available blocks */ u_int64_t files; /* # of inodes */ u_int64_t ffree; /* # of free inodes */ int64_t favail; /* # of available inodes */ #endif /* __OpenBSD__ */ #if defined(__DragonFly__) int flags; /* mount exported flags */ long bsize; /* file system block size */ unsigned long frsize; /* XXX: does not exist on DragonFly */ long blocks; /* size of fs in frsize unit */ long bfree; /* # of free blocks */ long bavail; /* # of available blocks */ long files; /* # of inodes */ long ffree; /* # of free inodes */ unsigned long favail; /* XXX: does not exist on DragonFly */ #endif /* __DragonFly__ */ #if defined(__APPLE__) uint32_t flags; /* mount exported flags */ uint32_t bsize; /* file system block size */ unsigned long frsize; /* XXX: does not exist on OSX */ uint64_t blocks; /* size of fs in frsize unit */ uint64_t bfree; /* # of free blocks */ uint64_t bavail; /* # of available blocks */ uint64_t files; /* # of inodes */ uint64_t ffree; /* # of free inodes */ unsigned long favail; /* XXX: does not exist on OSX */ #endif /* __APPLE__ */ #if defined(__sun) int flags; /* XXX: does not exist on Solaris */ u_long bsize; /* file system block size */ u_long frsize; /* fragment size */ fsblkcnt_t blocks; /* size of fs in frsize unit */ fsblkcnt_t bfree; /* # of free blocks */ fsblkcnt_t bavail; /* # of available blocks */ fsfilcnt_t files; /* # of inodes */ fsfilcnt_t ffree; /* # of free inodes */ fsfilcnt_t favail; /* # of available inodes */ #endif /* __sun */ int ignored; /* pointer to the next element of the list */ struct fsmntinfo *next; }; /* list structure to store fsmntinfo */ struct list { struct fsmntinfo *head; struct fsmntinfo *tail; }; /* function declaration */ void init_queue(struct list *lst); int is_empty(struct list lst); int enqueue(struct list *lst, struct fsmntinfo elt); struct fsmntinfo fmi_init(void); struct fsmntinfo *delete_struct_and_get_next(struct fsmntinfo *p); #endif /* ndef LIST_H */ dfc-3.1.0/src/platform/000755 001750 000144 00000000000 13072400264 015170 5ustar00robinusers000000 000000 dfc-3.1.0/src/platform/services-bsd.c000644 001750 000144 00000027052 13072400202 017723 0ustar00robinusers000000 000000 /* * Copyright (c) 2012-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ /* * services-bsd.c * * BSDs implemention of services. */ #if defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__) || \ defined(__OpenBSD__) || defined(__NetBSD__) #include #include #include #include #include #include #include #include #ifdef NLS_ENABLED #include #include #endif /* NLS_ENABLED */ #include "extern.h" #include "services.h" #include "util.h" /* Hide differences between NetBSD and the other BSD. */ #if defined(__NetBSD__) typedef struct statvfs statst; #define GET_FLAGS(vfsbuf) ((vfsbuf).f_flag) #define GET_FRSIZE(vfsbuf) ((vfsbuf).f_frsize) #define GET_FAVAIL(vfsbuf) ((vfsbuf).f_favail) #else /* Other BSDs. */ typedef struct statfs statst; #define GET_FLAGS(vfsbuf) ((vfsbuf).f_flags) #define GET_FRSIZE(vfsbuf) (0) #define GET_FAVAIL(vfsbuf) (0) #endif /* * XXX: OSX does not seem to define MNT_IGNORE even though it mentions it in * df(1) manual page. However, df and df -a have the same output on 2 machines * on which I could test. Use this workaround for now. */ #if defined(__APPLE__) #ifndef MNT_IGNORE #define MNT_IGNORE 0 #endif #endif /* __APPLE__ */ /* static functions declaration */ static char *statfs_flags_to_str(const struct fsmntinfo *fs); int is_mnt_ignore(const struct fsmntinfo *fs) { /* TODO: check MNT_IGNORE flags exists on all supported platforms */ if (fs->flags & MNT_IGNORE) return 1; return 0; } int is_remote(const struct fsmntinfo *fs) { if (fs->flags & MNT_LOCAL) return 0; return 1; } void fetch_info(struct list *lst) { struct fsmntinfo *fmi; int nummnt; statst *entbuf; statst vfsbuf, **fs; /* init fsmntinfo */ if ((fmi = malloc(sizeof(struct fsmntinfo))) == NULL) { (void)fputs("Error while allocating memory to fmi", stderr); exit(EXIT_FAILURE); /* NOTREACHED */ } *fmi = fmi_init(); if ((nummnt = getmntinfo(&entbuf, MNT_NOWAIT)) <= 0) err(EXIT_FAILURE, "Error while getting the list of mountpoints"); /* NOTREACHED */ for (fs = &entbuf; nummnt--; (*fs)++) { vfsbuf = **fs; if (Wflag) { /* Wflag to avoid name truncation */ if ((fmi->fsname = strdup(entbuf->f_mntfromname)) == NULL) fmi->fsname = g_unknown_str; if ((fmi->mntdir = strdup(entbuf->f_mntonname)) == NULL) fmi->mntdir = g_unknown_str; if ((fmi->fstype = strdup(entbuf->f_fstypename)) == NULL) fmi->fstype = g_unknown_str; } else { if ((fmi->fsname = strdup(shortenstr( entbuf->f_mntfromname, STRMAXLEN))) == NULL) { fmi->fsname = g_unknown_str; } if ((fmi->mntdir = strdup(shortenstr( entbuf->f_mntonname, STRMAXLEN))) == NULL) { fmi->mntdir = g_unknown_str; } if ((fmi->fstype = strdup(shortenstr( entbuf->f_fstypename, STRMAXLEN))) == NULL) { fmi->fstype = g_unknown_str; } } /* infos from statvfs */ fmi->flags = GET_FLAGS(vfsbuf); fmi->bsize = vfsbuf.f_bsize; fmi->frsize = GET_FRSIZE(vfsbuf); fmi->blocks = vfsbuf.f_blocks; fmi->bfree = vfsbuf.f_bfree; fmi->bavail = vfsbuf.f_bavail; fmi->files = vfsbuf.f_files; fmi->ffree = vfsbuf.f_ffree; fmi->favail = GET_FAVAIL(vfsbuf); if ((fmi->mntopts = statfs_flags_to_str(fmi)) == NULL) fmi->mntopts = g_none_str; /* compute, available, % used, etc. */ compute_fs_stats(fmi); /* pointer to the next element */ fmi->next = NULL; /* enqueue the element into the queue */ enqueue(lst, *fmi); update_maxwidth(fmi); } free(fmi); } void compute_fs_stats(struct fsmntinfo *fmi) { #if defined(__NetBSD__) fmi->total = (double)fmi->frsize * (double)fmi->blocks; fmi->avail = (double)fmi->frsize * (double)fmi->bavail; fmi->used = (double)fmi->frsize * ((double)fmi->blocks - (double)fmi->bfree); #else fmi->total = (double)fmi->bsize * (double)fmi->blocks; fmi->avail = (double)fmi->bsize * (double)fmi->bavail; fmi->used = (double)fmi->bsize * ((double)fmi->blocks - (double)fmi->bfree); #endif /* __NetBSD__ */ if ((int)fmi->total == 0) fmi->perctused = 100.0; else fmi->perctused = 100.0 - ((double)fmi->bavail / (double)fmi->blocks) * 100.0; } /* * All the flags found in *BSD and Mac OS X, alphabetically sorted. */ struct flag_str { long long flag; const char *str; } possible_flags[] = { #if defined(__FreeBSD__) { MNT_ACLS, "acls" }, #endif #if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) \ || defined(__OpenBSD__) || defined (__APPLE__) { MNT_ASYNC, "async" }, #endif #if defined(__APPLE__) { MNT_AUTOMOUNTED, "automounted" }, #endif #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) { MNT_DEFEXPORTED, "defexported" }, #endif #if defined(__APPLE__) { MNT_DEFWRITE, "defwrite" }, { MNT_DONTBROWSE, "dontbrowse" }, { MNT_DOVOLFS, "dovolfs" }, #endif #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) { MNT_EXKERB, "exkerb" }, #endif #if defined(__NetBSD__) { MNT_EXNORESPORT, "noresport" }, #endif #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) { MNT_EXPORTANON, "exportanon" }, #endif #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) \ || defined(__APPLE__) { MNT_EXPORTED, "exported" }, #endif #if defined(__FreeBSD__) || defined(__NetBSD__) { MNT_EXPUBLIC, "expublic" }, #endif #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) { MNT_EXRDONLY, "exrdonly" }, #endif #if defined(__NetBSD__) { MNT_EXTATTR, "extattr" }, #endif #if defined(__FreeBSD__) || defined(__DragonFly__) { MNT_FORCE, "force" }, #endif #if defined(__FreeBSD__) { MNT_GJOURNAL, "gjournal" }, #endif #if defined(__NetBSD__) { MNT_HIDDEN, "hidden" }, #endif #if defined(__APPLE__) { MNT_JOURNALED, "journaled" }, #endif #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) \ || defined(__OpenBSD__) || defined(__APPLE__) { MNT_LOCAL, "local" }, #endif #if defined(__NetBSD__) { MNT_LOG, "log" }, #endif #if defined(__FreeBSD__) || defined(__APPLE__) { MNT_MULTILABEL, "multilabel" }, #endif #if defined(__FreeBSD__) { MNT_NFS4ACLS, "nfs4acls" }, #endif #if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) \ || defined(__OpenBSD__) || defined(__APPLE__) { MNT_NOATIME, "noatime" }, #endif #if defined(__FreeBSD__) || defined(__DragonFly__) { MNT_NOCLUSTERR, "noclusterr" }, { MNT_NOCLUSTERW, "noclusterw" }, #endif #if defined(__NetBSD__) { MNT_NOCOREDUMP, "nocoredump" }, #endif #if defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) \ || defined(__APPLE__) { MNT_NODEV, "nodev" }, #endif #if defined(__NetBSD__) { MNT_NODEVMTIME, "nodevmtime" }, #endif #if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) \ || defined(__OpenBSD__) || defined(__APPLE__) { MNT_NOEXEC, "noexec" }, { MNT_NOSUID, "nosuid" }, #endif #if defined(__FreeBSD__) { MNT_NOSYMFOLLOW, "nosymfollow" }, #endif #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) \ || defined(__APPLE__) { MNT_QUOTA, "quota" }, #endif #if defined(__NetSBSD__) { MNT_RELATIME, "relatime" }, #endif /* MNT_RDONLY is treated separately in statfs_flags_to_str(). */ #if defined(__APPLE__) { MNT_RELOAD, "reload" }, #endif #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) \ || defined(__APPLE__) { MNT_ROOTFS, "rootfs" }, #endif #if defined(__FreeBSD__) { MNT_SNAPSHOT, "snapshot" }, #endif #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) { MNT_SOFTDEP, "softdep" }, #endif #if defined(__FreeBSD__) || defined(__DragonFly__) { MNT_SUIDDIR, "suiddir" }, #endif #if defined(__NetBSD__) { MNT_SYMPERM, "symperm" }, #endif #if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) \ || defined(__OpenBSD__) || defined(__APPLE__) { MNT_SYNCHRONOUS, "sync" }, #endif #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__) { MNT_UNION, "union" }, #endif #if defined(__APPLE__) { MNT_UPDATE, "update" }, #endif #if defined(__FreeBSD__) { MNT_USER, "user" }, #endif #if defined(__APPLE__) { MNT_UNKNOWNPERMISSIONS, "unknownpermissions" }, #endif }; /* * Turn the f_flags member of the given struct statfs to a human-readable string * of the form "opt1,opt2..." * Returns NULL if an error occurred. * @s: struct statfs * to parse. */ static char * statfs_flags_to_str(const struct fsmntinfo *fs) { int i, n_flags; size_t bufsize = 128; char *buffer = malloc(bufsize); if (!buffer) { (void)fprintf(stderr, _("Could not retrieve mount flags for %s\n"), fs->fsname); return NULL; } buffer[0] = '\0'; /* There is no MNT_RDWRITE flag, so we have to do this. */ if (fs->flags & MNT_RDONLY) { if (strlcat(buffer, "ro", bufsize) >= bufsize) goto truncated; } else { if (strlcat(buffer, "rw", bufsize) >= bufsize) goto truncated; } /* Comparing flags to all possible flags. */ n_flags = sizeof(possible_flags) / sizeof(possible_flags[0]); for (i = 0; i < n_flags; i++) { if (!(fs->flags & possible_flags[i].flag)) continue; if (strlcat(buffer, ",", bufsize) >= bufsize) goto truncated; if (strlcat(buffer, possible_flags[i].str, bufsize) >= bufsize) goto truncated; } return buffer; truncated: (void)fprintf(stderr, _("Truncating mount options for %s\n"), fs->fsname); return buffer; } #endif /* BSD */ dfc-3.1.0/src/platform/services-linux.c000644 001750 000144 00000012307 13072400202 020307 0ustar00robinusers000000 000000 /* * Copyright (c) 2012-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ /* * services-linux.c * * Linux implemention of services. */ #include #include #include #include #if defined(__linux__) || defined(__GLIBC__) #ifdef NLS_ENABLED #include #include #endif /* NLS_ENABLED */ #include #include #include #include "extern.h" #include "services.h" #include "util.h" int is_mnt_ignore(const struct fsmntinfo *fs) { /* if the size is zero, it is most likely a fs that we want to ignore */ if (fs->blocks == 0) return 1; /* treat tmpfs/devtmpfs/... as a special case */ if (fs->fstype && strstr(fs->fstype, "tmpfs")) return 0; return is_pseudofs(fs->fstype); } int is_remote(const struct fsmntinfo *fs) { return is_remotefs(fs->fstype); } void fetch_info(struct list *lst) { struct fsmntinfo *fmi; FILE *mtab; struct mntent *entbuf; struct statvfs vfsbuf; /* init fsmntinfo */ if ((fmi = malloc(sizeof(struct fsmntinfo))) == NULL) { (void)fputs("Error while allocating memory to fmi", stderr); exit(EXIT_FAILURE); /* NOTREACHED */ } *fmi = fmi_init(); /* open mtab file */ if ((mtab = fopen("/etc/mtab", "r")) == NULL) { perror("Error while opening mtab file "); exit(EXIT_FAILURE); /* NOTREACHED */ } /* loop to get infos from all the mounted fs */ while ((entbuf = getmntent(mtab)) != NULL) { /* avoid stating remote fs because they may hang */ if (lflag && is_remotefs(entbuf->mnt_type)) continue; /* get infos from statvfs */ if (statvfs(entbuf->mnt_dir, &vfsbuf) == -1) { /* show only "real" errors, not lack of permissions */ if (errno == EACCES) continue; /* display a warning when a FS cannot be stated */ (void)fprintf(stderr, _("WARNING: %s was skipped " "because it could not be stated"), entbuf->mnt_dir); perror(" "); continue; } /* infos from getmntent */ if (Wflag) { /* Wflag to avoid name truncation */ if ((fmi->fsname = strdup(entbuf->mnt_fsname)) == NULL) fmi->fsname = g_unknown_str; if ((fmi->mntdir = strdup(entbuf->mnt_dir)) == NULL) fmi->mntdir = g_unknown_str; if ((fmi->fstype = strdup(entbuf->mnt_type)) == NULL) fmi->fstype = g_unknown_str; } else { if ((fmi->fsname = strdup(shortenstr( entbuf->mnt_fsname, STRMAXLEN))) == NULL) { fmi->fsname = g_unknown_str; } if ((fmi->mntdir = strdup(shortenstr( entbuf->mnt_dir, STRMAXLEN))) == NULL) { fmi->mntdir = g_unknown_str; } if ((fmi->fstype = strdup(shortenstr( entbuf->mnt_type, STRMAXLEN))) == NULL) { fmi->fstype = g_unknown_str; } } if ((fmi->mntopts = strdup(entbuf->mnt_opts)) == NULL) fmi->mntopts = g_none_str; /* infos from statvfs */ fmi->bsize = vfsbuf.f_bsize; fmi->frsize = vfsbuf.f_frsize; fmi->blocks = vfsbuf.f_blocks; fmi->bfree = vfsbuf.f_bfree; fmi->bavail = vfsbuf.f_bavail; fmi->files = vfsbuf.f_files; fmi->ffree = vfsbuf.f_ffree; fmi->favail = vfsbuf.f_favail; /* compute, available, % used, etc. */ compute_fs_stats(fmi); /* pointer to the next element */ fmi->next = NULL; /* enqueue the element into the queue */ enqueue(lst, *fmi); update_maxwidth(fmi); } /* we need to close the mtab file now */ if (fclose(mtab) == EOF) perror("Could not close mtab file "); free(fmi); } void compute_fs_stats(struct fsmntinfo *fmi) { fmi->total = (double)fmi->frsize * (double)fmi->blocks; fmi->avail = (double)fmi->frsize * (double)fmi->bavail; fmi->used = (double)fmi->frsize * ((double)fmi->blocks - (double)fmi->bfree); if ((int)fmi->total == 0) fmi->perctused = 100.0; else fmi->perctused = 100.0 - ((double)fmi->bavail / (double)fmi->blocks) * 100.0; } #endif /* __linux__ */ dfc-3.1.0/src/platform/services-solaris.c000644 001750 000144 00000011765 13072400202 020633 0ustar00robinusers000000 000000 /* * Copyright (c) 2016-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ /* * services-solaris.c * * Solaris implemention of services. */ #ifdef __sun #include #include #include #include #ifdef NLS_ENABLED #include #include #endif /* NLS_ENABLED */ #include #include #include "extern.h" #include "services.h" #include "util.h" int is_mnt_ignore(const struct fsmntinfo *fs) { /* if the size is zero, it is most likely a fs that we want to ignore */ if (fs->blocks == 0) return 1; /* treat tmpfs/devtmpfs/... as a special case */ if (fs->fstype && strstr(fs->fstype, "tmpfs")) return 0; /* libc is dynamically mounted into /lib, treat it as a special case */ if (fs->mntdir && (strncmp(fs->mntdir, "/lib/", 5) == 0)) return 1; return is_pseudofs(fs->fstype); } int is_remote(const struct fsmntinfo *fs) { return is_remotefs(fs->fstype); } void fetch_info(struct list *lst) { struct fsmntinfo *fmi; FILE *mnttab; struct mnttab mnttabbuf; struct statvfs vfsbuf; int ret; /* init fsmntinfo */ if ((fmi = malloc(sizeof(struct fsmntinfo))) == NULL) { (void)fputs("Error while allocating memory to fmi", stderr); exit(EXIT_FAILURE); /* NOTREACHED */ } *fmi = fmi_init(); /* open mnttab file */ if ((mnttab = fopen("/etc/mnttab", "r")) == NULL) { perror("Error while opening mnttab file "); exit(EXIT_FAILURE); /* NOTREACHED */ } /* loop to get infos from all the mounted fs */ while ((ret = getmntent(mnttab, &mnttabbuf)) == 0) { if (statvfs(mnttabbuf.mnt_mountp, &vfsbuf) == -1) { (void)fprintf(stderr, _("WARNING: %s was skipped " "because it could not be stated"), mnttabbuf.mnt_mountp); perror(" "); continue; } if (Wflag) { /* Wflag to avoid name truncation */ if ((fmi->fsname = strdup(mnttabbuf.mnt_special)) == NULL) fmi->fsname = g_unknown_str; if ((fmi->mntdir = strdup(mnttabbuf.mnt_mountp))== NULL) fmi->mntdir = g_unknown_str; if ((fmi->fstype = strdup(mnttabbuf.mnt_fstype)) == NULL) fmi->fstype = g_unknown_str; } else { if ((fmi->fsname = strdup(shortenstr( mnttabbuf.mnt_special, STRMAXLEN))) == NULL) { fmi->fsname = g_unknown_str; } if ((fmi->mntdir = strdup(shortenstr (mnttabbuf.mnt_mountp, STRMAXLEN))) == NULL) { fmi->mntdir = g_unknown_str; } if ((fmi->fstype = strdup(shortenstr( mnttabbuf.mnt_fstype, STRMAXLEN))) == NULL) { fmi->fstype = g_unknown_str; } } if ((fmi->mntopts = strdup(mnttabbuf.mnt_mntopts)) == NULL) fmi->mntopts = g_none_str; fmi->bsize = vfsbuf.f_bsize; fmi->frsize = vfsbuf.f_frsize; fmi->blocks = vfsbuf.f_blocks; fmi->bfree = vfsbuf.f_bfree; fmi->bavail = vfsbuf.f_bavail; fmi->files = vfsbuf.f_files; fmi->ffree = vfsbuf.f_ffree; fmi->favail = vfsbuf.f_favail; compute_fs_stats(fmi); fmi->next = NULL; enqueue(lst, *fmi); update_maxwidth(fmi); } if (ret > 0) { (void)fprintf(stderr, "An error occured while reading the " "mnttab file\n"); } /* we need to close the mnttab file now */ if (fclose(mnttab) == EOF) perror("Could not close mnttab file "); free(fmi); } void compute_fs_stats(struct fsmntinfo *fmi) { fmi->total = (double)fmi->frsize * (double)fmi->blocks; fmi->avail = (double)fmi->frsize * (double)fmi->bavail; fmi->used = (double)fmi->frsize * ((double)fmi->blocks - (double)fmi->bfree); if ((int)fmi->total == 0) fmi->perctused = 100.0; else fmi->perctused = 100.0 - ((double)fmi->bavail / (double)fmi->blocks) * 100.0; } #endif /* __sun */ dfc-3.1.0/src/platform/services.h000644 001750 000144 00000004370 13072400202 017160 0ustar00robinusers000000 000000 /* * Copyright (c) 2012-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ #ifndef H_SERVICES #define H_SERVICES /* * services.h * * Generic interface for platform-dependent services. */ #include "list.h" #define STRMAXLEN 24 /* * Return 1 if the current fs should usually be ignored, 0 otherwise. * On error, -1 is returned. */ int is_mnt_ignore(const struct fsmntinfo *fs); /* * Determine if the fs in remote or local. * Return 1 if remote, 0 otherwise. */ int is_remote(const struct fsmntinfo *fs); /* * fetch information from getmntent and statvfs and store it into the queue * @lst: queue in which to store information */ void fetch_info(struct list *lst); /* * compute file systems statistics */ void compute_fs_stats(struct fsmntinfo *fmi); #endif /* ndef H_SERVICES */ dfc-3.1.0/src/util.c000644 001750 000144 00000042531 13072400202 014462 0ustar00robinusers000000 000000 /* * Copyright (c) 2012-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ /* * util.c * * Various util functions */ #include #include #include #include #include #include #include #include #if defined(__sun) #include /* on solaris, this is where struct winsize is declared */ #endif /* __sun */ #include "util.h" #ifdef NLS_ENABLED #include #endif /* static functions declaration */ static int typecmp(const void *e1, const void *e2); /* * Return the number of digits in `n` * @n: a positive integer. */ static int count_digit(unsigned long long n) { int i = 0; do { ++i; n /= 10; } while (n != 0); return i; } /* * Return the longest of the two parameters * @a: first element to compare * @b: second element to compare */ int imax(int a, int b) { return (a > b ? a : b); } /* * trim withespaces from the input string and returns it * @str: string that needs to be trimmed */ char * strtrim(char *str) { char *end; if (!str) return NULL; while (isspace(*str)) str++; if (*str == '\0') return str; end = str + strlen(str) - 1; while (end > str && isspace(*end)) end--; *(end + 1) = '\0'; return str; } /* * Shorten the input string to the specified length * @str: string to shorten * @len: the length the new string should be */ char * shortenstr(char *str, int len) { int slen = (int)strlen(str); if (slen < len + 1) return str; str += (slen - len); str[0] = '+'; return str; } /* * Given a string S, returns the same string where the '_' character is replaced * by "\_". The returned string must be freed by the caller. * Return NULL if it fails. */ char * sanitizestr(const char *str) { int i = 0; int j = 0; size_t nchars = 1; /* Trailing \0 */ char *new; for (i = 0; str[i] != '\0'; i++) { if (str[i] == '_') nchars += 2; else nchars++; } if (i == (int)nchars) /* No '_' was found. */ return strdup(str); if ((new = malloc(nchars)) == NULL) return NULL; for (i = 0; str[i] != '\0'; i++) { if (str[i] == '_') { new[j] = '\\'; new[j+1] = '_'; j += 2; } else { new[j] = str[i]; j++; } } new[nchars-1] = '\0'; return new; } /* * convert to human readable format and return the information i to format * correctly the output. * @n: address of the number to convert */ int humanize(double *n) { int i = 0; double divider = 1024.0; /* when using SI units... */ if (mflag) divider = 1000.0; while ((*n >= 1000) && (i < 8)) { *n /= divider; i++; } return i; } /* * convert to human readable format and return the information i to format * correctly the output. This one is intended to convert inodes to h-r * @n: address of the number to convert */ int humanize_i(uint64_t *n) { int i = 0; while ((*n >= 10000) && (i < 8)) { *n /= 1000; i++; } return i; } /* * Print a letter according to the desired unit * @i: should be the result of the humanize or humanize_i function when humanize * is used * @mode: either 0 or 1. 1 mode should be used when called to print filesystem * unit and 0 should be used when wanting to display "inodes unit" */ void print_unit(int i, int mode) { switch (unitflag) { case 'h': switch (i) { case 0: /* bytes */ if (mode) (void)printf("B"); else (void)printf(" "); return; case 1: /* Kio or Ko */ (void)printf("K"); return; case 2: /* Mio or Mo */ (void)printf("M"); return; case 3: /* Gio or Go*/ (void)printf("G"); return; case 4: /* Tio or To*/ (void)printf("T"); return; case 5: /* Pio or Po*/ (void)printf("P"); return; case 6: /* Eio or Eo*/ (void)printf("E"); return; case 7: /* Zio or Zo*/ (void)printf("Z"); return; case 8: /* Yio or Yo*/ (void)printf("Y"); return; default: (void)fputs("Could not print unit type in" " human-readable format\n", stderr); } case 'b': if (mode) (void)printf("B"); else (void)printf(" "); return; case 'k': (void)printf("K"); return; case 'm': (void)printf("M"); return; case 'g': (void)printf("G"); return; case 't': (void)printf("T"); return; case 'p': (void)printf("P"); return; case 'e': (void)printf("E"); return; case 'z': (void)printf("Z"); return; case 'y': (void)printf("Y"); return; default: (void)fputs("Could not print unit type\n", stderr); } } /* * Converts the argument to the correct unit * TODO: pretty crapy function... should do it in a smart way! * Plus there probably is some roundings errors... * Need to clean this crap ASAP * @n: number to convert */ double cvrt(double n) { switch (unitflag) { case 'b': return n; case 'e': if (mflag) /* 1000^6 */ return n / 1000000000000000000.0; else /* 1024^6 */ return n / 1152921504606846976.0; case 'g': if (mflag) /* 1000^3 */ return n / 1000000000.0; else /* 1024^3 */ return n / 1073741824.0; case 'k': if (mflag) return n / 1000.0; else return n / 1024.0; case 'm': if (mflag) /* 1000^2 */ return n / 1000000.0; else /* 1024^2 */ return n / 1048576.0; case 'p': if (mflag) /* 1000^5 */ return n / 1000000000000000.0; else /* 1024^5 */ return n / 1125899906842624.0; case 't': if (mflag) /* 1000^4 */ return n / 1000000000000.0; else /* 1024^4 */ return n / 1099511627776.0; case 'y': if (mflag) /* 1000^8 */ return n / 1000000000000000000000000.0; else /* 1024^8 */ return n / 1208925819614629174706176.0; case 'z': if (mflag) /* 1000^7 */ return n / 1000000000000000000000.0; else /* 1024^7 */ return n / 1180591620717411303424.0; default: (void)fputs("Could not convert unit size\n", stderr); return n; } } /* * Return: * 1 if the given fs should be showed * 0 if the given fs should be skipped * @fs: fs type or name to check * @filter: filter string * @nm: boolean indicating if the negative matching is activated */ int fsfilter(const char *fs, const char *filter, int nm) { int ret = 0; /* assume it should not be shown */ char *stropt; char *strtmp; if ((strtmp = strdup(filter)) == NULL) { (void)fputs("Cannot duplicate filter\n", stderr); exit(EXIT_FAILURE); /* NOTREACHED */ } stropt = strtok(strtmp, ","); while (stropt != NULL) { if (strncmp(fs, stropt, strlen(stropt)) == 0) { ret = 1; break; } stropt = strtok(NULL, ","); } free(strtmp); /* reverse result if negative matching activated */ return nm ? !ret : ret; } /* * Compares regarding qflag * @a: first element of comparison * @b: second element of comparison */ int cmp(struct fsmntinfo *a, struct fsmntinfo *b) { switch(qflag) { case 1: return strcmp(a->fsname, b->fsname); case 2: return strcmp(a->fstype, b->fstype); case 3: return strcmp(a->mntdir, b->mntdir); default: return -1; } } /* * Perform a mergesort algorithm to sort the list by ascending * Results depends on what was chosen for comparison (fsname, fstype or mntdir) * @fmi: pointer to the first element of the linked list structure to be sorted */ struct fsmntinfo * msort(struct fsmntinfo *fmi) { struct fsmntinfo *tail, *left, *right, *next; int nmerges, lsize, rsize; int size = 1; /* * trivial case: list is sorted if there is no or only one element in * the linked list */ if (fmi == NULL || fmi->next == NULL) return fmi; do { nmerges = 0; left = fmi; tail = fmi = NULL; while (left) { nmerges++; right = left; lsize = 0; rsize = size; while (right && lsize < size) { lsize++; right = right->next; } while (lsize > 0 || (rsize > 0 && right)) { if (!lsize) { next = right; right = right->next; rsize--; } else if (!rsize || !right) { next = left; left = left->next; lsize--; } else if (cmp(left, right) <= 0) { next = left; left = left->next; lsize--; } else { next = right; right = right->next; rsize--; } if (tail) tail->next = next; else fmi = next; tail = next; } left = right; } tail->next = NULL; size *= 2; } while (nmerges > 1); return fmi; } /* * Get the with of TTY and retun it. * 0 is returned if stdout is not a tty. */ int getttywidth(void) { int width = 0; struct winsize win; if (!isatty(STDOUT_FILENO)) return 0; if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == 0) width = win.ws_col; return width == 0 ? 80 : width; } /* * init a maxwidths structure */ void init_maxwidths(void) { /* * init min width to header names and width of the graph bar + 1 to have * a space between each column. */ max.fsname = (int)strlen(_("FILESYSTEM")) + 1; max.fstype = Tflag ? (int)strlen(_("TYPE")) + 1 : 0; max.bar = bflag ? 0 : wflag ? GRAPHBAR_WIDE : GRAPHBAR_SHORT; max.perctused = (int)strlen(_("%USED")) + 1; max.used = dflag ? (int)strlen(_("USED")) + 1 : 0; max.avail = (int)strlen(_("AVAILABLE")) + 1; max.total = (int)strlen(_("TOTAL")) + 1; max.nbinodes = iflag ? (int)strlen(_("#INODES")) + 1 : 0; max.avinodes = iflag ? (int)strlen(_("AV.INODES")) + 1 : 0; max.mntdir = Mflag ? 0 : (int)strlen(_("MOUNTED ON")) + 1; max.mntopts = oflag ? (int)strlen(_("MOUNT OPTIONS")) + 1: 0; } /* * Return the required width necessary for the number to be displayed. * This functions takes into account the unit used (b, k, m, g, ...). * @fs_size: file system size from which the required width for displaying * should be computed. */ int get_req_width(double fs_size) { long i, index; int req_width, req_min; const char *unitstring = "bkmgtpezy"; char *match; /* spaces for the unit symbol and floating point */ req_min = 4; req_width = req_min; if (unitflag == 'h') { req_width += 3; } else { if ((match = strchr(unitstring, unitflag)) == NULL) { (void)fputs(_("Cannot compute required width\n"), stderr); return -1; } if ((fs_size > 0.0) && isnormal(fs_size)) { /* * casting from double to int shall be safe here since * log10 of even the largest possible double value (ie: * around 309 in most cases) shall fit into an integer */ req_width += (int)(1.0 + trunc(log10(fs_size))); } index = match - unitstring + 1; for (i = 1; i < index; i++) { /* * displaying the same number in a "greater" unit (cf * unitstring) requires 3 digits less than what was * previously required */ req_width -= 3; } } return (req_width < req_min) ? req_min : req_width; } /* * Update values of the maxwidth structure. * @fmi: structure containing filesystem information */ void update_maxwidth(struct fsmntinfo *fmi) { if (!aflag && (is_mnt_ignore(fmi) == 1)) return; /* + 1 for a space between each column */ max.fsname = imax((int)strlen(fmi->fsname) + 1, max.fsname); max.fstype = imax((int)strlen(fmi->fstype) + 1, max.fstype); if (!Mflag) max.mntdir = imax((int)strlen(fmi->mntdir) + 1, max.mntdir); if (oflag) max.mntopts = imax((int)strlen(fmi->mntopts) + 1, max.mntopts); if (dflag) max.used = imax(get_req_width(fmi->used), max.used); max.avail = imax(get_req_width(fmi->avail), max.avail); max.total = imax(get_req_width(fmi->total), max.total); if (iflag) { max.nbinodes = imax(2 + count_digit(fmi->files), max.nbinodes); max.avinodes = imax(3 + count_digit(fmi->ffree), max.avinodes); } } /* * auto-adjust options based on the size needed to display the information * @lst: list containing info * @tty_width: width of the output terminal */ void auto_adjust(int tty_width) { int req_width; req_width = max.fsname + max.fstype + max.bar + max.perctused + max.used + max.avail + max.total + max.nbinodes + max.avinodes + max.mntdir + max.mntopts; if (tty_width > req_width) return; /* nothing to adjust */ (void)fputs(_("WARNING: TTY too narrow. Some options have been disabled" " to make dfc output fit (use -f to override).\n"), stderr); if (!bflag) { if (wflag) { wflag = 0; req_width -= GRAPHBAR_WIDE - GRAPHBAR_SHORT; if (tty_width >= req_width) return; } bflag = 1; req_width -= GRAPHBAR_SHORT; if (tty_width >= req_width) return; } if (dflag) { dflag = 0; req_width -= max.used; if (tty_width >= req_width) return; } if (Tflag) { Tflag = 0; req_width -= max.fstype; if (tty_width >= req_width) return; } if (!Mflag) { Mflag = 1; req_width -= max.mntdir; if (tty_width >= req_width) return; } if (iflag) { iflag = 0; req_width -= max.nbinodes; req_width -= max.avinodes; if (tty_width >= req_width) return; } if (oflag) { oflag = 0; req_width -= max.mntopts; if (tty_width >= req_width) return; } (void)fputs(_("WARNING: Output still messed up. Enlarge your " "terminal if you can...\n"), stderr); } /* * return the current date as of date(1) format * NULL is returned in case of errors */ char * fetchdate(void) { char date[255]; time_t t; struct tm *tmp; if ((t = time(NULL)) == -1) { perror("time"); return NULL; } if ((tmp = localtime(&t)) == NULL) { perror("localtime"); return NULL; } if (strftime(date, sizeof(date), "%c", tmp) == 0) { (void)fputs("Could not retrieve date\n", stderr); return NULL; } return strdup(date); } /* * Return the name of the given color or NULL * @color: color as defined in extern.h */ const char * colortostr(int color) { switch (color) { case BLACK: return "black"; case RED: return "red"; case GREEN: return "green"; case YELLOW: return "yellow"; case BLUE: return "blue"; case MAGENTA: return "magenta"; case CYAN: return "cyan"; case WHITE: return "white"; default: return NULL; } } /* * convert color from natural name into correponding number and return it * @col: color name */ int colortoint(const char *col) { if (strcoll(col, "black") == 0) return BLACK; else if (strcoll(col, "red") == 0) return RED; else if (strcoll(col, "green") == 0) return GREEN; else if (strcoll(col, "yellow") == 0) return YELLOW; else if (strcoll(col, "blue") == 0) return BLUE; else if (strcoll(col, "magenta") == 0) return MAGENTA; else if (strcoll(col, "cyan") == 0) return CYAN; else if (strcoll(col, "white") == 0) return WHITE; else return -1; } /* * check if the input string is a valid html color code. * ie: it should be an hexadecimal value * Returns 0 if all went well, otherwise it returns -1 * @color: input color * NOTE: color should omit the #: white is FFFFFF and not #FFFFFF */ int chk_html_colorcode(const char *color) { int i; if (strlen(color) != HTMLCOLORCODELENGTH) return -1; for (i = 0; i < HTMLCOLORCODELENGTH; i++) if (isxdigit(color[i]) == 0) return -1; return 0; } /* * Comparison function needed for is_pseudofs and is_remotefs bsearch call. */ static int typecmp(const void *e1, const void *e2) { const char *s1 = *(const char * const *)e1; const char *s2 = *(const char * const *)e2; return strcmp(s1, s2); } /* * Determine if fsname is a pseudo filesystem or not. * This function is useless under *BSD and OSX systems. * Return 1 if it is, 0 otherwise. */ int is_pseudofs(const char *type) { /* keep sorted for binary search */ static const char *pseudofs[] = { "anon_inodefs", "autofs", "bdev", "binfmt_misc", "cgroup", "configfs", "cpuset", "debugfs", "devfs", "devpts", "devtmpfs", "dlmfs", "fdescfs", "fuse.gvfs-fuse-daemon", "fusectl", "hugetlbfs", "linprocfs", "mqueue", "nfsd", "none", "pipefs", "proc", "pstore", "ramfs", "rootfs", "rpc_pipefs", "securityfs", "sockfs", "spufs", "sysfs", "tmpfs" }; if (!type) return 0; if (bsearch(&type, pseudofs, sizeof(pseudofs) / sizeof(pseudofs[0]), sizeof(*pseudofs), typecmp) == NULL) { return 0; } return 1; } int is_remotefs(const char *type) { /* keep sorted for binary search */ static const char *remotefs[] = { "afs", "cifs", "coda", "ftpfs", "fuse.sshfs", "mfs", "ncpfs", "nfs", "nfs4", "smbfs", "sshfs" }; if (!type) return 0; if (bsearch(&type, remotefs, sizeof(remotefs) / sizeof(remotefs[0]), sizeof(*remotefs), typecmp) == NULL) { return 0; } return 1; } dfc-3.1.0/src/util.h000644 001750 000144 00000004770 13072400202 014472 0ustar00robinusers000000 000000 /* * Copyright (c) 2012-2017, Robin Hahling * 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 the author 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 HOLDER 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. */ #ifndef H_UTIL #define H_UTIL /* * util.h * * Util functions */ #include #include "extern.h" #include "list.h" #include "platform/services.h" /* function declaration */ int imax(int a, int b); char * strtrim(char *str); char * shortenstr(char *str, int len); char * sanitizestr(const char *str); int humanize(double *n); int humanize_i(uint64_t *n); void print_unit(int i, int mode); double cvrt(double n); int fsfilter(const char *fs, const char *filter, int nm); int cmp(struct fsmntinfo *a, struct fsmntinfo *b); struct fsmntinfo * msort(struct fsmntinfo *fmi); int getttywidth(void); void init_maxwidths(void); int get_req_width(double fs_size); void update_maxwidth(struct fsmntinfo *fmi); void auto_adjust(int tty_width); char * fetchdate(void); const char * colortostr(int color); int colortoint(const char *col); int chk_html_colorcode(const char *color); int is_pseudofs(const char *type); int is_remotefs(const char *type); #endif /* ndef UTIL_H */
"); (void)printf(_("Generated by %s-%s on %s"), PACKAGE, VERSION, date); (void)puts("
%s%sUSAGE%s%s%s%s%s%s%s%s
SUMN/AN/AN/A"); if (wflag) barwidth *= 2; if (!cflag) { (void)printf("\t \n", (int)perct*barwidth/100, barheight); } else { /* color */ size = (perct < cnf.gmedium) ? (int)perct : cnf.gmedium; (void)printf("\t \n", size * barwidth / 100, barheight, cnf.hclow); if (perct >= cnf.gmedium) { size = (perct < cnf.ghigh) ? (int)perct : cnf.ghigh; size -= cnf.gmedium; (void)printf("\t \n", size * barwidth / 100, barheight, cnf.hcmedium); } if (perct >= cnf.ghigh) { size = (int)perct - cnf.ghigh; (void)printf("\t \n", size * barwidth / 100, barheight, cnf.hchigh); } } (void)puts("\t "); if (unitflag == 'h') { i = humanize(&n); (void)printf(i == 0 ? "%.f" : "%.1f", n); print_unit(i, 1); } else { if (unitflag == 'b' || unitflag == 'k') (void)printf("%.f", n); else (void)printf("%.1f", n); } (void)puts("
%s%s%" PRIu64, files); print_unit(i, 0); (void)printf("%" PRIu64, favail); print_unit(i, 0); (void)printf("%" PRIu64 "%" PRIu64 "%s%s%.f%%