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

add ssexec_copy and tree_resolve_array_search function

parent 31d9398d
No related branches found
No related tags found
No related merge requests found
......@@ -98,6 +98,7 @@ typedef int ssexec_func_t(int argc, char const *const *argv, ssexec_t *info) ;
typedef ssexec_func_t *ssexec_func_t_ref ;
extern void ssexec_free(ssexec_t *info) ;
extern void ssexec_copy(ssexec_t *dest, ssexec_t *src) ;
extern ssexec_t const ssexec_zero ;
extern void set_ssinfo(ssexec_t *info) ;
......@@ -180,7 +181,7 @@ extern char const *usage_66 ;
#define OPTS_START_LEN (sizeof OPTS_START - 1)
#define OPTS_STOP "uP"
#define OPTS_STOP_LEN (sizeof OPTS_STOP - 1)
#define OPTS_SVCTL "abqhkti12pcyroduxOw:P"
#define OPTS_SVCTL "abqHkti12pcyroduxOw:P"
#define OPTS_SVCTL_LEN (sizeof OPTS_SVCTL - 1)
#define OPTS_ENV "c:s:VLr:e:i:"
#define OPTS_ENV_LEN (sizeof OPTS_ENV - 1)
......
......@@ -183,7 +183,7 @@ extern int tree_resolve_write_cdb(cdbmaker *c, resolve_tree_t *tres) ;
extern int tree_resolve_copy(resolve_tree_t *dst, resolve_tree_t *tres) ;
extern int tree_resolve_modify_field(resolve_tree_t *tres, uint8_t field, char const *data) ;
extern int tree_resolve_get_field_tosa(stralloc *sa, resolve_tree_t *tres, resolve_tree_enum_t field) ;
extern int tree_resolve_array_search(resolve_tree_t *ares, unsigned int areslen, char const *name) ;
/** Master */
extern int tree_resolve_master_read_cdb(cdb *c, resolve_tree_master_t *mres) ;
extern int tree_resolve_master_write_cdb(cdbmaker *c, resolve_tree_master_t *mres) ;
......
ssexec_all.o
ssexec_boot.o
ssexec_copy.o
ssexec_disable.o
ssexec_enable.o
ssexec_env.o
......
/*
* ssexec_copy.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 <oblibs/string.h>
#include <oblibs/log.h>
#include <skalibs/stralloc.h>
#include <66/ssexec.h>
void ssexec_copy(ssexec_t *dest, ssexec_t *src)
{
log_flow() ;
stralloc_copy(&dest->base, &src->base) ;
stralloc_copy(&dest->live, &src->live) ;
stralloc_copy(&dest->tree, &src->tree) ;
stralloc_copy(&dest->scandir, &src->scandir) ;
stralloc_copy(&dest->treename, &src->treename) ;
dest->treeallow = src->treeallow ;
dest->owner = src->owner ;
auto_strings(dest->ownerstr, src->ownerstr) ;
dest->ownerlen = src->ownerlen ;
dest->timeout = src->timeout ;
dest->prog = src->prog ;
dest->help = src->help ;
dest->usage = src->usage ;
dest->opt_verbo = src->opt_verbo ;
dest->opt_live = src->opt_live ;
dest->opt_tree = src->opt_tree ;
dest->opt_timeout = src->opt_timeout ;
dest->opt_color = src->opt_color ;
dest->skip_opt_tree = src->skip_opt_tree ;
}
......@@ -5,6 +5,7 @@ tree_isenabled.o
tree_isinitialized.o
tree_isvalid.o
tree_ongroups.o
tree_resolve_array_search.o
tree_resolve_copy.o
tree_resolve_get_field_tosa.o
tree_resolve_master_copy.o
......
/*
* tree_resolve_array_search.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 <66/tree.h>
int tree_resolve_array_search(resolve_tree_t *ares, unsigned int areslen, char const *name)
{
unsigned int pos = 0 ;
for (; pos < areslen ; pos++) {
char const *n = ares[pos].sa.s + ares[pos].name ;
if (!strcmp(name, n))
return pos ;
}
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