2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1998 University of Maryland at College Park
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of U.M. not be used in advertising or
11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. U.M. makes no representations about the
13 * suitability of this software for any purpose. It is provided "as is"
14 * without express or implied warranty.
16 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Author: James da Silva, Systems Design and Analysis Group
24 * Computer Science Department
25 * University of Maryland at College Park
28 * $Id: amlogroll.c,v 1.14 2006/07/25 18:27:57 martinea Exp $
30 * rename a live log file to the datestamped name.
40 void handle_start(void);
41 int main(int argc, char **argv);
51 config_overwrites_t *cfg_ovr = NULL;
55 * Configure program for internationalization:
56 * 1) Only set the message locale for now.
57 * 2) Set textdomain for all amanda related programs to "amanda"
58 * We don't want to be forced to support dozens of message catalogs.
60 setlocale(LC_MESSAGES, "C");
65 set_pname("amlogroll");
67 dbopen(DBG_SUBDIR_SERVER);
69 erroutput_type = ERR_INTERACTIVE;
72 cfg_ovr = extract_commandline_config_overwrites(&argc, &argv);
78 /* read configuration files */
80 config_init(CONFIG_INIT_EXPLICIT_NAME | CONFIG_INIT_USE_CWD | CONFIG_INIT_FATAL,
82 apply_config_overwrites(cfg_ovr);
84 safe_cd(); /* must happen after config_init */
86 check_running_as(RUNNING_AS_DUMPUSER);
88 dbrename(config_name, DBG_SUBDIR_SERVER);
90 conf_logdir = config_dir_relative(getconf_str(CNF_LOGDIR));
91 logfname = vstralloc(conf_logdir, "/", "log", NULL);
94 if((logfile = fopen(logfname, "r")) == NULL) {
95 error(_("could not open log %s: %s"), logfname, strerror(errno));
100 erroutput_type |= ERR_AMANDALOG;
101 set_logerror(logerror);
103 while(get_logline(logfile)) {
104 if(curlog == L_START) {
106 if(datestamp != NULL) {
113 log_rename(datestamp);
122 void handle_start(void)
124 static int started = 0;
132 skip_whitespace(s, ch);
133 if(ch == '\0' || strncmp_const_skip(s - 1, "date", s, ch) != 0) {
134 return; /* ignore bogus line */
137 skip_whitespace(s, ch);
142 skip_non_whitespace(s, ch);
144 datestamp = newstralloc(datestamp, fp);