You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by jd...@apache.org on 2009/04/22 19:25:51 UTC

svn commit: r767594 [2/43] - in /incubator/etch/trunk/binding-c/runtime/c: ./ ext/ ext/hashtab/ ext/lib/ inc/ lib/ project/ project/$etchstop/ project/bin/ project/etch/ project/logcli/ project/logsrv/ project/notes/ project/test/ project/test/logcli/ ...

Added: incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkhtab.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkhtab.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkhtab.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkhtab.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,233 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/*
+--------------------------------------------------------------------
+By Bob Jenkins, 1996.  hash.h.  Public Domain.
+
+This implements a hash table.
+* Keys are unique.  Adding an item fails if the key is already there.
+* Keys and items are pointed at, not copied.  If you change the value
+  of the key after it is inserted then hfind will not be able to find it.
+* The hash table maintains a position that can be set and queried.
+* The table length doubles dynamically and never shrinks.  The insert
+  that causes table doubling may take a long time.
+* The table length splits when the table length equals the number of items
+  Comparisons usually take 7 instructions.
+  Computing a hash value takes 35+6n instructions for an n-byte key.
+
+  hcreate  - create a hash table
+  hdestroy - destroy a hash table
+   hcount  - The number of items in the hash table
+   hkey    - key at the current position
+   hkeyl   - key length at the current position
+   hstuff  - stuff at the current position
+  hfind    - find an item in the table
+   hadd    - insert an item into the table
+   hdel    - delete an item from the table
+  hstat    - print statistics about the table
+   hfirst  - position at the first item in the table
+   hnext   - move the position to the next item in the table
+--------------------------------------------------------------------
+*/
+
+#ifndef HASHTAB
+#define HASHTAB
+#include "jenkstd.h"
+
+#define HASHTAB_DEBUG /* #define HASHTAB_DEBUG to display debug info */
+
+/* PRIVATE TYPES AND DEFINITIONS */
+
+struct hitem
+{
+  ub1          *key;      /* key that is hashed */
+  ub4           keyl;     /* length of key */
+  void         *stuff;    /* stuff stored in this hitem */
+  ub4           hval;     /* hash value */
+  struct hitem *next;     /* next hitem in list */
+};
+typedef struct hitem  hitem;
+
+
+struct htab
+{
+  struct hitem **table;   /* hash table, array of size 2^logsize */
+  intx           logsize; /* log of size of table */
+  size_t         mask;    /* (hashval & mask) is position in table */
+  ub4            count;   /* how many items in this hash table so far? */
+  ub4            apos;    /* position in the array */
+  struct hitem  *ipos;    /* current item in the array */
+  struct reroot *space;   /* space for the hitems */
+  ub4            bcount;  /* # hitems useable in current block */
+};
+typedef struct htab  htab;
+
+
+/* PUBLIC FUNCTIONS */
+
+/* hcreate - create a hash table
+   ARGUMENTS:
+     logsize - 1<<logsize will be the initial table length
+   RETURNS:
+     the new table
+ */
+htab *hcreate(intx logsize);
+
+
+/* hdestroy - destroy a hash table
+   ARGUMENTS:
+     t - the hash table to be destroyed.  Note that the items and keys
+         will not be freed, the user created them and must destroy
+         them himself.
+   RETURNS:
+     nothing
+ */
+void  hdestroy(htab *t);
+
+
+/* hcount, hkey, hkeyl, hstuff
+     ARGUMENTS:
+     t - the hash table
+   RETURNS:
+     hcount - (ub4)    The number of items in the hash table
+     hkey   - (ub1 *)  key for the current item
+     hkeyl  - (ub4)    key length for the current item
+     hstuff - (void *) stuff for the current item
+   NOTE:
+     The current position always has an item as long as there
+       are items in the table, so hexist can be used to test if the
+       table is empty.
+     hkey, hkeyl, and hstuff will crash if hcount returns 0
+ */
+#define hcount(t) ((t)->count)
+#define hkey(t)   ((t)->ipos->key)
+#define hkeyl(t)  ((t)->ipos->keyl)
+#define hstuff(t) ((t)->ipos->stuff)
+
+
+
+/* hfind - move the current position to a given key
+   ARGUMENTS:
+     t    - the hash table
+     key  - the key to look for
+     keyl - length of the key
+   RETURNS:
+     TRUE if the item exists, FALSE if it does not.
+     If the item exists, moves the current position to that item.
+ */
+intx hfind(htab *t, ub1 *key, ub4 keyl);
+
+intx hfindx(htab* t, const ub4 hashed);
+
+
+/* hadd - add a new item to the hash table
+          change the position to point at the item with the key
+   ARGUMENTS:
+     t     - the hash table
+     key   - the key to look for
+     keyl  - length of the key
+     stuff - other stuff to be stored in this item
+   RETURNS:
+     FALSE if the operation fails (because that key is already there).
+ */
+intx hadd (htab *t, ub1 *key, ub4 keyl, void *stuff);
+
+intx haddx(htab *t, void *keyobj, void *stuff); 
+
+
+/* hdel - delete the item at the current position
+          change the position to the following item
+  ARGUMENTS:
+    t    - the hash table
+  RETURNS:
+    FALSE if there is no current item (meaning the table is empty)
+  NOTE:
+    This frees the item, but not the key or stuff stored in the item.
+    If you want these then deal with them first.  For example:
+      if (hfind(tab, key, keyl))
+      {
+        free(hkey(tab));
+        free(hstuff(tab));
+        hdel(tab);
+      }
+ */
+intx hdel(htab *t);
+
+
+/* hfirst - move position to the first item in the table
+  ARGUMENTS:
+    t    - the hash table
+  RETURNS:
+    FALSE if there is no current item (meaning the table is empty)
+  NOTE:
+ */
+intx hfirst(htab *t);
+
+
+/* hnext - move position to the next item in the table
+  ARGUMENTS:
+    t    - the hash table
+  RETURNS:
+    FALSE if the position wraps around to the beginning of the table
+  NOTE:
+    To see every item in the table, do
+      if (hfirst(t)) do
+      {
+        key   = hkey(t);
+        stuff = hstuff(t);
+      }
+      while (hnext(t));
+ */
+
+/* intx hnext(htab *t); */
+
+#define hnext(t) \
+  ((!(t)->ipos) ? FALSE :  \
+    ((t)->ipos=(t)->ipos->next) ? TRUE : hnbucket(t))
+
+/* hnbucket - PRIVATE - move to first item in the next nonempty bucket
+  ARGUMENTS:
+    t    - the hash table
+  RETURNS:
+    FALSE if the position wraps around to the beginning of the table
+  NOTE:
+    This is private to hashtab; do not use it externally.
+ */
+intx hnbucket(htab *t);
+
+
+/* hstat - print statistics about the hash table
+  ARGUMENTS:
+    t    - the hash table
+  NOTE:
+    items <0>:  <#buckets with zero items> buckets
+    items <1>:  <#buckets with 1 item> buckets
+    ...
+    buckets: #buckets  items: #items  existing: x
+    ( x is the average length of the list when you look for an
+      item that exists.  When the item does not exists, the average
+      length is #items/#buckets. )
+
+    If you put n items into n buckets, expect 1/(n!)e buckets to
+    have n items.  That is, .3678 0, .3678 1, .1839 2, ...
+    Also expect "existing" to be about 2.
+ */
+void hstat(htab *t);
+
+#endif   /* HASHTAB */

Added: incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenklook.c
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenklook.c?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenklook.c (added)
+++ incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenklook.c Wed Apr 22 17:25:43 2009
@@ -0,0 +1,262 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+
+/*
+--------------------------------------------------------------------
+lookupa.c, by Bob Jenkins, December 1996.  Same as lookup2.c
+Use this code however you wish.  Public Domain.  No warranty.
+Source is http://burtleburtle.net/bob/c/lookupa.c
+--------------------------------------------------------------------
+*/
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "jenkstd.h"
+#include "jenklook.h"
+
+
+/*
+--------------------------------------------------------------------
+mix -- mix 3 32-bit values reversibly.
+For every delta with one or two bit set, and the deltas of all three
+  high bits or all three low bits, whether the original value of a,b,c
+  is almost all zero or is uniformly distributed,
+* If mix() is run forward or backward, at least 32 bits in a,b,c
+  have at least 1/4 probability of changing.
+* If mix() is run forward, every bit of c will change between 1/3 and
+  2/3 of the time.  (Well, 22/100 and 78/100 for some 2-bit deltas.)
+mix() was built out of 36 single-cycle latency instructions in a 
+  structure that could supported 2x parallelism, like so:
+      a -= b; 
+      a -= c; x = (c>>13);
+      b -= c; a ^= x;
+      b -= a; x = (a<<8);
+      c -= a; b ^= x;
+      c -= b; x = (b>>13);
+      ...
+  Unfortunately, superscalar Pentiums and Sparcs can't take advantage 
+  of that parallelism.  They've also turned some of those single-cycle
+  latency instructions into multi-cycle latency instructions.  Still,
+  this is the fastest good hash I could find.  There were about 2^^68
+  to choose from.  I only looked at a billion or so.
+--------------------------------------------------------------------
+*/
+#define mix(a,b,c) \
+{ \
+  a -= b; a -= c; a ^= (c>>13); \
+  b -= c; b -= a; b ^= (a<<8); \
+  c -= a; c -= b; c ^= (b>>13); \
+  a -= b; a -= c; a ^= (c>>12);  \
+  b -= c; b -= a; b ^= (a<<16); \
+  c -= a; c -= b; c ^= (b>>5); \
+  a -= b; a -= c; a ^= (c>>3);  \
+  b -= c; b -= a; b ^= (a<<10); \
+  c -= a; c -= b; c ^= (b>>15); \
+}
+
+/*
+--------------------------------------------------------------------
+lookup() -- hash a variable-length key into a 32-bit value
+  k     : the key (the unaligned variable-length array of bytes)
+  len   : the length of the key, counting by bytes
+  level : the previous hash, or an arbitrary 4-byte value
+Returns a 32-bit value.  Every bit of the key affects every bit of
+the return value.  Every 1-bit and 2-bit delta achieves avalanche.
+About 6len+35 instructions.
+
+The best hash table sizes are powers of 2.  There is no need to do
+mod a prime (mod is sooo slow!).  If you need less than 32 bits,
+use a bitmask.  For example, if you need only 10 bits, do
+  h = (h & hashmask(10));
+In which case, the hash table should have hashsize(10) elements.
+
+If you are hashing n strings (ub1 **)k, do it like this:
+  for (i=0, h=0; i<n; ++i) h = lookup( k[i], len[i], h);
+
+By Bob Jenkins, 1996.  bob_jenkins@burtleburtle.net.  You may use this
+code any way you wish, private, educational, or commercial.
+
+See http://burtleburtle.net/bob/hash/evahash.html
+Use for hash table lookup, or anything where one collision in 2^32 is
+acceptable.  Do NOT use for cryptographic purposes.
+--------------------------------------------------------------------
+*/
+
+ub4 lookup(register ub1 *k, register ub4 length, register ub4 level)
+{
+   register ub4 a,b,c,len;
+
+   /* Set up the internal state */
+   len = length;
+   a = b = 0x9e3779b9;  /* the golden ratio; an arbitrary value */
+   c = level;           /* the previous hash value */
+
+   /*---------------------------------------- handle most of the key */
+   while (len >= 12)
+   {
+      a += (k[0] +((ub4)k[1]<<8) +((ub4)k[2]<<16) +((ub4)k[3]<<24));
+      b += (k[4] +((ub4)k[5]<<8) +((ub4)k[6]<<16) +((ub4)k[7]<<24));
+      c += (k[8] +((ub4)k[9]<<8) +((ub4)k[10]<<16)+((ub4)k[11]<<24));
+      mix(a,b,c);
+      k += 12; len -= 12;
+   }
+
+   /*------------------------------------- handle the last 11 bytes */
+   c += length;
+   switch(len)              /* all the case statements fall through */
+   {
+   case 11: c+=((ub4)k[10]<<24);
+   case 10: c+=((ub4)k[9]<<16);
+   case 9 : c+=((ub4)k[8]<<8);
+      /* the first byte of c is reserved for the length */
+   case 8 : b+=((ub4)k[7]<<24);
+   case 7 : b+=((ub4)k[6]<<16);
+   case 6 : b+=((ub4)k[5]<<8);
+   case 5 : b+=k[4];
+   case 4 : a+=((ub4)k[3]<<24);
+   case 3 : a+=((ub4)k[2]<<16);
+   case 2 : a+=((ub4)k[1]<<8);
+   case 1 : a+=k[0];
+     /* case 0: nothing left to add */
+   }
+   mix(a,b,c);
+   /*-------------------------------------------- report the result */
+   return c;
+}
+
+
+/*
+--------------------------------------------------------------------
+mixc -- mixc 8 4-bit values as quickly and thoroughly as possible.
+Repeating mix() three times achieves avalanche.
+Repeating mix() four times eliminates all funnels and all
+  characteristics stronger than 2^{-11}.
+--------------------------------------------------------------------
+*/
+#define mixc(a,b,c,d,e,f,g,h) \
+{ \
+   a^=b<<11; d+=a; b+=c; \
+   b^=c>>2;  e+=b; c+=d; \
+   c^=d<<8;  f+=c; d+=e; \
+   d^=e>>16; g+=d; e+=f; \
+   e^=f<<10; h+=e; f+=g; \
+   f^=g>>4;  a+=f; g+=h; \
+   g^=h<<8;  b+=g; h+=a; \
+   h^=a>>9;  c+=h; a+=b; \
+}
+
+/*
+--------------------------------------------------------------------
+checksum() -- hash a variable-length key into a 256-bit value
+  k     : the key (the unaligned variable-length array of bytes)
+  len   : the length of the key, counting by bytes
+  state : an array of CHECKSTATE 4-byte values (256 bits)
+The state is the checksum.  Every bit of the key affects every bit of
+the state.  There are no funnels.  About 112+6.875len instructions.
+
+If you are hashing n strings (ub1 **)k, do it like this:
+  for (i=0; i<8; ++i) state[i] = 0x9e3779b9;
+  for (i=0, h=0; i<n; ++i) checksum( k[i], len[i], state);
+
+(c) Bob Jenkins, 1996.  bob_jenkins@burtleburtle.net.  You may use this
+code any way you wish, private, educational, or commercial, as long
+as this whole comment accompanies it.
+
+See http://burtleburtle.net/bob/hash/evahash.html
+Use to detect changes between revisions of documents, assuming nobody
+is trying to cause collisions.  Do NOT use for cryptography.
+--------------------------------------------------------------------
+*/
+void  checksum( k, len, state)
+register ub1 *k;
+register ub4  len;
+register ub4 *state;
+{
+   register ub4 a,b,c,d,e,f,g,h,length;
+
+   /* Use the length and level; add in the golden ratio. */
+   length = len;
+   a=state[0]; b=state[1]; c=state[2]; d=state[3];
+   e=state[4]; f=state[5]; g=state[6]; h=state[7];
+
+   /*---------------------------------------- handle most of the key */
+   while (len >= 32)
+   {
+      a += (k[0] +(k[1]<<8) +(k[2]<<16) +(k[3]<<24));
+      b += (k[4] +(k[5]<<8) +(k[6]<<16) +(k[7]<<24));
+      c += (k[8] +(k[9]<<8) +(k[10]<<16)+(k[11]<<24));
+      d += (k[12]+(k[13]<<8)+(k[14]<<16)+(k[15]<<24));
+      e += (k[16]+(k[17]<<8)+(k[18]<<16)+(k[19]<<24));
+      f += (k[20]+(k[21]<<8)+(k[22]<<16)+(k[23]<<24));
+      g += (k[24]+(k[25]<<8)+(k[26]<<16)+(k[27]<<24));
+      h += (k[28]+(k[29]<<8)+(k[30]<<16)+(k[31]<<24));
+      mixc(a,b,c,d,e,f,g,h);
+      mixc(a,b,c,d,e,f,g,h);
+      mixc(a,b,c,d,e,f,g,h);
+      mixc(a,b,c,d,e,f,g,h);
+      k += 32; len -= 32;
+   }
+
+   /*------------------------------------- handle the last 31 bytes */
+   h += length;
+   switch(len)
+   {
+   case 31: h+=(k[30]<<24);
+   case 30: h+=(k[29]<<16);
+   case 29: h+=(k[28]<<8);
+   case 28: g+=(k[27]<<24);
+   case 27: g+=(k[26]<<16);
+   case 26: g+=(k[25]<<8);
+   case 25: g+=k[24];
+   case 24: f+=(k[23]<<24);
+   case 23: f+=(k[22]<<16);
+   case 22: f+=(k[21]<<8);
+   case 21: f+=k[20];
+   case 20: e+=(k[19]<<24);
+   case 19: e+=(k[18]<<16);
+   case 18: e+=(k[17]<<8);
+   case 17: e+=k[16];
+   case 16: d+=(k[15]<<24);
+   case 15: d+=(k[14]<<16);
+   case 14: d+=(k[13]<<8);
+   case 13: d+=k[12];
+   case 12: c+=(k[11]<<24);
+   case 11: c+=(k[10]<<16);
+   case 10: c+=(k[9]<<8);
+   case 9 : c+=k[8];
+   case 8 : b+=(k[7]<<24);
+   case 7 : b+=(k[6]<<16);
+   case 6 : b+=(k[5]<<8);
+   case 5 : b+=k[4];
+   case 4 : a+=(k[3]<<24);
+   case 3 : a+=(k[2]<<16);
+   case 2 : a+=(k[1]<<8);
+   case 1 : a+=k[0];
+   }
+   mixc(a,b,c,d,e,f,g,h);
+   mixc(a,b,c,d,e,f,g,h);
+   mixc(a,b,c,d,e,f,g,h);
+   mixc(a,b,c,d,e,f,g,h);
+
+   /*-------------------------------------------- report the result */
+   state[0]=a; state[1]=b; state[2]=c; state[3]=d;
+   state[4]=e; state[5]=f; state[6]=g; state[7]=h;
+}

Added: incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenklook.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenklook.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenklook.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenklook.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,42 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/*
+------------------------------------------------------------------------------
+By Bob Jenkins, September 1996.
+lookupa.h, a hash function for table lookup, same function as lookup.c.
+Use this code in any way you wish.  Public Domain.  It has no warranty.
+Source is http://burtleburtle.net/bob/c/lookupa.h
+------------------------------------------------------------------------------
+*/
+
+#ifndef LOOKUPA
+#define LOOKUPA
+
+#ifndef STANDARD
+#include "jenkstd.h"
+#endif
+
+#define CHECKSTATE 8
+#define hashsize(n) ((ub4)1<<(n))
+#define hashmask(n) (hashsize(n)-1)
+
+ub4  lookup(ub1 *k, ub4 length, ub4 level);
+void checksum(ub1 *k, ub4 length, ub4 *state);
+
+#endif /* LOOKUPA */

Added: incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkmake.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkmake.txt?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkmake.txt (added)
+++ incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkmake.txt Wed Apr 22 17:25:43 2009
@@ -0,0 +1,19 @@
+CFLAGS = -O
+
+.cc.o:
+	gcc $(CFLAGS) -c $<
+
+O = recycle.o lookupa.o hashtab.o unique.o
+
+unique : $(O)
+	gcc -o unique $(O) -lm
+
+# DEPENDENCIES
+
+recycle.o : recycle.c standard.h recycle.h
+
+lookupa.o : lookupa.c standard.h lookupa.h
+
+hashtab.o : hashtab.c standard.h recycle.h lookupa.h hashtab.h
+
+unique.o  : unique.c standard.h hashtab.h

Added: incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkrecy.c
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkrecy.c?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkrecy.c (added)
+++ incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkrecy.c Wed Apr 22 17:25:43 2009
@@ -0,0 +1,105 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/*
+--------------------------------------------------------------------
+By Bob Jenkins, September 1996.  recycle.c
+You may use this code in any way you wish, and it is free.  No warranty.
+
+This manages memory for commonly-allocated structures.
+It allocates RESTART to REMAX items at a time.
+Timings have shown that, if malloc is used for every new structure,
+malloc will consume about 90% of the time in a program.  
+This module cuts down the number of mallocs by an order of magnitude.
+This also decreases memory fragmentation, and freeing structures
+only requires freeing the root.
+--------------------------------------------------------------------
+*/
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "jenkstd.h"
+#include "jenkrecy.h"
+
+
+reroot *remkroot(size_t size)
+{
+   reroot *r = (reroot*) remalloc(sizeof(reroot), "recycle.c, root");
+   r->list  = (recycle*)0;
+   r->trash = (recycle*)0;
+   r->size  = align(size);
+   r->logsize = RESTART;
+   r->numleft = 0;
+   return r;
+}
+
+
+
+void refree(struct reroot *r)
+{
+   recycle *temp;
+   if (temp = r->list) while (r->list)
+   {
+      temp = r->list->next;
+      free((char *)r->list);
+      r->list = temp;
+   }
+   free((char *)r);
+   return;
+}
+
+
+
+/* to be called from the macro renew only */
+char *renewx(struct reroot *r)
+{
+   recycle *temp;
+   if (r->trash)
+   {  /* pull a node off the trash heap */
+      temp = r->trash;
+      r->trash = temp->next;
+      (void)memset((void *)temp, 0, r->size);
+   }
+   else
+   {  /* allocate a new block of nodes */
+      r->numleft = (int) r->size*((ub4)1<<r->logsize);
+      if (r->numleft < REMAX) ++r->logsize;
+      temp = (recycle *)remalloc(sizeof(recycle) + r->numleft, 
+				 "recycle.c, data");
+      temp->next = r->list;
+      r->list = temp;
+      r->numleft -= (int) r->size;
+      temp = (recycle *)((char *)(r->list+1)+r->numleft);
+   }
+   return (char *)temp;
+}
+
+
+char *remalloc(size_t len, char* purpose)
+{
+  char *x = (char*) malloc(len);
+  if (!x)
+  {
+    fprintf(stderr, "malloc %d failed for %s\n", len, purpose);
+    exit(SUCCESS);
+  }
+  return x;
+}
+

Added: incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkrecy.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkrecy.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkrecy.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkrecy.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,82 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/*
+--------------------------------------------------------------------
+By Bob Jenkins, September 1996.  recycle.h
+You may use this code in any way you wish, and it is free.  No warranty.
+
+This manages memory for commonly-allocated structures.
+It allocates RESTART to REMAX items at a time.
+Timings have shown that, if malloc is used for every new structure,
+  malloc will consume about 90% of the time in a program.  This
+  module cuts down the number of mallocs by an order of magnitude.
+This also decreases memory fragmentation, and freeing all structures
+  only requires freeing the root.
+--------------------------------------------------------------------
+*/
+
+#include "jenkstd.h"
+
+#ifndef RECYCLE
+#define RECYCLE
+
+#define RESTART    0
+#define REMAX      32000
+
+struct recycle
+{
+   struct recycle *next;
+};
+typedef struct recycle recycle;
+
+struct reroot
+{
+   struct recycle *list;     /* list of malloced blocks */
+   struct recycle *trash;    /* list of deleted items */
+   size_t          size;     /* size of an item */
+   size_t          logsize;  /* log_2 of number of items in a block */
+   intx            numleft;  /* number of bytes left in this block */
+};
+typedef  struct reroot  reroot;
+
+/* make a new recycling root */
+reroot *remkroot(size_t mysize);
+
+/* free a recycling root and all the items it has made */
+void refree(struct reroot *r);
+
+/* get a new (cleared) item from the root */
+#define renew(r) ((r)->numleft ? \
+   (((char *)((r)->list+1))+((r)->numleft-=(int)(r)->size)) : renewx(r))
+
+char *renewx(struct reroot *r);
+
+
+/* delete an item; let the root recycle it */
+/* void redel(/o_ struct reroot *r, struct recycle *item _o/); */
+#define redel(root,item) { \
+   ((recycle *)item)->next=(root)->trash; \
+   (root)->trash=(recycle *)(item); \
+}
+
+/* malloc, but complain to stderr and exit program if no joy */
+/* use plain free() to free memory allocated by remalloc() */
+char *remalloc(size_t len, char *purpose);
+
+#endif  /* RECYCLE */

Added: incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkstd.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkstd.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkstd.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenkstd.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,106 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/*
+------------------------------------------------------------------------------
+Standard definitions and types, Bob Jenkins
+------------------------------------------------------------------------------
+*/
+#ifndef STANDARD
+#define STANDARD
+
+/*
+   JLD cisco systems: ensure VS 2005 wide character support is turned on.
+   These definitions are enabled in the VS project, however for Linux and etc.
+   they may serve as a reminder that an etch binding should be unicode enabled.
+*/
+#ifndef _UNICODE    /* defined by default in VS2005 */
+#define _UNICODE
+#endif
+
+#include "tchar.h"  /* wide char support, wmain() vs main() */
+
+#ifndef UNICODE     /* defined by default in VS2005 */
+#define UNICODE
+#endif
+/*
+   end VS 2005 wide character support -- JLD
+*/
+ 
+#include <stdio.h>
+#include <stddef.h>
+
+typedef  unsigned long long  ub8;
+#define UB8MAXVAL 0xffffffffffffffffLL
+#define UB8BITS 64
+typedef    signed long long  sb8;
+#define SB8MAXVAL 0x7fffffffffffffffLL
+typedef  unsigned long  int  ub4;   /* unsigned 4-byte quantities */
+#define UB4MAXVAL 0xffffffff
+typedef    signed long  int  sb4;
+#define UB4BITS 32
+#define SB4MAXVAL 0x7fffffff
+typedef  unsigned short int  ub2;
+#define UB2MAXVAL 0xffff
+#define UB2BITS 16
+typedef    signed short int  sb2;
+#define SB2MAXVAL 0x7fff
+typedef  unsigned       char ub1;
+#define UB1MAXVAL 0xff
+#define UB1BITS 8
+typedef    signed       char sb1;   /* signed 1-byte quantities */
+#define SB1MAXVAL 0x7f
+
+/* JLD replaced Jenkins' 'word' typdef with 'intx'. 'word' is too 
+   likely to be confused by the reader with a Windows 16-bit integer.
+   intx is brief, and is more readable as 'the register size on the
+   host OS". It remains unclear whether simply changing this typedef to 
+   a 64-bit integer, on a 64-bit OS, is sufficient for the hashtable
+   to work as advertised in 64 bits. See macro renew() for example,
+   where it appears as if sizeof(char*) is assumed same as sizeof(int).   
+*/
+typedef int intx; 
+/* typedef int  word fastest type available */
+
+#define bis(target,mask)  ((target) |=  (mask))
+#define bic(target,mask)  ((target) &= ~(mask))
+#define bit(target,mask)  ((target) &   (mask))
+
+/* JLD commented this stuff out
+#ifndef min
+#define min(a,b) (((a)<(b)) ? (a) : (b))
+#endif  
+
+#ifndef max
+#define max(a,b) (((a)<(b)) ? (b) : (a))
+#endif  
+*/
+
+#ifndef align
+#define align(a) (((ub4)a+(sizeof(void *)-1))&(~(sizeof(void *)-1)))
+#endif  
+
+#ifndef abs
+#define abs(a)   (((a)>0) ? (a) : -(a))
+#endif
+
+#define TRUE    1
+#define FALSE   0
+#define SUCCESS 0  /* 1 on VAX */
+
+#endif /* STANDARD */

Added: incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenktest.c
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenktest.c?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenktest.c (added)
+++ incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenktest.c Wed Apr 22 17:25:43 2009
@@ -0,0 +1,106 @@
+/*
+** By Bob Jenkins, February 22, 1997, Public Domain
+** Contains various modifications by j l decocq cisco systems 2007
+** This is an example of how to use the hash table.
+**
+** Given an input (stdin) with lines in any order
+** produce an output (stdout) with duplicate lines removed.
+** Lines may not be longer than 4096 characters.
+*/
+#pragma warning(disable: 4996) /* quash VS compiler unsafe function warning JLD */
+
+/*
+ * JLD comments: the hash table appears to be fine with wide character support.
+ * _UNICODE is for C runtime TCHAR support, i.e. _tcscpy (--> wcscpy vs strcpy), 
+ * distinct from UNICODE, which turns, say, CreateWindowEx into CreateWindowExW 
+ * instead of CreateWindowExA. 
+*/
+
+#ifndef _UNICODE    /* defined by default in VS2005 */
+#define _UNICODE
+#endif
+#include "tchar.h"  /* wide char support, wmain() vs main() */
+
+#ifndef UNICODE     /* defined by default in VS2005 */
+#define UNICODE
+#endif
+ 
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "jenkstd.h"
+#include "jenkhtab.h"
+#include <conio.h>
+#define TESTDATAPATH "jenktest.txt"
+#define MAXLINELEN 64
+#define INITIAL_TABLE_SIZE_LOG2 2
+
+
+int _tmain(int argc, _TCHAR* argv[])
+{
+  /* when _UNICODE is defined _tmain expands to wmain, otherwise it expands to main */
+  char  buf[MAXLINELEN];
+  char* pkey;
+  int   keylen, myincount=0, myhashcount=0, myfreecount=0;
+  htab* myhashtable;
+  char  c = 0;
+  FILE* f;
+  printf("** jenktest.c start\n\n");
+
+  do {
+
+  f = fopen(TESTDATAPATH,"r");
+  if (!f)
+  {   printf("could not open test data file %s\n",TESTDATAPATH);
+      break;
+  }
+
+  myhashtable = hcreate(INITIAL_TABLE_SIZE_LOG2); /* create hash table */
+  hstat(myhashtable);  /* show table stats */
+
+  /* read in all the lines */
+  while (fgets((char*)buf, MAXLINELEN, f))  
+  {
+    keylen = (ub4) strlen(buf);
+
+    if (hadd(myhashtable, buf, keylen, (void *)0)) /* if not a duplicate */
+    {
+      pkey = (char*) malloc(keylen);      /* dumb use of malloc */
+      memcpy(pkey, buf, keylen);          /* copy buf into pkey */
+      hkey(myhashtable) = pkey;           /* replace buf with pkey */
+      myincount++;
+    }
+  }
+
+  fclose(f); f = 0;
+  hstat(myhashtable);                  /* show table stats */
+
+  if  (hfirst(myhashtable))            /* go to first element */  
+       printf("%.*s\n", hkeyl(myhashtable), hkey(myhashtable));  
+  else break;
+  myhashcount = 1;
+   
+  while(hnext(myhashtable))           /* go to next element */
+  {  printf("%.*s\n", hkeyl(myhashtable), hkey(myhashtable));  
+     myhashcount++;
+  }
+
+  while (hcount(myhashtable))          /* while the table is not empty */
+  {
+    free(hkey(myhashtable));           /* free memory for the line */
+    hdel(myhashtable);                 /* delete from hash table */
+    myfreecount++;
+  }
+
+  hstat(myhashtable);                  /* show table stats */
+
+  hdestroy(myhashtable);               /* destroy hash table */
+
+  } while(0);
+
+  printf("** keys read %d -- hashed %d -- removed %d\n", 
+         myincount, myhashcount, myfreecount);
+  printf("\n** jenktest.c end\n\n");
+  printf("any key ..."); while(!c) c = _getch(); printf("\n"); 
+  return 0;
+}

Added: incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenktest.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenktest.txt?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenktest.txt (added)
+++ incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/jenktest.txt Wed Apr 22 17:25:43 2009
@@ -0,0 +1,58 @@
+apple
+banana
+banter
+baseball
+blueberry
+brown
+browser
+camera
+can
+cantaloupe
+cherry
+cinnamon
+clear
+dash
+date
+distance
+ever
+ewe
+eye
+fig
+grape
+her
+lake
+leaf
+leave
+lemon
+lever
+lime
+mellon
+mango
+math
+music
+netscape
+never
+orange
+pear
+pepper
+politics
+psychedelic
+psychology
+salt
+science
+sift
+signals
+softball
+spice
+stupid
+swear
+syntax
+strawberry
+tangerine
+towel
+turn
+washcloth
+watermelon
+will
+words
+yellow

Added: incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/postbuild.bat
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/postbuild.bat?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/postbuild.bat (added)
+++ incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/postbuild.bat Wed Apr 22 17:25:43 2009
@@ -0,0 +1,21 @@
+@echo OFF
+echo postBuild.bat start
+echo postBuild.bat copying jenkhash.lib debug symbols to lib directory ...
+
+if exist .\debug\vc80.pdb goto debug
+if exist .\release\vc80.pdb goto release
+echo no debug symbol file found - assuming C7 embedded symbols
+goto done  
+
+:release
+xcopy .\release\vc80.pdb ..\lib /y /f /i
+del .\release\vc80.pdb 
+goto done
+
+:debug
+xcopy .\debug\vc80.pdb ..\lib /y /f /i
+del .\debug\vc80.pdb
+
+:done
+echo postBuild.bat exit
+

Added: incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/readme-jenk.txt
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/readme-jenk.txt?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/readme-jenk.txt (added)
+++ incubator/etch/trunk/binding-c/runtime/c/ext/hashtab/readme-jenk.txt Wed Apr 22 17:25:43 2009
@@ -0,0 +1,90 @@
+
+This is Bob Jenkins' hash table code from burtleburtle.net/bob/hash/hashtab.html.
+The author, Bob Jenkins, has placed this code in the public domain, 
+He states as such in comments in the code itself. Regarding inclusion of the
+code in an Apache project, he states:
+   I do prefer that you keep a pointer back to me as the source, so I can 
+   answer questions if any come up.  I would object if someone claimed 
+   they'd written it themselves. But other than that, there's no restrictions, 
+   you can remove or rewrite any of the comments or code, 
+   including the disclaimers.
+
+   James DeCocq (jadecocq) wrote:
+   > Hi Bob,
+   > Last year I used your excellent hash table C code in a project which 
+   > is now to become an Apache open source project. What is the usual  
+   > attribution and licensing disclaimer procedures when folks use your  
+   > code in open source projects? 
+
+CUSTOMIZED FOR ETCH
+The original code has been customized for use by etch. Changes are as follows:
+- renamed files belonging to this subproject to begin with "jenk".
+- changed name of unique.c to jenktest.c; changed this to read from file not stdin
+- added includes to .c files such that they compile individually
+
+BEGIN JENKINS COMMENTS ON THE CODE
+hashtab.h and hashtab.c form the hash table module. 
+The files before those are the support files that I always use. 
+The file after it (unique.c) is an example of how to use the hash table. 
+(The program UNIQUE takes a file in STDIN and dumps the unique lines 
+(duplicates removed) to STDOUT. 
+It also shuffles the unique lines pseudorandomly. 
+The sample input provided doesn't have any duplicate lines, 
+so the output should be the same size as the input, but the lines will be shuffled.) 
+
+The hash table has a fixed hash function, and its size is a power of two. 
+It doubles in size when it needs to, and when it doubles, it doubles all at once. 
+It never shrinks. Input keys and data are pointed to, not copied. 
+Keys are unique. 
+Collisions are handled by chaining. 
+
+Functions are: 
+hcreate  - create a hash table 
+hdestroy - destroy a hash table 
+hcount   - how many items are in the hash table? 
+hkey     - the key at the current position 
+hkeyl    - the length of the key at the current position 
+hstuff   - the other data at the current position 
+hfind    - position the hash table at some key 
+hadd     - add a new <key,stuff> pair to the table 
+hdel     - delete the item at the current position 
+hfirst   - position at the first item in the table 
+hnext    - move to the next item in the table 
+hstat    - print statistics about this table 
+
+The most unusual thing about this module is that it maintains a current position. 
+This means you can't have a dangling pointer into it. 
+If you position on something, and then delete it, the position moves to another item. 
+On the other hand, it also means it's hard to do nested loops over all the items in the table, 
+since there can be only one position at a time. 
+END JENKINS COMMENTS ON THE CODE
+
+
+JENKINS EMAIL RE 64-BIT COMPATIBILITY
+I don't have any.  However, Thomas Wang came up with this one:
+
+public long hash64shift(long key)
+{
+  key = (~key) + (key << 21); // key = (key << 21) - key - 1;
+  key = key ^ (key >>> 24);
+  key = (key + (key << 3)) + (key << 8); // key * 265
+  key = key ^ (key >>> 14);
+  key = (key + (key << 2)) + (key << 4); // key * 21
+  key = key ^ (key >>> 28);
+  key = key + (key << 31);
+  return key;
+}
+
+I haven't tested it, but the functions of his that I have tested aren't bad, and the operations look about like what I'd expect is needed.  My preliminary stabs at a 64-bit functions said 8 or 9 shifts are needed, he's got 10, but many are done in parallel, so it does look like a promising function.
+
+James DeCocq (jadecocq) wrote:
+> Hi Bob,
+>
+> Have you tried the code in 64 bits? I don't currently have the ability 
+> to do so, but a glance at some of the code, specifically the renew() 
+> macro, seems as if it might assume that a pointer is the same size as 
+> an int. If it is the case that it makes assumptions as to 32 bits, are 
+> there specific tweaks you may have made for 64 bits that you can share?
+END JENKINS EMAIL RE 64-BIT COMPATIBILITY
+
+

Added: incubator/etch/trunk/binding-c/runtime/c/ext/lib/jenkhash.lib
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/ext/lib/jenkhash.lib?rev=767594&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/etch/trunk/binding-c/runtime/c/ext/lib/jenkhash.lib
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/etch/trunk/binding-c/runtime/c/inc/apr_arch_thread_cond.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/apr_arch_thread_cond.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/apr_arch_thread_cond.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/apr_arch_thread_cond.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,31 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef THREAD_COND_H
+#define THREAD_COND_H
+
+#include "apr_thread_cond.h"
+
+struct apr_thread_cond_t {
+    apr_pool_t *pool;
+    HANDLE event;
+    int signal_all;
+    int num_waiting;
+    int signalled;
+};
+
+#endif  /* THREAD_COND_H */
+

Added: incubator/etch/trunk/binding-c/runtime/c/inc/apr_private.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/apr_private.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/apr_private.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/apr_private.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,173 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Note: 
+ * This is the windows specific autoconf-like config file
+ * which unix would create at build time.
+ */
+
+#ifdef WIN32
+
+#ifndef APR_PRIVATE_H
+#define APR_PRIVATE_H
+
+/* Include the public APR symbols, include our idea of the 'right'
+ * subset of the Windows.h header.  This saves us repetition.
+ */
+#include "apr.h"
+
+/* 
+ * Add a _very_few_ declarations missing from the restricted set of headers
+ * (If this list becomes extensive, re-enable the required headers above!)
+ * winsock headers were excluded by WIN32_LEAN_AND_MEAN, so include them now
+ */
+#ifndef SW_HIDE
+#define SW_HIDE             0
+#endif
+
+/* For the misc.h late-loaded dynamic symbols, we need some obscure types 
+ * Avoid dragging in wtypes.h unless it's absolutely necessary [generally
+ * not with APR itself, until some GUI-related security is introduced.]
+ */
+#ifndef _WIN32_WCE
+#define HAVE_ACLAPI 1
+#ifdef __wtypes_h__
+#include <accctrl.h>
+#else
+#define __wtypes_h__
+#include <accctrl.h>
+#undef __wtypes_h__
+#endif
+#else
+#define HAVE_ACLAPI 0
+#endif
+
+#if APR_HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if APR_HAVE_STDDEF_H
+#include <stddef.h>
+#endif
+#include <stdio.h>
+#if APR_HAVE_TIME_H
+#include <time.h>
+#endif
+
+/* Use this section to define all of the HAVE_FOO_H
+ * that are required to build properly.
+ */
+#define HAVE_LIMITS_H 1
+#define HAVE_MALLOC_H 1
+#define HAVE_SIGNAL_H 1
+/* #define HAVE_STDDEF_H 1 why not? */
+#define HAVE_STDLIB_H 1
+
+#define HAVE_STRICMP  1
+#define HAVE_STRNICMP 1
+#define HAVE_STRDUP   1
+#define HAVE_STRSTR   1
+#define HAVE_MEMCHR   1
+
+#define SIGHUP     1
+/* 2 is used for SIGINT on windows */
+#define SIGQUIT    3
+/* 4 is used for SIGILL on windows */
+#define SIGTRAP    5
+#define SIGIOT     6
+#define SIGBUS     7
+/* 8 is used for SIGFPE on windows */
+#define SIGKILL    9
+#define SIGUSR1    10
+/* 11 is used for SIGSEGV on windows */
+#define SIGUSR2    12
+#define SIGPIPE    13
+#define SIGALRM    14
+/* 15 is used for SIGTERM on windows */
+#define SIGSTKFLT  16
+#define SIGCHLD    17 
+#define SIGCONT    18
+#define SIGSTOP    19
+#define SIGTSTP    20
+/* 21 is used for SIGBREAK on windows */
+/* 22 is used for SIGABRT on windows */
+#define SIGTTIN    23
+#define SIGTTOU    24
+#define SIGURG     25
+#define SIGXCPU    26
+#define SIGXFSZ    27
+#define SIGVTALRM  28
+#define SIGPROF    29
+#define SIGWINCH   30
+#define SIGIO      31
+
+/* APR COMPATABILITY FUNCTIONS
+ * This section should be used to define functions and
+ * macros which are need to make Windows features look
+ * like POSIX features.
+ */
+typedef void (Sigfunc)(int);
+
+#define sleep(t)                 Sleep((t) * 1000)
+
+#define SIZEOF_SHORT           2
+#define SIZEOF_INT             4
+#define SIZEOF_LONGLONG        8
+#define SIZEOF_CHAR            1
+#define SIZEOF_SSIZE_T         SIZEOF_INT
+
+unsigned __stdcall SignalHandling(void *);
+int thread_ready(void);
+
+#if !APR_HAVE_ERRNO_H
+APR_DECLARE_DATA int errno;
+#define ENOSPC 1
+#endif
+
+#if APR_HAVE_IPV6
+#define HAVE_GETADDRINFO 1
+#define HAVE_GETNAMEINFO 1
+#endif
+
+/* MSVC 7.0 introduced _strtoi64 */
+#if _MSC_VER >= 1300 && _INTEGRAL_MAX_BITS >= 64 && !defined(_WIN32_WCE)
+#define APR_INT64_STRFN	      _strtoi64
+#endif
+
+#if APR_HAS_LARGE_FILES
+#ifdef APR_INT64_STRFN
+#define APR_OFF_T_STRFN         APR_INT64_STRFN
+#else
+#define APR_OFF_T_STRFN         apr_strtoi64
+#endif
+#else
+#if defined(_WIN32_WCE)
+#define APR_OFF_T_STRFN         strtol
+#else
+#define APR_OFF_T_STRFN         strtoi
+#endif
+#endif
+
+/* used to check for DWORD overflow in 64bit compiles */
+#define APR_DWORD_MAX 0xFFFFFFFFUL
+
+/*
+ * Include common private declarations.
+ */
+#include "../apr_private_common.h"
+
+#endif  /*APR_PRIVATE_H*/
+#endif  /*WIN32*/

Added: incubator/etch/trunk/binding-c/runtime/c/inc/etch.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etch.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etch.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etch.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,74 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/*
+ * etch.h -- includes common to the entire etch c binding. note that all
+ * function signatures are assumed to have a __cdecl calling convention.
+ */
+
+#ifndef ETCH_H
+#define ETCH_H
+
+#undef  IS_WINDOWS_ETCH  
+#ifdef  WIN32
+#define IS_WINDOWS_ETCH 32
+#endif  /* WIN32 */
+
+#include "etchwarn.h"     /* unicode switch warning */
+#include <tchar.h>        /* everything is unicode */
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "etchdefs.h"     /* constants, #defines, typedefs, etc. */
+#include "etchobjtypes.h" /* internal etch object type constants */
+
+unsigned etchhash(const void* key, const int keylen, const unsigned priorhash);  
+
+typedef int (*etch_comparator) (void* myobj, void* otherobj);
+
+#define IS_ETCH_TRANSPORT_LITTLEENDIAN FALSE
+#define ETCHCONFIGDEF_EXAMPLE_STRING_MAXLEN 15 
+
+/**
+ * etch configuration items 
+ */
+typedef struct etch_config
+{
+  int memory_watch_id; /* memory alloc id */
+  int default_mailbox_read_waitms;
+  int sleepSecondsPriorClientExit; /* for use when stepping thru server */ 
+  int max_log_files;   /* max log files in a single log directory */
+  int max_log_lines;   /* max lines in a single log file */
+  int loglevel;        /* computed 0, 1, 2, 3, 4 */
+  unsigned char log_level;      /* X, D, I, W, E */
+  unsigned char is_log_to_file;  
+  unsigned char is_log_to_console;
+  unsigned char is_validate_on_write;
+  unsigned char is_validate_on_read;
+  unsigned char is_log_memory_leak_detail;
+  unsigned char is_destroy_messages_with_mailbox;
+  unsigned char calculated_is_client;
+  char example_string[ETCHCONFIGDEF_EXAMPLE_STRING_MAXLEN+1];
+
+} etch_config;
+
+etch_config config;  /* global config items */
+
+
+#endif /* #ifndef ETCH_H */
\ No newline at end of file

Added: incubator/etch/trunk/binding-c/runtime/c/inc/etch_apr.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etch_apr.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etch_apr.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etch_apr.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,50 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/*
+ * etch_apr.h -- common apr and service initialization and teardown
+ */
+
+#ifndef ETCHAPR_H
+#define ETCHAPR_H
+
+#include "apr_thread_proc.h"
+#include "apr_time.h"
+#include "apr_atomic.h"
+#define INIT_ETCH_CLIENT TRUE
+#define INIT_ETCH_SERVER FALSE
+
+apr_pool_t* g_apr_pool;
+const char* apr_pooltag;
+
+typedef struct etch_runtime_exit_params
+{
+    unsigned char is_show_leak_detail;
+    unsigned char unused_a;
+    unsigned char unused_b;
+    unsigned char unused_c;
+
+} etch_runtime_exit_params;
+
+
+int etch_runtime_init_all(const int is_client);
+int etch_runtime_exit(etch_runtime_exit_params* args);
+int check_etch_heap_bytes (const int is_show_detail, const int is_log_result);
+
+
+#endif /* #ifndef ETCHPOOL_H */
\ No newline at end of file

Added: incubator/etch/trunk/binding-c/runtime/c/inc/etch_arraylist.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etch_arraylist.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etch_arraylist.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etch_arraylist.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,118 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/*
+ * etch_arrarylist.h 
+ * arraylist implementation.
+ */
+
+#ifndef ETCHARRAYLIST_H
+#define ETCHARRAYLIST_H
+
+#include "etch.h"
+#include "etch_collection.h"
+
+#define ETCHARRAYLIST_DEFSIZE 128
+#define ETCHARRAYLIST_CONTENT_SIMPLE 0  /* content memory freed as a unit */
+#define ETCHARRAYLIST_CONTENT_OBJECT 1  /* content is etchobject */
+#define ETCHARRAYLIST_SYNCHRONIZED TRUE
+
+typedef int (*arraycallback) (int, void*); /* arraylist callback signature */
+
+
+/** 
+ *  etch_arraylist: data structure encapsulating the arraylist
+ *  if is_readonly is set, content is read only and therefore is_free_content  
+ *  will have no effect -- list items may still be inserted and removed. This
+ *  guards against accidentally freeing memory during arraylist destruction 
+ *  for arrays of references which are still intended to remain in use. 
+ */
+typedef struct etch_arraylist   
+{
+    unsigned int     hashkey;
+    unsigned short   obj_type; 
+    unsigned short   class_id;
+    struct vtabmask* vtab;       
+    int  (*destroy) (void*);
+    void*(*clone)   (void*); 
+    obj_gethashkey   get_hashkey;
+    struct objmask*  parent;
+    etchresult*      result;
+    unsigned int     refcount;
+    unsigned int     length;
+    unsigned char    is_null;
+    unsigned char    is_copy;
+    unsigned char    is_static;
+    unsigned char    reserved;
+
+    void**   base;
+    unsigned short content_obj_type;  /* etch obj_type of a native value */
+    unsigned short content_class_id;  /* etch class_id of a native value */
+    unsigned int count;
+
+    /* this object may be masked by etch_collection_mask to determine content
+     * type and class, so do not add any fields above this comment */
+
+    unsigned int delta;
+    unsigned int size;
+    i_iterable iterable;
+
+    byte is_readonly;  
+    byte content_type;
+
+    arraycallback freehook; /* hook for free list content */
+    arraycallback synchook; /* hook for list synchronization */
+    void* synclock;         /* synchronization mutex */
+
+} etch_arraylist;
+
+
+etch_arraylist* new_arraylist(const unsigned initialsize, const unsigned deltasize);
+etch_arraylist* new_arraylist_from(etch_arraylist*);
+int   arraylist_add      (etch_arraylist*, void* content);
+int   arraylist_add_from (etch_arraylist*, etch_arraylist* newitems, etch_comparator); 
+int   arraylist_containsp(etch_arraylist*, void* content, const unsigned startat); /* pointer compare */
+int   arraylist_contains (etch_arraylist*, void* content, const unsigned startat, etch_comparator);
+int   arraylist_indexofp (etch_arraylist*, void* content, const unsigned startat); /* pointer compare */
+int   arraylist_indexof  (etch_arraylist*, void* content, const unsigned startat, etch_comparator);
+int   arraylist_remove_content(etch_arraylist*, void* content, const unsigned startat, etch_comparator);
+int   arraylist_insert   (etch_arraylist*, const unsigned i, void* content);
+int   arraylist_remove   (etch_arraylist*, const unsigned i, const int is_free_content);
+int   arraylist_set      (etch_arraylist*, const unsigned i, void* content);
+void* arraylist_get      (etch_arraylist*, const unsigned i);
+void  arraylist_clear    (etch_arraylist*, const int is_free_content);
+void  arraylist_destroy  (etch_arraylist*, const int is_free_content);
+void  arraylist_copyattrs(etch_arraylist* to, etch_arraylist* from);
+
+/* 
+ * explicit synchronization locking methods.
+ * these should be used only for locking a list during list iteration.   
+ * for synchronization of list operations, the presence of list.synchook  
+ * and list.synclock is sufficient. 
+ */
+int   arraylist_getlock  (etch_arraylist*);
+int   arraylist_trylock  (etch_arraylist*);
+int   arraylist_rellock  (etch_arraylist*);
+
+/* i_iterable function overrides */
+int   arraylist_iterable_first   (etch_iterator*);
+int   arraylist_iterable_next    (etch_iterator*);
+int   arraylist_iterable_has_next(etch_iterator*);
+
+
+#endif /* #ifndef ETCHARRAYLIST_H */
\ No newline at end of file

Added: incubator/etch/trunk/binding-c/runtime/c/inc/etch_arrayval.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etch_arrayval.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etch_arrayval.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etch_arrayval.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,110 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/**
+ * etch_arrayval.h 
+ */
+
+#ifndef ETCHARRAYVAL_H
+#define ETCHARRAYVAL_H
+
+#include "etchmsgutl.h"
+#include "etch_arraylist.h"
+#define ETCHARRAYVAL_READONLY TRUE
+#define ETCHARRAYVAL_NOTREADONLY FALSE
+
+
+/**
+ * etch_arrayvalue
+ * an array of values, where each value is a pointer to an etch object. 
+ */
+struct etch_arrayvalue
+{
+    unsigned int     hashkey;    
+    unsigned short   obj_type;   
+    unsigned short   class_id;   
+    struct vtabmask* vtab;         
+    int  (*destroy) (void*);     
+    void*(*clone)   (void*); 
+    obj_gethashkey   get_hashkey;    
+    struct objmask*  parent;     
+    etchresult*      result;     
+    unsigned int     refcount;       
+    unsigned int     length;     
+    unsigned char    is_null;   
+    unsigned char    is_copy;   
+    unsigned char    is_static;  
+    unsigned char    reserved;  
+ 
+    etch_arraylist* list;
+    unsigned short content_obj_type;  /* etch obj_type of a native value */
+    unsigned short content_class_id;  /* etch class_id of a native value */
+    int  dim;
+
+    /* this object may be masked by etch_collection_mask to determine content
+     * type and class, so do not add any fields above this comment */
+
+    unsigned short content_item_size; /* byte count of a native value */ 
+    unsigned char  is_array_owned;    /* arrayvalue owns natarray? */ 
+    signed   char  type_code;         /* external content type */
+
+    etch_type* custom_struct_type;    /* not owned */
+    etch_nativearray* natarray;       /* see is_array_owned */
+};
+
+typedef struct etch_arrayvalue etch_arrayvalue;
+
+/**
+ * new_arrayvalue_arraylist()
+ * allocates and returns an arraylist configured appropriately for use as arrayvalue backing store
+ */
+etch_arraylist* new_arrayvalue_arraylist(const int initsize, const int deltsize, 
+    const int is_readonly, const int is_synchronized);
+
+/* public methods on etch_arrayvalue */
+etch_arrayvalue* new_arrayvalue(const byte type_code, etch_type* custom_struct_type, 
+    const int dim, const int initsize, const int deltsize, 
+    const int is_readonly, const int is_synchronized);
+
+etch_arrayvalue* new_arrayvalue_from(etch_nativearray* natarray, 
+    const signed char type_code, etch_type* custom_struct_type, 
+    const int initsize, const int deltsize, 
+    const int is_readonly);
+
+etch_arrayvalue* new_arrayvalue_default();
+
+int  destroy_arrayvalue(etch_arrayvalue* thisp);
+
+ETCH_ARRAY_ELEMENT* new_array_element(const int objtype);
+
+int   arrayvalue_add (etch_arrayvalue* thisp, ETCH_ARRAY_ELEMENT* content);
+
+int   arrayvalue_count(etch_arrayvalue*);
+void* arrayvalue_get(etch_arrayvalue*, const int index);
+
+int   arrayvalue_set_iterator(etch_arrayvalue*, etch_iterator*);
+void  arrayvalue_set_static_content(etch_arrayvalue*, const int is_set);
+
+int   arrayvalue_to_nativearray(etch_arrayvalue*);
+
+signed char arrayvalue_get_external_typecode (unsigned short, unsigned short);
+signed char etch_classid_to_arraytype (const unsigned short class_id);
+unsigned short etch_arraytype_to_classid (const signed char typecode);
+
+
+#endif /* #ifndef ETCHARRAYVAL_H */
\ No newline at end of file

Added: incubator/etch/trunk/binding-c/runtime/c/inc/etch_binary_tdi.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etch_binary_tdi.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etch_binary_tdi.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etch_binary_tdi.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,166 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/*
+ * etch_binary_tdi.h
+ * binary tagged data input
+ */
+
+#ifndef ETCH_BINARY_TDI_H
+#define ETCH_BINARY_TDI_H
+
+#include "etch_tagdata.h"
+#include "etch_tagdata_inp.h"
+#include "etchflexbuf.h"
+#include "etch_valufact.h"
+
+#if(0)
+
+ BINARY_TAGGED_DATA_INPUT
+ value_factory vf;
+ ctor(valuefactory);
+
+     BINARY_TAGGED_DATA
+     bool  (*check_value)(object value, validator v);
+     byte  (*adjust_small_value)(byte type, object value);   
+     byte  (*check_value)(object value);
+     byte  (*get_native_type_code)(class*);
+     byte  (*get_custom_struct_type)(class*);
+     class*(*get_native_type)(byte type);
+     byte  (*check_byte)  (byte  v, byte is1, byte dt);
+     byte  (*check_short) (short v, byte is2, byte dt);
+     byte  (*check_int)   (int   v, byte is4, byte dt);
+     byte  (*check_long)  (long  v, byte is8, byte dt);
+
+        TAGGED_DATA
+        array_value* (*to_array_value) (object value);
+        object* (*from_array_value) (object value);
+        object* (*alloc_array_value)(byte type, Type custtructtype, int dim, int len);
+        class*  (*get_component_type)(byte type, Type custtructtype, int dim);
+        byte    (*check_value) (object value);
+        byte    (*get_native_typecode) (class* c);
+        byte    (*get_custom_struct_type)(class*);
+        class*  (*get_native_type)(byte type);
+
+    TAGGED_DATA_INPUT
+    etch_message* (*start_message) (tagged_data_input*);  
+    etch_message* (*end_message) (tagged_data_input*, etch_message*);
+    etch_structvalue* (*start_struct) (tagged_data_input*);
+    int (*read_struct_element) (tagged_data_input*, struct etch_struct_element*);
+    int (*end_struct) (tagged_data_input*, etch_structvalue*);
+    etch_arrayvalue* (*start_array) (tagged_data_input*);
+    int (*read_array_element) (tagged_data_input*, ETCH_ARRAY_ELEMENT**);
+    int (*end_array) (tagged_data_input*, etch_arrayvalue*);
+
+#endif
+
+
+/** 
+ *  i_binary_tdi: vtable for binary tagged data input interface
+ */
+struct i_binary_tdi
+{
+    unsigned int    hashkey;
+    unsigned short  obj_type; 
+    unsigned short  class_id;
+    struct i_binary_tdi* vtab;
+    int  (*destroy)(void*);
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;
+    struct objmask* parent;
+    etchresult*     result;
+    unsigned int    refcount;
+    unsigned int    length;
+    unsigned char   is_null;
+    unsigned char   is_copy;
+    unsigned char   is_static;
+    unsigned char   reserved;
+
+    etchparentinfo* inherits_from; 
+
+    /* i_tagdata_input */
+	etchtdi_start_message         start_message;
+    etchtdi_read_message          read_message;
+	etchtdi_end_message           end_message;
+	etchtdi_start_struct          start_struct;
+    etchtdi_read_struct           read_struct;
+    etchtdi_end_struct            end_struct;
+    etchtdi_start_array           start_array;
+    etchtdi_read_array            read_array;
+    etchtdi_end_array             end_array;
+
+    tagdata_get_native_type_code  get_native_type_code;
+    tagdata_get_native_type       get_native_type;
+    tagdata_get_custom_structtype get_custom_structtype;
+    tagdata_check_value check_value;	
+};
+
+typedef struct i_binary_tdi i_binary_tdi;
+
+
+/**
+ * binary_tagged_data_input
+ * binary tagged data input implementation
+ */
+typedef struct binary_tagged_data_input
+{
+    unsigned int    hashkey;    
+    unsigned short  obj_type;   
+    unsigned short  class_id;   
+    struct i_binary_tdi* vtab;       
+    int  (*destroy)(void*);     
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;    
+    struct objmask* parent;     
+    etchresult*     result;     
+    unsigned int    refcount;       
+    unsigned int    length;     
+    unsigned char   is_null;   
+    unsigned char   is_copy;   
+    unsigned char   is_static;  
+    unsigned char   reserved;
+
+    objmask* impl;  /* must appear first to mask tagged_data_input */
+
+    etch_value_factory*  vf;     /* not owned */
+    etch_flexbuffer* flexbuf;    /* not owned */
+    etch_validator*  vtor_int;   /* not owned */
+    objmask* static_nullobj;         /* owned */
+    objmask* static_eodmarker;       /* owned */
+    etch_string* static_emptystring; /* owned */
+
+} binary_tagged_data_input;
+
+
+ binary_tagged_data_input* new_binary_tagdata_input(etch_value_factory*);
+ tagged_data_input*        new_binary_tdi(etch_value_factory*);
+
+etch_message* bintdi_read_message(tagged_data_input* tdix, 
+    etch_flexbuffer* fbuf);
+
+etch_message* bintdi_read_message_fromf(etch_value_factory* vf, 
+    etch_flexbuffer* fbuf);
+
+etch_message* bintdi_read_message_from(etch_value_factory* vf, byte* buf, 
+    const int bufsize);
+
+etch_message* bintdi_read_message_fromo(etch_value_factory* vf, byte* buf, 
+    const int bufsize, const int msglen, const int offset);
+
+
+#endif /* #ifndef ETCH_BINARY_TDI_H */
\ No newline at end of file

Added: incubator/etch/trunk/binding-c/runtime/c/inc/etch_binary_tdo.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etch_binary_tdo.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etch_binary_tdo.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etch_binary_tdo.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,124 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/*
+ * etch_binary_tdo.h
+ * binary tagged data output
+ */
+
+#ifndef ETCH_BINARY_TDO_H
+#define ETCH_BINARY_TDO_H
+
+#include "etch_tagdata_out.h"
+#include "etchflexbuf.h"
+#include "etch_message.h"
+#include "etch_valufact.h"
+
+typedef struct binary_tagged_data_output binary_tagged_data_output;
+
+
+/** 
+ *  i_binary_tdo: vtable for binary tagged data output interface
+ */
+struct i_binary_tdo
+{
+    unsigned int    hashkey;
+    unsigned short  obj_type; 
+    unsigned short  class_id;
+    struct i_binary_tdo* vtab;
+    int  (*destroy)(void*);
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;
+    struct objmask* parent;
+    etchresult*     result;
+    unsigned int    refcount;
+    unsigned int    length;
+    unsigned char   is_null;
+    unsigned char   is_copy;
+    unsigned char   is_static;
+    unsigned char   reserved;
+
+    etchparentinfo* inherits_from; 
+
+    /* i_tagdata_output */
+	etchtdo_start_message         start_message;
+    etchtdo_write_message         write_message;
+	etchtdo_end_message           end_message;
+	etchtdo_start_struct          start_struct;
+    etchtdo_write_struct          write_struct;
+    etchtdo_end_struct            end_struct;
+    etchtdo_start_array           start_array;
+    etchtdo_write_array           write_array;
+    etchtdo_end_array             end_array;
+
+    tagdata_get_native_type_code  get_native_type_code;
+    tagdata_get_native_type       get_native_type;
+    tagdata_get_custom_structtype get_custom_structtype;
+    tagdata_check_value check_value;	
+};
+
+typedef struct i_binary_tdo i_binary_tdo;
+
+
+/**
+ * binary_tagged_data_output
+ * binary tagged data input implementation
+ */
+typedef struct binary_tagged_data_output
+{
+    unsigned int    hashkey;    
+    unsigned short  obj_type;   
+    unsigned short  class_id;   
+    struct i_binary_tdo* vtab;       
+    int  (*destroy)(void*);     
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;    
+    struct objmask* parent;     
+    etchresult*     result;     
+    unsigned int    refcount;       
+    unsigned int    length;     
+    unsigned char   is_null;   
+    unsigned char   is_copy;   
+    unsigned char   is_static;  
+    unsigned char   reserved;
+
+    objmask* impl;  /* must appear first to mask tagged_data_output */
+
+    etch_value_factory*  vf;      /* not owned */
+    etch_flexbuffer* flexbuf; /* usually owned */
+    unsigned char is_flexbuf_owned;
+
+    etch_validator*  vtor_int;    /* not owned */
+    etch_validator*  vtor_eod;    /* not owned */
+    objmask* static_nullobj;          /* owned */
+    objmask* static_eodmarker;        /* owned */
+    etch_string* static_emptystring;  /* owned */
+
+} binary_tagged_data_output;
+
+
+binary_tagged_data_output* new_binary_tagdata_output(etch_value_factory*, etch_flexbuffer*); 
+tagged_data_output*        new_binary_tdo(etch_value_factory*);
+
+int bintdo_get_bytes (etch_message*, etch_value_factory*, byte** out);
+int bintdo_write_value (binary_tagged_data_output*, etch_validator*, objmask*);
+etch_arrayvalue* bintdo_to_arrayvalue (etch_nativearray*);
+etch_arrayvalue* normalize_etch_array(void* a, const int maxdim);
+
+
+#endif /* #ifndef ETCH_BINARY_TDO_H */
\ No newline at end of file

Added: incubator/etch/trunk/binding-c/runtime/c/inc/etch_collection.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etch_collection.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etch_collection.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etch_collection.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,143 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/*
+ * etch_collection.h 
+ * definitions common to collections
+ */
+
+#ifndef ETCHCOLLECTION_H
+#define ETCHCOLLECTION_H
+
+#include "etch.h"
+#include "etchobj.h"
+
+#define ETCH_SYNC_SET 1
+#define ETCH_SYNC_TRY 2
+#define ETCH_SYNC_REL 3
+#define ETCH_SYNC_DEL 4
+
+#define ETCH_SYNC_SET_ ((void*) ETCH_SYNC_SET)
+#define ETCH_SYNC_TRY_ ((void*) ETCH_SYNC_TRY)
+#define ETCH_SYNC_REL_ ((void*) ETCH_SYNC_REL)
+#define ETCH_SYNC_DEL_ ((void*) ETCH_SYNC_DEL)
+
+struct i_iterable;
+struct etch_iterator;
+
+/** 
+ *  method signatures for i_iterable interface.
+ *  each accepts an iterator object as first parameter. the iterator constructor
+ *  should call first(), thus establishing a current position. next() should operate 
+ *  as first() if there is no current position.
+ */
+typedef int (*iterable_first)    (struct etch_iterator*); 
+typedef int (*iterable_next)     (struct etch_iterator*); 
+typedef int (*iterable_has_next) (struct etch_iterator*); 
+
+
+/** 
+ *  etch_iterator: iterator object for any i_iterable.
+ */
+typedef struct etch_iterator
+{
+    unsigned int    hashkey;
+    unsigned short  obj_type; 
+    unsigned short  class_id;
+    struct i_iterable* vtab;
+    int  (*destroy)(void*);
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;
+    struct objmask* parent;
+    etchresult*     result;
+    unsigned int    refcount;
+    unsigned int    length;
+    unsigned char   is_null;
+    unsigned char   is_copy;
+    unsigned char   is_static;
+    unsigned char   is_own_collection;
+
+    iterable_first    first;     
+    iterable_next     next;      
+    iterable_has_next has_next;  
+
+    int   ordinal;       /* 1-based position index */
+    void* collection;    /* underlying collection */
+    void* current_value; /* data at current posn */
+    void* current_key;   /* key at current posn */
+
+} etch_iterator;
+
+
+
+/** 
+ *  i_iterable: vtable for iterable interface
+ */
+struct i_iterable
+{
+    unsigned int    hashkey;
+    unsigned short  obj_type; 
+    unsigned short  class_id;
+    struct i_iterable* vtab;
+    int  (*destroy)(void*);
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;
+    struct objmask* parent;
+    etchresult*     result;
+    unsigned int    refcount;
+    unsigned int    length;
+    unsigned char   is_null;
+    unsigned char   is_copy;
+    unsigned char   is_static;
+    unsigned char   reserved;
+
+    etchparentinfo* inherits_from; 
+
+    iterable_first    first;    /* set current position at first entry  */
+    iterable_next     next;     /* set current position at next entry  */ 
+    iterable_has_next has_next; /* return TRUE if next will succeed */
+};
+
+typedef struct i_iterable i_iterable;
+
+
+/** 
+ *  new_iterable
+ *  constructor for i_iterable interface
+ */
+i_iterable* new_iterable(i_iterable* thisp, i_iterable* parent, 
+    iterable_first, iterable_next, iterable_has_next);
+
+/** 
+ *  new_iterator(), set_iterator(), destroy_iterator
+ *  constructors and destructors for etch_iterator
+ */
+etch_iterator* new_iterator(void* collection, i_iterable* iterable);
+
+int set_iterator(etch_iterator* thisp, void* collection, i_iterable* iterable);
+
+int destroy_iterator(etch_iterator*);
+
+etch_iterator* new_empty_iterator();
+
+
+int etch_comparator_noteq(void* a, void* b);
+int etch_comparator_equal(void* a, void* b);
+
+
+#endif /* #ifndef ETCHCOLLECTION_H */
\ No newline at end of file

Added: incubator/etch/trunk/binding-c/runtime/c/inc/etch_config.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etch_config.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etch_config.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etch_config.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,134 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/* 
+ * etch_config.h -- configuration items and file
+ */
+ 
+#ifndef ETCHCONFIG_H
+#define ETCHCONFIG_H
+
+#include "etch.h"
+
+#if(0)
+_________________________________________________________________________________
+example of adding a config entry to etch:
+1)  decide on an external config item name, e.g., myMaxClients.
+2)  add an internal name for the new entry to the etch_config struct below, e.g., 
+    int my_max_clients;
+3)  add a default value for the item to the defaults section below, e.g.,
+    #define ETCHCONFIGDEF_MY_MAX_CLIENTS 8
+4)  using the internal name from (2), and the default value from (3), add a 
+    default setter for the item to etch_reset_config() in etch_config.c;  e.g., 
+    config.my_max_clients = ETCHCONFIGDEF_MY_MAX_CLIENTS;
+5)  add a key for the item to the end of the ordinals section below, e.g.,
+    #define ETCHCONFIGKEY_MY_MAX_CLIENTS 21  /* value will be previous key + 1 */
+6)  using the key from (5) and the external name from (1), ad an entry to the  
+    config_keys table found in etch_read_configfile() in etch_config.c; e.g.,
+    {ETCHCONFIGKEY_MY_MAX_CLIENTS, "myMaxClients"},
+7.  using the key from (5) and the internal name from (2), add an edit and 
+    assignment for the item to etchconfig_assign_value() in etch_config.c; e.g.,
+    case ETCHCONFIGKEY_MY_MAX_CLIENTS:
+         if (datatype != ETCHCONFIG_DATATYPE_INT) result = -1;
+         else config.my_max_clients = ivalue;
+         break;
+8.  add the external name from (1), plus a value, to etch-c.config, e.g.,
+    myMaxClients = 4    # your optional comment here
+9.  optionally add some code to etch to put the configured value to use, e.g.,
+    if (etch_clients_count < config.my_max_clients)
+        etch_clients_count++;
+    else etchlog(ETCHETCH, ETCHLOG_ERROR, "max clients exceeded\n");
+10. build the etch runtime, and link an etch executable.
+11. start up the executable from (10), and test.
+_________________________________________________________________________________
+#endif
+
+
+/* default values for each config item */
+#define ETCHCONFIGDEF_LOG_LEVEL  'X'
+#define ETCHCONFIGDEF_MAX_LOGFILES 20
+#define ETCHCONFIGDEF_MAX_LOGLINES 4000
+#define ETCHCONFIGDEF_LOGCOUNT_GRACE  10
+#define ETCHCONFIGDEF_IS_LOG_TO_FILE  TRUE
+#define ETCHCONFIGDEF_IS_LOG_TO_CONSOLE  TRUE
+#define ETCHCONFIGDEF_IS_VALIDATE_ON_READ  TRUE
+#define ETCHCONFIGDEF_IS_VALIDATE_ON_WRITE TRUE
+#define ETCHCONFIGDEF_IS_DESTROY_MESSAGES_WITH_MAILBOX  FALSE
+#define ETCHCONFIGDEF_IS_LOG_MEMORY_LEAK_DETAIL  TRUE
+#define ETCHCONFIGDEF_DEFAULT_MAILBOX_READ_WAITMS  3000
+#define ETCHCONFIGDEF_SLEEP_SECONDS_PRIOR_CLIENT_EXIT 0
+#define ETCHCONFIGDEF_EXAMPLE_STRING_VALUE  "examplevalue" 
+
+
+/* unique ordinal key for each config file item. each configured item
+ * (but not computed items) must have an entry here. 
+ */
+#define ETCHCONFIGKEY_TEST_STRING           1  /* internal testing use */
+#define ETCHCONFIGKEY_TEST_INT              2  /* internal testing use */
+#define ETCHCONFIGKEY_TEST_BOOL             3  /* internal testing use */
+#define ETCHCONFIGKEY_TEST_FIXED            4  /* internal testing use */
+#define ETCHCONFIGKEY_LOG_LEVEL             5
+#define ETCHCONFIGKEY_ETCH_WATCH_ID         6
+#define ETCHCONFIGKEY_IS_LOG_TO_FILE        7
+#define ETCHCONFIGKEY_IS_LOG_TO_CONSOLE     8
+#define ETCHCONFIGKEY_IS_VALIDATE_ON_READ   9
+#define ETCHCONFIGKEY_IS_VALIDATE_ON_WRITE 10
+#define ETCHCONFIGKEY_MAX_LOGFILES         11
+#define ETCHCONFIGKEY_MAX_LOGLINES         12
+#define ETCHCONFIGKEY_IS_DESTROY_MESSAGES_WITH_MAILBOX 13
+#define ETCHCONFIGKEY_IS_DISPLAY_MEMORY_LEAK_DETAIL    14
+#define ETCHCONFIGKEY_DEFAULT_MAILBOX_READ_WAITMS      15
+#define ETCHCONFIGKEY_SLEEP_SECONDS_PRIOR_CLIENT_EXIT  16
+
+
+/**
+ * configuration items 
+ * the config struct and global are defined in etch.h - copied here for reference
+ */
+#if(0)
+
+typedef struct etch_config
+{
+  int memory_watch_id; /* memory alloc id */
+  int default_mailbox_read_waitms;
+  int sleepSecondsPriorClientExit; /* for use when stepping thru server */ 
+  int max_log_files;   /* max log files in a single log directory */
+  int max_log_lines;   /* max lines in a single log file */
+  int loglevel;        /* computed 0, 1, 2, 3, 4 */
+  unsigned char log_level;      /* X, D, I, W, E */
+  unsigned char is_log_to_file;  
+  unsigned char is_log_to_console;
+  unsigned char is_validate_on_write;
+  unsigned char is_validate_on_read;
+  unsigned char is_log_memory_leak_detail;
+  unsigned char is_destroy_messages_with_mailbox;
+  char example_string[ETCHCONFIGDEF_EXAMPLE_STRING_MAXLEN+1];
+
+} etch_config;
+
+etch_config config;  /* global config items */
+
+#endif
+
+
+int etch_read_configfile();
+int etch_reset_config (const int is_client);
+int get_etch_loglevel (const unsigned char);
+
+
+#endif /* #ifndef ETCHCONFIG_H */ 
\ No newline at end of file