1 /* Copyright (C) 2018 Thomas Balzer */
3 /* This file is part of tomd. */
5 /* tomd is free software: you can redistribute it and/or modify */
6 /* it under the terms of the GNU General Public License as published by */
7 /* the Free Software Foundation, either version 3 of the License, or */
8 /* (at your option) any later version. */
10 /* tomd is distributed in the hope that it will be useful, */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
13 /* GNU General Public License for more details. */
15 /* You should have received a copy of the GNU General Public License */
16 /* along with tomd. If not, see <http://www.gnu.org/licenses/>. */
21 #include <sys/socket.h>
24 #include "../../include/macros.h"
28 static void header(void)
30 tomc_p("Tom's Client, Copyright (C) 2018 Thomas Balzer");
31 tomc_p("GPL v3 or later license.");
34 static void init(void)
36 /* init socket connection */
46 struct sockaddr_un addr
;
47 addr
.sun_family
= AF_LOCAL
;
48 sprintf(addr
.sun_path
, "/run/user/1000/tomd/socket");
50 if(connect(sfd
, (struct sockaddr
*) &addr
, SUN_LEN(&addr
)) != 0){
56 #define HALLO "hallo there from dumb-client"
58 void write_hallo(void)
60 printf("writing hallo\n");
62 write(sfd
, HALLO
, sizeof HALLO
);
63 printf("wrote %d bytes.\n", wrote
);
66 static char *default_name
= "no_name";
68 char status
, stop
, kill
, start
;
72 static void extract_options(int argc
, char **argv
)
74 /* -status <name> Get status - if we thought we ran it, current real status */
75 /* -stop <name> Run provided command to gently stop */
76 /* -kill <name> Aggressive killing of process (signal 15) */
77 /* -start <name> Run name */
80 tomc_p("no args given.");
90 #define X(op) {if(strcmp("-" #op, arg) == 0){options.op = 1; continue;}}
96 /* assume last non option was the name */
100 if(options
.name
== NULL
){
101 options
.name
= default_name
;
105 static void print_options()
108 tomc_p(" name: %s", options
.name
);
109 tomc_p(" kill: %d", options
.kill
);
110 tomc_p("status: %d", options
.status
);
111 tomc_p(" stop: %d", options
.stop
);
112 tomc_p(" start: %d", options
.start
);
116 int main(int argc
, char **argv
)
119 extract_options(argc
, argv
);