diff options
| -rw-r--r-- | doc/mans/bindle_decode.3.in | 9 | ||||
| -rw-r--r-- | include/bindle.h | 6 | ||||
| -rw-r--r-- | lib/libbindle/lencoding.c | 36 | ||||
| -rw-r--r-- | lib/libbindle/libbindle.sym | 1 |
4 files changed, 52 insertions, 0 deletions
diff --git a/doc/mans/bindle_decode.3.in b/doc/mans/bindle_decode.3.in index 44607c6..f46993f 100644 --- a/doc/mans/bindle_decode.3.in +++ b/doc/mans/bindle_decode.3.in | |||
| @@ -51,6 +51,8 @@ Bindle Binaries Tools (libbindle, -lbindle) | |||
| 51 | .sp | 51 | .sp |
| 52 | .BI "ssize_t bindle_encoding_verify( int " method ", const char * " src "," | 52 | .BI "ssize_t bindle_encoding_verify( int " method ", const char * " src "," |
| 53 | .BI " size_t " n " );" | 53 | .BI " size_t " n " );" |
| 54 | .sp | ||
| 55 | .BI "int bindle_encoded_char( int " method ", char " c " );" | ||
| 54 | 56 | ||
| 55 | .SH DESCRIPTION | 57 | .SH DESCRIPTION |
| 56 | \fBbindle_decode\fR() decodes \fIn\fR bytes from \fIsrc\fR into \fIdst\fR | 58 | \fBbindle_decode\fR() decodes \fIn\fR bytes from \fIsrc\fR into \fIdst\fR |
| @@ -94,6 +96,9 @@ encode \fIn\fR bytes of data according to the method specified by | |||
| 94 | .sp | 96 | .sp |
| 95 | \fBbindle_encoding_verify\fR() verifies that \fIn\fR bytes of data in | 97 | \fBbindle_encoding_verify\fR() verifies that \fIn\fR bytes of data in |
| 96 | \fIsrc\fR are encoded according to encoding specified by \fImethod\fR. | 98 | \fIsrc\fR are encoded according to encoding specified by \fImethod\fR. |
| 99 | .sp | ||
| 100 | \fBbindle_encoded_char\fR() returns the value of the encoded character \fIc\fR | ||
| 101 | for \fImethod\fR. | ||
| 97 | 102 | ||
| 98 | .SH RETURN VALUES | 103 | .SH RETURN VALUES |
| 99 | If successful \fBbindle_decode\fR() and \fBbindle_encode\fR() return the | 104 | If successful \fBbindle_decode\fR() and \fBbindle_encode\fR() return the |
| @@ -106,6 +111,10 @@ error occurs, errno is set and -1 is returned. | |||
| 106 | .sp | 111 | .sp |
| 107 | \fBbindle_encoding_verify\fR() returns 0 if the data is correctly encoded. If | 112 | \fBbindle_encoding_verify\fR() returns 0 if the data is correctly encoded. If |
| 108 | an error occurred, errno is set and -1 is returned. | 113 | an error occurred, errno is set and -1 is returned. |
| 114 | .sp | ||
| 115 | \fBbindle_encoded_char\fR() returns the value of the specified character if | ||
| 116 | \fIc\fR is a valid encoded character for \fImethod\fR or returns -1 if \fIc\fR | ||
| 117 | is not a valid encoded character. | ||
| 109 | 118 | ||
| 110 | .SH SEE ALSO | 119 | .SH SEE ALSO |
| 111 | .BR bindletools (3) | 120 | .BR bindletools (3) |
diff --git a/include/bindle.h b/include/bindle.h index f7e16e3..aae49f5 100644 --- a/include/bindle.h +++ b/include/bindle.h | |||
| @@ -338,6 +338,12 @@ bindle_encode_size( | |||
| 338 | size_t n ); | 338 | size_t n ); |
| 339 | 339 | ||
| 340 | 340 | ||
| 341 | _BINDLE_F int | ||
| 342 | bindle_encoded_char( | ||
| 343 | int method, | ||
| 344 | char c ); | ||
| 345 | |||
| 346 | |||
| 341 | _BINDLE_F ssize_t | 347 | _BINDLE_F ssize_t |
| 342 | bindle_encoding_verify( | 348 | bindle_encoding_verify( |
| 343 | int method, | 349 | int method, |
diff --git a/lib/libbindle/lencoding.c b/lib/libbindle/lencoding.c index 4895ac0..8a3cc25 100644 --- a/lib/libbindle/lencoding.c +++ b/lib/libbindle/lencoding.c | |||
| @@ -1300,6 +1300,42 @@ bindle_encode_size( | |||
| 1300 | } | 1300 | } |
| 1301 | 1301 | ||
| 1302 | 1302 | ||
| 1303 | int | ||
| 1304 | bindle_encoded_char( | ||
| 1305 | int method, | ||
| 1306 | char c ) | ||
| 1307 | { | ||
| 1308 | unsigned char u = (unsigned char)c; | ||
| 1309 | switch(method) | ||
| 1310 | { | ||
| 1311 | case BNDL_BASE32: | ||
| 1312 | return(base32_vals[u]); | ||
| 1313 | |||
| 1314 | case BNDL_BASE32HEX: | ||
| 1315 | return(base32hex_vals[u]); | ||
| 1316 | |||
| 1317 | case BNDL_BASE64: | ||
| 1318 | return(base64_vals[u]); | ||
| 1319 | |||
| 1320 | case BNDL_CROCKFORD: | ||
| 1321 | return(crockford_vals[u]); | ||
| 1322 | |||
| 1323 | case BNDL_HEX: | ||
| 1324 | return(hex_vals[u]); | ||
| 1325 | |||
| 1326 | case BNDL_NONE: | ||
| 1327 | return((int)u); | ||
| 1328 | |||
| 1329 | case BNDL_PCTENC: | ||
| 1330 | return(pctenc_vals[u]); | ||
| 1331 | |||
| 1332 | default: | ||
| 1333 | break; | ||
| 1334 | }; | ||
| 1335 | return(-1); | ||
| 1336 | } | ||
| 1337 | |||
| 1338 | |||
| 1303 | ssize_t | 1339 | ssize_t |
| 1304 | bindle_encoding_verify( | 1340 | bindle_encoding_verify( |
| 1305 | int method, | 1341 | int method, |
diff --git a/lib/libbindle/libbindle.sym b/lib/libbindle/libbindle.sym index e7c5b34..b23a6e2 100644 --- a/lib/libbindle/libbindle.sym +++ b/lib/libbindle/libbindle.sym | |||
| @@ -52,6 +52,7 @@ bindle_decode | |||
| 52 | bindle_decode_size | 52 | bindle_decode_size |
| 53 | bindle_encode | 53 | bindle_encode |
| 54 | bindle_encode_size | 54 | bindle_encode_size |
| 55 | bindle_encoded_char | ||
| 55 | bindle_encoding_verify | 56 | bindle_encoding_verify |
| 56 | # | 57 | # |
| 57 | # file functions | 58 | # file functions |
