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