return (status);
} /* }}} int rrd_update_daemon */
+int rrdc_flush (const char *filename) /* {{{ */
+{
+ char buffer[4096];
+ char *buffer_ptr;
+ size_t buffer_free;
+ size_t buffer_size;
+ int status;
+
+ if (filename == NULL)
+ return (-1);
+
+ memset (buffer, 0, sizeof (buffer));
+ buffer_ptr = &buffer[0];
+ buffer_free = sizeof (buffer);
+
+ status = buffer_add_string ("flush", &buffer_ptr, &buffer_free);
+ if (status != 0)
+ return (ENOBUFS);
+
+ status = buffer_add_string (filename, &buffer_ptr, &buffer_free);
+ if (status != 0)
+ return (ENOBUFS);
+
+ assert (buffer_free < sizeof (buffer));
+ buffer_size = sizeof (buffer) - buffer_free;
+ assert (buffer[buffer_size - 1] == ' ');
+ buffer[buffer_size - 1] = '\n';
+
+ pthread_mutex_lock (&lock);
+
+ if (sd < 0)
+ {
+ pthread_mutex_unlock (&lock);
+ return (ENOTCONN);
+ }
+
+ status = swrite (buffer, buffer_size);
+ if (status != 0)
+ {
+ pthread_mutex_unlock (&lock);
+ return (status);
+ }
+
+ status = sread (buffer, sizeof (buffer));
+ if (status < 0)
+ {
+ status = errno;
+ pthread_mutex_unlock (&lock);
+ return (status);
+ }
+ else if (status == 0)
+ {
+ pthread_mutex_unlock (&lock);
+ return (ENODATA);
+ }
+
+ pthread_mutex_unlock (&lock);
+
+ status = atoi (buffer);
+ return (status);
+} /* }}} int rrdc_flush */
+
/*
* vim: set sw=2 sts=2 ts=8 et fdm=marker :
*/
int rrdc_update (const char *filename, int values_num,
const char * const *values);
+int rrdc_flush (const char *filename);
+
#endif /* __RRD_CLIENT_H */