Commit 0f5f162e authored by Daniel Veillard's avatar Daniel Veillard
Browse files

Fixed bug #68830, xmlcatalog now provides return codes in case of errors

* doc/xmlcatalog_man.xml xmlcatalog.c: Fixed bug #68830, xmlcatalog
  now provides return codes in case of errors
Daniel
parent 35e937a7
Sun Jan 20 13:38:22 CET 2002 Daniel Veillard <daniel@veillard.com>
* doc/xmlcatalog_man.xml xmlcatalog.c: Fixed bug #68830, xmlcatalog
now provides return codes in case of errors
Sat Jan 19 16:36:21 CET 2002 Bjorn Reese <breese@users.sourceforge.net>
* trio.h trio.c triodef.h triop.h trionan.h trionan.c Makefile.am:
......
......@@ -246,6 +246,18 @@ FIXME - Is my list of possible types correct? Are SGML types the same?
</refsect1>
<refsect1 id="return">
<title>Return values</title>
<para><application>xmlcatalog</application>'s return codes provide
information that can be used when calling it from scripts.</para>
<para>0: normal</para>
<para>1: Failed to remove an entry from the catalog</para>
<para>2: Failed to save to the catalog, check file permissions</para>
<para>3: Failed to add an entry to the catalog</para>
<para>4: Failed to lookup and entry in the catalog</para>
</refsect1>
<refsect1>
<title>References</title>
<para><ulink url="http://www.xmlsoft.org/">libxml web page</ulink></para>
......@@ -262,4 +274,4 @@ FIXME - Is my list of possible types correct? Are SGML types the same?
</refsect1>
</refentry>
\ No newline at end of file
</refentry>
......@@ -313,6 +313,7 @@ static void usage(const char *name) {
int main(int argc, char **argv) {
int i;
int ret;
int exit_value = 0;
if (argc <= 1) {
......@@ -430,9 +431,11 @@ int main(int argc, char **argv) {
ret = xmlACatalogRemove(catal, BAD_CAST argv[i + 2]);
else
ret = -1;
if (ret < 0)
fprintf(stderr, "Failed to removed entry from %s\n",
if (ret < 0) {
fprintf(stderr, "Failed to remove entry from %s\n",
argv[i + 1]);
exit_value = 1;
}
if ((noout) && (catal != NULL) &&
(xmlCatalogIsEmpty(catal))) {
super = xmlLoadSGMLSuperCatalog(
......@@ -440,10 +443,12 @@ int main(int argc, char **argv) {
if (super != NULL) {
ret = xmlACatalogRemove(super,
BAD_CAST argv[i + 1]);
if (ret < 0)
if (ret < 0) {
fprintf(stderr,
"Failed to removed entry from %s\n",
"Failed to remove entry from %s\n",
XML_SGML_DEFAULT_CATALOG);
exit_value = 1;
}
}
}
}
......@@ -457,6 +462,7 @@ int main(int argc, char **argv) {
if (out == NULL) {
fprintf(stderr, "could not open %s for saving\n",
argv[i + 1]);
exit_value = 2;
noout = 0;
} else {
xmlACatalogDump(catal, out);
......@@ -472,6 +478,7 @@ int main(int argc, char **argv) {
fprintf(stderr,
"could not open %s for saving\n",
XML_SGML_DEFAULT_CATALOG);
exit_value = 2;
noout = 0;
} else {
......@@ -494,12 +501,19 @@ int main(int argc, char **argv) {
ret = xmlCatalogAdd(BAD_CAST argv[i + 1],
BAD_CAST argv[i + 2],
BAD_CAST argv[i + 3]);
if (ret != 0)
if (ret != 0) {
printf("add command failed\n");
exit_value = 3;
}
i += 3;
} else if ((!strcmp(argv[i], "-del")) ||
(!strcmp(argv[i], "--del"))) {
ret = xmlCatalogRemove(BAD_CAST argv[i + 1]);
if (ret < 0) {
fprintf(stderr, "Failed to remove entry %s\n",
argv[i + 1]);
exit_value = 1;
}
i += 1;
}
}
......@@ -517,6 +531,7 @@ int main(int argc, char **argv) {
ans = xmlCatalogResolvePublic((const xmlChar *) argv[i]);
if (ans == NULL) {
printf("No entry for PUBLIC %s\n", argv[i]);
exit_value = 4;
} else {
printf("%s\n", ans);
xmlFree(ans);
......@@ -526,6 +541,7 @@ int main(int argc, char **argv) {
ans = xmlCatalogResolveSystem((const xmlChar *) argv[i]);
if (ans == NULL) {
printf("No entry for SYSTEM %s\n", argv[i]);
exit_value = 4;
} else {
printf("%s\n", ans);
xmlFree(ans);
......@@ -540,6 +556,7 @@ int main(int argc, char **argv) {
out = fopen(filename, "w");
if (out == NULL) {
fprintf(stderr, "could not open %s for saving\n", filename);
exit_value = 2;
noout = 0;
} else {
xmlCatalogDump(out);
......@@ -554,7 +571,7 @@ int main(int argc, char **argv) {
*/
xmlCleanupParser();
xmlMemoryDump();
return(0);
return(exit_value);
}
#else
int main(int argc, char **argv) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment