* Updated perl compile system. It now uses Makefile.PL for everything,
[rrdtool.git] / src / rrd_last.c
1 /*****************************************************************************
2  * RRDtool 1.1.x  Copyright Tobias Oetiker, 1997 - 2002
3  *****************************************************************************
4  * rrd_last.c
5  *****************************************************************************
6  * Initial version by Russ Wright, @Home Network, 9/28/98
7  *****************************************************************************/
8
9 #include "rrd_tool.h"
10
11 time_t
12 rrd_last(int argc, char **argv)
13 {
14     if(argc < 2){
15         rrd_set_error("please specify an rrd");
16         return(-1);
17     }
18
19     return( rrd_last_r(argv[1]) );
20 }
21  
22
23 time_t
24 rrd_last_r(const char *filename)
25 {
26     FILE        *in_file;
27     time_t       lastup;
28
29     rrd_t        rrd;
30
31     if(rrd_open(filename, &in_file, &rrd, RRD_READONLY)==-1){
32         return(-1);
33     }
34     lastup = rrd.live_head->last_up;
35     rrd_free(&rrd);
36     fclose(in_file);
37     return(lastup);
38 }
39
40