if(na->port != -1) {
char buffer[64];
- snprintf(buffer, sizeof buffer, "%d", na->port);
+ byte_snprintf(buffer, sizeof buffer, "%d", na->port);
vector_append(v, xstrdup(buffer));
}
vector_terminate(v);
hints->ai_family = na->af;
hints->ai_protocol = protocol;
hints->ai_flags = passive ? AI_PASSIVE : 0;
- snprintf(service, sizeof service, "%d", na->port);
+ byte_snprintf(service, sizeof service, "%d", na->port);
rc = getaddrinfo(na->address, service, hints, &res);
if(rc) {
disorder_error(0, "getaddrinfo %s %d: %s",
} else if(arg == disorder__integer) {
long n = va_arg(ap, long);
char buffer[16];
- snprintf(buffer, sizeof buffer, "%ld", n);
+ byte_snprintf(buffer, sizeof buffer, "%ld", n);
dynstr_append(&d, ' ');
dynstr_append_string(&d, buffer);
} else if(arg == disorder__time) {
time_t n = va_arg(ap, time_t);
char buffer[16];
- snprintf(buffer, sizeof buffer, "%lld", (long long)n);
+ byte_snprintf(buffer, sizeof buffer, "%lld", (long long)n);
dynstr_append(&d, ' ');
dynstr_append_string(&d, buffer);
} else {
/*
* This file is part of DisOrder
- * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
+ * Copyright (C) 2004, 2005, 2007-9, 2013 Richard Kettlewell
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "hex.h"
#include "mem.h"
#include "log.h"
+#include "printf.h"
/** @brief Convert a byte sequence to hex
* @param ptr Pointer to first byte
char *buf = xmalloc_noptr(n * 2 + 1), *p = buf;
while(n-- > 0)
- p += sprintf(p, "%02x", (unsigned)*ptr++);
+ p += byte_snprintf(p, 3, "%02x", (unsigned)*ptr++);
*p = 0;
return buf;
}
/*
* This file is part of DisOrder
- * Copyright (C) 2005, 2007, 2008 Richard Kettlewell
+ * Copyright (C) 2005, 2007-10, 2013 Richard Kettlewell
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "log.h"
#include "base64.h"
#include "kvp.h"
+#include "printf.h"
/** @brief Match whitespace characters */
static int whitespace(int c) {
++linelength;
} else {
/* Anything else that needs encoding */
- snprintf(buffer, sizeof buffer, "=%02X", c);
+ byte_snprintf(buffer, sizeof buffer, "=%02X", c);
dynstr_append_string(d, buffer);
linelength += 3;
}