|
NAMEdec64, enc64, dec32, enc32, dec16, enc16, encodefmt - encoding byte arrays as stringsSYNOPSIS#include <u.h>#include <libc.h> int dec64(uchar *out, int lim, char *in, int n) int enc64(char *out, int lim, uchar *in, int n) int dec32(uchar *out, int lim, char *in, int n) int enc32(char *out, int lim, uchar *in, int n) int dec16(uchar *out, int lim, char *in, int n) int enc16(char *out, int lim, uchar *in, int n) int encodefmt(Fmt*) DESCRIPTIONEnc16, enc32 and enc64 create null terminated strings. They return the size of the encoded string (without the null) or -1 if the encoding fails. The encoding fails if lim, the length of the output buffer, is too small.Dec16, dec32 and dec64 return the number of bytes decoded or -1 if the decoding fails. The decoding fails if the output buffer is not large enough or, for base 32, if the input buffer length is not a multiple of 8. Encodefmt can be used with and to print encoded representations of byte arrays. The verbs are
The length of the array is specified as f2. For example, to display a 15 byte array as hex: char x[15]; fmtinstall('H', encodefmt); print("%.*H\n", sizeof x, x); SOURCE/src/lib9/u32.c/src/lib9/u64.c Visit the GSP FreeBSD Man Page Interface. |