Did some stuff
[matches/swarm.git] / src / options.h
index 24f35eb..66fb4ef 100644 (file)
@@ -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 ([email protected])
+ */
+
 #ifndef _OPTIONS_H
 #define _OPTIONS_H
 
 #include <stdbool.h>
 #include <sys/select.h>
 
+// 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

UCC git Repository :: git.ucc.asn.au