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

Last change on this file since 4 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
RevLine 
[2]1/* $Id: main.c 4 2024-09-13 09:39:33Z nishi $ */
2
[3]3#include <stdio.h>
4#include <stdbool.h>
5#include <string.h>
6
7#include <cm_log.h>
8
[4]9#include "tw_config.h"
[3]10#include "tw_version.h"
11
12extern bool cm_do_log;
13
14int main(int argc, char** argv) {
15 int i;
[4]16 const char* config = PREFIX "/etc/tewi.conf";
[3]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 }
[4]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];
[3]33 } else {
34 fprintf(stderr, "Unknown option: %s\n", argv[i]);
35 return 1;
36 }
37 }
38 }
[4]39 if(tw_config_read(config) != 0){
40 fprintf(stderr, "Could not read the config\n");
41 return 1;
42 }
[3]43 cm_log("Daemon", "Ready");
44}
Note: See TracBrowser for help on using the repository browser.