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

split instance functions

parent 9a08a6b8
No related branches found
No related tags found
No related merge requests found
instance.o
instance_check.o
instance_create.o
instance_splitname.o
-ls6rc
-ls6
-loblibs
......
/*
* instance_check.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 <oblibs/log.h>
#include <oblibs/string.h>
#include <66/utils.h>
int instance_check(char const *svname)
{
log_flow() ;
int r ;
r = get_len_until(svname,'@') ;
// avoid empty value after the instance template name
if (strlen(svname+r) <= 1 && r > 0) return 0 ;
return r ;
}
/*
* instance.c
* instance_create.c
*
* Copyright (c) 2018-2021 Eric Vidal <eric@obarun.org>
*
......@@ -12,60 +12,15 @@
* except according to the terms contained in the LICENSE file./
*/
#include <66/utils.h>
#include <string.h>
#include <stddef.h>
#include <oblibs/log.h>
#include <oblibs/files.h>
#include <oblibs/string.h>
#include <oblibs/directory.h>
#include <oblibs/environ.h>
#include <oblibs/sastr.h>
#include <skalibs/stralloc.h>
#include <skalibs/djbunix.h>
#include <66/enum.h>
int instance_check(char const *svname)
{
log_flow() ;
int r ;
r = get_len_until(svname,'@') ;
// avoid empty value after the instance template name
if (strlen(svname+r) <= 1 && r > 0) return 0 ;
return r ;
}
int instance_splitname(stralloc *sa,char const *name,int len,int what)
{
log_flow() ;
char const *copy ;
size_t tlen = len + 1 ;
char template[tlen + 1] ;
memcpy(template,name,tlen) ;
template[tlen] = 0 ;
copy = name + tlen ;
sa->len = 0 ;
if (!what)
{
if (!stralloc_cats(sa,template) ||
!stralloc_0(sa)) return 0 ;
}
else
{
if (!stralloc_catb(sa,copy,strlen(copy)) ||
!stralloc_0(sa)) return 0 ;
}
return 1 ;
}
#include <66/utils.h>
int instance_create(stralloc *sasv,char const *svname, char const *regex, int len)
{
......
/*
* instance_splitname.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 <oblibs/log.h>
#include <skalibs/stralloc.h>
#include <66/utils.h>
int instance_splitname(stralloc *sa,char const *name,int len,int what)
{
log_flow() ;
char const *copy ;
size_t tlen = len + 1 ;
char template[tlen + 1] ;
memcpy(template,name,tlen) ;
template[tlen] = 0 ;
copy = name + tlen ;
sa->len = 0 ;
if (!what)
{
if (!stralloc_cats(sa,template) ||
!stralloc_0(sa)) return 0 ;
}
else
{
if (!stralloc_catb(sa,copy,strlen(copy)) ||
!stralloc_0(sa)) return 0 ;
}
return 1 ;
}
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