PyObject * MpRequest_FromRequest(request_rec *req) { requestobject *result; result = PyMem_NEW(requestobject, 1); if (! result) return PyErr_NoMemory(); result->request_rec = req; result->ob_type = &MpRequest_Type; result->connection = NULL; result->server = NULL; result->next = NULL; result->prev = NULL; result->main = NULL; result->headers_in = MpTable_FromTable(req->headers_in); result->headers_out = MpTable_FromTable(req->headers_out); result->err_headers_out = MpTable_FromTable(req->err_headers_out); result->subprocess_env = MpTable_FromTable(req->subprocess_env); result->notes = MpTable_FromTable(req->notes); result->Request = NULL; result->header_sent = 0; result->content_type_set = 0; result->hstack = NULL; result->rbuff = NULL; result->rbuff_pos = 0; result->rbuff_len = 0; _Py_NewReference(result); ap_register_cleanup(req->pool, (PyObject *)result, python_decref, ap_null_cleanup); return (PyObject *) result; }
static PyObject * req_get_options(requestobject *self, PyObject *args) { py_dir_config *conf = (py_dir_config *) ap_get_module_config(self->request_rec->per_dir_config, &python_module); return MpTable_FromTable(conf->options); }
static PyObject * req_get_all_dirs(requestobject *self, PyObject *args) { table *all; py_dir_config *conf = (py_dir_config *) ap_get_module_config(self->request_rec->per_dir_config, &python_module); all = ap_copy_table(self->request_rec->pool, conf->dirs); if (ap_table_get(self->request_rec->notes, "py_more_directives")) { array_header *ah = ap_table_elts(self->request_rec->notes); table_entry *elts = (table_entry *)ah->elts; int i = ah->nelts; while (i--) { if (elts[i].key) { /* chop off _dir */ char *s = ap_pstrdup(self->request_rec->pool, elts[i].key); if (valid_handler(s)) { s[strlen(s)-4] = 0; ap_table_set(all, s, elts[i].val); } } } } return MpTable_FromTable(all); }
PyObject * MpConn_FromConn(conn_rec *c) { connobject *result; result = PyObject_New(connobject, &MpConn_Type); if (! result) return PyErr_NoMemory(); result->conn = c; result->base_server = NULL; result->notes = MpTable_FromTable(c->notes); result->hlo = NULL; return (PyObject *)result; }
PyObject * MpTable_New() { tableobject *t; apr_pool_t *p; /* XXX need second arg abort function to report mem error */ apr_pool_sub_make(&p, NULL, NULL); /* two is a wild guess */ t = (tableobject *)MpTable_FromTable(apr_table_make(p, 2)); /* remember the pointer to our own pool */ t->pool = p; return (PyObject *)t; }
static PyObject * req_get_all_config(requestobject *self, PyObject *args) { table *all; py_dir_config *conf = (py_dir_config *) ap_get_module_config(self->request_rec->per_dir_config, &python_module); all = ap_copy_table(self->request_rec->pool, conf->directives); if (ap_table_get(self->request_rec->notes, "py_more_directives")) { array_header *ah = ap_table_elts(self->request_rec->notes); table_entry *elts = (table_entry *)ah->elts; int i = ah->nelts; while (i--) { if (elts[i].key) { if (valid_handler(elts[i].key)) { /* if exists - append, otherwise add */ const char *val = ap_table_get(all, elts[i].key); if (val) { ap_table_set(all, elts[i].key, ap_pstrcat(self->request_rec->pool, val, " ", elts[i].val, NULL)); } else { ap_table_set(all, elts[i].key, elts[i].val); } } } } } return MpTable_FromTable(all); }