source: Main/trunk/Server/main.c@ 8

Last change on this file since 8 was 8, checked in by Nishi, on Sep 13, 2024 at 8:18:23 PM

can listen now

  • Property svn:keywords set to Id
File size: 1.1 KB
Line 
1/* $Id: main.c 8 2024-09-13 11:18:23Z 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_server.h"
13#include "tw_version.h"
14
15extern bool cm_do_log;
16
17int main(int argc, char** argv) {
18 int i;
19 const char* config = PREFIX "/etc/tewi.conf";
20 for(i = 1; i < argc; i++) {
21 if(argv[i][0] == '-') {
22 if(strcmp(argv[i], "--verbose") == 0 || strcmp(argv[i], "-v") == 0) {
23 if(!cm_do_log) {
24 cm_do_log = true;
25 cm_log("", "This is Tewi HTTPd, version %s, using %s", tw_get_version(), OPENSSL_VERSION_TEXT);
26 } else {
27 cm_do_log = true;
28 }
29 } else if(strcmp(argv[i], "--config") == 0 || strcmp(argv[i], "-C") == 0) {
30 i++;
31 if(argv[i] == NULL) {
32 fprintf(stderr, "Missing argument\n");
33 return 1;
34 }
35 config = argv[i];
36 } else {
37 fprintf(stderr, "Unknown option: %s\n", argv[i]);
38 return 1;
39 }
40 }
41 }
42 tw_config_init();
43 if(tw_config_read(config) != 0) {
44 fprintf(stderr, "Could not read the config\n");
45 return 1;
46 }
47 if(tw_server_init() != 0) {
48 fprintf(stderr, "Could not initialize the server\n");
49 return 1;
50 }
51 cm_log("Daemon", "Ready");
52}
Note: See TracBrowser for help on using the repository browser.