/** compare two full jids */ int jid_compare_full(jid_t a, jid_t b) { jid_expand(a); jid_expand(b); return strcmp(a->_full, b->_full); }
/** compare the user portion of two jids */ int jid_compare_user(jid_t a, jid_t b) { jid_expand(a); jid_expand(b); return strcmp(a->_user, b->_user); }
static mod_ret_t _vacation_pkt_user(mod_instance_t mi, user_t user, pkt_t pkt) { module_t mod = mi->mod; vacation_t v = user->module_data[mod->index]; time_t t; pkt_t res; if(v->msg == NULL) return mod_PASS; /* only want messages, and only if they're offline */ if(!(pkt->type & pkt_MESSAGE) || user->top != NULL) return mod_PASS; /* reply only to real, human users - they always have full JIDs in 'from' */ jid_expand(pkt->from); if(pkt->from->node[0] == '\0' || pkt->from->resource[0] == '\0') { pkt_free(pkt); return mod_HANDLED; } t = time(NULL); if(v->start < t && (t < v->end || v->end == 0)) { res = pkt_create(mod->mm->sm, "message", NULL, jid_full(pkt->from), mod->mm->sm->id); nad_insert_elem(res->nad, 1, NAD_ENS(res->nad, 1), "subject", "Automated reply"); nad_insert_elem(res->nad, 1, NAD_ENS(res->nad, 1), "body", v->msg); pkt_router(res); /* !!! remember that we sent this */ } return mod_PASS; }
/** expand and return the full */ const unsigned char *jid_full(jid_t jid) { jid_expand(jid); return jid->_full; }
/** expand and return the user */ const unsigned char *jid_user(jid_t jid) { jid_expand(jid); return jid->_user; }
/** expand and return the full */ const char *jid_full(jid_t jid) { jid_expand(jid); return jid->_full; }
/** expand and return the user */ const char *jid_user(jid_t jid) { jid_expand(jid); return jid->_user; }