-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathconfigfile.c
102 lines (97 loc) · 2.13 KB
/
configfile.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* Copyright 2007, Intel Corporation
*
* This file is part of kerneloops.org
*
* This program file is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program in a file named COPYING; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authors:
* Arjan van de Ven <[email protected]>
*/
#define _GNU_SOURCE
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "kerneloops.h"
/* 0 = No
1 = Ask
2 = Yes
*/
int opted_in;
int allow_distro_to_pass_on;
char *submit_url;
char *log_file;
void read_config_file(char *filename)
{
FILE *file;
char *line = NULL;
size_t dummy;
file = fopen(filename, "r");
if (!file)
return;
while (!feof(file)) {
char *c;
line = NULL;
if (getline(&line, &dummy, file) <= 0) {
free(line);
break;
}
if (line[0] == '#') {
free(line);
continue;
}
c = strstr(line, "allow-submit ");
if (c) {
c += 13;
if (strstr(c, "yes"))
opted_in = 2;
if (strstr(c, "ask"))
opted_in = 1;
}
c = strstr(line, "allow-pass-on ");
if (c) {
c += 14;
if (strstr(c, "yes"))
allow_distro_to_pass_on = 1;
}
c = strstr(line, "submit-url ");
if (c) {
c += 11;
c = strstr(c, "http:");
if (c)
submit_url = strdup(c);
}
c = strstr(line, "log-file ");
if (c) {
c += 9;
while(*c) {
if ( !isspace(*c) && *c != '=')
break;
c++;
}
if (*c)
log_file = strdup(c);
}
free(line);
}
fclose(file);
if (!submit_url)
submit_url = strdup("http://submit.kerneloops.org/submitoops.php");
if (!log_file)
log_file = strdup("/var/log/messages");
}