/*++ /* NAME /* host_port 3 /* SUMMARY /* split string into host and port, destroy string /* SYNOPSIS /* #include <host_port.h> /* /* const char *host_port(string, host, def_host, port, def_service) /* char *string; /* char **host; /* char *def_host; /* char **port; /* char *def_service; /* DESCRIPTION /* host_port() splits a string into substrings with the host /* name or address, and the service name or port number. /* The input string is modified. /* /* Host/domain names are validated with valid_utf8_hostname(), /* and host addresses are validated with valid_hostaddr(). /* /* The following input formats are understood (null means /* a null pointer argument): /* /* When def_service is not null, and def_host is null: /* /* [host]:port, [host]:, [host] /* /* host:port, host:, host /* /* When def_host is not null, and def_service is null: /* /* :port, port /* /* Other combinations of def_service and def_host are /* not supported and produce undefined results. /* DIAGNOSTICS /* The result is a null pointer in case of success. /* In case of problems the result is a string pointer with /* the problem type. /* CLIENT EXAMPLE /* .ad /* .fi /* Typical client usage allows the user to omit the service port, /* in which case the client connects to a pre-determined default /* port: /* .nf /* .na /* /* buf = mystrdup(endpoint); /* if ((parse_error = host_port(buf, &host, NULL, &port, defport)) != 0) /* msg_fatal("%s in \"%s\"", parse_error, endpoint); /* if ((aierr = hostname_to_sockaddr(host, port, SOCK_STREAM, &res)) != 0) /* msg_fatal("%s: %s", endpoint, MAI_STRERROR(aierr)); /* myfree(buf); /* SERVER EXAMPLE /* .ad /* .fi /* Typical server usage allows the user to omit the host, meaning /* listen on all available network addresses: /* .nf /* .na /* /* buf = mystrdup(endpoint); /* if ((parse_error = host_port(buf, &host, "", &port, NULL)) != 0) /* msg_fatal("%s in \"%s\"", parse_error, endpoint); /* if (*host == 0) /* host = 0; /* if ((aierr = hostname_to_sockaddr(host, port, SOCK_STREAM, &res)) != 0) /* msg_fatal("%s: %s", endpoint, MAI_STRERROR(aierr)); /* myfree(buf); /* LICENSE /* .ad /* .fi /* The Secure Mailer license must be distributed with this software. /* AUTHOR(S) /* Wietse Venema /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA
/*--*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.