Add version

This commit is contained in:
Nikita Ivanov 2022-07-26 00:38:46 +05:00
parent f8a4c4a534
commit 9e4011e808
No known key found for this signature in database
GPG Key ID: 6E656AC5B97B5133
3 changed files with 16 additions and 1 deletions

View File

@ -14,6 +14,7 @@
#include "config.h"
#include "server.h"
#include "preview.h"
#include "../version.h"
#include "../previews.h"
struct InputFile {
@ -366,12 +367,18 @@ static RESULT mime(int argc, char *argv[])
return OK;
}
static RESULT version(void)
{
printf("%s version %s\n", program, VERSION);
return OK;
}
int main(int argc, char *argv[])
{
program = argc > 0 ? argv[0] : "ctpv";
int c;
while ((c = getopt(argc, argv, "s:c:e:lm")) != -1) {
while ((c = getopt(argc, argv, "s:c:e:lmv")) != -1) {
switch (c) {
case 's':
ctpv.mode = MODE_SERVER;
@ -391,6 +398,9 @@ int main(int argc, char *argv[])
case 'm':
ctpv.mode = MODE_MIME;
break;
case 'v':
ctpv.mode = MODE_VERSION;
break;
default:
return EXIT_FAILURE;
}
@ -419,6 +429,9 @@ int main(int argc, char *argv[])
case MODE_MIME:
ret = mime(argc, argv);
break;
case MODE_VERSION:
ret = version();
break;
default:
PRINTINTERR("unknown mode: %d", ctpv.mode);
ret = ERR;

View File

@ -11,6 +11,7 @@ struct CTPV {
MODE_END,
MODE_LIST,
MODE_MIME,
MODE_VERSION,
} mode;
char *server_id_s;
struct {

1
version.h Normal file
View File

@ -0,0 +1 @@
#define VERSION "1.0"