Logo Search packages:      
Sourcecode: ldb version File versions  Download package

int ldb_msg_add_empty ( struct ldb_message msg,
const char *  attr_name,
int  flags,
struct ldb_message_element **  return_el 
)

add a new empty element to a ldb_message

Definition at line 121 of file ldb_msg.c.

References ldb_message::elements, ldb_message_element::flags, LDB_ERR_OPERATIONS_ERROR, LDB_SUCCESS, ldb_message_element::name, ldb_message::num_elements, ldb_message_element::num_values, and ldb_message_element::values.

{
      struct ldb_message_element *els;

      /* FIXME: we should probably leave this to the schema module to check */
      if (! ldb_valid_attr_name(attr_name)) {
            return LDB_ERR_OPERATIONS_ERROR;
      }

      els = talloc_realloc(msg, msg->elements, 
                       struct ldb_message_element, msg->num_elements+1);
      if (!els) {
            errno = ENOMEM;
            return LDB_ERR_OPERATIONS_ERROR;
      }

      els[msg->num_elements].values = NULL;
      els[msg->num_elements].num_values = 0;
      els[msg->num_elements].flags = flags;
      els[msg->num_elements].name = talloc_strdup(els, attr_name);
      if (!els[msg->num_elements].name) {
            errno = ENOMEM;
            return LDB_ERR_OPERATIONS_ERROR;
      }

      msg->elements = els;
      msg->num_elements++;

      if (return_el) {
            *return_el = &els[msg->num_elements-1];
      }

      return LDB_SUCCESS;
}


Generated by  Doxygen 1.6.0   Back to index