-static int hbytes_t_sfa(Tcl_Interp *ip, Tcl_Obj *o) {
- char *str, *ep, *os;
- Byte *startbytes, *bytes;
- int l;
- char cbuf[3];
-
- os= str= Tcl_GetStringFromObj(o,&l); assert(str);
- objfreeir(o);
-
- if (l & 1) return staticerr(ip, "hbytes: conversion from hex:"
- " odd length in hex");
-
- startbytes= bytes= hbytes_arrayspace(OBJ_HBYTES(o), l/2);
-
- cbuf[2]= 0;
- while (l>0) {
- cbuf[0]= *str++;
- cbuf[1]= *str++;
- *bytes++= strtoul(cbuf,&ep,16);
- if (ep != cbuf+2) {
- hbytes_free(OBJ_HBYTES(o));
- return staticerr(ip, "hbytes: conversion from hex:"
- " bad hex digit");
- }
- l -= 2;
- }
-
- o->typePtr = &hbytes_type;
- return TCL_OK;
-}
-
-Tcl_ObjType hbytes_type = {
- "hbytes",
- hbytes_t_free, hbytes_t_dup, hbytes_t_ustr, hbytes_t_sfa
-};
-
-int do_hbytes_raw2h(ClientData cd, Tcl_Interp *ip,
- Tcl_Obj *binary, HBytes_Value *result) {
- const char *str;
- int l;
-
- str= Tcl_GetStringFromObj(binary,&l);
- hbytes_array(result, str, l);
- return TCL_OK;
-}
-
-int do_hbytes_h2raw(ClientData cd, Tcl_Interp *ip,
- HBytes_Value hex, Tcl_Obj **result) {
- *result= Tcl_NewStringObj(hbytes_data(&hex), hbytes_len(&hex));
- return TCL_OK;
-}
-
-int do_hbytes_length(ClientData cd, Tcl_Interp *ip,
- HBytes_Value v, int *result) {
- *result= hbytes_len(&v);
- return TCL_OK;
-}
-
-int do_hbytes_random(ClientData cd, Tcl_Interp *ip,
- int length, HBytes_Value *result) {
- Byte *space;
- int rc;
-
- space= hbytes_arrayspace(result, length);
- rc= get_urandom(ip, space, length);
- if (rc) { hbytes_free(result); return rc; }
- return TCL_OK;
-}
-
-int do_hbytes_zeroes(ClientData cd, Tcl_Interp *ip,
- int length, HBytes_Value *result) {
- Byte *space;
- space= hbytes_arrayspace(result, length);
- memset(space,0,length);
- return TCL_OK;
-}
-
-int do__hbytes(ClientData cd, Tcl_Interp *ip,
- const HBytes_SubCommand *subcmd,
- int objc, Tcl_Obj *const *objv) {
- return subcmd->func(0,ip,objc,objv);
-}
-
-int do__dgram_socket(ClientData cd, Tcl_Interp *ip,
- const DgramSocket_SubCommand *subcmd,
- int objc, Tcl_Obj *const *objv) {
- return subcmd->func(0,ip,objc,objv);