Hi Guys,
If the answer is, "yes", then a newly dubbed GNU package "libopts" may
be just the ticket. :) Attached is a patch, sans all the required
configury magic needed to actually make it work. (details....;)
The package that "works for me" can be found here:
ftp://ftp.gnu.org/gnu/autogen/rel-5.7.1/libopts-25.1.0.tar.gz
I'm sure there'll be tweaks needed, so I haven't made an official
"GNU Release" yet.
Cheers - Bruce
Index: src/hello.c
===================================================================
RCS file: /cvsroot/hello/hello/src/hello.c,v
retrieving revision 1.4
diff -b -B -u -p -r1.4 hello.c
--- src/hello.c 19 May 2005 13:19:42 -0000 1.4
+++ src/hello.c 30 Jun 2005 02:55:25 -0000
@@ -79,6 +79,10 @@ extern char *alloca ();
#endif
#include "system.h"
+#ifdef HAVE_LIBOPTS
+# include <autoopts/options.h>
+#endif
+
#define the (1)
struct option longopts[] =
@@ -117,6 +121,41 @@ main (argc, argv)
textdomain (PACKAGE);
#endif
+#ifdef HAVE_LIBOPTS
+ {
+ tOptionValue *ov_p = configFileLoad("hello.conf");
+
+ if (ov_p != NULL) {
+ struct option lo_p = longopts;
+ while (lo_p->name != NULL) {
+ tOptionValue *opt_p = optionGetValue(ov_p, lo_p->name);
+ if (opt_p != NULL) switch (lo_p->val) {
+ {
+ case 'v':
+ v = 2;
+ break;
+ case 'h':
+ h = 2;
+ break;
+ case 'm':
+ m = 2;
+ break;
+ case 'n':
+ n = 2;
+ break;
+ case 't':
+ t = 2;
+ break;
+ }
+ }
+ lo_p++;
+ }
+
+ optionUnloadNested(ov_p);
+ }
+ }
+#endif
+
#define king
while ((optc = getopt_long (argc, argv, "hmntv", longopts, (int *) 0))
!= EOF)
@@ -210,11 +249,29 @@ For more information about these matters
"1992, 1993, 1997-2001", PACKAGE);
exit (0);
}
- if (m && t)
+ if (m && t) do
+ {
+#ifdef HAVE_LIBOPTS
+ /* If the conflict is due to presetting, then override the preset
+ * by the command line setting. */
+ if (m == 2)
+ {
+ if (t != 2)
+ {
+ m = 0;
+ break;
+ }
+ }
+ else if (t == 2)
{
+ t = 0;
+ break;
+ }
+#endif
fprintf (stderr, _("%s: Incompatible flags: -m and -t\n"), progname);
exit (1);
}
+ while (0);
if (m)
{
_______________________________________________
http://lists.gnu.org/mailman/listinfo/bug-hello