コード例 #1
0
static void icaldirset_add_uid(icalcomponent *comp)
{
    char uidstring[MAXPATHLEN] = { 0 };
    icalproperty *uid;

#if defined(HAVE_SYS_UTSNAME_H)
    struct utsname unamebuf;
#endif

    icalerror_check_arg_rv((comp != 0), "comp");

    uid = icalcomponent_get_first_property(comp, ICAL_UID_PROPERTY);

    if (uid == 0) {

#if defined(HAVE_SYS_UTSNAME_H)
        uname(&unamebuf);
        snprintf(uidstring, sizeof(uidstring), "%d-%s", (int)getpid(), unamebuf.nodename);
#else
        /* FIXME: There must be an easy get the system name */
        snprintf(uidstring, sizeof(uidstring), "%d-%s", (int)getpid(), "WINDOWS");
#endif
        uid = icalproperty_new_uid(uidstring);
        icalcomponent_add_property(comp, uid);
    } else {
        strncpy(uidstring, icalproperty_get_uid(uid), MAXPATHLEN - 1);
        uidstring[MAXPATHLEN - 1] = '\0';
    }
}
コード例 #2
0
ファイル: icalbdbset.c プロジェクト: BenjamenMeyer/libical
icalcomponent *icalbdbset_fetch(icalset *set, icalcomponent_kind kind, const char *uid)
{
    icalcompiter i;
    icalbdbset *bset = (icalbdbset *) set;

    icalerror_check_arg_rz((bset != 0), "bset");

    for (i = icalcomponent_begin_component(bset->cluster, kind);
         icalcompiter_deref(&i) != 0; icalcompiter_next(&i)) {

        icalcomponent *this = icalcompiter_deref(&i);
        icalproperty *p = NULL;
        const char *this_uid = NULL;

        if (this != 0) {
            if (kind == ICAL_VAGENDA_COMPONENT) {
                p = icalcomponent_get_first_property(this, ICAL_RELCALID_PROPERTY);
                if (p != NULL) {
                    this_uid = icalproperty_get_relcalid(p);
                }
            } else {
                p = icalcomponent_get_first_property(this, ICAL_UID_PROPERTY);
                if (p != NULL) {
                    this_uid = icalproperty_get_uid(p);
                }
            }

            if (this_uid == NULL) {
                icalerror_warn("icalbdbset_fetch found a component with no UID");
                continue;
            }

            if (strcmp(uid, this_uid) == 0) {
                return this;
            }
        }
    }

    return 0;
}
コード例 #3
0
ファイル: icalbdbset.c プロジェクト: BenjamenMeyer/libical
struct icalbdbset_id icalbdbset_get_id(icalcomponent *comp)
{
    icalcomponent *inner;
    struct icalbdbset_id id;
    icalproperty *p;

    inner = icalcomponent_get_first_real_component(comp);

    p = icalcomponent_get_first_property(inner, ICAL_UID_PROPERTY);

    assert(p != 0);

    id.uid = strdup(icalproperty_get_uid(p));

    p = icalcomponent_get_first_property(inner, ICAL_SEQUENCE_PROPERTY);

    if (p == 0) {
        id.sequence = 0;
    } else {
        id.sequence = icalproperty_get_sequence(p);
    }

    p = icalcomponent_get_first_property(inner, ICAL_RECURRENCEID_PROPERTY);

    if (p == 0) {
        id.recurrence_id = 0;
    } else {
        icalvalue *v;

        v = icalproperty_get_value(p);
        id.recurrence_id = icalvalue_as_ical_string_r(v);

        assert(id.recurrence_id != 0);
    }

    return id;
}