| 276 | } |
| 277 | |
| 278 | static PyObject * |
| 279 | env_open_db(UpsEnvironment *self, PyObject *args) |
| 280 | { |
| 281 | ups_status_t st; |
| 282 | int name = 0; |
| 283 | uint32_t flags = 0; |
| 284 | PyObject *extargs = 0; |
| 285 | std::vector<ups_parameter_t> params; /* should be enough */ |
| 286 | |
| 287 | if (!PyArg_ParseTuple(args, "i|iO!:open_db", &name, &flags, |
| 288 | &PyTuple_Type, &extargs)) |
| 289 | return (0); |
| 290 | |
| 291 | if (extargs) { |
| 292 | if (!parse_parameters(extargs, params)) |
| 293 | return (0); |
| 294 | } |
| 295 | |
| 296 | UpsDatabase *db = (UpsDatabase *)construct_db(0, 0); |
| 297 | if (!db) |
| 298 | return (0); |
| 299 | |
| 300 | ups_set_context_data(db->db, db); |
| 301 | |
| 302 | st = ups_env_open_db(self->env, &db->db, (uint16_t)name, flags, |
| 303 | extargs ? ¶ms[0] : 0); |
| 304 | if (st) { |
| 305 | db_dealloc(db); |
| 306 | THROW(st); |
| 307 | } |
| 308 | |
| 309 | ups_parameter_t flag_params[] = { |
| 310 | {UPS_PARAM_FLAGS, 0}, |
| 311 | {0, 0} |
| 312 | }; |
| 313 | ups_db_get_parameters(db->db, &flag_params[0]); |
| 314 | db->flags = (uint32_t)flag_params[0].value; |
| 315 | |
| 316 | /* add the new database to the environment */ |
| 317 | if (!self->dblist) { |
| 318 | self->dblist = PyList_New(10); |
| 319 | if (!self->dblist) |
| 320 | return (0); |
| 321 | } |
| 322 | if (PyList_Append(self->dblist, (PyObject *)db)) |
| 323 | return (0); |
| 324 | Py_INCREF(db); |
| 325 | |
| 326 | return ((PyObject *)db); |
| 327 | } |
| 328 | |
| 329 | static PyObject * |
| 330 | env_rename_db(UpsEnvironment *self, PyObject *args) |
nothing calls this directly
no test coverage detected