Esempio n. 1
0
void pni_reactor_set_connection_peer_address(pn_connection_t *connection,
                                             const char *host,
                                             const char *port)
{
    pn_url_t *url = pn_url();
    pn_url_set_host(url, host);
    pn_url_set_port(url, port);
    pn_record_t *record = pn_connection_attachments(connection);
    if (!pn_record_has(record, PNI_CONN_PEER_ADDRESS)) {
      pn_record_def(record, PNI_CONN_PEER_ADDRESS, PN_OBJECT);
    }
    pn_record_set(record, PNI_CONN_PEER_ADDRESS, url);
    pn_decref(url);
}
Esempio n. 2
0
void pn_reactor_set_connection_host(pn_reactor_t *reactor,
                                    pn_connection_t *connection,
                                    const char *host,
                                    const char *port)
{
    (void)reactor;  // ignored
    pn_url_t *url = pn_url();
    pn_url_set_host(url, host);
    pn_url_set_port(url, port);
    pn_record_t *record = pn_connection_attachments(connection);
    if (!pn_record_has(record, PNI_CONN_URL)) {
        pn_record_def(record, PNI_CONN_URL, PN_OBJECT);
    }
    pn_record_set(record, PNI_CONN_URL, url);
    pn_decref(url);
}
Esempio n. 3
0
/** Parse a string URL as a pn_url_t.
 *@param[in] url A URL string.
 *@return The parsed pn_url_t or NULL if url is not a valid URL string.
 */
PN_EXTERN pn_url_t *pn_url_parse(const char *str) {
    if (!str || !*str)          /* Empty string or NULL is illegal. */
        return NULL;

    pn_url_t *url = pn_url();
    char *str2 = copy(str);
    pni_parse_url(str2, &url->scheme, &url->username, &url->password, &url->host, &url->port, &url->path);
    url->scheme = copy(url->scheme);
    url->username = copy(url->username);
    url->password = copy(url->password);
    url->host = (url->host && !*url->host) ? NULL : copy(url->host);
    url->port = copy(url->port);
    url->path = copy(url->path);

    free(str2);
    return url;
}
Esempio n. 4
0
pn_url_t* parse_allow_empty(const char* s) {
    return s && *s ? parse_throw(s) : pn_url();
}