CVS commit: othersrc/external/bsd/transit/dist

2014-03-11 Thread Thomas Klausner
Module Name:othersrc
Committed By:   wiz
Date:   Tue Mar 11 08:33:27 UTC 2014

Modified Files:
othersrc/external/bsd/transit/dist: libtransit.3

Log Message:
Remove trailing space.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 othersrc/external/bsd/transit/dist/libtransit.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/transit/dist/libtransit.3
diff -u othersrc/external/bsd/transit/dist/libtransit.3:1.3 othersrc/external/bsd/transit/dist/libtransit.3:1.4
--- othersrc/external/bsd/transit/dist/libtransit.3:1.3	Fri Mar  7 01:34:19 2014
+++ othersrc/external/bsd/transit/dist/libtransit.3	Tue Mar 11 08:33:27 2014
@@ -1,4 +1,4 @@
-.\ $NetBSD: libtransit.3,v 1.3 2014/03/07 01:34:19 agc Exp $
+.\ $NetBSD: libtransit.3,v 1.4 2014/03/11 08:33:27 wiz Exp $
 .\
 .\ Copyright (c) 2014 Alistair Crooks a...@netbsd.org
 .\ All rights reserved.
@@ -207,7 +207,7 @@ By doing this, the number is encoded in 
 The string of bytes is preceded by its length in bytes, encoded
 as a
 .Dq number .
-When encoding strings, 
+When encoding strings,
 the byte string does not need to be NUL-terminated.
 Neither do any characters need to be escaped.
 .Pp



CVS commit: othersrc/external/bsd/transit/dist

2014-03-11 Thread Thomas Klausner
Module Name:othersrc
Committed By:   wiz
Date:   Tue Mar 11 08:33:27 UTC 2014

Modified Files:
othersrc/external/bsd/transit/dist: libtransit.3

Log Message:
Remove trailing space.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 othersrc/external/bsd/transit/dist/libtransit.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: othersrc/external/bsd/transit

2014-03-06 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Fri Mar  7 01:34:19 UTC 2014

Modified Files:
othersrc/external/bsd/transit/bin: Makefile
othersrc/external/bsd/transit/dist: libtransit.3 main.c transit.c
transit.h
Added Files:
othersrc/external/bsd/transit/bin: 17.expected

Log Message:
Changes to transit-20140306

+ add a function to format JSON in-memory as part of the transit library
+ remove similar functionality from the program
+ update documentation


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/transit/bin/17.expected
cvs rdiff -u -r1.4 -r1.5 othersrc/external/bsd/transit/bin/Makefile
cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/transit/dist/libtransit.3
cvs rdiff -u -r1.4 -r1.5 othersrc/external/bsd/transit/dist/main.c \
othersrc/external/bsd/transit/dist/transit.c \
othersrc/external/bsd/transit/dist/transit.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/transit/bin/Makefile
diff -u othersrc/external/bsd/transit/bin/Makefile:1.4 othersrc/external/bsd/transit/bin/Makefile:1.5
--- othersrc/external/bsd/transit/bin/Makefile:1.4	Wed Mar  5 04:58:51 2014
+++ othersrc/external/bsd/transit/bin/Makefile	Fri Mar  7 01:34:19 2014
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.4 2014/03/05 04:58:51 agc Exp $
+# $NetBSD: Makefile,v 1.5 2014/03/07 01:34:19 agc Exp $
 
 .include bsd.own.mk
 
@@ -98,3 +98,8 @@ t: ${PROG}
 	env LD_LIBRARY_PATH=${LIB_TRANSIT_DIR} ./${PROG} -d -j 16.enc  16.out
 	diff 16.expected 16.out
 	rm -f 16.enc 16.out
+	echo 17. json output
+	env LD_LIBRARY_PATH=${LIB_TRANSIT_DIR} ./${PROG} -j '[1,2,3,4,[5,6,7,[8,[9,[0,10]'  17.enc
+	env LD_LIBRARY_PATH=${LIB_TRANSIT_DIR} ./${PROG} -d -j 17.enc  17.out
+	diff 17.expected 17.out
+	rm -f 17.out 17.enc

Index: othersrc/external/bsd/transit/dist/libtransit.3
diff -u othersrc/external/bsd/transit/dist/libtransit.3:1.2 othersrc/external/bsd/transit/dist/libtransit.3:1.3
--- othersrc/external/bsd/transit/dist/libtransit.3:1.2	Wed Mar  5 04:58:51 2014
+++ othersrc/external/bsd/transit/dist/libtransit.3	Fri Mar  7 01:34:19 2014
@@ -1,4 +1,4 @@
-.\ $NetBSD: libtransit.3,v 1.2 2014/03/05 04:58:51 agc Exp $
+.\ $NetBSD: libtransit.3,v 1.3 2014/03/07 01:34:19 agc Exp $
 .\
 .\ Copyright (c) 2014 Alistair Crooks a...@netbsd.org
 .\ All rights reserved.
@@ -23,7 +23,7 @@
 .\ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\
-.Dd March 4, 2014
+.Dd March 6, 2014
 .Dt LIBTRANSIT 3
 .Os
 .Sh NAME
@@ -54,6 +54,10 @@
 .Fo transit_read_json
 .Fa transit_t *transit const char *in size_t length
 .Fc
+.Ft int
+.Fo transit_format_json
+.Fa transit_t *transit const char *out size_t bufsize
+.Fc
 .Ft transit_t *
 .Fo transit_new
 .Fa void
@@ -154,6 +158,9 @@ by using the
 functions.
 Encoded JSON can be converted into the transit protocol using the
 .Fn transit_read_json
+function, whilst
+the data can be formatted into output as JSON using the
+.Fn transit_format_json
 function.
 .Pp
 To decode serialised input, possibly at the other end of a connection,

Index: othersrc/external/bsd/transit/dist/main.c
diff -u othersrc/external/bsd/transit/dist/main.c:1.4 othersrc/external/bsd/transit/dist/main.c:1.5
--- othersrc/external/bsd/transit/dist/main.c:1.4	Tue Feb 25 20:19:35 2014
+++ othersrc/external/bsd/transit/dist/main.c	Fri Mar  7 01:34:19 2014
@@ -177,57 +177,6 @@ walk(transit_t *t, FILE *fp, int recursi
 	return 1;
 }
 
-/* output JSON */
-static int
-output_json(transit_t *t, uint64_t a, FILE *fp)
-{
-	transit_atom_t	*atom;
-	uint64_t	*v;
-	unsigned	 i;
-
-	atom = transit_atom(t, a);
-	switch(transit_atom_type(atom)) {
-	case TRANSIT_NUMBER:
-		fprintf(fp, % PRIu64, transit_atom_size(atom));
-		return 1;
-	case TRANSIT_STRING:
-		fputc('', fp);
-		fwrite(transit_atom_ptr(atom), 1, transit_atom_size(atom), fp);
-		fputc('', fp);
-		return 1;
-	case TRANSIT_LIST:
-		fprintf(fp, [);
-		v = transit_atom_ptr(atom);
-		for (i = 0 ; i  transit_atom_size(atom) ; i++) {
-			output_json(t, v[i], fp);
-			if (i  transit_atom_size(atom) - 2) {
-fprintf(fp, ,);
-			}
-		}
-		fprintf(fp, ]);
-		return 1;
-	case TRANSIT_DICT:
-		fprintf(fp, {);
-		v = transit_atom_ptr(atom);
-		for (i = 0 ; i  transit_atom_size(atom) - 1 ; i += 2) {
-			output_json(t, v[i], fp);
-			fprintf(fp, :);
-			output_json(t, v[i + 1], fp);
-			if (i  transit_atom_size(atom) - 3) {
-fprintf(fp, ,);
-			}
-		}
-		fprintf(fp, });
-		return 1;
-	case TRANSIT_END:
-		return 1;
-	default:
-		fprintf(stderr, unrecognised atom: %d\n, transit_atom_type(atom));
-		return t-c;
-	}
-	fprintf(fp, \n);
-}
-
 
 int
 main(int argc, char **argv)
@@ -235,6 +184,7 @@ main(int argc, char **argv)
 	transit_t	 t;
 	size_t		 size;
 	char		*in;
+	char		 buf[8192];
 	int		 recursive;
 	int		 decoding;
 	int		 json;
@@ 

CVS commit: othersrc/external/bsd/transit

2014-03-06 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Fri Mar  7 01:34:19 UTC 2014

Modified Files:
othersrc/external/bsd/transit/bin: Makefile
othersrc/external/bsd/transit/dist: libtransit.3 main.c transit.c
transit.h
Added Files:
othersrc/external/bsd/transit/bin: 17.expected

Log Message:
Changes to transit-20140306

+ add a function to format JSON in-memory as part of the transit library
+ remove similar functionality from the program
+ update documentation


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/transit/bin/17.expected
cvs rdiff -u -r1.4 -r1.5 othersrc/external/bsd/transit/bin/Makefile
cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/transit/dist/libtransit.3
cvs rdiff -u -r1.4 -r1.5 othersrc/external/bsd/transit/dist/main.c \
othersrc/external/bsd/transit/dist/transit.c \
othersrc/external/bsd/transit/dist/transit.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: othersrc/external/bsd/transit

2014-03-04 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Wed Mar  5 04:58:51 UTC 2014

Modified Files:
othersrc/external/bsd/transit/bin: Makefile
othersrc/external/bsd/transit/dist: libtransit.3 transit.c transit.h
Added Files:
othersrc/external/bsd/transit/bin: 16.expected

Log Message:
Changes to transit-20140304

+ add 2 accessor functions for lists/dicts, one to get a field by its index,
  and the other for dicts to get the field value by name

+ bump version number to 20140304


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/transit/bin/16.expected
cvs rdiff -u -r1.3 -r1.4 othersrc/external/bsd/transit/bin/Makefile
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/bsd/transit/dist/libtransit.3
cvs rdiff -u -r1.3 -r1.4 othersrc/external/bsd/transit/dist/transit.c \
othersrc/external/bsd/transit/dist/transit.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/transit/bin/Makefile
diff -u othersrc/external/bsd/transit/bin/Makefile:1.3 othersrc/external/bsd/transit/bin/Makefile:1.4
--- othersrc/external/bsd/transit/bin/Makefile:1.3	Tue Feb 25 08:54:43 2014
+++ othersrc/external/bsd/transit/bin/Makefile	Wed Mar  5 04:58:51 2014
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.3 2014/02/25 08:54:43 agc Exp $
+# $NetBSD: Makefile,v 1.4 2014/03/05 04:58:51 agc Exp $
 
 .include bsd.own.mk
 
@@ -93,3 +93,8 @@ t: ${PROG}
 	env LD_LIBRARY_PATH=${LIB_TRANSIT_DIR} ./${PROG} -d -j 15.enc  15.out
 	diff 15.expected 15.out
 	rm -f 15.enc 15.out
+	@echo 16. json structured data as output
+	env LD_LIBRARY_PATH=${LIB_TRANSIT_DIR} ./${PROG} -j '{array:{field1:1,field2:val2,field3:string value 3,field4:val4},array2:[1,2,3,4,5,6,7,8]}'  16.enc
+	env LD_LIBRARY_PATH=${LIB_TRANSIT_DIR} ./${PROG} -d -j 16.enc  16.out
+	diff 16.expected 16.out
+	rm -f 16.enc 16.out

Index: othersrc/external/bsd/transit/dist/libtransit.3
diff -u othersrc/external/bsd/transit/dist/libtransit.3:1.1.1.1 othersrc/external/bsd/transit/dist/libtransit.3:1.2
--- othersrc/external/bsd/transit/dist/libtransit.3:1.1.1.1	Mon Feb 24 05:59:13 2014
+++ othersrc/external/bsd/transit/dist/libtransit.3	Wed Mar  5 04:58:51 2014
@@ -1,4 +1,4 @@
-.\ $NetBSD: libtransit.3,v 1.1.1.1 2014/02/24 05:59:13 agc Exp $
+.\ $NetBSD: libtransit.3,v 1.2 2014/03/05 04:58:51 agc Exp $
 .\
 .\ Copyright (c) 2014 Alistair Crooks a...@netbsd.org
 .\ All rights reserved.
@@ -23,7 +23,7 @@
 .\ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\
-.Dd February 22, 2014
+.Dd March 4, 2014
 .Dt LIBTRANSIT 3
 .Os
 .Sh NAME
@@ -89,6 +89,16 @@ atoms, or fields of atoms.
 .Fo transit_size
 .Fa transit_t *transit
 .Fc
+.Pp
+Some dictionary and list access functions are also defined.
+.Ft int
+.Fo transit_field_by_index
+.Fa transit_t *transit uint32_t dictnum uint32_t fieldnum transit_atom_t *result
+.Fc
+.Ft int
+.Fo transit_field_by_name
+.Fa transit_t *transit uint32_t dictnum const char *fieldname transit_atom_t *result
+.Fc
 .Sh DESCRIPTION
 The
 .Nm

Index: othersrc/external/bsd/transit/dist/transit.c
diff -u othersrc/external/bsd/transit/dist/transit.c:1.3 othersrc/external/bsd/transit/dist/transit.c:1.4
--- othersrc/external/bsd/transit/dist/transit.c:1.3	Tue Feb 25 08:54:43 2014
+++ othersrc/external/bsd/transit/dist/transit.c	Wed Mar  5 04:58:51 2014
@@ -421,3 +421,45 @@ transit_size(transit_t *trans)
 {
 	return (trans) ? trans-c : 0;
 }
+
+/*/
+
+/* dictionary/list accessors */
+
+/* return the contents of the list/dict field, accessed by number */
+int
+transit_field_by_index(transit_t *t, uint32_t dict, uint32_t field, transit_atom_t *ret)
+{
+	transit_atom_t	*atom;
+	transit_atom_t	*el;
+	uint64_t	*indices;
+
+	atom = transit_atom(t, dict);
+	indices = transit_atom_ptr(atom);
+	el = transit_atom(t, indices[field]);
+	memcpy(ret, el, sizeof(*ret));
+	return 1;
+}
+
+/* return the contents of the dict value, accessed by name */
+int
+transit_field_by_name(transit_t *t, uint32_t dict, const char *name, transit_atom_t *ret)
+{
+	transit_atom_t	*atom;
+	transit_atom_t	*el;
+	uint64_t	*indices;
+	uint64_t	 i;
+
+	atom = transit_atom(t, dict);
+	indices = transit_atom_ptr(atom);
+	for (i = 2 ; i  transit_atom_size(atom) ; i += 2) {
+		el = transit_atom(t, indices[i]);
+		if (el-type == TRANSIT_STRING  memcmp(name, el-v, el-n) == 0) {
+			el = transit_atom(t, indices[i + 1]);
+			memcpy(ret, el, sizeof(*ret));
+			return 1;
+		}
+	}
+	return 0;
+}
+
Index: othersrc/external/bsd/transit/dist/transit.h
diff -u othersrc/external/bsd/transit/dist/transit.h:1.3 othersrc/external/bsd/transit/dist/transit.h:1.4
--- othersrc/external/bsd/transit/dist/transit.h:1.3	Tue Mar  4 02:14:15 2014
+++ othersrc/external/bsd/transit/dist/transit.h	Wed Mar  5 04:58:51 2014
@@ -23,7 +23,7 @@
  * 

CVS commit: othersrc/external/bsd/transit

2014-03-04 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Wed Mar  5 04:58:51 UTC 2014

Modified Files:
othersrc/external/bsd/transit/bin: Makefile
othersrc/external/bsd/transit/dist: libtransit.3 transit.c transit.h
Added Files:
othersrc/external/bsd/transit/bin: 16.expected

Log Message:
Changes to transit-20140304

+ add 2 accessor functions for lists/dicts, one to get a field by its index,
  and the other for dicts to get the field value by name

+ bump version number to 20140304


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/transit/bin/16.expected
cvs rdiff -u -r1.3 -r1.4 othersrc/external/bsd/transit/bin/Makefile
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/bsd/transit/dist/libtransit.3
cvs rdiff -u -r1.3 -r1.4 othersrc/external/bsd/transit/dist/transit.c \
othersrc/external/bsd/transit/dist/transit.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: othersrc/external/bsd/transit

2014-03-03 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Tue Mar  4 02:14:15 UTC 2014

Modified Files:
othersrc/external/bsd/transit: Makefile
othersrc/external/bsd/transit/dist: transit.h
Added Files:
othersrc/external/bsd/transit/dist: Makefile.in configure

Log Message:
Add almost-pass-through configure and Makefile.in scripts for the
package distribution. No functional change


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/bsd/transit/Makefile
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/transit/dist/Makefile.in \
othersrc/external/bsd/transit/dist/configure
cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/transit/dist/transit.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/transit/Makefile
diff -u othersrc/external/bsd/transit/Makefile:1.1.1.1 othersrc/external/bsd/transit/Makefile:1.2
--- othersrc/external/bsd/transit/Makefile:1.1.1.1	Mon Feb 24 05:59:13 2014
+++ othersrc/external/bsd/transit/Makefile	Tue Mar  4 02:14:15 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1.1.1 2014/02/24 05:59:13 agc Exp $
+#	$NetBSD: Makefile,v 1.2 2014/03/04 02:14:15 agc Exp $
 
 SUBDIR=		lib .WAIT
 SUBDIR+=	bin
@@ -7,5 +7,3 @@ SUBDIR+=	bin
 
 t:
 	cd bin  ${MAKE} t
-# comment
-# comment

Index: othersrc/external/bsd/transit/dist/transit.h
diff -u othersrc/external/bsd/transit/dist/transit.h:1.2 othersrc/external/bsd/transit/dist/transit.h:1.3
--- othersrc/external/bsd/transit/dist/transit.h:1.2	Mon Feb 24 21:05:18 2014
+++ othersrc/external/bsd/transit/dist/transit.h	Tue Mar  4 02:14:15 2014
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #ifndef TRANSIT_H_
-#define TRANSIT_H_	20140223
+#define TRANSIT_H_	20140303
 
 #include sys/types.h
 

Added files:

Index: othersrc/external/bsd/transit/dist/Makefile.in
diff -u /dev/null othersrc/external/bsd/transit/dist/Makefile.in:1.1
--- /dev/null	Tue Mar  4 02:14:15 2014
+++ othersrc/external/bsd/transit/dist/Makefile.in	Tue Mar  4 02:14:15 2014
@@ -0,0 +1,23 @@
+# $NetBSD: Makefile.in,v 1.1 2014/03/04 02:14:15 agc Exp $
+
+PROG=transit
+
+OBJS+= transit.o
+OBJS+= main.o
+
+PREFIX=@PREFIX@
+MANDIR=@MANDIR@
+
+all: ${PROG}
+
+${PROG}: ${OBJS}
+	${CC} ${OBJS} -o ${PROG}
+
+install:
+	install -c -s ${PROG} ${DESTDIR}${PREFIX}/bin
+	install -c transit.1 ${DESTDIR}${MANDIR}/man1
+
+clean:
+	rm -rf *.core ${OBJS} ${PROG}
+cleandist:
+	rm -rf *.core ${OBJS} ${PROG} Makefile
Index: othersrc/external/bsd/transit/dist/configure
diff -u /dev/null othersrc/external/bsd/transit/dist/configure:1.1
--- /dev/null	Tue Mar  4 02:14:15 2014
+++ othersrc/external/bsd/transit/dist/configure	Tue Mar  4 02:14:15 2014
@@ -0,0 +1,65 @@
+#! /bin/sh
+
+# $NetBSD: configure,v 1.1 2014/03/04 02:14:15 agc Exp $
+
+# Copyright (c) 2014 Alistair Crooks a...@netbsd.org
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#notice, this list of conditions and the following disclaimer in the
+#documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+# set up defs and paths, etc
+prefix=/usr/local
+mandir=${prefix}/man
+while [ $# -gt 0 ]; do
+	case $1 in
+	# have all /bin/sh's got ${1#--prefix=} yet?
+	--prefix=*)	prefix=$(echo $1 | sed -e 's|--prefix=||') ;;
+	--mandir=*)	mandir=$(echo $1 | sed -e 's|--mandir=||') ;;
+	--build=*|--host=*|--infodir=*)	;;
+	*)		break ;;
+	esac
+	shift
+done
+
+rm -f config.h
+echo #ifndef CONFIG_H_  config.h
+echo #define CONFIG_H_ $(date '+%Y%m%d')  config.h
+echo   config.h
+
+# portability macros
+echo #ifndef __UNCONST  config.h
+echo #define __UNCONST(a)   ((void *)(unsigned long)(const void *)(a))  config.h
+echo #endif /* __UNCONST */  config.h
+echo   config.h
+echo #ifndef USE_ARG  config.h
+echo #define USE_ARG(x)   /*LINTED*/(void)(x)  config.h
+echo #endif /* 

CVS commit: othersrc/external/bsd/transit

2014-03-03 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Tue Mar  4 02:14:15 UTC 2014

Modified Files:
othersrc/external/bsd/transit: Makefile
othersrc/external/bsd/transit/dist: transit.h
Added Files:
othersrc/external/bsd/transit/dist: Makefile.in configure

Log Message:
Add almost-pass-through configure and Makefile.in scripts for the
package distribution. No functional change


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/bsd/transit/Makefile
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/transit/dist/Makefile.in \
othersrc/external/bsd/transit/dist/configure
cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/transit/dist/transit.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: othersrc/external/bsd/transit

2014-02-25 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Tue Feb 25 08:54:43 UTC 2014

Modified Files:
othersrc/external/bsd/transit/bin: Makefile
othersrc/external/bsd/transit/dist: main.c transit.c
Added Files:
othersrc/external/bsd/transit/bin: 13.expected 14.expected 15.expected

Log Message:
Add the ability to convert back to JSON in transit(1) - so, if desired,
JSON could be transported safely via the transit protocol.

Small fix for dictionary parsing.

Add more tests.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/transit/bin/13.expected \
othersrc/external/bsd/transit/bin/14.expected \
othersrc/external/bsd/transit/bin/15.expected
cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/transit/bin/Makefile
cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/transit/dist/main.c \
othersrc/external/bsd/transit/dist/transit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/transit/bin/Makefile
diff -u othersrc/external/bsd/transit/bin/Makefile:1.2 othersrc/external/bsd/transit/bin/Makefile:1.3
--- othersrc/external/bsd/transit/bin/Makefile:1.2	Mon Feb 24 21:05:18 2014
+++ othersrc/external/bsd/transit/bin/Makefile	Tue Feb 25 08:54:43 2014
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.2 2014/02/24 21:05:18 agc Exp $
+# $NetBSD: Makefile,v 1.3 2014/02/25 08:54:43 agc Exp $
 
 .include bsd.own.mk
 
@@ -78,13 +78,18 @@ t: ${PROG}
 	env LD_LIBRARY_PATH=${LIB_TRANSIT_DIR} ./${PROG} -d 12.enc  12.out
 	diff 12.expected 12.out
 	rm -f 12.enc 12.out
-	@echo 12. json structured data
-	env LD_LIBRARY_PATH=${LIB_TRANSIT_DIR} ./${PROG} -j '{field1:[potatoes,tomatoes,anykindoftoes,[1,2,3,4,sublist,{field1.1:11,field1.2:twotwo}]],field2:[quayle,bush,shrub,reagan,[3,nothing],[4,4,4,4,4,5,6]]}'  12.enc
-	env LD_LIBRARY_PATH=${LIB_TRANSIT_DIR} ./${PROG} -d 12.enc  12.out
-	diff 12.expected 12.out
-	rm -f 12.enc 12.out
 	@echo 13. json structured data
-	env LD_LIBRARY_PATH=${LIB_TRANSIT_DIR} ./${PROG} -j '{field1:[potatoes\\,tomatoes,anykindoftoes,[1,2,3,4,sublist,{field1.1:11,field1.2:twotwo}]],field2:[quayle,bush,shrub,reagan,[3,nothing],[4,4,4,4,4,5,6]]}'  13.enc
+	env LD_LIBRARY_PATH=${LIB_TRANSIT_DIR} ./${PROG} -j '{field1:[potatoes,tomatoes,anykindoftoes,[1,2,3,4,sublist,{field1.1:11,field1.2:twotwo}]],field2:[quayle,bush,shrub,reagan,[3,nothing],[4,4,4,4,4,5,6]]}'  13.enc
 	env LD_LIBRARY_PATH=${LIB_TRANSIT_DIR} ./${PROG} -d 13.enc  13.out
 	diff 13.expected 13.out
 	rm -f 13.enc 13.out
+	@echo 14. json structured data
+	env LD_LIBRARY_PATH=${LIB_TRANSIT_DIR} ./${PROG} -j '{field1:[potatoes\\,tomatoes,anykindoftoes,[1,2,3,4,sublist,{field1.1:11,field1.2:twotwo}]],field2:[quayle,bush,shrub,reagan,[3,nothing],[4,4,4,4,4,5,6]]}'  14.enc
+	env LD_LIBRARY_PATH=${LIB_TRANSIT_DIR} ./${PROG} -d 14.enc  14.out
+	diff 14.expected 14.out
+	rm -f 14.enc 14.out
+	@echo 15. json structured data as output
+	env LD_LIBRARY_PATH=${LIB_TRANSIT_DIR} ./${PROG} -j '{field1:[potatoes\\,tomatoes,anykindoftoes,[1,2,3,4,sublist,{field1.1:11,field1.2:twotwo}]],field2:[quayle,bush,shrub,reagan,[3,nothing],[4,4,4,4,4,5,6]]}'  15.enc
+	env LD_LIBRARY_PATH=${LIB_TRANSIT_DIR} ./${PROG} -d -j 15.enc  15.out
+	diff 15.expected 15.out
+	rm -f 15.enc 15.out

Index: othersrc/external/bsd/transit/dist/main.c
diff -u othersrc/external/bsd/transit/dist/main.c:1.2 othersrc/external/bsd/transit/dist/main.c:1.3
--- othersrc/external/bsd/transit/dist/main.c:1.2	Mon Feb 24 21:05:18 2014
+++ othersrc/external/bsd/transit/dist/main.c	Tue Feb 25 08:54:43 2014
@@ -172,6 +172,55 @@ walk(transit_t *t, FILE *fp, int recursi
 	return 1;
 }
 
+static int
+output_json(transit_t *t, uint64_t a, FILE *fp)
+{
+	transit_atom_t	*atom;
+	uint64_t	*v;
+	unsigned	 i;
+
+	atom = transit_atom(t, a);
+	switch(transit_atom_type(atom)) {
+	case TRANSIT_NUMBER:
+		fprintf(fp, % PRIu64, transit_atom_size(atom));
+		return 1;
+	case TRANSIT_STRING:
+		fputc('', fp);
+		fwrite(transit_atom_ptr(atom), 1, transit_atom_size(atom), fp);
+		fputc('', fp);
+		return 1;
+	case TRANSIT_LIST:
+		fprintf(fp, [);
+		v = transit_atom_ptr(atom);
+		for (i = 0 ; i  transit_atom_size(atom) ; i++) {
+			output_json(t, v[i], fp);
+			if (i  transit_atom_size(atom) - 2) {
+fprintf(fp, ,);
+			}
+		}
+		fprintf(fp, ]);
+		return 1;
+	case TRANSIT_DICT:
+		fprintf(fp, {);
+		v = transit_atom_ptr(atom);
+		for (i = 0 ; i  transit_atom_size(atom) - 1 ; i += 2) {
+			output_json(t, v[i], fp);
+			fprintf(fp, :);
+			output_json(t, v[i + 1], fp);
+			if (i  transit_atom_size(atom) - 3) {
+fprintf(fp, ,);
+			}
+		}
+		fprintf(fp, });
+		return 1;
+	case TRANSIT_END:
+		return 1;
+	default:
+		fprintf(stderr, unrecognised atom: %d\n, transit_atom_type(atom));
+		return t-c;
+	}
+}
+
 
 int
 main(int argc, char **argv)
@@ -208,19 +257,23 @@ main(int argc, char **argv)
 		}
 	}
 	if (decoding) {
+		in = NULL;
 		if (optind == argc) {
 	

CVS commit: othersrc/external/bsd/transit/dist

2014-02-25 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Tue Feb 25 20:19:35 UTC 2014

Modified Files:
othersrc/external/bsd/transit/dist: main.c

Log Message:
add comments


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 othersrc/external/bsd/transit/dist/main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/transit/dist/main.c
diff -u othersrc/external/bsd/transit/dist/main.c:1.3 othersrc/external/bsd/transit/dist/main.c:1.4
--- othersrc/external/bsd/transit/dist/main.c:1.3	Tue Feb 25 08:54:43 2014
+++ othersrc/external/bsd/transit/dist/main.c	Tue Feb 25 20:19:35 2014
@@ -37,7 +37,7 @@
 #define PROGRAM_AUTHOR	tran...@agc.ac
 #define PROGRAM_VERSION	20140223
 
-
+/* process all data in a stream */
 static char *
 dostream(FILE *fp, size_t *size)
 {
@@ -51,6 +51,7 @@ dostream(FILE *fp, size_t *size)
 	return s;
 }
 
+/* open a file and process the stream */
 static char *
 dofile(const char *f, size_t *size)
 {
@@ -66,6 +67,7 @@ dofile(const char *f, size_t *size)
 	return s;
 }
 
+/* recursive walk function */
 static int
 recwalk1(transit_t *t, unsigned *from, FILE *fp, unsigned indent, const char *term)
 {
@@ -103,6 +105,7 @@ recwalk1(transit_t *t, unsigned *from, F
 	}
 }
 
+/* print indent */
 static inline void
 doindent(FILE *fp, unsigned in)
 {
@@ -113,6 +116,7 @@ doindent(FILE *fp, unsigned in)
 	}
 }
 
+/* array-based walk function */
 static int
 arrwalk1(transit_t *t, uint64_t a, FILE *fp, unsigned indent, const char *term)
 {
@@ -157,6 +161,7 @@ arrwalk1(transit_t *t, uint64_t a, FILE 
 	}
 }
 
+/* walk function */
 static int
 walk(transit_t *t, FILE *fp, int recursive)
 {
@@ -172,6 +177,7 @@ walk(transit_t *t, FILE *fp, int recursi
 	return 1;
 }
 
+/* output JSON */
 static int
 output_json(transit_t *t, uint64_t a, FILE *fp)
 {
@@ -219,6 +225,7 @@ output_json(transit_t *t, uint64_t a, FI
 		fprintf(stderr, unrecognised atom: %d\n, transit_atom_type(atom));
 		return t-c;
 	}
+	fprintf(fp, \n);
 }
 
 
@@ -241,7 +248,8 @@ main(int argc, char **argv)
 	while ((i = getopt(argc, argv, Vdjr)) != -1) {
 		switch(i) {
 		case 'V':
-			printf(%s by %s, version %s\n, PROGRAM_NAME, PROGRAM_AUTHOR, PROGRAM_VERSION);
+			printf(%s by %s, version %s\n,
+PROGRAM_NAME, PROGRAM_AUTHOR, PROGRAM_VERSION);
 			exit(EXIT_SUCCESS);
 		case 'd':
 			decoding = 1;



CVS commit: othersrc/external/bsd/transit

2014-02-25 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Tue Feb 25 08:54:43 UTC 2014

Modified Files:
othersrc/external/bsd/transit/bin: Makefile
othersrc/external/bsd/transit/dist: main.c transit.c
Added Files:
othersrc/external/bsd/transit/bin: 13.expected 14.expected 15.expected

Log Message:
Add the ability to convert back to JSON in transit(1) - so, if desired,
JSON could be transported safely via the transit protocol.

Small fix for dictionary parsing.

Add more tests.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/transit/bin/13.expected \
othersrc/external/bsd/transit/bin/14.expected \
othersrc/external/bsd/transit/bin/15.expected
cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/transit/bin/Makefile
cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/transit/dist/main.c \
othersrc/external/bsd/transit/dist/transit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: othersrc/external/bsd/transit/dist

2014-02-25 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Tue Feb 25 20:19:35 UTC 2014

Modified Files:
othersrc/external/bsd/transit/dist: main.c

Log Message:
add comments


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 othersrc/external/bsd/transit/dist/main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: othersrc/external/bsd/transit

2014-02-24 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Mon Feb 24 21:05:18 UTC 2014

Modified Files:
othersrc/external/bsd/transit/bin: Makefile
othersrc/external/bsd/transit/dist: main.c transit.c transit.h

Log Message:
Update transit to version 20140223

+ properly escape valid JSON strings when converting


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/bsd/transit/bin/Makefile
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/bsd/transit/dist/main.c \
othersrc/external/bsd/transit/dist/transit.c \
othersrc/external/bsd/transit/dist/transit.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: othersrc/external/bsd/transit/bin/Makefile
diff -u othersrc/external/bsd/transit/bin/Makefile:1.1.1.1 othersrc/external/bsd/transit/bin/Makefile:1.2
--- othersrc/external/bsd/transit/bin/Makefile:1.1.1.1	Mon Feb 24 05:59:13 2014
+++ othersrc/external/bsd/transit/bin/Makefile	Mon Feb 24 21:05:18 2014
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1.1.1 2014/02/24 05:59:13 agc Exp $
+# $NetBSD: Makefile,v 1.2 2014/02/24 21:05:18 agc Exp $
 
 .include bsd.own.mk
 
@@ -83,3 +83,8 @@ t: ${PROG}
 	env LD_LIBRARY_PATH=${LIB_TRANSIT_DIR} ./${PROG} -d 12.enc  12.out
 	diff 12.expected 12.out
 	rm -f 12.enc 12.out
+	@echo 13. json structured data
+	env LD_LIBRARY_PATH=${LIB_TRANSIT_DIR} ./${PROG} -j '{field1:[potatoes\\,tomatoes,anykindoftoes,[1,2,3,4,sublist,{field1.1:11,field1.2:twotwo}]],field2:[quayle,bush,shrub,reagan,[3,nothing],[4,4,4,4,4,5,6]]}'  13.enc
+	env LD_LIBRARY_PATH=${LIB_TRANSIT_DIR} ./${PROG} -d 13.enc  13.out
+	diff 13.expected 13.out
+	rm -f 13.enc 13.out

Index: othersrc/external/bsd/transit/dist/main.c
diff -u othersrc/external/bsd/transit/dist/main.c:1.1.1.1 othersrc/external/bsd/transit/dist/main.c:1.2
--- othersrc/external/bsd/transit/dist/main.c:1.1.1.1	Mon Feb 24 05:59:13 2014
+++ othersrc/external/bsd/transit/dist/main.c	Mon Feb 24 21:05:18 2014
@@ -35,7 +35,7 @@
 
 #define PROGRAM_NAME	transit
 #define PROGRAM_AUTHOR	tran...@agc.ac
-#define PROGRAM_VERSION	20140222
+#define PROGRAM_VERSION	20140223
 
 
 static char *
Index: othersrc/external/bsd/transit/dist/transit.c
diff -u othersrc/external/bsd/transit/dist/transit.c:1.1.1.1 othersrc/external/bsd/transit/dist/transit.c:1.2
--- othersrc/external/bsd/transit/dist/transit.c:1.1.1.1	Mon Feb 24 05:59:13 2014
+++ othersrc/external/bsd/transit/dist/transit.c	Mon Feb 24 21:05:18 2014
@@ -284,6 +284,9 @@ transit_read_json(transit_t *t, const ch
 			return (int)(cp - json);
 		case '':
 			for (i = 1, cp = __UNCONST(json[i]) ; json[i] != '' ; i++) {
+if (json[i] == '\\') {
+	i += 1;
+}
 			}
 			transit_encode_string(t, json[1], (size_t)(json[i] - cp));
 			return i + 1;
Index: othersrc/external/bsd/transit/dist/transit.h
diff -u othersrc/external/bsd/transit/dist/transit.h:1.1.1.1 othersrc/external/bsd/transit/dist/transit.h:1.2
--- othersrc/external/bsd/transit/dist/transit.h:1.1.1.1	Mon Feb 24 05:59:13 2014
+++ othersrc/external/bsd/transit/dist/transit.h	Mon Feb 24 21:05:18 2014
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #ifndef TRANSIT_H_
-#define TRANSIT_H_	20140222
+#define TRANSIT_H_	20140223
 
 #include sys/types.h
 



CVS commit: othersrc/external/bsd/transit

2014-02-24 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Mon Feb 24 21:05:18 UTC 2014

Modified Files:
othersrc/external/bsd/transit/bin: Makefile
othersrc/external/bsd/transit/dist: main.c transit.c transit.h

Log Message:
Update transit to version 20140223

+ properly escape valid JSON strings when converting


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/bsd/transit/bin/Makefile
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/bsd/transit/dist/main.c \
othersrc/external/bsd/transit/dist/transit.c \
othersrc/external/bsd/transit/dist/transit.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.