1 /* vmlog - high-speed logging for free VMs */
2 /* Copyright (C) 2006 Edwin Steiner <edwin.steiner@gmx.net> */
4 /* This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
40 "Usage: vmlogindex prefix listfile\n";
42 #define VMLOG_MAXLINELENGTH 1024*16
44 void parse_command_line(int argc,char **argv)
49 r = getopt(argc,argv,"");
53 case '?': vmlog_die("invalid option");
57 if (argc - optind < 2)
58 vmlog_die_usage(usage,1);
60 opt_prefix = argv[optind++];
61 opt_listfname = argv[optind++];
64 int main(int argc,char **argv)
75 vmlog_set_progname(argv[0]);
76 parse_command_line(argc,argv);
78 listfile = fopen(opt_listfname,"r");
80 vmlog_die("could not open file: %s: %s",opt_listfname,strerror(errno));
82 vml = vmlog_log_new(opt_prefix,1);
84 buf = VMLOG_NEW_ARRAY(char,VMLOG_MAXLINELENGTH+1);
85 while (!feof(listfile)) {
86 p = fgets(buf,VMLOG_MAXLINELENGTH,listfile);
89 vmlog_die("reading from file: %s: %s",opt_listfname,strerror(errno));
90 assert(feof(listfile));
95 if (p[len-1] != '\n') {
96 vmlog_warn("line without newline or overlong line read");
103 while (isspace(p[len-1])) {
108 vmlog_warn("removed trailing whitespace from line");
110 i = vmlog_get_string_index(vml,buf,len);
119 /* vim: noet ts=8 sw=8