Esempio n. 1
0
static void
startElement(struct solv_xmlparser *xmlp, int state, const char *name, const char **atts)
{
  struct parsedata *pd = xmlp->userdata;
  Pool *pool = pd->pool;
  Solvable *s = pd->solvable;

  switch(state)
    {
    case STATE_PRODUCT:
      {
	/* parse 'type' */
	const char *type = solv_xmlparser_find_attr("type", atts);
	s = pd->solvable = pool_id2solvable(pool, repo_add_solvable(pd->repo));
	pd->handle = s - pool->solvables;
	if (type)
	  repodata_set_str(pd->data, pd->handle, PRODUCT_TYPE, type);
      }
      break;
    case STATE_VERSION:
      {
	const char *ver = solv_xmlparser_find_attr("ver", atts);
	const char *rel = solv_xmlparser_find_attr("rel", atts);
	/* const char *epoch = solv_xmlparser_find_attr("epoch", atts); ignored */
	s->evr = makeevr(pd->pool, join2(&pd->jd, ver, "-", rel));
      }
      break;
    case STATE_SUMMARY:		/* <summary lang="xy">... */
      pd->tmplang = join_dup(&pd->jd, solv_xmlparser_find_attr("lang", atts));
      break;
    default:
      break;
    }
}
Esempio n. 2
0
static void XMLCALL
startElement(void *userData, const char *name, const char **atts)
{
  struct parsedata *pd = userData;
  Pool *pool = pd->pool;
  Solvable *s = pd->solvable;
  struct stateswitch *sw;

#if 0
  fprintf(stderr, "start: [%d]%s\n", pd->state, name);
#endif
  if (pd->depth != pd->statedepth)
    {
      pd->depth++;
      return;
    }

  pd->depth++;
  if (!pd->swtab[pd->state])	/* no statetable -> no substates */
    {
#if 0
      fprintf(stderr, "into unknown: %s (from: %d)\n", name, pd->state);
#endif
      return;
    }
  for (sw = pd->swtab[pd->state]; sw->from == pd->state; sw++)  /* find name in statetable */
    if (!strcmp(sw->ename, name))
      break;

  if (sw->from != pd->state)
    {
#if 0
      fprintf(stderr, "into unknown: %s (from: %d)\n", name, pd->state);
#endif
      return;
    }
  pd->state = sw->to;
  pd->docontent = sw->docontent;
  pd->statedepth = pd->depth;
  pd->lcontent = 0;
  *pd->content = 0;

  switch(pd->state)
    {
    case STATE_PRODUCT:
      /* parse 'schemeversion' and store in global variable */
      {
        const char * scheme = find_attr("schemeversion", atts);
        pd->productscheme = (scheme && *scheme) ? atoi(scheme) : -1;
      }
      if (!s)
	{
	  s = pd->solvable = pool_id2solvable(pool, repo_add_solvable(pd->repo));
	  pd->handle = s - pool->solvables;
	}
      break;

      /* <summary lang="xy">... */
    case STATE_SUMMARY:
    case STATE_DESCRIPTION:
      pd->tmplang = join_dup(&pd->jd, find_attr("lang", atts));
      break;
    case STATE_URL:
      pd->urltype = pool_str2id(pd->pool, find_attr("name", atts), 1);
      break;
    case STATE_REGUPDREPO:
      {
        const char *repoid = find_attr("repoid", atts);
	if (repoid && *repoid)
          repodata_add_poolstr_array(pd->data, pd->handle, PRODUCT_UPDATES_REPOID, repoid);
      }
    default:
      break;
    }
}