/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. #ifndef _OPT_INCLUDED
  27. #define _OPT_INCLUDED
  28. #if HAVE_CONFIG_H
  29. #include "config.h"
  30. #endif
  31. #include <sys/types.h> /* for uid_t */
  32. #include "src/common/macros.h"
  33. #include "src/common/list.h"
  34. #include "src/common/hostlist.h"
  35. #define MAX_GENDATTR 64
  36. #define RC_MAGIC "XXRETCODE:"
  37. #define RC_FAILED 254 /* -S exit value if any hosts fail to connect */
  38. /* set to 0x1 and 0x2 so we can do bitwise operations with DSH and PCP */
  39. typedef enum { DSH = 0x1, PCP = 0x2} pers_t;
  40. typedef struct {
  41. /* common options */
  42. char *progname; /* argv[0] */
  43. bool debug; /* -d */
  44. bool info_only; /* -q */
  45. bool test_range_expansion; /* -Q (implies -q) */
  46. bool sdr_verify; /* -v */
  47. bool sdr_global; /* -G */
  48. bool altnames; /* -i */
  49. bool sigint_terminates; /* -b */
  50. hostlist_t wcoll; /* target node list (-w, WCOLL, or stdin) */
  51. char *luser; /* local username */
  52. uid_t luid; /* uid for above */
  53. char *ruser; /* remote username (-l or default) */
  54. int fanout; /* (-f, FANOUT, or default) */
  55. int connect_timeout;
  56. int command_timeout;
  57. char *rcmd_name; /* -R name */
  58. char *misc_modules; /* Explicit list of misc modules to load */
  59. bool resolve_hosts; /* Set optionally by rcmd modules */
  60. bool kill_on_fail;
  61. /* DSH-specific options */
  62. bool separate_stderr; /* -s */
  63. bool stdin_unavailable; /* set if stdin used for WCOLL */
  64. char *cmd;
  65. char *dshpath; /* optional PATH command prepended to cmd */
  66. char *getstat; /* optional echo $? appended to cmd */
  67. bool ret_remote_rc; /* -S: return largest remote return val */
  68. bool labels; /* display host: before output */
  69. /* PCP-specific options */
  70. bool preserve; /* -p */
  71. bool recursive; /* -r */
  72. List infile_names; /* -I or pcp source spec */
  73. char *outfile_name; /* pcp dest spec */
  74. bool pcp_server; /* undocument pdcp server option */
  75. bool target_is_directory; /* undocumented pdcp is target a directory */
  76. bool pcp_client; /* undocumented pdcp client option */
  77. char *pcp_client_host; /* hostname used to execute client */
  78. char *local_program_path; /* absolute path to program on local node */
  79. char *remote_program_path; /* absolute path to program on remote nodes */
  80. bool reverse_copy; /* rpdcp: reverse copy */
  81. } opt_t;
  82. void opt_default(opt_t *, char *argv0);
  83. void opt_env(opt_t *);
  84. void opt_args_early(opt_t *, int, char **);
  85. void opt_args(opt_t *, int, char **);
  86. bool opt_verify(opt_t *);
  87. void opt_list(opt_t *);
  88. void opt_free(opt_t *);
  89. /*
  90. * Return the current pdsh "personality"
  91. */
  92. pers_t pdsh_personality(void);
  93. /*
  94. * Return a list of the original remote args
  95. */
  96. const char ** pdsh_remote_argv (void);
  97. /*
  98. * Return a list of the original remote arg count
  99. */
  100. int pdsh_remote_argc (void);
  101. /*
  102. * Structure for pdsh modules to export new options.
  103. *
  104. * Module should define a table of options as:
  105. *
  106. * struct pdsh_module_option pdsh_module_opts[] = { ... };
  107. *
  108. * which will be read by the module loader. The module loader
  109. * (see mod.c) will call opt_register for each of the defined
  110. * options. If any option fails to register, the module will
  111. * be unloaded and a warning message printed.
  112. */
  113. typedef int (*optFunc)(opt_t *opt, int optopt, char *optarg);
  114. struct pdsh_module_option {
  115. char opt; /* option character */
  116. char *arginfo; /* one word descr of arg if option takes one */
  117. char *descr; /* short description of option */
  118. int personality; /* Personality for which this option is suitable. *
  119. * May be set to DSH, PCP, or DSH |PCP */
  120. optFunc f; /* callback function for option processing */
  121. };
  122. #define PDSH_OPT_TABLE_END { 0, NULL, NULL, 0, NULL }
  123. bool opt_register(struct pdsh_module_option *popt);
  124. #endif /* OPT_INCLUDED */
  125. /*
  126. * vi:tabstop=4 shiftwidth=4 expandtab
  127. */