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

pkt_t pkt_dup ( pkt_t  pkt,
const char *  to,
const char *  from 
)

duplicate pkt, replacing addresses

Definition at line 73 of file pkt.c.

References pkt_st::from, pkt_st::nad, sm_st::pc, pkt_st::sm, pkt_st::to, and pkt_st::type.

Referenced by _disco_in_sess(), _disco_pkt_sm(), _roster_push(), pres_in(), pres_roster(), and pres_update().

                                                           {
    pkt_t pnew;

    if(pkt == NULL) return NULL;

    pnew = (pkt_t) malloc(sizeof(struct pkt_st));
    memset(pnew, 0, sizeof(struct pkt_st));

    pnew->sm = pkt->sm;
    pnew->type = pkt->type;
    pnew->nad = nad_copy(pkt->nad);

    /* set replacement attrs */
    if(to != NULL) {
        pnew->to = jid_new(pkt->sm->pc, to, -1);
        nad_set_attr(pnew->nad, 1, -1, "to", jid_full(pnew->to), 0);
    } else if(pkt->to != NULL)
        pnew->to = jid_dup(pkt->to);

    if(from != NULL) {
        pnew->from = jid_new(pkt->sm->pc, from, -1);
        nad_set_attr(pnew->nad, 1, -1, "from", jid_full(pnew->from), 0);
    } else if(pkt->from != NULL)
        pnew->from = jid_dup(pkt->from);

    log_debug(ZONE, "duplicated packet");

    return pnew;
}


Generated by  Doxygen 1.6.0   Back to index