]> granicus.if.org Git - libexpat/commitdiff
Elaborate the XML_GetFeatureList() API a bit, and add additional info
authorFred L. Drake, Jr. <fdrake@users.sourceforge.net>
Thu, 5 Sep 2002 01:48:26 +0000 (01:48 +0000)
committerFred L. Drake, Jr. <fdrake@users.sourceforge.net>
Thu, 5 Sep 2002 01:48:26 +0000 (01:48 +0000)
that may be needed by a hughly flexible client.  (Or at least used to check
that the Expat that it links to matches client expectations.)

expat/doc/reference.html
expat/lib/expat.h
expat/lib/xmlparse.c
expat/xmlwf/xmlwf.c

index 1d422c7a9fe7082b332ca2b2f3cacc1b7c2b33af..fda752f8e17a91bf4f5599fd5f2235008df829b8 100644 (file)
@@ -1712,12 +1712,17 @@ enum XML_FeatureEnum {
   XML_FEATURE_END = 0,
   XML_FEATURE_UNICODE,
   XML_FEATURE_UNICODE_WCHAR_T,
-  XML_FEATURE_DTD
+  XML_FEATURE_DTD,
+  XML_FEATURE_CONTEXT_BYTES,
+  XML_FEATURE_MIN_SIZE,
+  XML_FEATURE_SIZEOF_XML_CHAR,
+  XML_FEATURE_SIZEOF_XML_LCHAR
 };
 
 typedef struct {
   enum XML_FeatureEnum  feature;
   XML_LChar            *name;
+  long int              value;
 } XML_Feature;
 </pre>
 <div class="fcndef">
@@ -1730,12 +1735,31 @@ check these features to do so at runtime.</p>
 <p>The return value is an array of <code>XML_Feature</code>,
 terminated by a record with a <code>feature</code> of
 <code>XML_FEATURE_END</code> and <code>name</code> of NULL,
-identifying the feature-test macros Expat was compiled with.  Since
-an application that requires this kind of information needs to
-determine the type of character the <code>name</code> points to,
-records for the <code>XML_UNICODE</code> and
-<code>XML_UNICODE_WCHAR_T</code> features will be located at the
-beginning of the list, if they are present at all.</p>
+identifying the feature-test macros Expat was compiled with.  Since an
+application that requires this kind of information needs to determine
+the type of character the <code>name</code> points to, records for the
+<code>XML_FEATURE_SIZEOF_XML_CHAR</code> and
+<code>XML_FEATURE_SIZEOF_XML_LCHAR</code> will be located at the
+beginning of the list, followed by <code>XML_FEATURE_UNICODE</code>
+and <code>XML_FEATURE_UNICODE_WCHAR_T</code>, if they are present at
+all.</p>
+
+<p>Some features have an associated value.  If there isn't an
+associated value, the <code>value</code> field is set to 0.  At this
+time, the following features have been defined to have values:</p>
+
+<dl>
+  <dt><code>XML_FEATURE_SIZEOF_XML_CHAR</code></dt>
+  <dd>The number of bytes occupied by one <code>XML_Char</code>
+  character.</dd>
+  <dt><code>XML_FEATURE_SIZEOF_XML_LCHAR</code></dt>
+  <dd>The number of bytes occupied by one <code>XML_LChar</code>
+  character.</dd>
+  <dt><code>XML_FEATURE_CONTEXT_BYTES</code></dt>
+  <dd>The maximum number of characters of context which can be
+  reported by <code><a href= "#XML_GetInputContext"
+  >XML_GetInputContext</a></code>.</dd>
+</dl>
 </div>
 
 <hr />
index 63c08527537e60742f94516ddd91393d4bf24045..d69211efa8fc72d2272253c573ea0d04ea135c5d 100644 (file)
@@ -875,13 +875,18 @@ enum XML_FeatureEnum {
   XML_FEATURE_END = 0,
   XML_FEATURE_UNICODE,
   XML_FEATURE_UNICODE_WCHAR_T,
-  XML_FEATURE_DTD
+  XML_FEATURE_DTD,
+  XML_FEATURE_CONTEXT_BYTES,
+  XML_FEATURE_MIN_SIZE,
+  XML_FEATURE_SIZEOF_XML_CHAR,
+  XML_FEATURE_SIZEOF_XML_LCHAR
   /* Additional features must be added to the end of this enum. */
 };
 
 typedef struct {
   enum XML_FeatureEnum  feature;
   XML_LChar            *name;
+  long int              value;
 } XML_Feature;
 
 XMLPARSEAPI(const XML_Feature *)
index db15eae123c5069b72ffd2ac841f0c69134dbfde..0488f41c41c3475651f2196baf5958ecbe69d643 100644 (file)
@@ -1607,19 +1607,30 @@ XML_ExpatVersionInfo(void)
 const XML_Feature *
 XML_GetFeatureList(void)
 {
-  static const XML_Feature features[] = {
+  static XML_Feature features[] = {
+    {XML_FEATURE_SIZEOF_XML_CHAR,  XML_L("sizeof(XML_Char)")},
+    {XML_FEATURE_SIZEOF_XML_LCHAR, XML_L("sizeof(XML_LChar)")},
 #ifdef XML_UNICODE
-    {XML_FEATURE_UNICODE,         XML_L("XML_UNICODE")},
+    {XML_FEATURE_UNICODE,          XML_L("XML_UNICODE")},
 #endif
 #ifdef XML_UNICODE_WCHAR_T
-    {XML_FEATURE_UNICODE_WCHAR_T, XML_L("XML_UNICODE_WCHAR_T")},
+    {XML_FEATURE_UNICODE_WCHAR_T,  XML_L("XML_UNICODE_WCHAR_T")},
 #endif
 #ifdef XML_DTD
-    {XML_FEATURE_DTD,             XML_L("XML_DTD")},
+    {XML_FEATURE_DTD,              XML_L("XML_DTD")},
 #endif
-    {XML_FEATURE_END,             NULL}
+#ifdef XML_CONTEXT_BYTES
+    {XML_FEATURE_CONTEXT_BYTES,    XML_L("XML_CONTEXT_BYTES"),
+     XML_CONTEXT_BYTES},
+#endif
+#ifdef XML_MIN_SIZE
+    {XML_FEATURE_MIN_SIZE,         XML_L("XML_MIN_SIZE")},
+#endif
+    {XML_FEATURE_END,              NULL}
   };
 
+  features[0].value = sizeof(XML_Char);
+  features[1].value = sizeof(XML_LChar);
   return features;
 }
 
index 34149c344efe806725188e505420041b69b4b75a..8a8056e552eb228e48e76cc2bf8a58b4ae46dc4d 100755 (executable)
@@ -609,17 +609,19 @@ showVersion(XML_Char *prog)
       prog = s + 1;
     ++s;
   }
-  ftprintf(stdout, T("%s using %s"), prog, XML_ExpatVersion());
-  if (features == NULL || features[0].feature == XML_FEATURE_END)
-    ftprintf(stdout, T("\n"));
-  else {
+  ftprintf(stdout, T("%s using %s\n"), prog, XML_ExpatVersion());
+  if (features != NULL && features[0].feature != XML_FEATURE_END) {
     int i = 1;
-    ftprintf(stdout, T(" (%s"), features[0].name);
+    ftprintf(stdout, T("%s"), features[0].name);
+    if (features[0].value)
+      ftprintf(stdout, T("=%ld"), features[0].value);
     while (features[i].feature != XML_FEATURE_END) {
       ftprintf(stdout, T(", %s"), features[i].name);
+      if (features[i].value)
+        ftprintf(stdout, T("=%ld"), features[i].value);
       ++i;
     }
-    ftprintf(stdout, T(")\n"));
+    ftprintf(stdout, T("\n"));
   }
 }