PageRenderTime 24ms CodeModel.GetById 2ms app.highlight 16ms RepoModel.GetById 2ms app.codeStats 0ms

/src/pdsh/opt.h

https://code.google.com/
C++ Header | 156 lines | 73 code | 29 blank | 54 comment | 0 complexity | 3312ae8b04f461323efc3283b729f16d MD5 | raw file
  1/*****************************************************************************\
  2 *  $Id$
  3 *****************************************************************************
  4 *  Copyright (C) 2001-2006 The Regents of the University of California.
  5 *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  6 *  Written by Jim Garlick <garlick@llnl.gov>.
  7 *  UCRL-CODE-2003-005.
  8 *  
  9 *  This file is part of Pdsh, a parallel remote shell program.
 10 *  For details, see <http://www.llnl.gov/linux/pdsh/>.
 11 *  
 12 *  Pdsh is free software; you can redistribute it and/or modify it under
 13 *  the terms of the GNU General Public License as published by the Free
 14 *  Software Foundation; either version 2 of the License, or (at your option)
 15 *  any later version.
 16 *  
 17 *  Pdsh is distributed in the hope that it will be useful, but WITHOUT ANY
 18 *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 19 *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 20 *  details.
 21 *  
 22 *  You should have received a copy of the GNU General Public License along
 23 *  with Pdsh; if not, write to the Free Software Foundation, Inc.,
 24 *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
 25\*****************************************************************************/
 26
 27#ifndef _OPT_INCLUDED
 28#define _OPT_INCLUDED
 29
 30#if	HAVE_CONFIG_H
 31#include "config.h"
 32#endif
 33
 34#include <sys/types.h>          /* for uid_t */
 35
 36#include "src/common/macros.h"
 37#include "src/common/list.h"
 38#include "src/common/hostlist.h"
 39
 40#define MAX_GENDATTR	64
 41
 42#define RC_MAGIC	"XXRETCODE:"
 43
 44#define RC_FAILED	254     /* -S exit value if any hosts fail to connect */
 45
 46/* set to 0x1 and 0x2 so we can do bitwise operations with DSH and PCP */
 47typedef enum { DSH = 0x1, PCP = 0x2} pers_t;
 48
 49typedef struct {
 50
 51    /* common options */
 52    char *progname;             /* argv[0] */
 53    bool debug;                 /* -d */
 54    bool info_only;             /* -q */
 55    bool test_range_expansion;  /* -Q (implies -q) */
 56    bool sdr_verify;            /* -v */
 57    bool sdr_global;            /* -G */
 58    bool altnames;              /* -i */
 59    bool sigint_terminates;     /* -b */
 60    hostlist_t wcoll;           /* target node list (-w, WCOLL, or stdin) */
 61    char *luser;                /* local username */
 62    uid_t luid;                 /* uid for above */
 63    char *ruser;                /* remote username (-l or default) */
 64    int fanout;                 /* (-f, FANOUT, or default) */
 65    int connect_timeout;
 66    int command_timeout;
 67
 68    char *rcmd_name;            /* -R name   */
 69    char *misc_modules;         /* Explicit list of misc modules to load */ 
 70    bool resolve_hosts;         /* Set optionally by rcmd modules */
 71
 72    bool kill_on_fail;          
 73
 74    /* DSH-specific options */
 75    bool separate_stderr;       /* -s */
 76    bool stdin_unavailable;     /* set if stdin used for WCOLL */
 77    char *cmd;
 78    char *dshpath;              /* optional PATH command prepended to cmd */
 79    char *getstat;              /* optional echo $? appended to cmd */
 80    bool ret_remote_rc;         /* -S: return largest remote return val */
 81    bool labels;                /* display host: before output */
 82
 83    /* PCP-specific options */
 84    bool preserve;              /* -p */
 85    bool recursive;             /* -r */
 86    List infile_names;          /* -I or pcp source spec */
 87    char *outfile_name;         /* pcp dest spec */
 88    bool pcp_server;            /* undocument pdcp server option */
 89    bool target_is_directory;   /* undocumented pdcp is target a directory */
 90    bool pcp_client;            /* undocumented pdcp client option */
 91    char *pcp_client_host;      /* hostname used to execute client */
 92    char *local_program_path;   /* absolute path to program on local node   */
 93    char *remote_program_path;  /* absolute path to program on remote nodes */
 94    bool reverse_copy;          /* rpdcp: reverse copy */
 95} opt_t;
 96
 97
 98void opt_default(opt_t *, char *argv0);
 99void opt_env(opt_t *);
100void opt_args_early(opt_t *, int, char **);
101void opt_args(opt_t *, int, char **);
102bool opt_verify(opt_t *);
103void opt_list(opt_t *);
104void opt_free(opt_t *);
105
106/* 
107 *  Return the current pdsh "personality"
108 */
109pers_t pdsh_personality(void);
110
111
112/*
113 *  Return a list of the original remote args
114 */
115const char ** pdsh_remote_argv (void);
116
117/*
118 *  Return a list of the original remote arg count
119 */
120int pdsh_remote_argc (void);
121
122/*
123 * Structure for pdsh modules to export new options. 
124 * 
125 * Module should define a table of options as:
126 *
127 *     struct pdsh_module_option pdsh_module_opts[] = { ... };
128 *
129 *   which will be read by the module loader. The module loader
130 *   (see mod.c) will call opt_register for each of the defined
131 *   options. If any option fails to register, the module will
132 *   be unloaded and a warning message printed.
133 */ 
134
135typedef int (*optFunc)(opt_t *opt, int optopt, char *optarg);
136
137struct pdsh_module_option {
138    char    opt;          /* option character                               */
139    char   *arginfo;      /* one word descr of arg if option takes one      */
140    char   *descr;        /* short description of option                    */
141    int     personality;  /* Personality for which this option is suitable. *
142                           * May be set to DSH, PCP, or DSH |PCP            */  
143
144    optFunc f;            /* callback function for option processing        */
145};
146
147#define PDSH_OPT_TABLE_END { 0, NULL, NULL, 0, NULL }
148
149
150bool opt_register(struct pdsh_module_option *popt);
151
152#endif                          /* OPT_INCLUDED */
153
154/*
155 * vi:tabstop=4 shiftwidth=4 expandtab
156 */