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