Browse Source

* removed lib/libsde-ini.in and ini code from lib/libsde.in, because it's

superseded by bin/sde-config-ini helper.


git-svn-id: svn://svn.opensde.net/opensde/opensde/trunk@21683 10447126-35f2-4685-b0cf-6dd780d3921f
misl/sde-wrapper
Alejandro Mery 17 years ago
parent
commit
0fd08c6088
2 changed files with 0 additions and 114 deletions
  1. +0
    -83
      lib/libsde-ini.in
  2. +0
    -31
      lib/libsde.in

+ 0
- 83
lib/libsde-ini.in

@ -1,83 +0,0 @@
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: lib/libsde-ini.in
# Copyright (C) 2006 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
# this file has to be sourced only by tools which really want to
# write ini formated files. reading methods are available at libsde.in
# writes a list of variables into a section of an ini file
# USAGE: ini_write "file" "section" var1 var2 var3 ...
#
ini_write() {
local file="$1" section="$2" var= c=
local tmpfile=
shift 2
# something to write?
[ $# -gt 0 ] || return
# make sure the file exists
[ -f "$file" ] || touch "$file"
tmpfile="$file.$$"
# FIXME: a lock may be needed
if grep -q "^\[$section\][ \t]*$" "$file"; then
# known section
#
#FIXME: better performance may be required
# split the file
rm -rf $tmpfile.{0,1,2}
gawk "BEGIN { level=0; }
/^\[/ {
if ( level == 0 && \$0 ~ /^\[$section\][ \t]*\$/ )
level=1;
else if ( level == 1 )
level=2;
}
{ print > \"$tmpfile.\" level }
" "$file"
# remove empty lines
sed -i -e '/^[ \t]*$/d;' $tmpfile.1
# edit the section
for var; do
if grep -q "^$var=" $tmpfile.1; then
sed -i -e "s|^$var=.*|$var=$( eval echo \$$var )|" $tmpfile.1
else
echo "$var=$( eval echo \$$var )" >> $tmpfile.1
fi
done
# and finally write the new file!
(
cat $tmpfile.0
cat $tmpfile.1
if [ -s $tmpfile.2 ]; then
echo
cat $tmpfile.2
fi
) > "$file"
rm -rf $tmpfile.{0,1,2}
else
# new section
#
echo -e "\n[$section]" >> "$file"
for var; do
echo "$var=$( eval echo \$$var )"
done >> "$file"
fi
}

+ 0
- 31
lib/libsde.in

@ -46,34 +46,3 @@ unlock() {
rm "$1.lock"
}
# INI format functions
# NOTE: if you want to write, source libsde-ini.in too.
# dumps the raw content of a section
# USAGE: ini_section_raw "file" "section"
#
ini_section_raw() {
gawk "BEGIN { show=0; }
/^\[/ {
if ( \$0 ~ /^\[$2\][ \t]*\$/ )
show=1;
else
show=0;
}
/^[^\[]/ { if ( show ) print; }" "$1"
}
# dumps the content of a section assuming variables are defined in there
# USAGE: ini_section_read "file" "section"
#
ini_section_read() {
ini_section_raw "$1" "$2" | sed -e '/^[ \t]*#/d;' -e '/^[ \t]*$/d;' -e 's,",\\",g' -e 's,=\(..*\)$,="\1",'
}
# list the available sections on a file
# USAGE: ini_section_list "file"
#
ini_section_list() {
sed -n -e 's,^\[\(.*\)\][ \t]*$,\1,p' "$1"
}

Loading…
Cancel
Save