Subversion Repositories Mokou

Rev

Rev 3 | Rev 5 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3 Rev 4
Line 1... Line 1...
1
/* $Id: service.c 3 2024-09-06 09:21:55Z nishi $ */
1
/* $Id: service.c 4 2024-09-06 09:55:53Z nishi $ */
2
 
2
 
3
#include "mk_service.h"
3
#include "mk_service.h"
4
 
4
 
5
#include <stdio.h>
5
#include <stdio.h>
6
#include <dirent.h>
6
#include <dirent.h>
Line 15... Line 15...
15
 
15
 
16
void mk_service_scan(void){
16
void mk_service_scan(void){
17
	if(services != NULL){
17
	if(services != NULL){
18
		int i;
18
		int i;
19
		for(i = 0; services[i] != NULL; i++){
19
		for(i = 0; services[i] != NULL; i++){
20
			free(services[i]->name);
20
			if(services[i]->description != NULL) free(services[i]->description);
21
			free(services[i]->exec);
21
			if(services[i]->exec != NULL) free(services[i]->exec);
22
			free(services[i]->pidfile);
22
			if(services[i]->pidfile != NULL) free(services[i]->pidfile);
23
			free(services[i]);
23
			free(services[i]);
24
		}
24
		}
25
		free(services);
25
		free(services);
26
		mk_log("Cleaning up the list");
26
		mk_log("Cleaning up the list");
27
	}
27
	}
Line 108... Line 108...
108
 
108
 
109
					if(!bad){
109
					if(!bad){
110
						char* log = mk_strcat3("Adding ", desc == NULL ? path : desc, " to the list");
110
						char* log = mk_strcat3("Adding ", desc == NULL ? path : desc, " to the list");
111
						mk_log(log);
111
						mk_log(log);
112
						free(log);
112
						free(log);
-
 
113
 
-
 
114
						struct mk_service* serv = malloc(sizeof(*serv));
-
 
115
						serv->description = desc != NULL ? mk_strdup(desc) : NULL;
-
 
116
						serv->exec = mk_strdup(exec);
-
 
117
						serv->pidfile = mk_strdup(pidfile);
113
					}
118
					}
114
 
119
 
115
					if(desc != NULL) free(desc);
120
					if(desc != NULL) free(desc);
116
					if(exec != NULL) free(exec);
121
					if(exec != NULL) free(exec);
117
					if(pidfile != NULL) free(pidfile);
122
					if(pidfile != NULL) free(pidfile);