X-Git-Url: https://unix4lyfe.org/gitweb/darkstat-debian/blobdiff_plain/a1e8056c92203d02860d719abb1d562453896da8..4da209d9116b41ab59eeedc5823bc2cb64b5bc3e:/str.c diff --git a/str.c b/str.c index 8092666..852a24d 100644 --- a/str.c +++ b/str.c @@ -16,14 +16,15 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "conv.h" +#include "err.h" +#include "str.h" + #include #include #include #include /* for uint32_t on Linux and OS X */ - -#include "conv.h" -#include "err.h" -#include "str.h" +#include #define INITIAL_LEN 1024 @@ -105,7 +106,8 @@ static void str_append_u32(struct str *s, const uint32_t i, const int mod_sep) { char out[I32_MAXLEN]; - int pos, len; + int pos; + unsigned int len; uint32_t rem, next; if (i == 0) { @@ -148,7 +150,8 @@ static void str_append_u64(struct str *s, const uint64_t i, const int mod_sep) { char out[I64_MAXLEN]; - int pos, len; + int pos; + unsigned int len; uint64_t rem, next; uint32_t rem32, next32; @@ -224,9 +227,7 @@ str_append_hex8(struct str *s, const uint8_t b) * * %x is equivalent to %02x and expects a uint8_t */ -static void -str_vappendf(struct str *s, const char *format, va_list va) -{ +void str_vappendf(struct str *s, const char *format, va_list va) { size_t pos, len; len = strlen(format); @@ -354,4 +355,12 @@ length_of_time(const time_t t) return buf; } +ssize_t str_write(const struct str * const buf, const int fd) { + return write(fd, buf->buf, buf->len); +} + +size_t str_len(const struct str * const buf) { + return buf->len; +} + /* vim:set ts=3 sw=3 tw=78 expandtab: */