depre

Afficher la date et l'heure hexadécimale
git clone git://git.asteride.xyz/~ldp/depre.git
Journaux | Fichiers | Références | LISEZ-MOI | LICENCE

commit c9a0475d6badb71ca8cf5c5208a4c6000693869c
parent ad69ba79f75c081fb77ccb30b6e9de7f2928f81e
Auteur: ldp <ldp@asteride.xyz>
Date:   Thu,  8 Aug 2024 09:52:21 -0400

ajout de l'option -V

Diffstat:
M.gitignore | 2+-
MMakefile | 5++++-
Mdepre.c | 12+++++++++++-
3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,3 +1,3 @@ *.o *.core -dax +depre diff --git a/Makefile b/Makefile @@ -1,3 +1,5 @@ +VERSION = 1.0-ε/1 (2024/08/08) + PREFIX = /usr/local BIN_DOS = ${PREFIX}/bin @@ -5,10 +7,11 @@ CC = cc COPTS_SPCL = -O2 -DNDEBUG COPTS = -Wall -Wextra -Werror -Wpedantic -Wno-implicit-fallthrough \ -std=c89 ${COPTS_SPCL} +CPPOPTS = -DVERSION="\"${VERSION}\"" .SUFFIXES: .c .o .c.o: - ${CC} ${COPTS} -c "$<" + ${CC} ${CPPOPTS} ${COPTS} -c "$<" all: depre diff --git a/depre.c b/depre.c @@ -14,6 +14,7 @@ #define INTERVALLE (11138 * 60 * 60 * 24 + 3600 * 4) static void utilisation(FILE *f); +static void version(void); static int ccvt(char *cc, time_t *rep); char *nom_prog; @@ -32,12 +33,15 @@ main(int argc, char **argv) secondes = time(NULL); opterr = 0; - while ((opt = getopt(argc, argv, "s:h")) != -1) { + while ((opt = getopt(argc, argv, "s:Vh")) != -1) { switch (opt) { case 's': if (ccvt(optarg, &secondes) < 0) goto erreur; break; + case 'V': + version(); + return 0; case 'h': utilisation(stdout); return 0; @@ -78,6 +82,12 @@ utilisation(FILE *f) fprintf(f, "Utilisation: %s [-r secondes] [-h]\n", nom_prog); } +static void +version(void) +{ + fprintf(stdout, "%s " VERSION "\n", nom_prog); +} + /* convertir une chaîne de caractères en nombre */ static int ccvt(char *cc, time_t *rep)