static int sfd;
+static void header(void)
+{
+ tomc_p("Tom's Client, Copyright (C) 2018 Thomas Balzer");
+ tomc_p("GPL v3 or later license.");
+}
+
static void init(void)
{
/* init socket connection */
printf("wrote %d bytes.\n", wrote);
}
-static void header(void)
+static char *default_name = "no_name";
+static struct{
+ char status, stop, kill, start;
+ char *name;
+} options;
+
+static void extract_options(int argc, char **argv)
+{
+ /* -status <name> Get status - if we thought we ran it, current real status */
+ /* -stop <name> Run provided command to gently stop */
+ /* -kill <name> Aggressive killing of process (signal 15) */
+ /* -start <name> Run name */
+ if(argc == 1){
+ /* only tomc given */
+ tomc_p("no args given.");
+ exit(EXIT_SUCCESS);
+ }
+
+ options.name = NULL;
+
+ for(int i = 1;
+ i < argc;
+ i++){
+ char *arg = argv[i];
+#define X(op) {if(strcmp("-" #op, arg) == 0){options.op = 1; continue;}}
+ X(status);
+ X(stop);
+ X(kill);
+ X(start);
+#undef X
+ /* assume last non option was the name */
+ options.name = arg;
+ }
+
+ if(options.name == NULL){
+ options.name = default_name;
+ }
+}
+
+static void print_options()
{
- tomd_p("Tom's Client, Copyright (C) 2018 Thomas Balzer");
- tomd_p("GPL v3 or later license.");
+ tomc_p("---------");
+ tomc_p(" name: %s", options.name);
+ tomc_p(" kill: %d", options.kill);
+ tomc_p("status: %d", options.status);
+ tomc_p(" stop: %d", options.stop);
+ tomc_p(" start: %d", options.start);
+ tomc_p("---------");
}
int main(int argc, char **argv)
{
header();
+ extract_options(argc, argv);
+ print_options();
init();
- write_hallo();
+
return EXIT_SUCCESS;
}