[xiph-cvs] cvs commit: vorbis-tools/ogg123 cfgfile_options.c

Stan Seibert volsung at xiph.org
Sat Dec 15 17:35:25 PST 2001



volsung     01/12/15 17:35:24

  Modified:    ogg123   Tag: volsung_kc_20011011 cfgfile_options.c
  Log:
  Completed implementation of boolean config file options.

Revision  Changes    Path
No                   revision

No                   revision

1.1.2.2   +26 -2     vorbis-tools/ogg123/Attic/cfgfile_options.c

Index: cfgfile_options.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/Attic/cfgfile_options.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- cfgfile_options.c	2001/12/08 23:59:24	1.1.2.1
+++ cfgfile_options.c	2001/12/16 01:35:22	1.1.2.2
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: cfgfile_options.c,v 1.1.2.1 2001/12/08 23:59:24 volsung Exp $
+ last mod: $Id: cfgfile_options.c,v 1.1.2.2 2001/12/16 01:35:22 volsung Exp $
 
  ********************************************************************/
 
@@ -80,7 +80,8 @@
       case opt_type_string:
         *(char **) opts->ptr = *(char **) opts->dfl;
         break;
-	
+
+      case opt_type_bool:
       case opt_type_int:
         *(long int *) opts->ptr = *(int *) opts->dfl;
         break;
@@ -166,6 +167,9 @@
       case opt_type_none:
         w -= fprintf (f, "none");
         break;
+      case opt_type_bool:
+	w -= fprintf (f, "bool");
+	break;
       case opt_type_char:
         w -= fprintf (f, "char");
         break;
@@ -200,6 +204,7 @@
         case opt_type_string:
           fputs (*(char **) opt->dfl, f);
           break;
+	case opt_type_bool:
         case opt_type_int:
           fprintf (f, "%ld", *(long int *) opt->dfl);
           break;
@@ -277,6 +282,25 @@
         if (value != NULL || strlen(value) > 0)
           return parse_badvalue;
         opt->found++;
+	break;
+
+      case opt_type_bool:
+	if (!value || *value == '\0')
+	  return parse_badvalue;
+	
+	/* Maybe this is a numeric bool */
+	tmpl = strtol (value, &endptr, 0);
+
+	if ( strncasecmp(value, "y", 1) == 0
+	     || strcasecmp(value, "true")
+	     || (*endptr == '\0' && tmpl) )
+	  *(long int *) opt->ptr = 1;
+	else if ( strncasecmp(value, "n", 1) == 0
+		  || strcasecmp(value, "false")
+		  || (*endptr == '\0' && !tmpl) )
+	  *(long int *) opt->ptr = 0;
+	else
+	  return parse_badvalue;
         break;
 
       case opt_type_char:

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list