char *id_to_name(char *s) { if (s[3]) { /* uid */ u_user *u = u_user_by_uid(s); return u ? u->nick : "*"; } else { /* sid */ u_server *sv = u_server_by_sid(s); return sv ? sv->name : "*"; } }
u_entity *u_entity_from_id(u_entity *e, char *s) { if (!s) return NULL; if (s[3]) { if (!(e->v.u = u_user_by_uid(s))) return NULL; make_user(e); } else { if (!(e->v.sv = u_server_by_sid(s))) return NULL; make_server(e); } return e; }
u_conn *ref_link(u_conn *ctx, char *ref) { if (ctx && ctx->ctx == CTX_SERVER && isdigit(ref[0])) { if (ref[3]) { u_user *u = u_user_by_uid(ref); return u ? u->link : NULL; } else { u_server *sv = u_server_by_sid(ref); return sv ? sv->link : NULL; } } else { if (!strchr(ref, '.')) { u_user *u = u_user_by_nick(ref); return u ? u->link : NULL; } else { u_server *sv = u_server_by_name(ref); return sv ? sv->link : NULL; } } }