]> arthur.barton.de Git - netdata.git/blob - src/web_buffer.h
splitted netdata to multiple source files
[netdata.git] / src / web_buffer.h
1 #include <stdarg.h>
2 #include <time.h>
3 #include "storage_number.h"
4
5 #ifndef NETDATA_WEB_BUFFER_H
6 #define NETDATA_WEB_BUFFER_H 1
7
8 #define WEB_DATA_LENGTH_INCREASE_STEP 65536
9
10 struct web_buffer {
11         long size;              // allocation size of buffer
12         long bytes;             // current data length in buffer
13         long sent;              // current data length sent to output
14         char *buffer;   // the buffer
15         int contenttype;
16         long rbytes;    // if non-zero, the excepted size of ifd
17         time_t date;    // the date this content has been generated
18 };
19
20 // content-types
21 #define CT_APPLICATION_JSON                             1
22 #define CT_TEXT_PLAIN                                   2
23 #define CT_TEXT_HTML                                    3
24 #define CT_APPLICATION_X_JAVASCRIPT             4
25 #define CT_TEXT_CSS                                             5
26 #define CT_TEXT_XML                                             6
27 #define CT_APPLICATION_XML                              7
28 #define CT_TEXT_XSL                                             8
29 #define CT_APPLICATION_OCTET_STREAM             9
30 #define CT_APPLICATION_X_FONT_TRUETYPE  10
31 #define CT_APPLICATION_X_FONT_OPENTYPE  11
32 #define CT_APPLICATION_FONT_WOFF                12
33 #define CT_APPLICATION_VND_MS_FONTOBJ   13
34 #define CT_IMAGE_SVG_XML                                14
35
36 #define web_buffer_printf(wb, args...) wb->bytes += snprintf(&wb->buffer[wb->bytes], (wb->size - wb->bytes), ##args)
37 #define web_buffer_reset(wb) wb->buffer[wb->bytes = 0] = '\0'
38
39 void web_buffer_strcpy(struct web_buffer *wb, const char *txt);
40 int print_calculated_number(char *str, calculated_number value);
41 void web_buffer_rrd_value(struct web_buffer *wb, calculated_number value);
42
43 void web_buffer_jsdate(struct web_buffer *wb, int year, int month, int day, int hours, int minutes, int seconds);
44
45 struct web_buffer *web_buffer_create(long size);
46 void web_buffer_free(struct web_buffer *b);
47 void web_buffer_increase(struct web_buffer *b, long free_size_required);
48
49 #endif /* NETDATA_WEB_BUFFER_H */