]> arthur.barton.de Git - netdata.git/blobdiff - src/procfile.h
log: now is logging program name too; tc: huge optimizations; procfile: optimized...
[netdata.git] / src / procfile.h
index f9bcd95b6bdaaa0d7c0952e7373434f6dc095a3f..73dfa19835813b45b210a8ba6e2f9a5018e2465b 100755 (executable)
@@ -55,11 +55,15 @@ typedef struct {
 // ----------------------------------------------------------------------------
 // The procfile
 
+#define PROCFILE_FLAG_DEFAULT             0x00000000
+#define PROCFILE_FLAG_NO_ERROR_ON_FILE_IO 0x00000001
+
 typedef struct {
        char filename[FILENAME_MAX + 1];
+       uint32_t flags;
        int fd;                 // the file desriptor
-       ssize_t len;            // the bytes we have placed into data
-       ssize_t size;           // the bytes we have allocated for data
+       size_t len;             // the bytes we have placed into data
+       size_t size;            // the bytes we have allocated for data
        pflines *lines;
        pfwords *words;
        char separators[256];
@@ -73,13 +77,20 @@ extern void procfile_close(procfile *ff);
 extern procfile *procfile_readall(procfile *ff);
 
 // open a /proc or /sys file
-extern procfile *procfile_open(const char *filename, const char *separators);
+extern procfile *procfile_open(const char *filename, const char *separators, uint32_t flags);
+
+// re-open a file
+// if separators == NULL, the last separators are used
+extern procfile *procfile_reopen(procfile *ff, const char *filename, const char *separators, uint32_t flags);
 
 // example walk-through a procfile parsed file
 extern void procfile_print(procfile *ff);
 
 // ----------------------------------------------------------------------------
 
+// set this to 1, to have procfile adapt its initial buffer allocation to the max allocation used so far
+extern int procfile_adaptive_initial_allocation;
+
 // return the number of lines present
 #define procfile_lines(ff) (ff->lines->len)