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