Debian Codegraph @

src/url.c

raw symbols SCIP
1 /*
2 * AIDE (Advanced Intrusion Detection Environment)
3 *
4 * Copyright (C) 2020 Hannes von Haugwitz
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #include "url.h"
22
23 #include <string.h>
24
25 struct url_type {
26 URL_TYPE type;
27 const char *string;
28 };
29
30 static struct url_type url_type_array[] = {
31 { url_file, "file" },
32 { url_stdout, "stdout" },
33 { url_stdin, "stdin" },
34 { url_stderr, "stderr" },
35 { url_fd, "fd" },
36 { url_ftp, "ftp" },
37 { url_http, "http" },
38 { url_https, "https" },
39 { url_syslog, "syslog" },
40 };
41
42 int num_url_types = sizeof(url_type_array)/sizeof(struct url_type);
43
44 URL_TYPE get_url_type(char * str) {
45
46 for (int i = 0; i < num_url_types; ++i) {
47 if (strcmp(str, url_type_array[i].string) == 0) {
48 return url_type_array[i].type;
49 }
50 }
51 return 0;
52 }
53
54 const char* get_url_type_string(URL_TYPE type) {
55 return url_type_array[type-1].string;
56 }