Beispiel #1
0
LDAPMod *
createLDAPModFromItem(int mod_op, PyObject *key, PyObject *value) {
	LDAPMod *mod;

	mod = (LDAPMod *)malloc(sizeof(LDAPMod));
	if (mod == NULL) return NULL;

	mod->mod_op = mod_op;
	mod->mod_type = PyObject2char(key);
	mod->mod_vals.modv_bvals = PyList2BervalList(value);
	return mod;
}
Beispiel #2
0
/* Add new LDAPMod to the list. */
int
LDAPModList_Add(LDAPModList *self, int mod_op, PyObject *key, PyObject *value) {
    LDAPMod *mod;

    /* Add to the next free slot, if there is one. */
    if (self->last == self->size) {
        PyErr_Format(PyExc_OverflowError, "The LDAPModList is full.");
        return -1;
    }

    /* Malloc a new LDAPMod struct. */
    mod = (LDAPMod *)malloc(sizeof(LDAPMod));
    if (mod == NULL) return -1;

    /* Set the values with the parameters. */
    mod->mod_op = mod_op;
    mod->mod_type = PyObject2char(key);
    mod->mod_vals.modv_bvals = PyList2BervalList(value);

    self->mod_list[self->last++] = mod;
    self->mod_list[self->last] = NULL;

    return 0;
}