1 /*****************************************************************************
2 * RRDtool 1.0.33 Copyright Tobias Oetiker, 1997,1998, 1999
3 *****************************************************************************
4 * rrdlib.h Public header file for librrd
5 *****************************************************************************
6 * $Id$
7 * $Log$
8 * Revision 1.3 2003/02/13 07:05:27 oetiker
9 * Find attached the patch I promised to send to you. Please note that there
10 * are three new source files (src/rrd_is_thread_safe.h, src/rrd_thread_safe.c
11 * and src/rrd_not_thread_safe.c) and the introduction of librrd_th. This
12 * library is identical to librrd, but it contains support code for per-thread
13 * global variables currently used for error information only. This is similar
14 * to how errno per-thread variables are implemented. librrd_th must be linked
15 * alongside of libpthred
16 *
17 * There is also a new file "THREADS", holding some documentation.
18 *
19 * -- Peter Stamfest <peter@stamfest.at>
20 *
21 * Revision 1.2 2002/05/07 21:58:32 oetiker
22 * new command rrdtool xport integrated
23 * -- Wolfgang Schrimm <Wolfgang.Schrimm@urz.uni-heidelberg.de>
24 *
25 * Revision 1.1.1.1 2001/02/25 22:25:05 oetiker
26 * checkin
27 *
28 *****************************************************************************/
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
33 #ifndef _RRDLIB_H
34 #define _RRDLIB_H
36 #include <time.h>
37 #include <stdio.h> /* for FILE */
39 /* Transplanted from rrd_format.h */
40 typedef double rrd_value_t; /* the data storage type is
41 * double */
42 /* END rrd_format.h */
44 /* main function blocks */
45 int rrd_create(int, char **);
46 int rrd_update(int, char **);
47 int rrd_graph(int, char **, char ***, int *, int *);
48 int rrd_fetch(int, char **, time_t *, time_t *, unsigned long *,
49 unsigned long *, char ***, rrd_value_t **);
50 int rrd_restore(int, char **);
51 int rrd_dump(int, char **);
52 int rrd_tune(int, char **);
53 time_t rrd_last(int, char **);
54 int rrd_resize(int, char **);
55 int rrd_xport(int, char **, int *, time_t *, time_t *,
56 unsigned long *, unsigned long *,
57 char ***, rrd_value_t **);
59 /* thread-safe (hopefully) */
60 int rrd_create_r(char *filename,
61 unsigned long pdp_step, time_t last_up,
62 int argc, char **argv);
63 /* NOTE: rrd_update_r is only thread-safe if no at-style time
64 specifications get used!!! */
65 int rrd_update_r(char *filename, char *template,
66 int argc, char **argv);
67 int rrd_dump_r(char *filename);
68 time_t rrd_last_r(char *filename);
70 /* Transplanted from parsetime.h */
71 typedef enum {
72 ABSOLUTE_TIME,
73 RELATIVE_TO_START_TIME,
74 RELATIVE_TO_END_TIME
75 } timetype;
77 #define TIME_OK NULL
79 struct time_value {
80 timetype type;
81 long offset;
82 struct tm tm;
83 };
85 struct rrd_context {
86 int len;
87 int errlen;
88 char *lib_errstr;
89 char *rrd_error;
90 };
92 /* returns the current per-thread rrd_context */
93 struct rrd_context *rrd_get_context(void);
95 char *parsetime(char *spec, struct time_value *ptv);
96 /* END parsetime.h */
98 int proc_start_end (struct time_value *, struct time_value *, time_t *, time_t *);
100 /* HELPER FUNCTIONS */
101 void rrd_set_error(char *,...);
102 void rrd_clear_error(void);
103 int rrd_test_error(void);
104 char *rrd_get_error(void);
106 /** MULTITHREADED HELPER FUNCTIONS */
107 struct rrd_context *rrd_new_context(void);
108 void rrd_free_context (struct rrd_context *buf);
110 /* void rrd_set_error_r (struct rrd_context *, char *, ...); */
111 /* void rrd_clear_error_r(struct rrd_context *); */
112 /* int rrd_test_error_r (struct rrd_context *); */
113 /* char *rrd_get_error_r (struct rrd_context *); */
115 int LockRRD(FILE *);
117 #endif /* _RRDLIB_H */
119 #ifdef __cplusplus
120 }
121 #endif