+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <stdlib.h>
-#include "web_buffer.h"
+#ifdef STORAGE_WITH_MATH
+#include <math.h>
+#endif
#include "common.h"
+#include "web_buffer.h"
#include "log.h"
void web_buffer_strcpy(struct web_buffer *wb, const char *txt)
wb->bytes = bytes;
}
-int print_calculated_number(char *str, calculated_number value)
-{
- char *wstr = str;
-
- // make sure it is unsigned
- unsigned long long uvalue = (unsigned long long)(((value < 0) ? -value : value) * (calculated_number)10000);
-
- // print each digit
- do *wstr++ = (char)(48 + (uvalue % 10)); while(uvalue /= 10);
-
- // make sure we have 8 bytes at least
- while((wstr - str) < 5) *wstr++ = '0';
-
- // put the sign back
- if (value < 0) *wstr++ = '-';
-
- // reverse it
- wstr--;
- strreverse(str, wstr);
-
- // terminate it, one position to the right
- // to let space for a dot
- wstr[2] = '\0';
-
- int i;
- for(i = 0; i < 4 ;i++) {
- wstr[1] = wstr[0];
- wstr--;
- }
- wstr[1] = '.';
-
- // return the buffer length
- return ( (wstr - str) + 6 );
-}
-
void web_buffer_rrd_value(struct web_buffer *wb, calculated_number value)
{
if(wb->size - wb->bytes < 50) return;