Skip to content

Commit

Permalink
Add -V switch (print version info)
Browse files Browse the repository at this point in the history
  • Loading branch information
skeeto committed Mar 24, 2019
1 parent 4ffc65b commit 7fd1530
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion endlessh.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <arpa/inet.h>
#include <netinet/in.h>

#define ENDLESSH_VERSION 0.1

#define DEFAULT_PORT 2222
#define DEFAULT_DELAY 10000 /* milliseconds */
#define DEFAULT_MAX_LINE_LENGTH 32
Expand Down Expand Up @@ -494,6 +496,13 @@ usage(FILE *f)
fprintf(f, " -p INT Listening port [" XSTR(DEFAULT_PORT) "]\n");
fprintf(f, " -v Print diagnostics to standard output "
"(repeatable)\n");
fprintf(f, " -v Print version information and exit\n");
}

static void
print_version(void)
{
puts("Endlessh " XSTR(ENDLESSH_VERSION));
}

static int
Expand Down Expand Up @@ -536,7 +545,7 @@ main(int argc, char **argv)
config_load(&config, config_file, 1);

int option;
while ((option = getopt(argc, argv, "d:f:hl:m:p:v")) != -1) {
while ((option = getopt(argc, argv, "d:f:hl:m:p:vV")) != -1) {
switch (option) {
case 'd':
config_set_delay(&config, optarg, 1);
Expand All @@ -562,6 +571,10 @@ main(int argc, char **argv)
if (!loglevel++)
setvbuf(stdout, 0, _IOLBF, 0);
break;
case 'V':
print_version();
exit(EXIT_SUCCESS);
break;
default:
usage(stderr);
exit(EXIT_FAILURE);
Expand Down

0 comments on commit 7fd1530

Please sign in to comment.