Line | |
---|
1 | /* $Id: main.c 6 2024-09-13 10:28:20Z nishi $ */
|
---|
2 |
|
---|
3 | #include <stdio.h>
|
---|
4 | #include <stdbool.h>
|
---|
5 | #include <string.h>
|
---|
6 |
|
---|
7 | #include <openssl/opensslv.h>
|
---|
8 |
|
---|
9 | #include <cm_log.h>
|
---|
10 |
|
---|
11 | #include "tw_config.h"
|
---|
12 | #include "tw_version.h"
|
---|
13 |
|
---|
14 | extern bool cm_do_log;
|
---|
15 |
|
---|
16 | int main(int argc, char** argv) {
|
---|
17 | int i;
|
---|
18 | const char* config = PREFIX "/etc/tewi.conf";
|
---|
19 | for(i = 1; i < argc; i++) {
|
---|
20 | if(argv[i][0] == '-') {
|
---|
21 | if(strcmp(argv[i], "--verbose") == 0 || strcmp(argv[i], "-v") == 0) {
|
---|
22 | if(!cm_do_log) {
|
---|
23 | cm_do_log = true;
|
---|
24 | cm_log("", "This is Tewi HTTPd, version %s, using %s", tw_get_version(), OPENSSL_VERSION_TEXT);
|
---|
25 | } else {
|
---|
26 | cm_do_log = true;
|
---|
27 | }
|
---|
28 | } else if(strcmp(argv[i], "--config") == 0 || strcmp(argv[i], "-C") == 0) {
|
---|
29 | i++;
|
---|
30 | if(argv[i] == NULL) {
|
---|
31 | fprintf(stderr, "Missing argument\n");
|
---|
32 | return 1;
|
---|
33 | }
|
---|
34 | config = argv[i];
|
---|
35 | } else {
|
---|
36 | fprintf(stderr, "Unknown option: %s\n", argv[i]);
|
---|
37 | return 1;
|
---|
38 | }
|
---|
39 | }
|
---|
40 | }
|
---|
41 | tw_config_init();
|
---|
42 | if(tw_config_read(config) != 0) {
|
---|
43 | fprintf(stderr, "Could not read the config\n");
|
---|
44 | return 1;
|
---|
45 | }
|
---|
46 | cm_log("Daemon", "Ready");
|
---|
47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.