aboutsummaryrefslogtreecommitdiff
path: root/client.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-11-01 20:10:47 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-11-01 20:10:47 +0000
commit438d6eaff0b4280492c8a0a161a33daec5de3707 (patch)
tree5dd2bb0988475cdf2ea535266a992a93aba738c7 /client.c
parentterm_init(): initialize slave TERM from term_init() argument (diff)
client/server: add -t,--term to footclient
Diffstat (limited to 'client.c')
-rw-r--r--client.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/client.c b/client.c
index 25dcbd27..bac72838 100644
--- a/client.c
+++ b/client.c
@@ -30,7 +30,8 @@ print_usage(const char *prog_name)
printf("Usage: %s [OPTIONS]...\n", prog_name);
printf("\n");
printf("Options:\n");
- printf(" -v,--version show the version number and quit\n");
+ printf(" -t,--term=TERM value to set the environment variable TERM to (foot)\n"
+ " -v,--version show the version number and quit\n");
}
int
@@ -41,17 +42,24 @@ main(int argc, char *const *argv)
const char *const prog_name = argv[0];
static const struct option longopts[] = {
+ {"term", required_argument, 0, 't'},
{"version", no_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{NULL, no_argument, 0, 0},
};
+ const char *term = "";
+
while (true) {
- int c = getopt_long(argc, argv, ":hv", longopts, NULL);
+ int c = getopt_long(argc, argv, ":t:hv", longopts, NULL);
if (c == -1)
break;
switch (c) {
+ case 't':
+ term = optarg;
+ break;
+
case 'v':
printf("footclient version %s\n", FOOT_VERSION);
return EXIT_SUCCESS;
@@ -98,6 +106,14 @@ main(int argc, char *const *argv)
}
}
+ uint16_t term_len = strlen(term);
+ if (send(fd, &term_len, sizeof(term_len), 0) != sizeof(term_len) ||
+ send(fd, term, term_len, 0) != term_len)
+ {
+ LOG_ERRNO("failed to send TERM to server");
+ goto err;
+ }
+
if (send(fd, &argc, sizeof(argc), 0) != sizeof(argc)) {
LOG_ERRNO("failed to send argc/argv to server");
goto err;