static int Wmii_init(Wmii *self, PyObject *args, PyObject *kwds) { PyObject *address, *tmp; const char *adr; if (!PyArg_ParseTuple(args, "S", &address)) return -1; if(address) { if (self->client) { ixp_unmount(self->client); } tmp = self->address; Py_INCREF(address); self->address = address; adr = PyString_AsString(address); //printf("** Wmii([%s]) **\n", adr); self->client = ixp_mount(adr); //printf("self->client: %d\n", self->client); if(!self->client) { PyErr_SetString(PyExc_RuntimeError, "Could not connect to server"); return -1; } Py_XDECREF(tmp); } return 0; }
void client_init(char* address) { if(address && *address) client = ixp_mount(address); else client = ixp_nsmount("wmii"); if(client == nil) fatal("can't mount: %r\n"); }
/* ------------------------------------------------------------------------ * lua: x = ixp.new("unix!/tmp/ns.bart.:0/wmii") -- create a new ixp object */ static int l_new (lua_State *L) { const char *adr; IxpClient *cli; struct ixp *ixp; adr = luaL_checkstring (L, 1); DBGF("** ixp.new ([%s]) **\n", adr); cli = ixp_mount(adr); if (!cli) return lixp_pusherror (L, "could not open ixp connection"); ixp = (struct ixp*)lua_newuserdata(L, sizeof (struct ixp)); luaL_getmetatable (L, L_IXP_MT); lua_setmetatable (L, -2); ixp->address = strdup (adr); ixp->client = cli; return 1; }