Global variables (state)

Previous: Data structures: frames and tags ] [ Top: xmltools index ] [ Next: Printing the current stack as a locator ]

 
/* The parsing context: */
FRAME stack = {
   "<bottom>",
   0,
   0,
   0,
   NULL,
   NULL,
   NULL,
   NULL
};

/* Settings */
int emit_content = 1;
int emit_matching_tag = 1;
int emit_tags = 1;
int emit_comments = 0;
int emit_pis = 0;
int emit_locator = 0;

char * infile = NULL;
char * insertwhere = NULL;
char * setattr = NULL;
char * setvalue = NULL;

FRAME * top = &stack;

int finished; /* We can set this if we know we're done with the snip. */
int emit_level = -1; /* Set this to the level when our location first matches the locator. */

int done;


Reading the command line
 
int init(int argc, char * argv[]) {
   int i;
   char * mark;

   for (i=1; i < argc; i++) {
      if (*argv[i] == '-') {
         mark = argv[i];
         while (*mark++) {
           switch (*mark) {
              case 'c': emit_comments = 1; break;
              case 'o': emit_tags = 0; break;
              case 'e': emit_content = 0; break;
#ifndef XMLSET
              case 'm': emit_matching_tag = 0; break;
#endif
              case 'p': emit_pis = 1; break;
              case 'l': emit_locator = 1; break;
           }
         }
      }
#ifdef XMLINSERT
      else if (!insertwhere) { insertwhere = argv[i]; }
#endif
      else if (!stack.locator) { stack.locator = argv[i]; }
#ifdef XMLSET
      else if (!setattr) { setattr = argv[i]; }
      else if (!setvalue) { setvalue = argv[i]; }
#endif
      else if (!infile) { infile = argv[i]; }
   }
}
Previous: Data structures: frames and tags ] [ Top: xmltools index ] [ Next: Printing the current stack as a locator ]


This code and documentation are released under the terms of the GNU license. They are additionally copyright (c) 2000, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license.