Skip to content

Commit

Permalink
Rename GIT_VERSION_STRING to LY_VERSION, don't allow shutdown and reb…
Browse files Browse the repository at this point in the history
…oot at same time
  • Loading branch information
AnErrupTion committed Jun 15, 2023
1 parent 57a8eec commit d775efb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CC = gcc
FLAGS = -std=c99 -pedantic -g
FLAGS+= -Wall -Wextra -Werror=vla -Wno-unused-parameter
#FLAGS+= -DDEBUG
FLAGS+= -DGIT_VERSION_STRING=\"$(shell git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g')\"
FLAGS+= -DLY_VERSION=\"$(shell git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g')\"
LINK = -lpam -lxcb
VALGRIND = --show-leak-kinds=all --track-origins=yes --leak-check=full --suppressions=../res/valgrind.supp
CMD = ./$(NAME)
Expand Down
16 changes: 7 additions & 9 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
#include <stdlib.h>

#define ARG_COUNT 7
// things you can define:
// GIT_VERSION_STRING

#ifndef LY_VERSION
#define LY_VERSION "0.6.0"
#endif

// global
struct lang lang;
Expand All @@ -30,15 +32,12 @@ struct config config;
void arg_help(void* data, char** pars, const int pars_count)
{
printf("If you want to configure Ly, please check the config file, usually located at /etc/ly/config.ini.\n");
exit(0);
}

void arg_version(void* data, char** pars, const int pars_count)
{
#ifdef GIT_VERSION_STRING
printf("Ly version %s\n", GIT_VERSION_STRING);
#else
printf("Ly version unknown\n");
#endif
printf("Ly version %s\n", LY_VERSION);
}

// low-level error messages
Expand Down Expand Up @@ -345,8 +344,7 @@ int main(int argc, char** argv)
{
execl("/bin/sh", "sh", "-c", config.shutdown_cmd, NULL);
}

if (reboot)
else if (reboot)
{
execl("/bin/sh", "sh", "-c", config.restart_cmd, NULL);
}
Expand Down

0 comments on commit d775efb

Please sign in to comment.