X-Git-Url: https://git.ucc.asn.au/?p=matches%2Fswarm.git;a=blobdiff_plain;f=src%2Foptions.h;h=66fb4eff004c323d0f106534877cca4909e02a68;hp=24f35eba82307b0a9b2be45b5c38e471f3b8356c;hb=HEAD;hpb=4e2127d6576cea3f54c619d0bb20a22006567206 diff --git a/src/options.h b/src/options.h index 24f35eb..66fb4ef 100644 --- a/src/options.h +++ b/src/options.h @@ -1,3 +1,11 @@ +/** + * @file options.h + * @purpose Defines struct that is basically a container for global variables + * Also contains definitions for functions that initialise the struct + * Contains a few other clobal definitions + * @author Sam Moore (matches@ucc.asn.au) + */ + #ifndef _OPTIONS_H #define _OPTIONS_H @@ -6,42 +14,49 @@ #include #include +// One off commands are written to this file and then read back through a freopen of stdin #define COMMAND_FILE ".swarm.command" -#define SHELL_EXIT_MESSAGE "\nexit 666\n" -#define SHELL_EXIT_CODE 666 // make sure this matches the above +#define SHELL_EXIT_COMMAND "exit\n" +#define SHELL_OUTPUT_FINISHED "\a\a\a" // No one ever uses bell characters... right? +#define SHELL_OUTPUT_FINISHED_LENGTH 3 // WARNING: Make sure this is consistent with the above! +/** + * @struct Options + * @purpose Container for "options" (ie: arguments) to the program, as well as other global variables + */ typedef struct { - char * program; - char * name; - char * shell; - char * master_addr; - char * logfile; - char * outfile; - int verbosity; - int port; - char * prepend; - char * append; - char * end; - int endlen; - int nCPU; - int master_pid; - bool daemon; - bool daemon_wrapper; - bool encrypt; - bool interactive; - bool handle_signals; + char * program; // program name + char * name; // name of machine the program is running on + // Is populated by gethostname(2) but may be changed on remote instances + char * shell; // The shell to start; default "bash" + char * master_addr; // Name of master swarm. If this swarm *is* the master, it is NULL. + char * logfile; // Name of file to be opened after option parsing for logging messages and errors + char * outfile; // Name of file to be opened after option parsing for stdout + int verbosity; // Level at which to print log messages (see log.h) + int port; // Port for remote instance to connect to master on; has no effect if ssh tunneling is used + char * prepend; // Command to prepend to every other command //TODO: Not fully implemented + char * append; // Command to append to every other command //TODO: Not fully implemented + int nCPU; // Number of local shells to spawn; defaults to the number of cores/CPU on the machine + bool daemon; // indicates whether this instance is a daemon or not + bool daemon_wrapper; // indicates whether this instance is a daemon wrapper + bool interactive; // indicates whether this instance is interactive + bool encrypt; // indicates whether ssh tunnels will be used when absorbing remote instances + // NOTE: This cannot be set by the user + // It will automatically be set to true when #ABSORB# is used, and false when #ABSORB UNSECURE# is used. } Options; -extern Options options; +extern Options options; // single global variable + +extern void options_setup(int argc, char ** argv, Options * o); // fill options with default values, call ParseArguments +extern void options_parse_args(int argc, char ** argv, Options * o); // parse arguments and change option values -extern void Initialise(int argc, char ** argv, Options * o); -extern void ParseArguments(int argc, char ** argv, Options * o); +extern char * strdup(); //HACK: For some reason I couldn't use stdlib's strdup and wrote my own. -extern char * strdup(); +extern void sigchld_respond(int s, char * name, int id); // I don't know why this is here, but it is #endif //_OPTIONS_H