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

void os_object_put ( os_object_t  o,
const char *  key,
const void *  val,
os_type_t  type 
)

add a field to the object

Definition at line 132 of file object.c.

References os_object_st::hash, os_field_st::key, os_object_st::os, os_type_BOOLEAN, os_type_INTEGER, os_type_NAD, os_type_STRING, os_type_UNKNOWN, os_st::p, os_field_st::type, and os_field_st::val.

Referenced by _privacy_in_sess(), _template_roster_save_item(), and os_object_put_time().

                                                                                    {
    os_field_t osf;
    nad_t nad;

    log_debug(ZONE, "adding field %s (val %x type %d) to object", key, val, type);

    osf = pmalloco(o->os->p, sizeof(struct os_field_st));
    osf->key = pstrdup(o->os->p, key);

    switch(type) {
        case os_type_BOOLEAN:
        case os_type_INTEGER:
            osf->val = (void *) pmalloco(o->os->p, sizeof(int));
            * (int *) osf->val = * (int *) val;
            break;

        case os_type_STRING:
            osf->val = (void *) pstrdup(o->os->p, (char *) val);
            break;

        case os_type_NAD:
            nad = nad_copy((nad_t) val);

            /* make sure that the nad gets freed when the os pool gets freed */
            pool_cleanup(o->os->p, (pool_cleaner) nad_free, (void *) nad);

            osf->val = (void *) nad;
            break;

      case os_type_UNKNOWN:
            break;
    }

    osf->type = type;

    xhash_put(o->hash, osf->key, (void *) osf);
}


Generated by  Doxygen 1.6.0   Back to index