aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2007-09-30 20:40:50 +0000
committerRafael J. Wysocki <rjw@sisk.pl>2007-09-30 20:40:50 +0000
commit8ef4cf14f065297c168d6735cfb76d8c0bf3139f (patch)
tree13018e4b43b4d6a07962f587205462c301f3e40b
parentfd749a738f781cb0dd191d1ff5d3b960bd37ee50 (diff)
downloadsuspend-utils-8ef4cf14f065297c168d6735cfb76d8c0bf3139f.tar.gz
Patch from Alon Bar-Lev <alon.barlev@gmail.com> to add a switch to print
version information (-V or --version command line options) to each of the utilities.
-rw-r--r--config_parser.c21
-rw-r--r--config_parser.h1
-rw-r--r--configure.ac7
-rw-r--r--resume.c10
-rw-r--r--s2ram-main.c10
-rw-r--r--suspend.c10
-rw-r--r--whitelist.c2
-rw-r--r--whitelist.h1
8 files changed, 57 insertions, 5 deletions
diff --git a/config_parser.c b/config_parser.c
index dea9c2f..30744e7 100644
--- a/config_parser.c
+++ b/config_parser.c
@@ -138,3 +138,24 @@ void usage(char *my_name, struct option *options, const char *short_options)
printf("\n");
}
+
+void version(char *my_name, char *extra_version)
+{
+ printf(
+ (
+ "%s (%s) %s %s\n"
+ "\n"
+ "FEATURES: %s\n"
+ "\n"
+ "This is free software. You may redistribute copies of it under the terms of\n"
+ "the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.\n"
+ "There is NO WARRANTY, to the extent permitted by law.\n"
+ ),
+ my_name,
+ PACKAGE_NAME,
+ PACKAGE_VERSION,
+ extra_version ? extra_version : "",
+ CONFIG_FEATURES
+ );
+}
+
diff --git a/config_parser.h b/config_parser.h
index 3695a6b..b1adb7f 100644
--- a/config_parser.h
+++ b/config_parser.h
@@ -25,5 +25,6 @@ int parse_line(char *str, struct config_par *parv);
int parse(char *my_name, char *file_name, struct config_par *parv);
void usage(char *my_name, struct option options[], const char *short_options);
+void version(char *my_name, char *extra_version);
#define CONFIG_FILE "/etc/suspend.conf"
diff --git a/configure.ac b/configure.ac
index 194e03e..10767b1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -109,6 +109,8 @@ case "${host}" in
ppc-*) ARCH="ppc";;
esac
+CONFIG_FEATURES=""
+
if test "${ARCH}" = "x86"; then
AC_DEFINE([CONFIG_ARCH_X86], [1], [Define if x86 arch])
@@ -152,6 +154,7 @@ elif test "${ARCH}" = "ppc"; then
fi
if test "${enable_compress}" = "yes"; then
+ CONFIG_FEATURES="${CONFIG_FEATURES} compress"
AC_DEFINE([CONFIG_COMPRESS], [1], [Define if x86 arch])
if test -z "${LZO_LIBS}"; then
AC_ARG_VAR([LZO_CFLAGS], [C compiler flags for lzo])
@@ -171,6 +174,7 @@ if test "${enable_compress}" = "yes"; then
fi
if test "${enable_encrypt}" = "yes"; then
+ CONFIG_FEATURES="${CONFIG_FEATURES} encrypt"
AC_DEFINE([CONFIG_ENCRYPT], [1], [Define if encryption enabled])
AC_MSG_CHECKING([for libgcrypt])
@@ -184,6 +188,7 @@ if test "${enable_encrypt}" = "yes"; then
fi
if test "${enable_splashy}" = "yes"; then
+ CONFIG_FEATURES="${CONFIG_FEATURES} splashy"
AC_DEFINE([CONFIG_SPLASHY], [1], [Define if splashy enabled])
if test -z "${SPLASHY_LIBS}"; then
@@ -198,6 +203,8 @@ if test "${enable_splashy}" = "yes"; then
fi
fi
+AC_DEFINE_UNQUOTED([CONFIG_FEATURES], ["${CONFIG_FEATURES/ /}"], [String representation of available features])
+
AC_HEADER_STDC
AC_CHECK_HEADERS([ \
inttypes.h \
diff --git a/resume.c b/resume.c
index 094499d..4b4acf7 100644
--- a/resume.c
+++ b/resume.c
@@ -762,6 +762,10 @@ static inline int get_config(int argc, char *argv[])
no_argument, NULL, 'h'
},
{
+ "version\0\t\t\tversion information",
+ no_argument, NULL, 'V'
+ },
+ {
"config\0\t\talternative configuration file.",
required_argument, NULL, 'f'
},
@@ -781,7 +785,7 @@ static inline int get_config(int argc, char *argv[])
};
int i, error;
char *conf_name = CONFIG_FILE;
- const char *optstring = "hf:o:r:P:";
+ const char *optstring = "hVf:o:r:P:";
struct stat stat_buf;
int fail_missing_config = 0;
@@ -791,6 +795,9 @@ static inline int get_config(int argc, char *argv[])
case 'h':
usage(my_name, options, optstring);
exit(EXIT_SUCCESS);
+ case 'V':
+ version(my_name, NULL);
+ exit(EXIT_SUCCESS);
case 'f':
conf_name = optarg;
fail_missing_config = 1;
@@ -816,7 +823,6 @@ static inline int get_config(int argc, char *argv[])
optind = 0;
while ((i = getopt_long(argc, argv, optstring, options, NULL)) != -1) {
switch (i) {
- case 'h':
case 'f':
/* already handled */
break;
diff --git a/s2ram-main.c b/s2ram-main.c
index 4eadff3..c42e41d 100644
--- a/s2ram-main.c
+++ b/s2ram-main.c
@@ -16,6 +16,7 @@
#define S2RAM
#endif
#include "vt.h"
+#include "whitelist.h"
#include "s2ram.h"
#include "config_parser.h"
@@ -28,6 +29,10 @@ int main(int argc, char *argv[])
"help\0\tthis text.",
no_argument, NULL, 'h'
},
+ {
+ "version\0\t\t\tversion information",
+ no_argument, NULL, 'V'
+ },
{
"test\0\ttest if the machine is in the database.",
no_argument, NULL, 'n'
@@ -39,13 +44,16 @@ int main(int argc, char *argv[])
HACKS_LONG_OPTS
{ NULL, 0, NULL, 0 }
};
- const char *optstring = "hni" "fspmrva:";
+ const char *optstring = "hVni" "fspmrva:";
while ((i = getopt_long(argc, argv, optstring, options, NULL)) != -1) {
switch (i) {
case 'h':
usage("s2ram", options, optstring);
exit(0);
+ case 'V':
+ version("s2ram", whitelist_version);
+ exit(EXIT_SUCCESS);
case 'i':
identify_machine();
exit(0);
diff --git a/suspend.c b/suspend.c
index 0a5b740..ef1c2f6 100644
--- a/suspend.c
+++ b/suspend.c
@@ -1237,6 +1237,10 @@ static inline int get_config(int argc, char *argv[])
no_argument, NULL, 'h'
},
{
+ "version\0\t\t\tversion information",
+ no_argument, NULL, 'V'
+ },
+ {
"config\0\t\talternative configuration file.",
required_argument, NULL, 'f'
},
@@ -1263,7 +1267,7 @@ static inline int get_config(int argc, char *argv[])
};
int i, error;
char *conf_name = CONFIG_FILE;
- const char *optstring = "hf:s:o:r:P:";
+ const char *optstring = "hVf:s:o:r:P:";
struct stat stat_buf;
int fail_missing_config = 0;
@@ -1273,6 +1277,9 @@ static inline int get_config(int argc, char *argv[])
case 'h':
usage(my_name, options, optstring);
exit(EXIT_SUCCESS);
+ case 'V':
+ version(my_name, NULL);
+ exit(EXIT_SUCCESS);
case 'f':
conf_name = optarg;
fail_missing_config = 1;
@@ -1298,7 +1305,6 @@ static inline int get_config(int argc, char *argv[])
optind = 0;
while ((i = getopt_long(argc, argv, optstring, options, NULL)) != -1) {
switch (i) {
- case 'h':
case 'f':
/* already handled */
break;
diff --git a/whitelist.c b/whitelist.c
index cf3e002..b1be6a9 100644
--- a/whitelist.c
+++ b/whitelist.c
@@ -7,6 +7,8 @@
#include <stdlib.h>
#include "whitelist.h"
+char *whitelist_version = "$Id: whitelist.c,v 1.114 2007/09/30 20:40:50 rjwysocki Exp $";
+
struct machine_entry whitelist[] = {
{ "IBM", "", "ThinkPad X32", "", RADEON_OFF|S3_BIOS|S3_MODE },
/* Michael Wagner <michael-wagner@gmx.de> */
diff --git a/whitelist.h b/whitelist.h
index a249b81..a7224ed 100644
--- a/whitelist.h
+++ b/whitelist.h
@@ -23,4 +23,5 @@ struct machine_entry
unsigned int flags;
};
+extern char *whitelist_version;
extern struct machine_entry whitelist[];