From 6ba98a9f9f48e13738d9736cba9c45b5e94f42f2 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Mon, 14 Apr 2008 21:52:55 -0400 Subject: Initial import --- libconfig/.cvsignore | 15 ++ libconfig/.pure | 0 libconfig/.svn/README.txt | 2 + libconfig/.svn/empty-file | 0 libconfig/.svn/entries | 202 +++++++++++++++++ libconfig/.svn/format | 1 + libconfig/.svn/prop-base/.cvsignore.svn-base | 1 + libconfig/.svn/prop-base/.pure.svn-base | 1 + libconfig/.svn/prop-base/ArrayData.h.svn-base | 1 + libconfig/.svn/prop-base/ArrayData.m.svn-base | 1 + libconfig/.svn/prop-base/BuffIO.h.svn-base | 1 + libconfig/.svn/prop-base/BuffIO.m.svn-base | 1 + libconfig/.svn/prop-base/COPYRIGHT.svn-base | 1 + libconfig/.svn/prop-base/Data.h.svn-base | 1 + libconfig/.svn/prop-base/Data.m.svn-base | 1 + libconfig/.svn/prop-base/DictData.h.svn-base | 1 + libconfig/.svn/prop-base/DictData.m.svn-base | 1 + libconfig/.svn/prop-base/Makefile.svn-base | 1 + libconfig/.svn/prop-base/NumData.h.svn-base | 1 + libconfig/.svn/prop-base/NumData.m.svn-base | 1 + libconfig/.svn/prop-base/Parser.h.svn-base | 1 + libconfig/.svn/prop-base/Parser.m.svn-base | 1 + libconfig/.svn/prop-base/String.h.svn-base | 1 + libconfig/.svn/prop-base/String.m.svn-base | 1 + libconfig/.svn/prop-base/StringData.h.svn-base | 1 + libconfig/.svn/prop-base/StringData.m.svn-base | 1 + libconfig/.svn/prop-base/config.m.svn-base | 1 + libconfig/.svn/props/.cvsignore.svn-work | 1 + libconfig/.svn/props/.pure.svn-work | 1 + libconfig/.svn/props/ArrayData.h.svn-work | 1 + libconfig/.svn/props/ArrayData.m.svn-work | 1 + libconfig/.svn/props/BuffIO.h.svn-work | 1 + libconfig/.svn/props/BuffIO.m.svn-work | 1 + libconfig/.svn/props/COPYRIGHT.svn-work | 1 + libconfig/.svn/props/Data.h.svn-work | 1 + libconfig/.svn/props/Data.m.svn-work | 1 + libconfig/.svn/props/DictData.h.svn-work | 1 + libconfig/.svn/props/DictData.m.svn-work | 1 + libconfig/.svn/props/Makefile.svn-work | 1 + libconfig/.svn/props/NumData.h.svn-work | 1 + libconfig/.svn/props/NumData.m.svn-work | 1 + libconfig/.svn/props/Parser.h.svn-work | 1 + libconfig/.svn/props/Parser.m.svn-work | 1 + libconfig/.svn/props/String.h.svn-work | 1 + libconfig/.svn/props/String.m.svn-work | 1 + libconfig/.svn/props/StringData.h.svn-work | 1 + libconfig/.svn/props/StringData.m.svn-work | 1 + libconfig/.svn/props/config.m.svn-work | 1 + libconfig/.svn/text-base/.cvsignore.svn-base | 15 ++ libconfig/.svn/text-base/.pure.svn-base | 0 libconfig/.svn/text-base/ArrayData.h.svn-base | 44 ++++ libconfig/.svn/text-base/ArrayData.m.svn-base | 161 ++++++++++++++ libconfig/.svn/text-base/BuffIO.h.svn-base | 49 +++++ libconfig/.svn/text-base/BuffIO.m.svn-base | 96 +++++++++ libconfig/.svn/text-base/COPYRIGHT.svn-base | 27 +++ libconfig/.svn/text-base/Data.h.svn-base | 62 ++++++ libconfig/.svn/text-base/Data.m.svn-base | 92 ++++++++ libconfig/.svn/text-base/DictData.h.svn-base | 47 ++++ libconfig/.svn/text-base/DictData.m.svn-base | 210 ++++++++++++++++++ libconfig/.svn/text-base/Makefile.svn-base | 11 + libconfig/.svn/text-base/NumData.h.svn-base | 39 ++++ libconfig/.svn/text-base/NumData.m.svn-base | 74 +++++++ libconfig/.svn/text-base/Parser.h.svn-base | 42 ++++ libconfig/.svn/text-base/Parser.m.svn-base | 95 ++++++++ libconfig/.svn/text-base/String.h.svn-base | 46 ++++ libconfig/.svn/text-base/String.m.svn-base | 82 +++++++ libconfig/.svn/text-base/StringData.h.svn-base | 41 ++++ libconfig/.svn/text-base/StringData.m.svn-base | 117 ++++++++++ libconfig/.svn/text-base/config.m.svn-base | 287 +++++++++++++++++++++++++ libconfig/ArrayData.h | 44 ++++ libconfig/ArrayData.m | 161 ++++++++++++++ libconfig/BuffIO.h | 49 +++++ libconfig/BuffIO.m | 96 +++++++++ libconfig/COPYRIGHT | 27 +++ libconfig/Data.h | 62 ++++++ libconfig/Data.m | 92 ++++++++ libconfig/DictData.h | 47 ++++ libconfig/DictData.m | 210 ++++++++++++++++++ libconfig/Makefile | 11 + libconfig/NumData.h | 39 ++++ libconfig/NumData.m | 74 +++++++ libconfig/Parser.h | 42 ++++ libconfig/Parser.m | 95 ++++++++ libconfig/String.h | 46 ++++ libconfig/String.m | 82 +++++++ libconfig/StringData.h | 41 ++++ libconfig/StringData.m | 117 ++++++++++ libconfig/config.m | 287 +++++++++++++++++++++++++ 88 files changed, 3521 insertions(+) create mode 100644 libconfig/.cvsignore create mode 100644 libconfig/.pure create mode 100644 libconfig/.svn/README.txt create mode 100644 libconfig/.svn/empty-file create mode 100644 libconfig/.svn/entries create mode 100644 libconfig/.svn/format create mode 100644 libconfig/.svn/prop-base/.cvsignore.svn-base create mode 100644 libconfig/.svn/prop-base/.pure.svn-base create mode 100644 libconfig/.svn/prop-base/ArrayData.h.svn-base create mode 100644 libconfig/.svn/prop-base/ArrayData.m.svn-base create mode 100644 libconfig/.svn/prop-base/BuffIO.h.svn-base create mode 100644 libconfig/.svn/prop-base/BuffIO.m.svn-base create mode 100644 libconfig/.svn/prop-base/COPYRIGHT.svn-base create mode 100644 libconfig/.svn/prop-base/Data.h.svn-base create mode 100644 libconfig/.svn/prop-base/Data.m.svn-base create mode 100644 libconfig/.svn/prop-base/DictData.h.svn-base create mode 100644 libconfig/.svn/prop-base/DictData.m.svn-base create mode 100644 libconfig/.svn/prop-base/Makefile.svn-base create mode 100644 libconfig/.svn/prop-base/NumData.h.svn-base create mode 100644 libconfig/.svn/prop-base/NumData.m.svn-base create mode 100644 libconfig/.svn/prop-base/Parser.h.svn-base create mode 100644 libconfig/.svn/prop-base/Parser.m.svn-base create mode 100644 libconfig/.svn/prop-base/String.h.svn-base create mode 100644 libconfig/.svn/prop-base/String.m.svn-base create mode 100644 libconfig/.svn/prop-base/StringData.h.svn-base create mode 100644 libconfig/.svn/prop-base/StringData.m.svn-base create mode 100644 libconfig/.svn/prop-base/config.m.svn-base create mode 100644 libconfig/.svn/props/.cvsignore.svn-work create mode 100644 libconfig/.svn/props/.pure.svn-work create mode 100644 libconfig/.svn/props/ArrayData.h.svn-work create mode 100644 libconfig/.svn/props/ArrayData.m.svn-work create mode 100644 libconfig/.svn/props/BuffIO.h.svn-work create mode 100644 libconfig/.svn/props/BuffIO.m.svn-work create mode 100644 libconfig/.svn/props/COPYRIGHT.svn-work create mode 100644 libconfig/.svn/props/Data.h.svn-work create mode 100644 libconfig/.svn/props/Data.m.svn-work create mode 100644 libconfig/.svn/props/DictData.h.svn-work create mode 100644 libconfig/.svn/props/DictData.m.svn-work create mode 100644 libconfig/.svn/props/Makefile.svn-work create mode 100644 libconfig/.svn/props/NumData.h.svn-work create mode 100644 libconfig/.svn/props/NumData.m.svn-work create mode 100644 libconfig/.svn/props/Parser.h.svn-work create mode 100644 libconfig/.svn/props/Parser.m.svn-work create mode 100644 libconfig/.svn/props/String.h.svn-work create mode 100644 libconfig/.svn/props/String.m.svn-work create mode 100644 libconfig/.svn/props/StringData.h.svn-work create mode 100644 libconfig/.svn/props/StringData.m.svn-work create mode 100644 libconfig/.svn/props/config.m.svn-work create mode 100644 libconfig/.svn/text-base/.cvsignore.svn-base create mode 100644 libconfig/.svn/text-base/.pure.svn-base create mode 100644 libconfig/.svn/text-base/ArrayData.h.svn-base create mode 100644 libconfig/.svn/text-base/ArrayData.m.svn-base create mode 100644 libconfig/.svn/text-base/BuffIO.h.svn-base create mode 100644 libconfig/.svn/text-base/BuffIO.m.svn-base create mode 100644 libconfig/.svn/text-base/COPYRIGHT.svn-base create mode 100644 libconfig/.svn/text-base/Data.h.svn-base create mode 100644 libconfig/.svn/text-base/Data.m.svn-base create mode 100644 libconfig/.svn/text-base/DictData.h.svn-base create mode 100644 libconfig/.svn/text-base/DictData.m.svn-base create mode 100644 libconfig/.svn/text-base/Makefile.svn-base create mode 100644 libconfig/.svn/text-base/NumData.h.svn-base create mode 100644 libconfig/.svn/text-base/NumData.m.svn-base create mode 100644 libconfig/.svn/text-base/Parser.h.svn-base create mode 100644 libconfig/.svn/text-base/Parser.m.svn-base create mode 100644 libconfig/.svn/text-base/String.h.svn-base create mode 100644 libconfig/.svn/text-base/String.m.svn-base create mode 100644 libconfig/.svn/text-base/StringData.h.svn-base create mode 100644 libconfig/.svn/text-base/StringData.m.svn-base create mode 100644 libconfig/.svn/text-base/config.m.svn-base create mode 100644 libconfig/ArrayData.h create mode 100644 libconfig/ArrayData.m create mode 100644 libconfig/BuffIO.h create mode 100644 libconfig/BuffIO.m create mode 100644 libconfig/COPYRIGHT create mode 100644 libconfig/Data.h create mode 100644 libconfig/Data.m create mode 100644 libconfig/DictData.h create mode 100644 libconfig/DictData.m create mode 100644 libconfig/Makefile create mode 100644 libconfig/NumData.h create mode 100644 libconfig/NumData.m create mode 100644 libconfig/Parser.h create mode 100644 libconfig/Parser.m create mode 100644 libconfig/String.h create mode 100644 libconfig/String.m create mode 100644 libconfig/StringData.h create mode 100644 libconfig/StringData.m create mode 100644 libconfig/config.m (limited to 'libconfig') 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 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 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + 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 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 + * + * 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 + * + * 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 +#include +#include +#include +#include +#include +#include + +@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 + * + * 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 + +#include + +@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 + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include + +@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 + * + * 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 + * + * 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 + +#include + +#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 + * + * 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 +#include +#include +#include +#include +#include +#include + +@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 + * + * 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 + * + * 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 +#include +#include +#include +#include +#include +#include + +@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 + * + * 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 + * + * 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 +#include +#include +#include +#include +#include +#include + +@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 + * + * 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 + +@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 +#include +#include +#include + +@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 + * + * 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 + +@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 + * + * 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 +#include +#include + +@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 + * + * 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 + * + * 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 +#include +#include +#include +#include +#include +#include + +#if NEED_STRINGS +#include +#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 +#include + +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 + * + * 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 + * + * 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 +#include +#include +#include +#include +#include +#include + +@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 + * + * 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 + +#include + +@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 + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include + +@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 + * + * 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 + * + * 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 + +#include + +#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 + * + * 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 +#include +#include +#include +#include +#include +#include + +@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 + * + * 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 + * + * 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 +#include +#include +#include +#include +#include +#include + +@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 + * + * 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 + * + * 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 +#include +#include +#include +#include +#include +#include + +@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 + * + * 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 + +@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 +#include +#include +#include + +@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 + * + * 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 + +@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 + * + * 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 +#include +#include + +@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 + * + * 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 + * + * 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 +#include +#include +#include +#include +#include +#include + +#if NEED_STRINGS +#include +#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 +#include + +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; +} -- cgit v1.2.3