[Opensrf-commits] SPAM: r1045 - in branches/autotools: . bin doc examples include/objson include/opensrf src src/jserver src/libopensrf src/objson src/perlmods src/perlmods/OpenSRF src/perlmods/OpenSRF/Application src/perlmods/OpenSRF/Application/Demo src/perlmods/OpenSRF/DomainObject src/perlmods/OpenSRF/Utils src/python src/python/osrf src/router src/srfsh

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Jul 18 01:27:32 EDT 2007


Author: asmodai
Date: 2007-07-18 01:21:54 -0400 (Wed, 18 Jul 2007)
New Revision: 1045

Added:
   branches/autotools/COPYING
   branches/autotools/LICENSE.txt
   branches/autotools/src/perlmods/OpenSRF/Utils/JSON.pm
Removed:
   branches/autotools/examples/bootstrap.conf.example
   branches/autotools/src/perlmods/JSON.pm
   branches/autotools/src/perlmods/OpenSRF/DOM.pm
   branches/autotools/src/perlmods/OpenSRF/DOM/
   branches/autotools/src/perlmods/OpenSRF/DomainObject.pm
   branches/autotools/src/perlmods/OpenSRF/DomainObject/oilsMultiSearch.pm
   branches/autotools/src/perlmods/OpenSRF/DomainObject/oilsPrimitive.pm
   branches/autotools/src/perlmods/OpenSRF/DomainObject/oilsSearch.pm
   branches/autotools/src/perlmods/OpenSRF/DomainObjectCollection.pm
   branches/autotools/src/srfsh/srfsh.h
Modified:
   branches/autotools/
   branches/autotools/bin/osrf_ctl.sh
   branches/autotools/doc/dokuwiki-doc-stubber.pl
   branches/autotools/examples/fieldmapper2perl.xsl
   branches/autotools/examples/math_bench.pl
   branches/autotools/examples/multisession-test.pl
   branches/autotools/examples/opensrf.xml.example
   branches/autotools/examples/opensrf_core.xml.example
   branches/autotools/examples/srfsh.xml.example
   branches/autotools/include/objson/json_parser.h
   branches/autotools/include/opensrf/socket_bundle.h
   branches/autotools/src/Makefile
   branches/autotools/src/jserver/osrf_chat.c
   branches/autotools/src/libopensrf/opensrf.c
   branches/autotools/src/libopensrf/osrf_prefork.c
   branches/autotools/src/libopensrf/osrf_system.c
   branches/autotools/src/libopensrf/socket_bundle.c
   branches/autotools/src/libopensrf/transport_message.c
   branches/autotools/src/libopensrf/transport_session.c
   branches/autotools/src/libopensrf/utils.c
   branches/autotools/src/libopensrf/xml_utils.c
   branches/autotools/src/objson/json_parser.c
   branches/autotools/src/perlmods/OpenSRF/AppSession.pm
   branches/autotools/src/perlmods/OpenSRF/Application.pm
   branches/autotools/src/perlmods/OpenSRF/Application/Demo/Math.pm
   branches/autotools/src/perlmods/OpenSRF/Application/Demo/MathDB.pm
   branches/autotools/src/perlmods/OpenSRF/Application/Persist.pm
   branches/autotools/src/perlmods/OpenSRF/DomainObject/oilsMessage.pm
   branches/autotools/src/perlmods/OpenSRF/DomainObject/oilsMethod.pm
   branches/autotools/src/perlmods/OpenSRF/DomainObject/oilsResponse.pm
   branches/autotools/src/perlmods/OpenSRF/EX.pm
   branches/autotools/src/perlmods/OpenSRF/System.pm
   branches/autotools/src/perlmods/OpenSRF/Transport.pm
   branches/autotools/src/perlmods/OpenSRF/UnixServer.pm
   branches/autotools/src/perlmods/OpenSRF/Utils/Cache.pm
   branches/autotools/src/perlmods/OpenSRF/Utils/Logger.pm
   branches/autotools/src/python/osrf/conf.py
   branches/autotools/src/python/osrf/gateway.py
   branches/autotools/src/python/osrf/json.py
   branches/autotools/src/python/osrf/log.py
   branches/autotools/src/python/osrf/net_obj.py
   branches/autotools/src/python/osrf/ses.py
   branches/autotools/src/python/osrf/system.py
   branches/autotools/src/python/osrf/utils.py
   branches/autotools/src/python/srfsh.py
   branches/autotools/src/router/osrf_router_main.c
   branches/autotools/src/srfsh/Makefile
   branches/autotools/src/srfsh/srfsh.c
Log:
Merged revisions 984-1044 via svnmerge.



Property changes on: branches/autotools
___________________________________________________________________
Name: svnmerge-integrated
   - /trunk:1-983
   + /trunk:1-1044

Copied: branches/autotools/COPYING (from rev 1041, trunk/COPYING)
===================================================================
--- branches/autotools/COPYING	                        (rev 0)
+++ branches/autotools/COPYING	2007-07-18 05:21:54 UTC (rev 1045)
@@ -0,0 +1,17 @@
+ Copyright (C) 2005-2007, Georgia Public Library Service and others
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public 
+ License along with this program; if not, write to the Free 
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
+ MA 02111-1307 USA
+

Copied: branches/autotools/LICENSE.txt (from rev 1041, trunk/LICENSE.txt)
===================================================================
--- branches/autotools/LICENSE.txt	                        (rev 0)
+++ branches/autotools/LICENSE.txt	2007-07-18 05:21:54 UTC (rev 1045)
@@ -0,0 +1,340 @@
+GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year  name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.

Modified: branches/autotools/bin/osrf_ctl.sh
===================================================================
--- branches/autotools/bin/osrf_ctl.sh	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/bin/osrf_ctl.sh	2007-07-18 05:21:54 UTC (rev 1045)
@@ -119,9 +119,9 @@
 function start_perl {
 	do_action "start" $PID_OSRF_PERL "OpenSRF Perl";
 	perl -MOpenSRF::System="$OPT_CONFIG" -e 'OpenSRF::System->bootstrap()' & 
-	pid=$!;
+	sleep 3;
+	pid=$(ps ax | grep "OpenSRF System" | grep -v grep | grep -v "System-C"| awk '{print $1}')
 	echo $pid > $PID_OSRF_PERL;
-	sleep 5;
 	return 0;
 }
 

Modified: branches/autotools/doc/dokuwiki-doc-stubber.pl
===================================================================
--- branches/autotools/doc/dokuwiki-doc-stubber.pl	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/doc/dokuwiki-doc-stubber.pl	2007-07-18 05:21:54 UTC (rev 1045)
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-use OpenSRF::System qw(/pines/conf/bootstrap.conf);
+use OpenSRF::System qw(/openils/conf/opensrf_core.xml);
 use Getopt::Long
 
 $| = 1;

Deleted: branches/autotools/examples/bootstrap.conf.example
===================================================================
--- branches/autotools/examples/bootstrap.conf.example	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/examples/bootstrap.conf.example	2007-07-18 05:21:54 UTC (rev 1045)
@@ -1,44 +0,0 @@
-# ----------------------------------------------------------
-# bootstrap config file
-# ----------------------------------------------------------
-[bootstrap]
-
-# location of the opensrf.xml config file
-settings_config	= /path/to/opensrf.xml
-
-# log files directory
-log_dir				= /path/to/log
-
-## Log file is either a file name or syslog:<facility> 
-#logfile				= osrfysys.log
-logfile				= syslog:local0
-
-# defines the syslog facility for the activity log
-#actlog				= activity.log
-actlog				= syslog:local1
-
-# log level
-debug					= ERROR
-#debug				= INFO
-#debug				= DEBUG
-#debug				= INTERNAL
-
-# the jabber login of the router (changing this will likely cause problems)
-router_name			= router
-
-# all jabber domains we want our app to connect to
-list:domains		= router1.domain.com, router2.domain.com
-
-# jabber login
-username				= jabber_username
-
-# jabber password
-passwd				= jabber_password
-
-# if port is non-numeric (e.g. /tmp/mysock.sock) then we will attempt to
-# connect to the specified string as a unix socket file 
-# This works with Chop Chop jabber only (opensrf custom jabber server)
-port					= 5222
-
-# --------------------------------------
-

Modified: branches/autotools/examples/fieldmapper2perl.xsl
===================================================================
--- branches/autotools/examples/fieldmapper2perl.xsl	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/examples/fieldmapper2perl.xsl	2007-07-18 05:21:54 UTC (rev 1045)
@@ -13,7 +13,7 @@
 
 	<xsl:template match="/">
 package Fieldmapper;
-use JSON;
+use OpenSRF::Utils::JSON;
 use Data::Dumper;
 use base 'OpenSRF::Application';
 

Modified: branches/autotools/examples/math_bench.pl
===================================================================
--- branches/autotools/examples/math_bench.pl	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/examples/math_bench.pl	2007-07-18 05:21:54 UTC (rev 1045)
@@ -13,7 +13,7 @@
 print "usage: $0 <num_requests>\n" and exit unless $count;
 
 # * connect to the Jabber network
-OpenSRF::System->bootstrap_client( config_file => "/openils/conf/bootstrap.conf" );
+OpenSRF::System->bootstrap_client( config_file => "/openils/conf/opensrf_core.xml" );
 $log->set_service('math_bench');
 
 # * create a new application session for the opensrf.math service

Modified: branches/autotools/examples/multisession-test.pl
===================================================================
--- branches/autotools/examples/multisession-test.pl	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/examples/multisession-test.pl	2007-07-18 05:21:54 UTC (rev 1045)
@@ -4,7 +4,7 @@
 use OpenILS::Application::AppUtils;
 use OpenILS::Event;
 use OpenSRF::EX qw/:try/;
-use JSON;
+use OpenSRF::Utils::JSON;
 use Data::Dumper;
 use OpenILS::Utils::Fieldmapper;
 use Digest::MD5 qw/md5_hex/;
@@ -12,7 +12,6 @@
 use OpenSRF::MultiSession;
 use OpenSRF::AppSession;
 use Time::HiRes qw/time/;
-use JSON;
 
 my $config = shift;
 
@@ -37,7 +36,7 @@
 	sub {
 		my $ses = shift;
 		my $req = shift;
-		print $req->{params}->[0] . "\t: " . JSON->perl2JSON($req->{response}->[0]->content)."\n";
+		print $req->{params}->[0] . "\t: " . OpenSRF::Utils::JSON->perl2JSON($req->{response}->[0]->content)."\n";
 	}
 );
 
@@ -45,7 +44,7 @@
 	sub {
 		my $ses = shift;
 		my $req = shift;
-		warn "record $req->{params}->[0] failed: ".JSON->perl2JSON($req->{response});
+		warn "record $req->{params}->[0] failed: " . OpenSRF::Utils::JSON->perl2JSON($req->{response});
 	}
 );
 

Modified: branches/autotools/examples/opensrf.xml.example
===================================================================
--- branches/autotools/examples/opensrf.xml.example	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/examples/opensrf.xml.example	2007-07-18 05:21:54 UTC (rev 1045)
@@ -1,208 +1,207 @@
-<?xml version='1.0'?>
+<?xml version="1.0"?>
+<opensrf version="0.0.1">
+<!-- 
 
-<opensrf version='0.0.1'>
+	There is one <host> entry for each server on the network.  Settings for the
+	'default' host are used for every setting that isn't overridden within a given 
+	host's config.  
 
-		<!-- 
+	To specify which applications a host is serving, list those applications
+	within that host's config section.  If the defaults are acceptible, then
+	that's all that needs to be added/changed.
 
-		There is one <host> entry for each server on the network.  Settings for the
-		'default' host are used for every setting that isn't overridden within a given 
-		host's config.  
+	Any valid XML may be added to the <default> block and server components will have 
+	acces to it.
 
-		To specify which applications a host is serving, list those applications
-		within that host's config section.  If the defaults are acceptible, then
-		that's all that needs to be added/changed.
+-->
 
-		Any valid XML may be added to the <default> block and server components will have 
-		acces to it.
+  <default>
+    <dirs>
 
-		-->
+      <!-- opensrf log files go in this directory -->
+      <log>/path/to/log</log>
 
-	<default>
-	
-		<dirs>
+      <!-- opensrf unix domaind socket files go here -->
+      <sock>/path/to/sock</sock>
 
-			<!-- opensrf log files go in this directory -->
-			<log>/path/to/log</log>
+      <!-- opensrf pids go here -->
+      <pid>/path/to/pid</pid>
 
-			<!-- opensrf unix domaind socket files go here -->
-			<sock>/path/to/sock</sock>
+      <!-- global config directory -->
+      <conf>/path/to/conf</conf>
+    </dirs>
 
-			<!-- opensrf pids go here -->
-			<pid>/path/to/pid</pid>
+    <!-- prefork, simple. prefork is suggested -->
+    <server_type>prefork</server_type>
 
-			<!-- global config directory -->
-			<conf>/path/to/conf</conf>
+    <!-- Default doesn't host any apps -->
+    <activeapps/>
+    <cache>
+      <global>
+        <servers>
 
-		</dirs>
+          <!-- memcached server ip:port -->
+          <server>127.0.0.1:10101</server>
 
-		<!-- prefork, simple. prefork is suggested -->
-		<server_type>prefork</server_type>
+        </servers>
 
-		<!-- Default doesn't host any apps -->
-		<activeapps/> 
+        <!-- maximun time that anything may stay in the cache -->
+        <max_cache_time>86400</max_cache_time>
 
-		<cache>
-			<global>
-				<servers>
-					<!-- memcached server ip:port -->
-					<server>127.0.0.1:10101</server>
-				</servers>
-				<!-- maximun time that anything may stay in the cache -->
-				<max_cache_time>86400</max_cache_time>
-			</global>
-		</cache>
+      </global>
+    </cache>
 
-		<!-- These are the defaults for every served app.  Each server should 
-			duplicate the node layout for any nodes that need changing.
-			Any settings that are overridden in the server specific section 
-			will be used as the config values for that server.  Any settings that are
-			not overridden will fall back on the defaults
-			Note that overriding 'stateless' will break things -->
+<!-- These are the defaults for every served app.  Each server should 
+	duplicate the node layout for any nodes that need changing.
+	Any settings that are overridden in the server specific section 
+	will be used as the config values for that server.  Any settings that are
+	not overridden will fall back on the defaults
+	Note that overriding 'stateless' will break things -->
 
-		<apps>
+    <apps>
+      <opensrf.persist>
 
-			<opensrf.persist>
+        <!-- How many seconds to wait between server 
+	requests before timing out a stateful server session. -->
+        <keepalive>1</keepalive>
 
-				<!-- How many seconds to wait between server 
-					requests before timing out a stateful server session. -->
-				<keepalive>1</keepalive>
+        <!-- if 1, then we support stateless sessions (no connect required),
+	if 0 then we don't -->
+        <stateless>1</stateless>
 
-				<!-- if 1, then we support stateless sessions (no connect required), if
-						0 then we don't -->
-				<stateless>1</stateless>
+        <!-- Tells the servers which language this implementation is coded in 
+	In this case non "perl" servers will not be able to load the module -->
+        <language>perl</language>
 
-				<!-- Tells the servers which language this implementation is coded in 
-					In this case non "perl" servers will not be able to load the module -->
-				<language>perl</language>
+        <!-- Module the implements this application -->
+        <implementation>OpenSRF::Application::Persist</implementation>
 
-				<!-- Module the implements this application -->
-				<implementation>OpenSRF::Application::Persist</implementation>
+        <!-- max stateful requests before a session automatically disconnects a client -->
+        <max_requests>97</max_requests>
 
-				<!-- max stateful requests before a session automatically disconnects a client -->
-				<max_requests>97</max_requests>
+        <!-- settings for the backend application drones.  These are probably sane defaults -->
+        <unix_config>
 
-				<!-- settings for the backend application drones.  These are probably sane defaults -->
+          <!-- unix socket file -->
+          <unix_sock>opensrf.persist_unix.sock</unix_sock>
 
-				<unix_config>
-					<!-- unix socket file -->
-					<unix_sock>opensrf.persist_unix.sock</unix_sock>
+          <!-- pid file -->
+          <unix_pid>opensrf.persist_unix.pid</unix_pid>
 
-					<!-- pid file -->
-					<unix_pid>opensrf.persist_unix.pid</unix_pid>
+          <!-- max requests per process backend before a child is recycled -->
+          <max_requests>1000</max_requests>
 
-					<!-- max requests per process backend before a child is recycled -->
-					<max_requests>1000</max_requests>
+          <!-- log file for this application -->
+          <unix_log>opensrf.persist_unix.log</unix_log>
 
-					<!-- log file for this application -->
-					<unix_log>opensrf.persist_unix.log</unix_log>
+          <!-- Number of children to pre-fork -->
+          <min_children>5</min_children>
 
-					<!-- Number of children to pre-fork -->
-					<min_children>5</min_children>
+          <!-- maximun number of children to fork -->
+          <max_children>25</max_children>
 
-					<!-- maximun number of children to fork -->
-					<max_children>25</max_children>
+          <!-- minimun number of spare forked children -->
+          <min_spare_children>2</min_spare_children>
 
-					<!-- minimun number of spare forked children -->
-					<min_spare_children>2</min_spare_children>
+          <!-- max number of spare forked children -->
+          <max_spare_children>5</max_spare_children>
 
-					<!-- max number of spare forked children -->
-					<max_spare_children>5</max_spare_children>
+        </unix_config>
 
-				</unix_config>
+        <!-- Any additional setting for a particular application go in the app_settings node -->
+        <app_settings>
 
-				<!-- Any additional setting for a particular application go in the app_settings node -->
-				<app_settings>
+          <!-- sqlite database file -->
+          <dbfile>/path/to/dbfile/persist.db</dbfile>
 
-					<!-- sqlite database file -->
-					<dbfile>/path/to/dbfile/persist.db</dbfile>
-				</app_settings>
+        </app_settings>
+      </opensrf.persist>
 
-			</opensrf.persist>
+      <opensrf.math>
+        <keepalive>3</keepalive>
+        <stateless>1</stateless>
+        <language>perl</language>
+        <implementation>OpenSRF::Application::Demo::Math</implementation>
+        <max_requests>97</max_requests>
+        <unix_config>
+          <unix_sock>opensrf.math_unix.sock</unix_sock>
+          <unix_pid>opensrf.math_unix.pid</unix_pid>
+          <max_requests>1000</max_requests>
+          <unix_log>opensrf.math_unix.log</unix_log>
+          <min_children>5</min_children>
+          <max_children>15</max_children>
+          <min_spare_children>2</min_spare_children>
+          <max_spare_children>5</max_spare_children>
+        </unix_config>
+      </opensrf.math>
 
-			<opensrf.math>
-				<keepalive>3</keepalive>
-				<stateless>1</stateless>
-				<language>perl</language>
-				<implementation>OpenSRF::Application::Demo::Math</implementation>
-				<max_requests>97</max_requests>
-				<unix_config>
-					<unix_sock>opensrf.math_unix.sock</unix_sock>
-					<unix_pid>opensrf.math_unix.pid</unix_pid>
-					<max_requests>1000</max_requests>
-					<unix_log>opensrf.math_unix.log</unix_log>
-					<min_children>5</min_children>
-					<max_children>15</max_children>
-					<min_spare_children>2</min_spare_children>
-					<max_spare_children>5</max_spare_children>
-				</unix_config>
-			</opensrf.math>
-			
-			<opensrf.dbmath> 
-				<keepalive>3</keepalive>
-				<stateless>1</stateless>
-				<language>perl</language>
-				<implementation>OpenSRF::Application::Demo::MathDB</implementation>
-				<max_requests>99</max_requests>
-				<unix_config>
-					<max_requests>1000</max_requests>
-					<unix_log>opensrf.dbmath_unix.log</unix_log>
-					<unix_sock>opensrf.dbmath_unix.sock</unix_sock>
-					<unix_pid>opensrf.dbmath_unix.pid</unix_pid>
-					<min_children>5</min_children>
-					<max_children>15</max_children>
-					<min_spare_children>2</min_spare_children> <max_spare_children>5</max_spare_children>
-				</unix_config>
-			</opensrf.dbmath>
+      <opensrf.dbmath>
+        <keepalive>3</keepalive>
+        <stateless>1</stateless>
+        <language>perl</language>
+        <implementation>OpenSRF::Application::Demo::MathDB</implementation>
+        <max_requests>99</max_requests>
+        <unix_config>
+          <max_requests>1000</max_requests>
+          <unix_log>opensrf.dbmath_unix.log</unix_log>
+          <unix_sock>opensrf.dbmath_unix.sock</unix_sock>
+          <unix_pid>opensrf.dbmath_unix.pid</unix_pid>
+          <min_children>5</min_children>
+          <max_children>15</max_children>
+          <min_spare_children>2</min_spare_children>
+          <max_spare_children>5</max_spare_children>
+        </unix_config>
+      </opensrf.dbmath>
 
-			<opensrf.settings>
-				<keepalive>1</keepalive>
-				<stateless>0</stateless>
-				<language>perl</language>
-				<implementation>OpenSRF::Application::Settings</implementation>
-				<max_requests>17</max_requests>
-				<unix_config>
-					<unix_sock>opensrf.settings_unix.sock</unix_sock>
-					<unix_pid>opoensrf.settings_unix.pid</unix_pid>
-					<max_requests>1000</max_requests>
-					<unix_log>opensrf.settings_unix.log</unix_log>
-					<min_children>5</min_children>
-					<max_children>15</max_children>
-					<min_spare_children>3</min_spare_children>
-					<max_spare_children>5</max_spare_children>
-				</unix_config>
-			</opensrf.settings>
+      <opensrf.settings>
+        <keepalive>1</keepalive>
+        <stateless>0</stateless>
+        <language>perl</language>
+        <implementation>OpenSRF::Application::Settings</implementation>
+        <max_requests>17</max_requests>
+        <unix_config>
+          <unix_sock>opensrf.settings_unix.sock</unix_sock>
+          <unix_pid>opoensrf.settings_unix.pid</unix_pid>
+          <max_requests>1000</max_requests>
+          <unix_log>opensrf.settings_unix.log</unix_log>
+          <min_children>5</min_children>
+          <max_children>15</max_children>
+          <min_spare_children>3</min_spare_children>
+          <max_spare_children>5</max_spare_children>
+        </unix_config>
+      </opensrf.settings>
+    </apps>
+  </default>
 
-		</apps>
+  <hosts>
 
-	</default>
+    <myhost.mydomain.org>
+<!-- ^-=-
+	Must match the fully qualified domain name of the host 
+	on Linux, this is usually the output of "hostname -f"
+-->
 
-	<hosts>
+<!-- List all of the apps this server will be running -->
+      <activeapps>
+        <appname>opensrf.persist</appname>
+        <appname>opensrf.settings</appname>
+        <appname>opensrf.math</appname>
+        <appname>opensrf.dbmath</appname>
+      </activeapps>
 
-		<myhost.mydomain.org>
-			<!-- ^-=-
-				must match the fully qualified domain name of the host 
-				on Linux, this is usually the output of "hostname -f"
-			-->
+      <apps>
 
+<!-- Example of an app-specific setting override -->
+        <opensrf.persist>
+          <app_settings>
+            <dbfile>/different/path/to/dbfile/persist.db</dbfile>
+          </app_settings>
+        </opensrf.persist>
 
-			<!-- List all of the apps this server will be running -->
-			<activeapps>
-				<appname>opensrf.persist</appname> 
-				<appname>opensrf.settings</appname> 
-				<appname>opensrf.math</appname> 
-				<appname>opensrf.dbmath</appname> 
-			</activeapps>
+      </apps>
 
-			<apps> <!-- Example of an app-specific setting override -->
-				<opensrf.persist>
-					<app_settings>
-						<dbfile>/different/path/to/dbfile/persist.db</dbfile>
-					</app_settings>
-				</opensrf.persist>
-			</apps>
+    </myhost.mydomain.org>
 
-		</myhost.mydomain.org> 
+  </hosts>
 
-	</hosts>
-
 </opensrf>

Modified: branches/autotools/examples/opensrf_core.xml.example
===================================================================
--- branches/autotools/examples/opensrf_core.xml.example	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/examples/opensrf_core.xml.example	2007-07-18 05:21:54 UTC (rev 1045)
@@ -1,143 +1,141 @@
-<?xml version='1.0'?>
-
+<?xml version="1.0"?>
 <config>
 
-  <opensrf> <!-- bootstrap config for OpenSRF apps -->
+  <!-- bootstrap config for OpenSRF apps -->
+  <opensrf>
 
-		<!--  the routers's name on the network -->
-		<!-- do not change this -->
-      <router_name>router</router_name>
-		
-      <routers> 
-			<!-- 
-				list of router domains we should register with. 
-				We must at least have our default jabber domain in here
-			-->
-         <router>localhost</router>
-      </routers>
+    <!-- The OpenSRF Routers's name on the network -->
+    <!-- You should never need to change thischange this -->
+    <router_name>router</router_name>
 
-      <domains>
-      <!-- Our jabber domain, currently only one domain is supported -->
-         <domain>localhost</domain>
-      </domains>
+    <routers>
 
-      <username>client</username>
-      <passwd>mypass</passwd>
-      <port>5222</port>
+      <!-- List of router domains we should register with. 
+        We must at least have our default jabber domain in here -->
+      <router>localhost</router>
 
-		<!-- log to a local file -->
-      <logfile>/openils/var/log/osrfsys.log</logfile>
+    </routers>
+    <domains>
 
-		<!-- 
-			Log to syslog. You can use this same layout for 
-			defining the logging of all services in this file 
-		-->
+      <!-- Our jabber domain, currently only one domain is supported -->
+      <domain>localhost</domain>
 
-		<!--
-		<logfile>syslog</logfile>
-		<syslog>local2</syslog>
-		<actlog>local1</actlog>
-		-->
+    </domains>
+    <username>client</username>
+    <passwd>mypass</passwd>
+    <port>5222</port>
 
-		<!-- 0 None, 1 Error, 2 Warning, 3 Info, 4 debug, 5 Internal (Nasty) -->
-      <loglevel>3</loglevel>
+    <!-- log to a local file -->
+    <logfile>/openils/var/log/osrfsys.log</logfile>
 
+    <!-- Log to syslog. You can use this same layout for 
+        defining the logging of all services in this file -->
+<!--
+    <logfile>syslog</logfile>
+    <syslog>local2</syslog>
+    <actlog>local1</actlog>
+-->
+
+    <!-- 0 None, 1 Error, 2 Warning, 3 Info, 4 debug, 5 Internal (Nasty) -->
+    <loglevel>3</loglevel>
+
     <!-- config file for the services -->
     <settings_config>/openils/conf/opensrf.xml</settings_config>
+
   </opensrf>
 
-	<!-- Update this if you use ChopChop -->
-	<chopchop> <!-- Our jabber server -->
-		<domain>localhost</domain>
-		<port>5222</port>
+  <!-- Update this if you use ChopChop -->
+  <chopchop>
 
-		<!-- used when multiple servers need to communicate -->
-		<s2sport>5269</s2sport>
-		<secret>secret</secret>
+    <!-- Our jabber server -->
+    <domain>localhost</domain>
+    <port>5222</port>
 
-		<listen_address>10.0.0.3</listen_address>
-		<loglevel>3</loglevel>
-		<logfile>/openils/var/log/osrfsys.log</logfile>
-	</chopchop>
+    <!-- used when multiple servers need to communicate -->
+    <s2sport>5269</s2sport>
+    <secret>secret</secret>
+    <listen_address>10.0.0.3</listen_address>
+    <loglevel>3</loglevel>
+    <logfile>/openils/var/log/osrfsys.log</logfile>
+  </chopchop>
 
-	<!-- The section between <gateway>...</gateway> is a standard OpenSRF C stack config file -->
-	<gateway>
+  <!-- The section between <gateway>...</gateway> is a standard OpenSRF C stack config file -->
+  <gateway>
 
-        <!-- we consider ourselves to be the "originating" client for requests,
+    <!-- we consider ourselves to be the "originating" client for requests,
             which means we define the log XID string for log traces -->
-        <client>true</client>
+    <client>true</client>
 
-		<!--  the routers's name on the network -->
-		<router_name>router</router_name>
+    <!--  the routers's name on the network -->
+    <router_name>router</router_name>
 
-		<!-- jabber domains to connect to (domain1, domain2, ...) -->
-		<domains>
-			<domain>localhost</domain>
-		</domains>
+    <!-- jabber domains to connect to (domain1, domain2, ...) -->
+    <domains>
+      <domain>localhost</domain>
+    </domains>
 
-		<!-- These are the services that the gateway will serve. 
-			Any other requests will receive an HTTP_NOT_FOUND (404) 
-			DO NOT put any services here that you don't want the internet to have access to
-			-->
-		<services>
-			<service>opensrf.math</service> 
-			<service>open-ils.cat</service> 
-			<service>open-ils.search</service> 
-			<service>open-ils.circ</service> 
-			<service>open-ils.actor</service> 
-			<service>open-ils.auth</service> 
-		</services>
+<!-- These are the services that the gateway will serve. 
+	Any other requests will receive an HTTP_NOT_FOUND (404) 
+	DO NOT put any services here that you don't want the internet to have access to
+-->
+    <services>
+      <service>opensrf.math</service>
+      <service>open-ils.cat</service>
+      <service>open-ils.search</service>
+      <service>open-ils.circ</service>
+      <service>open-ils.actor</service>
+      <service>open-ils.auth</service>
+    </services>
 
+    <!-- jabber login info -->
+    <username>mylogin</username>
+    <passwd>mypassword</passwd>
+    <port>5222</port>
+    <logfile>/openils/var/log/gateway.log</logfile>
+    <loglevel>3</loglevel>
 
-		<!-- jabber login info -->
-		<username>mylogin</username>
-		<passwd>mypassword</passwd>
-		<port>5222</port>
-	
-		<logfile>/openils/var/log/gateway.log</logfile>
-		<loglevel>3</loglevel>
+  </gateway>
 
-	</gateway>
+  <!-- ======================================================================================== -->
 
+  <router>
 
-	<!-- ======================================================================================== -->
+    <!-- do not change -->
+    <component>0</component>
 
-	<router>
+    <trusted_domains>
 
-		<!-- do not change -->
-		<component>0</component>
-	
-		<trusted_domains>
-			<!-- Trusted servers are allowed to register apps with the router -->
-			<server>localhost</server>
-			<!-- Trusted clients are allowed to send packets through the router -->
-			<client>localhost</client>
-		</trusted_domains>
-	
-		<transport>
-			<!-- jabber server are we connecting to -->
-			<server>localhost</server>
-			<port>5222</port>
+      <!-- Trusted servers are allowed to register apps with the router -->
+      <server>localhost</server>
 
-			<!-- if this is changed, all "router_name" settings 
+      <!-- Trusted clients are allowed to send packets through the router -->
+      <client>localhost</client>
+
+    </trusted_domains>
+
+    <transport>
+
+      <!-- jabber server are we connecting to -->
+      <server>localhost</server>
+      <port>5222</port>
+
+      <!-- if this is changed, all "router_name" settings 
                 will need to be updated to match this setting -->
-			<username>router</username>
+      <username>router</username>
+      <password>mypassword</password>
 
-			<password>mypassword</password>
+      <!-- router's jabber resource -->
+      <!-- do not change this -->
+      <resource>router</resource>
+      <connect_timeout>10</connect_timeout>
+      <max_reconnect_attempts>5</max_reconnect_attempts>
 
-			<!-- router's jabber resource --> 
-			<!-- do not change this -->
-			<resource>router</resource>
+    </transport>
+    <logfile>/openils/var/log/router.log</logfile>
+    <loglevel>3</loglevel>
 
-			<connect_timeout>10</connect_timeout>
-			<max_reconnect_attempts>5</max_reconnect_attempts>
-		</transport>
-	
-		<logfile>/openils/var/log/router.log</logfile>
-		<loglevel>3</loglevel>
-	
-	</router>
+  </router>
 
-	<!-- ======================================================================================== -->
+  <!-- ======================================================================================== -->
 
 </config>

Modified: branches/autotools/examples/srfsh.xml.example
===================================================================
--- branches/autotools/examples/srfsh.xml.example	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/examples/srfsh.xml.example	2007-07-18 05:21:54 UTC (rev 1045)
@@ -1,12 +1,13 @@
-<!-- This file follows the standard C stack bootstrap config file layout -->
+<?xml version="1.0"?>
+<!-- This file follows the standard bootstrap config file layout found in opensrf_core.xml -->
 <srfsh>
-	<router_name>router</router_name>
-	<domains>
-		<domain>127.0.0.1</domain> 
-	</domains>
-	<username>myusername</username>
-	<passwd>mypassword</passwd>
-	<port>5222</port>
-	<logfile>/path/to/log/srfsh.log</logfile>
-	<loglevel>4</loglevel>
+  <router_name>router</router_name>
+  <domains>
+    <domain>127.0.0.1</domain>
+  </domains>
+  <username>myusername</username>
+  <passwd>mypassword</passwd>
+  <port>5222</port>
+  <logfile>/path/to/log/srfsh.log</logfile>
+  <loglevel>4</loglevel>
 </srfsh>

Modified: branches/autotools/include/objson/json_parser.h
===================================================================
--- branches/autotools/include/objson/json_parser.h	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/include/objson/json_parser.h	2007-07-18 05:21:54 UTC (rev 1045)
@@ -23,6 +23,7 @@
 #define JSON_PARSER_H
 
 #include <stdio.h>
+#include <ctype.h>
 #include <objson/object.h>
 #include <opensrf/utils.h>
 
@@ -77,9 +78,6 @@
 /* prints a useful error message to stderr. always returns -1 */
 int json_handle_error(char* string, unsigned long* index, char* err_msg);
 
-/* returns true if c is 0-9 */
-int is_number(char c);
-
 int json_parse_json_null(char* string, unsigned long* index, jsonObject* obj, int current_strlen);
 
 

Modified: branches/autotools/include/opensrf/socket_bundle.h
===================================================================
--- branches/autotools/include/opensrf/socket_bundle.h	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/include/opensrf/socket_bundle.h	2007-07-18 05:21:54 UTC (rev 1045)
@@ -67,19 +67,19 @@
 /* creates a new server socket node and adds it to the socket set.
 	returns socket id on success.  -1 on failure.
 	socket_type is one of INET or UNIX  */
-int socket_open_tcp_server(socket_manager*, int port, char* listen_ip );
+int socket_open_tcp_server(socket_manager*, int port, const char* listen_ip );
 
 int socket_open_unix_server(socket_manager* mgr, char* path);
 
-int socket_open_udp_server( socket_manager* mgr, int port, char* listen_ip );
+int socket_open_udp_server( socket_manager* mgr, int port, const char* listen_ip );
 
 /* creates a client TCP socket and adds it to the socket set.
 	returns 0 on success.  -1 on failure.  */
-int socket_open_tcp_client(socket_manager*, int port, char* dest_addr);
+int socket_open_tcp_client(socket_manager*, int port, const char* dest_addr);
 
 /* creates a client UNIX socket and adds it to the socket set.
 	returns 0 on success.  -1 on failure.  */
-int socket_open_unix_client(socket_manager*, char* sock_path);
+int socket_open_unix_client(socket_manager*, const char* sock_path);
 
 int socket_open_udp_client( socket_manager* mgr, int port, char* dest_addr);
 

Modified: branches/autotools/src/Makefile
===================================================================
--- branches/autotools/src/Makefile	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/Makefile	2007-07-18 05:21:54 UTC (rev 1045)
@@ -86,7 +86,6 @@
 	cp -r ../include/opensrf $(INCLUDEDIR)
 	cp libopensrf/opensrf $(BINDIR)/opensrf-c
 	make -C c-apps install
-	cp ../examples/bootstrap.conf.example $(ETCDIR)
 	cp ../bin/osrf_ctl.sh $(BINDIR)
 	cp ../examples/opensrf.xml.example $(ETCDIR)
 	cp ../examples/opensrf_core.xml.example $(ETCDIR)

Modified: branches/autotools/src/jserver/osrf_chat.c
===================================================================
--- branches/autotools/src/jserver/osrf_chat.c	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/jserver/osrf_chat.c	2007-07-18 05:21:54 UTC (rev 1045)
@@ -19,8 +19,11 @@
 #include <time.h>
 
 static int osrfChatXMLErrorOcurred = 0;
-static int osrfChatClientSentDisconnect = 0;
 
+/* This is used by code in osrfChatPushData, but that code is
+   currently commented out.  Uncomment the next line if needed. */
+//static int osrfChatClientSentDisconnect = 0;
+
 /* shorter version of strcmp */
 static int eq(const char* a, const char* b) { return (a && b && !strcmp(a,b)); }
 //#define eq(a,b) ((a && b && !strcmp(a,b)) ? 1 : 0)
@@ -613,7 +616,7 @@
 	if(eq(name,"message")) {
 
 		/* drop the old message and start with a new one */
-		xmlNodePtr root = xmlNewNode(NULL, name);
+		xmlNodePtr root = xmlNewNode(NULL, BAD_CAST name);
 		xmlAddAttrs(root, atts);
 		xmlNodePtr oldRoot = xmlDocSetRootElement(node->msgDoc, root);
 		free(node->to);
@@ -628,7 +631,7 @@
 	} else {
 
 		/* all non "message" nodes are simply added to the message */
-		xmlNodePtr nodep = xmlNewNode(NULL, name);
+		xmlNodePtr nodep = xmlNewNode(NULL, BAD_CAST name);
 		xmlAddAttrs(nodep, atts);
 		xmlAddChild(xmlDocGetRootElement(node->msgDoc), nodep);
 	}

Modified: branches/autotools/src/libopensrf/opensrf.c
===================================================================
--- branches/autotools/src/libopensrf/opensrf.c	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/libopensrf/opensrf.c	2007-07-18 05:21:54 UTC (rev 1045)
@@ -9,9 +9,6 @@
 		return 1;
 	}
 
-	fprintf(stderr, "Loading OpenSRF host %s with bootstrap config %s "
-			"and config context %s\n", argv[1], argv[2], argv[3] );
-
 	/* these must be strdup'ed because init_proc_title / set_proc_title 
 		are evil and overwrite the argv memory */
 	char* host		= strdup( argv[1] );

Modified: branches/autotools/src/libopensrf/osrf_prefork.c
===================================================================
--- branches/autotools/src/libopensrf/osrf_prefork.c	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/libopensrf/osrf_prefork.c	2007-07-18 05:21:54 UTC (rev 1045)
@@ -69,14 +69,14 @@
 	prefork_simple* forker = prefork_simple_init(
 		osrfSystemGetTransportClient(), maxr, minc, maxc);
 
-	forker->appname = strdup(appname);
-	forker->keepalive	= kalive;
-
 	if(forker == NULL) {
 		osrfLogError( OSRF_LOG_MARK, "osrf_prefork_run() failed to create prefork_simple object");
 		return -1;
 	}
 
+	forker->appname = strdup(appname);
+	forker->keepalive	= kalive;
+
 	prefork_launch_children(forker);
 
 	osrf_prefork_register_routers(appname);

Modified: branches/autotools/src/libopensrf/osrf_system.c
===================================================================
--- branches/autotools/src/libopensrf/osrf_system.c	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/libopensrf/osrf_system.c	2007-07-18 05:21:54 UTC (rev 1045)
@@ -79,7 +79,12 @@
 			hostname, configfile );
 		return -1;
 	}
-	
+
+	/** daemonize me **/
+	/* background and let our children do their thing */
+	/* NOTE: This has been moved from below the 'if (apps)' block below ... move it back if things go crazy */
+	daemonize();
+
 	jsonObject* apps = osrf_settings_host_value_object("/activeapps/appname");
 	osrfStringArray* arr = osrfNewStringArray(8);
 	
@@ -122,7 +127,7 @@
 	
 				} else {
 		
-					fprintf(stderr, " * Running application %s\n", appname);
+					osrfLogError( OSRF_LOG_MARK, " * Running application %s\n", appname);
 					if( osrfAppRegisterApplication( appname, libfile ) == 0 ) 
 						osrf_prefork_run(appname);
 	
@@ -131,27 +136,22 @@
 				}
 			} // language == c
 		} 
+	} // should we do something if there are no apps? does the wait(NULL) below do that for us?
+
+	while(1) {
+		errno = 0;
+		pid_t pid = wait(NULL);
+		if(-1 == pid) {
+			if(errno == ECHILD)
+				osrfLogError(OSRF_LOG_MARK, "We have no more live services... exiting");
+			else
+				osrfLogError(OSRF_LOG_MARK, "Exiting top-level system loop with error: %s", strerror(errno));
+			break;
+		} else {
+			osrfLogError(OSRF_LOG_MARK, "We lost a top-level service process with PID %ld", pid);
+		}
 	}
 
-	/** daemonize me **/
-
-	/* background and let our children do their thing */
-	daemonize();
-    while(1) {
-        errno = 0;
-        pid_t pid = wait(NULL);
-        if(-1 == pid) {
-            if(errno == ECHILD)
-                osrfLogError(OSRF_LOG_MARK, "We have no more live services... exiting");
-            else
-                osrfLogError(OSRF_LOG_MARK, "Exiting top-level system loop with error: %s", strerror(errno));
-            break;
-        } else {
-            osrfLogError(OSRF_LOG_MARK, "We lost a top-level service process with PID %ld", pid);
-        }
-    }
-
-
 	return 0;
 }
 

Modified: branches/autotools/src/libopensrf/socket_bundle.c
===================================================================
--- branches/autotools/src/libopensrf/socket_bundle.c	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/libopensrf/socket_bundle.c	2007-07-18 05:21:54 UTC (rev 1045)
@@ -77,7 +77,7 @@
 /* creates a new server socket node and adds it to the socket set.
 	returns new socket fd on success.  -1 on failure.
 	socket_type is one of INET or UNIX  */
-int socket_open_tcp_server(socket_manager* mgr, int port, char* listen_ip) {
+int socket_open_tcp_server(socket_manager* mgr, int port, const char* listen_ip) {
 
 	if( mgr == NULL ) {
 		osrfLogWarning( OSRF_LOG_MARK, "socket_open_tcp_server(): NULL mgr"); 
@@ -98,7 +98,13 @@
 	server_addr.sin_family = AF_INET;
 
 	if(listen_ip != NULL) {
-		server_addr.sin_addr.s_addr = inet_addr(listen_ip);
+		struct in_addr addr;
+		if( inet_aton( listen_ip, &addr ) )
+			server_addr.sin_addr.s_addr = addr.s_addr;
+		else {
+			osrfLogError( OSRF_LOG_MARK, "Listener address is invalid: %s", listen_ip );
+			return -1;
+		}
 	} else {
 		server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
 	}
@@ -175,7 +181,7 @@
 
 
 int socket_open_udp_server( 
-		socket_manager* mgr, int port, char* listen_ip ) {
+		socket_manager* mgr, int port, const char* listen_ip ) {
 
 	int sockfd;
 	struct sockaddr_in server_addr;
@@ -188,8 +194,15 @@
 
 	server_addr.sin_family = AF_INET;
 	server_addr.sin_port = htons(port);
-	if(listen_ip) server_addr.sin_addr.s_addr = inet_addr(listen_ip);
-	else server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+	if(listen_ip) {
+		struct in_addr addr;
+		if( inet_aton( listen_ip, &addr ) )
+			server_addr.sin_addr.s_addr = addr.s_addr;
+		else {
+			osrfLogError( OSRF_LOG_MARK, "UDP listener address is invalid: %s", listen_ip );
+			return -1;
+		}
+	} else server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
 
 	errno = 0;
 	if( (bind (sockfd, (struct sockaddr *) &server_addr,sizeof(server_addr))) ) {
@@ -203,7 +216,7 @@
 }
 
 
-int socket_open_tcp_client(socket_manager* mgr, int port, char* dest_addr) {
+int socket_open_tcp_client(socket_manager* mgr, int port, const char* dest_addr) {
 
 	struct sockaddr_in remoteAddr, localAddr;
    struct hostent *hptr;
@@ -318,7 +331,7 @@
 }
 
 
-int socket_open_unix_client(socket_manager* mgr, char* sock_path) {
+int socket_open_unix_client(socket_manager* mgr, const char* sock_path) {
 
 	int sock_fd, len;
    struct sockaddr_un usock;

Modified: branches/autotools/src/libopensrf/transport_message.c
===================================================================
--- branches/autotools/src/libopensrf/transport_message.c	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/libopensrf/transport_message.c	2007-07-18 05:21:54 UTC (rev 1045)
@@ -95,7 +95,7 @@
 		xmlFree(router_class);
 	}
 	if(broadcast) {
-		if(strcmp(broadcast,"0") )
+		if(strcmp((char*) broadcast,"0") )
 			new_msg->broadcast	= 1;
 		xmlFree(broadcast);
 	}
@@ -211,9 +211,9 @@
 // ---------------------------------------------------------------------------------
 char* message_to_xml( const transport_message* msg ) {
 
-	int			bufsize;
+	//int			bufsize;
 	//xmlChar*		xmlbuf;
-	char*			encoded_body;
+	//char*			encoded_body;
 
 	xmlNodePtr	message_node;
 	xmlNodePtr	body_node;

Modified: branches/autotools/src/libopensrf/transport_session.c
===================================================================
--- branches/autotools/src/libopensrf/transport_session.c	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/libopensrf/transport_session.c	2007-07-18 05:21:54 UTC (rev 1045)
@@ -332,7 +332,7 @@
 	if( ! ses ) { return; }
 
 	
-	if( strcmp( name, "message" ) == 0 ) {
+	if( strcmp( (char*) name, "message" ) == 0 ) {
 		ses->state_machine->in_message = 1;
 		buffer_add( ses->from_buffer, get_xml_attr( atts, "from" ) );
 		buffer_add( ses->recipient_buffer, get_xml_attr( atts, "to" ) );
@@ -350,37 +350,37 @@
 
 	if( ses->state_machine->in_message ) {
 
-		if( strcmp( name, "body" ) == 0 ) {
+		if( strcmp( (char*) name, "body" ) == 0 ) {
 			ses->state_machine->in_message_body = 1;
 			return;
 		}
 	
-		if( strcmp( name, "subject" ) == 0 ) {
+		if( strcmp( (char*) name, "subject" ) == 0 ) {
 			ses->state_machine->in_subject = 1;
 			return;
 		}
 	
-		if( strcmp( name, "thread" ) == 0 ) {
+		if( strcmp( (char*) name, "thread" ) == 0 ) {
 			ses->state_machine->in_thread = 1;
 			return;
 		}
 
 	}
 
-	if( strcmp( name, "presence" ) == 0 ) {
+	if( strcmp( (char*) name, "presence" ) == 0 ) {
 		ses->state_machine->in_presence = 1;
 		buffer_add( ses->from_buffer, get_xml_attr( atts, "from" ) );
 		buffer_add( ses->recipient_buffer, get_xml_attr( atts, "to" ) );
 		return;
 	}
 
-	if( strcmp( name, "status" ) == 0 ) {
+	if( strcmp( (char*) name, "status" ) == 0 ) {
 		ses->state_machine->in_status = 1;
 		return;
 	}
 
 
-	if( strcmp( name, "stream:error" ) == 0 ) {
+	if( strcmp( (char*) name, "stream:error" ) == 0 ) {
 		ses->state_machine->in_error = 1;
 		ses->state_machine->connected = 0;
 		osrfLogWarning(  OSRF_LOG_MARK, "Received <stream:error> message from Jabber server" );
@@ -389,21 +389,21 @@
 
 
 	/* first server response from a connect attempt */
-	if( strcmp( name, "stream:stream" ) == 0 ) {
+	if( strcmp( (char*) name, "stream:stream" ) == 0 ) {
 		if( ses->state_machine->connecting == CONNECTING_1 ) {
 			ses->state_machine->connecting = CONNECTING_2;
 			buffer_add( ses->session_id, get_xml_attr(atts, "id") );
 		}
 	}
 
-	if( strcmp( name, "handshake" ) == 0 ) {
+	if( strcmp( (char*) name, "handshake" ) == 0 ) {
 		ses->state_machine->connected = 1;
 		ses->state_machine->connecting = 0;
 		return;
 	}
 
 
-	if( strcmp( name, "error" ) == 0 ) {
+	if( strcmp( (char*) name, "error" ) == 0 ) {
 		ses->state_machine->in_message_error = 1;
 		buffer_add( ses->message_error_type, get_xml_attr( atts, "type" ) );
 		ses->message_error_code = atoi( get_xml_attr( atts, "code" ) );
@@ -412,7 +412,7 @@
 		return;
 	}
 
-	if( strcmp( name, "iq" ) == 0 ) {
+	if( strcmp( (char*) name, "iq" ) == 0 ) {
 		ses->state_machine->in_iq = 1;
 
 		if( strcmp( get_xml_attr(atts, "type"), "result") == 0 
@@ -433,7 +433,7 @@
 	int i;
 	if (atts != NULL) {
 		for(i = 0;(atts[i] != NULL);i++) {
-			if( strcmp( atts[i++], attr_name ) == 0 ) {
+			if( strcmp( (char*) atts[i++], attr_name ) == 0 ) {
 				if( atts[i] != NULL ) {
 					return (char*) atts[i];
 				}
@@ -451,7 +451,7 @@
 	transport_session* ses = (transport_session*) session;
 	if( ! ses ) { return; }
 
-	if( strcmp( name, "message" ) == 0 ) {
+	if( strcmp( (char*) name, "message" ) == 0 ) {
 
 
 		/* pass off the message info the callback */
@@ -489,22 +489,22 @@
 		return;
 	}
 	
-	if( strcmp( name, "body" ) == 0 ) {
+	if( strcmp( (char*) name, "body" ) == 0 ) {
 		ses->state_machine->in_message_body = 0;
 		return;
 	}
 
-	if( strcmp( name, "subject" ) == 0 ) {
+	if( strcmp( (char*) name, "subject" ) == 0 ) {
 		ses->state_machine->in_subject = 0;
 		return;
 	}
 
-	if( strcmp( name, "thread" ) == 0 ) {
+	if( strcmp( (char*) name, "thread" ) == 0 ) {
 		ses->state_machine->in_thread = 0;
 		return;
 	}
 	
-	if( strcmp( name, "iq" ) == 0 ) {
+	if( strcmp( (char*) name, "iq" ) == 0 ) {
 		ses->state_machine->in_iq = 0;
 		if( ses->message_error_code > 0 ) {
 			osrfLogWarning( OSRF_LOG_MARK,  "Error in IQ packet: code %d",  ses->message_error_code );
@@ -514,7 +514,7 @@
 		return;
 	}
 
-	if( strcmp( name, "presence" ) == 0 ) {
+	if( strcmp( (char*) name, "presence" ) == 0 ) {
 		ses->state_machine->in_presence = 0;
 		/*
 		if( ses->presence_callback ) {
@@ -525,17 +525,17 @@
 		return;
 	}
 
-	if( strcmp( name, "status" ) == 0 ) {
+	if( strcmp( (char*) name, "status" ) == 0 ) {
 		ses->state_machine->in_status = 0;
 		return;
 	}
 
-	if( strcmp( name, "error" ) == 0 ) {
+	if( strcmp( (char*) name, "error" ) == 0 ) {
 		ses->state_machine->in_message_error = 0;
 		return;
 	}
 
-	if( strcmp( name, "error:error" ) == 0 ) {
+	if( strcmp( (char*) name, "error:error" ) == 0 ) {
 		ses->state_machine->in_error = 0;
 		return;
 	}

Modified: branches/autotools/src/libopensrf/utils.c
===================================================================
--- branches/autotools/src/libopensrf/utils.c	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/libopensrf/utils.c	2007-07-18 05:21:54 UTC (rev 1045)
@@ -13,12 +13,13 @@
 */
 
 #include <opensrf/utils.h>
+#include <opensrf/log.h>
 #include <errno.h>
 
 inline void* safe_malloc( int size ) {
 	void* ptr = (void*) malloc( size );
 	if( ptr == NULL ) {
-		perror("safe_malloc(): Out of Memory" );
+		osrfLogError( OSRF_LOG_MARK, "Out of Memory" );
 		exit(99);
 	}
 	memset( ptr, 0, size );
@@ -189,7 +190,7 @@
 		}
 	
 		if( gb->size > BUFFER_MAX_SIZE ) {
-			fprintf(stderr, "Buffer reached MAX_SIZE of %d", BUFFER_MAX_SIZE );
+			osrfLogError( OSRF_LOG_MARK, "Buffer reached MAX_SIZE of %d", BUFFER_MAX_SIZE );
 			buffer_free( gb );
 			return 0;
 		}
@@ -366,20 +367,34 @@
 }
 
 
-// A function to turn a process into a daemon and set it's process name in ps/top
+// A function to turn a process into a daemon 
 int daemonize() {
-	int f = fork();
+	pid_t f = fork();
 
 	if (f == -1) {
-		perror("Failed to fork!");
+		osrfLogError( OSRF_LOG_MARK, "Failed to fork!" );
 		return -1;
 
 	} else if (f == 0) { // We're in the child now...
+		
+		// Change directories.  Otherwise whatever directory
+		// we're in couldn't be deleted until the program
+		// terminated -- possibly causing some inconvenience.
+		chdir( "/" );
+
+		/* create new session */
 		setsid();
+
+		// Now that we're no longer attached to a terminal,
+		// we don't want any traffic on the standard streams
+		freopen( "/dev/null", "r", stdin );
+		freopen( "/dev/null", "w", stdout );
+		freopen( "/dev/null", "w", stderr );
+		
 		return 0;
 
 	} else { // We're in the parent...
-		exit(0);
+		_exit(0);
 	}
 }
 
@@ -406,10 +421,7 @@
 
 	FILE* file = fopen(filename, "r");
 	if(!file) {
-		int l = strlen(filename) + 64;
-		char b[l];
-		snprintf(b,l,"Unable to open file [%s] in file_to_string()", filename);
-		perror(b);
+		osrfLogError( OSRF_LOG_MARK, "Unable to open file [%s]", filename );
 		return NULL;
 	}
 

Modified: branches/autotools/src/libopensrf/xml_utils.c
===================================================================
--- branches/autotools/src/libopensrf/xml_utils.c	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/libopensrf/xml_utils.c	2007-07-18 05:21:54 UTC (rev 1045)
@@ -97,7 +97,7 @@
 	if( atts && name ) {
 		int i;
 		for(i = 0; (atts[i] != NULL); i++) {
-			if(!strcmp(atts[i], name)) {
+			if(!strcmp((char*) atts[i], name)) {
 				if(atts[++i]) return (char*) atts[i];
 			}
 		}

Modified: branches/autotools/src/objson/json_parser.c
===================================================================
--- branches/autotools/src/objson/json_parser.c	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/objson/json_parser.c	2007-07-18 05:21:54 UTC (rev 1045)
@@ -127,7 +127,7 @@
 			break;
 
 		default:
-			if(is_number(c) || c == '.' || c == '-') { /* are we a number? */
+			if(isdigit(c) || c == '.' || c == '-') { /* are we a number? */
 				status = json_parse_json_number(string, index, obj, current_strlen);	
 				if(status) return status;
 				break;
@@ -225,7 +225,7 @@
 
 	while(*index < current_strlen) {
 
-		if(is_number(c)) {
+		if(isdigit(c)) {
 			buffer_add_char(buf, c);
 		}
 
@@ -503,18 +503,18 @@
 	
 					if (ucs_char < 0x80) {
 						utf_out[0] = ucs_char;
-						buffer_add(buf, utf_out);
+						buffer_add(buf, (char*) utf_out);
 
 					} else if (ucs_char < 0x800) {
 						utf_out[0] = 0xc0 | (ucs_char >> 6);
 						utf_out[1] = 0x80 | (ucs_char & 0x3f);
-						buffer_add(buf, utf_out);
+						buffer_add(buf, (char*) utf_out);
 
 					} else {
 						utf_out[0] = 0xe0 | (ucs_char >> 12);
 						utf_out[1] = 0x80 | ((ucs_char >> 6) & 0x3f);
 						utf_out[2] = 0x80 | (ucs_char & 0x3f);
-						buffer_add(buf, utf_out);
+						buffer_add(buf, (char*) utf_out);
 					}
 					/* ----------------------------------------------------------------------- */
 					/* ----------------------------------------------------------------------- */
@@ -692,23 +692,6 @@
 	return 0;
 }
 
-int is_number(char c) {
-	switch(c) {
-		case '0':
-		case '1':
-		case '2':
-		case '3':
-		case '4':
-		case '5':
-		case '6':
-		case '7':
-		case '8':
-		case '9':
-			return 1;
-	}
-	return 0;
-}
-
 int json_handle_error(char* string, unsigned long* index, char* err_msg) {
 
 	char buf[60];

Deleted: branches/autotools/src/perlmods/JSON.pm
===================================================================
--- branches/autotools/src/perlmods/JSON.pm	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/perlmods/JSON.pm	2007-07-18 05:21:54 UTC (rev 1045)
@@ -1,827 +0,0 @@
-
-package JSON::number;
-sub new {
-	my $class = shift;
-	my $x = shift || $class;
-	return bless \$x => __PACKAGE__;
-}
-
-use overload ( '""' => \&toString );
-
-sub toString { defined($_[1]) ? ${$_[1]} : ${$_[0]} }
-
-package JSON::bool::true;
-sub new { return bless {} => __PACKAGE__ }
-use overload ( '""' => \&toString );
-use overload ( 'bool' => sub { 1 } );
-use overload ( '0+' => sub { 1 } );
-
-sub toString { 'true' }
-
-package JSON::bool::false;
-sub new { return bless {} => __PACKAGE__ }
-use overload ( '""' => \&toString );
-use overload ( 'bool' => sub { 0 } );
-use overload ( '0+' => sub { 0 } );
-
-sub toString { 'false' }
-
-package JSON;
-use Unicode::Normalize;
-use vars qw/%_class_map/;
-
-sub register_class_hint {
-	my $class = shift;
-	my %args = @_;
-
-	$_class_map{hints}{$args{hint}} = \%args;
-	$_class_map{classes}{$args{name}} = \%args;
-}
-
-sub _JSON_regex {
-	my $string = shift;
-
-	$string =~ s/^\s* ( 
-			   {				| # start object
-			   \[				| # start array
-			   -?\d+\.?\d*			| # number literal
-			   "(?:(?:\\[\"])|[^\"])*"	| # string literal
-			   (?:\/\*.+?\*\/)		| # C comment
-			   true				| # bool true
-			   false			| # bool false
-			   null				| # undef()
-			   :				| # object key-value sep
-			   ,				| # list sep
-			   \]				| # array end
-			   }				  # object end
-			)
-		 \s*//sox;
-	return ($string,$1);
-}
-
-sub lookup_class {
-	my $self = shift;
-	my $hint = shift;
-	return $_class_map{hints}{$hint}{name}
-}
-
-sub lookup_hint {
-	my $self = shift;
-	my $class = shift;
-	return $_class_map{classes}{$class}{hint}
-}
-
-sub _json_hint_to_class {
-	my $type = shift;
-	my $hint = shift;
-
-	return $_class_map{hints}{$hint}{name} if (exists $_class_map{hints}{$hint});
-	
-	$type = 'hash' if ($type eq '}');
-	$type = 'array' if ($type eq ']');
-
-	JSON->register_class_hint(name => $hint, hint => $hint, type => $type);
-
-	return $hint;
-}
-
-sub JSON2perl {
-	my $class = shift;
-	local $_ = shift;
-
-	s/(?<!\\)\$/\\\$/gmo; # fixup $ for later
-	s/(?<!\\)\@/\\\@/gmo; # fixup @ for later
-	s/(?<!\\)\%/\\\%/gmo; # fixup % for later
-
-	# Convert JSON Unicode...
-	s/\\u([0-9a-fA-F]{4})/chr(hex($1))/esog;
-
-	# handle class blessings
-	s/\/\*--\s*S\w*?\s+\S+\s*--\*\// bless(/sog;
-	s/(\]|\}|")\s*\/\*--\s*E\w*?\s+(\S+)\s*--\*\//$1 => _json_hint_to_class("$1", "$2")) /sog;
-
-	my $re = qr/((?<!\\)"(?>(?<=\\)"|[^"])*(?<!\\)")/;
-	# Grab strings...
-	my @strings = /$re/sog;
-
-	# Replace with code...
-	#s/"(?:(?:\\[\"])|[^\"])*"/ do{ \$t = '"'.shift(\@strings).'"'; eval \$t;} /sog;
-	s/$re/ eval shift(\@strings) /sog;
-
-	# Perlify hash notation
-	s/:/ => /sog;
-
-	# Do numbers...
-	#s/\b(-?\d+\.?\d*)\b/ JSON::number::new($1) /sog;
-
-	# Change javascript stuff to perl...
-	s/null/ undef /sog;
-	s/true/ bless( {}, "JSON::bool::true") /sog;
-	s/false/ bless( {}, "JSON::bool::false") /sog;
-
-	my $ret;
-	return eval '$ret = '.$_;
-}
-
-my $_json_index;
-sub ___JSON2perl {
-	my $class = shift;
-	my $data = shift;
-
-	$data = [ split //, $data ];
-
-	$_json_index = 0;
-
-	return _json_parse_data($data);
-}
-
-sub _eat_WS {
-	my $data = shift;
-	while ($$data[$_json_index] =~ /\s+/o) { $_json_index++ }
-}
-
-sub _json_parse_data {
-	my $data = shift;
-
-	my $out; 
-
-	#warn "parse_data";
-
-	while ($$data[$_json_index] =~ /\s+/o) { $_json_index++ }
-
-	my $class = '';
-
-	my $c = $$data[$_json_index];
-
-	if ($c eq '/') {
-		$_json_index++;
-		$class = _json_parse_comment($data);
-		
-		while ($$data[$_json_index] =~ /\s+/o) { $_json_index++ }
-		$c = $$data[$_json_index];
-	}
-
-	if ($c eq '"') {
-		$_json_index++;
-		my $val = '';
-
-		my $seen_slash = 0;
-		my $done = 0;
-		while (!$done) {
-			my $c = $$data[$_json_index];
-			#warn "c is $c";
-
-			if ($c eq '\\') {
-				if ($seen_slash) {
-					$val .= '\\';
-					$seen_slash = 0;
-				} else {
-					$seen_slash = 1;
-				}
-			} elsif ($c eq '"') {
-				if ($seen_slash) {
-					$val .= '"';
-					$seen_slash = 0;
-				} else {
-					$done = 1;
-				}
-			} elsif ($c eq 't') {
-				if ($seen_slash) {
-					$val .= "\t";
-					$seen_slash = 0;
-				} else {
-					$val .= 't';
-				}
-			} elsif ($c eq 'b') {
-				if ($seen_slash) {
-					$val .= "\b";
-					$seen_slash = 0;
-				} else {
-					$val .= 'b';
-				}
-			} elsif ($c eq 'f') {
-				if ($seen_slash) {
-					$val .= "\f";
-					$seen_slash = 0;
-				} else {
-					$val .= 'f';
-				}
-			} elsif ($c eq 'r') {
-				if ($seen_slash) {
-					$val .= "\r";
-					$seen_slash = 0;
-				} else {
-					$val .= 'r';
-				}
-			} elsif ($c eq 'n') {
-				if ($seen_slash) {
-					$val .= "\n";
-					$seen_slash = 0;
-				} else {
-					$val .= 'n';
-				}
-			} elsif ($c eq 'u') {
-				if ($seen_slash) {
-					$_json_index++;
-					$val .= chr(hex(join('',$$data[$_json_index .. $_json_index + 3])));
-					$_json_index += 3;
-					$seen_slash = 0;
-				} else {
-					$val .= 'u';
-				}
-			} else {
-				$val .= $c;
-			}
-			$_json_index++;
-
-			#warn "string is $val";
-		}
-
-		$out = $val;
-
-		#$out = _json_parse_string($data);
-	} elsif ($c eq '[') {
-		$_json_index++;
-		$out = [];
-
-		my $in_parse = 0;
-		my $done = 0;
-		while(!$done) {
-			while ($$data[$_json_index] =~ /\s+/o) { $_json_index++ }
-
-			if ($$data[$_json_index] eq ']') {
-				$done = 1;
-				$_json_index++;
-				last;
-			}
-
-			if ($in_parse) {
-				if ($$data[$_json_index] ne ',') {
-					#warn "_json_parse_array: bad data, leaving array parser";
-					last;
-				}
-				$_json_index++;
-				while ($$data[$_json_index] =~ /\s+/o) { $_json_index++ }
-			}
-
-			my $item = _json_parse_data($data);
-
-			push @$out, $item;
-			$in_parse++;
-		}
-
-		#$out = _json_parse_array($data);
-	} elsif ($c eq '{') {
-		$_json_index++;
-		$out = {};
-
-		my $in_parse = 0;
-		my $done = 0;
-		while(!$done) {
-			while ($$data[$_json_index] =~ /\s+/o) { $_json_index++ }
-
-			if ($$data[$_json_index] eq '}') {
-				$done = 1;
-				$_json_index++;
-				last;
-			}
-
-			if ($in_parse) {
-				if ($$data[$_json_index] ne ',') {
-					#warn "_json_parse_object: bad data, leaving object parser";
-					last;
-				}
-				$_json_index++;
-				while ($$data[$_json_index] =~ /\s+/o) { $_json_index++ }
-			}
-
-			my ($key,$value);
-			$key = _json_parse_data($data);
-
-			#warn "object key is $key";
-
-			while ($$data[$_json_index] =~ /\s+/o) { $_json_index++ }
-		
-			if ($$data[$_json_index] ne ':') {
-				#warn "_json_parse_object: bad data, leaving object parser";
-				last;
-			}
-			$_json_index++;
-			$value = _json_parse_data($data);
-
-			$out->{$key} = $value;
-			$in_parse++;
-		}
-		#$out = _json_parse_object($data);
-	} elsif (lc($c) eq 'n') {
-		if (lc(join('',$$data[$_json_index .. $_json_index + 3])) eq 'null') {
-			$_json_index += 4;
-		} else {
-			warn "CRAP! bad null parsing...";
-		}
-		$out = undef;
-		#$out = _json_parse_null($data);
-	} elsif (lc($c) eq 't' or lc($c) eq 'f') {
-		if (lc(join('',$$data[$_json_index .. $_json_index + 3])) eq 'true') {
-			$out = 1;
-			$_json_index += 4;
-		} elsif (lc(join('',$$data[$_json_index .. $_json_index + 4])) eq 'false') {
-			$out = 0;
-			$_json_index += 5;
-		} else {
-			#warn "CRAP! bad bool parsing...";
-			$out = undef;
-		}
-		#$out = _json_parse_bool($data);
-	} elsif ($c =~ /\d+/o or $c eq '.' or $c eq '-') {
-		my $val;
-		while ($$data[$_json_index] =~ /[-\.0-9]+/io) {
-			$val .= $$data[$_json_index];
-			$_json_index++;
-		}
-		$out = 0+$val;
-		#$out = _json_parse_number($data);
-	}
-
-	if ($class) {
-		while ($$data[$_json_index] =~ /\s+/o) { $_json_index++ }
-		my $c = $$data[$_json_index];
-
-		if ($c eq '/') {
-			$_json_index++;
-			_json_parse_comment($data)
-		}
-
-		bless( $out => lookup_class($class) );
-	}
-
-	$out;
-}
-
-sub _json_parse_null {
-	my $data = shift;
-
-	#warn "parse_null";
-
-	if (lc(join('',$$data[$_json_index .. $_json_index + 3])) eq 'null') {
-		$_json_index += 4;
-	} else {
-		#warn "CRAP! bad null parsing...";
-	}
-	return undef;
-}
-
-sub _json_parse_bool {
-	my $data = shift;
-
-	my $out;
-
-	#warn "parse_bool";
-
-	if (lc(join('',$$data[$_json_index .. $_json_index + 3])) eq 'true') {
-		$out = 1;
-		$_json_index += 4;
-	} elsif (lc(join('',$$data[$_json_index .. $_json_index + 4])) eq 'false') {
-		$out = 0;
-		$_json_index += 5;
-	} else {
-		#warn "CRAP! bad bool parsing...";
-		$out = undef;
-	}
-	return $out;
-}
-
-sub _json_parse_number {
-	my $data = shift;
-
-	#warn "parse_number";
-
-	my $val;
-	while ($$data[$_json_index] =~ /[-\.0-9]+/io) {
-		$val .= $$data[$_json_index];
-		$_json_index++;
-	}
-
-	return 0+$val;
-}
-
-sub _json_parse_object {
-	my $data = shift;
-
-	#warn "parse_object";
-
-	my $out = {};
-
-	my $in_parse = 0;
-	my $done = 0;
-	while(!$done) {
-		while ($$data[$_json_index] =~ /\s+/o) { $_json_index++ }
-
-		if ($$data[$_json_index] eq '}') {
-			$done = 1;
-			$_json_index++;
-			last;
-		}
-
-		if ($in_parse) {
-			if ($$data[$_json_index] ne ',') {
-				#warn "_json_parse_object: bad data, leaving object parser";
-				last;
-			}
-			$_json_index++;
-			while ($$data[$_json_index] =~ /\s+/o) { $_json_index++ }
-		}
-
-		my ($key,$value);
-		$key = _json_parse_data($data);
-
-		#warn "object key is $key";
-
-		while ($$data[$_json_index] =~ /\s+/o) { $_json_index++ }
-		
-		if ($$data[$_json_index] ne ':') {
-			#warn "_json_parse_object: bad data, leaving object parser";
-			last;
-		}
-		$_json_index++;
-		$value = _json_parse_data($data);
-
-		$out->{$key} = $value;
-		$in_parse++;
-	}
-
-	return $out;
-}
-
-sub _json_parse_array {
-	my $data = shift;
-
-	#warn "parse_array";
-
-	my $out = [];
-
-	my $in_parse = 0;
-	my $done = 0;
-	while(!$done) {
-		while ($$data[$_json_index] =~ /\s+/o) { $_json_index++ }
-
-		if ($$data[$_json_index] eq ']') {
-			$done = 1;
-			$_json_index++;
-			last;
-		}
-
-		if ($in_parse) {
-			if ($$data[$_json_index] ne ',') {
-				#warn "_json_parse_array: bad data, leaving array parser";
-				last;
-			}
-			$_json_index++;
-			while ($$data[$_json_index] =~ /\s+/o) { $_json_index++ }
-		}
-
-		my $item = _json_parse_data($data);
-
-		push @$out, $item;
-		$in_parse++;
-	}
-
-	return $out;
-}
-
-
-sub _json_parse_string {
-	my $data = shift;
-
-	#warn "parse_string";
-
-	my $val = '';
-
-	my $seen_slash = 0;
-	my $done = 0;
-	while (!$done) {
-		my $c = $$data[$_json_index];
-		#warn "c is $c";
-
-		if ($c eq '\\') {
-			if ($seen_slash) {
-				$val .= '\\';
-				$seen_slash = 0;
-			} else {
-				$seen_slash = 1;
-			}
-		} elsif ($c eq '"') {
-			if ($seen_slash) {
-				$val .= '"';
-				$seen_slash = 0;
-			} else {
-				$done = 1;
-			}
-		} elsif ($c eq 't') {
-			if ($seen_slash) {
-				$val .= "\t";
-				$seen_slash = 0;
-			} else {
-				$val .= 't';
-			}
-		} elsif ($c eq 'b') {
-			if ($seen_slash) {
-				$val .= "\b";
-				$seen_slash = 0;
-			} else {
-				$val .= 'b';
-			}
-		} elsif ($c eq 'f') {
-			if ($seen_slash) {
-				$val .= "\f";
-				$seen_slash = 0;
-			} else {
-				$val .= 'f';
-			}
-		} elsif ($c eq 'r') {
-			if ($seen_slash) {
-				$val .= "\r";
-				$seen_slash = 0;
-			} else {
-				$val .= 'r';
-			}
-		} elsif ($c eq 'n') {
-			if ($seen_slash) {
-				$val .= "\n";
-				$seen_slash = 0;
-			} else {
-				$val .= 'n';
-			}
-		} elsif ($c eq 'u') {
-			if ($seen_slash) {
-				$_json_index++;
-				$val .= chr(hex(join('',$$data[$_json_index .. $_json_index + 3])));
-				$_json_index += 3;
-				$seen_slash = 0;
-			} else {
-				$val .= 'u';
-			}
-		} else {
-			$val .= $c;
-		}
-		$_json_index++;
-
-		#warn "string is $val";
-	}
-
-	return $val;
-}
-
-sub _json_parse_comment {
-	my $data = shift;
-
-	#warn "parse_comment";
-
-	if ($$data[$_json_index] eq '/') {
-		$_json_index++;
-		while (!($$data[$_json_index] eq "\n")) { $_json_index++ }
-		$_json_index++;
-		return undef;
-	}
-
-	my $class = '';
-
-	if (join('',$$data[$_json_index .. $_json_index + 2]) eq '*--') {
-		$_json_index += 3;
-		while ($$data[$_json_index] =~ /\s+/o) { $_json_index++ }
-		if ($$data[$_json_index] eq 'S') {
-			while ($$data[$_json_index] =~ /\s+/o) { $_json_index++ }
-			while ($$data[$_json_index] !~ /[-\s]+/o) {
-				$class .= $$data[$_json_index];
-				$_json_index++;
-			}
-			while ($$data[$_json_index] =~ /\s+/o) { $_json_index++ }
-		}
-	}
-
-	while ($$data[$_json_index] ne '/') { $_json_index++ };
-	$_json_index++;
-
-	return $class;
-}
-
-sub old_JSON2perl {
-	my ($class, $json) = @_;
-
-	if (!defined($json)) {
-		return undef;
-	}
-
-	$json =~ s/(?<!\\)\$/\\\$/gmo; # fixup $ for later
-	$json =~ s/(?<!\\)\@/\\\@/gmo; # fixup @ for later
-	$json =~ s/(?<!\\)\%/\\\%/gmo; # fixup % for later
-
-	my @casts;
-	my $casting_depth = 0;
-	my $current_cast;
-	my $element;
-	my $output = '';
-	while (($json,$element) = _JSON_regex($json)) {
-
-		last unless ($element);
-
-		if ($element eq 'null') {
-			$output .= ' undef() ';
-			next;
-		} elsif ($element =~ /^\/\*--\s*S\w*?\s+(\w+)\s*--\*\/$/) {
-			my $hint = $1;
-			if (exists $_class_map{hints}{$hint}) {
-				$casts[$casting_depth] = $hint;
-				$output .= ' bless(';
-			}
-			next;
-		} elsif ($element =~ /^\/\*/) {
-			next;
-		} elsif ($element =~ /^\d/) {
-			$output .= "do { JSON::number::new($element) }";
-			next;
-		} elsif ($element eq '{' or $element eq '[') {
-			$casting_depth++;
-		} elsif ($element eq '}' or $element eq ']') {
-			$casting_depth--;
-			my $hint = $casts[$casting_depth];
-			$casts[$casting_depth] = undef;
-			if (defined $hint and exists $_class_map{hints}{$hint}) {
-				$output .= $element . ',"'. $_class_map{hints}{$hint}{name} . '")';
-				next;
-			}
-		} elsif ($element eq ':') {
-			$output .= ' => ';
-			next;
-		} elsif ($element eq 'true') {
-			$output .= 'bless( {}, "JSON::bool::true")';
-			next;
-		} elsif ($element eq 'false') {
-			$output .= 'bless( {}, "JSON::bool::false")';
-			next;
-		}
-		
-		$output .= $element;
-	}
-
-	return eval $output;
-}
-
-sub perl2JSON {
-	my ($class, $perl, $strict) = @_;
-
-	my $output = '';
-	if (!defined($perl)) {
-		$output = '' if $strict;
-		$output = 'null' unless $strict;
-	} elsif (ref($perl) and ref($perl) =~ /^JSON/) {
-		$output .= $perl;
-	} elsif ( ref($perl) && exists($_class_map{classes}{ref($perl)}) ) {
-		$output .= '/*--S '.$_class_map{classes}{ref($perl)}{hint}.'--*/';
-		if (lc($_class_map{classes}{ref($perl)}{type}) eq 'hash') {
-			my %hash =  %$perl;
-			$output .= perl2JSON(undef,\%hash, $strict);
-		} elsif (lc($_class_map{classes}{ref($perl)}{type}) eq 'array') {
-			my @array =  @$perl;
-			$output .= perl2JSON(undef,\@array, $strict);
-		}
-		$output .= '/*--E '.$_class_map{classes}{ref($perl)}{hint}.'--*/';
-	} elsif (ref($perl) and ref($perl) =~ /HASH/) {
-		$output .= '{';
-		my $c = 0;
-		for my $key (sort keys %$perl) {
-			my $outkey = NFC($key);
-			$output .= ',' if ($c); 
-
-			$outkey =~ s{\\}{\\\\}sgo;
-			$outkey =~ s/"/\\"/sgo;
-			$outkey =~ s/\t/\\t/sgo;
-			$outkey =~ s/\f/\\f/sgo;
-			$outkey =~ s/\r/\\r/sgo;
-			$outkey =~ s/\n/\\n/sgo;
-			$outkey =~ s/([\x{0080}-\x{fffd}])/sprintf('\u%0.4x',ord($1))/sgoe;
-
-			$output .= '"'.$outkey.'":'. perl2JSON(undef,$$perl{$key}, $strict);
-			$c++;
-		}
-		$output .= '}';
-	} elsif (ref($perl) and ref($perl) =~ /ARRAY/) {
-		$output .= '[';
-		my $c = 0;
-		for my $part (@$perl) {
-			$output .= ',' if ($c); 
-			
-			$output .= perl2JSON(undef,$part, $strict);
-			$c++;
-		}
-		$output .= ']';
-	} elsif (ref($perl) and ref($perl) =~ /CODE/) {
-		$output .= perl2JSON(undef,$perl->(), $strict);
-	} elsif (ref($perl) and ("$perl" =~ /^([^=]+)=(\w+)/o)) {
-		my $type = $2;
-		my $name = $1;
-		JSON->register_class_hint(name => $name, hint => $name, type => lc($type));
-		$output .= perl2JSON(undef,$perl, $strict);
-	} else {
-		$perl = NFC($perl);
-		$perl =~ s{\\}{\\\\}sgo;
-		$perl =~ s/"/\\"/sgo;
-		$perl =~ s/\t/\\t/sgo;
-		$perl =~ s/\f/\\f/sgo;
-		$perl =~ s/\r/\\r/sgo;
-		$perl =~ s/\n/\\n/sgo;
-		$perl =~ s/([\x{0080}-\x{fffd}])/sprintf('\u%0.4x',ord($1))/sgoe;
-		if (length($perl) < 10 and $perl =~ /^(?:\+|-)?\d*\.?\d+$/o and $perl !~ /^(?:\+|-)?0\d+/o ) {
-			$output = $perl;
-		} else {
-			$output = '"'.$perl.'"';
-		}
-	}
-
-	return $output;
-}
-
-my $depth = 0;
-sub perl2prettyJSON {
-	my ($class, $perl, $nospace) = @_;
-	$perl ||= $class;
-
-	my $output = '';
-	if (!defined($perl)) {
-		$output = "   "x$depth unless($nospace);
-		$output .= 'null';
-	} elsif (ref($perl) and ref($perl) =~ /^JSON/) {
-		$output = "   "x$depth unless($nospace);
-		$output .= $perl;
-	} elsif ( ref($perl) && exists($_class_map{classes}{ref($perl)}) ) {
-		$depth++;
-		$output .= "\n";
-		$output .= "   "x$depth;
-		$output .= '/*--S '.$_class_map{classes}{ref($perl)}{hint}."--*/ ";
-		if (lc($_class_map{classes}{ref($perl)}{type}) eq 'hash') {
-			my %hash =  %$perl;
-			$output .= perl2prettyJSON(\%hash,undef,1);
-		} elsif (lc($_class_map{classes}{ref($perl)}{type}) eq 'array') {
-			my @array =  @$perl;
-			$output .= perl2prettyJSON(\@array,undef,1);
-		}
-		$output .= ' /*--E '.$_class_map{classes}{ref($perl)}{hint}.'--*/';
-		$depth--;
-	} elsif (ref($perl) and ref($perl) =~ /HASH/) {
-		$output .= "   "x$depth unless ($nospace);
-		$output .= "{\n";
-		my $c = 0;
-		$depth++;
-		for my $key (sort keys %$perl) {
-			$output .= ",\n" if ($c); 
-			$output .= "   "x$depth;
-			$output .= perl2prettyJSON($key)." : ".perl2prettyJSON($$perl{$key}, undef, 1);
-			$c++;
-		}
-		$depth--;
-		$output .= "\n";
-		$output .= "   "x$depth;
-		$output .= '}';
-	} elsif (ref($perl) and ref($perl) =~ /ARRAY/) {
-		$output .= "   "x$depth unless ($nospace);
-		$output .= "[\n";
-		my $c = 0;
-		$depth++;
-		for my $part (@$perl) {
-			$output .= ",\n" if ($c); 
-			$output .= "   "x$depth;
-			$output .= perl2prettyJSON($part);
-			$c++;
-		}
-		$depth--;
-		$output .= "\n";
-		$output .= "   "x$depth;
-		$output .= "]";
-	} elsif (ref($perl) and ref($perl) =~ /CODE/) {
-		$output .= perl2prettyJSON(undef,$perl->(), $nospace);
-	} elsif (ref($perl) and "$perl" =~ /^([^=]+)=(\w{4,5})\(0x/) {
-		my $type = $2;
-		my $name = $1;
-		register_class_hint(undef, name => $name, hint => $name, type => lc($type));
-		$output .= perl2prettyJSON(undef,$perl);
-	} else {
-		$perl = NFC($perl);
-		$perl =~ s/\\/\\\\/sgo;
-		$perl =~ s/"/\\"/sgo;
-		$perl =~ s/\t/\\t/sgo;
-		$perl =~ s/\f/\\f/sgo;
-		$perl =~ s/\r/\\r/sgo;
-		$perl =~ s/\n/\\n/sgo;
-		$perl =~ s/([\x{0080}-\x{fffd}])/sprintf('\u%0.4x',ord($1))/sgoe;
-		$output .= "   "x$depth unless($nospace);
-		if (length($perl) < 10 and $perl =~ /^(?:\+|-)?\d*\.?\d+$/o and $perl !~ /^(?:\+|-)?0\d+/o ) {
-			$output = $perl;
-		} else {
-			$output = '"'.$perl.'"';
-		}
-	}
-
-	return $output;
-}
-
-1;

Modified: branches/autotools/src/perlmods/OpenSRF/AppSession.pm
===================================================================
--- branches/autotools/src/perlmods/OpenSRF/AppSession.pm	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/perlmods/OpenSRF/AppSession.pm	2007-07-18 05:21:54 UTC (rev 1045)
@@ -1,10 +1,9 @@
 package OpenSRF::AppSession;
-use OpenSRF::DOM;
-#use OpenSRF::DOM::Element::userAuth;
 use OpenSRF::DomainObject::oilsMessage;
 use OpenSRF::DomainObject::oilsMethod;
 use OpenSRF::DomainObject::oilsResponse qw/:status/;
 use OpenSRF::Transport::PeerHandle;
+use OpenSRF::Utils::JSON;
 use OpenSRF::Utils::Logger qw(:level);
 use OpenSRF::Utils::SettingsClient;
 use OpenSRF::Utils::Config;
@@ -531,7 +530,7 @@
 		}
 
 	} 
-	my $json = JSON->perl2JSON(\@doc);
+	my $json = OpenSRF::Utils::JSON->perl2JSON(\@doc);
 	$logger->internal("AppSession sending doc: $json");
 
 	$self->{peer_handle}->send( 

Modified: branches/autotools/src/perlmods/OpenSRF/Application/Demo/Math.pm
===================================================================
--- branches/autotools/src/perlmods/OpenSRF/Application/Demo/Math.pm	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/perlmods/OpenSRF/Application/Demo/Math.pm	2007-07-18 05:21:54 UTC (rev 1045)
@@ -3,7 +3,6 @@
 use OpenSRF::Application;
 use OpenSRF::Utils::Logger qw/:level/;
 use OpenSRF::DomainObject::oilsResponse;
-#use OpenSRF::DomainObject::oilsPrimitive;
 use OpenSRF::EX qw/:try/;
 use strict;
 use warnings;

Modified: branches/autotools/src/perlmods/OpenSRF/Application/Demo/MathDB.pm
===================================================================
--- branches/autotools/src/perlmods/OpenSRF/Application/Demo/MathDB.pm	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/perlmods/OpenSRF/Application/Demo/MathDB.pm	2007-07-18 05:21:54 UTC (rev 1045)
@@ -1,9 +1,8 @@
 package OpenSRF::Application::Demo::MathDB;
-use JSON;
+use OpenSRF::Utils::JSON;
 use base qw/OpenSRF::Application/;
 use OpenSRF::Application;
 use OpenSRF::DomainObject::oilsResponse qw/:status/;
-#use OpenSRF::DomainObject::oilsPrimitive;
 use OpenSRF::Utils::Logger qw/:level/;
 use strict;
 use warnings;
@@ -20,7 +19,7 @@
 	my $n1 = shift; 
 	my $n2 = shift;
 	my $a = $n1 + $n2;
-	return JSON::number->new($a);
+	return OpenSRF::Utils::JSON::number->new($a);
 }
 
 __PACKAGE__->register_method( method => 'sub_1', api_name => 'dbmath.sub' );
@@ -31,7 +30,7 @@
 	my $n1 = shift; 
 	my $n2 = shift;
 	my $a = $n1 - $n2;
-	return JSON::number->new($a);
+	return OpenSRF::Utils::JSON::number->new($a);
 }
 
 __PACKAGE__->register_method( method => 'mult_1', api_name => 'dbmath.mult' );
@@ -42,7 +41,7 @@
 	my $n1 = shift; 
 	my $n2 = shift;
 	my $a = $n1 * $n2;
-	return JSON::number->new($a);
+	return OpenSRF::Utils::JSON::number->new($a);
 }
 
 __PACKAGE__->register_method( method => 'div_1', api_name => 'dbmath.div' );
@@ -53,7 +52,7 @@
 	my $n1 = shift; 
 	my $n2 = shift;
 	my $a = $n1 / $n2;
-	return JSON::number->new($a);
+	return OpenSRF::Utils::JSON::number->new($a);
 }
 
 1;

Modified: branches/autotools/src/perlmods/OpenSRF/Application/Persist.pm
===================================================================
--- branches/autotools/src/perlmods/OpenSRF/Application/Persist.pm	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/perlmods/OpenSRF/Application/Persist.pm	2007-07-18 05:21:54 UTC (rev 1045)
@@ -6,7 +6,7 @@
 use OpenSRF::EX qw/:try/;
 use OpenSRF::Utils qw/:common/;
 use OpenSRF::Utils::Logger;
-use JSON;
+use OpenSRF::Utils::JSON;
 use DBI;
 
 use vars qw/$dbh $log $default_expire_time/;
@@ -227,7 +227,7 @@
 			$dbh->do('DELETE FROM storage WHERE name_id = ?;', {}, $name_id);
 		}
 
-		$dbh->do('INSERT INTO storage (name_id,value) VALUES (?,?);', {}, $name_id, JSON->perl2JSON($value));
+		$dbh->do('INSERT INTO storage (name_id,value) VALUES (?,?);', {}, $name_id, OpenSRF::Utils::JSON->perl2JSON($value));
 
 		_flush_by_name($name);
 
@@ -344,7 +344,7 @@
 
 		_flush_by_name($name);
 
-		return JSON->JSON2perl( $value->[1] );
+		return OpenSRF::Utils::JSON->JSON2perl( $value->[1] );
 	} catch Error with {
 		#my $e = shift;
 		#return $e;
@@ -377,7 +377,7 @@
 	
 	my $values = $dbh->selectall_arrayref("SELECT value FROM storage WHERE name_id = ? ORDER BY id $order;", {}, $name_id);
 
-	$client->respond( JSON->JSON2perl( $_->[0] ) ) for (@$values);
+	$client->respond( OpenSRF::Utils::JSON->JSON2perl( $_->[0] ) ) for (@$values);
 
 	_flush_by_name($name);
 	return undef;
@@ -407,7 +407,7 @@
 
 	my $value = $dbh->selectcol_arrayref('SELECT SUM(LENGTH(value)) FROM storage WHERE name_id = ?;', {}, $name_id);
 
-	return JSON->JSON2perl( $value->[0] );
+	return OpenSRF::Utils::JSON->JSON2perl( $value->[0] );
 }
 __PACKAGE__->register_method(
 	api_name => 'opensrf.persist.queue.size',
@@ -436,7 +436,7 @@
 
 	my $value = $dbh->selectcol_arrayref('SELECT COUNT(*) FROM storage WHERE name_id = ?;', {}, $name_id);
 
-	return JSON->JSON2perl( $value->[0] );
+	return OpenSRF::Utils::JSON->JSON2perl( $value->[0] );
 }
 __PACKAGE__->register_method(
 	api_name => 'opensrf.persist.queue.length',
@@ -465,7 +465,7 @@
 
 		_flush_by_name($name);
 
-		return JSON->JSON2perl( $value->[1] );
+		return OpenSRF::Utils::JSON->JSON2perl( $value->[1] );
 	} catch Error with {
 		my $e = shift;
 		return undef;
@@ -498,7 +498,7 @@
 
 		_flush_by_name($name);
 
-		return JSON->JSON2perl( $value->[1] );
+		return OpenSRF::Utils::JSON->JSON2perl( $value->[1] );
 	} catch Error with {
 		return undef;
 	};

Modified: branches/autotools/src/perlmods/OpenSRF/Application.pm
===================================================================
--- branches/autotools/src/perlmods/OpenSRF/Application.pm	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/perlmods/OpenSRF/Application.pm	2007-07-18 05:21:54 UTC (rev 1045)
@@ -10,7 +10,7 @@
 use Time::HiRes qw/time/;
 use OpenSRF::EX qw/:try/;
 use Carp;
-use JSON;
+use OpenSRF::Utils::JSON;
 #use OpenSRF::UnixServer;  # to get the server class from UnixServer::App
 
 sub DESTROY{};
@@ -148,7 +148,7 @@
 							for my $p (0 .. scalar(@{ $sig->{params} }) - 1 ) {
 								my $s = $sig->{params}->[$p];
 								my $a = $args[$p];
-								if ($s->{class} && JSON->lookup_hint(ref $a) ne $s->{class}) {
+								if ($s->{class} && OpenSRF::Utils::JSON->lookup_hint(ref $a) ne $s->{class}) {
 									die "Incorrect param class at position $p : should be a '$$s{class}'";
 								} elsif ($s->{type}) {
 									if (lc($s->{type}) eq 'object' && $a !~ /HASH/o) {
@@ -225,7 +225,7 @@
 								for my $p (0 .. scalar(@{ $sig->{params} }) - 1 ) {
 									my $s = $sig->{params}->[$p];
 									my $a = $args[$p];
-									if ($s->{class} && JSON->lookup_hint(ref $a) ne $s->{class}) {
+									if ($s->{class} && OpenSRF::Utils::JSON->lookup_hint(ref $a) ne $s->{class}) {
 										die "Incorrect param class at position $p : should be a '$$s{class}'";
 									} elsif ($s->{type}) {
 										if (lc($s->{type}) eq 'object' && $a !~ /HASH/o) {
@@ -393,7 +393,7 @@
 		($args{object_hint} = $args{package}) =~ s/::/_/go;
 	}
 
-	JSON->register_class_hint( name => $args{package}, hint => $args{object_hint}, type => "hash" );
+	OpenSRF::Utils::JSON->register_class_hint( name => $args{package}, hint => $args{object_hint}, type => "hash" );
 
 	$_METHODS[$args{api_level}]{$args{api_name}} = bless \%args => $app;
 

Deleted: branches/autotools/src/perlmods/OpenSRF/DOM.pm
===================================================================
--- branches/autotools/src/perlmods/OpenSRF/DOM.pm	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/perlmods/OpenSRF/DOM.pm	2007-07-18 05:21:54 UTC (rev 1045)
@@ -1,289 +0,0 @@
-use XML::LibXML;
-use OpenSRF::Utils::Logger qw(:level);
-
-package XML::LibXML::Element;
-use OpenSRF::EX;
-
-sub AUTOLOAD {
-	my $self = shift;
-	(my $name = $AUTOLOAD) =~ s/.*://;   # strip fully-qualified portion
-
-	### Check for recursion
-	my $calling_method = (caller(1))[3];
-	my @info = caller(1);
-
-	if( @info ) {
-		if ($info[0] =~ /AUTOLOAD/) { @info = caller(2); }
-	}
-	unless( @info ) { @info = caller(); }
-	if( $calling_method  and $calling_method eq "XML::LibXML::Element::AUTOLOAD" ) {
-		throw OpenSRF::EX::PANIC ( "RECURSION! Caller [ @info ] | Object [ ".ref($self)." ]\n ** Trying to call $name", ERROR );
-	}
-	### Check for recursion
-	
-	#OpenSRF::Utils::Logger->debug( "Autoloading method for DOM: $AUTOLOAD on ".$self->toString, INTERNAL );
-
-	my $new_node = OpenSRF::DOM::upcast($self);
-	OpenSRF::Utils::Logger->debug( "Autoloaded to: ".ref($new_node), INTERNAL );
-
-	return $new_node->$name(@_);
-}
-
-
-
-#--------------------------------------------------------------------------------
-package OpenSRF::DOM;
-use base qw/XML::LibXML OpenSRF/;
-
-our %_NAMESPACE_MAP = (
-	'http://open-ils.org/xml/namespaces/oils_v1' => 'oils',
-);
-
-our $_one_true_parser;
-
-sub new {
-	my $self = shift;
-	return $_one_true_parser if (defined $_one_true_parser);
-	$_one_true_parser = $self->SUPER::new(@_);
-	$_one_true_parser->keep_blanks(0);
-	$XML::LibXML::skipXMLDeclaration = 0;
-	return $_one_true_parser = $self->SUPER::new(@_);
-}
-
-sub createDocument {
-	my $self = shift;
-
-	# DOM API: createDocument(namespaceURI, qualifiedName, doctype?)
-	my $doc = XML::LibXML::Document->new("1.0", "UTF-8");
-	my $el = $doc->createElement('root');
-
-	$el->setNamespace('http://open-ils.org/xml/namespaces/oils_v1', 'oils', 1);
-	$doc->setDocumentElement($el);
-
-	return $doc;
-}
-
-my %_loaded_classes;
-sub upcast {
-	my $node = shift;
-	return undef unless $node;
-
-	my ($ns,$tag) = split ':' => $node->nodeName;
-
-	return $node unless ($ns eq 'oils');
-
-	my $class = "OpenSRF::DOM::Element::$tag";
-	unless (exists $_loaded_classes{$class}) {
-		$class->use;
-		$_loaded_classes{$class} = 1;
-	}
-	if ($@) {
-		OpenSRF::Utils::Logger->error("Couldn't use $class! $@");
-	}
-
-	#OpenSRF::Utils::Logger->debug("Upcasting ".$node->toString." to $class", INTERNAL);
-
-	return bless $node => $class;
-}
-
-#--------------------------------------------------------------------------------
-package OpenSRF::DOM::Node;
-use base 'XML::LibXML::Node';
-
-sub new {
-	my $class = shift;
-	return bless $class->SUPER::new(@_) => $class;
-}
-
-sub childNodes {
-	my $self = shift;
-	my @children = $self->_childNodes();
-	return wantarray ? @children : OpenSRF::DOM::NodeList->new( @children );
-}
-
-sub attributes {
-	my $self = shift;
-	my @attr = $self->_attributes();
-	return wantarray ? @attr : OpenSRF::DOM::NamedNodeMap->new( @attr );
-}
-
-sub findnodes {
-	my ($node, $xpath) = @_;
-	my @nodes = $node->_findnodes($xpath);
-	if (wantarray) {
-		return @nodes;
-	} else {
-		return OpenSRF::DOM::NodeList->new(@nodes);
-	}
-}
-
-
-#--------------------------------------------------------------------------------
-package OpenSRF::DOM::NamedNodeMap;
-use base 'XML::LibXML::NamedNodeMap';
-
-#--------------------------------------------------------------------------------
-package OpenSRF::DOM::NodeList;
-use base 'XML::LibXML::NodeList';
-
-#--------------------------------------------------------------------------------
-package OpenSRF::DOM::Element;
-use base 'XML::LibXML::Element';
-
-sub new {
-	my $class = shift;
-
-	# magically create the element (tag) name, or build a blank element
-	(my $name = $class) =~ s/^OpenSRF::DOM::Element:://;
-	if ($name) {
-		$name = "oils:$name";
-	} else {
-		undef $name;
-	}
-
-	my $self = $class->SUPER::new($name);
-
-	my %attrs = @_;
-	for my $aname (keys %attrs) {
-		$self->setAttribute($aname, $attrs{$aname});
-	}
-
-	return $self;
-}
-
-sub getElementsByTagName {
-    my ( $node , $name ) = @_;
-        my $xpath = "descendant::$name";
-    my @nodes = $node->_findnodes($xpath);
-        return wantarray ? @nodes : OpenSRF::DOM::NodeList->new(@nodes);
-}
-
-sub  getElementsByTagNameNS {
-    my ( $node, $nsURI, $name ) = @_;
-    my $xpath = "descendant::*[local-name()='$name' and namespace-uri()='$nsURI']";
-    my @nodes = $node->_findnodes($xpath);
-    return wantarray ? @nodes : OpenSRF::DOM::NodeList->new(@nodes);
-}
-
-sub getElementsByLocalName {
-    my ( $node,$name ) = @_;
-    my $xpath = "descendant::*[local-name()='$name']";
-    my @nodes = $node->_findnodes($xpath);
-    return wantarray ? @nodes : OpenSRF::DOM::NodeList->new(@nodes);
-}
-
-sub getChildrenByLocalName {
-    my ( $node,$name ) = @_;
-    my $xpath = "./*[local-name()='$name']";
-    my @nodes = $node->_findnodes($xpath);
-    return @nodes;
-}
-
-sub getChildrenByTagName {
-    my ( $node, $name ) = @_;
-    my @nodes = grep { $_->nodeName eq $name } $node->childNodes();
-    return @nodes;
-}
-
-sub getChildrenByTagNameNS {
-    my ( $node, $nsURI, $name ) = @_;
-    my $xpath = "*[local-name()='$name' and namespace-uri()='$nsURI']";
-    my @nodes = $node->_findnodes($xpath);
-    return @nodes;
-}
-
-sub appendWellBalancedChunk {
-    my ( $self, $chunk ) = @_;
-
-    my $local_parser = OpenSRF::DOM->new();
-    my $frag = $local_parser->parse_xml_chunk( $chunk );
-
-    $self->appendChild( $frag );
-}
-
-package OpenSRF::DOM::Element::root;
-use base 'OpenSRF::DOM::Element';
-
-#--------------------------------------------------------------------------------
-package OpenSRF::DOM::Text;
-use base 'XML::LibXML::Text';
-
-
-#--------------------------------------------------------------------------------
-package OpenSRF::DOM::Comment;
-use base 'XML::LibXML::Comment';
-
-#--------------------------------------------------------------------------------
-package OpenSRF::DOM::CDATASection;
-use base 'XML::LibXML::CDATASection';
-
-#--------------------------------------------------------------------------------
-package OpenSRF::DOM::Document;
-use base 'XML::LibXML::Document';
-
-sub empty {
-	my $self = shift;
-	return undef unless (ref($self));
-	$self->documentElement->removeChild($_) for $self->documentElement->childNodes;
-	return $self;
-}
-
-sub new {
-	my $class = shift;
-	return bless $class->SUPER::new(@_) => $class;
-}
-
-sub getElementsByTagName {
-	my ( $doc , $name ) = @_;
-	my $xpath = "descendant-or-self::node()/$name";
-	my @nodes = $doc->_findnodes($xpath);
-	return wantarray ? @nodes : OpenSRF::DOM::NodeList->new(@nodes);
-}
-
-sub  getElementsByTagNameNS {
-	my ( $doc, $nsURI, $name ) = @_;
-	my $xpath = "descendant-or-self::*[local-name()='$name' and namespace-uri()='$nsURI']";
-	my @nodes = $doc->_findnodes($xpath);
-	return wantarray ? @nodes : OpenSRF::DOM::NodeList->new(@nodes);
-}
-
-sub getElementsByLocalName {
-	my ( $doc,$name ) = @_;
-	my $xpath = "descendant-or-self::*[local-name()='$name']";
-	my @nodes = $doc->_findnodes($xpath);
-	return wantarray ? @nodes : OpenSRF::DOM::NodeList->new(@nodes);
-}
-
-#--------------------------------------------------------------------------------
-package OpenSRF::DOM::DocumentFragment;
-use base 'XML::LibXML::DocumentFragment';
-
-#--------------------------------------------------------------------------------
-package OpenSRF::DOM::Attr;
-use base 'XML::LibXML::Attr';
-
-#--------------------------------------------------------------------------------
-package OpenSRF::DOM::Dtd;
-use base 'XML::LibXML::Dtd';
-
-#--------------------------------------------------------------------------------
-package OpenSRF::DOM::PI;
-use base 'XML::LibXML::PI';
-
-#--------------------------------------------------------------------------------
-package OpenSRF::DOM::Namespace;
-use base 'XML::LibXML::Namespace';
-
-sub isEqualNode {
-	my ( $self, $ref ) = @_;
-	if ( $ref->isa("XML::LibXML::Namespace") ) {
-		return $self->_isEqual($ref);
-	}
-	return 0;
-}
-
-#--------------------------------------------------------------------------------
-package OpenSRF::DOM::Schema;
-use base 'XML::LibXML::Schema';
-
-1;

Modified: branches/autotools/src/perlmods/OpenSRF/DomainObject/oilsMessage.pm
===================================================================
--- branches/autotools/src/perlmods/OpenSRF/DomainObject/oilsMessage.pm	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/perlmods/OpenSRF/DomainObject/oilsMessage.pm	2007-07-18 05:21:54 UTC (rev 1045)
@@ -1,18 +1,18 @@
 package OpenSRF::DomainObject::oilsMessage;
-use JSON;
+use OpenSRF::Utils::JSON;
 use OpenSRF::AppSession;
 use OpenSRF::DomainObject::oilsResponse qw/:status/;
 use OpenSRF::Utils::Logger qw/:level/;
 use warnings; use strict;
 use OpenSRF::EX qw/:try/;
 
-JSON->register_class_hint(hint => 'osrfMessage', name => 'OpenSRF::DomainObject::oilsMessage', type => 'hash');
+OpenSRF::Utils::JSON->register_class_hint(hint => 'osrfMessage', name => 'OpenSRF::DomainObject::oilsMessage', type => 'hash');
 
 sub toString {
 	my $self = shift;
 	my $pretty = shift;
-	return JSON->perl2prettyJSON($self) if ($pretty);
-	return JSON->perl2JSON($self);
+	return OpenSRF::Utils::JSON->perl2prettyJSON($self) if ($pretty);
+	return OpenSRF::Utils::JSON->perl2JSON($self);
 }
 
 sub new {

Modified: branches/autotools/src/perlmods/OpenSRF/DomainObject/oilsMethod.pm
===================================================================
--- branches/autotools/src/perlmods/OpenSRF/DomainObject/oilsMethod.pm	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/perlmods/OpenSRF/DomainObject/oilsMethod.pm	2007-07-18 05:21:54 UTC (rev 1045)
@@ -1,13 +1,13 @@
 package OpenSRF::DomainObject::oilsMethod;
 
-use JSON;
-JSON->register_class_hint(hint => 'osrfMethod', name => 'OpenSRF::DomainObject::oilsMethod', type => 'hash');
+use OpenSRF::Utils::JSON;
+OpenSRF::Utils::JSON->register_class_hint(hint => 'osrfMethod', name => 'OpenSRF::DomainObject::oilsMethod', type => 'hash');
 
 sub toString {
 	my $self = shift;
 	my $pretty = shift;
-	return JSON->perl2prettyJSON($self) if ($pretty);
-	return JSON->perl2JSON($self);
+	return OpenSRF::Utils::JSON->perl2prettyJSON($self) if ($pretty);
+	return OpenSRF::Utils::JSON->perl2JSON($self);
 }
 
 sub new {

Deleted: branches/autotools/src/perlmods/OpenSRF/DomainObject/oilsMultiSearch.pm
===================================================================
--- branches/autotools/src/perlmods/OpenSRF/DomainObject/oilsMultiSearch.pm	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/perlmods/OpenSRF/DomainObject/oilsMultiSearch.pm	2007-07-18 05:21:54 UTC (rev 1045)
@@ -1,186 +0,0 @@
-package OpenSRF::DomainObjectCollection::oilsMultiSearch;
-use OpenSRF::DomainObjectCollection;
-use OpenSRF::DomainObject::oilsPrimitive;
-use OpenSRF::DomainObject::oilsSearch;
-use OpenSRF::DOM::Element::searchCriteria;
-use OpenSRF::DOM::Element::searchCriterium;
-use base 'OpenSRF::DomainObjectCollection::oilsHash';
-
-sub new {
-	my $class = shift;
-	my %args = @_;
-
-	$class = ref($class) || $class;
-
-	my $self = $class->SUPER::new;
-
-	tie my %hash, 'OpenSRF::DomainObjectCollection::oilsHash', $self;
-
-	$self->set( bind_count	=> 1 );
-	$self->set( searches	=> new OpenSRF::DomainObjectCollection::oilsHash );
-	$self->set( relators	=> new OpenSRF::DomainObjectCollection::oilsArray );
-	$self->set( fields	=> new OpenSRF::DomainObjectCollection::oilsArray );
-	$self->set( group_by	=> new OpenSRF::DomainObjectCollection::oilsArray );
-	$self->set( order_by	=> new OpenSRF::DomainObjectCollection::oilsArray );
-	
-	return $self;
-}
-
-sub add_subsearch {
-	my $self = shift;
-	my $alias = shift;
-	my $search = shift;
-	my $relator = shift;
-	
-	$search = OpenSRF::DomainObject::oilsSearch->new($search) if (ref($search) eq 'ARRAY');
-
-	$self->searches->set( $alias => $search );
-	
-	if ($self->searches->size > 1) {
-		throw OpenSRF::EX::InvalidArg ('You need to pass a relator searchCriterium')
-			unless (defined $relator);
-	}
-
-	$relator = OpenSRF::DOM::Element::searchCriterium->new( @$relator )
-		if (ref($relator) eq 'ARRAY');
-
-	$self->relators->push( $relator ) if (defined $relator);
-
-	return $self;
-}
-
-sub relators {
-	return $_[0]->_accessor('relators');
-}
-
-sub searches {
-	return $_[0]->_accessor('searches');
-}
-
-sub fields {
-	my $self = shift;
-	my @parts = @_;
-	if (@parts) {
-		$self->set( fields => OpenSRF::DomainObjectCollection::oilsArray->new(@_) );
-	}
-	return $self->_accessor('fields')->list;
-}
-
-sub format {
-	$_[0]->set( format => $_[1] ) if (defined $_[1]);
-	return $_[0]->_accessor('format');
-}
-
-sub limit {
-	$_[0]->set( limit => $_[1] ) if (defined $_[1]);
-	return $_[0]->_accessor('limit');
-}
-
-sub offset {
-	$_[0]->set( offset => $_[1] ) if (defined $_[1]);
-	return $_[0]->_accessor('offset');
-}
-
-sub chunk_key {
-	$_[0]->set( chunk_key => $_[1] ) if (defined $_[1]);
-	return $_[0]->_accessor('chunk_key');
-}
-
-sub order_by {
-	my $self = shift;
-	my @parts = @_;
-	if (@parts) {
-		$self->set( order_by => OpenSRF::DomainObjectCollection::oilsArray->new(@_) );
-	}
-	return $self->_accessor('order_by')->list;
-}
-
-sub group_by {
-	my $self = shift;
-	my @parts = @_;
-	if (@parts) {
-		$self->set( group_by => OpenSRF::DomainObjectCollection::oilsArray->new(@_) );
-	}
-	return $self->_accessor('group_by')->list;
-}
-
-sub SQL_select_list {
-	my $self = shift;
-
-	if (my $sql = $self->_accessor('sql_select_list')) {
-		return $sql;
-	}
-
-	$self->set( sql_select_list => 'SELECT '.join(', ', $self->fields) ) if defined($self->fields);
-	return $self->_accessor('sql_select_list');
-}
-
-sub SQL_group_by {
-	my $self = shift;
-
-	if (my $sql = $self->_accessor('sql_group_by')) {
-		return $sql;
-	}
-
-	$self->set( sql_group_by => 'GROUP BY '.join(', ', $self->group_by) ) if defined($self->group_by);
-	return $self->_accessor('sql_group_by');
-}
-
-sub SQL_order_by {
-	my $self = shift;
-
-	if (my $sql = $self->_accessor('sql_order_by')) {
-		return $sql;
-	}
-
-	$self->set( sql_order_by => 'ORDER BY '.join(', ', $self->order_by) ) if defined($self->order_by);
-	return $self->_accessor('sql_order_by');
-}
-
-sub SQL_offset {
-	my $self = shift;
-
-	if (my $sql = $self->_accessor('sql_offset')) {
-		return $sql;
-	}
-
-	$self->set( sql_offset => 'OFFSET '.$self->offset ) if defined($self->offset);
-	return $self->_accessor('sql_offset');
-}
-
-sub SQL_limit {
-	my $self = shift;
-
-	if (my $sql = $self->_accessor('sql_limit')) {
-		return $sql;
-	}
-
-	$self->set( sql_limit => 'LIMIT '.$self->limit ) if defined($self->limit);
-	return $self->_accessor('sql_limit');
-}
-
-sub toSQL {
-	my $self = shift;
-
-	my $SQL = $self->SQL_select_list.' FROM ';
-
-	my @subselects;
-	for my $search ( $self->searches->keys ) {
-		push @subselects, '('.$self->searches->_accessor($search)->toSQL.') '.$search;
-	}
-	$SQL .= join(', ', @subselects).' WHERE ';
-
-	my @relators;
-	for my $rel ( $self->relators->list ) {
-		push @relators, $rel->value->toSQL( no_quote => 1 );
-	}
-	$SQL .= join(' AND ', @relators).' ';
-	$SQL .= join ' ', ($self->SQL_group_by, $self->SQL_order_by, $self->SQL_limit, $self->SQL_offset);
-
-	return $SQL;
-}
-
-#this is just to allow DomainObject to "upcast" nicely
-package OpenSRF::DomainObject::oilsMultiSearch;
-use base OpenSRF::DomainObjectCollection::oilsMultiSearch;
-1;

Deleted: branches/autotools/src/perlmods/OpenSRF/DomainObject/oilsPrimitive.pm
===================================================================
--- branches/autotools/src/perlmods/OpenSRF/DomainObject/oilsPrimitive.pm	2007-07-17 14:50:56 UTC (rev 1044)
+++ branches/autotools/src/perlmods/OpenSRF/DomainObject/oilsPrimitive.pm	2007-07-18 05:21:54 UTC (rev 1045)
@@ -1,623 +0,0 @@
-package OpenSRF::DomainObject::oilsScalar;
-use base 'OpenSRF::DomainObject';
-use OpenSRF::DomainObject;
-
-=head1 NAME
-
-OpenSRF::DomainObject::oilsScalar
-
-=head1 SYNOPSIS
-
-  use OpenSRF::DomainObject::oilsScalar;
-
-  my $text = OpenSRF::DomainObject::oilsScalar->new( 'a string or number' );
-  $text->value( 'replacement value' );
-  print "$text"; # stringify
-
-   ...
-
-  $text->value( 1 );
-  if( $text ) { # boolify
-
-   ...
-
-  $text->value( rand() * 1000 );
-  print 10 + $text; # numify
-
-    Or, using the TIE interface:
-
-  my $scalar;
-  my $real_object = tie($scalar, 'OpenSRF::DomainObject::oilsScalar', "a string to store...");
-
-  $scalar = "a new string";
-  print $scalar . "\n";
-  print $real_object->toString . "\n";
-
-=head1 METHODS
-
-=head2 OpenSRF::DomainObject::oilsScalar->value( [$new_value] )
-
-=over 4
-
-Sets or gets the value of the scalar.  As above, this can be specified
-as a build attribute as well as added to a prebuilt oilsScalar object.
-
-=back
-
-=cut
-
-use overload '""'   => sub { return ''.$_[0]->value };
-use overload '0+'   => sub { return int($_[0]->value) };
-use overload '<=>'   => sub { return int($_[0]->value) <=> $_[1] };
-use overload 'bool' => sub { return 1 if ($_[0]->value); return 0 };
-
-sub new {
-	my $class = shift;
-	$class = ref($class) || $class;
-
-	my $value = shift;
-
-	return $value
-		if (	defined $value and
-			ref $value and $value->can('base_type') and
-			UNIVERSAL::isa($value->class, __PACKAGE__) and
-			!scalar(@_)
-		);
-
-	my $self = $class->SUPER::new;
-
-	if (ref($value) and ref($value) eq 'SCALAR') {
-		$self->value($$value);
-		tie( $$value, ref($self->upcast), $self);
-	} else {
-		$self->value($value) if (defined $value);
-	}
-
-	return $self;
-}
-
-sub TIESCALAR {
-	return CORE::shift()->new(@_);
-}
-
-sub value {
-	my $self = shift;
-	my $value = shift;
-
-	if ( defined $value ) {
-		$self->removeChild($_) for ($self->childNodes);
-		if (ref($value) && $value->isa('XML::LibXML::Node')) {
-			#throw OpenSRF::EX::NotADomainObject
-			#	unless ($value->nodeName =~ /^oils:domainObject/o);
-			$self->appendChild($value);
-		} elsif (defined $value) {
-			$self->appendText( ''.$value );
-		}
-
-		return $value
-	} else {
-		$value = $self->firstChild;
-		if ($value) {
-			if ($value->nodeType == 3) {
-				return $value->textContent;
-			} else {
-				return $value;
-			}
-		}
-		return undef;
-	}
-}
-
-sub FETCH { $_[0]->value }
-sub STORE { $_[0]->value($_[1]) }
-
-package OpenSRF::DomainObject::oilsPair;
-use base 'OpenSRF::DomainObject::oilsScalar';
-
-=head1 NAME
-
-OpenSRF::DomainObject::oilsPair
-
-=head1 SYNOPSIS
-
-  use OpenSRF::DomainObject::oilsPair;
-
-  my $pair = OpenSRF::DomainObject::oilsPair->new( 'key_for_pair' => 'a string or number' );
-
-  $pair->key( 'replacement key' );
-  $pair->value( 'replacement value' );
-
-  print "$pair"; # stringify 'value'
-
-   ...
-
-  $pair->value( 1 );
-
-  if( $pair ) { # boolify
-
-   ...
-
-  $pair->value( rand() * 1000 );
-
-  print 10 + $pair; # numify 'value'
-
-=head1 ABSTRACT
-
-This class impliments a "named pair" object.  This is the basis for
-hash-type domain objects.
-
-=head1 METHODS
-
-=head2 OpenSRF::DomainObject::oilsPair->value( [$new_value] )
-
-=over 4
-
-Sets or gets the value of the pair.  As above, this can be specified
-as a build attribute as well as added to a prebuilt oilsPair object.
-
-=back
-
-=head2 OpenSRF::DomainObject::oilsPair->key( [$new_key] )
-
-=over 4
-
-Sets or gets the key of the pair.  As above, this can be specified
-as a build attribute as well as added to a prebuilt oilsPair object.
-This must be a perlish scalar; any string or number that is valid as the 
-attribute on an XML node will work.
-
-=back
-
-=cut
-
-use overload '""'   => sub { return ''.$_[0]->value };
-use overload '0+'   => sub { return int($_[0]->value) };
-use overload 'bool' => sub { return 1 if ($_[0]->value); return 0 };
-
-sub new {
-	my $class = shift;
-	my ($key, $value) = @_;
-
-	my $self = $class->SUPER::new($value);
-	$self->setAttribute( key => $key);
-
-	return $self;
-}
-
-sub key {
-	my $self = shift;
-	my $key = shift;
-
-	$self->setAttribute( key => $key) if ($key);
-	return $self->getAttribute( 'key' );
-}
-
-package OpenSRF::DomainObjectCollection::oilsArray;
-use base qw/OpenSRF::DomainObjectCollection Tie::Array/;
-use OpenSRF::DomainObjectCollection;
-
-=head1 NAME
-
-OpenSRF::DomainObjectCollection::oilsArray
-
-=head1 SYNOPSIS
-
-  use OpenSRF::DomainObject::oilsPrimitive;
-
-  my $collection = OpenSRF::DomainObjectCollection::oilsArray->new( $domain_object, $another_domain_object, ...);
-
-  $collection->push( 'appended value' );
-  $collection->unshift( 'prepended vaule' );
-  my $first = $collection->shift;
-  my $last = $collection->pop;
-
-   ...
-
-  my @values = $collection->list;
-
-    Or, using the TIE interface:
-
-  my @array;
-  my $real_object = tie(@array, 'OpenSRF::DomainObjectCollection::oilsArray', $domain, $objects, 'to', $store);
-
-      or to tie an existing $collection object
-
-  my @array;
-  tie(@array, 'OpenSRF::DomainObjectCollection::oilsArray', $collection);
-
-      or even....
-
-  my @array;
-  tie(@array, ref($collection), $collection);
-
-
-  $array[2] = $DomainObject; # replaces 'to' (which is now an OpenSRF::DomainObject::oilsScalar) above
-  delete( $array[3] ); # removes '$store' above.
-  my $size = scalar( @array );
-
-  print $real_obj