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

Last change on this file since 11 was 9, checked in by Nishi, on Sep 13, 2024 at 8:28:43 PM

wip

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