示例#1
0
/**
 * Prints the host address ``ha'' followed by ``port'' to a static buffer. 
 *
 * @param ha the host address.
 * @param port the port number.
 *
 * @return a pointer to a static buffer holding a NUL-terminated string
 *         representing the given host address and port.
 */
const char *
port_host_addr_to_string(uint16 port, const host_addr_t ha)
{
	static char buf[HOST_ADDR_PORT_BUFLEN];
	size_t n;

	n = host_port_addr_to_string_buf(port, ha, buf, sizeof buf);
	g_assert(n < sizeof buf);
	return buf;
}
示例#2
0
/**
 * Prints the host address ``ha'' followed by ``port'' to a static buffer.
 *
 * @param ha the host address.
 * @param port the port number.
 *
 * @return a pointer to a static buffer holding a NUL-terminated string
 *         representing the given host address and port.
 */
const char *
port_host_addr_to_string(uint16 port, const host_addr_t ha)
{
	buf_t *b = buf_private(G_STRFUNC, HOST_ADDR_PORT_BUFLEN);
	char *p = buf_data(b);
	size_t len, n = buf_size(b);

	len = host_port_addr_to_string_buf(port, ha, p, n);
	g_assert(len < n);
	return p;
}