added version flag support

This commit is contained in:
cylgom 2018-10-05 17:42:20 +02:00
parent b0ce2ed635
commit 4dee666dcf
2 changed files with 29 additions and 1 deletions

View File

@ -3,6 +3,7 @@ CC=gcc
#CC=gcc -O3
#CC=tcc
FLAGS=-std=c99 -pedantic -Wall -Werror=vla -Werror -g
FLAGS+=-DGIT_VERSION_STRING=\"$(shell git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g')\"
OS:=$(shell uname -s)
ifeq ($(OS),Linux)

View File

@ -8,10 +8,32 @@
#include "util.h"
#include <unistd.h>
#include <stdio.h>
#include <string.h>
enum active_input {INPUT_DESKTOP, INPUT_LOGIN, INPUT_PASSWORD};
enum shutdown {SHUTDOWN_NO, SHUTDOWN_YES, SHUTDOWN_REBOOT};
bool args(int argc, char** argv)
{
char* arg;
while (argc > 0)
{
arg = argv[argc - 1];
if (strcmp(arg, "-v") == 0
|| strcmp(arg, "--version") == 0)
{
printf("ly version %s\n", GIT_VERSION_STRING);
return false;
}
--argc;
}
return true;
}
int main(int argc, char** argv)
{
struct desktop desktop;
@ -23,6 +45,11 @@ int main (int argc, char **argv)
enum err error = OK;
enum err status;
if (!args(argc, argv))
{
return 0;
}
void* input_structs[3] =
{
(void*) &desktop,