Subversion Repositories Mokou

Rev

Rev 3 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 nishi 1
/* $Id: service.c 2 2024-09-05 18:31:51Z nishi $ */
2
 
3
#include "mk_service.h"
4
 
5
#include <dirent.h>
6
#include <stdlib.h>
7
 
8
#include "mk_log.h"
9
#include "mk_util.h"
10
 
11
struct mk_service** services = NULL;
12
 
13
void mk_service_scan(void){
14
	if(services != NULL){
15
		int i;
16
		for(i = 0; services[i] != NULL; i++){
17
			free(services[i]->name);
18
			free(services[i]->exec);
19
			free(services[i]->pidfile);
20
			free(services[i]);
21
		}
22
		free(services);
23
	}
24
 
25
	mk_log("Scanning the service directory.");
26
 
27
	DIR* dir = opendir(PREFIX "/etc/mokou");
28
	if(dir != NULL){
29
		struct dirent* d;
30
		while((d = readdir(dir)) != NULL){
31
			if(mk_endswith(d->d_name, ".conf")){
32
				char* path = mk_strcat(PREFIX "/etc/mokou/", d->d_name);
33
				char* str = mk_strcat("Reading ", path);
34
				mk_log(str);
35
				free(str);
36
				free(path);
37
			}
38
		}
39
		closedir(dir);
40
	}else{
41
		mk_log("Cannot open the directory.");
42
	}
43
}