summaryrefslogtreecommitdiff
path: root/inc/confutils.php
diff options
context:
space:
mode:
authorGina Haeussge <osd@foosel.net>2009-02-28 14:04:23 +0100
committerGina Haeussge <osd@foosel.net>2009-02-28 14:04:23 +0100
commitedcb01e585240a0977dded101c5e715aa365e9df (patch)
tree69fd95ea811c219d6137ccce1a334bb8c7d8925f /inc/confutils.php
parentaa5a29376d31a6787c8fa1025af1d1fb4d64dec8 (diff)
downloadrpg-edcb01e585240a0977dded101c5e715aa365e9df.tar.gz
rpg-edcb01e585240a0977dded101c5e715aa365e9df.tar.bz2
Split confToHash into confToHash and linesToHash
New function linesToHash (which now is used by existing function confToHash) allows for parsing of given strings into a config hash. darcs-hash:20090228130423-2b4f5-e4f08c80350d83d3d93a4652aa8db1aae96e3a13.gz
Diffstat (limited to 'inc/confutils.php')
-rw-r--r--inc/confutils.php27
1 files changed, 21 insertions, 6 deletions
diff --git a/inc/confutils.php b/inc/confutils.php
index 14b2ad727..aab0be4be 100644
--- a/inc/confutils.php
+++ b/inc/confutils.php
@@ -123,19 +123,16 @@ function getSchemes() {
}
/**
- * Builds a hash from a configfile
+ * Builds a hash from an array of lines
*
* If $lower is set to true all hash keys are converted to
* lower case.
*
* @author Harry Fuecks <hfuecks@gmail.com>
* @author Andreas Gohr <andi@splitbrain.org>
+ * @author Gina Haeussge <gina@foosel.net>
*/
-function confToHash($file,$lower=false) {
- $conf = array();
- $lines = @file( $file );
- if ( !$lines ) return $conf;
-
+function linesToHash($lines, $lower=false) {
foreach ( $lines as $line ) {
//ignore comments (except escaped ones)
$line = preg_replace('/(?<![&\\\\])#.*$/','',$line);
@@ -155,6 +152,24 @@ function confToHash($file,$lower=false) {
}
/**
+ * Builds a hash from a configfile
+ *
+ * If $lower is set to true all hash keys are converted to
+ * lower case.
+ *
+ * @author Harry Fuecks <hfuecks@gmail.com>
+ * @author Andreas Gohr <andi@splitbrain.org>
+ * @author Gina Haeussge <gina@foosel.net>
+ */
+function confToHash($file,$lower=false) {
+ $conf = array();
+ $lines = @file( $file );
+ if ( !$lines ) return $conf;
+
+ return linesToHash($lines, $lower);
+}
+
+/**
* Retrieve the requested configuration information
*
* @author Chris Smith <chris@jalakai.co.uk>