- socks[sockix]= 0;
- return TCL_OK;
-}
-
-/* Arg parsing */
-
-int pat_sockid(Tcl_Interp *ip, Tcl_Obj *o, TuntapSocket **val) {
- int rc, sockix;
- TuntapSocket *sock;
-
- rc= Tcl_ConvertToType(ip,o,&tuntapsockid_type);
- if (rc) return rc;
-
- sockix= o->internalRep.longValue;
- if (sockix >= n_socks || !(sock= socks[sockix]))
- return staticerr(ip,"tuntap socket not open",0);
-
- assert(socks[sockix]->ix == sockix);
-
- *val= sock;
- return TCL_OK;
-}
-
-Tcl_Obj *ret_sockid(Tcl_Interp *ip, TuntapSocket *val) {
- Tcl_Obj *o;
-
- o= Tcl_NewObj();
- Tcl_InvalidateStringRep(o);
- o->internalRep.longValue= val->ix;
- o->typePtr= &tuntapsockid_type;
- return o;
-}
-
-static void sockid_t_free(Tcl_Obj *o) { }
-
-static void sockid_t_dup(Tcl_Obj *src, Tcl_Obj *dup) {
- dup->internalRep= src->internalRep;
- dup->typePtr= &tuntapsockid_type;
-}
-
-static void sockid_t_ustr(Tcl_Obj *o) {
- char buf[75];
-
- snprintf(buf,sizeof(buf), "%d", (int)o->internalRep.longValue);
- obj_updatestr_vstringls(o,
- "tuntapsock",9,
- buf, strlen(buf),
- (char*)0);
-}
-
-static int sockid_t_sfa(Tcl_Interp *ip, Tcl_Obj *o) {
- unsigned long ul;
- char *ep, *str;
-
- str= Tcl_GetStringFromObj(o,0);
- if (memcmp(str,"tuntapsock",9)) return staticerr(ip,"bad tuntap socket id",0);
- errno=0; ul=strtoul(str+9,&ep,10);
- if (errno || *ep) return staticerr(ip,"bad tuntap socket id number",0);
- if (ul > INT_MAX) return staticerr(ip,"out of range tuntap socket id",0);
-
- objfreeir(o);
- o->internalRep.longValue= ul;
- o->typePtr= &tuntapsockid_type;