static void no_buffer(void) { int len; len = rb_snprintf_append(NULL, 0, "%s", "test"); is_int(-1, len, MSG); }
/* * m_userhost added by Darren Reed 13/8/91 to aid clients and reduce * the need for complicated requests like WHOIS. It returns user/host * information only (no spurious AWAY labels or channels). */ static int m_userhost(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { struct Client *target_p; char response[IRCD_BUFSIZE]; int i; memset(response, 0, sizeof(response)); /* XXX why 5 here? */ for(i = 1; i <= 5; i++) { if(parc < i + 1) break; if((target_p = find_person(parv[i])) != NULL) { /* * Show real IP for USERHOST on yourself. * This is needed for things like mIRC, which do a server-based * lookup (USERHOST) to figure out what the clients' local IP * is. Useful for things like NAT, and dynamic dial-up users. */ if(MyClient(target_p) && (target_p == source_p)) { rb_snprintf_append(response, sizeof(response), "%s%s=%c%s@%s ", target_p->name, IsOper(target_p) ? "*" : "", (target_p->user->away) ? '-' : '+', target_p->username, target_p->sockhost); } else { rb_snprintf_append(response, sizeof(response), "%s%s=%c%s@%s ", target_p->name, IsOper(target_p) ? "*" : "", (target_p->user->away) ? '-' : '+', target_p->username, target_p->host); } } } sendto_one_numeric(source_p, s_RPL(RPL_USERHOST), response); return 0; }
static void from_empty1(void) { char output[2048] = { 0 }; int len; len = rb_snprintf_append(output, sizeof(output), "%s", "test"); is_int(4, len, MSG); is_string("test", output, MSG); }
static void too_long_basic_append1(void) { char output[11] = { 0 }; int len; strcat(output, "test"); len = rb_snprintf_append(output, sizeof(output), "%s", "TESTING"); is_int(11, len, MSG); is_string("testTESTIN", output, MSG); }
static void exact_fit_empty1(void) { char output[5] = { 0 }; int len; strcat(output, "test"); len = rb_snprintf_append(output, sizeof(output), "%s", ""); is_int(4, len, MSG); is_string("test", output, MSG); }
static void truncate_existing2(void) { char output[2048] = { 0 }; int len; strcat(output, "testing"); len = rb_snprintf_append(output, 5, "%s", "TEST"); is_int(4, len, MSG); is_string("test", output, MSG); }
static void report_nameservers(void) { int i; char ipaddr[HOSTIPLEN + 1]; char buf[512]; buf[0] = '\0'; for(i = 0; i < irc_nscount; i++) { if(!rb_inet_ntop_sock ((struct sockaddr *)&(irc_nsaddr_list[i]), ipaddr, sizeof(ipaddr))) { rb_strlcpy(ipaddr, "?", sizeof(ipaddr)); } rb_snprintf_append(buf, sizeof(buf), "%s ", ipaddr); } rb_helper_write(res_helper, "A %s", buf); }