mirror of
https://github.com/skeeto/endlessh.git
synced 2025-12-08 22:23:23 +00:00
Add -V switch (print version info)
This commit is contained in:
15
endlessh.c
15
endlessh.c
@@ -15,6 +15,8 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
#define ENDLESSH_VERSION 0.1
|
||||||
|
|
||||||
#define DEFAULT_PORT 2222
|
#define DEFAULT_PORT 2222
|
||||||
#define DEFAULT_DELAY 10000 /* milliseconds */
|
#define DEFAULT_DELAY 10000 /* milliseconds */
|
||||||
#define DEFAULT_MAX_LINE_LENGTH 32
|
#define DEFAULT_MAX_LINE_LENGTH 32
|
||||||
@@ -494,6 +496,13 @@ usage(FILE *f)
|
|||||||
fprintf(f, " -p INT Listening port [" XSTR(DEFAULT_PORT) "]\n");
|
fprintf(f, " -p INT Listening port [" XSTR(DEFAULT_PORT) "]\n");
|
||||||
fprintf(f, " -v Print diagnostics to standard output "
|
fprintf(f, " -v Print diagnostics to standard output "
|
||||||
"(repeatable)\n");
|
"(repeatable)\n");
|
||||||
|
fprintf(f, " -v Print version information and exit\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_version(void)
|
||||||
|
{
|
||||||
|
puts("Endlessh " XSTR(ENDLESSH_VERSION));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -536,7 +545,7 @@ main(int argc, char **argv)
|
|||||||
config_load(&config, config_file, 1);
|
config_load(&config, config_file, 1);
|
||||||
|
|
||||||
int option;
|
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) {
|
switch (option) {
|
||||||
case 'd':
|
case 'd':
|
||||||
config_set_delay(&config, optarg, 1);
|
config_set_delay(&config, optarg, 1);
|
||||||
@@ -562,6 +571,10 @@ main(int argc, char **argv)
|
|||||||
if (!loglevel++)
|
if (!loglevel++)
|
||||||
setvbuf(stdout, 0, _IOLBF, 0);
|
setvbuf(stdout, 0, _IOLBF, 0);
|
||||||
break;
|
break;
|
||||||
|
case 'V':
|
||||||
|
print_version();
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage(stderr);
|
usage(stderr);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|||||||
Reference in New Issue
Block a user