16#ifdef HAVE_LIBREADLINE
17#include <readline/readline.h>
19#include <readline/history.h>
29#if defined(LIBXML_CATALOG_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
37static int no_super_update = 0;
42#ifndef XML_SGML_DEFAULT_CATALOG
43#define XML_SGML_DEFAULT_CATALOG SYSCONFDIR "/sgml/catalog"
61xmlShellReadline(
const char *prompt) {
62#ifdef HAVE_LIBREADLINE
69 if (line_read && *line_read)
70 add_history (line_read);
93static void usershell(
void) {
103 cmdline = xmlShellReadline(
"> ");
112 while ((*
cur ==
' ') || (*
cur ==
'\t'))
cur++;
114 while ((*
cur !=
' ') && (*
cur !=
'\t') &&
115 (*
cur !=
'\n') && (*
cur !=
'\r')) {
130 while ((*
cur ==
' ') || (*
cur ==
'\t'))
cur++;
132 while ((*
cur !=
'\n') && (*
cur !=
'\r') && (*
cur != 0)) {
147 while ((*
cur ==
' ') || (*
cur ==
'\t'))
cur++;
151 while ((*
cur != 0) && (*
cur !=
'\''))
cur++;
158 }
else if (*
cur ==
'"') {
161 while ((*
cur != 0) && (*
cur !=
'"'))
cur++;
170 while ((*
cur != 0) && (*
cur !=
' ') && (*
cur !=
'\t'))
191 printf(
"public requires 1 arguments\n");
193 ans = xmlCatalogResolvePublic((
const xmlChar *)
argv[0]);
197 printf(
"%s\n", (
char *) ans);
203 printf(
"system requires 1 arguments\n");
205 ans = xmlCatalogResolveSystem((
const xmlChar *)
argv[0]);
209 printf(
"%s\n", (
char *) ans);
214 if ((nbargs != 3) && (nbargs != 2)) {
215 printf(
"add requires 2 or 3 arguments\n");
224 printf(
"add command failed\n");
228 printf(
"del requires 1\n");
232 printf(
"del command failed\n");
237 printf(
"resolve requires 2 arguments\n");
242 printf(
"Resolver failed to find an answer\n");
244 printf(
"%s\n", (
char *) ans);
250 printf(
"dump has no arguments\n");
256 printf(
"debug has no arguments\n");
263 printf(
"quiet has no arguments\n");
273 printf(
"Commands available:\n");
274 printf(
"\tpublic PublicID: make a PUBLIC identifier lookup\n");
275 printf(
"\tsystem SystemID: make a SYSTEM identifier lookup\n");
276 printf(
"\tresolve PublicID SystemID: do a full resolver lookup\n");
277 printf(
"\tadd 'type' 'orig' 'replace' : add an entry\n");
278 printf(
"\tdel 'values' : remove values\n");
279 printf(
"\tdump: print the current catalog state\n");
280 printf(
"\tdebug: increase the verbosity level\n");
281 printf(
"\tquiet: decrease the verbosity level\n");
282 printf(
"\texit: quit the shell\n");
296Usage : %s [options] catalogfile entities...\n\
297\tParse the catalog file (void specification possibly expressed as \"\"\n\
298\tappoints the default system one) and query it for the entities\n\
299\t--sgml : handle SGML Super catalogs for --add and --del\n\
300\t--shell : run a shell allowing interactive queries\n\
301\t--create : create a new catalog\n\
302\t--add 'type' 'orig' 'replace' : add an XML entry\n\
303\t--add 'entry' : add an SGML entry\n",
name);
305\t--del 'values' : remove values\n\
306\t--noout: avoid dumping the result on stdout\n\
307\t used with --add or --del, it saves the catalog changes\n\
308\t and with --sgml it automatically updates the super catalog\n\
309\t--no-super-update: do not update the SGML super catalog\n\
310\t-v --verbose : provide debug information\n");
328 if (
argv[
i][0] !=
'-')
351 }
else if ((!
strcmp(
argv[
i],
"-no-super-update")) ||
386 fprintf(
stderr,
"No catalog entry specified to remove from\n");
392 }
else if (
argv[
i][0] ==
'-')
398 xmlInitializeCatalog();
410 ret = xmlCatalogConvert();
412 if ((add) || (
del)) {
417 if (
argv[
i][0] !=
'-')
427 xmlCatalogPtr catal =
NULL;
428 xmlCatalogPtr super =
NULL;
430 catal = xmlLoadSGMLSuperCatalog(
argv[
i + 1]);
435 catal = xmlNewCatalog(1);
436 xmlACatalogAdd(catal,
BAD_CAST "CATALOG",
439 if (!no_super_update) {
440 super = xmlLoadSGMLSuperCatalog(XML_SGML_DEFAULT_CATALOG);
442 super = xmlNewCatalog(1);
444 xmlACatalogAdd(super,
BAD_CAST "CATALOG",
457 if ((!no_super_update) && (
noout) && (catal !=
NULL) &&
458 (xmlCatalogIsEmpty(catal))) {
459 super = xmlLoadSGMLSuperCatalog(
460 XML_SGML_DEFAULT_CATALOG);
462 ret = xmlACatalogRemove(super,
466 "Failed to remove entry from %s\n",
467 XML_SGML_DEFAULT_CATALOG);
476 if (xmlCatalogIsEmpty(catal)) {
486 xmlACatalogDump(catal,
out);
490 if (!no_super_update && super !=
NULL) {
491 if (xmlCatalogIsEmpty(super)) {
492 remove(XML_SGML_DEFAULT_CATALOG);
494 out =
fopen(XML_SGML_DEFAULT_CATALOG,
"w");
497 "could not open %s for saving\n",
498 XML_SGML_DEFAULT_CATALOG);
503 xmlACatalogDump(super,
out);
509 xmlACatalogDump(catal,
stdout);
523 printf(
"add command failed\n");
549 ans = xmlCatalogResolvePublic((
const xmlChar *)
argv[
i]);
554 printf(
"%s\n", (
char *) ans);
559 ans = xmlCatalogResolveSystem((
const xmlChar *)
argv[
i]);
567 printf(
"%s\n", (
char *) ans);
571 printf(
"%s\n", (
char *) ans);
603 fprintf(
stderr,
"libxml was not compiled with catalog and output support\n");
int strcmp(const char *String1, const char *String2)
ACPI_SIZE strlen(const char *String)
static logline * readline(FILE *inf, adns_state adns, int opts)
void shell(int argc, const char *argv[])
static VOID del(LPHIST_ENTRY item)
GLsizeiptr const GLvoid GLenum usage
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
#define memcpy(s1, s2, n)
static const struct access_res create[16]
XMLPUBVAR xmlFreeFunc xmlFree
XMLPUBFUN void XMLCALL xmlCleanupParser(void)
XMLPUBFUN xmlURIPtr XMLCALL xmlParseURI(const char *str)
XMLPUBFUN void XMLCALL xmlFreeURI(xmlURIPtr uri)
XMLPUBFUN void XMLCALL xmlMemoryDump(void)
#define LIBXML_TEST_VERSION