The Assimilation Project  based on Assimilation version 1.1.7.1474836767
misc.h File Reference

Defines miscellaneous interfaces. More...

#include <projectcommon.h>
#include <configcontext.h>
#include <syslog.h>
#include <stdio.h>
Include dependency graph for misc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define STD_PID_DIR   "/var/run"
 

Enumerations

enum  PidRunningStat { PID_NOTRUNNING, PID_DEAD, PID_NOTUS, PID_RUNNING }
 Status of pid file and/or running processes referred to by it - analogous to "service status". More...
 

Functions

char * proj_get_sysname (void)
 Return a malloced string of the system name. More...
 
WINEXPORT char * get_default_pid_fileName (const char *procname)
 Make a daemon process out of this process. More...
 
WINEXPORT void daemonize_me (gboolean stay_in_foreground, const char *dirtorunin, char *pidfile, int minclosefd)
 minimum file descriptor to close - or zero More...
 
WINEXPORT void assimilation_openlog (const char *logname)
 Open logs in our style (syslog) More...
 
WINEXPORT PidRunningStat are_we_already_running (const char *pidfile, int *pid)
 Determine service status. More...
 
WINEXPORT guint pidrunningstat_to_status (PidRunningStat)
 Convert PidRunningStat to an exit code for status. More...
 
gboolean create_pid_file (const char *pidfile)
 Create pid file - return TRUE on success. More...
 
WINEXPORT void remove_pid_file (const char *pidfile)
 Remove pid file we created (if we created one) More...
 
WINEXPORT int kill_pid_service (const char *pidfile, int signal)
 Issue given signal to the pidfile-indicated running process. More...
 
WINEXPORT void rmpid_and_exit_on_signal (const char *pidfile, int signal)
 Issue given signal to the pidfile-indicated running process. More...
 
WINEXPORT gchar ** assim_merge_environ (const gchar *const *env, ConfigContext *)
 Create new env merged from ConfigContext. More...
 
WINEXPORT void assim_free_environ (gchar **env)
 Free environment created by assim_merge_environ. More...
 
WINEXPORT gsize setpipebuf (int fd, gsize bufsize)
 Set pipe buffer size (if possible) More...
 
WINEXPORT gsize getpipebuf (int fd)
 Return pipe buffer size. More...
 
WINEXPORT void assim_g_notify_unref (gpointer assimobj)
 Unref for glib notify. More...
 
WINEXPORT guint assim_set_io_watch (int fd, GIOCondition condition, GIOFunc func, gpointer user_data)
 Simiplified interface to g_io_add_watch for our Python code. More...
 

Variables

const char * assim_syslogid
 

Detailed Description

Defines miscellaneous interfaces.

Defines a variety of miscellaneous non-class interfaces.

This file is part of the Assimilation Project.

Author
Copyright © 2012 - Alan Robertson alanr.nosp@m.@uni.nosp@m.x.sh
The Assimilation software is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The Assimilation software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the Assimilation Project software. If not, see http://www.gnu.org/licenses/

Definition in file misc.h.

Macro Definition Documentation

#define STD_PID_DIR   "/var/run"

Definition at line 32 of file misc.h.

Referenced by get_default_pid_fileName().

Enumeration Type Documentation

Status of pid file and/or running processes referred to by it - analogous to "service status".

Enumerator
PID_NOTRUNNING 
PID_DEAD 
PID_NOTUS 
PID_RUNNING 

Definition at line 37 of file misc.h.

Function Documentation

WINEXPORT PidRunningStat are_we_already_running ( const char *  pidfile,
int *  pidarg 
)

Determine service status.

Determine service status.

Parameters
pidfileThe pathname of our expected pid file
pidargPid of the process (if running)

Definition at line 331 of file misc.c.

References MAXPATH, PID_DEAD, PID_NOTRUNNING, PID_NOTUS, PID_RUNNING, PROCOTHEREXE, PROCSELFEXE, and SEP.

Referenced by create_pid_file(), daemonize_me(), kill_pid_service(), cma.cma::main(), and main().

Here is the caller graph for this function:

WINEXPORT void assim_free_environ ( gchar **  env)

Free environment created by assim_merge_environ.

Free environment created by assim_merge_environ.

Parameters
envThe result of assim_merge_environ – to be freed

Definition at line 709 of file misc.c.

References WINEXPORT.

Referenced by childprocess_new().

Here is the caller graph for this function:

WINEXPORT void assim_g_notify_unref ( gpointer  assimobj)

Unref for glib notify.

Definition at line 753 of file misc.c.

References CASTTOCLASS, cma.assimglib::GIOFunc, and _AssimObj::unref.

Referenced by _cryptframe_initialize_maps(), _netio_recvframesets(), and _pktdata_to_framesetlist().

Here is the caller graph for this function:

WINEXPORT gchar** assim_merge_environ ( const gchar *const *  env,
ConfigContext update 
)

Create new env merged from ConfigContext.

Create new env merged from ConfigContext.

Parameters
envInitial environment – or NULL
updateUpdates to merge into this environment

Definition at line 576 of file misc.c.

References _shell_array_value(), _NetAddr::baseclass, CFG_ARRAY, CFG_BOOL, CFG_EEXIST, CFG_INT64, CFG_NETADDR, CFG_STRING, FMT_64BIT, FSTATIC, g_get_environ(), _ConfigContext::getaddr, _ConfigContext::getarray, _ConfigContext::getbool, _ConfigContext::getint, _ConfigContext::getstring, _ConfigContext::gettype, _ConfigContext::keycount, _ConfigContext::keys, and _AssimObj::toString.

Referenced by childprocess_new().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT guint assim_set_io_watch ( int  fd,
GIOCondition  condition,
GIOFunc  func,
gpointer  user_data 
)

Simiplified interface to g_io_add_watch for our Python code.

Definition at line 765 of file misc.c.

References __FUNCTION__, _assim_proxy_io_watch(), and FSTATIC.

Here is the call graph for this function:

WINEXPORT void assimilation_openlog ( const char *  logname)

Open logs in our style (syslog)

Definition at line 225 of file misc.c.

References assim_syslogid, and assimilation_logger().

Referenced by assimilation_logger(), cma.cma::main(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean create_pid_file ( const char *  pidfile)

Create pid file - return TRUE on success.

Create pid file - return TRUE on success.

Definition at line 434 of file misc.c.

References __FUNCTION__, are_we_already_running(), g_unlink, GETPID, PID_DEAD, PID_NOTUS, and PID_RUNNING.

Referenced by daemonize_me().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT void daemonize_me ( gboolean  stay_in_foreground,
const char *  dirtorunin,
char *  origpidfile,
int  minclosefd 
)

minimum file descriptor to close - or zero

minimum file descriptor to close - or zero

Make us into a proper daemon.

Parameters
[in]stay_in_foregroundTRUE to not make a background job
[in]dirtoruninDirectory to cd to or NULL for default (/)
[in]origpidfilePathname of pidfile or NULL for no pidfile
[in]minclosefdMinimum file descriptor to close or 0

Definition at line 106 of file misc.c.

References __FUNCTION__, are_we_already_running(), create_pid_file(), daemonize_me(), DIMOF, FREE, and PID_RUNNING.

Referenced by daemonize_me(), cma.cma::main(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT char* get_default_pid_fileName ( const char *  procname)

Make a daemon process out of this process.

Make a daemon process out of this process.

Definition at line 481 of file misc.c.

References STD_PID_DIR.

Referenced by main().

Here is the caller graph for this function:

WINEXPORT gsize getpipebuf ( int  fd)

Return pipe buffer size.

Return pipe buffer size.

Definition at line 743 of file misc.c.

References WINEXPORT.

Referenced by setpipebuf().

Here is the caller graph for this function:

WINEXPORT int kill_pid_service ( const char *  pidfile,
int  signal 
)

Issue given signal to the pidfile-indicated running process.

Issue given signal to the pidfile-indicated running process.

Definition at line 503 of file misc.c.

References are_we_already_running(), g_unlink, and PID_RUNNING.

Referenced by cma.cma::main(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT guint pidrunningstat_to_status ( PidRunningStat  )

Convert PidRunningStat to an exit code for status.

Definition at line 553 of file misc.c.

References PID_DEAD, PID_NOTRUNNING, PID_NOTUS, PID_RUNNING, and WINEXPORT.

Referenced by cma.cma::main(), and main().

Here is the caller graph for this function:

char* proj_get_sysname ( void  )

Return a malloced string of the system name.

Referenced by arpdiscovery_new(), construct_pcap_frameset(), cryptcurve25519_gen_persistent_keypair(), nano_initiate_shutdown(), nano_reqconfig(), and nanoprobe_initialize_keys().

Here is the caller graph for this function:

WINEXPORT void remove_pid_file ( const char *  pidfile)

Remove pid file we created (if we created one)

Remove pid file we created (if we created one)

Definition at line 494 of file misc.c.

References g_unlink.

Referenced by cma.cma::main(), and main().

Here is the caller graph for this function:

WINEXPORT void rmpid_and_exit_on_signal ( const char *  pidfile,
int  signal_in 
)

Issue given signal to the pidfile-indicated running process.

Issue given signal to the pidfile-indicated running process.

Definition at line 526 of file misc.c.

References catch_pid_signal(), FSTATIC, and signal.

Referenced by cma.cma::main().

Here is the call graph for this function:

Here is the caller graph for this function:

WINEXPORT gsize setpipebuf ( int  fd,
gsize  bufsize 
)

Set pipe buffer size (if possible)

Set pipe buffer size (if possible)

Definition at line 717 of file misc.c.

References getpipebuf(), and WINEXPORT.

Here is the call graph for this function:

Variable Documentation

const char* assim_syslogid

Definition at line 53 of file misc.c.

Referenced by assimilation_logger(), and assimilation_openlog().