Logo Search packages:      
Sourcecode: hal version File versions

static void start ( ParsingContext pc,
const char *  el,
const char **  attr 
) [static]

Called by expat when an element begins.

Parameters:
pc Parsing context
el Element name
attr Attribute key/value pairs

Definition at line 722 of file device_info.c.

References ParsingContext::aborted, ParsingContext::cdata_buf_len, ParsingContext::curelem, CURELEM_APPEND, CURELEM_DEVICE, CURELEM_DEVICE_INFO, CURELEM_MATCH, CURELEM_MERGE, ParsingContext::curelem_stack, CURELEM_UNKNOWN, ParsingContext::depth, ParsingContext::file, HAL_ERROR, handle_append(), handle_match(), handle_merge(), ParsingContext::match_depth_first_fail, ParsingContext::match_ok, MAX_DEPTH, ParsingContext::parser, and parsing_abort().

Referenced by process_fdi_file().

{
      if (pc->aborted)
            return;

      pc->cdata_buf_len = 0;

/*
    for (i = 0; i < pc->depth; i++)
        printf("  ");
    
    printf("%s", el);
    
    for (i = 0; attr[i]; i += 2) {
        printf(" %s='%s'", attr[i], attr[i + 1]);
    }

    printf("   curelem=%d\n", pc->curelem);
*/

      if (strcmp (el, "match") == 0) {
            if (pc->curelem != CURELEM_DEVICE
                && pc->curelem != CURELEM_MATCH) {
                  HAL_ERROR (("%s:%d:%d: Element <match> can only be "
                            "inside <device> and <match>", 
                            pc->file, 
                            XML_GetCurrentLineNumber (pc->parser), 
                            XML_GetCurrentColumnNumber (pc->parser)));
                  parsing_abort (pc);
            }

            pc->curelem = CURELEM_MATCH;

            /* don't bother checking if matching at lower depths failed */
            if (pc->match_ok) {
                  if (!handle_match (pc, attr)) {
                        /* No match */
                        pc->match_depth_first_fail = pc->depth;
                        pc->match_ok = FALSE;
                  }
            }
      } else if (strcmp (el, "merge") == 0) {
            if (pc->curelem != CURELEM_DEVICE
                && pc->curelem != CURELEM_MATCH) {
                  HAL_ERROR (("%s:%d:%d: Element <merge> can only be "
                            "inside <device> and <match>", 
                            pc->file, 
                            XML_GetCurrentLineNumber (pc->parser), 
                            XML_GetCurrentColumnNumber (pc->parser)));
                  parsing_abort (pc);
            }

            pc->curelem = CURELEM_MERGE;
            if (pc->match_ok) {
                  handle_merge (pc, attr);
            } else {
                  /*HAL_INFO(("No merge!")); */
            }
      } else if (strcmp (el, "append") == 0) {
            if (pc->curelem != CURELEM_DEVICE
                && pc->curelem != CURELEM_MATCH) {
                  HAL_ERROR (("%s:%d:%d: Element <append> can only be "
                            "inside <device> and <match>", 
                            pc->file, 
                            XML_GetCurrentLineNumber (pc->parser), 
                            XML_GetCurrentColumnNumber (pc->parser)));
                  parsing_abort (pc);
            }

            pc->curelem = CURELEM_APPEND;
            if (pc->match_ok) {
                  handle_append (pc, attr);
            } else {
                  /*HAL_INFO(("No merge!")); */
            }
      } else if (strcmp (el, "device") == 0) {
            if (pc->curelem != CURELEM_DEVICE_INFO) {
                  HAL_ERROR (("%s:%d:%d: Element <device> can only be "
                            "inside <deviceinfo>", 
                            pc->file, 
                            XML_GetCurrentLineNumber (pc->parser), 
                            XML_GetCurrentColumnNumber (pc->parser)));
                  parsing_abort (pc);
            }
            pc->curelem = CURELEM_DEVICE;
      } else if (strcmp (el, "deviceinfo") == 0) {
            if (pc->curelem != CURELEM_UNKNOWN) {
                  HAL_ERROR (("%s:%d:%d: Element <deviceinfo> must be "
                            "a top-level element", 
                            pc->file, 
                            XML_GetCurrentLineNumber (pc->parser), 
                            XML_GetCurrentColumnNumber (pc->parser)));
                  parsing_abort (pc);
            }
            pc->curelem = CURELEM_DEVICE_INFO;
      } else {
            HAL_ERROR (("%s:%d:%d: Unknown element <%s>",
                      pc->file,
                      XML_GetCurrentLineNumber (pc->parser),
                      XML_GetCurrentColumnNumber (pc->parser), el));
            parsing_abort (pc);
      }

      /* Nasty hack */
      assert (pc->depth < MAX_DEPTH);

      pc->depth++;

      /* store depth */
      pc->curelem_stack[pc->depth] = pc->curelem;

}


Generated by  Doxygen 1.6.0   Back to index