reduce compiler warnings. Many small fixes. -- Mike Slifcak <slif@bellsouth.net>
[rrdtool.git] / src / rrd.h
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.8  2004/05/26 22:11:12  oetiker
9  * reduce compiler warnings. Many small fixes. -- Mike Slifcak <slif@bellsouth.net>
10  *
11  * Revision 1.7  2003/11/12 22:14:26  oetiker
12  * allow to pass an open filehandle into rrd_graph as an extra argument
13  *
14  * Revision 1.6  2003/11/11 19:46:21  oetiker
15  * replaced time_value with rrd_time_value as MacOS X introduced a struct of that name in their standard headers
16  *
17  * Revision 1.5  2003/04/25 18:35:08  jake
18  * Alternate update interface, updatev. Returns info about CDPs written to disk as result of update. Output format is similar to rrd_info, a hash of key-values.
19  *
20  * Revision 1.4  2003/04/01 22:52:23  jake
21  * Fix Win32 build. VC++ 6.0 and 7.0 now use the thread-safe code.
22  *
23  * Revision 1.3  2003/02/13 07:05:27  oetiker
24  * Find attached the patch I promised to send to you. Please note that there
25  * are three new source files (src/rrd_is_thread_safe.h, src/rrd_thread_safe.c
26  * and src/rrd_not_thread_safe.c) and the introduction of librrd_th. This
27  * library is identical to librrd, but it contains support code for per-thread
28  * global variables currently used for error information only. This is similar
29  * to how errno per-thread variables are implemented.  librrd_th must be linked
30  * alongside of libpthred
31  *
32  * There is also a new file "THREADS", holding some documentation.
33  *
34  * -- Peter Stamfest <peter@stamfest.at>
35  *
36  * Revision 1.2  2002/05/07 21:58:32  oetiker
37  * new command rrdtool xport integrated
38  * --  Wolfgang Schrimm <Wolfgang.Schrimm@urz.uni-heidelberg.de>
39  *
40  * Revision 1.1.1.1  2001/02/25 22:25:05  oetiker
41  * checkin
42  *
43  *****************************************************************************/
44 #ifdef  __cplusplus
45 extern "C" {
46 #endif
47
48 #ifndef _RRDLIB_H
49 #define _RRDLIB_H
50
51 #include <time.h>
52 #include <stdio.h> /* for FILE */
53
54 /* Transplanted from rrd_format.h */
55 typedef double       rrd_value_t;         /* the data storage type is
56                                            * double */
57 /* END rrd_format.h */
58
59 /* main function blocks */
60 int    rrd_create(int, char **);
61 int    rrd_update(int, char **);
62 int    rrd_graph(int, char **, char ***, int *, int *, FILE *);
63 int    rrd_fetch(int, char **, time_t *, time_t *, unsigned long *,
64                  unsigned long *, char ***, rrd_value_t **);
65 int    rrd_restore(int, char **);
66 int    rrd_dump(int, char **);
67 int    rrd_tune(int, char **);
68 time_t rrd_last(int, const char **);
69 int    rrd_resize(int, char **);
70 int    rrd_xport(int, char **, int *, time_t *, time_t *,
71                  unsigned long *, unsigned long *,
72                  char ***, rrd_value_t **);
73
74 /* thread-safe (hopefully) */
75 int    rrd_create_r(char *filename,
76                     unsigned long pdp_step, time_t last_up,
77                     int argc, char **argv);
78 /* NOTE: rrd_update_r are only thread-safe if no at-style time
79    specifications get used!!! */
80 int    rrd_update_r(char *filename, char *_template,
81                     int argc, char **argv);
82 int    rrd_dump_r(char *filename);
83 time_t rrd_last_r(const char *filename);
84
85 /* Transplanted from parsetime.h */
86 typedef enum {
87         ABSOLUTE_TIME,
88         RELATIVE_TO_START_TIME, 
89         RELATIVE_TO_END_TIME
90 } timetype;
91
92 #define TIME_OK NULL
93
94 struct rrd_time_value {
95   timetype type;
96   long offset;
97   struct tm tm;
98 };
99
100 struct rrd_context {
101     int len;
102     int errlen;
103     char *lib_errstr;
104     char *rrd_error;
105 };
106
107 /* returns the current per-thread rrd_context */
108 struct rrd_context *rrd_get_context(void);
109
110 char *parsetime(const char *spec, struct rrd_time_value *ptv);
111 /* END parsetime.h */
112
113 int proc_start_end (struct rrd_time_value *,  struct rrd_time_value *, time_t *, time_t *);
114
115 /* HELPER FUNCTIONS */
116 void rrd_set_error(char *,...);
117 void rrd_clear_error(void);
118 int  rrd_test_error(void);
119 char *rrd_get_error(void);
120
121 /** MULTITHREADED HELPER FUNCTIONS */
122 struct rrd_context *rrd_new_context(void);
123 void   rrd_free_context (struct rrd_context *buf);
124
125 /* void   rrd_set_error_r  (struct rrd_context *, char *, ...); */
126 /* void   rrd_clear_error_r(struct rrd_context *); */
127 /* int    rrd_test_error_r (struct rrd_context *); */
128 /* char  *rrd_get_error_r  (struct rrd_context *); */
129
130 int  LockRRD(FILE *);
131
132 #endif /* _RRDLIB_H */
133
134 #ifdef  __cplusplus
135 }
136 #endif