chiark / gitweb /
wiringpi: changelog: Mention that wiringpi not in Debian proper
[chiark-tcl.git] / hbytes / parse.c
1 /*
2  * hbytes - hex-stringrep efficient byteblocks for Tcl
3  * Copyright 2006-2012 Ian Jackson
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this library; if not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #include "chiark_tcl_hbytes.h"
20
21 int cht_pat_hbv(Tcl_Interp *ip, Tcl_Obj *var, HBytes_Var *agg) {
22   int rc;
23   rc= cht_pat_somethingv(ip,var,&agg->sth,&cht_hbytes_type);
24   if (rc) return rc;
25   agg->hb= OBJ_HBYTES(agg->sth.obj);
26   return TCL_OK;
27 }
28 int cht_pat_hb(Tcl_Interp *ip, Tcl_Obj *obj, HBytes_Value *val) {
29   int rc;
30   rc= Tcl_ConvertToType(ip,obj,&cht_hbytes_type);  if (rc) return rc;
31   *val= *OBJ_HBYTES(obj);
32   return TCL_OK;
33 }
34
35 Tcl_Obj *cht_ret_hb(Tcl_Interp *ip, HBytes_Value val) {
36   Tcl_Obj *obj;
37   obj= Tcl_NewObj();
38   Tcl_InvalidateStringRep(obj);
39   *OBJ_HBYTES(obj)= val;
40   obj->typePtr= &cht_hbytes_type;
41   return obj;
42 }