xdasd_exec.c File Reference

OpenXDAS script execution engine. More...

#include "xdasd_exec.h"
#include "xdasd_log.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

Go to the source code of this file.

Defines

#define INITIAL_BUFSZ_MULTIPLIER   2
#define XDAS_FIELD_COUNT   33
#define SHELL_ENVAR   "SHELL"
#define DEFAULT_SHELL   "/bin/sh"

Functions

static char * ex_substitute_vars (const char *script, const char **msgflds)
 Substitute values in for variable names.
static int ex_exec_script (const char *script)
 Execute an extra-process command.
int xdasd_exec (const char *script, const char **msgflds)
 Execute a shell script with variable expansion.


Detailed Description

OpenXDAS script execution engine.

Author:
John Calcote (jcalcote@novell.com)
Attention:
Please submit patches to http://openxdas.sourceforge.net

Definition in file xdasd_exec.c.


Define Documentation

#define DEFAULT_SHELL   "/bin/sh"

Referenced by ex_exec_script().

#define INITIAL_BUFSZ_MULTIPLIER   2

Definition at line 61 of file xdasd_exec.c.

Referenced by ex_substitute_vars().

#define SHELL_ENVAR   "SHELL"

Referenced by ex_exec_script().

#define XDAS_FIELD_COUNT   33


Function Documentation

static int ex_exec_script ( const char *  script  )  [static]

Execute an extra-process command.

This routine spawns an extra-process shell, feeding it a shell script via standard handle redirection. That is, the child shell process reads a script from STDIN (piped from the parent process), and then terminates with the exit code from the script.

Parameters:
[in] script - the (possibly multi-line) script to be executed.
Returns:
The shell status code obtained by executing the script, or a -1 returned by system failure of some sort if the script could not be executed.

For internal use only.

Definition at line 151 of file xdasd_exec.c.

References bytes, DEFAULT_SHELL, SHELL_ENVAR, and xdasd_log().

Referenced by xdasd_exec().

static char* ex_substitute_vars ( const char *  script,
const char **  msgflds 
) [static]

Substitute values in for variable names.

Parameters:
[in] script - the script text (possibly) containing variables.
[in] msgflds - The values to be substitued for variables in line.
Returns:
An allocated modified copy of line. Caller is responsible for releasing allocated memory.

For internal use only.

Definition at line 76 of file xdasd_exec.c.

References free, INITIAL_BUFSZ_MULTIPLIER, malloc, XDAS_FIELD_COUNT, and xdasd_log().

Referenced by xdasd_exec().


Generated on Thu Aug 20 22:33:07 2009 for OpenXDAS by  doxygen 1.5.6