chiark / gitweb /
tuntap
[chiark-tcl.git] / base / tcmdiflib.c
1 /*
2  * base code for various Tcl extensions
3  * Copyright 2006 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, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18  * 02110-1301, USA.
19  */
20
21 #include "chiark-tcl-base.h"
22
23 int cht_pat_enum(Tcl_Interp *ip, Tcl_Obj *obj, const void **val,
24              const void *opts, size_t sz, const char *what) {
25   *val= cht_enum_lookup_cached_func(ip,obj,opts,sz,what);
26   if (!*val) return TCL_ERROR;
27   return TCL_OK;
28 }
29   
30 int cht_pat_obj(Tcl_Interp *ip, Tcl_Obj *obj, Tcl_Obj **val) {
31   *val= obj;
32   return TCL_OK;
33 }
34
35 Tcl_Obj *cht_ret_int(Tcl_Interp *ip, int val) {
36   return Tcl_NewIntObj(val);
37 }
38
39 Tcl_Obj *cht_ret_obj(Tcl_Interp *ip, Tcl_Obj *val) {
40   return val;
41 }
42
43 void cht_setstringresult(Tcl_Interp *ip, const char *m) {
44   Tcl_ResetResult(ip);
45   Tcl_AppendResult(ip, m, (char*)0);
46 }