aboutsummaryrefslogtreecommitdiffstats
path: root/argparse.c
diff options
context:
space:
mode:
Diffstat (limited to 'argparse.c')
-rw-r--r--argparse.c52
1 files changed, 49 insertions, 3 deletions
diff --git a/argparse.c b/argparse.c
index e748b3e..68ee068 100644
--- a/argparse.c
+++ b/argparse.c
@@ -1,3 +1,21 @@
+/* This file is part of cputemp2maxfreq.
+
+ Copyright (C) 2023-2024 pa4wdh
+
+ cputemp2maxfreq is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License , or
+ (at your option) any later version.
+
+ cputemp2maxfreq is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with cputemp2maxfreq; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses>.
+*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@@ -5,6 +23,7 @@
#include "cputemp2maxfreq.h"
#include "debug.h"
#include "logger.h"
+#include "version.h"
extern struct s_config config;
@@ -50,12 +69,36 @@ void printhelp()
" Default timestamp format is: YYYY-MM-DD HH:MM:SS\n"
"\n"
"Other options:\n"
- "-h Display this help text\n",
+ "-h Display this help text\n"
+ "-v Display version and license information\n",
config.name,config.fallback_freq,config.governor,config.temp_input,config.interval,
config.freq_step,config.max_temp/1000,config.logger_name
);
}
+void printversion()
+{
+ printf("%s version %s\n\n",config.name,version());
+ printf(
+ "Copyright 2023, 2024 pa4wdh\n"
+ "\n"
+ "%s is free software; you can redistribute it and/or modify\n"
+ "it under the terms of the GNU General Public License as published by\n"
+ "the Free Software Foundation; either version 3 of the License , or\n"
+ "(at your option) any later version.\n"
+ "\n"
+ "%s is distributed in the hope that it will be useful,\n"
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
+ "GNU General Public License for more details.\n"
+ "\n"
+ "You should have received a copy of the GNU General Public License\n"
+ "along with %s; see the file COPYING. If not, see\n"
+ "<http://www.gnu.org/licenses>.\n",
+ config.name,config.name,config.name
+ );
+}
+
void argparse(int argc, char **argv)
{
int opt;
@@ -77,7 +120,7 @@ void argparse(int argc, char **argv)
memcpy(&userconfig,&config,sizeof(struct s_config));
// Parse options
- while((opt=getopt(argc,argv,"c:C:d:f:g:hi:kl:mp:P:s:t:u"))!=-1)
+ while((opt=getopt(argc,argv,"c:C:d:f:g:hi:kl:mp:P:s:t:uv"))!=-1)
{
DEBUG1_ARGPARSE("Argument: %c Value: %s\n",opt,optarg);
switch(opt)
@@ -106,7 +149,7 @@ void argparse(int argc, char **argv)
break;
case 'h':
printhelp();
- exit(1);
+ exit(0);
case 'i':
strncpy(userconfig.temp_input,optarg,sizeof(userconfig.temp_input));
break;
@@ -139,6 +182,9 @@ void argparse(int argc, char **argv)
case 'u':
userconfig.use_unixtime=1;
break;
+ case 'v':
+ printversion();
+ exit(0);
default:
printhelp();
exit(1);