mdsshell.af_unix.c File Reference

UNIX socket interface to mdsshell. More...

#include <libgen.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/syslog.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
#include <assert.h>
#include <errno.h>
#include "local.h"
#include "etcp.h"
#include "usc.h"
#include "mdsshell.h"
#include <popt.h>

Go to the source code of this file.

Defines

#define BUILD   "$Id: mdsshell.af_unix.c,v 1.24 2009/09/10 18:47:36 pgm Exp $$Revision: 1.24 $ B1032"
#define PROCLOGNAME   "mdsshell"
#define DEBUG_SOCK   "/tmp/mdsshell.debug"
#define COMMAND_SOCK   "/tmp/mdsshell.command"
#define MDSSHELL_LOCAL_SKT   "MDSSHELL_LOCAL_SKT"
 Environment KEYS.
#define MDSSHELL_SCRIPT   "MDSSHELL_SCRIPT"
#define EPATH   "/usr/local/bin"
#define JOB   "/tmp/mdsshell.job"
#define MAXARGS   10
#define IS_COMMENT(s)   (s[0] == '#')
#define MAXCMD   4096
#define MAXARGSE   30
#define MAXBUF   4096

Enumerations

enum  TOP_STATE { TS_NOTHING, TS_HAVE_COMMAND, TS_HAVE_DEBUG }

Functions

static void ln_visitor (void *vobj, const char *command)
static void makelinks (void)
static void debugPrompt (void)
static enum TOP_STATE new_state (enum TOP_STATE state, struct timeval *on_timeout, struct IoBuf *iob_deb, struct IoBuf *iob_cmd)
static int doDebug (struct IoBuf *debug)
static int server_work (void)
static int read_command (FILE *fp, struct Buf *cmd, int *line_num)
static void spawnCmd (struct IoBuf *cmd)
static int batch_work (FILE *fp)
static int process_script (const char *script)
static int server (int argc, const char *argv[])
static int getUnixSocket (const char *_path)
 client .
static int client_work (char *buf)
static void processEnv (void)
static int client (int argc, const char *argv[])
int main (int argc, const char *argv[])

Variables

int debugs = 0
int commands = 0
int euid
char * debug_sock = DEBUG_SOCK
char * command_sock = COMMAND_SOCK
const char * epath = EPATH
const char * MDSPUTCH = "mdsPutCh"
char * mdsshell_rev


Detailed Description

UNIX socket interface to mdsshell.

Definition in file mdsshell.af_unix.c.


Define Documentation

#define BUILD   "$Id: mdsshell.af_unix.c,v 1.24 2009/09/10 18:47:36 pgm Exp $$Revision: 1.24 $ B1032"

Definition at line 23 of file mdsshell.af_unix.c.

#define COMMAND_SOCK   "/tmp/mdsshell.command"

Definition at line 54 of file mdsshell.af_unix.c.

Referenced by initContext(), and main().

#define DEBUG_SOCK   "/tmp/mdsshell.debug"

Definition at line 53 of file mdsshell.af_unix.c.

#define EPATH   "/usr/local/bin"

Definition at line 70 of file mdsshell.af_unix.c.

#define IS_COMMENT (  )     (s[0] == '#')

#define JOB   "/tmp/mdsshell.job"

Definition at line 74 of file mdsshell.af_unix.c.

Referenced by makelinks().

#define MAXARGS   10

#define MAXARGSE   30

Definition at line 328 of file mdsshell.af_unix.c.

Referenced by spawnCmd().

#define MAXBUF   4096

Definition at line 487 of file mdsshell.af_unix.c.

#define MAXCMD   4096

Definition at line 299 of file mdsshell.af_unix.c.

#define MDSSHELL_LOCAL_SKT   "MDSSHELL_LOCAL_SKT"

Environment KEYS.

Definition at line 58 of file mdsshell.af_unix.c.

Referenced by main().

#define MDSSHELL_SCRIPT   "MDSSHELL_SCRIPT"

Definition at line 59 of file mdsshell.af_unix.c.

Referenced by server().

#define PROCLOGNAME   "mdsshell"

Definition at line 44 of file mdsshell.af_unix.c.


Enumeration Type Documentation

enum TOP_STATE

Enumerator:
TS_NOTHING 
TS_HAVE_COMMAND 
TS_HAVE_DEBUG 

Definition at line 62 of file mdsshell.af_unix.c.


Function Documentation

static int batch_work ( FILE *  fp  )  [static]

static int client ( int  argc,
const char *  argv[] 
) [static]

Definition at line 536 of file mdsshell.af_unix.c.

References client_work(), MAXBUF, and processEnv().

Referenced by main().

static int client_work ( char *  buf  )  [static]

ideally the error should come "out of band" on the EOF line

Definition at line 489 of file mdsshell.af_unix.c.

References command_sock, getUnixSocket(), MAXBUF, and readline().

Referenced by client().

static void debugPrompt ( void   )  [static]

Definition at line 93 of file mdsshell.af_unix.c.

Referenced by doDebug(), and new_state().

static int doDebug ( struct IoBuf debug  )  [static]

Definition at line 238 of file mdsshell.af_unix.c.

References acq200_debug, IoBuf::Buf::buf, debugPrompt(), IoBuf::in, IS_COMMENT, MAXARGS, and split().

Referenced by server_work().

static int getUnixSocket ( const char *  _path  )  [static]

client .

..

Definition at line 466 of file mdsshell.af_unix.c.

Referenced by client_work().

static void ln_visitor ( void *  vobj,
const char *  command 
) [static]

Definition at line 77 of file mdsshell.af_unix.c.

References epath.

Referenced by makelinks().

int main ( int  argc,
const char *  argv[] 
)

Definition at line 566 of file mdsshell.af_unix.c.

References BUILD, client(), command_sock, MDSSHELL_LOCAL_SKT, mdsshell_rev, and server().

static void makelinks ( void   )  [static]

Definition at line 84 of file mdsshell.af_unix.c.

References JOB, ln_visitor(), and mdsshell_iterateCommands().

Referenced by server().

static enum TOP_STATE new_state ( enum TOP_STATE  state,
struct timeval *  on_timeout,
struct IoBuf iob_deb,
struct IoBuf iob_cmd 
) [static]

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

Definition at line 395 of file mdsshell.af_unix.c.

References batch_work().

Referenced by server().

static void processEnv ( void   )  [static]

Definition at line 523 of file mdsshell.af_unix.c.

References acq200_debug, command_sock, and debug_sock.

Referenced by client().

static int read_command ( FILE *  fp,
struct Buf *  cmd,
int *  line_num 
) [static]

Definition at line 301 of file mdsshell.af_unix.c.

References acq200_debug.

Referenced by batch_work().

static int server ( int  argc,
const char *  argv[] 
) [static]

static int server_work ( void   )  [static]

static void spawnCmd ( struct IoBuf cmd  )  [static]

Definition at line 332 of file mdsshell.af_unix.c.

References IoBuf::Buf::buf, IoBuf::in, IoBuf::Buf::len, MAXARGSE, IoBuf::Buf::maxlen, and split().

Referenced by batch_work().


Variable Documentation

Definition at line 68 of file mdsshell.af_unix.c.

Referenced by client_work(), initContext(), main(), new_state(), processEnv(), and server().

int commands = 0

Definition at line 65 of file mdsshell.af_unix.c.

Referenced by new_state().

char* debug_sock = DEBUG_SOCK

Definition at line 67 of file mdsshell.af_unix.c.

Referenced by new_state(), processEnv(), and server().

int debugs = 0

Definition at line 64 of file mdsshell.af_unix.c.

Referenced by new_state().

const char* epath = EPATH

Definition at line 72 of file mdsshell.af_unix.c.

Referenced by ln_visitor(), and server().

int euid

Definition at line 66 of file mdsshell.af_unix.c.

Referenced by server(), and server_work().

const char* MDSPUTCH = "mdsPutCh"

Definition at line 364 of file mdsshell.af_unix.c.

Referenced by batch_work().

char* mdsshell_rev

Definition at line 224 of file mdsshell.c.


Generated on Wed Feb 3 08:08:33 2010 for mdsshell by  doxygen 1.5.7.1