dfc-3.0.5/HACKING000644 001751 001751 00000001462 12414102152 013523 0ustar00robinrobin000000 000000 Patches are welcome! Just keep in mind the following: * keep the same coding style * use c89 (the only exception being for using uint64_t type) * 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's returned, explicitly declare it by casting it to void. * preferably use 'git format patch' to generate your patch * your patch must improve dfc in one way or another If this is OK, you can send your patch via email to the author: Robin Hahling: OR, better solution, register to the official website: http://projects.gw-computing.net/projects/dfc and add an issue with your patch attached. Thanks for making dfc better! dfc-3.0.5/CHANGELOG000644 001751 001751 00000014207 12414103405 013751 0ustar00robinrobin000000 000000 # CHANGELOG ## 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.0.5/conf/dfcrc000644 001751 001751 00000002717 12414102152 014471 0ustar00robinrobin000000 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 # 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 # vim: set noet syn=conf dfc-3.0.5/conf/fr/dfcrc000644 001751 001751 00000003610 12414102152 015071 0ustar00robinrobin000000 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: # - noir # - rouge # - vert # - jaune # - bleu # - magenta # - cyan # - blanc # Note: cela concerne uniquement les couleurs en premier-plan # Couleur de l'entête color_header = bleu # Couleur lorsque le taux d'utilisation est faible color_low = vert # Couleur lorsque le taux d'utilisation est moyen color_medium = jaune # Couleur lorsque le taux d'utilisation est élevé color_high = rouge # 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 # vim: set noet syn=conf dfc-3.0.5/CMakeLists.txt000644 001751 001751 00000013275 12414104517 015310 0ustar00robinrobin000000 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 0) set(VERSION_PATCH 5) set(VERSION_BRANCH "") set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_BRANCH}) # 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) # 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) option(GRIM "Very strict compiler options (use it to debug dfc)" off) if(GRIM) set(CMAKE_BUILD_TYPE GRIM CACHE STRING "Very strict compiler options") 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) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -pedantic -Wall -Wextra -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") 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() else() set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "Build optimized for release") endif() configure_file( ${SOURCE_DIR}/extern.h.in ${SOURCE_DIR}/extern.h ) set(EXECUTABLE_NAME ${CMAKE_PROJECT_NAME}) SET(SRCS ${SOURCE_DIR}/csv.c ${SOURCE_DIR}/dotfile.c ${SOURCE_DIR}/dfc.c ${SOURCE_DIR}/html.c ${SOURCE_DIR}/list.c ${SOURCE_DIR}/tex.c ${SOURCE_DIR}/text.c ${SOURCE_DIR}/util.c ) add_executable( ${EXECUTABLE_NAME} ${SRCS} ) # CFLAGS (using c99 only for long long, all the rest should be c89 compliant) add_definitions(-O2 -std=c99) if(LFS_ENABLED) add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64) endif() if(NLS_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() set(DFC_DOC_FILES AUTHORS CHANGELOG HACKING LICENSE README TRANSLATORS ) 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$" "${PROJECT_SOURCE_DIR}/src/extern.h$" "${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.0.5/TRANSLATORS000644 001751 001751 00000006220 12414102152 014270 0ustar00robinrobin000000 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 string 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, ckeck your translation. ## 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.0.5/cmake/modules/GettextTranslate.cmake000644 001751 001751 00000022647 12403353270 021607 0ustar00robinrobin000000 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.0.5/cmake/modules/COPYING-CMAKE-SCRIPTS000644 001751 001751 00000002457 12403353270 020276 0ustar00robinrobin000000 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.0.5/cmake/modules/FindLibintl.cmake000644 001751 001751 00000002453 12403353270 020474 0ustar00robinrobin000000 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.0.5/cmake/cmake_uninstall.cmake.in000644 001751 001751 00000001765 12403353270 020411 0ustar00robinrobin000000 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.0.5/AUTHORS000644 001751 001751 00000000654 12414102152 013606 0ustar00robinrobin000000 000000 ## AUTHOR: * Robin Hahling ## CONTRIBUTORS: * Baptiste Daroussin * Cyril Roelandt * Frank Villaro-Dixon * Kevin Gillieron * Landry Breuil * Matthieu Le Jeune * Sylvain Laperche ## TRANSLATORS: French: * Robin Hahling Swedish: * Andreas Rönnquist dfc-3.0.5/po/fr.po000644 001751 001751 00000021563 12414103564 014135 0ustar00robinrobin000000 000000 # French translations for dfc package. # Copyright (C) 2012-2014 THE dfc'S COPYRIGHT HOLDER # This file is distributed under the same license as the dfc package. # Robin Hahling , 2012-2014. # msgid "" msgstr "" "Project-Id-Version: dfc 3.0.5\n" "Report-Msgid-Bugs-To: robin.hahling@gw-computing.net\n" "POT-Creation-Date: 2014-10-05 01:49+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/csv.c:95 #, c-format msgid "FILESYSTEM," msgstr "SYSTÈME DE FICHIERS," #: src/csv.c:98 #, c-format msgid "TYPE," msgstr "TYPE," #: src/csv.c:100 #, c-format msgid "%%USED," msgstr "%%UTILISÉ," #: src/csv.c:103 #, c-format msgid "USED," msgstr "UTILISÉ," #: src/csv.c:105 #, c-format msgid "AVAILABLE," msgstr "DISPONIBLE," #: src/csv.c:107 #, c-format msgid "TOTAL," msgstr "TOTAL," #: src/csv.c:110 #, c-format msgid "#INODES," msgstr "#INODES," #: src/csv.c:111 src/html.c:168 src/tex.c:158 #, c-format msgid "AV.INODES," msgstr "INODES DISP.," #: src/csv.c:114 src/html.c:171 src/tex.c:160 msgid "MOUNTED ON" msgstr "MONTÉ SUR" #: src/csv.c:117 #, c-format msgid ",MOUNT OPTIONS" msgstr ",OPTIONS DE MONTAGE" #: src/csv.c:144 #, c-format msgid "SUM:," msgstr "SOMME:," #: src/dfc.c:203 #, c-format msgid "-c: illegal sub option %s\n" msgstr "-c: sous-option illégale %s\n" #: src/dfc.c:236 #, c-format msgid "-e: illegal sub option %s\n" msgstr "-e: sous-option illégale %s\n" #: src/dfc.c:284 #, c-format msgid "-q: illegal sub option %s\n" msgstr "-q: sous-option illégale %s\n" #: src/dfc.c:344 #, c-format msgid "-u: illegal sub option %s\n" msgstr "-u: sous-option illégale %s\n" #: src/dfc.c:386 #, c-format msgid "Error reading the configuration file: %s\n" msgstr "Erreur pendant la lecture du fichier de configuration: %s\n" #: src/dfc.c:421 msgid "Try dfc -h for more information\n" msgstr "Essayez dfc -h pour plus d'informations\n" #: src/dfc.c:424 msgid "" "Usage: dfc [OPTION(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 "" "Utilisation: dfc [OPTION(S)] [-c WHEN] [-e FORMAT] [-p FSNAME] [-q SORTBY] " "[-t FSTYPE]\n" "\t[-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\n" "\t\tpour les détails\n" "\t-d\taffiche la taille de l'utilisation\n" "\t-e\texporte dans le format spécifié. Lisez le manuel\n" "\t\tpour 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\n" "\t\tlocalement uniquement\n" #: src/dfc.c:442 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\tutilise les unités métriques (unités SI)\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\n" "\t\tpour les détails\n" "\t-q\ttrie l'affichage. Lisez le manuel\n" "\t\tpour les détails.\n" "\t-s\tsomme l'utilisation totale\n" "\t-t\tfiltre par type de système de fichiers. Lisez le manuel\n" "\t\tpour les détails\n" "\t-T\taffiche le type de système de fichiers\n" "\t-u\tpermet de choisir l'unité dans laquelle\n" "\t\tles valeurs sont affichées. Lisez le manuel\n" "\t\tpour 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/dfc.c:508 #, 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" #: src/dfc.c:947 #, 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/dfc.c:983 #, c-format msgid "Truncating mount options for %s\n" msgstr "Troncation des options de montage pour %s\n" #: src/dotfile.c:151 #, 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:216 src/dotfile.c:236 #, 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:221 #, 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:224 #, 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:241 #, 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:244 #, 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:254 #, c-format msgid "Wrong symbol value: %s\n" msgstr "Symbole impossible: %s\n" #: src/dotfile.c:350 #, 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:359 #, c-format msgid "Unknown color value: %s\n" msgstr "Couleur inconnue: %s\n" #: src/dotfile.c:364 #, c-format msgid "Not a valid HTML color: %s\n" msgstr "Couleur HTML invalide: %s\n" #: src/html.c:147 msgid "Unknown date" msgstr "Date inconnue" #: src/html.c:150 #, c-format msgid "Generated by %s-%s on %s" msgstr "Généré par %s-%s le %s" #: src/html.c:153 src/tex.c:146 msgid "FILESYSTEM" msgstr "SYSTÈME DE FICHIERS" #: src/html.c:156 src/tex.c:148 msgid "TYPE" msgstr "TYPE" #: src/html.c:160 src/text.c:126 msgid "%USED" msgstr "%UTILISÉ" #: src/html.c:162 src/tex.c:153 src/text.c:135 msgid "USED" msgstr " UT." #: src/html.c:163 src/tex.c:154 src/text.c:145 msgid "AVAILABLE" msgstr " DISPO." #: src/html.c:164 src/tex.c:155 src/text.c:155 msgid "TOTAL" msgstr "TOTAL" #: src/html.c:167 msgid "#INODES" msgstr "#INODES" #: src/html.c:174 src/tex.c:162 msgid "MOUNT OPTIONS" msgstr "OPTIONS DE MONTAGE" #: src/tex.c:150 msgid "USAGE" msgstr "UTILISATION" #: src/tex.c:151 msgid "\\%USED" msgstr "\\%UTILISÉ" #: src/tex.c:157 msgid "\\#INODES" msgstr "\\#INODES" #: src/text.c:102 msgid "FILESYSTEM " msgstr "SYS. FICH. " #: src/text.c:107 msgid " TYPE" msgstr " TYPE" #: src/text.c:120 msgid " (=) USED" msgstr " (=) UT." #: src/text.c:123 msgid "FREE (-) " msgstr "LIB. (-) " #: src/text.c:158 msgid " #INODES" msgstr " #INODES" #: src/text.c:159 msgid " AV.INODES" msgstr " INODES D." #: src/text.c:162 msgid " MOUNTED ON " msgstr " MONTÉ SUR " #: src/text.c:167 msgid "MOUNT OPTIONS\n" msgstr " OPT. DE MONT.\n" #: src/text.c:198 msgid "SUM:" msgstr "SOM:" #: src/util.c:644 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:697 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/util.c:840 msgid "black" msgstr "noir" #: src/util.c:843 msgid "red" msgstr "rouge" #: src/util.c:846 msgid "green" msgstr "vert" #: src/util.c:849 msgid "yellow" msgstr "jaune" #: src/util.c:852 msgid "blue" msgstr "bleu" #: src/util.c:855 msgid "magenta" msgstr "magenta" #: src/util.c:858 msgid "cyan" msgstr "cyan" #: src/util.c:861 msgid "white" msgstr "blanc" dfc-3.0.5/po/POTFILES.in000644 001751 001751 00000000115 12414102152 014721 0ustar00robinrobin000000 000000 src/csv.c src/dfc.c src/dotfile.c src/html.c src/tex.c src/text.c src/util.c dfc-3.0.5/po/CMakeLists.txt000644 001751 001751 00000000023 12403353270 015711 0ustar00robinrobin000000 000000 GettextTranslate() dfc-3.0.5/po/Makevars000644 001751 001751 00000000343 12403353270 014652 0ustar00robinrobin000000 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.0.5/po/LINGUAS000644 001751 001751 00000000003 12403353270 014174 0ustar00robinrobin000000 000000 fr dfc-3.0.5/po/sv.po000644 001751 001751 00000022164 12414103440 014145 0ustar00robinrobin000000 000000 # Swedish translations for dfc package # Svenska översättningar för paket dfc. # Copyright (C) 2012-2014 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.5\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.0.5/src/csv.c000644 001751 001751 00000015634 12414102675 014302 0ustar00robinrobin000000 000000 /* * Copyright (c) 2012-2014, 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 #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(struct list *lst); static void csv_disp_sum(struct list *lst, double stot, double utot, double ftot, double ifitot, double ifatot); static void csv_disp_bar(double perct); static void csv_disp_at(double n, double perct); static void csv_disp_fs(struct list *lst, char *fsname); static void csv_disp_type(struct list *lst, char *type); static void csv_disp_inodes(uint64_t files, uint64_t favail); static void csv_disp_mount(char *dir); static void csv_disp_mopt(struct list *lst, char *dir, char *opts); static void csv_disp_perct(double perct); /* 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_at = csv_disp_at; 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; } /* * Display header * @lst: queue containing the informations */ static void csv_disp_header(struct list *lst) { /* do not care about lst in CSV output */ (void)lst; (void)printf(_("FILESYSTEM,")); if (Tflag) (void)printf(_("TYPE,")); (void)printf(_("%%USED,")); if (dflag) (void)printf(_("USED,")); (void)printf(_("AVAILABLE,")); (void)printf(_("TOTAL,")); if (iflag) { (void)printf(_("#INODES,")); (void)printf(_("AV.INODES,")); } (void)printf("%s", _("MOUNTED ON")); if (oflag) (void)printf(_(",MOUNT OPTIONS")); (void)printf("\n"); } /* * Display the sum (useful when -s option is used * @lst: queue containing the informations * @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(struct list *lst, double stot, double atot, double utot, double ifitot, double ifatot) { double ptot = 0; /* do not care about lst in CSV output */ (void)lst; if ((int)stot == 0) ptot = 100.0; else ptot = (utot / stot) * 100.0; (void)printf(_("SUM:,")); if (Tflag) (void)printf(","); csv_disp_perct(ptot); if (uflag) { stot = cvrt(stot); atot = cvrt(atot); if (dflag) utot = cvrt(utot); } if (dflag) csv_disp_at(utot, ptot); csv_disp_at(atot, ptot); csv_disp_at(stot, ptot); 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 formated * @n: number to print * @perct: percentage (useful for finding which color to use) */ static void csv_disp_at(double n, double perct) { int i; /* do not care about perct here */ (void)perct; (void)printf(","); 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 * @lst: is ignored here * @fsname: list of the file system to print */ static void csv_disp_fs(struct list *lst, char *fsname) { /* we do not care about lst here */ (void)lst; (void)printf("%s,",fsname); } /* * Display file system type * @lst: is ignored here * @type: the file system type to print */ static void csv_disp_type(struct list *lst, char *type) { /* we do not care about lst here */ (void)lst; (void)printf("%s,", type); } /* * 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(",%" PRIu64 ",", files); print_unit(i, 0); i = humanize_i(&favail); (void)printf(",%" PRIu64 ",", favail); print_unit(i, 0); } else { (void)printf(",%" PRIu64 ",", files); (void)printf(",%" PRIu64 ",", favail); } } /* * Display mount point * @dir: mount point */ static void csv_disp_mount(char *dir) { (void)printf(",%s", dir); } /* * Display mount options * @lst: is ignored here * @dir: is ignored here * @opts: mount options */ static void csv_disp_mopt(struct list *lst, char *dir, char *opts) { /* we do not care about lst here */ (void)lst; /* neither about dir */ (void)dir; (void)printf(",%s", opts); } /* * Display percentage * @perct: percentage */ static void csv_disp_perct(double perct) { (void)printf("%.f,%%", perct); } dfc-3.0.5/src/display.h000644 001751 001751 00000004644 12414102564 015155 0ustar00robinrobin000000 000000 /* * Copyright (c) 2012-2014, 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 #if defined(__APPLE__) #include #include #endif /* __APPLE__ */ #include "list.h" /* 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) (struct list*); void (*print_sum) (struct list*, double, double, double, double, double); void (*print_bar) (double); void (*print_at) (double, double); void (*print_fs) (struct list*, char *); void (*print_type) (struct list*, char *); void (*print_inodes) (uint64_t, uint64_t); void (*print_mount) (char *); void (*print_mopt) (struct list*, char *, char *); void (*print_perct) (double); }; #endif /* ndef H_DISPLAY */ dfc-3.0.5/src/html.c000644 001751 001751 00000024630 12414102722 014440 0ustar00robinrobin000000 000000 /* * Copyright (c) 2012-2014, 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 #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(struct list *lst); static void html_disp_sum(struct list *lst, double stot, double utot, double ftot, double ifitot, double ifatot); static void html_disp_bar(double perct); static void html_disp_at(double n, double perct); static void html_disp_fs(struct list *lst, char *fsname); static void html_disp_type(struct list *lst, char *type); static void html_disp_inodes(uint64_t files, uint64_t favail); static void html_disp_mount(char *dir); static void html_disp_mopt(struct list *lst, char *dir, char *opts); static void html_disp_perct(double perct); /* 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_at = html_disp_at; 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; } /* * 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 * @lst: is ignored here */ static void html_disp_header(struct list *lst) { char *date; (void) lst; if ((date = fetchdate()) == NULL) date = _("Unknown date"); (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,")); } (void)printf("\t \n", _("MOUNTED ON")); if (oflag) (void)printf("\t \n", _("MOUNT OPTIONS")); (void)puts("\t\n\t"); } /* * Display the sum (useful when -s option is used * @lst: is ignored here * @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(struct list *lst, 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)lst; (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_at(utot, ptot); html_disp_at(atot, ptot); html_disp_at(stot, ptot); 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 formated * @n: number to print * @perct: percentage (useful for finding which color to use) */ static void html_disp_at(double n, double perct) { int i; (void)perct; (void)printf("\t "); } /* * Display file system * @lst: is ignored here * @fsname: list of the file system to print */ static void html_disp_fs(struct list *lst, char *fsname) { static int must_close = 0; (void)lst; if (must_close == 1) (void)puts("\t"); (void)printf("\t\n\t \n", fsname); must_close = 1; } /* * Display file system type * @lst: is ignored here * @type: the file system type to print */ static void html_disp_type(struct list *lst, char *type) { (void)lst; (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(char *dir) { (void)printf("\t ", dir); } /* * Display mount options * @lst: is ignored here * @dir: is ignored here * @opts: mount options */ static void html_disp_mopt(struct list *lst, char *dir, char *opts) { (void)lst; (void)dir; (void)printf("\n\t ", opts); } /* * Display percentage * @perct: percentage */ static void html_disp_perct(double perct) { (void)printf("\t \n", perct); } dfc-3.0.5/src/extern.h.in000644 001751 001751 00000007154 12414102733 015417 0ustar00robinrobin000000 000000 /* * Copyright (c) 2012-2014, 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 */ #cmakedefine PACKAGE "${PACKAGE}" #cmakedefine VERSION "${VERSION}" #cmakedefine NLS_ENABLED /* too ugly to use gettext in each string that needs translation... */ #ifdef NLS_ENABLED #define _(STRING) gettext(STRING) #cmakedefine LOCALEDIR "${LOCALEDIR}" #else #define _(STRING) STRING #endif /* 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 /* html color code length (type of #FF0000, etc.) without the # */ #define HTMLCOLORCODELENGTH 6 /* * These two variables are used when we don't need to alloc some mem for the * fsmntinfo struct. So we can know that and don't free the pointers */ extern char *g_unknown_str; extern char *g_none_str; struct conf { 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 */ char gsymbol; /* symbol used to draw the graph */ char *hcheadbg; /* background color for header and footer (html) */ char *hcheadfg; /* font color used in header and footer (html) */ char *hccellbg; /* background color for cells (html) */ char *hccellfg; /* font color for cells (html) */ char *hchoverbg;/* background color on hover (html) */ char *hchoverfg;/* font color on hover (html) */ char *hclow; /* color when usage is low (html) */ char *hcmedium; /* color when usage is medium (html) */ char *hchigh; /* color when usage is high (html) */ }; /* struct to store specific configuration from config file */ struct conf cnf; /* set flags for options */ int aflag, bflag, cflag, dflag, eflag, fflag, hflag, iflag, lflag, mflag, nflag, oflag, pflag, qflag, sflag, tflag, uflag, vflag, wflag; int Tflag, Wflag; /* flag that determines which unit is in use (Ko, Mo, etc.) */ char unitflag; #endif /* ndef EXTERN_H */ dfc-3.0.5/src/dotfile.c000644 001751 001751 00000024177 12414102606 015131 0ustar00robinrobin000000 000000 /* * Copyright (c) 2012-2014, 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 */ #define _BSD_SOURCE #include #include #include #include #include #include #include #include "dotfile.h" #ifdef NLS_ENABLED #include #endif /* * Finds the configuration file and returns it. * 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 * getconf(void) { struct stat buf; char *home; char *xdg_c_h; char *conf; if ((xdg_c_h = getenv("XDG_CONFIG_HOME")) != NULL) { if ((conf = strcat(xdg_c_h, "/dfc/dfcrc")) == NULL) { (void)fputs("strcat failed while guessing " "configuration file\n", stderr); return NULL; /* NOTREACHED */ } if (stat(conf, &buf) == 0) return conf; /* NOTREACHED */ else /* no configuration file exists or it cannot be accessed */ return NULL; /* NOTREACHED */ } else { /* maybe XDG_CONFIG_HOME is just not exported */ /* lets assume that XDG_CONFIG_HOME is simply $HOME/.config */ if ((home = getenv("HOME")) != NULL) { if ((conf = strcat(home, "/.config/dfc/dfcrc")) == NULL) { (void)fputs("strcat failed while guessing " "configuration file location\n", stderr); return NULL; /* NOTREACHED */ } if (stat(conf, &buf) == 0) return conf; /* NOTREACHED */ else { /* support $HOME/.dfcrc */ /* home has been modified by strcat */ if ((home = getenv("HOME")) == NULL) return NULL; /* NOTREACHED */ if ((conf = strcat(home, "/.dfcrc")) == NULL) { (void)fputs("strcat failed while guessing" " configuration file\n", stderr); return NULL; /* NOTREACHED */ } if (stat(conf, &buf) == 0) return conf; /* NOTREACHED */ else return NULL; /* NOTREACHED */ } } else /* sorry, there is nothing I can do... */ return NULL; /* NOTREACHED */ } } /* * parse the configuration file and update options * return -1 in case of error, otherwise, 0 is returned * @conf: path to the configuration file */ int parse_conf(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; /* NOTREACHED */ } while ((fgets(line, (int)sizeof(line), fd)) != NULL) { /* skip empty lines and lines beginning with # */ if (!strlen(strtrim(line)) || line[0] == '#') continue; /* NOTREACHED */ 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; /* NOTREACHED */ } ret += set_conf(key, val); } if (fclose(fd) == EOF) perror("Could not close configuration file "); if (ret < 0) return -1; /* NOTREACHED */ return ret; /* NOTREACHED */ } /* * Set configuration values taken from the configuration file * Return 0 if no error occured, -1 otherwise. * @key: key in configuration file * @val: value corresponding to the key */ int set_conf(char *key, char *val) { int tmp; int ret = 0; char *tmpc; if (strcmp(key, "color_header") == 0) { if ((tmp = colortoint(val)) == -1) goto unknown_color_value; /* NOTREACHED */ else cnf.chead = tmp; } else if (strcmp(key, "color_low") == 0) { if ((tmp = colortoint(val)) == -1) goto unknown_color_value; /* NOTREACHED */ else cnf.clow = tmp; } else if (strcmp(key, "color_medium") == 0) { if ((tmp = colortoint(val)) == -1) goto unknown_color_value; /* NOTREACHED */ else cnf.cmedium = tmp; } else if (strcmp(key, "color_high") == 0) { if ((tmp = colortoint(val)) == -1) goto unknown_color_value; /* NOTREACHED */ 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; /* NOTREACHED */ else cnf.hcheadbg = tmpc; } else goto non_valid_html_color; /* NOTREACHED */ } else if (strcmp(key, "html_color_header_fg") == 0) { if (chk_html_colorcode(val) == 0) { if (!(tmpc = strdup(val))) goto strdup_failed; /* NOTREACHED */ else cnf.hcheadfg = tmpc; } else goto non_valid_html_color; /* NOTREACHED */ } else if (strcmp(key, "html_color_cell_bg") == 0) { if (chk_html_colorcode(val) == 0) { if (!(tmpc = strdup(val))) goto strdup_failed; /* NOTREACHED */ else cnf.hccellbg = tmpc; } else goto non_valid_html_color; /* NOTREACHED */ } else if (strcmp(key, "html_color_cell_fg") == 0) { if (chk_html_colorcode(val) == 0) { if (!(tmpc = strdup(val))) goto strdup_failed; /* NOTREACHED */ else cnf.hccellfg = tmpc; } else goto non_valid_html_color; /* NOTREACHED */ } else if (strcmp(key, "html_color_hover_bg") == 0) { if (chk_html_colorcode(val) == 0) { if (!(tmpc = strdup(val))) goto strdup_failed; /* NOTREACHED */ else cnf.hchoverbg = tmpc; } else goto non_valid_html_color; /* NOTREACHED */ } else if (strcmp(key, "html_color_hover_fg") == 0) { if (chk_html_colorcode(val) == 0) { if (!(tmpc = strdup(val))) goto strdup_failed; /* NOTREACHED */ else cnf.hchoverfg = tmpc; } else goto non_valid_html_color; /* NOTREACHED */ } else if (strcmp(key, "html_color_low") == 0) { if (chk_html_colorcode(val) == 0) { if (!(tmpc = strdup(val))) goto strdup_failed; /* NOTREACHED */ else cnf.hclow = tmpc; } else goto non_valid_html_color; /* NOTREACHED */ } else if (strcmp(key, "html_color_medium") == 0) { if (chk_html_colorcode(val) == 0) { if (!(tmpc = strdup(val))) goto strdup_failed; /* NOTREACHED */ else cnf.hcmedium = tmpc; } else goto non_valid_html_color; /* NOTREACHED */ } else if (strcmp(key, "html_color_high") == 0) { if (chk_html_colorcode(val) == 0) { if (!(tmpc = strdup(val))) goto strdup_failed; /* NOTREACHED */ else cnf.hchigh = tmpc; } else goto non_valid_html_color; /* NOTREACHED */ } else { (void)fprintf(stderr, _("Error: unknown option in configuration" " file: %s\n"), key); ret = -1; } return ret; /* NOTREACHED */ unknown_color_value: (void)fprintf(stderr, _("Unknown color value: %s\n"), val); return -1; /* NOTREACHED */ non_valid_html_color: (void)fprintf(stderr, _("Not a valid HTML color: %s\n"), val); return -1; /* NOTREACHED */ strdup_failed: (void)fprintf(stderr, "Could not assign value from configuration file: " "%s\n", val); return -1; /* NOTREACHED */ } /* * 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"; } dfc-3.0.5/src/text.c000644 001751 001751 00000022766 12414102657 014477 0ustar00robinrobin000000 000000 /* * Copyright (c) 2012-2014, 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 #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(struct list *lst); static void text_disp_sum(struct list *lst, double stot, double utot, double ftot, double ifitot, double ifatot); static void text_disp_bar(double perct); static void text_disp_at(double n, double perct); static void text_disp_fs(struct list *lst, char *fsname); static void text_disp_type(struct list *lst, char *type); static void text_disp_inodes(uint64_t files, uint64_t favail); static void text_disp_mount(char *dir); static void text_disp_mopt(struct list *lst, char *dir, char *opts); static void text_disp_perct(double perct); 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_at = text_disp_at; 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; } /* * Display header * @lst: queue containing the informations */ static void text_disp_header(struct list *lst) { int i; int barinc = 5; /* use color option is triggered */ if (cflag) (void)printf("\033[;%dm", cnf.chead); (void)printf("%s", _("FILESYSTEM ")); for (i = 11; i < lst->fsmaxlen; i++) (void)printf(" "); if (Tflag) { (void)printf("%s", _(" TYPE")); if (lst->typemaxlen > 5) for (i = 5; i < lst->typemaxlen + 1; i++) (void)printf(" "); else lst->typemaxlen = 5; } /* option to display a wider bar */ if (wflag) { barinc = 35; } if (!bflag) { (void)printf("%s", _(" (=) USED")); for (i = 0; i < (barinc + 1); i++) (void)printf(" "); (void)printf("%s", _("FREE (-) ")); } (void)printf("%s", _("%USED")); if (dflag) { if (unitflag == 'k') (void)printf(" "); else if (unitflag == 'b') (void)printf(" "); else (void)printf(" "); (void)printf("%s", _("USED")); } if (unitflag == 'k') (void)printf(" "); else if (unitflag == 'b') (void)printf(" "); else (void)printf(" "); (void)printf("%s", _("AVAILABLE")); if (unitflag == 'k') (void)printf(" "); else if (unitflag == 'm') (void)printf(" "); else if (unitflag == 'b') (void)printf(" "); else (void)printf(" "); (void)printf("%s", _("TOTAL")); if (iflag) { (void)printf("%s", _(" #INODES")); (void)printf("%s", _(" AV.INODES")); } (void)printf("%s", _(" MOUNTED ON ")); if (oflag) { for (i = 10; i < lst->dirmaxlen; i++) (void)printf(" "); (void)printf("%s", _("MOUNT OPTIONS\n")); } else (void)printf("\n"); reset_color(); } /* * Display the sum (useful when -s option is used * @lst: queue containing the informations * @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(struct list *lst, double stot, double atot, double utot, double ifitot, double ifatot) { int i,j; double ptot = 0; if ((int)stot == 0) ptot = 100.0; else ptot = (utot / stot) * 100.0; /* use color option is triggered */ if (cflag) (void)printf("\033[;%dm", cnf.chead); (void)printf("%s", _("SUM:")); reset_color(); j = lst->fsmaxlen + 1; if (Tflag) j += lst->typemaxlen + 1; for (i = 4; i < j; i++) (void)printf(" "); 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_at(utot, ptot); text_disp_at(atot, ptot); text_disp_at(stot, ptot); 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[;%dm", cnf.clow); for (i = 0; (i < cnf.gmedium) && (i < perct); i += barinc) (void)printf("%c", cnf.gsymbol); /* yellow */ (void)printf("\033[;%dm", cnf.cmedium); for (; (i < cnf.ghigh) && (i < perct); i += barinc) (void)printf("%c", cnf.gsymbol); /* red */ (void)printf("\033[;%dm", 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 available and total correctly formated * @n: number to print * @perct: percentage (useful for finding which color to use) */ static void text_disp_at(double n, double perct) { int i; change_color(perct); if (unitflag == 'h') { i = humanize(&n); change_color(perct); (void)printf(i == 0 ? "%9.f" : "%9.1f", n); reset_color(); print_unit(i, 1); } else { change_color(perct); if (unitflag == 'b') (void)printf("%15.f", n); else if (unitflag == 'k') (void)printf("%10.f", n); else (void)printf("%9.1f", n); reset_color(); print_unit(0, 1); } } /* * Display file system * @lst: list containing the information * @fsname: list of the file system to print */ static void text_disp_fs(struct list *lst, char *fsname) { int i; (void)printf("%s", fsname); for (i = (int)strlen(fsname); i < lst->fsmaxlen + 1; i++) (void)printf(" "); } /* * Display file system type * @lst: list containing the information * @type: the file system type to print */ static void text_disp_type(struct list* lst, char *type) { int i; (void)printf("%s", type); for (i = (int)strlen(type); i < lst->typemaxlen + 1; i++) (void)printf(" "); } /* * 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("%9" PRIu64, files); print_unit(i, 0); i = humanize_i(&favail); (void)printf("%9" PRIu64, favail); print_unit(i, 0); } else { (void)printf(" %9" PRIu64, files); (void)printf(" %9" PRIu64, favail); } } /* * Display mount point * @dir: mount point */ static void text_disp_mount(char *dir) { (void)printf(" %s", dir); } /* * Display mount options * @lst: structure containing information * @dir: mount point * @opts: mount options */ static void text_disp_mopt(struct list* lst, char *dir, char *opts) { int i; for (i = (int)strlen(dir); i < imax(lst->dirmaxlen + 1, 11); i++) (void)printf(" "); (void)printf("%s", opts); } /* * Display percentage * @perct: percentage */ static void text_disp_perct(double perct) { change_color(perct); (void)printf("%3.f", perct); reset_color(); (void)printf("%%"); } /* * Change color according to perct * @perct: percentage */ static void change_color(double perct) { if (cflag) { if (perct < (double)cnf.gmedium) /* green */ (void)printf("\033[;%dm", cnf.clow); else if (perct < (double)cnf.ghigh) /* yellow */ (void)printf("\033[;%dm", cnf.cmedium); else /* red */ (void)printf("\033[;%dm", cnf.chigh); } } /* * Reset color attribute to default */ static void reset_color(void) { if (cflag) (void)printf("\033[;m"); } dfc-3.0.5/src/list.c000644 001751 001751 00000007236 12414102673 014457 0ustar00robinrobin000000 000000 /* * Copyright (c) 2012-2014, 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" char *g_unknown_str = "unknown"; char *g_none_str = "none"; /* * Initializes a queue structure * @lst: queue pointer */ void init_queue(struct list *lst) { lst->head = NULL; lst->tail = NULL; lst->fsmaxlen = -1; lst->dirmaxlen = -1; lst->typemaxlen = -1; lst->mntoptmaxlen = -1; /* stairway to heaven ! */ } /* * 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; /* NOTREACHED */ else return 0; /* NOTREACHED */ } /* * Enqueues an element into a queue * @lst: queue pointer * @elt: element * Returns: * --> -1 on error * --> 0 on sucess */ 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; /* NOTREACHED */ } /* 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; /* NOTREACHED */ } /* * 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.dir = g_unknown_str; fmi.type = g_unknown_str; fmi.opts = g_none_str; 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; /* NOTREACHED */ } 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->dir != g_unknown_str) free(p->dir); if(p->type != g_unknown_str) free(p->type); if(p->opts != g_none_str) free(p->opts); free(p); return next; } dfc-3.0.5/src/dotfile.h000644 001751 001751 00000003524 12414102744 015132 0ustar00robinrobin000000 000000 /* * Copyright (c) 2012-2014, 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 * getconf(void); int parse_conf(char *dfcrc); int set_conf(char *key, char *val); void init_conf(struct conf *config); #endif /* ndef H_DOTFILE */ dfc-3.0.5/src/export.h000644 001751 001751 00000003546 12414103033 015021 0ustar00robinrobin000000 000000 /* * Copyright (c) 2012-2014, 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_tex(struct display *disp); void init_disp_text(struct display *disp); #endif /* ndef H_EXPORT */ dfc-3.0.5/src/list.h000644 001751 001751 00000011733 12414103124 014451 0ustar00robinrobin000000 000000 /* * Copyright (c) 2012-2014, 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 #if defined(__APPLE__) #include #include #endif /* __APPLE__ */ /* * structure needed to store informations about mounted fs * It should contain brut datas. * Later on, we would need to compute those infos: * unsigned long bused; used blocks * double prct_used; usage of fs in percent * double prct_free; free space of fs in percent */ struct fsmntinfo { /* infos to get from getmntent(3) */ char *fsname; /* name of mounted file system */ char *dir; /* file system path prefix */ char *type; /* mount type */ char *opts; /* mount options (see mntent.h) */ /* infos to get from statvfs(3) */ #if defined(__linux__) || defined(__NetBSD__) 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__ || __NetBSD__ */ #if defined(__FreeBSD__) 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 */ uint64_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 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__) 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 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__ */ /* pointer to the next element of the list */ struct fsmntinfo *next; }; /* list structure to store fsmntinfo */ struct list { struct fsmntinfo *head; struct fsmntinfo *tail; int fsmaxlen; /* should be the size of the longest fsname */ int dirmaxlen; /* same for dir */ int typemaxlen; /* same for type */ int mntoptmaxlen; /* same for mount option */ }; /* 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.0.5/src/dfc.c000644 001751 001751 00000057216 12414102762 014242 0ustar00robinrobin000000 000000 /* * Copyright (c) 2012-2014, 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. */ #define _BSD_SOURCE #ifdef __linux #define _POSIX_C_SOURCE 2 #define _XOPEN_SOURCE 500 #endif /* __linux__ */ #define STRMAXLEN 24 #include #include #include #include #include #ifdef __linux__ #include #endif /* __linux__ */ #include #include #include #include #include #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) \ || defined(__APPLE__) || defined(__DragonFly__) #include #include #endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __APPLE__ || __DragonFly__ */ #include "dfc.h" #ifdef NLS_ENABLED #include #include #endif /* NLS_ENABLED */ int main(int argc, char *argv[]) { struct list queue; struct display sdisp; int ch; int width; int ret = EXIT_SUCCESS; char *fsnfilter = NULL; char *fstfilter = NULL; char *subopts; char *value; char *cfgfile; char *color_opts[] = { #define CALWAYS 0 "always", #define CNEVER 1 "never", #define CAUTO 2 "auto", NULL }; char *export_opts[] = { #define ETEXT 0 "text", #define ECSV 1 "csv", #define EHTML 2 "html", #define ETEX 3 "tex", NULL }; char *sort_opts[] = { #define SFSNAME 0 "name", #define SFSTYPE 1 "type", #define SFSDIR 2 "mount", NULL }; char *unit_opts[] = { #define H 0 "h", #define B 1 "b", #define K 2 "k", #define M 3 "m", #define G 4 "g", #define T 5 "t", #define P 6 "p", #define E 7 "e", #define Z 8 "z", #define Y 9 "y", 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:fhilmnop: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); return EXIT_FAILURE; /* NOTREACHED */ } } 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 -1: /* FALLTHROUGH */ default: (void)fprintf(stderr, _("-e: illegal sub option %s\n"), subopts); return EXIT_FAILURE; /* NOTREACHED */ } } 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 '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); return EXIT_FAILURE; /* NOTREACHED */ } } 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 H: /* * disable uflag since conversion to * human readable format is computed * very differently from other formats */ uflag = 0; unitflag = 'h'; break; case B: unitflag = 'b'; break; case K: unitflag = 'k'; break; case M: unitflag = 'm'; break; case G: unitflag = 'g'; break; case T: unitflag = 't'; break; case P: unitflag = 'p'; break; case E: unitflag = 'e'; break; case Z: unitflag = 'z'; break; case Y: unitflag = 'y'; break; case -1: /* FALLTHROUGH */ default: (void)fprintf(stderr, _("-u: illegal sub option %s\n"), subopts); return EXIT_FAILURE; /* NOTREACHED */ } } break; case 'v': vflag = 1; break; case 'w': wflag = 1; break; case 'W': Wflag = 1; break; case '?': default: usage(EXIT_FAILURE); /* NOTREACHED */ } } if (hflag) usage(EXIT_SUCCESS); /* NOTREACHED */ if (vflag) { (void)printf("%s %s\n", PACKAGE, VERSION); return EXIT_SUCCESS; /* NOTREACHED */ } width = getttywidth(); /* if fd is not a terminal and color mode is not "always", disable color */ if (width == 0 && cflag != 2) cflag = 0; /* change cnf value according to config file, it it exists */ if ((cfgfile = getconf()) != NULL) { if (parse_conf(cfgfile) == -1) { (void)fprintf(stderr, _("Error reading the configuration" " file: %s\n"), cfgfile); ret = EXIT_FAILURE; } } /* 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 && width > 0 && !eflag) auto_adjust(queue, width); /* actually displays the info we have got */ disp(&queue, fstfilter, fsnfilter, &sdisp); return ret; /* NOTREACHED */ } /* * 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]\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"), stdout); (void)fputs(_( "\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"), stdout); } exit(status); /* NOTREACHED */ } /* * 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) { struct fsmntinfo *fmi; #ifdef __linux__ FILE *mtab; struct mntent *entbuf; struct statvfs vfsbuf; #else /* *BSD */ int nummnt; #if defined(__NetBSD__) struct statvfs *entbuf; struct statvfs vfsbuf, **fs; #else struct statfs *entbuf; struct statfs vfsbuf, **fs; #endif #endif /* __linux__ */ /* 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(); #ifdef __linux__ /* 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) { /* get infos from statvfs */ if (statvfs(entbuf->mnt_dir, &vfsbuf) == -1) { /* 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(" "); } else { #else /* BSD */ 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; #endif /* __linux__ */ #ifdef __linux__ /* infos from getmntent */ if (Wflag) { /* Wflag to avoid name truncation */ if ((fmi->fsname = strdup(entbuf->mnt_fsname)) == NULL) { /* g_unknown_str is def. in extern.h(.in) */ fmi->fsname = g_unknown_str; } if ((fmi->dir = strdup(entbuf->mnt_dir)) == NULL) { fmi->dir = g_unknown_str; } } else { if ((fmi->fsname = strdup(shortenstr( entbuf->mnt_fsname, STRMAXLEN))) == NULL) { fmi->fsname = g_unknown_str; } if ((fmi->dir = strdup(shortenstr(entbuf->mnt_dir, STRMAXLEN))) == NULL) { fmi->dir = g_unknown_str; } } if ((fmi->type = strdup(shortenstr(entbuf->mnt_type, 12))) == NULL) { fmi->type = g_unknown_str; } if ((fmi->opts = strdup(entbuf->mnt_opts)) == NULL) { fmi->opts = g_none_str; } #else /* BSD */ if (Wflag) { /* Wflag to avoid name truncation */ if ((fmi->fsname = strdup( entbuf->f_mntfromname)) == NULL) { fmi->fsname = g_unknown_str; } if ((fmi->dir = strdup(( entbuf->f_mntonname ))) == NULL) { fmi->dir = g_unknown_str; } } else { if ((fmi->fsname = strdup(shortenstr( entbuf->f_mntfromname, STRMAXLEN))) == NULL) { fmi->fsname = g_unknown_str; } if ((fmi->dir = strdup(shortenstr( entbuf->f_mntonname, STRMAXLEN))) == NULL) { fmi->dir = g_unknown_str; } } if ((fmi->type = strdup(shortenstr( entbuf->f_fstypename, 12))) == NULL) { fmi->type = g_unknown_str; } if ((fmi->opts = statfs_flags_to_str(entbuf)) == NULL) { fmi->opts = g_none_str; } #endif /* __linux__ */ /* infos from statvfs */ fmi->bsize = vfsbuf.f_bsize; #if defined(__linux__) || defined(__NetBSD__) fmi->frsize = vfsbuf.f_frsize; #else /* *BSD do not have frsize */ fmi->frsize = 0; #endif /* __linux__ */ 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; #if defined(__linux__) || defined(__NetBSD__) fmi->favail = vfsbuf.f_favail; #else /* *BSD do not have favail */ fmi->favail = 0; #endif /* __linux__ */ /* pointer to the next element */ fmi->next = NULL; /* enqueue the element into the queue */ enqueue(lst, *fmi); /* adjust longest for the queue */ if ((!aflag && fmi->blocks > 0) || aflag) { lst->fsmaxlen = imax((int)strlen(fmi->fsname), lst->fsmaxlen); lst->dirmaxlen = imax((int)strlen(fmi->dir), lst->dirmaxlen); lst->typemaxlen = imax((int)strlen(fmi->type), lst->typemaxlen); lst->mntoptmaxlen = imax((int)strlen(fmi->opts), lst->mntoptmaxlen); } } #ifdef __linux__ } /* we need to close the mtab file now */ if (fclose(mtab) == EOF) perror("Could not close mtab file "); #endif /* __linux__ */ free(fmi); } /* * 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, char *fstfilter, char *fsnfilter, struct display *sdisp) { struct fsmntinfo *p = NULL; int n; int nmt = 0; int nmn = 0; double perctused, size, avail, used; 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 and tex export (csv and text point to NULL) */ if (sdisp->init) sdisp->init(); /* legend on top */ if (!nflag) sdisp->print_header(lst); if (lst->fsmaxlen < 11) lst->fsmaxlen = 11; /* sort the list */ if (qflag) lst->head = msort(lst->head); p = lst->head; while (p != NULL) { if (!aflag) { /* skip (pseudo)devices (which have a size of 0 usually) */ if (p->blocks == 0) { p = delete_struct_and_get_next(p); continue; /*NOTREACHED */ } } /* apply filtering on fs type */ if (fstypefilter(p->type, fstfilter, nmt) == 0) { p = delete_struct_and_get_next(p); continue; /* NOTREACHED */ } /* apply filtering on fs name */ if (fsnamefilter(p->fsname, fsnfilter, nmn) == 0) { p = delete_struct_and_get_next(p); continue; /* NOTREACHED */ } /* skip remote file systems */ if (lflag) { if (is_remote(p->type)) { p = delete_struct_and_get_next(p); continue; /* NOTREACHED */ } } /* filesystem */ sdisp->print_fs(lst, p->fsname); /* type */ if (Tflag) { sdisp->print_type(lst, p->type); } #if defined(__linux__) || defined(__NetBSD__) size = (double)p->frsize * (double)p->blocks; avail = (double)p->frsize * (double)p->bavail; used = (double)p->frsize * ((double)p->blocks - (double)p->bfree); #else /* *BSD */ size = (double)p->bsize * (double)p->blocks; avail = (double)p->bsize * (double)p->bavail; used = (double)p->bsize * ((double)p->blocks - (double)p->bfree); #endif /* __linux__ */ /* calculate the % used */ if ((int)size == 0) perctused = 100.0; else /* * compute percent based on bfree as it is a given * value and not a computed one like used size */ perctused = 100.0 - ((double)p->bavail / (double)p->blocks) * 100.0; if (sflag) { stot += size; atot += avail; utot += used; } if (!bflag) sdisp->print_bar(perctused); /* %used */ sdisp->print_perct(perctused); /* format to requested format */ if (uflag) { size = cvrt(size); avail = cvrt(avail); if (dflag) used = cvrt(used); } if (dflag) sdisp->print_at(used, perctused); /* avail and total */ sdisp->print_at(avail, perctused); sdisp->print_at(size, perctused); /* info about inodes */ if (iflag) { ifitot += (double)p->files; ifatot += (double)p->favail; #if defined(__linux__) 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 */ sdisp->print_mount(p->dir); /* info about mount option */ if (oflag) sdisp->print_mopt(lst, p->dir, p->opts); (void)printf("\n"); p = delete_struct_and_get_next(p); /* XXX returns p->next! */ } if (sflag) sdisp->print_sum(lst, stot, atot, utot, ifitot, ifatot); /* only required for html and tex export (csv and text point to NULL) */ if (sdisp->deinit) sdisp->deinit(); } #if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) \ || defined(__OpenBSD__) || defined(__APPLE__) /* * 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(__FreeBSD__) { MNT_GJOURNAL, "gjournal" }, #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(__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__) { 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 /* MNT_RDONLY is treated separately in statfs_flags_to_str(). */ #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) \ || defined(__APPLE__) { MNT_ROOTFS, "rootfs" }, #endif #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) { MNT_SOFTDEP, "softdep" }, #endif #if defined(__FreeBSD__) { 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(__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. */ char * statfs_flags_to_str( #ifdef __NetBSD__ struct statvfs *s #else struct statfs *s #endif ) { int i, n_flags; #if defined(__DragonFly__) int flags = s->f_flags; #elif defined(__NetBSD__) unsigned long flags = s->f_flag; #else uint64_t flags = s->f_flags; #endif /* __DragonFly__ */ size_t bufsize = 128; char *buffer = malloc(bufsize); if (!buffer) { (void)fprintf(stderr, _("Could not retrieve mount flags for %s\n"), s->f_mntonname); return NULL; /* NOTREACHED */ } buffer[0] = '\0'; /* There is no MNT_RDWRITE flag, so we have to do this. */ if (flags & MNT_RDONLY) { if (strlcat(buffer, "ro", bufsize) >= bufsize) goto truncated; /* NOTREACHED */ } else { if (strlcat(buffer, "rw", bufsize) >= bufsize) goto truncated; /* NOTREACHED */ } /* Comparing flags to all possible flags. */ n_flags = sizeof(possible_flags) / sizeof(possible_flags[0]); for (i = 0; i < n_flags; i++) { if (!(flags & possible_flags[i].flag)) continue; /* NOTREACHED */ if (strlcat(buffer, ",", bufsize) >= bufsize) goto truncated; /* NOTREACHED */ if (strlcat(buffer, possible_flags[i].str, bufsize) >= bufsize) goto truncated; /* NOTREACHED */ } return buffer; /* NOTREACHED */ truncated: (void)fprintf(stderr, _("Truncating mount options for %s\n"), s->f_mntonname); return buffer; /* NOTREACHED */ } #endif /* __FreeBSD__ || __OpenBSD__ || __APPLE__ || __DragonFly__ */ dfc-3.0.5/src/util.c000644 001751 001751 00000041723 12414103004 014445 0ustar00robinrobin000000 000000 /* * Copyright (c) 2012-2014, 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 */ #define _BSD_SOURCE #include #include #include #include #include #include #include #include #include "util.h" #ifdef NLS_ENABLED #include #endif /* * 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); /* NOTREACHED */ } /* * 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; /* NOTREACHED */ while (isspace(*str)) str++; if (*str == '\0') return str; /* NOTREACHED */ end = str + strlen(str) - 1; while (end > str && isspace(*end)) end--; *(end + 1) = '\0'; return str; /* NOTREACHED */ } /* * 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; /* NOTREACHED */ str += (slen - len); str[0] = '+'; return str; /* NOTREACHED */ } /* * 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); /* NOTREACHED */ if ((new = malloc(nchars)) == NULL) { (void)fputs("malloc failed\n", stderr); return NULL; /* NOTREACHED */ } 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; /* NOTREACHED */ } /* * Get the width of tty and return it. * Return 0 if stdout is not a tty. */ int getttywidth(void) { int width = 0; #ifdef TIOCGSIZE struct ttysize win; #elif defined(TIOCGWINSZ) struct winsize win; #endif /* TIOCGSIZE */ if (!isatty(STDOUT_FILENO)) return 0; /* NOTREACHED */ #ifdef TIOCGSIZE if (ioctl(STDOUT_FILENO, TIOCGSIZE, &win) == 0) #if defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) width = win.ts_cols; #else width = win.ws_col; #endif /* __APPLE__ || __NetBSD__ || __OpenBSD__ || __DragonFly__ */ #elif defined(TIOCGWINSZ) if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == 0) #if defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) width = win.ts_cols; #else width = win.ws_col; #endif /* __APPLE__ || __NetBSD__ || __OpenBSD__ || __DragonFly__ */ #endif /* TIOCGSIZE */ return width == 0 ? 80 : width; /* NOTREACHED */ } /* * 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; /* NOTREACHED */ } /* * 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; /* NOTREACHED */ } /* * 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; /* NOTREACHED */ case 1: /* Kio or Ko */ (void)printf("K"); return; /* NOTREACHED */ case 2: /* Mio or Mo */ (void)printf("M"); return; /* NOTREACHED */ case 3: /* Gio or Go*/ (void)printf("G"); return; /* NOTREACHED */ case 4: /* Tio or To*/ (void)printf("T"); return; /* NOTREACHED */ case 5: /* Pio or Po*/ (void)printf("P"); return; /* NOTREACHED */ case 6: /* Eio or Eo*/ (void)printf("E"); return; /* NOTREACHED */ case 7: /* Zio or Zo*/ (void)printf("Z"); return; /* NOTREACHED */ case 8: /* Yio or Yo*/ (void)printf("Y"); return; /* NOTREACHED */ 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; /* NOTREACHED */ case 'k': (void)printf("K"); return; /* NOTREACHED */ case 'm': (void)printf("M"); return; /* NOTREACHED */ case 'g': (void)printf("G"); return; /* NOTREACHED */ case 't': (void)printf("T"); return; /* NOTREACHED */ case 'p': (void)printf("P"); return; /* NOTREACHED */ case 'e': (void)printf("E"); return; /* NOTREACHED */ case 'z': (void)printf("Z"); return; /* NOTREACHED */ case 'y': (void)printf("Y"); return; /* NOTREACHED */ 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; /* NOTREACHED */ case 'e': if (mflag) /* 1000^6 */ return n / 1000000000000000000.0; /* NOTREACHED */ else /* 1024^6 */ return n / 1152921504606846976.0; /* NOTREACHED */ case 'g': if (mflag) /* 1000^3 */ return n / 1000000000.0; /* NOTREACHED */ else /* 1024^3 */ return n / 1073741824.0; /* NOTREACHED */ case 'k': if (mflag) return n / 1000.0; /* NOTREACHED */ else return n / 1024.0; /* NOTREACHED */ case 'm': if (mflag) /* 1000^2 */ return n / 1000000.0; /* NOTREACHED */ else /* 1024^2 */ return n / 1048576.0; /* NOTREACHED */ case 'p': if (mflag) /* 1000^5 */ return n / 1000000000000000.0; /* NOTREACHED */ else /* 1024^5 */ return n / 1125899906842624.0; /* NOTREACHED */ case 't': if (mflag) /* 1000^4 */ return n / 1000000000000.0; /* NOTREACHED */ else /* 1024^4 */ return n / 1099511627776.0; /* NOTREACHED */ case 'y': if (mflag) /* 1000^8 */ return n / 1000000000000000000000000.0; /* NOTREACHED */ else /* 1024^8 */ return n / 1208925819614629174706176.0; /* NOTREACHED */ case 'z': if (mflag) /* 1000^7 */ return n / 1000000000000000000000.0; /* NOTREACHED */ else /* 1024^7 */ return n / 1180591620717411303424.0; /* NOTREACHED */ default: (void)fputs("Could not convert unit size\n", stderr); return n; /* NOTREACHED */ } } /* * Return: * 1 if the given fs should be showed * 0 if the given fs should be skipped * @type: fs type to check * @filter: filter string * @nm: boolean indicating if the negative matching is activated */ int fstypefilter(char *type, char *filter, int nm) { int ret = 1; char *stropt; char *strtmp; if (tflag) { if ((strtmp = strdup(filter)) == NULL) { (void)fputs("Cannot duplicate filter\n", stderr); exit(EXIT_FAILURE); /* NOTREACHED */ } /* assume it should not be shown */ ret = 0; stropt = strtok(strtmp, ","); while (stropt != NULL) { if (strcmp(type, stropt) == 0) { ret = 1; break; } stropt = strtok(NULL, ","); } free(strtmp); } /* reverse result if negative matching activated */ if (nm) { if (ret) ret = 0; else ret = 1; } return ret; /* NOTREACHED */ } /* * Return: * 1 if the given fs should be showed * 0 if the given fs should be skipped * @type: fs type to check * @filter: filter string * @nm: boolean indicating if the negative matching is activated */ int fsnamefilter(char *fsname, char *filter, int nm) { int ret = 1; char *stropt; char *strtmp; if (pflag) { if ((strtmp = strdup(filter)) == NULL) { (void)fputs("Cannot duplicate filter\n", stderr); exit(EXIT_FAILURE); /* NOTREACHED */ } /* assume it should not be shown */ ret = 0; stropt = strtok(strtmp, ","); while (stropt != NULL) { if (strncmp(fsname, stropt, strlen(stropt)) == 0) { ret = 1; break; } stropt = strtok(NULL, ","); } free(strtmp); } /* reverse result if negative matching activated */ if (nm) { if (ret) ret = 0; else ret = 1; } return ret; /* NOTREACHED */ } /* * Determine if the fstype is remote or only local. * Return 1 if remote, otherwise return 0. * @fstype: type of file system */ int is_remote(char *fstype) { const char remote_fs[] = "afs cifs coda fuse.sshfs mfs " "ncpfs ftpfs nfs smbfs sshfs"; /* assume it is local by default */ int ret = 0; if (strstr(remote_fs, fstype)) ret = 1; return ret; /* NOTREACHED */ } /* * 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); /* NOTREACHED */ case 2: return strcmp(a->type, b->type); /* NOTREACHED */ case 3: return strcmp(a->dir, b->dir); /* NOTREACHED */ default: return -1; /* NOTREACHED */ } } /* * Perform a mergesort algorithm to sort the list by ascending * Results depends on what was chosen for comparison (fsname, type or dir) * @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; /* NOTREACHED */ 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; /* NOTREACHED */ } /* * auto-adjust options based on the size needed to display the informations * @lst: list containing info * @width: width of the output */ void auto_adjust(struct list lst, int width) { int req, gap; req = req_width(lst); /* nothing to adjust here */ if ((gap = (width - req)) >= 0) return; /* NOTREACHED */ (void)fputs(_("WARNING: TTY too narrow. Some options have been disabled" " to make dfc output fit (use -f to override).\n"), stderr); if (!bflag) { /* large graph should be the first option to disable */ if (wflag) { wflag = 0; gap += 30; if (gap >= 0) return; /* NOTREACHED */ } bflag = 1; gap += 23; if (gap >= 0) return; /* NOTREACHED */ } if (dflag) { dflag = 0; gap += 4; if (unitflag == 'k') gap += 7; else if (unitflag == 'b') gap += 12; else gap += 6; if (gap >= 0) return; /* NOTREACHED */ } if (Tflag) { Tflag = 0; gap += imax(lst.typemaxlen, 5); if (gap >= 0) return; /* NOTREACHED */ } if (iflag) { iflag = 0; gap += 20; if (gap >= 0) return; /* NOTREACHED */ } if (oflag) { oflag = 0; gap += imax(lst.mntoptmaxlen, 13); if (gap >= 0) return; /* NOTREACHED */ } if (gap < 0) (void)fputs(_("WARNING: Output still messed up. Enlarge your " "terminal if you can...\n"), stderr); } /* * compute the required width needed for the output and return it * (computation based on text_disp_header function) * @lst: list containing the info */ int req_width(struct list lst) { int ret; /* dir and fs are always displayed */ ret = imax(lst.fsmaxlen, 11); if (Tflag) ret += imax(lst.typemaxlen, 5); if (!bflag) { ret += 23; if (wflag) ret += 30; } /* % */ ret += 5; if (dflag) { if (unitflag == 'k') ret += 7; else if (unitflag == 'b') ret += 12; else ret += 6; ret += 4; } /* available */ ret += 9; switch (unitflag) { case 'b': ret += 7 + 11; break; case 'k': ret += 2 + 6; break; case 'm': ret += 5; break; case 'h': /* FALLTHROUGH */ case 'g': /* FALLTHROUGH */ case 't': /* FALLTHROUGH */ case 'p': /* FALLTHROUGH */ case 'e': /* FALLTHROUGH */ case 'z': /* FALLTHROUGH */ case 'y': /* FALLTHROUGH */ ret += 1 + 5; break; default: (void)fputs("Unknown unit type\n", stderr); } /* total */ ret += 5; if (iflag) ret += 20; /* mounted on */ ret += imax(lst.dirmaxlen, 12); if (oflag) ret += imax(lst.mntoptmaxlen, 13); return ret; /* NOTREACHED */ } /* * 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 */ 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(char *col) { if (strcoll(col, _("black")) == 0) return BLACK; /* NOTREACHED */ else if (strcoll(col, _("red")) == 0) return RED; /* NOTREACHED */ else if (strcoll(col, _("green")) == 0) return GREEN; /* NOTREACHED */ else if (strcoll(col, _("yellow")) == 0) return YELLOW; /* NOTREACHED */ else if (strcoll(col, _("blue")) == 0) return BLUE; /* NOTREACHED */ else if (strcoll(col, _("magenta")) == 0) return MAGENTA; /* NOTREACHED */ else if (strcoll(col, _("cyan")) == 0) return CYAN; /* NOTREACHED */ else if (strcoll(col, _("white")) == 0) return WHITE; /* NOTREACHED */ else return -1; /* NOTREACHED */ } /* * 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 ommit the #: white is FFFFFF and not #FFFFFF */ int chk_html_colorcode(char *color) { int i; if (strlen(color) != HTMLCOLORCODELENGTH) return -1; /* NOTREACHED */ for (i = 0; i < HTMLCOLORCODELENGTH; i++) if (isxdigit(color[i]) == 0) return -1; /* NOTREACHED */ return 0; /* NOTREACHED */ } dfc-3.0.5/src/dfc.h000644 001751 001751 00000004470 12414103042 014231 0ustar00robinrobin000000 000000 /* * Copyright (c) 2012-2014, 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 "display.h" #include "dotfile.h" #include "export.h" #include "extern.h" #include "list.h" #include "util.h" /* function declaration */ void usage(int status); void fetch_info(struct list *lst); void disp(struct list *lst, char *fsfilter, char *fsnfilter, struct display *sdisp); #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) \ || defined(__DragonFly__) /* avoid struct statfs declared inside parameter list warning */ struct statfs; char * statfs_flags_to_str(struct statfs *s); #elif defined(__NetBSD__) struct statvfs; char *statfs_flags_to_str(struct statvfs *s); #endif /* __FreeBSD__ || __OpenBSD__ || __APPLE__ || __DragonFly__ || __NetBSD__ */ #endif /* ndef DFC_H */ dfc-3.0.5/src/util.h000644 001751 001751 00000004620 12414103052 014450 0ustar00robinrobin000000 000000 /* * Copyright (c) 2012-2014, 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" /* function declaration */ int imax(int a, int b); char * strtrim(char *str); char * shortenstr(char *str, int len); char * sanitizestr(const char *str); int getttywidth(void); int humanize(double *n); int humanize_i(uint64_t *n); void print_unit(int i, int mode); double cvrt(double n); int fstypefilter(char *type, char *filter, int nm); int fsnamefilter(char *fsname, char *filter, int nm); int is_remote(char *fstype); int cmp(struct fsmntinfo *a, struct fsmntinfo *b); struct fsmntinfo * msort(struct fsmntinfo *fmi); void auto_adjust(struct list lst, int width); int req_width(struct list lst); char * fetchdate(void); char * colortostr(int color); int colortoint(char *col); int chk_html_colorcode(char *color); #endif /* ndef UTIL_H */ dfc-3.0.5/src/tex.c000644 001751 001751 00000022451 12414102640 014272 0ustar00robinrobin000000 000000 /* * Copyright (c) 2012-2014, 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 */ #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #include #include #include #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(struct list *lst); static void tex_disp_sum(struct list *lst, double stot, double utot, double ftot, double ifitot, double ifatot); static void tex_disp_bar(double perct); static void tex_disp_at(double n, double perct); static void tex_disp_fs(struct list *lst, char *fsname); static void tex_disp_type(struct list *lst, char *type); static void tex_disp_inodes(uint64_t files, uint64_t favail); static void tex_disp_mount(char *dir); static void tex_disp_mopt(struct list *lst, char *dir, char *opts); static void tex_disp_perct(double perct); /* 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_at = tex_disp_at; 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; } /* * 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 * @lst: is ignored here */ static void tex_disp_header(struct list *lst) { (void)lst; (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,")); } (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 * @lst: is ignored here * @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(struct list *lst, 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)lst; (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_at(utot, ptot); tex_disp_at(atot, ptot); tex_disp_at(stot, ptot); 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 formated * @n: number to print * @perct: percentage (useful for finding which color to use) */ static void tex_disp_at(double n, double perct) { int i; (void)perct; 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 * @lst: is ignored here * @fsname: list of the file system to print */ static void tex_disp_fs(struct list *lst, 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; /* NOTREACHED */ } (void)lst; if (must_close == 1) (void)puts("\\\\"); (void)printf("%s", cleaned_fsname); free(cleaned_fsname); must_close = 1; } /* * Display file system type * @lst: is ignored here * @type: the file system type to print */ static void tex_disp_type(struct list *lst, char *type) { char *cleaned_type = sanitizestr(type); if (cleaned_type == NULL) { (void)fputs("Cannot print type\n", stderr); return; /* NOTREACHED */ } (void) lst; (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(char *dir) { char *cleaned_dir = sanitizestr(dir); if (cleaned_dir == NULL) { (void)fputs("Cannot print mount point\n", stderr); return; /* NOTREACHED */ } (void)printf(" & %s", cleaned_dir); free(cleaned_dir); } /* * Display mount options * @lst: is ignored here * @dir: is ignored here * @opts: mount options */ static void tex_disp_mopt(struct list *lst, char *dir, char *opts) { char *cleaned_opts = sanitizestr(opts); if (cleaned_opts == NULL) { (void)fputs("Cannot print mount options\n", stderr); return; /* NOTREACHED */ } (void)lst; (void)dir; (void)printf(" & %s", cleaned_opts); free(cleaned_opts); } /* * Display percentage * @perct: percentage */ static void tex_disp_perct(double perct) { (void)printf(" & %.f\\%%", perct); } dfc-3.0.5/LICENSE000644 001751 001751 00000002736 12414103114 013545 0ustar00robinrobin000000 000000 Copyright (c) 2012-2014, 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.0.5/man/fr/dfc.1000644 001751 001751 00000015337 12414103176 014551 0ustar00robinrobin000000 000000 .TH dfc 1 "Le 05 Octobre 2014" "version 3.0.5" "COMMANDES UTILISATEURS" .SH NOM dfc \- affiche le taux d'utilisation des systèmes de fichiers avec graphes et couleurs. .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 avers le format HTML. Exemple d'utilisation: dfc \-e html \-Tadiso \-c always > index.html "tex": Exporte vers le foramt TeX. Exemple d'utilisation: dfc \-e tex \-c always > report.tex "text": Sortie texte (defaut). .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 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 filter 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. 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éfault 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 la troncation 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-2014 Robin Hahling .SH LICENCE BSD 3 Clauses .SH VOIR AUSSI df(1), du(1) dfc-3.0.5/man/dfc.1000644 001751 001751 00000012752 12414103216 014133 0ustar00robinrobin000000 000000 .TH dfc 1 "October 05, 2014" "version 3.0.5" "USER COMMANDS" .SH NAME dfc \- display file system space usage using graphs and colors .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 "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 \-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 name 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. 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 type 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-2014 Robin Hahling .SH LICENSE BSD 3-clause .SH SEE ALSO df(1), du(1) dfc-3.0.5/README000644 001751 001751 00000004250 12414102152 013412 0ustar00robinrobin000000 000000 # README dfc is a simple tool that displays file system space usage using graph and color. ## BUILD cmake is required in order to build dfc. I suggest you create a build directory to compile dfc, but this is of course not required. 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 directory. Note: if you do not want to build translation, you can use the following at the cmake step: cmake .. -DNLS_ENABLED=false ## RUN Once built, you can run it by typing: ./dfc from within the directory where dfc is situated. see ./dfc -h for options and usage. ## INSTALL By default, it 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: $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 beed 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 preceeded by a dot): $HOME/.dfcrc ## INFORMATION FOR PACKAGERS Here is the list of dependencies: * glibc Yep, that should be it. :) Please, note that gettext is required in order to build translation. 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.
"); (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%%