properly rename internal [v]snprintf() functions

Otherwise it clashes when we want to re-introduce the `xmpp_` prefix'ed
versions.

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
Steffen Jaeckel
2022-03-03 21:34:07 +01:00
parent a92115ab9f
commit fc6ba89c61
14 changed files with 30 additions and 32 deletions

View File

@@ -540,7 +540,7 @@ static char *_make_scram_init_msg(xmpp_conn_t *conn)
message_len = strlen(node) + strlen(nonce) + 8 + 1;
message = strophe_alloc(ctx, message_len);
if (message) {
xmpp_snprintf(message, message_len, "n,,n=%s,r=%s", node, nonce);
strophe_snprintf(message, message_len, "n,,n=%s,r=%s", node, nonce);
}
strophe_free(ctx, node);
@@ -1298,7 +1298,7 @@ int _handle_component_auth(xmpp_conn_t *conn)
if (digest) {
/* convert the digest into string representation */
for (i = 0; i < sizeof(md_value); i++)
xmpp_snprintf(digest + i * 2, 3, "%02x", md_value[i]);
strophe_snprintf(digest + i * 2, 3, "%02x", md_value[i]);
digest[2 * sizeof(md_value)] = '\0';
strophe_debug(conn->ctx, "auth", "Digest: %s, len: %d", digest,

View File

@@ -919,7 +919,7 @@ void xmpp_send_raw_string(xmpp_conn_t *conn, const char *fmt, ...)
return;
va_start(ap, fmt);
len = xmpp_vsnprintf(buf, sizeof(buf), fmt, ap);
len = strophe_vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
if (len >= sizeof(buf)) {
@@ -933,7 +933,7 @@ void xmpp_send_raw_string(xmpp_conn_t *conn, const char *fmt, ...)
return;
}
va_start(ap, fmt);
xmpp_vsnprintf(bigbuf, len, fmt, ap);
strophe_vsnprintf(bigbuf, len, fmt, ap);
va_end(ap);
/* len - 1 so we don't send trailing \0 */

View File

@@ -42,7 +42,7 @@ static char *digest_to_string(const uint8_t *digest, char *s, size_t len)
return NULL;
for (i = 0; i < SHA1_DIGEST_SIZE; ++i)
xmpp_snprintf(s + i * 2, 3, "%02x", digest[i]);
strophe_snprintf(s + i * 2, 3, "%02x", digest[i]);
return s;
}

View File

@@ -283,7 +283,7 @@ static void _strophe_log(const xmpp_ctx_t *ctx,
return;
va_copy(copy, ap);
ret = xmpp_vsnprintf(smbuf, sizeof(smbuf), fmt, ap);
ret = strophe_vsnprintf(smbuf, sizeof(smbuf), fmt, ap);
if (ret >= (int)sizeof(smbuf)) {
buf = (char *)strophe_alloc(ctx, ret + 1);
if (!buf) {
@@ -294,7 +294,7 @@ static void _strophe_log(const xmpp_ctx_t *ctx,
return;
}
oldret = ret;
ret = xmpp_vsnprintf(buf, ret + 1, fmt, copy);
ret = strophe_vsnprintf(buf, ret + 1, fmt, copy);
if (ret > oldret) {
strophe_error(ctx, "log", "Unexpected error");
strophe_free(ctx, buf);

View File

@@ -179,8 +179,8 @@ int resolver_srv_lookup(xmpp_ctx_t *ctx,
(void)buf;
(void)len;
xmpp_snprintf(fulldomain, sizeof(fulldomain), "_%s._%s.%s", service, proto,
domain);
strophe_snprintf(fulldomain, sizeof(fulldomain), "_%s._%s.%s", service,
proto, domain);
*srv_rr_list = NULL;
@@ -715,8 +715,8 @@ static int resolver_win32_srv_lookup(xmpp_ctx_t *ctx,
rr->port = current->Data.Srv.wPort;
rr->priority = current->Data.Srv.wPriority;
rr->weight = current->Data.Srv.wWeight;
xmpp_snprintf(rr->target, sizeof(rr->target), "%s",
current->Data.Srv.pNameTarget);
strophe_snprintf(rr->target, sizeof(rr->target), "%s",
current->Data.Srv.pNameTarget);
*srv_rr_list = rr;
}
current = current->pNext;

View File

@@ -440,9 +440,9 @@ char *sasl_scram(xmpp_ctx_t *ctx,
goto out_auth;
}
xmpp_snprintf(response, response_len, "c=biws,%s", r);
xmpp_snprintf(auth, auth_len, "%s,%s,%s", first_bare + 3, challenge,
response);
strophe_snprintf(response, response_len, "c=biws,%s", r);
strophe_snprintf(auth, auth_len, "%s,%s,%s", first_bare + 3, challenge,
response);
SCRAM_ClientKey(alg, (uint8_t *)password, strlen(password), (uint8_t *)sval,
sval_len, (uint32_t)ival, key);

View File

@@ -61,7 +61,7 @@
/* JAM: we don't need this - #include "config.h" */
/* JAM: changed declarations to xmpp_snprintf and xmpp_vsnprintf to
/* JAM: changed declarations to strophe_snprintf and strophe_vsnprintf to
avoid namespace collision. */
#include "snprintf.h"
@@ -722,7 +722,7 @@ int strophe_snprintf(char *str, size_t count, const char *fmt, ...)
int total;
VA_START(fmt);
total = xmpp_vsnprintf(str, count, fmt, ap);
total = strophe_vsnprintf(str, count, fmt, ap);
VA_END;
return total;
}

View File

@@ -20,16 +20,14 @@
#endif
#ifdef HAVE_SNPRINTF
#define xmpp_snprintf snprintf
#define strophe_snprintf snprintf
#else
#define xmpp_snprintf strophe_snprintf
int strophe_snprintf(char *str, size_t count, const char *fmt, ...);
#endif
#ifdef HAVE_VSNPRINTF
#define xmpp_vsnprintf vsnprintf
#define strophe_vsnprintf vsnprintf
#else
#define xmpp_vsnprintf strophe_vsnprintf
int strophe_vsnprintf(char *str, size_t count, const char *fmt, va_list arg);
#endif

View File

@@ -76,7 +76,7 @@ sock_t sock_connect(const char *host, unsigned short port)
struct addrinfo *res, *ainfo, hints;
int err;
xmpp_snprintf(service, 6, "%u", port);
strophe_snprintf(service, 6, "%u", port);
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;

View File

@@ -336,7 +336,7 @@ _render_stanza_recursive(xmpp_stanza_t *stanza, char *buf, size_t buflen)
tmp = _escape_xml(stanza->ctx, stanza->data);
if (tmp == NULL)
return XMPP_EMEM;
ret = xmpp_snprintf(ptr, left, "%s", tmp);
ret = strophe_snprintf(ptr, left, "%s", tmp);
strophe_free(stanza->ctx, tmp);
if (ret < 0)
return XMPP_EMEM;
@@ -346,7 +346,7 @@ _render_stanza_recursive(xmpp_stanza_t *stanza, char *buf, size_t buflen)
return XMPP_EINVOP;
/* write beginning of tag and attributes */
ret = xmpp_snprintf(ptr, left, "<%s", stanza->data);
ret = strophe_snprintf(ptr, left, "<%s", stanza->data);
if (ret < 0)
return XMPP_EMEM;
_render_update(&written, buflen, ret, &left, &ptr);
@@ -374,7 +374,7 @@ _render_stanza_recursive(xmpp_stanza_t *stanza, char *buf, size_t buflen)
hash_iter_release(iter);
return XMPP_EMEM;
}
ret = xmpp_snprintf(ptr, left, " %s=\"%s\"", key, tmp);
ret = strophe_snprintf(ptr, left, " %s=\"%s\"", key, tmp);
strophe_free(stanza->ctx, tmp);
if (ret < 0) {
hash_iter_release(iter);
@@ -387,7 +387,7 @@ _render_stanza_recursive(xmpp_stanza_t *stanza, char *buf, size_t buflen)
if (!stanza->children) {
/* write end if singleton tag */
ret = xmpp_snprintf(ptr, left, "/>");
ret = strophe_snprintf(ptr, left, "/>");
if (ret < 0)
return XMPP_EMEM;
_render_update(&written, buflen, ret, &left, &ptr);
@@ -395,7 +395,7 @@ _render_stanza_recursive(xmpp_stanza_t *stanza, char *buf, size_t buflen)
/* this stanza has child stanzas */
/* write end of start tag */
ret = xmpp_snprintf(ptr, left, ">");
ret = strophe_snprintf(ptr, left, ">");
if (ret < 0)
return XMPP_EMEM;
_render_update(&written, buflen, ret, &left, &ptr);
@@ -413,7 +413,7 @@ _render_stanza_recursive(xmpp_stanza_t *stanza, char *buf, size_t buflen)
}
/* write end tag */
ret = xmpp_snprintf(ptr, left, "</%s>", stanza->data);
ret = strophe_snprintf(ptr, left, "</%s>", stanza->data);
if (ret < 0)
return XMPP_EMEM;

View File

@@ -214,7 +214,7 @@ static xmpp_tlscert_t *_x509_to_tlscert(xmpp_ctx_t *ctx, gnutls_x509_crt_t cert)
hex_encode(buf, smallbuf, size);
tlscert->elements[XMPP_CERT_FINGERPRINT_SHA256] = strophe_strdup(ctx, buf);
xmpp_snprintf(buf, sizeof(buf), "%d", gnutls_x509_crt_get_version(cert));
strophe_snprintf(buf, sizeof(buf), "%d", gnutls_x509_crt_get_version(cert));
tlscert->elements[XMPP_CERT_VERSION] = strophe_strdup(ctx, buf);
algo = gnutls_x509_crt_get_pk_algorithm(cert, NULL);

View File

@@ -433,7 +433,7 @@ static xmpp_tlscert_t *_x509_to_tlscert(xmpp_ctx_t *ctx, X509 *cert)
tlscert->elements[XMPP_CERT_FINGERPRINT_SHA256] =
_get_fingerprint(ctx, cert, XMPP_CERT_FINGERPRINT_SHA256);
xmpp_snprintf(buf, sizeof(buf), "%ld", X509_get_version(cert) + 1);
strophe_snprintf(buf, sizeof(buf), "%ld", X509_get_version(cert) + 1);
tlscert->elements[XMPP_CERT_VERSION] = strophe_strdup(ctx, buf);
tlscert->elements[XMPP_CERT_KEYALG] = _get_alg(ctx, cert, XMPP_CERT_KEYALG);

View File

@@ -35,7 +35,7 @@ void strophe_free(const xmpp_ctx_t *ctx, void *p)
}
#ifndef HAVE_SNPRINTF
int xmpp_snprintf(char *str, size_t count, const char *fmt, ...)
int strophe_snprintf(char *str, size_t count, const char *fmt, ...)
{
(void)str;
(void)count;

View File

@@ -37,7 +37,7 @@ int main(void)
for (x = 0; fp_fmt[x] != NULL; x++)
for (y = 0; fp_nums[y] != 0; y++) {
xmpp_snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]);
strophe_snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]);
sprintf(buf2, fp_fmt[x], fp_nums[y]);
if (strcmp(buf1, buf2)) {
printf("xmpp_snprintf doesn't match Format: "
@@ -50,7 +50,7 @@ int main(void)
for (x = 0; int_fmt[x] != NULL; x++)
for (y = 0; int_nums[y] != 0; y++) {
xmpp_snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]);
strophe_snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]);
sprintf(buf2, int_fmt[x], int_nums[y]);
if (strcmp(buf1, buf2)) {
printf("xmpp_snprintf doesn't match Format: "