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