From 7dc83dc313f81bbbf5fa4c24be3ca3667c4e9554 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Fri, 25 Sep 2015 22:43:27 +0000 Subject: [PATCH] kstartupconfig: replace kstartupconfig4 with kdostartupconfig4 --- kstartupconfig/CMakeLists.txt | 14 +- kstartupconfig/kstartupconfig.c | 158 --------------------- .../{kdostartupconfig.cpp => kstartupconfig.cpp} | 0 3 files changed, 2 insertions(+), 170 deletions(-) delete mode 100644 kstartupconfig/kstartupconfig.c rename kstartupconfig/{kdostartupconfig.cpp => kstartupconfig.cpp} (100%) diff --git a/kstartupconfig/CMakeLists.txt b/kstartupconfig/CMakeLists.txt index 67e6242d..d16ddb89 100644 --- a/kstartupconfig/CMakeLists.txt +++ b/kstartupconfig/CMakeLists.txt @@ -1,20 +1,10 @@ ########### kstartupconfig ############### -set(kstartupconfig_SRCS kstartupconfig.c ) +set(kstartupconfig_SRCS kstartupconfig.cpp ) add_executable(kstartupconfig4 ${kstartupconfig_SRCS}) -target_link_libraries(kstartupconfig4 ${KDE4_KDEFAKES_LIBS} ) +target_link_libraries(kstartupconfig4 ${KDE4_KDECORE_LIBS} ) install(TARGETS kstartupconfig4 ${INSTALL_TARGETS_DEFAULT_ARGS} ) -########### kdostartupconfig ############### - -set(kdostartupconfig_SRCS kdostartupconfig.cpp ) - -add_executable(kdostartupconfig4 ${kdostartupconfig_SRCS}) - -target_link_libraries(kdostartupconfig4 ${KDE4_KDECORE_LIBS} ) - -install(TARGETS kdostartupconfig4 ${INSTALL_TARGETS_DEFAULT_ARGS} ) - diff --git a/kstartupconfig/kstartupconfig.c b/kstartupconfig/kstartupconfig.c deleted file mode 100644 index 9c356f0c..00000000 --- a/kstartupconfig/kstartupconfig.c +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** - - Copyright (C) 2005 Lubos Lunak - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - -****************************************************************************/ - -/* - -This utility helps to have some configuration options available in startkde -without the need to launch anything linked to KDE libraries (which may need -some time to load). - -The configuration options are written to $KDEHOME/share/config/startupconfigkeys, -one option per line, as . It is possible to -use ' for quoting multiword entries. Values of these options will be written -to $KDEHOME/share/config/startupconfig as a shell script that will set -the values to shell variables, named __ (all spaces replaced -by underscores, everything lowercase). So e.g. line -"ksplashrc KSplash Theme Default" may result in "ksplashrc_ksplash_theme=Default". - -In order to real a whole group it is possible to use <[group]>, e.g. -"ksplashrc [KSplash]", which will set shell variables for all keys in the group. -It is not possible to specify default values, but since the configuration options -are processed in the order they are specified this can be solved by first -specifying a group and then all the entries that need default values. - -When a kconf_update script is used to update such option, kstartupconfig is run -before kconf_update and therefore cannot see the change in time. To avoid this -problem, together with the kconf_update script also the matching global config -file should be updated (any change, kstartupconfig will see the timestamp change). - -Note that the kdeglobals config file is not used as a depedendency for other config -files. - -Since the checking is timestamp-based, config files that are frequently updated -should not be used. - -Kstartupconfig works by storing every line from startupconfigkeys in file startupconfigfiles -followed by paths of all files that are relevant to the option. Non-existent files -have '!' prepended (for the case they'll be later created), the list of files is -terminated by line containing '*'. If the timestamps of all relevant files are older -than the timestamp of the startupconfigfile file, there's no need to update anything. -Otherwise kdostartupconfig is launched to create or update all the necessary files -(which already requires loading KDE libraries, but this case should be rare). - -*/ - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -int main() - { - time_t config_time; - FILE* config; - FILE* keys; - struct stat st; - char kdehome[ 1024 ]; - char filename[ 1024 ]; - - if( getenv( "KDEHOME" )) - strlcpy( kdehome, getenv( "KDEHOME" ), 1024 ); - else if( getenv( "HOME" )) - { - strlcpy( kdehome, getenv( "HOME" ), 1024 ); - strlcat( kdehome, "/" KDE_DEFAULT_HOME, 1024 ); - } - else - return 1; - strlcpy( filename, kdehome, 1024 ); - strlcat( filename, "/share/config/startupconfig", 1024 ); - if( access( filename, R_OK ) != 0 ) - goto doit; - strlcpy( filename, kdehome, 1024 ); - strlcat( filename, "/share/config/startupconfigfiles", 1024 ); - if( stat( filename, &st ) != 0 ) - goto doit; - config_time = st.st_mtime; - config = fopen( filename, "r" ); - if( config == NULL ) - goto doit; - strlcpy( filename, kdehome, 1024 ); - strlcat( filename, "/share/config/startupconfigkeys", 1024 ); - keys = fopen( filename, "r" ); - if( keys == NULL ) - return 2; - for(;;) - { - char* nl; - char keyline[ 1024 ]; - char line[ 1024 ]; - - if( fgets( keyline, 1023, keys ) == NULL ) - return 0; - if( (nl = strchr( keyline, '\n' )) ) - *nl = '\0'; - if( fgets( line, 1023, config ) == NULL ) - break; - if( (nl = strchr( line, '\n' )) ) - *nl = '\0'; - if( strcmp( keyline, line ) != 0 ) - break; - for(;;) - { - if( fgets( line, 1023, config ) == NULL ) - goto doit2; - if( (nl = strchr( line, '\n' )) ) - *nl = '\0'; - if( *line == '\0' ) - goto doit2; - if( *line == '*' ) - break; - if( *line == '!' ) - { - if( access( line + 1, R_OK ) == 0 ) - goto doit2; /* file now exists -> update */ - } - else - { - if( stat( line, &st ) != 0 ) - goto doit2; - if( st.st_mtime > config_time ) - goto doit2; - } - } - } - doit2: - fclose( keys ); - fclose( config ); - doit: - return system( "kdostartupconfig4" ); - } diff --git a/kstartupconfig/kdostartupconfig.cpp b/kstartupconfig/kstartupconfig.cpp similarity index 100% rename from kstartupconfig/kdostartupconfig.cpp rename to kstartupconfig/kstartupconfig.cpp -- 2.11.0