Module Name: othersrc
Committed By: agc
Date: Thu Mar 17 03:21:11 UTC 2011
Modified Files:
othersrc/external/bsd/rs/dist: main.c rs.1
Log Message:
rework the data/parity bytes command line specification to be more natural,
especially for this area of erasure codes.
To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/bsd/rs/dist/main.c
cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/rs/dist/rs.1
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/rs/dist/main.c
diff -u othersrc/external/bsd/rs/dist/main.c:1.1.1.1 othersrc/external/bsd/rs/dist/main.c:1.2
--- othersrc/external/bsd/rs/dist/main.c:1.1.1.1 Sat Mar 12 08:08:29 2011
+++ othersrc/external/bsd/rs/dist/main.c Thu Mar 17 03:21:11 2011
@@ -93,8 +93,11 @@
unsigned poly;
uint8_t databytes;
uint8_t parity;
+ uint8_t data2;
+ uint8_t par2;
rs_t rs;
char *out;
+ char *s;
int encoding;
int i;
@@ -108,17 +111,24 @@
case 'P':
poly = (unsigned)strtol(optarg, NULL, 16);
break;
- case 'b':
- databytes = atoi(optarg) & 0xff;
- break;
case 'd':
encoding = 0;
break;
case 'o':
out = optarg;
break;
+ case 'b':
case 'p':
- parity = atoi(optarg) & 0xff;
+ for (s = optarg, data2 = 0 ; *s && *s != '/' ; s++) {
+ data2 = (data2 * 10) + (*s - '0');
+ }
+ if (*s == ',') {
+ for (s++, par2 = 0 ; *s ; s++) {
+ par2 = (par2 * 10) + (*s - '0');
+ }
+ parity = data2 - par2;
+ databytes = par2;
+ }
break;
case 'v':
printf("Version: %u\n", PKG_VERSION);
@@ -130,6 +140,8 @@
}
(void) memset(&rs, 0x0, sizeof(rs));
/* Initialization of the ECC library */
+/* databytes: def 224, should be 255 */
+/* parity: def 32, should be 223 */
if (!rs_init(&rs, poly, databytes, parity)) {
exit(EXIT_FAILURE);
}
Index: othersrc/external/bsd/rs/dist/rs.1
diff -u othersrc/external/bsd/rs/dist/rs.1:1.2 othersrc/external/bsd/rs/dist/rs.1:1.3
--- othersrc/external/bsd/rs/dist/rs.1:1.2 Sat Mar 12 13:20:00 2011
+++ othersrc/external/bsd/rs/dist/rs.1 Thu Mar 17 03:21:11 2011
@@ -1,4 +1,4 @@
-.\" $NetBSD: rs.1,v 1.2 2011/03/12 13:20:00 wiz Exp $
+.\" $NetBSD: rs.1,v 1.3 2011/03/17 03:21:11 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 March 10, 2011
+.Dd March 16, 2011
.Dt RS 1
.Os
.Sh NAME
@@ -32,9 +32,9 @@
.Sh SYNOPSIS
.Nm
.Fl dv
-.Op Fl b Ar data-bytes
+.Op Fl b Ar total-bytes,parity-bytes
.Op Fl o Ar filename
-.Op Fl p Ar parity-bytes
+.Op Fl p Ar total-bytes,parity-bytes
.Ar file ...
.Sh DESCRIPTION
The
@@ -60,32 +60,26 @@
data bytes.
.Pp
The following options are available:
-.Bl -tag -width parity-bytes-and
+.Bl -tag -width total-bytes-and-data-bytes
.It Fl d
decode the file(s) given, or
.Dv stdin
if no files were specified.
-.It Fl v
-print the version information on
-.Dv stdout
-and then exit.
-.It Fl b Ar data-bytes
-specifies the number of data bytes to be used in an output packet.
+.It Fl b Ar total-bytes,data-bytes
+.It Fl p Ar total-bytes,data-bytes
+specifies the total number of bytes in an
+.Dq output packet
+as well as the number of data bytes to be used in an output packet.
If no value is specified,
-.Dv 224
+.Dv 255,223
is used.
+This will protect against 16 errors in the data.
.It Fl o Ar output-file
use the specified file for output.
By default, output will go to
.Dv stdout
-.It Fl p Ar parity-bytes
-specifies the number of parity bytes to be used in an output packet.
-If no value is specified,
-.Dv 32
-is used.
-This will protect against 16 errors in the data.
.It Fl v
-prints the version of
+prints the version information of
.Nm
on
.Dv stdout