Skip to content
Snippets Groups Projects
Commit 1959a45e authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

write resolve file as soon as possible with the conjunction of the new sanitize_write function

parent 8a60ce56
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,7 @@
#include <66/enum.h>
#include <66/constants.h>
#include <66/parser.h>
#include <66/parse.h>
#include <66/ssexec.h>
#include <66/config.h>
#include <66/write.h>
......@@ -63,45 +63,38 @@ void parse_service(char const *sv, ssexec_t *info, uint8_t force, uint8_t conf)
log_flow();
int r ;
unsigned int areslen = 0, residx = 0, pos = 0 ;
unsigned int areslen = 0, count = 0, pos = 0 ;
resolve_service_t ares[SS_MAX_SERVICE] ;
char main[strlen(sv) + 1] ;
if (!ob_basename(main, sv))
log_dieu(LOG_EXIT_SYS, "get basename of: ", sv) ;
r = parse_frontend(sv, ares, &areslen, info, force, conf, &residx, 0, main) ;
r = parse_frontend(sv, ares, &areslen, info, force, conf, 0, main, 0) ;
if (r == 2)
/** already parsed */
return ;
for (; pos < areslen ; pos++) {
/** parse_compute_resolve add the logger
* to the ares array */
count = areslen ;
for (; pos < count ; pos++)
parse_compute_resolve(pos, ares, &areslen, info) ;
if (force) {
for (pos = 0 ; pos < areslen ; pos++) {
resolve_service_t res = RESOLVE_SERVICE_ZERO ;
resolve_wrapper_t_ref wres = resolve_set_struct(DATA_SERVICE, &res) ;
/** warn old tree of the change and modify the desired one.
* Force was used so we are supposed to have an existing resolve file of
* the service. Before overwritting its resolve file, check if the tree is the same.*/
if (resolve_read_g(wres, info->base.s, ares[pos].sa.s + ares[pos].name) &&
strcmp(ares[pos].sa.s + ares[pos].treename, res.sa.s + res.treename))
tree_service_remove(info->base.s, res.sa.s + res.treename, res.sa.s + res.name) ;
}
parse_compute_resolve(&ares[pos], info) ;
tree_service_add(info->base.s, ares[pos].sa.s + ares[pos].treename, ares[pos].sa.s + ares[pos].name) ;
sanitize_write(&ares[pos], force) ;
char dst[strlen(ares[pos].sa.s + ares[pos].path.home) + SS_SYSTEM_LEN + SS_SERVICE_LEN + 1] ;
auto_strings(dst, ares[pos].sa.s + ares[pos].path.home, SS_SYSTEM, SS_SERVICE) ;
if (!service_resolve_write(&ares[pos]))
log_dieu(LOG_EXIT_SYS, "write resolve file of service: ", ares[pos].sa.s + ares[pos].name) ;
write_services(&ares[pos], dst, force) ;
write_services(&ares[pos], ares[pos].sa.s + ares[pos].path.servicedir) ;
ss_state_t sta = STATE_ZERO ;
if (state_check(ares[pos].sa.s + ares[pos].path.home, ares[pos].sa.s + ares[pos].name)) {
if (state_check(&ares[pos])) {
if (!state_read(&sta, ares[pos].sa.s + ares[pos].path.home, ares[pos].sa.s + ares[pos].name))
if (!state_read(&sta, &ares[pos]))
log_dieu(LOG_EXIT_SYS, "read state file of: ", ares[pos].sa.s + ares[pos].name) ;
}
......@@ -111,25 +104,10 @@ void parse_service(char const *sv, ssexec_t *info, uint8_t force, uint8_t conf)
FLAGS_SET(sta.isearlier, ares[pos].earlier ? STATE_FLAGS_TRUE : STATE_FLAGS_FALSE) ;
FLAGS_SET(sta.isdownfile, ares[pos].execute.down ? STATE_FLAGS_TRUE : STATE_FLAGS_FALSE) ;
if (!state_write(&sta, ares[pos].sa.s + ares[pos].path.home, ares[pos].sa.s + ares[pos].name))
if (!state_write(&sta, &ares[pos]))
log_dieu(LOG_EXIT_SYS, "write state file of: ", ares[pos].sa.s + ares[pos].name) ;
if (ares[pos].logger.name && ares[pos].type == TYPE_CLASSIC) {
if (state_check(info->base.s, ares[pos].sa.s + ares[pos].logger.name)) {
if (!state_read(&sta, ares[pos].sa.s + ares[pos].path.home, ares[pos].sa.s + ares[pos].logger.name))
log_dieu(LOG_EXIT_SYS, "read state file of: ", ares[pos].sa.s + ares[pos].logger.name) ;
FLAGS_SET(sta.toinit, STATE_FLAGS_TRUE) ;
FLAGS_SET(sta.isparsed, STATE_FLAGS_TRUE) ;
FLAGS_SET(sta.isearlier, ares[pos].earlier ? STATE_FLAGS_TRUE : STATE_FLAGS_FALSE) ;
FLAGS_SET(sta.isdownfile, ares[pos].execute.down ? STATE_FLAGS_TRUE : STATE_FLAGS_FALSE) ;
}
if (!state_write(&sta, ares[pos].sa.s + ares[pos].path.home, ares[pos].sa.s + ares[pos].logger.name))
log_dieu(LOG_EXIT_SYS, "write state file of: ", ares[pos].sa.s + ares[pos].logger.name) ;
}
tree_service_add(info->base.s, ares[pos].sa.s + ares[pos].treename, ares[pos].sa.s + ares[pos].name) ;
log_info("Parsed successfully: ", ares[pos].sa.s + ares[pos].name, " at tree: ", ares[pos].sa.s + ares[pos].treename) ;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment