summaryrefslogtreecommitdiffstats
path: root/libconfig
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2008-04-14 21:52:55 -0400
committerBrian Cully <github.20.shmit@spamgourmet.com>2008-04-14 21:52:55 -0400
commit6ba98a9f9f48e13738d9736cba9c45b5e94f42f2 (patch)
tree86d7c281bcdbf67eb53cee064aa905e740ec5ccf /libconfig
downloadnastd-6ba98a9f9f48e13738d9736cba9c45b5e94f42f2.tar.gz
nastd-6ba98a9f9f48e13738d9736cba9c45b5e94f42f2.zip
Initial import
Diffstat (limited to 'libconfig')
-rw-r--r--libconfig/.cvsignore15
-rw-r--r--libconfig/.pure0
-rw-r--r--libconfig/.svn/README.txt2
-rw-r--r--libconfig/.svn/empty-file0
-rw-r--r--libconfig/.svn/entries202
-rw-r--r--libconfig/.svn/format1
-rw-r--r--libconfig/.svn/prop-base/.cvsignore.svn-base1
-rw-r--r--libconfig/.svn/prop-base/.pure.svn-base1
-rw-r--r--libconfig/.svn/prop-base/ArrayData.h.svn-base1
-rw-r--r--libconfig/.svn/prop-base/ArrayData.m.svn-base1
-rw-r--r--libconfig/.svn/prop-base/BuffIO.h.svn-base1
-rw-r--r--libconfig/.svn/prop-base/BuffIO.m.svn-base1
-rw-r--r--libconfig/.svn/prop-base/COPYRIGHT.svn-base1
-rw-r--r--libconfig/.svn/prop-base/Data.h.svn-base1
-rw-r--r--libconfig/.svn/prop-base/Data.m.svn-base1
-rw-r--r--libconfig/.svn/prop-base/DictData.h.svn-base1
-rw-r--r--libconfig/.svn/prop-base/DictData.m.svn-base1
-rw-r--r--libconfig/.svn/prop-base/Makefile.svn-base1
-rw-r--r--libconfig/.svn/prop-base/NumData.h.svn-base1
-rw-r--r--libconfig/.svn/prop-base/NumData.m.svn-base1
-rw-r--r--libconfig/.svn/prop-base/Parser.h.svn-base1
-rw-r--r--libconfig/.svn/prop-base/Parser.m.svn-base1
-rw-r--r--libconfig/.svn/prop-base/String.h.svn-base1
-rw-r--r--libconfig/.svn/prop-base/String.m.svn-base1
-rw-r--r--libconfig/.svn/prop-base/StringData.h.svn-base1
-rw-r--r--libconfig/.svn/prop-base/StringData.m.svn-base1
-rw-r--r--libconfig/.svn/prop-base/config.m.svn-base1
-rw-r--r--libconfig/.svn/props/.cvsignore.svn-work1
-rw-r--r--libconfig/.svn/props/.pure.svn-work1
-rw-r--r--libconfig/.svn/props/ArrayData.h.svn-work1
-rw-r--r--libconfig/.svn/props/ArrayData.m.svn-work1
-rw-r--r--libconfig/.svn/props/BuffIO.h.svn-work1
-rw-r--r--libconfig/.svn/props/BuffIO.m.svn-work1
-rw-r--r--libconfig/.svn/props/COPYRIGHT.svn-work1
-rw-r--r--libconfig/.svn/props/Data.h.svn-work1
-rw-r--r--libconfig/.svn/props/Data.m.svn-work1
-rw-r--r--libconfig/.svn/props/DictData.h.svn-work1
-rw-r--r--libconfig/.svn/props/DictData.m.svn-work1
-rw-r--r--libconfig/.svn/props/Makefile.svn-work1
-rw-r--r--libconfig/.svn/props/NumData.h.svn-work1
-rw-r--r--libconfig/.svn/props/NumData.m.svn-work1
-rw-r--r--libconfig/.svn/props/Parser.h.svn-work1
-rw-r--r--libconfig/.svn/props/Parser.m.svn-work1
-rw-r--r--libconfig/.svn/props/String.h.svn-work1
-rw-r--r--libconfig/.svn/props/String.m.svn-work1
-rw-r--r--libconfig/.svn/props/StringData.h.svn-work1
-rw-r--r--libconfig/.svn/props/StringData.m.svn-work1
-rw-r--r--libconfig/.svn/props/config.m.svn-work1
-rw-r--r--libconfig/.svn/text-base/.cvsignore.svn-base15
-rw-r--r--libconfig/.svn/text-base/.pure.svn-base0
-rw-r--r--libconfig/.svn/text-base/ArrayData.h.svn-base44
-rw-r--r--libconfig/.svn/text-base/ArrayData.m.svn-base161
-rw-r--r--libconfig/.svn/text-base/BuffIO.h.svn-base49
-rw-r--r--libconfig/.svn/text-base/BuffIO.m.svn-base96
-rw-r--r--libconfig/.svn/text-base/COPYRIGHT.svn-base27
-rw-r--r--libconfig/.svn/text-base/Data.h.svn-base62
-rw-r--r--libconfig/.svn/text-base/Data.m.svn-base92
-rw-r--r--libconfig/.svn/text-base/DictData.h.svn-base47
-rw-r--r--libconfig/.svn/text-base/DictData.m.svn-base210
-rw-r--r--libconfig/.svn/text-base/Makefile.svn-base11
-rw-r--r--libconfig/.svn/text-base/NumData.h.svn-base39
-rw-r--r--libconfig/.svn/text-base/NumData.m.svn-base74
-rw-r--r--libconfig/.svn/text-base/Parser.h.svn-base42
-rw-r--r--libconfig/.svn/text-base/Parser.m.svn-base95
-rw-r--r--libconfig/.svn/text-base/String.h.svn-base46
-rw-r--r--libconfig/.svn/text-base/String.m.svn-base82
-rw-r--r--libconfig/.svn/text-base/StringData.h.svn-base41
-rw-r--r--libconfig/.svn/text-base/StringData.m.svn-base117
-rw-r--r--libconfig/.svn/text-base/config.m.svn-base287
-rw-r--r--libconfig/ArrayData.h44
-rw-r--r--libconfig/ArrayData.m161
-rw-r--r--libconfig/BuffIO.h49
-rw-r--r--libconfig/BuffIO.m96
-rw-r--r--libconfig/COPYRIGHT27
-rw-r--r--libconfig/Data.h62
-rw-r--r--libconfig/Data.m92
-rw-r--r--libconfig/DictData.h47
-rw-r--r--libconfig/DictData.m210
-rw-r--r--libconfig/Makefile11
-rw-r--r--libconfig/NumData.h39
-rw-r--r--libconfig/NumData.m74
-rw-r--r--libconfig/Parser.h42
-rw-r--r--libconfig/Parser.m95
-rw-r--r--libconfig/String.h46
-rw-r--r--libconfig/String.m82
-rw-r--r--libconfig/StringData.h41
-rw-r--r--libconfig/StringData.m117
-rw-r--r--libconfig/config.m287
88 files changed, 3521 insertions, 0 deletions
diff --git a/libconfig/.cvsignore b/libconfig/.cvsignore
new file mode 100644
index 0000000..afcbfe8
--- /dev/null
+++ b/libconfig/.cvsignore
@@ -0,0 +1,15 @@
+radiusd
+radctl
+radpass
+radpwtst
+radacct
+radterminate
+radiusd.pid
+radiusd.core
+Makefiles/os/target
+*.o
+*.so
+*.a
+*.core
+*.gmon
+tags
diff --git a/libconfig/.pure b/libconfig/.pure
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/libconfig/.pure
diff --git a/libconfig/.svn/README.txt b/libconfig/.svn/README.txt
new file mode 100644
index 0000000..271a8ce
--- /dev/null
+++ b/libconfig/.svn/README.txt
@@ -0,0 +1,2 @@
+This is a Subversion working copy administrative directory.
+Visit http://subversion.tigris.org/ for more information.
diff --git a/libconfig/.svn/empty-file b/libconfig/.svn/empty-file
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/libconfig/.svn/empty-file
diff --git a/libconfig/.svn/entries b/libconfig/.svn/entries
new file mode 100644
index 0000000..8a68b21
--- /dev/null
+++ b/libconfig/.svn/entries
@@ -0,0 +1,202 @@
+<?xml version="1.0" encoding="utf-8"?>
+<wc-entries
+ xmlns="svn:">
+<entry
+ committed-rev="1"
+ name=""
+ committed-date="2005-12-08T17:32:07.572093Z"
+ url="svn+ssh://coleridge/svn/nastd/trunk/libconfig"
+ last-author="bjc"
+ kind="dir"
+ uuid="2641c99b-6c07-0410-920d-927397d2d5d0"
+ revision="8"/>
+<entry
+ committed-rev="1"
+ name="NumData.h"
+ text-time="2005-12-24T00:01:00.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="f0bc8bcac885c33fae6b388cbdb2993b"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:57.000000Z"/>
+<entry
+ committed-rev="1"
+ name="Parser.h"
+ text-time="2005-12-24T00:01:00.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="7b1df589d7cf17b360f454ea5a8b8a75"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:57.000000Z"/>
+<entry
+ committed-rev="1"
+ name="NumData.m"
+ text-time="2005-12-24T00:01:00.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="d7d513d55f5b2f49a1c2a7c3f25c607d"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:57.000000Z"/>
+<entry
+ committed-rev="1"
+ name="StringData.h"
+ text-time="2005-12-24T00:01:00.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="b71ed77078d9ecdb0e1d35916ecd34c2"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:57.000000Z"/>
+<entry
+ committed-rev="1"
+ name="Parser.m"
+ text-time="2005-12-24T00:01:00.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="a53cf0bea060a85d392626f2c94743ec"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:57.000000Z"/>
+<entry
+ committed-rev="1"
+ name=".pure"
+ text-time="2005-12-24T00:01:01.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="d41d8cd98f00b204e9800998ecf8427e"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:58.000000Z"/>
+<entry
+ committed-rev="1"
+ name="StringData.m"
+ text-time="2005-12-24T00:01:01.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="11882741e1ffc0eaffcac8be00f66260"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:58.000000Z"/>
+<entry
+ committed-rev="1"
+ name="String.h"
+ text-time="2005-12-24T00:01:01.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="5b4aacb4740fc4011707463414825c1e"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:58.000000Z"/>
+<entry
+ committed-rev="1"
+ name="ArrayData.h"
+ text-time="2005-12-24T00:01:01.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="36413ddac4334f96f517dbb4c345233e"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:58.000000Z"/>
+<entry
+ committed-rev="1"
+ name="Data.h"
+ text-time="2005-12-24T00:01:01.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="03560d07811808854cd76458597260e1"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:58.000000Z"/>
+<entry
+ committed-rev="1"
+ name="config.m"
+ text-time="2005-12-24T00:01:02.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="96c499111fc8af7aa5d577175c0e686d"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:59.000000Z"/>
+<entry
+ committed-rev="1"
+ name="BuffIO.h"
+ text-time="2005-12-24T00:01:01.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="e965c2fafb52c388d7aca469112f1e77"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:58.000000Z"/>
+<entry
+ committed-rev="1"
+ name="String.m"
+ text-time="2005-12-24T00:01:02.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="c1e8fe9a7cb472bb543a4ff3c08e7357"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:59.000000Z"/>
+<entry
+ committed-rev="1"
+ name="ArrayData.m"
+ text-time="2005-12-24T00:01:02.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="6e30e0b55fa6a60befe3d7b3b11613d0"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:59.000000Z"/>
+<entry
+ committed-rev="1"
+ name="DictData.h"
+ text-time="2005-12-24T00:01:02.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="8fea54e50780f21f4cb95ee16a402f05"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:59.000000Z"/>
+<entry
+ committed-rev="1"
+ name="Data.m"
+ text-time="2005-12-24T00:01:02.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="d1d9d9dd062f32cdf17168e1b1be86d6"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:59.000000Z"/>
+<entry
+ committed-rev="1"
+ name="BuffIO.m"
+ text-time="2005-12-24T00:01:02.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="e6751ba80a47e13ed8ec55e568d6d9f3"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:59.000000Z"/>
+<entry
+ committed-rev="1"
+ name="DictData.m"
+ text-time="2005-12-24T00:01:02.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="3db081896c8282d290e88914619cdff1"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:00:59.000000Z"/>
+<entry
+ committed-rev="1"
+ name="COPYRIGHT"
+ text-time="2005-12-24T00:01:02.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="f8d5134885de20571cd0b6ca9a3313d8"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:01:00.000000Z"/>
+<entry
+ committed-rev="1"
+ name="Makefile"
+ text-time="2005-12-24T00:01:03.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="484e04bcaacde2d0cf55dc18f8a9a799"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:01:00.000000Z"/>
+<entry
+ committed-rev="1"
+ name=".cvsignore"
+ text-time="2005-12-24T00:01:03.000000Z"
+ committed-date="2005-12-08T17:32:07.572093Z"
+ checksum="11c2ac373f2d4ba2c5a696bd87529357"
+ last-author="bjc"
+ kind="file"
+ prop-time="2005-12-24T00:01:00.000000Z"/>
+</wc-entries>
diff --git a/libconfig/.svn/format b/libconfig/.svn/format
new file mode 100644
index 0000000..b8626c4
--- /dev/null
+++ b/libconfig/.svn/format
@@ -0,0 +1 @@
+4
diff --git a/libconfig/.svn/prop-base/.cvsignore.svn-base b/libconfig/.svn/prop-base/.cvsignore.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/.cvsignore.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/.pure.svn-base b/libconfig/.svn/prop-base/.pure.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/.pure.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/ArrayData.h.svn-base b/libconfig/.svn/prop-base/ArrayData.h.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/ArrayData.h.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/ArrayData.m.svn-base b/libconfig/.svn/prop-base/ArrayData.m.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/ArrayData.m.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/BuffIO.h.svn-base b/libconfig/.svn/prop-base/BuffIO.h.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/BuffIO.h.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/BuffIO.m.svn-base b/libconfig/.svn/prop-base/BuffIO.m.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/BuffIO.m.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/COPYRIGHT.svn-base b/libconfig/.svn/prop-base/COPYRIGHT.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/COPYRIGHT.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/Data.h.svn-base b/libconfig/.svn/prop-base/Data.h.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/Data.h.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/Data.m.svn-base b/libconfig/.svn/prop-base/Data.m.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/Data.m.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/DictData.h.svn-base b/libconfig/.svn/prop-base/DictData.h.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/DictData.h.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/DictData.m.svn-base b/libconfig/.svn/prop-base/DictData.m.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/DictData.m.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/Makefile.svn-base b/libconfig/.svn/prop-base/Makefile.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/Makefile.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/NumData.h.svn-base b/libconfig/.svn/prop-base/NumData.h.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/NumData.h.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/NumData.m.svn-base b/libconfig/.svn/prop-base/NumData.m.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/NumData.m.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/Parser.h.svn-base b/libconfig/.svn/prop-base/Parser.h.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/Parser.h.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/Parser.m.svn-base b/libconfig/.svn/prop-base/Parser.m.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/Parser.m.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/String.h.svn-base b/libconfig/.svn/prop-base/String.h.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/String.h.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/String.m.svn-base b/libconfig/.svn/prop-base/String.m.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/String.m.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/StringData.h.svn-base b/libconfig/.svn/prop-base/StringData.h.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/StringData.h.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/StringData.m.svn-base b/libconfig/.svn/prop-base/StringData.m.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/StringData.m.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/prop-base/config.m.svn-base b/libconfig/.svn/prop-base/config.m.svn-base
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/prop-base/config.m.svn-base
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/.cvsignore.svn-work b/libconfig/.svn/props/.cvsignore.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/.cvsignore.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/.pure.svn-work b/libconfig/.svn/props/.pure.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/.pure.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/ArrayData.h.svn-work b/libconfig/.svn/props/ArrayData.h.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/ArrayData.h.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/ArrayData.m.svn-work b/libconfig/.svn/props/ArrayData.m.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/ArrayData.m.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/BuffIO.h.svn-work b/libconfig/.svn/props/BuffIO.h.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/BuffIO.h.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/BuffIO.m.svn-work b/libconfig/.svn/props/BuffIO.m.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/BuffIO.m.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/COPYRIGHT.svn-work b/libconfig/.svn/props/COPYRIGHT.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/COPYRIGHT.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/Data.h.svn-work b/libconfig/.svn/props/Data.h.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/Data.h.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/Data.m.svn-work b/libconfig/.svn/props/Data.m.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/Data.m.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/DictData.h.svn-work b/libconfig/.svn/props/DictData.h.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/DictData.h.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/DictData.m.svn-work b/libconfig/.svn/props/DictData.m.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/DictData.m.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/Makefile.svn-work b/libconfig/.svn/props/Makefile.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/Makefile.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/NumData.h.svn-work b/libconfig/.svn/props/NumData.h.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/NumData.h.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/NumData.m.svn-work b/libconfig/.svn/props/NumData.m.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/NumData.m.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/Parser.h.svn-work b/libconfig/.svn/props/Parser.h.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/Parser.h.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/Parser.m.svn-work b/libconfig/.svn/props/Parser.m.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/Parser.m.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/String.h.svn-work b/libconfig/.svn/props/String.h.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/String.h.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/String.m.svn-work b/libconfig/.svn/props/String.m.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/String.m.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/StringData.h.svn-work b/libconfig/.svn/props/StringData.h.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/StringData.h.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/StringData.m.svn-work b/libconfig/.svn/props/StringData.m.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/StringData.m.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/props/config.m.svn-work b/libconfig/.svn/props/config.m.svn-work
new file mode 100644
index 0000000..dce2c1d
--- /dev/null
+++ b/libconfig/.svn/props/config.m.svn-work
@@ -0,0 +1 @@
+END
diff --git a/libconfig/.svn/text-base/.cvsignore.svn-base b/libconfig/.svn/text-base/.cvsignore.svn-base
new file mode 100644
index 0000000..afcbfe8
--- /dev/null
+++ b/libconfig/.svn/text-base/.cvsignore.svn-base
@@ -0,0 +1,15 @@
+radiusd
+radctl
+radpass
+radpwtst
+radacct
+radterminate
+radiusd.pid
+radiusd.core
+Makefiles/os/target
+*.o
+*.so
+*.a
+*.core
+*.gmon
+tags
diff --git a/libconfig/.svn/text-base/.pure.svn-base b/libconfig/.svn/text-base/.pure.svn-base
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/libconfig/.svn/text-base/.pure.svn-base
diff --git a/libconfig/.svn/text-base/ArrayData.h.svn-base b/libconfig/.svn/text-base/ArrayData.h.svn-base
new file mode 100644
index 0000000..246803e
--- /dev/null
+++ b/libconfig/.svn/text-base/ArrayData.h.svn-base
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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 ARRAYDATA_H
+# define ARRAYDATA_H
+
+#include "Data.h"
+
+@interface ArrayData: DataObject
+{
+ id *data;
+ int numChildren;
+ int curObj;
+}
+-free;
+-(int)numObjects;
+-addChild: child;
+-objectAt: (int)index;
+@end
+#endif
diff --git a/libconfig/.svn/text-base/ArrayData.m.svn-base b/libconfig/.svn/text-base/ArrayData.m.svn-base
new file mode 100644
index 0000000..dfee1e7
--- /dev/null
+++ b/libconfig/.svn/text-base/ArrayData.m.svn-base
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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.
+ */
+#include "ArrayData.h"
+#include "Parser.h"
+#include "String.h"
+
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+@implementation ArrayData
+-init
+{
+ self = [super init];
+
+ numChildren = 0;
+ curObj = 0;
+ data = malloc(MALLOC_GRANULARITY * sizeof(DictEntry *));
+ if (!data) {
+ fprintf(stderr, "ERROR: couldn't allocate memory: %s.\n",
+ strerror(errno));
+ return nil;
+ }
+
+ return self;
+}
+
+-free
+{
+ int i;
+
+ fprintf(stderr, "DEBUG: freeing array\n");
+ for (i = 0; i < numChildren; i++)
+ [data[i] free];
+ free(data);
+ [super free];
+
+ return nil;
+}
+
+-addChild: child
+{
+ /* Allocate additional space for children pointers, if required. */
+ if (numChildren % MALLOC_GRANULARITY == 0) {
+ /* TODO: fail gracefully. */
+ data = realloc(data, (numChildren+MALLOC_GRANULARITY) *
+ sizeof(DataObject *));
+ if (!data) {
+ fprintf(stderr,
+ "ERROR: couldn't allocate memory: %s.\n",
+ strerror(errno));
+ return nil;
+ }
+ }
+
+ data[numChildren] = child;
+
+ numChildren++;
+ return self;
+}
+
+-setFromBuffer: (const char *)buffer withLength: (int)len
+{
+ Parser *parser;
+ String *string;
+ const char *offset;
+
+ self = [super init];
+ parser = [Parser new];
+ string = [[String new] init];
+ if (parser == nil || string == nil)
+ return nil;
+
+ if (buffer[len] == '\0')
+ len--;
+
+ /* Skip any leading white space. */
+ for (offset = buffer; offset <= buffer+len && isspace((int)*offset);
+ offset++);
+ /* Kill any ending white space. */
+ for (; len >= 0 && isspace((int)buffer[len]); len--);
+
+ /* If there's a leading brace, kill it and the ending one. */
+ if (offset[0] == '[') {
+ if (buffer[len] != ']') {
+ fprintf(stderr, "ERROR: Unbalanced braces.\n");
+ [parser free]; [string free];
+ return nil;
+ }
+ offset++; len--;
+
+ /* Do the whitespace shuffle again. */
+ for (; len >= 0 && isspace((int)buffer[len]); len--);
+ }
+
+ while (offset < buffer+len) {
+ DataObject *dataObj;
+ int strLen;
+
+ /* Do the whitespace shuffle. */
+ for (; offset <= buffer+len && isspace((int)*offset); offset++);
+
+ strLen = [parser getLineLenFrom: offset to: buffer+len];
+ [string setStr: offset withLength: strLen];
+ offset += strLen + 1;
+
+ /* Parse the data element, then add it to our list. */
+ dataObj = [parser getDataFrom: string];
+ if (dataObj == nil) {
+ [parser free]; [string free];
+ return nil;
+ }
+ [self addChild: dataObj];
+ }
+
+ [parser free]; [string free];
+ return self;
+}
+
+-(int)
+numObjects
+{
+ return numChildren;
+}
+
+-objectAt: (int)index
+{
+ if (index >= numChildren)
+ return nil;
+ return data[index];
+}
+@end
diff --git a/libconfig/.svn/text-base/BuffIO.h.svn-base b/libconfig/.svn/text-base/BuffIO.h.svn-base
new file mode 100644
index 0000000..d58a0a3
--- /dev/null
+++ b/libconfig/.svn/text-base/BuffIO.h.svn-base
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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 BUFFIO_H
+# define BUFFIO_H
+
+#include <Object.h>
+
+#include <sys/types.h>
+
+@interface BuffIO: Object
+{
+ char *file;
+ char *curOff;
+ off_t fileLen;
+ char EOL;
+}
+
+-init: (const char *)fileName;
+-free;
+-(char *)getCurOff;
+-(off_t)getLength;
+-setEOL: (char)delim;
+@end
+#endif
diff --git a/libconfig/.svn/text-base/BuffIO.m.svn-base b/libconfig/.svn/text-base/BuffIO.m.svn-base
new file mode 100644
index 0000000..f7a5408
--- /dev/null
+++ b/libconfig/.svn/text-base/BuffIO.m.svn-base
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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.
+ */
+
+#include "BuffIO.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+@implementation BuffIO
+-init: (const char *)fileName
+{
+ struct stat sb;
+ int confFd;
+
+ confFd = open(fileName, O_RDONLY, 0);
+ if (confFd == -1) {
+ fprintf(stderr, "ERROR: couldn't open config file %s: %s.\n",
+ fileName, strerror(errno));
+ return nil;
+ }
+ if (fstat(confFd, &sb) == -1) {
+ fprintf(stderr, "ERROR: couldn't stat config file %s: %s.\n",
+ fileName, strerror(errno));
+ return nil;
+ }
+ fileLen = sb.st_size;
+ file = mmap(NULL, fileLen, PROT_READ, MAP_PRIVATE, confFd, 0);
+ if (file == MAP_FAILED) {
+ fprintf(stderr, "ERROR: couldn't mmap config file %s: %s.\n",
+ fileName, strerror(errno));
+ return nil;
+ }
+ close(confFd);
+
+ curOff = file;
+ EOL = '\n';
+
+ return self;
+}
+
+-free
+{
+ munmap(file, fileLen);
+ return [super free];
+}
+
+-(char *)
+getCurOff
+{
+ return curOff;
+}
+
+-(off_t)
+getLength
+{
+ return fileLen;
+}
+
+-setEOL: (char)delim
+{
+ EOL = delim;
+ return self;
+}
+@end
diff --git a/libconfig/.svn/text-base/COPYRIGHT.svn-base b/libconfig/.svn/text-base/COPYRIGHT.svn-base
new file mode 100644
index 0000000..a61dc39
--- /dev/null
+++ b/libconfig/.svn/text-base/COPYRIGHT.svn-base
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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.
+ */
diff --git a/libconfig/.svn/text-base/Data.h.svn-base b/libconfig/.svn/text-base/Data.h.svn-base
new file mode 100644
index 0000000..966310f
--- /dev/null
+++ b/libconfig/.svn/text-base/Data.h.svn-base
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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 DATA_H
+# define DATA_H
+
+#include "String.h"
+
+#include <Object.h>
+
+#include <sys/types.h>
+
+#define MALLOC_GRANULARITY 10 /* Malloc for every 10 entries. */
+
+/*
+ * Generic Entry and Data objects.
+ */
+@interface DataObject: Object
+-dealloc;
+-(char *)createCStr;
+-(String *)createStr;
+-setFromBuffer: (const char *)buffer withLength: (int)len;
+@end
+
+@interface DictEntry: Object
+{
+ String *key;
+ DataObject *data;
+ DictEntry *super;
+}
+
+-init;
+-setKey: keyName;
+-setData: dataPtr;
+-getKey;
+-getData;
+@end
+#endif
diff --git a/libconfig/.svn/text-base/Data.m.svn-base b/libconfig/.svn/text-base/Data.m.svn-base
new file mode 100644
index 0000000..3b48c7a
--- /dev/null
+++ b/libconfig/.svn/text-base/Data.m.svn-base
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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.
+ */
+#include "Data.h"
+#include "Parser.h"
+#include "String.h"
+
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+@implementation DataObject
+-dealloc
+{
+ free(self);
+ return nil;
+}
+
+-(char *)createCStr
+{
+ return NULL;
+}
+
+-(String *)createStr
+{
+ return nil;
+}
+
+-setFromBuffer: (const char *)buffer withLength: (int)len
+{
+ return self;
+}
+@end
+
+@implementation DictEntry
+-init
+{
+ self = [super init];
+ key = NULL; data = NULL;
+ return self;
+}
+
+-setKey: (String *)keyStr
+{
+ key = keyStr;
+ return self;
+}
+
+-setData: (DataObject *)dataPtr
+{
+ data = dataPtr;
+ return self;
+}
+
+-getKey
+{
+ return key;
+}
+
+-getData
+{
+ return data;
+}
+@end
diff --git a/libconfig/.svn/text-base/DictData.h.svn-base b/libconfig/.svn/text-base/DictData.h.svn-base
new file mode 100644
index 0000000..52dfc0d
--- /dev/null
+++ b/libconfig/.svn/text-base/DictData.h.svn-base
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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 DICTDATA_H
+# define DICTDATA_H
+
+#include "Data.h"
+
+@interface DictData: DataObject
+{
+ id *data;
+ int numChildren;
+ int curObj;
+}
+
+-free;
+-addChild: child;
+-delChild: (const char *)keyName;
+-findChild: (const char *)keyName;
+-firstObject;
+-nextObject;
+@end
+#endif
diff --git a/libconfig/.svn/text-base/DictData.m.svn-base b/libconfig/.svn/text-base/DictData.m.svn-base
new file mode 100644
index 0000000..8620d7c
--- /dev/null
+++ b/libconfig/.svn/text-base/DictData.m.svn-base
@@ -0,0 +1,210 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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.
+ */
+#include "DictData.h"
+#include "Parser.h"
+#include "String.h"
+
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+@implementation DictData
+-init
+{
+ self = [super init];
+
+ numChildren = 0;
+ curObj = 0;
+ data = malloc(MALLOC_GRANULARITY * sizeof(DataObject *));
+ if (!data) {
+ fprintf(stderr, "ERROR: couldn't allocate memory: %s.\n",
+ strerror(errno));
+ return nil;
+ }
+
+ return self;
+}
+
+-free
+{
+ int i;
+
+ fprintf(stderr, "DEBUG: freeing dict\n");
+ for (i = 0; i < numChildren; i++)
+ [data[i] free];
+ free(data);
+ [super free];
+
+ return nil;
+}
+
+-addChild: child
+{
+ /* Allocate additional space for children pointers, if required. */
+ if (numChildren % MALLOC_GRANULARITY == 0) {
+ /* TODO: fail gracefully. */
+ data = realloc(data, (numChildren+MALLOC_GRANULARITY) *
+ sizeof(DictEntry *));
+ if (!data) {
+ fprintf(stderr,
+ "ERROR: couldn't allocate memory: %s.\n",
+ strerror(errno));
+ return nil;
+ }
+ }
+
+ data[numChildren] = child;
+
+ numChildren++;
+ return self;
+}
+
+-setFromBuffer: (const char *)buffer withLength: (int)len
+{
+ Parser *parser;
+ String *string;
+ const char *offset;
+
+ self = [super init];
+ parser = [Parser new];
+ string = [[String new] init];
+ if (parser == nil || string == nil)
+ return nil;
+
+ if (buffer[len] == '\0')
+ len--;
+
+ /* Skip any leading white space. */
+ for (offset = buffer; offset <= buffer+len && isspace((int)*offset);
+ offset++);
+ /* Kill any ending white space. */
+ for (; len >= 0 && isspace((int)buffer[len]); len--);
+
+ /* If there's a leading brace, kill it and the ending one. */
+ if (offset[0] == '{') {
+ if (buffer[len] != '}') {
+ fprintf(stderr, "ERROR: Unbalanced braces.\n");
+ [parser free]; [string free];
+ return nil;
+ }
+ offset++; len--;
+
+ /* Do the whitespace shuffle again. */
+ for (; len >= 0 && isspace((int)buffer[len]); len--);
+ }
+
+ while (offset < buffer+len) {
+ DataObject *dataObj;
+ DictEntry *dictEntry;
+ String *key;
+ char *sep;
+ int strLen;
+
+ /* Do the whitespace shuffle. */
+ for (; offset <= buffer+len && isspace((int)*offset); offset++);
+
+ /* Get the key element. */
+ sep = strchr(offset, '=');
+ if (!sep) {
+ fprintf(stderr, "ERROR: No equals sign!\n");
+ return nil;
+ }
+ for (sep--; sep > offset && isspace((int)*sep); sep--);
+ key = [[[String new] init] setStr: offset
+ withLength: (sep-offset+1)];
+
+ /* Get the data element. */
+ offset = strchr(offset, '=');
+ for(offset++; offset < buffer+len && isspace((int)*offset);
+ offset++);
+ strLen = [parser getLineLenFrom: offset to: buffer+len];
+ [string setStr: offset withLength: strLen];
+ offset += strLen + 1;
+
+ /* Parse the data element, then add it to our list. */
+ dataObj = [parser getDataFrom: string];
+ if (dataObj == nil) {
+ fprintf(stderr,
+ "ERROR: Couldn't parse data for node `%s'.\n",
+ [key getStr]);
+ [parser free]; [string free];
+ return nil;
+ }
+
+ dictEntry = [[DictEntry new] setKey: key];
+ if (dictEntry == nil) {
+ fprintf(stderr,
+ "ERROR: Couldn't create node `%s'.\n",
+ [key getStr]);
+ [parser free]; [string free];
+ return nil;
+ }
+ [dictEntry setData: dataObj];
+ [self addChild: dictEntry];
+ }
+
+ [parser free]; [string free];
+ return self;
+}
+
+-delChild: (const char *)keyName
+{
+ return self;
+}
+
+-findChild: (const char *)keyName
+{
+ int i;
+
+ for (i = 0; i < numChildren; i++)
+ if (!strcmp([[data[i] getKey] getStr], keyName))
+ return data[i];
+ return nil;
+}
+
+-firstObject
+{
+ curObj = 0;
+ return [self nextObject];
+}
+
+-nextObject
+{
+ DictEntry *obj;
+
+ if (curObj >= numChildren)
+ return nil;
+ obj = data[curObj];
+ curObj++;
+ return obj;
+}
+@end
diff --git a/libconfig/.svn/text-base/Makefile.svn-base b/libconfig/.svn/text-base/Makefile.svn-base
new file mode 100644
index 0000000..9fca5ac
--- /dev/null
+++ b/libconfig/.svn/text-base/Makefile.svn-base
@@ -0,0 +1,11 @@
+# $Id: Makefile,v 1.1 2001/10/04 23:57:55 shmit Exp $
+
+CONFIGOBJS= ArrayData.o BuffIO.o Data.o DictData.o NumData.o Parser.o \
+ String.o StringData.o config.o
+
+libconfig.a: ${CONFIGOBJS}
+ ar r $@ ${CONFIGOBJS}
+ ranlib $@
+
+MKDIR= ../Makefiles
+include ${MKDIR}/build
diff --git a/libconfig/.svn/text-base/NumData.h.svn-base b/libconfig/.svn/text-base/NumData.h.svn-base
new file mode 100644
index 0000000..a8c2810
--- /dev/null
+++ b/libconfig/.svn/text-base/NumData.h.svn-base
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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 NUMDATA_H
+# define NUMDATA_H
+
+#include "Data.h"
+
+@interface NumData: DataObject
+{
+ long data;
+}
+-(long)getNum;
+@end
+#endif
diff --git a/libconfig/.svn/text-base/NumData.m.svn-base b/libconfig/.svn/text-base/NumData.m.svn-base
new file mode 100644
index 0000000..68f6bfa
--- /dev/null
+++ b/libconfig/.svn/text-base/NumData.m.svn-base
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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.
+ */
+#include "NumData.h"
+#include "Parser.h"
+#include "String.h"
+
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+@implementation NumData
+-init
+{
+ self = [super init];
+ return self;
+}
+
+-(String *)
+createStr
+{
+ char buffer[1024];
+
+ snprintf(buffer, sizeof(buffer), "%ld", data);
+ return [[String new] setStr: buffer];
+}
+
+-setFromBuffer: (const char *)buffer withLength: (int)len
+{
+ char *endPtr;
+
+ data = strtol(buffer, &endPtr, 0);
+ if (*endPtr) {
+ fprintf(stderr, "ERROR: `%s' is not a number.\n", buffer);
+ return nil;
+ }
+
+ return self;
+}
+
+-(long)
+getNum
+{
+ return data;
+}
+@end
diff --git a/libconfig/.svn/text-base/Parser.h.svn-base b/libconfig/.svn/text-base/Parser.h.svn-base
new file mode 100644
index 0000000..963a78a
--- /dev/null
+++ b/libconfig/.svn/text-base/Parser.h.svn-base
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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 PARSER_H
+# define PARSER_H
+
+#include "Data.h"
+#include "String.h"
+
+#include <Object.h>
+
+@interface Parser: Object
+-free;
+-init;
+-(DataObject *)getDataFrom: (String *)line;
+-(int)getLineLenFrom: (const char *)startAddr to: (const char *)endAddr;
+@end
+#endif
diff --git a/libconfig/.svn/text-base/Parser.m.svn-base b/libconfig/.svn/text-base/Parser.m.svn-base
new file mode 100644
index 0000000..f95cb3d
--- /dev/null
+++ b/libconfig/.svn/text-base/Parser.m.svn-base
@@ -0,0 +1,95 @@
+#include "Parser.h"
+#include "ArrayData.h"
+#include "DictData.h"
+#include "NumData.h"
+#include "StringData.h"
+#include "String.h"
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+@implementation Parser
+-(int)
+getLineLenFrom: (const char *)startAddr to: (const char *)endAddr
+{
+ int len;
+ char quote = '\0';
+ int frenchBraces = 0, squareBraces = 0;
+
+ for (len = 0; startAddr+len < endAddr; len++) {
+ if (!quote && !frenchBraces && !squareBraces &&
+ *(startAddr+len) == ';')
+ break;
+
+ switch (*(startAddr+len)) {
+ case '{':
+ frenchBraces++;
+ break;
+ case '}':
+ if (!frenchBraces)
+ fprintf(stderr,
+ "WARNING: found `}' without `{'.\n");
+ else
+ frenchBraces--;
+ break;
+ case '[':
+ squareBraces++;
+ break;
+ case ']':
+ if (!squareBraces)
+ fprintf(stderr,
+ "WARNING: found ']' without '['.\n");
+ else
+ squareBraces--;
+ break;
+ case '"':
+ if (!quote)
+ quote = *(startAddr+len);
+ else
+ quote = '\0';
+ break;
+ }
+ }
+
+ return len;
+}
+
+-init
+{
+ return self;
+}
+
+-free
+{
+ return [super free];
+}
+
+-(DataObject *)
+getDataFrom: (String *)dataStr
+{
+ const char *dataBuff;
+ id dataElem;
+
+ dataBuff = [dataStr getStr];
+
+ /* Figure out what type of node to allocate. */
+ switch (dataBuff[0]) {
+ case '{':
+ dataElem = [[DictData new] init];
+ break;
+ case '[':
+ dataElem = [[ArrayData new] init];
+ break;
+ case '"':
+ dataElem = [[StringData new] init];
+ break;
+ default:
+ dataElem = [[NumData new] init];
+ break;
+ }
+
+ return [dataElem setFromBuffer: dataBuff withLength: [dataStr getLen]];
+}
+@end
diff --git a/libconfig/.svn/text-base/String.h.svn-base b/libconfig/.svn/text-base/String.h.svn-base
new file mode 100644
index 0000000..ab0aaad
--- /dev/null
+++ b/libconfig/.svn/text-base/String.h.svn-base
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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 STRING_H
+# define STRING_H
+
+#include <Object.h>
+
+@interface String: Object
+{
+ char *data;
+ int len;
+}
+
+-init;
+-free;
+-setStr: (const char *)stringData withLength: (int)length;
+-setStr: (const char *)stringData;
+-(int)getLen;
+-(char *)getStr;
+@end
+#endif
diff --git a/libconfig/.svn/text-base/String.m.svn-base b/libconfig/.svn/text-base/String.m.svn-base
new file mode 100644
index 0000000..9a0bc5a
--- /dev/null
+++ b/libconfig/.svn/text-base/String.m.svn-base
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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.
+ */
+#include "String.h"
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+@implementation String
+-init
+{
+ self = [super init];
+ data = NULL;
+ return self;
+}
+
+-free
+{
+ free(data);
+ return [super free];
+}
+
+-setStr: (const char *)stringData withLength: (int)length
+{
+ if (data)
+ free(data);
+
+ data = malloc((length+1)*sizeof(char));
+ if (!data) {
+ fprintf(stderr, "ERROR: Couldn't allocate memory: %s.\n",
+ strerror(errno));
+ return nil;
+ }
+
+ memcpy(data, stringData, length);
+ data[length] = '\0';
+ len = length;
+ return self;
+}
+
+-setStr: (const char *)stringData
+{
+ return [self setStr: stringData withLength: strlen(stringData)];
+}
+
+-(int)
+getLen
+{
+ return len;
+}
+
+-(char *)
+getStr
+{
+ return data;
+}
+@end
diff --git a/libconfig/.svn/text-base/StringData.h.svn-base b/libconfig/.svn/text-base/StringData.h.svn-base
new file mode 100644
index 0000000..80c4d26
--- /dev/null
+++ b/libconfig/.svn/text-base/StringData.h.svn-base
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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 STRINGDATA_H
+# define STRINGDATA_H
+
+#include "Data.h"
+#include "String.h"
+
+@interface StringData: DataObject
+{
+ String *data;
+}
+
+-free;
+@end
+#endif
diff --git a/libconfig/.svn/text-base/StringData.m.svn-base b/libconfig/.svn/text-base/StringData.m.svn-base
new file mode 100644
index 0000000..1c02ac5
--- /dev/null
+++ b/libconfig/.svn/text-base/StringData.m.svn-base
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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.
+ */
+#include "conf.h"
+
+#include "StringData.h"
+#include "Parser.h"
+#include "String.h"
+
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+#if NEED_STRINGS
+#include <strings.h>
+#endif
+
+@implementation StringData
+-init
+{
+ self = [super init];
+ data = [[String new] init];
+ return self;
+}
+
+-free
+{
+ [data free];
+ [super free];
+ return self;
+}
+
+-(char *)
+createCStr
+{
+ char *buffer;
+
+ buffer = malloc(([data getLen]+1) * sizeof(char));
+ if (!buffer) {
+ fprintf(stderr, "ERROR: Couldn't allocate buffer: %s.\n",
+ strerror(errno));
+ return NULL;
+ }
+
+ strcpy(buffer, [data getStr]);
+ return buffer;
+}
+
+-(String *)
+createStr
+{
+ String *str;
+ char *buffer;
+
+ buffer = [self createCStr];
+ if (buffer == NULL)
+ return nil;
+
+ str = [[[String new] init] setStr: buffer];
+ free(buffer);
+
+ return str;
+}
+
+-setFromBuffer: (const char *)buffer withLength: (int)len
+{
+ const char *startPtr, *endPtr;
+
+ startPtr = index(buffer, '"');
+ if (!startPtr) {
+ fprintf(stderr, "ERROR: No opening quote for string.\n");
+ return nil;
+ }
+ startPtr++;
+
+ for (endPtr = buffer+len; endPtr > startPtr; endPtr--)
+ if (*endPtr == '"')
+ break;
+
+ if (endPtr == startPtr) {
+ fprintf(stderr, "ERROR: No ending quote for string.\n");
+ return nil;
+ }
+ endPtr--;
+
+ [data setStr: startPtr withLength: endPtr-startPtr+1];
+ return self;
+}
+@end
diff --git a/libconfig/.svn/text-base/config.m.svn-base b/libconfig/.svn/text-base/config.m.svn-base
new file mode 100644
index 0000000..b0d13a9
--- /dev/null
+++ b/libconfig/.svn/text-base/config.m.svn-base
@@ -0,0 +1,287 @@
+#include "conf.h"
+#include "config.h"
+#include "nastipc.h"
+#include "thread.h"
+
+#include "BuffIO.h"
+#include "ArrayData.h"
+#include "DictData.h"
+#include "NumData.h"
+#include "StringData.h"
+
+#include <netdb.h>
+#include <stdlib.h>
+
+RCSID("$Id: config.m,v 1.5 2001/11/09 15:54:38 shmit Exp $");
+
+/*
+ * Global variables.
+ */
+static DictData *root;
+char config_filen[MAXPATHLEN];
+struct nast_config config;
+
+static int
+config_read(const char *filename)
+{
+ BuffIO *confFile;
+
+ confFile = [[[BuffIO new] init: filename] setEOL: ';'];
+ if (confFile == nil) {
+ fprintf(stderr, "ERROR: Couldn't load config file.");
+ return -1;
+ }
+
+ root = [[DictData new] setFromBuffer: [confFile getCurOff]
+ withLength: [confFile getLength]];
+
+ /* We've duplicated all the data in here into private storage. */
+ [confFile free];
+
+ if (root == nil) {
+ fprintf(stderr, "ERROR: Couldn't parse config file.");
+ return -1;
+ }
+ return 0;
+}
+
+static int
+get_val(const char *name, void *dst, enum data_type type)
+{
+ id node;
+
+ node = [[root findChild: name] getData];
+ if (node == nil)
+ return 0;
+
+ switch (type) {
+ case NUMBER:
+ if (![node isKindOf: [NumData class]]) {
+ fprintf(stderr, "Node `%s' in `%s' should be a number.",
+ name, config_filen);
+ return -1;
+ }
+ *(int *)dst = [node getNum];
+ break;
+ case STRING:
+ if (![node isKindOf: [StringData class]]) {
+ fprintf(stderr, "Node `%s' in `%s' should be a string.",
+ name, config_filen);
+ return -1;
+ }
+ *(char **)dst = [node createCStr];
+ break;
+ case ARRAY:
+ fprintf(stderr, "ERROR: Can't load array into C yet.");
+ return -1;
+ case DICTIONARY:
+ fprintf(stderr, "ERROR: Can't load dictionary into C yet.");
+ return -1;
+ default:
+ fprintf(stderr, "ERROR: Don't know what to do with type `%d'.",
+ type);
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * Sets configuration variables to defaults, in case they're not set
+ * elsewhere.
+ */
+void
+config_setdefaults()
+{
+ /* Set the defaults. */
+ config.description = "Description not set in config file.";
+ config.nast_dir = DATADIR;
+ config.nast_sock = NASTHOLE;
+ config.nast_cdb_file = "nast.cdb";
+ config.mysql_host = DBHOST;
+ config.mysql_user = DBUSER;
+ config.mysql_pass = DBPASS;
+ config.nofork_flag = 0;
+ config.null_cache_timeout = 60;
+ config.tcp_port = 31337;
+
+ return;
+}
+
+/*
+ * Initializes configuration variables from config file.
+ */
+int
+config_init()
+{
+ snprintf(config_filen, sizeof(config_filen),
+ "%s/nastd.conf", config.nast_dir);
+ if (config_read(config_filen) == -1)
+ return -1;
+
+ /*
+ * Now grab all the top-level config information.
+ */
+ if (get_val("description", &config.description, STRING) == -1)
+ return -1;
+
+ if (get_val("nast_dir", &config.nast_dir, STRING) == -1)
+ return -1;
+
+ if (get_val("nast_sock", &config.nast_sock, STRING) == -1)
+ return -1;
+
+ if (get_val("nast_cdb_file", &config.nast_cdb_file, STRING) == -1)
+ return -1;
+
+ if (get_val("mysql_host", &config.mysql_host, STRING) == -1)
+ return -1;
+
+ if (get_val("mysql_user", &config.mysql_user, STRING) == -1)
+ return -1;
+
+ if (get_val("mysql_pass", &config.mysql_pass, STRING) == -1)
+ return -1;
+
+ if (get_val("null_cache_timeout", &config.null_cache_timeout,
+ NUMBER) == -1)
+ return -1;
+
+ if (get_val("tcp_port", &config.tcp_port, NUMBER) == -1)
+ return -1;
+
+ return 0;
+}
+
+void
+config_delete()
+{
+ [root free];
+}
+
+static enum data_type
+getctype(id node)
+{
+ if ([node isKindOf: [StringData class]])
+ return STRING;
+ else if ([node isKindOf: [NumData class]])
+ return NUMBER;
+ else if ([node isKindOf: [ArrayData class]])
+ return ARRAY;
+ else if ([node isKindOf: [DictData class]])
+ return DICTIONARY;
+ else {
+ return -1;
+ }
+}
+
+void *
+config_find(void *root_node, const char *name, enum data_type *type)
+{
+ id rootNode, dstNode;
+
+ if (root_node == NULL)
+ root_node = root;
+
+ rootNode = (id)root_node;
+ if ([rootNode isKindOf: [DictData class]] == NO) {
+ fprintf(stderr, "Trying to find `%s' in non-dictionary.", name);
+ return NULL;
+ }
+
+ dstNode = [[rootNode findChild: name] getData];
+ if (dstNode == nil)
+ return NULL;
+ *type = getctype(dstNode);
+ return dstNode;
+}
+
+void *
+config_arrayitemat(void *array, int index, enum data_type *type)
+{
+ id arrayNode, dstNode;
+
+ if (array == NULL)
+ return NULL;
+
+ arrayNode = (id)array;
+ if ([arrayNode isKindOf: [ArrayData class]] == NO) {
+ fprintf(stderr, "Trying to index in non-array.");
+ return NULL;
+ }
+
+ if (index >= [arrayNode numObjects])
+ return NULL;
+
+ dstNode = [arrayNode objectAt: index];
+ if (dstNode == nil)
+ return NULL;
+ *type = getctype(dstNode);
+ return dstNode;
+}
+
+void *
+config_dictitemat(void *dict, const char *name, enum data_type *type)
+{
+ id dictNode, dstNode;
+
+ if (dict == NULL)
+ return NULL;
+
+ dictNode = (id)dict;
+ if ([dictNode isKindOf: [DictData class]] == NO) {
+ fprintf(stderr, "Trying to find `%s' in non-dictionary.", name);
+ return NULL;
+ }
+
+ dstNode = [[dictNode findChild: name] getData];
+ if (dstNode == nil)
+ return NULL;
+ *type = getctype(dstNode);
+ return dstNode;
+}
+
+void *
+getdata(void *itemref, void *dst, enum data_type want_type)
+{
+ id item;
+
+ if (itemref == NULL)
+ return NULL;
+
+ item = (id)itemref;
+ if ([item isKindOf: [DataObject class]] == NO) {
+ fprintf(stderr, "Can only deref DataObject types "
+ "or sub-classes.");
+ return NULL;
+ }
+
+ switch (want_type) {
+ case NUMBER:
+ if ([item isKindOf: [NumData class]] == NO)
+ return NULL;
+ *(int *)dst = [item getNum];
+ break;
+ case STRING:
+ if ([item isKindOf: [StringData class]] == NO)
+ return NULL;
+ *(char **)dst = [item createCStr];
+ break;
+ case ARRAY:
+ if ([item isKindOf: [ArrayData class]] == NO)
+ return NULL;
+ dst = [item getData];
+ break;
+ case DICTIONARY:
+ if ([item isKindOf: [DictData class]] == NO)
+ return NULL;
+ dst = [item getData];
+ break;
+ default:
+ fprintf(stderr,
+ "Can't deref type `%d': unknown type.", want_type);
+ return NULL;
+ }
+
+ return dst;
+}
diff --git a/libconfig/ArrayData.h b/libconfig/ArrayData.h
new file mode 100644
index 0000000..246803e
--- /dev/null
+++ b/libconfig/ArrayData.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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 ARRAYDATA_H
+# define ARRAYDATA_H
+
+#include "Data.h"
+
+@interface ArrayData: DataObject
+{
+ id *data;
+ int numChildren;
+ int curObj;
+}
+-free;
+-(int)numObjects;
+-addChild: child;
+-objectAt: (int)index;
+@end
+#endif
diff --git a/libconfig/ArrayData.m b/libconfig/ArrayData.m
new file mode 100644
index 0000000..dfee1e7
--- /dev/null
+++ b/libconfig/ArrayData.m
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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.
+ */
+#include "ArrayData.h"
+#include "Parser.h"
+#include "String.h"
+
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+@implementation ArrayData
+-init
+{
+ self = [super init];
+
+ numChildren = 0;
+ curObj = 0;
+ data = malloc(MALLOC_GRANULARITY * sizeof(DictEntry *));
+ if (!data) {
+ fprintf(stderr, "ERROR: couldn't allocate memory: %s.\n",
+ strerror(errno));
+ return nil;
+ }
+
+ return self;
+}
+
+-free
+{
+ int i;
+
+ fprintf(stderr, "DEBUG: freeing array\n");
+ for (i = 0; i < numChildren; i++)
+ [data[i] free];
+ free(data);
+ [super free];
+
+ return nil;
+}
+
+-addChild: child
+{
+ /* Allocate additional space for children pointers, if required. */
+ if (numChildren % MALLOC_GRANULARITY == 0) {
+ /* TODO: fail gracefully. */
+ data = realloc(data, (numChildren+MALLOC_GRANULARITY) *
+ sizeof(DataObject *));
+ if (!data) {
+ fprintf(stderr,
+ "ERROR: couldn't allocate memory: %s.\n",
+ strerror(errno));
+ return nil;
+ }
+ }
+
+ data[numChildren] = child;
+
+ numChildren++;
+ return self;
+}
+
+-setFromBuffer: (const char *)buffer withLength: (int)len
+{
+ Parser *parser;
+ String *string;
+ const char *offset;
+
+ self = [super init];
+ parser = [Parser new];
+ string = [[String new] init];
+ if (parser == nil || string == nil)
+ return nil;
+
+ if (buffer[len] == '\0')
+ len--;
+
+ /* Skip any leading white space. */
+ for (offset = buffer; offset <= buffer+len && isspace((int)*offset);
+ offset++);
+ /* Kill any ending white space. */
+ for (; len >= 0 && isspace((int)buffer[len]); len--);
+
+ /* If there's a leading brace, kill it and the ending one. */
+ if (offset[0] == '[') {
+ if (buffer[len] != ']') {
+ fprintf(stderr, "ERROR: Unbalanced braces.\n");
+ [parser free]; [string free];
+ return nil;
+ }
+ offset++; len--;
+
+ /* Do the whitespace shuffle again. */
+ for (; len >= 0 && isspace((int)buffer[len]); len--);
+ }
+
+ while (offset < buffer+len) {
+ DataObject *dataObj;
+ int strLen;
+
+ /* Do the whitespace shuffle. */
+ for (; offset <= buffer+len && isspace((int)*offset); offset++);
+
+ strLen = [parser getLineLenFrom: offset to: buffer+len];
+ [string setStr: offset withLength: strLen];
+ offset += strLen + 1;
+
+ /* Parse the data element, then add it to our list. */
+ dataObj = [parser getDataFrom: string];
+ if (dataObj == nil) {
+ [parser free]; [string free];
+ return nil;
+ }
+ [self addChild: dataObj];
+ }
+
+ [parser free]; [string free];
+ return self;
+}
+
+-(int)
+numObjects
+{
+ return numChildren;
+}
+
+-objectAt: (int)index
+{
+ if (index >= numChildren)
+ return nil;
+ return data[index];
+}
+@end
diff --git a/libconfig/BuffIO.h b/libconfig/BuffIO.h
new file mode 100644
index 0000000..d58a0a3
--- /dev/null
+++ b/libconfig/BuffIO.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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 BUFFIO_H
+# define BUFFIO_H
+
+#include <Object.h>
+
+#include <sys/types.h>
+
+@interface BuffIO: Object
+{
+ char *file;
+ char *curOff;
+ off_t fileLen;
+ char EOL;
+}
+
+-init: (const char *)fileName;
+-free;
+-(char *)getCurOff;
+-(off_t)getLength;
+-setEOL: (char)delim;
+@end
+#endif
diff --git a/libconfig/BuffIO.m b/libconfig/BuffIO.m
new file mode 100644
index 0000000..f7a5408
--- /dev/null
+++ b/libconfig/BuffIO.m
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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.
+ */
+
+#include "BuffIO.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+@implementation BuffIO
+-init: (const char *)fileName
+{
+ struct stat sb;
+ int confFd;
+
+ confFd = open(fileName, O_RDONLY, 0);
+ if (confFd == -1) {
+ fprintf(stderr, "ERROR: couldn't open config file %s: %s.\n",
+ fileName, strerror(errno));
+ return nil;
+ }
+ if (fstat(confFd, &sb) == -1) {
+ fprintf(stderr, "ERROR: couldn't stat config file %s: %s.\n",
+ fileName, strerror(errno));
+ return nil;
+ }
+ fileLen = sb.st_size;
+ file = mmap(NULL, fileLen, PROT_READ, MAP_PRIVATE, confFd, 0);
+ if (file == MAP_FAILED) {
+ fprintf(stderr, "ERROR: couldn't mmap config file %s: %s.\n",
+ fileName, strerror(errno));
+ return nil;
+ }
+ close(confFd);
+
+ curOff = file;
+ EOL = '\n';
+
+ return self;
+}
+
+-free
+{
+ munmap(file, fileLen);
+ return [super free];
+}
+
+-(char *)
+getCurOff
+{
+ return curOff;
+}
+
+-(off_t)
+getLength
+{
+ return fileLen;
+}
+
+-setEOL: (char)delim
+{
+ EOL = delim;
+ return self;
+}
+@end
diff --git a/libconfig/COPYRIGHT b/libconfig/COPYRIGHT
new file mode 100644
index 0000000..a61dc39
--- /dev/null
+++ b/libconfig/COPYRIGHT
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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.
+ */
diff --git a/libconfig/Data.h b/libconfig/Data.h
new file mode 100644
index 0000000..966310f
--- /dev/null
+++ b/libconfig/Data.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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 DATA_H
+# define DATA_H
+
+#include "String.h"
+
+#include <Object.h>
+
+#include <sys/types.h>
+
+#define MALLOC_GRANULARITY 10 /* Malloc for every 10 entries. */
+
+/*
+ * Generic Entry and Data objects.
+ */
+@interface DataObject: Object
+-dealloc;
+-(char *)createCStr;
+-(String *)createStr;
+-setFromBuffer: (const char *)buffer withLength: (int)len;
+@end
+
+@interface DictEntry: Object
+{
+ String *key;
+ DataObject *data;
+ DictEntry *super;
+}
+
+-init;
+-setKey: keyName;
+-setData: dataPtr;
+-getKey;
+-getData;
+@end
+#endif
diff --git a/libconfig/Data.m b/libconfig/Data.m
new file mode 100644
index 0000000..3b48c7a
--- /dev/null
+++ b/libconfig/Data.m
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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.
+ */
+#include "Data.h"
+#include "Parser.h"
+#include "String.h"
+
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+@implementation DataObject
+-dealloc
+{
+ free(self);
+ return nil;
+}
+
+-(char *)createCStr
+{
+ return NULL;
+}
+
+-(String *)createStr
+{
+ return nil;
+}
+
+-setFromBuffer: (const char *)buffer withLength: (int)len
+{
+ return self;
+}
+@end
+
+@implementation DictEntry
+-init
+{
+ self = [super init];
+ key = NULL; data = NULL;
+ return self;
+}
+
+-setKey: (String *)keyStr
+{
+ key = keyStr;
+ return self;
+}
+
+-setData: (DataObject *)dataPtr
+{
+ data = dataPtr;
+ return self;
+}
+
+-getKey
+{
+ return key;
+}
+
+-getData
+{
+ return data;
+}
+@end
diff --git a/libconfig/DictData.h b/libconfig/DictData.h
new file mode 100644
index 0000000..52dfc0d
--- /dev/null
+++ b/libconfig/DictData.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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 DICTDATA_H
+# define DICTDATA_H
+
+#include "Data.h"
+
+@interface DictData: DataObject
+{
+ id *data;
+ int numChildren;
+ int curObj;
+}
+
+-free;
+-addChild: child;
+-delChild: (const char *)keyName;
+-findChild: (const char *)keyName;
+-firstObject;
+-nextObject;
+@end
+#endif
diff --git a/libconfig/DictData.m b/libconfig/DictData.m
new file mode 100644
index 0000000..8620d7c
--- /dev/null
+++ b/libconfig/DictData.m
@@ -0,0 +1,210 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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.
+ */
+#include "DictData.h"
+#include "Parser.h"
+#include "String.h"
+
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+@implementation DictData
+-init
+{
+ self = [super init];
+
+ numChildren = 0;
+ curObj = 0;
+ data = malloc(MALLOC_GRANULARITY * sizeof(DataObject *));
+ if (!data) {
+ fprintf(stderr, "ERROR: couldn't allocate memory: %s.\n",
+ strerror(errno));
+ return nil;
+ }
+
+ return self;
+}
+
+-free
+{
+ int i;
+
+ fprintf(stderr, "DEBUG: freeing dict\n");
+ for (i = 0; i < numChildren; i++)
+ [data[i] free];
+ free(data);
+ [super free];
+
+ return nil;
+}
+
+-addChild: child
+{
+ /* Allocate additional space for children pointers, if required. */
+ if (numChildren % MALLOC_GRANULARITY == 0) {
+ /* TODO: fail gracefully. */
+ data = realloc(data, (numChildren+MALLOC_GRANULARITY) *
+ sizeof(DictEntry *));
+ if (!data) {
+ fprintf(stderr,
+ "ERROR: couldn't allocate memory: %s.\n",
+ strerror(errno));
+ return nil;
+ }
+ }
+
+ data[numChildren] = child;
+
+ numChildren++;
+ return self;
+}
+
+-setFromBuffer: (const char *)buffer withLength: (int)len
+{
+ Parser *parser;
+ String *string;
+ const char *offset;
+
+ self = [super init];
+ parser = [Parser new];
+ string = [[String new] init];
+ if (parser == nil || string == nil)
+ return nil;
+
+ if (buffer[len] == '\0')
+ len--;
+
+ /* Skip any leading white space. */
+ for (offset = buffer; offset <= buffer+len && isspace((int)*offset);
+ offset++);
+ /* Kill any ending white space. */
+ for (; len >= 0 && isspace((int)buffer[len]); len--);
+
+ /* If there's a leading brace, kill it and the ending one. */
+ if (offset[0] == '{') {
+ if (buffer[len] != '}') {
+ fprintf(stderr, "ERROR: Unbalanced braces.\n");
+ [parser free]; [string free];
+ return nil;
+ }
+ offset++; len--;
+
+ /* Do the whitespace shuffle again. */
+ for (; len >= 0 && isspace((int)buffer[len]); len--);
+ }
+
+ while (offset < buffer+len) {
+ DataObject *dataObj;
+ DictEntry *dictEntry;
+ String *key;
+ char *sep;
+ int strLen;
+
+ /* Do the whitespace shuffle. */
+ for (; offset <= buffer+len && isspace((int)*offset); offset++);
+
+ /* Get the key element. */
+ sep = strchr(offset, '=');
+ if (!sep) {
+ fprintf(stderr, "ERROR: No equals sign!\n");
+ return nil;
+ }
+ for (sep--; sep > offset && isspace((int)*sep); sep--);
+ key = [[[String new] init] setStr: offset
+ withLength: (sep-offset+1)];
+
+ /* Get the data element. */
+ offset = strchr(offset, '=');
+ for(offset++; offset < buffer+len && isspace((int)*offset);
+ offset++);
+ strLen = [parser getLineLenFrom: offset to: buffer+len];
+ [string setStr: offset withLength: strLen];
+ offset += strLen + 1;
+
+ /* Parse the data element, then add it to our list. */
+ dataObj = [parser getDataFrom: string];
+ if (dataObj == nil) {
+ fprintf(stderr,
+ "ERROR: Couldn't parse data for node `%s'.\n",
+ [key getStr]);
+ [parser free]; [string free];
+ return nil;
+ }
+
+ dictEntry = [[DictEntry new] setKey: key];
+ if (dictEntry == nil) {
+ fprintf(stderr,
+ "ERROR: Couldn't create node `%s'.\n",
+ [key getStr]);
+ [parser free]; [string free];
+ return nil;
+ }
+ [dictEntry setData: dataObj];
+ [self addChild: dictEntry];
+ }
+
+ [parser free]; [string free];
+ return self;
+}
+
+-delChild: (const char *)keyName
+{
+ return self;
+}
+
+-findChild: (const char *)keyName
+{
+ int i;
+
+ for (i = 0; i < numChildren; i++)
+ if (!strcmp([[data[i] getKey] getStr], keyName))
+ return data[i];
+ return nil;
+}
+
+-firstObject
+{
+ curObj = 0;
+ return [self nextObject];
+}
+
+-nextObject
+{
+ DictEntry *obj;
+
+ if (curObj >= numChildren)
+ return nil;
+ obj = data[curObj];
+ curObj++;
+ return obj;
+}
+@end
diff --git a/libconfig/Makefile b/libconfig/Makefile
new file mode 100644
index 0000000..9fca5ac
--- /dev/null
+++ b/libconfig/Makefile
@@ -0,0 +1,11 @@
+# $Id: Makefile,v 1.1 2001/10/04 23:57:55 shmit Exp $
+
+CONFIGOBJS= ArrayData.o BuffIO.o Data.o DictData.o NumData.o Parser.o \
+ String.o StringData.o config.o
+
+libconfig.a: ${CONFIGOBJS}
+ ar r $@ ${CONFIGOBJS}
+ ranlib $@
+
+MKDIR= ../Makefiles
+include ${MKDIR}/build
diff --git a/libconfig/NumData.h b/libconfig/NumData.h
new file mode 100644
index 0000000..a8c2810
--- /dev/null
+++ b/libconfig/NumData.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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 NUMDATA_H
+# define NUMDATA_H
+
+#include "Data.h"
+
+@interface NumData: DataObject
+{
+ long data;
+}
+-(long)getNum;
+@end
+#endif
diff --git a/libconfig/NumData.m b/libconfig/NumData.m
new file mode 100644
index 0000000..68f6bfa
--- /dev/null
+++ b/libconfig/NumData.m
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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.
+ */
+#include "NumData.h"
+#include "Parser.h"
+#include "String.h"
+
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+@implementation NumData
+-init
+{
+ self = [super init];
+ return self;
+}
+
+-(String *)
+createStr
+{
+ char buffer[1024];
+
+ snprintf(buffer, sizeof(buffer), "%ld", data);
+ return [[String new] setStr: buffer];
+}
+
+-setFromBuffer: (const char *)buffer withLength: (int)len
+{
+ char *endPtr;
+
+ data = strtol(buffer, &endPtr, 0);
+ if (*endPtr) {
+ fprintf(stderr, "ERROR: `%s' is not a number.\n", buffer);
+ return nil;
+ }
+
+ return self;
+}
+
+-(long)
+getNum
+{
+ return data;
+}
+@end
diff --git a/libconfig/Parser.h b/libconfig/Parser.h
new file mode 100644
index 0000000..963a78a
--- /dev/null
+++ b/libconfig/Parser.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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 PARSER_H
+# define PARSER_H
+
+#include "Data.h"
+#include "String.h"
+
+#include <Object.h>
+
+@interface Parser: Object
+-free;
+-init;
+-(DataObject *)getDataFrom: (String *)line;
+-(int)getLineLenFrom: (const char *)startAddr to: (const char *)endAddr;
+@end
+#endif
diff --git a/libconfig/Parser.m b/libconfig/Parser.m
new file mode 100644
index 0000000..f95cb3d
--- /dev/null
+++ b/libconfig/Parser.m
@@ -0,0 +1,95 @@
+#include "Parser.h"
+#include "ArrayData.h"
+#include "DictData.h"
+#include "NumData.h"
+#include "StringData.h"
+#include "String.h"
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+@implementation Parser
+-(int)
+getLineLenFrom: (const char *)startAddr to: (const char *)endAddr
+{
+ int len;
+ char quote = '\0';
+ int frenchBraces = 0, squareBraces = 0;
+
+ for (len = 0; startAddr+len < endAddr; len++) {
+ if (!quote && !frenchBraces && !squareBraces &&
+ *(startAddr+len) == ';')
+ break;
+
+ switch (*(startAddr+len)) {
+ case '{':
+ frenchBraces++;
+ break;
+ case '}':
+ if (!frenchBraces)
+ fprintf(stderr,
+ "WARNING: found `}' without `{'.\n");
+ else
+ frenchBraces--;
+ break;
+ case '[':
+ squareBraces++;
+ break;
+ case ']':
+ if (!squareBraces)
+ fprintf(stderr,
+ "WARNING: found ']' without '['.\n");
+ else
+ squareBraces--;
+ break;
+ case '"':
+ if (!quote)
+ quote = *(startAddr+len);
+ else
+ quote = '\0';
+ break;
+ }
+ }
+
+ return len;
+}
+
+-init
+{
+ return self;
+}
+
+-free
+{
+ return [super free];
+}
+
+-(DataObject *)
+getDataFrom: (String *)dataStr
+{
+ const char *dataBuff;
+ id dataElem;
+
+ dataBuff = [dataStr getStr];
+
+ /* Figure out what type of node to allocate. */
+ switch (dataBuff[0]) {
+ case '{':
+ dataElem = [[DictData new] init];
+ break;
+ case '[':
+ dataElem = [[ArrayData new] init];
+ break;
+ case '"':
+ dataElem = [[StringData new] init];
+ break;
+ default:
+ dataElem = [[NumData new] init];
+ break;
+ }
+
+ return [dataElem setFromBuffer: dataBuff withLength: [dataStr getLen]];
+}
+@end
diff --git a/libconfig/String.h b/libconfig/String.h
new file mode 100644
index 0000000..ab0aaad
--- /dev/null
+++ b/libconfig/String.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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 STRING_H
+# define STRING_H
+
+#include <Object.h>
+
+@interface String: Object
+{
+ char *data;
+ int len;
+}
+
+-init;
+-free;
+-setStr: (const char *)stringData withLength: (int)length;
+-setStr: (const char *)stringData;
+-(int)getLen;
+-(char *)getStr;
+@end
+#endif
diff --git a/libconfig/String.m b/libconfig/String.m
new file mode 100644
index 0000000..9a0bc5a
--- /dev/null
+++ b/libconfig/String.m
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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.
+ */
+#include "String.h"
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+@implementation String
+-init
+{
+ self = [super init];
+ data = NULL;
+ return self;
+}
+
+-free
+{
+ free(data);
+ return [super free];
+}
+
+-setStr: (const char *)stringData withLength: (int)length
+{
+ if (data)
+ free(data);
+
+ data = malloc((length+1)*sizeof(char));
+ if (!data) {
+ fprintf(stderr, "ERROR: Couldn't allocate memory: %s.\n",
+ strerror(errno));
+ return nil;
+ }
+
+ memcpy(data, stringData, length);
+ data[length] = '\0';
+ len = length;
+ return self;
+}
+
+-setStr: (const char *)stringData
+{
+ return [self setStr: stringData withLength: strlen(stringData)];
+}
+
+-(int)
+getLen
+{
+ return len;
+}
+
+-(char *)
+getStr
+{
+ return data;
+}
+@end
diff --git a/libconfig/StringData.h b/libconfig/StringData.h
new file mode 100644
index 0000000..80c4d26
--- /dev/null
+++ b/libconfig/StringData.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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 STRINGDATA_H
+# define STRINGDATA_H
+
+#include "Data.h"
+#include "String.h"
+
+@interface StringData: DataObject
+{
+ String *data;
+}
+
+-free;
+@end
+#endif
diff --git a/libconfig/StringData.m b/libconfig/StringData.m
new file mode 100644
index 0000000..1c02ac5
--- /dev/null
+++ b/libconfig/StringData.m
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 1998, Brian Cully <shmit@kublai.com>
+ *
+ * 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 above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. The names of contributers to this software may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 REGENTS 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.
+ */
+#include "conf.h"
+
+#include "StringData.h"
+#include "Parser.h"
+#include "String.h"
+
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+#if NEED_STRINGS
+#include <strings.h>
+#endif
+
+@implementation StringData
+-init
+{
+ self = [super init];
+ data = [[String new] init];
+ return self;
+}
+
+-free
+{
+ [data free];
+ [super free];
+ return self;
+}
+
+-(char *)
+createCStr
+{
+ char *buffer;
+
+ buffer = malloc(([data getLen]+1) * sizeof(char));
+ if (!buffer) {
+ fprintf(stderr, "ERROR: Couldn't allocate buffer: %s.\n",
+ strerror(errno));
+ return NULL;
+ }
+
+ strcpy(buffer, [data getStr]);
+ return buffer;
+}
+
+-(String *)
+createStr
+{
+ String *str;
+ char *buffer;
+
+ buffer = [self createCStr];
+ if (buffer == NULL)
+ return nil;
+
+ str = [[[String new] init] setStr: buffer];
+ free(buffer);
+
+ return str;
+}
+
+-setFromBuffer: (const char *)buffer withLength: (int)len
+{
+ const char *startPtr, *endPtr;
+
+ startPtr = index(buffer, '"');
+ if (!startPtr) {
+ fprintf(stderr, "ERROR: No opening quote for string.\n");
+ return nil;
+ }
+ startPtr++;
+
+ for (endPtr = buffer+len; endPtr > startPtr; endPtr--)
+ if (*endPtr == '"')
+ break;
+
+ if (endPtr == startPtr) {
+ fprintf(stderr, "ERROR: No ending quote for string.\n");
+ return nil;
+ }
+ endPtr--;
+
+ [data setStr: startPtr withLength: endPtr-startPtr+1];
+ return self;
+}
+@end
diff --git a/libconfig/config.m b/libconfig/config.m
new file mode 100644
index 0000000..b0d13a9
--- /dev/null
+++ b/libconfig/config.m
@@ -0,0 +1,287 @@
+#include "conf.h"
+#include "config.h"
+#include "nastipc.h"
+#include "thread.h"
+
+#include "BuffIO.h"
+#include "ArrayData.h"
+#include "DictData.h"
+#include "NumData.h"
+#include "StringData.h"
+
+#include <netdb.h>
+#include <stdlib.h>
+
+RCSID("$Id: config.m,v 1.5 2001/11/09 15:54:38 shmit Exp $");
+
+/*
+ * Global variables.
+ */
+static DictData *root;
+char config_filen[MAXPATHLEN];
+struct nast_config config;
+
+static int
+config_read(const char *filename)
+{
+ BuffIO *confFile;
+
+ confFile = [[[BuffIO new] init: filename] setEOL: ';'];
+ if (confFile == nil) {
+ fprintf(stderr, "ERROR: Couldn't load config file.");
+ return -1;
+ }
+
+ root = [[DictData new] setFromBuffer: [confFile getCurOff]
+ withLength: [confFile getLength]];
+
+ /* We've duplicated all the data in here into private storage. */
+ [confFile free];
+
+ if (root == nil) {
+ fprintf(stderr, "ERROR: Couldn't parse config file.");
+ return -1;
+ }
+ return 0;
+}
+
+static int
+get_val(const char *name, void *dst, enum data_type type)
+{
+ id node;
+
+ node = [[root findChild: name] getData];
+ if (node == nil)
+ return 0;
+
+ switch (type) {
+ case NUMBER:
+ if (![node isKindOf: [NumData class]]) {
+ fprintf(stderr, "Node `%s' in `%s' should be a number.",
+ name, config_filen);
+ return -1;
+ }
+ *(int *)dst = [node getNum];
+ break;
+ case STRING:
+ if (![node isKindOf: [StringData class]]) {
+ fprintf(stderr, "Node `%s' in `%s' should be a string.",
+ name, config_filen);
+ return -1;
+ }
+ *(char **)dst = [node createCStr];
+ break;
+ case ARRAY:
+ fprintf(stderr, "ERROR: Can't load array into C yet.");
+ return -1;
+ case DICTIONARY:
+ fprintf(stderr, "ERROR: Can't load dictionary into C yet.");
+ return -1;
+ default:
+ fprintf(stderr, "ERROR: Don't know what to do with type `%d'.",
+ type);
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * Sets configuration variables to defaults, in case they're not set
+ * elsewhere.
+ */
+void
+config_setdefaults()
+{
+ /* Set the defaults. */
+ config.description = "Description not set in config file.";
+ config.nast_dir = DATADIR;
+ config.nast_sock = NASTHOLE;
+ config.nast_cdb_file = "nast.cdb";
+ config.mysql_host = DBHOST;
+ config.mysql_user = DBUSER;
+ config.mysql_pass = DBPASS;
+ config.nofork_flag = 0;
+ config.null_cache_timeout = 60;
+ config.tcp_port = 31337;
+
+ return;
+}
+
+/*
+ * Initializes configuration variables from config file.
+ */
+int
+config_init()
+{
+ snprintf(config_filen, sizeof(config_filen),
+ "%s/nastd.conf", config.nast_dir);
+ if (config_read(config_filen) == -1)
+ return -1;
+
+ /*
+ * Now grab all the top-level config information.
+ */
+ if (get_val("description", &config.description, STRING) == -1)
+ return -1;
+
+ if (get_val("nast_dir", &config.nast_dir, STRING) == -1)
+ return -1;
+
+ if (get_val("nast_sock", &config.nast_sock, STRING) == -1)
+ return -1;
+
+ if (get_val("nast_cdb_file", &config.nast_cdb_file, STRING) == -1)
+ return -1;
+
+ if (get_val("mysql_host", &config.mysql_host, STRING) == -1)
+ return -1;
+
+ if (get_val("mysql_user", &config.mysql_user, STRING) == -1)
+ return -1;
+
+ if (get_val("mysql_pass", &config.mysql_pass, STRING) == -1)
+ return -1;
+
+ if (get_val("null_cache_timeout", &config.null_cache_timeout,
+ NUMBER) == -1)
+ return -1;
+
+ if (get_val("tcp_port", &config.tcp_port, NUMBER) == -1)
+ return -1;
+
+ return 0;
+}
+
+void
+config_delete()
+{
+ [root free];
+}
+
+static enum data_type
+getctype(id node)
+{
+ if ([node isKindOf: [StringData class]])
+ return STRING;
+ else if ([node isKindOf: [NumData class]])
+ return NUMBER;
+ else if ([node isKindOf: [ArrayData class]])
+ return ARRAY;
+ else if ([node isKindOf: [DictData class]])
+ return DICTIONARY;
+ else {
+ return -1;
+ }
+}
+
+void *
+config_find(void *root_node, const char *name, enum data_type *type)
+{
+ id rootNode, dstNode;
+
+ if (root_node == NULL)
+ root_node = root;
+
+ rootNode = (id)root_node;
+ if ([rootNode isKindOf: [DictData class]] == NO) {
+ fprintf(stderr, "Trying to find `%s' in non-dictionary.", name);
+ return NULL;
+ }
+
+ dstNode = [[rootNode findChild: name] getData];
+ if (dstNode == nil)
+ return NULL;
+ *type = getctype(dstNode);
+ return dstNode;
+}
+
+void *
+config_arrayitemat(void *array, int index, enum data_type *type)
+{
+ id arrayNode, dstNode;
+
+ if (array == NULL)
+ return NULL;
+
+ arrayNode = (id)array;
+ if ([arrayNode isKindOf: [ArrayData class]] == NO) {
+ fprintf(stderr, "Trying to index in non-array.");
+ return NULL;
+ }
+
+ if (index >= [arrayNode numObjects])
+ return NULL;
+
+ dstNode = [arrayNode objectAt: index];
+ if (dstNode == nil)
+ return NULL;
+ *type = getctype(dstNode);
+ return dstNode;
+}
+
+void *
+config_dictitemat(void *dict, const char *name, enum data_type *type)
+{
+ id dictNode, dstNode;
+
+ if (dict == NULL)
+ return NULL;
+
+ dictNode = (id)dict;
+ if ([dictNode isKindOf: [DictData class]] == NO) {
+ fprintf(stderr, "Trying to find `%s' in non-dictionary.", name);
+ return NULL;
+ }
+
+ dstNode = [[dictNode findChild: name] getData];
+ if (dstNode == nil)
+ return NULL;
+ *type = getctype(dstNode);
+ return dstNode;
+}
+
+void *
+getdata(void *itemref, void *dst, enum data_type want_type)
+{
+ id item;
+
+ if (itemref == NULL)
+ return NULL;
+
+ item = (id)itemref;
+ if ([item isKindOf: [DataObject class]] == NO) {
+ fprintf(stderr, "Can only deref DataObject types "
+ "or sub-classes.");
+ return NULL;
+ }
+
+ switch (want_type) {
+ case NUMBER:
+ if ([item isKindOf: [NumData class]] == NO)
+ return NULL;
+ *(int *)dst = [item getNum];
+ break;
+ case STRING:
+ if ([item isKindOf: [StringData class]] == NO)
+ return NULL;
+ *(char **)dst = [item createCStr];
+ break;
+ case ARRAY:
+ if ([item isKindOf: [ArrayData class]] == NO)
+ return NULL;
+ dst = [item getData];
+ break;
+ case DICTIONARY:
+ if ([item isKindOf: [DictData class]] == NO)
+ return NULL;
+ dst = [item getData];
+ break;
+ default:
+ fprintf(stderr,
+ "Can't deref type `%d': unknown type.", want_type);
+ return NULL;
+ }
+
+ return dst;
+}