]> arthur.barton.de Git - netdata.git/blobdiff - src/web_buffer.c
Merge pull request #17 from alonbl/build
[netdata.git] / src / web_buffer.c
index 48f29a2926087bb5718f495b25215b807414a45c..f679f1b7e6d2f36e4d7d4c051ca76dd1d259f205 100755 (executable)
@@ -1,8 +1,14 @@
+#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)
@@ -16,41 +22,6 @@ 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;