Beispiel #1
0
const char *GWEN_XMLNode_GetCharValue(const GWEN_XMLNODE *n,
                                      const char *name,
                                      const char *defValue) {
  GWEN_XMLNODE *nn;

  if (name && *name) {
    nn=GWEN_XMLNode_FindFirstTag(n, name, 0, 0);

    while(nn) {
      GWEN_XMLNODE *dn;

      dn=GWEN_XMLNode_GetFirstData(nn);
      if (dn) {
	if (dn->data)
	  return dn->data;
      }
      nn=GWEN_XMLNode_FindNextTag(nn, name, 0, 0);
    }
  }
  else {
    GWEN_XMLNODE *dn;

    dn=GWEN_XMLNode_GetFirstData(n);
    if (dn) {
      if (dn->data)
	return dn->data;
    }
  }
  return defValue;
}
Beispiel #2
0
const char *GWEN_XMLNode_GetLocalizedCharValue(const GWEN_XMLNODE *n,
					       const char *name,
					       const char *defValue) {
  GWEN_XMLNODE *nn=0;
  GWEN_STRINGLIST *langl;

  langl=GWEN_I18N_GetCurrentLocaleList();
  if (langl) {
    GWEN_STRINGLISTENTRY *se;

    se=GWEN_StringList_FirstEntry(langl);
    while(se) {
      const char *l;

      l=GWEN_StringListEntry_Data(se);
      DBG_DEBUG(GWEN_LOGDOMAIN, "Trying locale \"%s\"", l);
      assert(l);
      nn=GWEN_XMLNode_FindFirstTag(n, name, "lang", l);
      while(nn) {
        GWEN_XMLNODE *dn;

        dn=GWEN_XMLNode_GetFirstData(nn);
        if (dn) {
          if (dn->data && *(dn->data))
            return dn->data;
        }
        nn=GWEN_XMLNode_FindNextTag(nn, name, "lang", l);
      } /* while nn */
      se=GWEN_StringListEntry_Next(se);
    } /* while */
  } /* if language list available */

  /* otherwise try without locale */
  nn=GWEN_XMLNode_FindFirstTag(n, name, 0, 0);
  while(nn) {
    GWEN_XMLNODE *dn;

    dn=GWEN_XMLNode_GetFirstData(nn);
    if (dn) {
      if (dn->data)
        return dn->data;
    }
    nn=GWEN_XMLNode_FindNextTag(nn, name, 0, 0);
  }

  return defValue;
}
Beispiel #3
0
const char *GWEN_XMLNode_GetCharValueByPath(GWEN_XMLNODE *n,
    const char *name,
    const char *defValue) {
  GWEN_XMLNODE *nn;

  nn=GWEN_XMLNode_GetNodeByXPath(n, name, 0);
  if (nn) {
    GWEN_XMLNODE *dn;

    dn=GWEN_XMLNode_GetFirstData(nn);
    if (dn) {
      if (dn->data)
        return dn->data;
    }
  }

  return defValue;
}
Beispiel #4
0
uint32_t LC_ReaderFlags_fromXml(GWEN_XMLNODE *node, const char *name){
  const char *p;
  uint32_t flags=0;
  GWEN_XMLNODE *n;

  n=GWEN_XMLNode_FindFirstTag(node, name, 0, 0);
  while(n) {
    GWEN_XMLNODE *nn;

    nn=GWEN_XMLNode_GetFirstData(n);
    if (nn) {
      p=GWEN_XMLNode_GetData(nn);
      assert(p);

      if (strcasecmp(p, "keypad")==0)
        flags|=LC_READER_FLAGS_KEYPAD;
      else if (strcasecmp(p, "display")==0)
        flags|=LC_READER_FLAGS_DISPLAY;
      else if (strcasecmp(p, "noinfo")==0)
        flags|=LC_READER_FLAGS_NOINFO;
      else if (strcasecmp(p, "remote")==0)
        flags|=LC_READER_FLAGS_REMOTE;
      else if (strcasecmp(p, "auto")==0)
        flags|=LC_READER_FLAGS_AUTO;
      else if (strcasecmp(p, "suspended_checks")==0)
        flags|=LC_READER_FLAGS_SUSPENDED_CHECKS;
      else if (strcasecmp(p, "driverHasVerify")==0)
        flags|=LC_READER_FLAGS_DRIVER_HAS_VERIFY;
      else if (strcasecmp(p, "keepRunning")==0)
        flags|=LC_READER_FLAGS_KEEP_RUNNING;
      else if (strcasecmp(p, "lowWriteBoundary")==0)
	flags|=LC_READER_FLAGS_LOW_WRITE_BOUNDARY;
      else if (strcasecmp(p, "noMemorySw")==0)
	flags|=LC_READER_FLAGS_NO_MEMORY_SW;
      else {
        DBG_WARN(0, "Unknown flag \"%s\", ignoring", p);
      }
    }
    n=GWEN_XMLNode_FindNextTag(n, name, 0, 0);
  } /* while */

  return flags;
}
Beispiel #5
0
void GWEN_DBIO__XmlDb_ReadDataTags(GWEN_XMLNODE *node, GWEN_BUFFER *buf) {
  GWEN_XMLNODE *ndata;
  GWEN_BUFFER *tbuf;
  int rv;

  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
  ndata=GWEN_XMLNode_GetFirstData(node);
  while(ndata) {
    const char *s;

    s=GWEN_XMLNode_GetData(ndata);
    if (s) {
      if (GWEN_Buffer_GetUsedBytes(tbuf))
	GWEN_Buffer_AppendByte(tbuf, ' ');
      GWEN_Buffer_AppendString(tbuf, s);
    }
    ndata=GWEN_XMLNode_GetNextData(node);
  }
  rv=GWEN_Text_UnescapeXmlToBuffer(GWEN_Buffer_GetStart(tbuf), buf);
  if (rv<0) {
    DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
  }
  GWEN_Buffer_free(tbuf);
}
Beispiel #6
0
AB_TRANSACTION *AB_ImExporterYN__ReadLNE_LNS(AB_IMEXPORTER *ie,
                                             AB_IMEXPORTER_ACCOUNTINFO *ai,
                                             GWEN_XMLNODE *node)
{
  AB_TRANSACTION *t;
  GWEN_XMLNODE *nn;
  GWEN_DATE *da=NULL;
  AB_VALUE *val=NULL;

  t=AB_Transaction_new();

  /* get date */
  nn=GWEN_XMLNode_FindFirstTag(node, "DTM", 0, 0);
  if (nn)
    da=AB_ImExporterYN__ReadDate(ie, nn, 209);
  AB_Transaction_SetValutaDate(t, da);
  GWEN_Date_free(da);
  da=NULL;

  /* read amount */
  nn=GWEN_XMLNode_FindFirstTag(node, "MOA", 0, 0);
  if (nn) {
    /* Gutschrift */
    val=AB_ImExporterYN__ReadValue(ie, nn, 210);
    if (val) {
      if (AB_Value_IsZero(val)) {
        AB_Value_free(val);
        val=NULL;
      }
    }
    if (val==NULL) {
      val=AB_ImExporterYN__ReadValue(ie, nn, 211);
      if (val)
        AB_Value_Negate(val);
    }
  }
  if (val==NULL)
    val=AB_Value_new();
  AB_Value_SetCurrency(val, AB_ImExporterAccountInfo_GetCurrency(ai));
  AB_Transaction_SetValue(t, val);
  AB_Value_free(val);
  val=0;

  /* read purpose */
  nn=GWEN_XMLNode_GetNodeByXPath(node, "FTX/C108",
                                 GWEN_PATH_FLAGS_NAMEMUSTEXIST);
  if (nn) {
    GWEN_XMLNODE *nnn;

    nnn=GWEN_XMLNode_FindFirstTag(nn, "D_4440", 0, 0);
    while (nnn) {
      GWEN_XMLNODE *nData;

      nData=GWEN_XMLNode_GetFirstData(nnn);
      if (nData) {
        const char *s;

        s=GWEN_XMLNode_GetData(nData);
        if (s) {
          GWEN_BUFFER *xbuf;

          xbuf=GWEN_Buffer_new(0, 256, 0, 1);
          AB_ImExporter_Iso8859_1ToUtf8(s, strlen(s), xbuf);
          AB_Transaction_AddPurposeLine(t, GWEN_Buffer_GetStart(xbuf));
          GWEN_Buffer_free(xbuf);
        }
      }
      nnn=GWEN_XMLNode_FindNextTag(nnn, "D_4440", 0, 0);
    }
  }

  return t;
}