Module Name:    othersrc
Committed By:   agc
Date:           Thu Feb 16 04:05:12 UTC 2012

Modified Files:
        othersrc/external/bsd/circa/dist: circa.c circa.h libcirca.3 main.c
        othersrc/external/bsd/circa/libcirca: shlib_version

Log Message:
Add an argument to circa_file(3), and a command line flag (-n) to
circa(1), to denote that we do/do not want the circa header placed in the
output.  This is useful in cases where the sectorsize is pre-defined,
and so we do not need to place the value in a header in the output.

Bump shlib major version for the change to the API for libcirca(3).


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 othersrc/external/bsd/circa/dist/circa.c \
    othersrc/external/bsd/circa/dist/libcirca.3 \
    othersrc/external/bsd/circa/dist/main.c
cvs rdiff -u -r1.3 -r1.4 othersrc/external/bsd/circa/dist/circa.h
cvs rdiff -u -r1.1.1.1 -r1.2 \
    othersrc/external/bsd/circa/libcirca/shlib_version

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/circa/dist/circa.c
diff -u othersrc/external/bsd/circa/dist/circa.c:1.5 othersrc/external/bsd/circa/dist/circa.c:1.6
--- othersrc/external/bsd/circa/dist/circa.c:1.5	Thu Oct 13 16:00:48 2011
+++ othersrc/external/bsd/circa/dist/circa.c	Thu Feb 16 04:05:12 2012
@@ -295,7 +295,7 @@ circa_end(circa_t *circa)
 
 /* process a file - encoding or decoding */
 int
-circa_file(circa_t *circa, size_t sectorsize, int encoding, char *in, char *fout)
+circa_file(circa_t *circa, size_t sectorsize, int encoding, int header, char *in, char *fout)
 {
 	uint8_t	*buf;
 	uint8_t	*out;
@@ -332,21 +332,27 @@ circa_file(circa_t *circa, size_t sector
 			(void) fprintf(stderr, "can't allocate sectorsize buffers\n");
 			return 0;
 		}
-		outcc = circa_put_header(circa, out, sectorsize);
-		if (write(fileno(fpout), out, (size_t)outcc) != outcc) {
-			(void) fprintf(stderr, "short write\n");
-			return 0;
+		if (header) {
+			outcc = circa_put_header(circa, out, sectorsize);
+			if (write(fileno(fpout), out, (size_t)outcc) != outcc) {
+				(void) fprintf(stderr, "short write\n");
+				return 0;
+			}
 		}
 	} else {
 		/* read the encoding paramters from input */
-		if (read(fileno(fpin), &circa->header, sizeof(circa->header)) != sizeof(circa->header)) {
-			(void) fprintf(stderr, "short read\n");
-			return 0;
-		}
-		if (circa_get_header(circa, &circa->header, sizeof(circa->header)) != sizeof(circa->header) ||
-		    !circa_init(circa, readsize = sectorsize = circa->header.sectorsize)) {
-			(void) fprintf(stderr, "bad sectorsize %zu\n", sectorsize);
-			return 0;
+		if (header) {
+			if (read(fileno(fpin), &circa->header, sizeof(circa->header)) != sizeof(circa->header)) {
+				(void) fprintf(stderr, "short read\n");
+				return 0;
+			}
+			if (circa_get_header(circa, &circa->header, sizeof(circa->header)) != sizeof(circa->header) ||
+			    !circa_init(circa, readsize = sectorsize = circa->header.sectorsize)) {
+				(void) fprintf(stderr, "bad sectorsize %zu\n", sectorsize);
+				return 0;
+			}
+		} else {
+			readsize = sectorsize;
 		}
 		if ((buf = calloc(1, sectorsize)) == NULL ||
 		    (out = calloc(1, sectorsize)) == NULL) {
Index: othersrc/external/bsd/circa/dist/libcirca.3
diff -u othersrc/external/bsd/circa/dist/libcirca.3:1.5 othersrc/external/bsd/circa/dist/libcirca.3:1.6
--- othersrc/external/bsd/circa/dist/libcirca.3:1.5	Wed Aug  3 05:52:19 2011
+++ othersrc/external/bsd/circa/dist/libcirca.3	Thu Feb 16 04:05:12 2012
@@ -1,4 +1,4 @@
-.\" $NetBSD: libcirca.3,v 1.5 2011/08/03 05:52:19 agc Exp $
+.\" $NetBSD: libcirca.3,v 1.6 2012/02/16 04:05:12 agc Exp $
 .\"
 .\" Copyright (c) 2011 Alistair Crooks <[email protected]>
 .\" 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 August 2, 2011
+.Dd February 15, 2012
 .Dt LIBCIRCA 3
 .Os
 .Sh NAME
@@ -48,7 +48,7 @@
 .Fc
 .Ft int
 .Fo circa_file
-.Fa "circa_t *circa" "size_t sectorsize" "int encoding" "char *in" "char *fout"
+.Fa "circa_t *circa" "size_t sectorsize" "int encoding" "int header" "char *in" "char *fout"
 .Fc
 .Ft ssize_t
 .Fo circa_get_header
Index: othersrc/external/bsd/circa/dist/main.c
diff -u othersrc/external/bsd/circa/dist/main.c:1.5 othersrc/external/bsd/circa/dist/main.c:1.6
--- othersrc/external/bsd/circa/dist/main.c:1.5	Wed Aug  3 05:52:19 2011
+++ othersrc/external/bsd/circa/dist/main.c	Thu Feb 16 04:05:12 2012
@@ -34,7 +34,7 @@
 
 #include "circa.h"
 
-#define PKG_VERSION	"20110511"
+#define PKG_VERSION	"20120215"
 #define PKG_AUTHOR	"Alistair Crooks ([email protected])"
 
 int
@@ -44,17 +44,22 @@ main(int argc, char **argv)
 	size_t	 sectorsize;
 	char	*out;
 	int	 encoding;
+	int	 header;
 	int	 i;
 
 	(void) memset(&circa, 0x0, sizeof(circa));
+	header = 1;
 	encoding = 1;
 	sectorsize = CIRCA_SECTOR_SIZE;
 	out = NULL;
-	while ((i = getopt(argc, argv, "do:s:v")) != -1) {
+	while ((i = getopt(argc, argv, "dno:s:v")) != -1) {
 		switch(i) {
 		case 'd':
 			encoding = 0;
 			break;
+		case 'n':
+			header = 0;
+			break;
 		case 'o':
 			out = optarg;
 			break;
@@ -71,10 +76,10 @@ main(int argc, char **argv)
 	}
 	/* Initialization of the ECC library */
 	if (optind == argc) {
-		circa_file(&circa, sectorsize, encoding, NULL, out);
+		circa_file(&circa, sectorsize, encoding, header, NULL, out);
 	} else {
 		for (i = optind ; i < argc ; i++) {
-			circa_file(&circa, sectorsize, encoding, argv[i], out);
+			circa_file(&circa, sectorsize, encoding, header, argv[i], out);
 		}
 	}
 	circa_end(&circa);

Index: othersrc/external/bsd/circa/dist/circa.h
diff -u othersrc/external/bsd/circa/dist/circa.h:1.3 othersrc/external/bsd/circa/dist/circa.h:1.4
--- othersrc/external/bsd/circa/dist/circa.h:1.3	Wed Aug  3 05:52:19 2011
+++ othersrc/external/bsd/circa/dist/circa.h	Thu Feb 16 04:05:12 2012
@@ -75,7 +75,7 @@ int circa_end(circa_t */*circa*/);
 ssize_t circa_encode(circa_t */*circa*/, const void */*in*/, size_t /*insize*/, uint8_t */*out*/, size_t /*outsize*/);
 ssize_t circa_decode(circa_t */*circa*/, const void */*in*/, size_t /*insize*/, uint8_t */*out*/, size_t /*outsize*/);
 
-int circa_file(circa_t */*circa*/, size_t /*sectorsize*/, int /*encoding*/, char */*in*/, char */*fout*/);
+int circa_file(circa_t */*circa*/, size_t /*sectorsize*/, int /*encoding*/, int /*header*/, char */*in*/, char */*fout*/);
 
 /* resilient header routines */
 ssize_t circa_get_header(circa_t */*circa*/, const void */*in*/, size_t /*size*/);

Index: othersrc/external/bsd/circa/libcirca/shlib_version
diff -u othersrc/external/bsd/circa/libcirca/shlib_version:1.1.1.1 othersrc/external/bsd/circa/libcirca/shlib_version:1.2
--- othersrc/external/bsd/circa/libcirca/shlib_version:1.1.1.1	Sat May  7 02:31:24 2011
+++ othersrc/external/bsd/circa/libcirca/shlib_version	Thu Feb 16 04:05:12 2012
@@ -1,2 +1,2 @@
-major=0
+major=1
 minor=0

Reply via email to