4 * hbytes raw2h BINARY => hex
5 * hbytes h2raw HEX => binary
7 * hbytes prepend VAR [VALUE ...] = set VAR [concat VALUE ... $VAR]
8 * hbytes append VAR [VALUE ...] = set VAR [concat $VAR VALUE ...]
9 * hbytes concat VAR [VALUE ...] = set VAR [concat VALUE ...]
10 * hbytes unprepend VAR PREFIXLENGTH => prefix (removed from VAR)
11 * hbytes unappend VAR SUFFIXLENGTH => suffix (removed from VAR)
12 * hbytes chopto VAR NEWVARLENGTH => suffix (removed from VAR)
15 * hbytes pkcs5 pa|ua VAR ALG => worked? (always 1 for p)
16 * hbytes pkcs5 pn|un VAR BLOCKSIZE => worked? (always 1 for p)
17 * hbytes blockcipher d|e VAR ALG MODE [IV] => IV
19 * hbytes hash ALG MESSAGE => hash
20 * hbytes hmac ALG MESSAGE KEY [MACLENGTH] => mac
33 typedef unsigned char Byte;
37 /* Internal representation details: */
38 #define HBYTES_ISEMPTY(hb) (!(hb)->begin_complex && !(hb)->end_0)
39 #define HBYTES_ISSENTINEL(hb) (!(hb)->begin_complex && (hb)->end_0)
40 #define HBYTES_ISSIMPLE(hb) ((hb)->begin_complex && (hb)->end_0)
41 #define HBYTES_ISCOMPLEX(hb) ((hb)->begin_complex && !(hb)->end_0)
44 void *begin_complex, *end_0;
45 } HBytes_Value; /* overlays internalRep */
48 Byte *dstart; /* always allocated dynamically */
49 int prespace, len, avail;
51 * | SPARE | USED | SPARE |
52 * |<-prespace->|<-len->| |
56 } HBytes_ComplexValue; /* pointed to from internalRep.otherValuePtr */
58 /* Public interfaces: */
60 extern Tcl_ObjType hbytes_type;
62 int hbytes_len(const HBytes_Value *v);
63 Byte *hbytes_data(const HBytes_Value *v); /* caller may then modify data! */
64 int hbytes_issentinel(const HBytes_Value *v);
66 Byte *hbytes_prepend(HBytes_Value *upd, int el);
67 Byte *hbytes_append(HBytes_Value *upd, int el);
68 /* return value is where to put the data */
70 const Byte *hbytes_unprepend(HBytes_Value *upd, int rl);
71 const Byte *hbytes_unappend(HBytes_Value *upd, int rl);
72 /* return value points to the removed data, which remains valid
73 * until next op on the HBytes_Value. If original value is
74 * shorter than rl or negative, returns 0 and does nothing. */
76 void hbytes_empty(HBytes_Value *returns);
77 void hbytes_sentinel(HBytes_Value *returns);
78 void hbytes_array(HBytes_Value *returns, const Byte *array, int l);
79 Byte *hbytes_arrayspace(HBytes_Value *returns, int l);
80 void hbytes_free(HBytes_Value *frees);
81 /* _empty, _sentinel and _array do not free or read the old value;
82 * _free it first if needed. _free leaves it garbage, so you
83 * have to call _empty to reuse it. _arrayspace doesn't fill
84 * the array; you get a pointer and must fill it with data
87 /* The value made by hbytes_sentinel should not be passed to
88 * anything except HBYTES_IS..., and hbytes_free. */
92 int staticerr(Tcl_Interp *ip, const char *m);
93 void objfreeir(Tcl_Obj *o);
102 void fini_hbv(Tcl_Interp *ip, int rc, HBytes_Var *agg);
108 extern Tcl_ObjType enum_nearlytype;
109 extern Tcl_ObjType enum1_nearlytype;
111 const void *enum_lookup_cached_func(Tcl_Interp *ip, Tcl_Obj *o,
112 const void *firstentry, size_t entrysize,
114 #define enum_lookup_cached(ip,o,table,what) \
115 (enum_lookup_cached_func((ip),(o), \
116 sizeof((table)[0]),&(table)[0], \
118 /* table should be a pointer to an array of structs of size
119 * entrysize, the first member of which should be a const char*.
120 * The table should finish with a null const char *.
121 * On error, 0 is returned and the ip->result will have been
122 * set to the error message.
125 int enum1_lookup_cached_func(Tcl_Interp *ip, Tcl_Obj *o,
126 const char *opts, const char *what);
132 int blocksize, hashsize;
137 } BlockCipherAlgInfo;
141 } BlockCipherModeInfo;
145 #define OBJ_HBYTES(o) ((HBytes_Value*)&(o)->internalRep.twoPtrValue)
147 #define TALLOC(s) ((void*)Tcl_Alloc((s)))
148 #define TFREE(f) (Tcl_Free((void*)(f)))