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

add rc_xxx function

parent e8f5b306
No related branches found
No related tags found
No related merge requests found
/*
* rc.h
*
* Copyright (c) 2018 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./
*/
#ifndef RC_H
#define RC_H
#include <66/ssexec.h>
#include <skalibs/genalloc.h>
extern int rc_init(ssexec_t *info, char const *const *envp) ;
extern int rc_send(ssexec_t *info,genalloc *ga,char const *sig,char const *const *envp) ;
#endif
/*
* rc_send.c
*
* Copyright (c) 2018 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 <66/rc.h>
#include <string.h>
#include <stdlib.h>
#include <oblibs/error2.h>
#include <skalibs/genalloc.h>
#include <66/resolve.h>
#include <66/ssexec.h>
#include <66/utils.h>
#include <s6/s6-supervise.h>
int rc_init(ssexec_t *info, char const *const *envp)
{
int r ;
int nargc = 4 ;
char const *newargv[nargc] ;
unsigned int m = 0 ;
newargv[m++] = "fake_name" ;
newargv[m++] = "-d" ;
newargv[m++] = info->treename.s ;
newargv[m++] = 0 ;
if (ssexec_init(nargc,newargv,envp,info))
return 0 ;
VERBO3 strerr_warnt2x("reload scandir: ",info->scandir.s) ;
r = s6_svc_writectl(info->scandir.s, S6_SVSCAN_CTLDIR, "an", 2) ;
if (r < 0) return 0 ;
return 1 ;
}
/*
* rc_send.c
*
* Copyright (c) 2018 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 <66/rc.h>
#include <string.h>
#include <stdlib.h>
#include <skalibs/genalloc.h>
#include <66/resolve.h>
#include <66/ssexec.h>
int rc_send(ssexec_t *info,genalloc *ga,char const *sig,char const *const *envp)
{
unsigned int i = 0 ;
int nargc = 3 + genalloc_len(ss_resolve_t,ga) ;
char const *newargv[nargc] ;
unsigned int m = 0 ;
newargv[m++] = "fake_name" ;
newargv[m++] = sig ;
for (; i < genalloc_len(ss_resolve_t,ga) ; i++)
newargv[m++] = genalloc_s(ss_resolve_t,ga)[i].sa.s + genalloc_s(ss_resolve_t,ga)[i].name ;
newargv[m++] = 0 ;
if (ssexec_dbctl(nargc,newargv,envp,info))
return 0 ;
return 1 ;
}
/*
* svc_send.c
*
* Copyright (c) 2018 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 <66/svc.h>
#include <string.h>
#include <stdlib.h>
#include <skalibs/genalloc.h>
#include <66/resolve.h>
#include <66/ssexec.h>
int svc_send(ssexec_t *info,genalloc *ga,char const *sig,char const *const *envp)
{
unsigned int i = 0 ;
int nargc = 3 + genalloc_len(ss_resolve_t,ga) ;
char const *newargv[nargc] ;
unsigned int m = 0 ;
newargv[m++] = "fake_name" ;
newargv[m++] = sig ;
for (; i < genalloc_len(ss_resolve_t,ga) ; i++)
newargv[m++] = genalloc_s(ss_resolve_t,ga)[i].sa.s + genalloc_s(ss_resolve_t,ga)[i].name ;
newargv[m++] = 0 ;
if (ssexec_svctl(nargc,newargv,envp,info))
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