-typedef struct {
- const char *name;
- int minargs, maxargs;
- Tcl_ObjCmdProc *func;
-} SubCommand;
-
-static const SubCommand subcommands[] = {
- { "bin", 1, 2, hc_bin },
- { 0 }
-};
-
-static int hb_proc(ClientData cd, Tcl_Interp *ip, int objc,
- Tcl_Obj *const *objv) {
- const SubCommand *sc;
-
- if (objc<2) return staticerr(ip, "hbytes: need subcommand");
- sc= enum_lookup_cached(ip,objv[1],subcommands,"hbytes subcommand");
- if (!sc) return TCL_ERROR;
- objc -= 2;
- objv += 2;
- if (objc < sc->minargs)
- return staticerr(ip, "too few args");
- if (sc->maxargs >=0 && objc > sc->maxargs)
- return staticerr(ip,"too many args");
- return sc->func((void*)sc,ip,objc,objv);
+static HBytes_ComplexValue*
+prechop(HBytes_Value *hb, int cl, const Byte **rv) {
+ HBytes_ComplexValue *cx;
+
+ if (cl<0) { *rv=0; return 0; }
+ if (cl==0) { *rv= (const void*)&hbytes_type; return 0; }
+
+ cx= complex(hb);
+ if (cl > cx->len) { *rv=0; return 0; }
+ return cx;