On Friday 03 August 2007, Rafael J. Wysocki wrote:
> On Friday, 3 August 2007 01:16, Alon Bar-Lev wrote:
> >
> > config.* conflicts with autoconf files.
> > Rename the to configparser.*.
> >
> > After applying this patch, you should rename:
> > config.h->configparser.h
> > config.c->configparser.c
>
> OK
>
> > I did not want to include the removal/addition in patch.
>
> Please do, it's easier to apply complete patches.
>
> Greetings,
> Rafael
But it is less easy to review :)
And it takes much more space...
We should have patch rename command... Something like:
@@ RENAME from, to @@
OK... Here it is.
Alon.
---
diff -urNp suspend.org/resume.c suspend-0.6_beta1/resume.c
--- suspend.org/resume.c 2007-05-13 20:53:13.000000000 +0300
+++ suspend-0.6_beta1/resume.c 2007-08-01 23:05:59.000000000 +0300
@@ -34,3 +34,3 @@
#include "swsusp.h"
-#include "config.h"
+#include "configparser.h"
#include "md5.h"
diff -urNp suspend.org/s2ram.c suspend-0.6_beta1/s2ram.c
--- suspend.org/s2ram.c 2007-06-17 23:51:30.000000000 +0300
+++ suspend-0.6_beta1/s2ram.c 2007-08-02 17:36:49.000000000 +0300
@@ -16,7 +17,7 @@
#endif
#include "vt.h"
#include "s2ram.h"
-#include "config.h"
+#include "configparser.h"
/* Actually enter the suspend. May be ran on frozen system. */
diff -urNp suspend.org/s2ram-x86.c suspend-0.6_beta1/s2ram-x86.c
--- suspend.org/s2ram-x86.c 2007-08-03 00:33:20.000000000 +0300
+++ suspend-0.6_beta1/s2ram-x86.c 2007-08-02 23:50:33.000000000 +0300
@@ -16,7 +17,7 @@
#include "vbetool/vbetool.h"
#include "vt.h"
#include "s2ram.h"
-#include "config.h"
+#include "configparser.h"
/* From dmidecode.c */
void dmi_scan(void);
diff -urNp suspend.org/suspend.c suspend-0.6_beta1/suspend.c
--- suspend.org/suspend.c 2007-07-29 21:30:27.000000000 +0300
+++ suspend-0.6_beta1/suspend.c 2007-08-02 23:55:20.000000000 +0300
@@ -42,4 +41,4 @@
#include "swsusp.h"
-#include "config.h"
+#include "configparser.h"
#include "md5.h"
#include "splash.h"
--- suspend.org/Makefile 2007-07-29 21:30:27.000000000 +0300
+++ suspend-0.6_beta1/Makefile 2007-08-03 01:14:35.000000000 +0300
@@ -23,7 +23,7 @@ LD_FLAGS=-L/usr/local/lib
BINARIES=s2disk s2both s2ram swap-offset resume
BINARIES_MIN=s2disk swap-offset
-S2RAM_OBJ=vt.o config.o
-SWSUSP_OBJ=vt.o md5.o encrypt.o config.o loglevel.o splash.o bootsplash.o
+S2RAM_OBJ=vt.o configparser.o
+SWSUSP_OBJ=vt.o md5.o encrypt.o configparser.o loglevel.o splash.o
bootsplash.o
S2RAM_LD_FLAGS = $(LD_FLAGS)
@@ -94,7 +94,7 @@ md5.o encrypt.o: %.o : %.c %.h md5.h
$(CC) $(CC_FLAGS) -DHAVE_INTTYPES_H -DHAVE_STDINT_H -c $< -o $@
# Simple objects with header
-config.o vt.o bootsplash.o splash.o splashy_funcs.o vbetool/vbetool.o
s2ram-ppc.o: %.o : %.c %.h
+configparser.o vt.o bootsplash.o splash.o splashy_funcs.o vbetool/vbetool.o
s2ram-ppc.o: %.o : %.c %.h
$(CC) $(CC_FLAGS) -c $< -o $@
# Simple object without header
--- suspend.org/config.h 2007-05-13 20:53:13.000000000 +0300
+++ suspend.inter/config.h 1970-01-01 02:00:00.000000000 +0200
@@ -1,28 +0,0 @@
-/*
- * config.h
- *
- * Configuration file-related definitions for user space suspend and resume
- * tools.
- *
- * Copyright (C) 2006 Rafael J. Wysocki <[EMAIL PROTECTED]>
- *
- * This file is released under the GPLv2.
- *
- */
-
-#include <getopt.h>
-
-#define MAX_STR_LEN 256
-
-struct config_par {
- char *name;
- char *fmt;
- void *ptr;
- unsigned int len;
-};
-
-int parse(char *my_name, char *file_name, int parc, struct config_par *parv);
-
-void usage(char *my_name, struct option options[], const char *short_options);
-
-#define CONFIG_FILE "/etc/suspend.conf"
--- suspend.org/config.c 2007-05-13 20:53:13.000000000 +0300
+++ suspend.inter/config.c 1970-01-01 02:00:00.000000000 +0200
@@ -1,131 +0,0 @@
-/*
- * config.c
- *
- * Configuration file parser for userland suspend tools
- *
- * Copyright (C) 2006 Rafael J. Wysocki <[EMAIL PROTECTED]>
- *
- * This file is released under the GPLv2.
- *
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <getopt.h>
-
-#include "config.h"
-#include "encrypt.h"
-
-/**
- * parse - read and parse the configuration file
- * note that a non-present config file is not considered an error here
- */
-
-int parse(char *my_name, char *file_name, int parc, struct config_par *parv)
-{
- char *str, *dst, *fmt, buf[MAX_STR_LEN];
- struct stat stat_buf;
- FILE *file;
- int error, i, j, k;
-
- if (stat(file_name, &stat_buf)) {
- fprintf(stderr, "%s: Could not stat configuration file\n",
- my_name);
- return 0;
- }
- file = fopen(file_name, "r");
- if (!file) {
- fprintf(stderr, "%s: Could not open configuration file\n",
- my_name);
- return 0;
- }
- error = 0;
- i = 0;
- do {
- str = fgets(buf, MAX_STR_LEN, file);
- if (!str)
- break;
- i++;
- /* Ignore comments */
- if (*str == '#')
- continue;
- /* Skip white space */
- while (*str == ' ' || *str == '\t' || *str == '\r' || *str ==
'\n')
- str++;
- /* Skip the lines containing white space only */
- if (!*str)
- continue;
- /* Compare with parameter names */
- for (j = 0; j < parc; j++) {
- k = strlen(parv[j].name);
- if (!strncmp(parv[j].name, str, k)) {
- if (!parv[j].ptr)
- break;
- str += k;
- while (*str == ' ' || *str == '\t')
- str++;
- if (*str != ':' && *str != '=') {
- error = -EINVAL;
- break;
- }
- str++;
- while (*str == ' ' || *str == '\t')
- str++;
- if (*str) {
- fmt = parv[j].fmt;
- if (!strncmp(fmt, "%s", 2)) {
- dst = parv[j].ptr;
- k = parv[j].len;
- strncpy(dst, str, k - 1);
- k = strlen(dst) - 1;
- if (dst[k] == '\n')
- dst[k] = '\0';
- } else {
- k = sscanf(str, fmt,
parv[j].ptr);
- if (k <= 0)
- error = -EINVAL;
- }
- break;
- }
- }
- }
- if (j >= parc)
- error = -EINVAL;
- } while (!error);
- fclose(file);
- if (error)
- fprintf(stderr, "%s: Error in configuration file, line %d\n",
- my_name, i);
- return error;
-}
-
-/* We're abusing struct option a bit. usage() expects an \0 in the
- * name string, and after that a comment.
- */
-void usage(char *my_name, struct option *options, const char *short_options)
-{
- struct option *opt;
-
- printf("Usage: %s [options]", my_name);
- for (opt = options; opt->name; opt++)
- {
- const char *descr = opt->name + strlen(opt->name) + 1;
- if (strchr(short_options,opt->val))
- printf("\n -%c, --%s", opt->val, opt->name);
- else
- printf("\n --%s", opt->name);
-
- if (opt->has_arg)
- printf(" <%s>", opt->name);
-
- if (strlen(descr))
- printf("\t%s",descr);
- }
-
- printf("\n");
-}
--- suspend.org/configparser.c 1970-01-01 02:00:00.000000000 +0200
+++ suspend.inter/configparser.c 2007-08-03 02:07:23.000000000 +0300
@@ -0,0 +1,131 @@
+/*
+ * configparser.c
+ *
+ * Configuration file parser for userland suspend tools
+ *
+ * Copyright (C) 2006 Rafael J. Wysocki <[EMAIL PROTECTED]>
+ *
+ * This file is released under the GPLv2.
+ *
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <getopt.h>
+
+#include "configparser.h"
+#include "encrypt.h"
+
+/**
+ * parse - read and parse the configuration file
+ * note that a non-present config file is not considered an error here
+ */
+
+int parse(char *my_name, char *file_name, int parc, struct config_par *parv)
+{
+ char *str, *dst, *fmt, buf[MAX_STR_LEN];
+ struct stat stat_buf;
+ FILE *file;
+ int error, i, j, k;
+
+ if (stat(file_name, &stat_buf)) {
+ fprintf(stderr, "%s: Could not stat configuration file\n",
+ my_name);
+ return 0;
+ }
+ file = fopen(file_name, "r");
+ if (!file) {
+ fprintf(stderr, "%s: Could not open configuration file\n",
+ my_name);
+ return 0;
+ }
+ error = 0;
+ i = 0;
+ do {
+ str = fgets(buf, MAX_STR_LEN, file);
+ if (!str)
+ break;
+ i++;
+ /* Ignore comments */
+ if (*str == '#')
+ continue;
+ /* Skip white space */
+ while (*str == ' ' || *str == '\t' || *str == '\r' || *str ==
'\n')
+ str++;
+ /* Skip the lines containing white space only */
+ if (!*str)
+ continue;
+ /* Compare with parameter names */
+ for (j = 0; j < parc; j++) {
+ k = strlen(parv[j].name);
+ if (!strncmp(parv[j].name, str, k)) {
+ if (!parv[j].ptr)
+ break;
+ str += k;
+ while (*str == ' ' || *str == '\t')
+ str++;
+ if (*str != ':' && *str != '=') {
+ error = -EINVAL;
+ break;
+ }
+ str++;
+ while (*str == ' ' || *str == '\t')
+ str++;
+ if (*str) {
+ fmt = parv[j].fmt;
+ if (!strncmp(fmt, "%s", 2)) {
+ dst = parv[j].ptr;
+ k = parv[j].len;
+ strncpy(dst, str, k - 1);
+ k = strlen(dst) - 1;
+ if (dst[k] == '\n')
+ dst[k] = '\0';
+ } else {
+ k = sscanf(str, fmt,
parv[j].ptr);
+ if (k <= 0)
+ error = -EINVAL;
+ }
+ break;
+ }
+ }
+ }
+ if (j >= parc)
+ error = -EINVAL;
+ } while (!error);
+ fclose(file);
+ if (error)
+ fprintf(stderr, "%s: Error in configuration file, line %d\n",
+ my_name, i);
+ return error;
+}
+
+/* We're abusing struct option a bit. usage() expects an \0 in the
+ * name string, and after that a comment.
+ */
+void usage(char *my_name, struct option *options, const char *short_options)
+{
+ struct option *opt;
+
+ printf("Usage: %s [options]", my_name);
+ for (opt = options; opt->name; opt++)
+ {
+ const char *descr = opt->name + strlen(opt->name) + 1;
+ if (strchr(short_options,opt->val))
+ printf("\n -%c, --%s", opt->val, opt->name);
+ else
+ printf("\n --%s", opt->name);
+
+ if (opt->has_arg)
+ printf(" <%s>", opt->name);
+
+ if (strlen(descr))
+ printf("\t%s",descr);
+ }
+
+ printf("\n");
+}
--- suspend.org/configparser.h 1970-01-01 02:00:00.000000000 +0200
+++ suspend.inter/configparser.h 2007-05-13 20:53:13.000000000 +0300
@@ -0,0 +1,28 @@
+/*
+ * configparser.h
+ *
+ * Configuration file-related definitions for user space suspend and resume
+ * tools.
+ *
+ * Copyright (C) 2006 Rafael J. Wysocki <[EMAIL PROTECTED]>
+ *
+ * This file is released under the GPLv2.
+ *
+ */
+
+#include <getopt.h>
+
+#define MAX_STR_LEN 256
+
+struct config_par {
+ char *name;
+ char *fmt;
+ void *ptr;
+ unsigned int len;
+};
+
+int parse(char *my_name, char *file_name, int parc, struct config_par *parv);
+
+void usage(char *my_name, struct option options[], const char *short_options);
+
+#define CONFIG_FILE "/etc/suspend.conf"
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Suspend-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/suspend-devel