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

Last change on this file since 5 was 4, checked in by Nishi, on Sep 13, 2024 at 6:39:33 PM

can trim line

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