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

bye bye old parser

parent a8a87b81
No related branches found
No related tags found
No related merge requests found
/*
* parser.c
*
* Copyright (c) 2018-2021 Eric Vidal <eric@obarun.org>
*
* All rights reserved.
*
* This file is part of Obarun. It is subject to the license terms in
* the LICENSE file found in the top-level directory of this
* distribution.
* This file may not be copied, modified, propagated, or distributed
* except according to the terms contained in the LICENSE file./
*/
#include <string.h>
#include <stdint.h>
#include <stdint.h>
//#include <stdio.h>
#include <stddef.h>
#include <oblibs/log.h>
#include <skalibs/genalloc.h>
#include <66/enum.h>
#include <66/parser.h>
sv_alltype const sv_alltype_zero = SV_ALLTYPE_ZERO ;
sv_name_t const sv_name_zero = SV_NAME_ZERO ;
keynocheck const keynocheck_zero = KEYNOCHECK_ZERO ;
int parser(sv_alltype *service,stralloc *src,char const *svname,int svtype)
{
log_flow() ;
int r ;
size_t i = 0 ;
section_t sasection = SECTION_ZERO ;
genalloc ganocheck = GENALLOC_ZERO ;
sasection.file = svname ;
r = section_get_range(&sasection,src) ;
if (r <= 0){
log_warnu("parse section of service file: ",svname) ;
goto err ;
}
if (!sasection.idx[SECTION_MAIN])
{
log_warn("missing section [main] in service file: ", svname) ;
goto err ;
}
if ((svtype != TYPE_BUNDLE && svtype != TYPE_MODULE) && !sasection.idx[SECTION_START])
{
log_warn("missing section [start] in service file: ", svname) ;
goto err ;
}
if (!key_get_range(&ganocheck,&sasection)) goto err ;
if (!genalloc_len(keynocheck,&ganocheck)){
log_warn("empty service file: ",svname) ;
goto err ;
}
for (i = 0;i < genalloc_len(keynocheck,&ganocheck);i++)
{
if (!nocheck_toservice(&(genalloc_s(keynocheck,&ganocheck)[i]),svtype,service))
{
log_warnu("keep information of service file: ",svname) ;
goto err ;
}
}
if (!check_mandatory(service,&sasection)) goto err ;
if ((service->opts[1]) && (svtype == TYPE_LONGRUN))
{
if (!add_pipe(service, &deps))
{
log_warnu("add pipe: ", keep.s+service->cname.name) ;
goto err ;
}
}
section_free(&sasection) ;
genalloc_deepfree(keynocheck,&ganocheck,keynocheck_free) ;
return 1 ;
err:
section_free(&sasection) ;
genalloc_deepfree(keynocheck,&ganocheck,keynocheck_free) ;
return 0 ;
}
This diff is collapsed.
This diff is collapsed.
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