Subversion Repositories Mokou

Rev

Rev 4 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 nishi 1
/* $Id: main.c 5 2024-09-07 08:42:09Z nishi $ */
2
 
3
#include <stdio.h>
4
#include <unistd.h>
3 nishi 5
#include <stdlib.h>
4 nishi 6
#include <string.h>
7
#include <stdbool.h>
2 nishi 8
 
9
#include "mk_service.h"
3 nishi 10
#include "mk_log.h"
11
#include "mk_util.h"
12
#include "mk_version.h"
2 nishi 13
 
4 nishi 14
extern bool mk_syslog;
15
 
2 nishi 16
int main(int argc, char** argv){
4 nishi 17
	int i;
18
	for(i = 1; i < argc; i++){
19
		if(argv[i][0] == '-'){
20
			if(strcmp(argv[i], "--stderr") == 0 || strcmp(argv[i], "-S") == 0){
21
				mk_syslog = false;
22
			}else{
23
				fprintf(stderr, "%s: %s: unknown flag\n", argv[0], argv[i]);
24
				return 1;
25
			}
26
		}
27
	}
2 nishi 28
	if(getuid() != 0){
29
		fprintf(stderr, "Run me as root.\n");
30
		return 1;
31
	}
3 nishi 32
	char* log = mk_strcat3("Mokou version ", mk_get_version(), " starting up");
33
	mk_log(log);
34
	free(log);
2 nishi 35
	mk_service_scan();
5 nishi 36
	mk_start_services();
37
	mk_log("Mokou is up, creating the server socket");
2 nishi 38
}