Exemplo n.º 1
0
int GWEN_Directory_FindPathForFile(const GWEN_STRINGLIST *paths,
                                   const char *filePath,
                                   GWEN_BUFFER *fbuf) {
  GWEN_STRINGLISTENTRY *se;

  se=GWEN_StringList_FirstEntry(paths);
  while(se) {
    GWEN_BUFFER *tbuf;
    FILE *f;

    tbuf=GWEN_Buffer_new(0, 256, 0, 1);
    GWEN_Buffer_AppendString(tbuf, GWEN_StringListEntry_Data(se));
    GWEN_Buffer_AppendString(tbuf, DIRSEP);
    GWEN_Buffer_AppendString(tbuf, filePath);
    DBG_VERBOUS(GWEN_LOGDOMAIN, "Trying \"%s\"",
                GWEN_Buffer_GetStart(tbuf));
    f=fopen(GWEN_Buffer_GetStart(tbuf), "r");
    if (f) {
      fclose(f);
      DBG_INFO(GWEN_LOGDOMAIN,
               "File \"%s\" found in folder \"%s\"",
               filePath,
               GWEN_StringListEntry_Data(se));
      GWEN_Buffer_AppendString(fbuf, GWEN_StringListEntry_Data(se));
      GWEN_Buffer_free(tbuf);
      return 0;
    }
    GWEN_Buffer_free(tbuf);

    se=GWEN_StringListEntry_Next(se);
  }

  DBG_INFO(GWEN_LOGDOMAIN, "File \"%s\" not found", filePath);
  return GWEN_ERROR_NOT_FOUND;
}
Exemplo n.º 2
0
int AB_SetupNewUserDialog_DetermineBackendIndex(GWEN_DIALOG *dlg) {
  AB_SETUP_NEWUSER_DIALOG *xdlg;
  GWEN_STRINGLISTENTRY *se;
  int i=0;

  assert(dlg);
  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AB_SETUP_NEWUSER_DIALOG, dlg);
  assert(xdlg);

  se=GWEN_StringList_FirstEntry(xdlg->backendRadioNames);
  while(se) {
    const char *s;

    s=GWEN_StringListEntry_Data(se);
    if (GWEN_Dialog_GetIntProperty(dlg, s, GWEN_DialogProperty_Value, 0, 0))
      break;
    i++;
    se=GWEN_StringListEntry_Next(se);
  }

  if (se)
    return i;

  return -1;
}
Exemplo n.º 3
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;
}
Exemplo n.º 4
0
int GWEN_Crypt_Token_ModuleInit(void)
{
  GWEN_PLUGIN_MANAGER *pm;
  int err;
  GWEN_STRINGLIST *sl;

  pm=GWEN_PluginManager_new(GWEN_CRYPT_TOKEN_PLUGIN_TYPENAME, GWEN_PM_LIBNAME);
  err=GWEN_PluginManager_Register(pm);
  if (err) {
    DBG_ERROR(GWEN_LOGDOMAIN, "Could not register CryptToken plugin manager");
    return err;
  }

  /* create plugin paths */
  sl=GWEN_PathManager_GetPaths(GWEN_PM_LIBNAME, GWEN_PM_PLUGINDIR);
  if (sl) {
    GWEN_STRINGLISTENTRY *se;
    GWEN_BUFFER *pbuf;

    pbuf=GWEN_Buffer_new(0, 256, 0, 1);

    se=GWEN_StringList_FirstEntry(sl);
    while (se) {
      GWEN_Buffer_AppendString(pbuf, GWEN_StringListEntry_Data(se));
      GWEN_Buffer_AppendString(pbuf, DIRSEP GWEN_CRYPT_TOKEN_FOLDER);
      DBG_INFO(GWEN_LOGDOMAIN, "Adding plugin path [%s]",
               GWEN_Buffer_GetStart(pbuf));
      GWEN_PluginManager_AddPath(pm, GWEN_PM_LIBNAME,
                                 GWEN_Buffer_GetStart(pbuf));
      GWEN_Buffer_Reset(pbuf);
      se=GWEN_StringListEntry_Next(se);
    }
    GWEN_Buffer_free(pbuf);
    GWEN_StringList_free(sl);
  }

  return 0;
}
Exemplo n.º 5
0
void FOX16_HtmlLabel::updateHtml() {
  GWEN_STRINGLISTENTRY *se;

  if (m_htmlCtx)
    delete m_htmlCtx;
  m_haveDefaultDims=false;
  m_htmlCtx=new FOX16_HtmlCtx(0);
  /* copy media paths to context */
  se=GWEN_StringList_FirstEntry(m_mediaPaths);
  while(se) {
    const char *s;

    s=GWEN_StringListEntry_Data(se);
    assert(s);
    m_htmlCtx->addMediaPath(s);
    se=GWEN_StringListEntry_Next(se);
  }

  m_htmlCtx->setBackgroundColor(backColor);
  m_htmlCtx->setForegroundColor(fxcolorfromname("black"));
  m_htmlCtx->setText(m_text.text());
  flags|=FLAG_DIRTY;
}
Exemplo n.º 6
0
const char *AH_User_FindSepaDescriptor(AB_USER *u, const char *tmpl) {
  AH_USER *ue;
  GWEN_STRINGLISTENTRY *se;

  assert(u);
  ue=GWEN_INHERIT_GETDATA(AB_USER, AH_USER, u);
  assert(ue);

  if (GWEN_StringList_Count(ue->sepaDescriptors)<1)
    AH_User_LoadSepaDescriptors(u);

  se=GWEN_StringList_FirstEntry(ue->sepaDescriptors);
  while(se) {
    const char *s;

    s=GWEN_StringListEntry_Data(se);
    if (s && *s && -1!=GWEN_Text_ComparePattern(s, tmpl, 1))
      return s;

    se=GWEN_StringListEntry_Next(se);
  }

  return NULL;
}
Exemplo n.º 7
0
static int addToList(const char *fname, int recursive, GWEN_STRINGLIST *sl) {
  struct stat st;
  int rv;

  /* stat file to be added */
#if _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
  rv=lstat(fname, &st);
#else
  rv=stat(fname, &st);
#endif
  if (rv) {
    DBG_ERROR(GSA_LOGDOMAIN, "stat(%s): %d (%s)",
              fname, errno, strerror(errno));
    fprintf(stderr, "Ignoring file \"%s\"\n", fname);
  }
  else {
    /* always append this entry */
    GWEN_StringList_AppendString(sl, fname, 0, 1);
    if (recursive && S_ISDIR(st.st_mode)) {
      GWEN_STRINGLIST *sll;
      GWEN_STRINGLISTENTRY *se;
      GWEN_DIRECTORY *d;
      int rv;
      char buffer[256];
      GWEN_BUFFER *tbuf;
      uint32_t pos;

      /* add entries */
      sll=GWEN_StringList_new();
      d=GWEN_Directory_new();
      rv=GWEN_Directory_Open(d, fname);
      if (rv<0) {
        DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
        GWEN_Directory_free(d);
        GWEN_StringList_free(sll);
        return rv;
      }

      while(0==GWEN_Directory_Read(d, buffer, sizeof(buffer))) {
        if (strcmp(buffer, ".")!=0 &&
            strcmp(buffer, "..")!=0)
          GWEN_StringList_AppendString(sll, buffer, 0, 1);
      }

      GWEN_Directory_Close(d);
      GWEN_Directory_free(d);

      /* recurse */
      tbuf=GWEN_Buffer_new(0, 256, 0, 1);
      GWEN_Buffer_AppendString(tbuf, fname);
      GWEN_Buffer_AppendString(tbuf, GWEN_DIR_SEPARATOR_S);
      pos=GWEN_Buffer_GetPos(tbuf);
      se=GWEN_StringList_FirstEntry(sll);
      while(se) {
        const char *s;

        s=GWEN_StringListEntry_Data(se);
        if (s && *s) {
          GWEN_Buffer_AppendString(tbuf, s);
          rv=addToList(GWEN_Buffer_GetStart(tbuf), recursive, sl);
          if (rv<0) {
            DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
            GWEN_Buffer_free(tbuf);
            GWEN_StringList_free(sll);
            return rv;
          }
        }
        GWEN_Buffer_Crop(tbuf, 0, pos);
        se=GWEN_StringListEntry_Next(se);
      } /* while se */
      GWEN_Buffer_free(tbuf);
      GWEN_StringList_free(sll);
    } /* if dir and recursive */
  } /* if stat was ok */

  return 0;
}
Exemplo n.º 8
0
int add2Archive(GWEN_DB_NODE *dbArgs, int argc, char **argv) {
  GWEN_DB_NODE *db;
  const char *aname;
  GWEN_SAR *sr;
  int rv;
  int recursive;
  int verbosity;
  const GWEN_ARGS args[]={
  {
    GWEN_ARGS_FLAGS_HAS_ARGUMENT,     /* flags */
    GWEN_ArgsType_Char,               /* type */
    "archive",                        /* name */
    1,                                /* minnum */
    1,                                /* maxnum */
    "a",                              /* short option */
    "archive",                        /* long option */
    "Specify the archive file name",  /* short description */
    "Specify the archive file name"   /* long description */
  },
  {
    0, /* flags */
    GWEN_ArgsType_Int,                /* type */
    "recursive",                      /* name */
    0,                                /* minnum */
    1,                                /* maxnum */
    "r",                              /* short option */
    "recursive",                      /* long option */
    "add folders recursively",        /* short description */
    "add folders recursively"         /* long description */
  },
  {
    0, /* flags */
    GWEN_ArgsType_Int,                /* type */
    "verbosity",                      /* name */
    0,                                /* minnum */
    10,                                /* maxnum */
    "v",                              /* short option */
    NULL,                             /* long option */
    "set verbosity",                  /* short description */
    "set verbosity"                   /* long description */
  },
  {
    GWEN_ARGS_FLAGS_HELP | GWEN_ARGS_FLAGS_LAST, /* flags */
    GWEN_ArgsType_Int,             /* type */
    "help",                       /* name */
    0,                            /* minnum */
    0,                            /* maxnum */
    "h",                          /* short option */
    "help",                       /* long option */
    "Show this help screen",      /* short description */
    "Show this help screen"       /* long description */
  }
  };

  db=GWEN_DB_GetGroup(dbArgs, GWEN_DB_FLAGS_DEFAULT, "local");
  rv=GWEN_Args_Check(argc, argv, 1,
                     GWEN_ARGS_MODE_ALLOW_FREEPARAM,
                     args,
                     db);
  if (rv==GWEN_ARGS_RESULT_ERROR) {
    fprintf(stderr, "ERROR: Could not parse arguments\n");
    return 1;
  }
  else if (rv==GWEN_ARGS_RESULT_HELP) {
    GWEN_BUFFER *ubuf;

    ubuf=GWEN_Buffer_new(0, 1024, 0, 1);
    if (GWEN_Args_Usage(args, ubuf, GWEN_ArgsOutType_Txt)) {
      fprintf(stderr, "ERROR: Could not create help string\n");
      return 1;
    }
    fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(ubuf));
    GWEN_Buffer_free(ubuf);
    return 0;
  }

  aname=GWEN_DB_GetCharValue(db, "archive", 0, NULL);
  assert(aname);

  recursive=GWEN_DB_GetIntValue(db, "recursive", 0, 0);
  verbosity=GWEN_DB_GetIntValue(db, "verbosity", 0, 0);

  sr=GWEN_Sar_new();
  rv=GWEN_Sar_OpenArchive(sr, aname,
                          GWEN_SyncIo_File_CreationMode_OpenExisting,
                          GWEN_SYNCIO_FILE_FLAGS_READ|GWEN_SYNCIO_FILE_FLAGS_WRITE);
  if (rv<0) {
    fprintf(stderr, "ERROR: Error opening archive (%d)\n", rv);
    return 2;
  }
  else {
    int i;
    GWEN_STRINGLIST *sl;
    GWEN_STRINGLISTENTRY *se;

    sl=GWEN_StringList_new();
    for (i=0; ; i++) {
      const char *fname;

      fname=GWEN_DB_GetCharValue(db, "params", i, 0);
      if (fname && *fname) {
        rv=addToList(fname, recursive, sl);
        if (rv<0) {
          fprintf(stderr, "ERROR: Error adding entry \"%s\" to archive \"%s\" (%d)\n",
                  fname, aname, rv);
          GWEN_StringList_free(sl);
          return 2;
        }
      }
      else
        break;
    }

    se=GWEN_StringList_FirstEntry(sl);
    while(se) {
      const char *s;

      s=GWEN_StringListEntry_Data(se);
      if (s && *s) {
        rv=GWEN_Sar_AddFile(sr, s);
        if (rv<0) {
          fprintf(stderr, "ERROR: Error adding file \"%s\" to archive \"%s\" (%d)\n",
                  s, aname, rv);
          GWEN_Sar_CloseArchive(sr, 1);
          GWEN_Sar_free(sr);
          return 2;
        }
        if (verbosity>0) {
          fprintf(stdout, "added \"%s\"\n", s);
        }
      }
      se=GWEN_StringListEntry_Next(se);
    } /* while se */

    GWEN_StringList_free(sl);

    rv=GWEN_Sar_CloseArchive(sr, 0);
    if (rv<0) {
      fprintf(stderr, "ERROR: Error closing archive (%d)\n", rv);
      return 2;
    }

    return 0;
  }
}
Exemplo n.º 9
0
int doBuildDefs(GWEN_DB_NODE *dbArgs, const char *fname) {
  TYPEMAKER2_TYPEMANAGER *tym;
  TYPEMAKER2_BUILDER *tb=NULL;
  TYPEMAKER2_TYPE *ty;
  GWEN_STRINGLIST *sl;
  TYPEMAKER2_TYPE_LIST2 *tlist;
  TYPEMAKER2_TYPE_LIST2_ITERATOR *it;
  const char *s;
  int i;
  int rv;

  tym=Typemaker2_TypeManager_new();

  s=GWEN_DB_GetCharValue(dbArgs, "api", 0, NULL);
  if (s && *s)
    Typemaker2_TypeManager_SetApiDeclaration(tym, s);

  s=GWEN_DB_GetCharValue(dbArgs, "language", 0, "c");
  if (s && *s) {
    Typemaker2_TypeManager_SetLanguage(tym, s);
    if (strcasecmp(s, "c")==0) {
      tb=Typemaker2_Builder_C_new();
      Typemaker2_Builder_SetTypeManager(tb, tym);
    }
    else {
      DBG_ERROR(GWEN_LOGDOMAIN, "Unsupported language [%s]", s);
      return 1;
    }
  }
  else {
    DBG_ERROR(GWEN_LOGDOMAIN, "Missing language specification");
    return 1;
  }

  Typemaker2_Builder_SetSourceFileName(tb, fname);

  for (i=0; i<99; i++) {
    s=GWEN_DB_GetCharValue(dbArgs, "include", i, NULL);
    if (s && *s)
      Typemaker2_TypeManager_AddFolder(tym, s);
    else
      break;
  }

  sl=GWEN_PathManager_GetPaths(GWEN_PM_LIBNAME, GWEN_PM_DATADIR);
  if (sl) {
    GWEN_STRINGLISTENTRY *se;

    se=GWEN_StringList_FirstEntry(sl);
    while(se) {
      s=GWEN_StringListEntry_Data(se);
      if (s) {
	GWEN_BUFFER *xbuf;

	xbuf=GWEN_Buffer_new(0, 256, 0, 1);
	GWEN_Buffer_AppendString(xbuf, s);
	GWEN_Buffer_AppendString(xbuf, "/typemaker2/");
        s=Typemaker2_TypeManager_GetLanguage(tym);
	if (s && *s)
	  GWEN_Buffer_AppendString(xbuf, s);
	Typemaker2_TypeManager_AddFolder(tym, GWEN_Buffer_GetStart(xbuf));
        GWEN_Buffer_free(xbuf);
      }
      se=GWEN_StringListEntry_Next(se);
    }
    GWEN_StringList_free(sl);
  }

  tlist=Typemaker2_Type_List2_new();
  rv=Typemaker2_TypeManager_LoadTypeFileNoLookup(tym, fname, tlist);
  if (rv<0) {
    DBG_ERROR(GWEN_LOGDOMAIN, "Unable to load file [%s] (%d)", fname, rv);
    return 2;
  }

  it=Typemaker2_Type_List2_First(tlist);
  if(it) {
    ty=Typemaker2_Type_List2Iterator_Data(it);
    while(ty) {
      /* DEBUG */
#if 0
      Typemaker2_TypeManager_Dump(tym, stderr, 2);
#endif

      /* only write typedef files */
      rv=Typemaker2_Builder_WriteFiles(tb, ty, 1);
      if (rv<0) {
        DBG_ERROR(GWEN_LOGDOMAIN, "here (%d)", rv);
        return 2;
      }


      /* handle next type */
      ty=Typemaker2_Type_List2Iterator_Next(it);
    }
    Typemaker2_Type_List2Iterator_free(it);
  }
  Typemaker2_Type_List2_free(tlist);


  return 0;
}
Exemplo n.º 10
0
int AB_TransactionLimits_toDb(const AB_TRANSACTION_LIMITS *st, GWEN_DB_NODE *db) {
  assert(st);
  assert(db);
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxLenLocalName", st->maxLenLocalName))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minLenLocalName", st->minLenLocalName))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxLenRemoteName", st->maxLenRemoteName))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minLenRemoteName", st->minLenRemoteName))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxLinesRemoteName", st->maxLinesRemoteName))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minLinesRemoteName", st->minLinesRemoteName))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxLenLocalBankCode", st->maxLenLocalBankCode))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minLenLocalBankCode", st->minLenLocalBankCode))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxLenLocalAccountNumber", st->maxLenLocalAccountNumber))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minLenLocalAccountNumber", st->minLenLocalAccountNumber))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxLenLocalSuffix", st->maxLenLocalSuffix))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minLenLocalSuffix", st->minLenLocalSuffix))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxLenRemoteBankCode", st->maxLenRemoteBankCode))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minLenRemoteBankCode", st->minLenRemoteBankCode))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxLenRemoteAccountNumber", st->maxLenRemoteAccountNumber))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minLenRemoteAccountNumber", st->minLenRemoteAccountNumber))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxLenRemoteSuffix", st->maxLenRemoteSuffix))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minLenRemoteSuffix", st->minLenRemoteSuffix))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxLenRemoteIban", st->maxLenRemoteIban))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minLenRemoteIban", st->minLenRemoteIban))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxLenTextKey", st->maxLenTextKey))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minLenTextKey", st->minLenTextKey))
    return -1;
  if (st->valuesTextKey)
    {
      GWEN_STRINGLISTENTRY *se;

      GWEN_DB_DeleteVar(db, "valuesTextKey");
      se=GWEN_StringList_FirstEntry(st->valuesTextKey);
      while(se) {
        const char *s;

        s=GWEN_StringListEntry_Data(se);
        assert(s);
        if (GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_DEFAULT, "valuesTextKey", s))
          return -1;
        se=GWEN_StringListEntry_Next(se);
      } /* while */
    }
  if (st->textKeys)
  if (1) {
    GWEN_DB_NODE *dbT;
    AB_TEXTKEY_DESCR *e;

    dbT=GWEN_DB_GetGroup(db, GWEN_PATH_FLAGS_CREATE_GROUP, "textKeys");
    assert(dbT);
    e=AB_TextKeyDescr_List_First(st->textKeys);
    while(e) {
      if (AB_TextKeyDescr_toDb(e, GWEN_DB_GetGroup(dbT, GWEN_PATH_FLAGS_CREATE_GROUP, "element")))
        return -1;
      e=AB_TextKeyDescr_List_Next(e);
    } /* while */
  } /* if (1) */
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxLenCustomerReference", st->maxLenCustomerReference))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minLenCustomerReference", st->minLenCustomerReference))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxLenBankReference", st->maxLenBankReference))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minLenBankReference", st->minLenBankReference))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxLenPurpose", st->maxLenPurpose))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minLenPurpose", st->minLenPurpose))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxLinesPurpose", st->maxLinesPurpose))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minLinesPurpose", st->minLinesPurpose))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "needDate", st->needDate))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minValueSetupTime", st->minValueSetupTime))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxValueSetupTime", st->maxValueSetupTime))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minValueSetupTimeFirst", st->minValueSetupTimeFirst))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxValueSetupTimeFirst", st->maxValueSetupTimeFirst))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minValueSetupTimeOnce", st->minValueSetupTimeOnce))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxValueSetupTimeOnce", st->maxValueSetupTimeOnce))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minValueSetupTimeRecurring", st->minValueSetupTimeRecurring))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxValueSetupTimeRecurring", st->maxValueSetupTimeRecurring))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "minValueSetupTimeFinal", st->minValueSetupTimeFinal))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "maxValueSetupTimeFinal", st->maxValueSetupTimeFinal))
    return -1;
  if (st->valuesCycleWeek)
    {
      GWEN_STRINGLISTENTRY *se;

      GWEN_DB_DeleteVar(db, "valuesCycleWeek");
      se=GWEN_StringList_FirstEntry(st->valuesCycleWeek);
      while(se) {
        const char *s;

        s=GWEN_StringListEntry_Data(se);
        assert(s);
        if (GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_DEFAULT, "valuesCycleWeek", s))
          return -1;
        se=GWEN_StringListEntry_Next(se);
      } /* while */
    }
  if (st->valuesCycleMonth)
    {
      GWEN_STRINGLISTENTRY *se;

      GWEN_DB_DeleteVar(db, "valuesCycleMonth");
      se=GWEN_StringList_FirstEntry(st->valuesCycleMonth);
      while(se) {
        const char *s;

        s=GWEN_StringListEntry_Data(se);
        assert(s);
        if (GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_DEFAULT, "valuesCycleMonth", s))
          return -1;
        se=GWEN_StringListEntry_Next(se);
      } /* while */
    }
  if (st->valuesExecutionDayWeek)
    {
      GWEN_STRINGLISTENTRY *se;

      GWEN_DB_DeleteVar(db, "valuesExecutionDayWeek");
      se=GWEN_StringList_FirstEntry(st->valuesExecutionDayWeek);
      while(se) {
        const char *s;

        s=GWEN_StringListEntry_Data(se);
        assert(s);
        if (GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_DEFAULT, "valuesExecutionDayWeek", s))
          return -1;
        se=GWEN_StringListEntry_Next(se);
      } /* while */
    }
  if (st->valuesExecutionDayMonth)
    {
      GWEN_STRINGLISTENTRY *se;

      GWEN_DB_DeleteVar(db, "valuesExecutionDayMonth");
      se=GWEN_StringList_FirstEntry(st->valuesExecutionDayMonth);
      while(se) {
        const char *s;

        s=GWEN_StringListEntry_Data(se);
        assert(s);
        if (GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_DEFAULT, "valuesExecutionDayMonth", s))
          return -1;
        se=GWEN_StringListEntry_Next(se);
      } /* while */
    }
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "allowMonthly", st->allowMonthly))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "allowWeekly", st->allowWeekly))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "allowChangeRecipientAccount", st->allowChangeRecipientAccount))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "allowChangeRecipientName", st->allowChangeRecipientName))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "allowChangeValue", st->allowChangeValue))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "allowChangeTextKey", st->allowChangeTextKey))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "allowChangePurpose", st->allowChangePurpose))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "allowChangeFirstExecutionDate", st->allowChangeFirstExecutionDate))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "allowChangeLastExecutionDate", st->allowChangeLastExecutionDate))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "allowChangeCycle", st->allowChangeCycle))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "allowChangePeriod", st->allowChangePeriod))
    return -1;
  if (GWEN_DB_SetIntValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "allowChangeExecutionDay", st->allowChangeExecutionDay))
    return -1;
  return 0;
}
Exemplo n.º 11
0
int AB_Banking_LoadAllAccounts(AB_BANKING *ab) {
  GWEN_STRINGLIST *sl;
  int rv;

  sl=GWEN_StringList_new();
  rv=GWEN_ConfigMgr_ListSubGroups(ab->configMgr, AB_CFG_GROUP_ACCOUNTS, sl);
  if (rv<0) {
    DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d)", rv);
    GWEN_StringList_free(sl);
    return rv;
  }
  if (GWEN_StringList_Count(sl)) {
    GWEN_STRINGLISTENTRY *se;

    se=GWEN_StringList_FirstEntry(sl);
    while(se) {
      const char *t;
      GWEN_DB_NODE *db=NULL;

      t=GWEN_StringListEntry_Data(se);
      assert(t);

      rv=GWEN_ConfigMgr_GetGroup(ab->configMgr, AB_CFG_GROUP_ACCOUNTS, t, &db);
      if (rv<0) {
	DBG_WARN(AQBANKING_LOGDOMAIN,
		 "Could not load account group [%s] (%d), ignoring",
		 t, rv);
      }
      else {
	AB_ACCOUNT *a=NULL;
	uint32_t uid;

        assert(db);
	uid=GWEN_DB_GetIntValue(db, "uniqueId", 0, 0);
	if (uid)
	  a=AB_Banking_GetAccount(ab, uid);
	if (a) {
	  /* account already exists, reload existing account */
	  const char *s;
	  AB_PROVIDER *pro;

          AB_Account_SetDbId(a, t);
	  s=AB_Account_GetBackendName(a);
	  assert(s && *s);
	  pro=AB_Banking_GetProvider(ab, s);
	  if (!pro) {
	    DBG_WARN(AQBANKING_LOGDOMAIN,
		     "Provider \"%s\" not found, ignoring account [%s/%s]",
		     s,
		     AB_Account_GetBankCode(a),
		     AB_Account_GetAccountNumber(a));
	  }
	  else {
	    int rv;
	    GWEN_DB_NODE *dbP;

            /* reload account from DB */
	    AB_Account_ReadDb(a, db);

            /* let provider also reload account data */
	    dbP=GWEN_DB_GetGroup(db, GWEN_DB_FLAGS_DEFAULT,
				 "data/backend");
	    rv=AB_Provider_ExtendAccount(pro, a, AB_ProviderExtendMode_Reload, dbP);
	    if (rv<0) {
	      DBG_WARN(AQBANKING_LOGDOMAIN, "Could not extend account [%s/%s] (%d)",
		       AB_Account_GetBankCode(a), AB_Account_GetAccountNumber(a), rv);
	    }
	  }
	}
	else {
          /* account is new, load and add it */
	  a=AB_Account_fromDb(ab, db);
	  if (a) {
	    const char *s;
	    AB_PROVIDER *pro;
  
	    AB_Account_SetDbId(a, t);
	    s=AB_Account_GetBackendName(a);
	    assert(s && *s);
	    pro=AB_Banking_GetProvider(ab, s);
	    if (!pro) {
	      DBG_WARN(AQBANKING_LOGDOMAIN,
		       "Provider \"%s\" not found, ignoring account [%s/%s]",
		       s, AB_Account_GetBankCode(a), AB_Account_GetAccountNumber(a));
	    }
	    else {
	      int rv;
	      GWEN_DB_NODE *dbP;
  
	      dbP=GWEN_DB_GetGroup(db, GWEN_DB_FLAGS_DEFAULT,
				   "data/backend");
	      rv=AB_Provider_ExtendAccount(pro, a, AB_ProviderExtendMode_Extend, dbP);
	      if (rv) {
		DBG_INFO(AQBANKING_LOGDOMAIN, "here");
		AB_Account_free(a);
	      }
	      else {
		DBG_DEBUG(AQBANKING_LOGDOMAIN, "Adding account");
		AB_Account_List_Add(a, ab->accounts);
	      }
	    }
	  }
	}
        GWEN_DB_Group_free(db);
      }
      se=GWEN_StringListEntry_Next(se);
    }
  }
  GWEN_StringList_free(sl);

  return 0;
}
Exemplo n.º 12
0
int AB_Banking_LoadAllUsers(AB_BANKING *ab) {
  GWEN_STRINGLIST *sl;
  int rv;

  sl=GWEN_StringList_new();
  rv=GWEN_ConfigMgr_ListSubGroups(ab->configMgr, AB_CFG_GROUP_USERS, sl);
  if (rv<0) {
    DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d)", rv);
    GWEN_StringList_free(sl);
    return rv;
  }
  if (GWEN_StringList_Count(sl)) {
    GWEN_STRINGLISTENTRY *se;

    se=GWEN_StringList_FirstEntry(sl);
    while(se) {
      const char *t;
      GWEN_DB_NODE *db=NULL;

      t=GWEN_StringListEntry_Data(se);
      assert(t);

      rv=GWEN_ConfigMgr_GetGroup(ab->configMgr, AB_CFG_GROUP_USERS, t, &db);
      if (rv<0) {
	DBG_WARN(AQBANKING_LOGDOMAIN,
		 "Could not load user group [%s] (%d), ignoring",
		 t, rv);
      }
      else {
	AB_USER *u=NULL;
	uint32_t uid;

        assert(db);
	uid=GWEN_DB_GetIntValue(db, "uniqueId", 0, 0);
	if (uid)
	  u=AB_Banking_GetUser(ab, uid);
	if (u) {
	  /* user already exists, reload existing user */
	  const char *s;
	  AB_PROVIDER *pro=NULL;

	  DBG_INFO(AQBANKING_LOGDOMAIN,
		   "Loading established user [%08x]",
		   (unsigned int) uid);
	  AB_User_SetDbId(u, t);
	  s=AB_User_GetBackendName(u);
          if (s && *s)
	    pro=AB_Banking_GetProvider(ab, s);
	  if (!pro) {
	    DBG_WARN(AQBANKING_LOGDOMAIN,
		     "Provider \"%s\" not found, ignoring user [%s]",
		     s?s:"(null)", AB_User_GetUserId(u));
	  }
	  else {
	    int rv;
	    GWEN_DB_NODE *dbP;

            /* reload user from DB */
	    AB_User_ReadDb(u, db);

            /* let provider also reload user data */
	    dbP=GWEN_DB_GetGroup(db, GWEN_DB_FLAGS_DEFAULT,
				 "data/backend");
	    rv=AB_Provider_ExtendUser(pro, u, AB_ProviderExtendMode_Reload, dbP);
	    if (rv<0) {
	      DBG_WARN(AQBANKING_LOGDOMAIN, "Could not extend user [%s] (%d)",
		       AB_User_GetUserId(u), rv);
	    }
	  }
	}
	else {
          /* user is new, load and add it */
	  DBG_INFO(AQBANKING_LOGDOMAIN,
		   "Loading new user [%08x]",
		   (unsigned int) uid);
	  u=AB_User_fromDb(ab, db);
	  if (u) {
	    const char *s;
	    AB_PROVIDER *pro=NULL;

	    AB_User_SetDbId(u, t);
	    s=AB_User_GetBackendName(u);
	    if (s && *s)
	      pro=AB_Banking_GetProvider(ab, s);
	    if (!pro) {
	      DBG_WARN(AQBANKING_LOGDOMAIN,
		       "Provider \"%s\" not found, ignoring user [%s]",
		       s, AB_User_GetUserId(u));
	    }
	    else {
	      int rv;
	      GWEN_DB_NODE *dbP;
  
	      dbP=GWEN_DB_GetGroup(db, GWEN_DB_FLAGS_DEFAULT,
				   "data/backend");
	      rv=AB_Provider_ExtendUser(pro, u, AB_ProviderExtendMode_Extend, dbP);
	      if (rv) {
		DBG_INFO(AQBANKING_LOGDOMAIN, "here");
		AB_User_free(u);
	      }
	      else {
		DBG_DEBUG(AQBANKING_LOGDOMAIN, "Adding user");
		AB_User_List_Add(u, ab->users);
	      }
	    }
	  }
	  else {
            DBG_INFO(AQBANKING_LOGDOMAIN, "Could not load user from DB");
	  }
	}
        GWEN_DB_Group_free(db);
      }
      se=GWEN_StringListEntry_Next(se);
    }
  }
  else {
    DBG_INFO(AQBANKING_LOGDOMAIN, "No users");
  }
  GWEN_StringList_free(sl);

  return 0;
}
Exemplo n.º 13
0
int GWEN_Directory_GetMatchingFilesRecursively(const char *folder,
                                               GWEN_STRINGLIST *sl,
                                               const char *mask) {
  GWEN_DIRECTORY *d;
  int rv;
  char buffer[256];
  GWEN_BUFFER *pbuf;
  uint32_t pos;
  GWEN_STRINGLIST *folderList;

  folderList=GWEN_StringList_new();

  d=GWEN_Directory_new();
  rv=GWEN_Directory_Open(d, folder);
  if (rv<0) {
    DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
    GWEN_Directory_free(d);
    GWEN_StringList_free(folderList);
    return rv;
  }

  pbuf=GWEN_Buffer_new(0, 256, 0, 1);
  GWEN_Buffer_AppendString(pbuf, folder);
  GWEN_Buffer_AppendString(pbuf, GWEN_DIR_SEPARATOR_S);
  pos=GWEN_Buffer_GetPos(pbuf);

  while(0==GWEN_Directory_Read(d, buffer, sizeof(buffer)-2)) {
    if (strcmp(buffer, ".")!=0 &&
        strcmp(buffer, "..")!=0) {
      struct stat st;

      GWEN_Buffer_AppendString(pbuf, buffer);
      if (stat(GWEN_Buffer_GetStart(pbuf), &st)==0) {
        if (S_ISDIR(st.st_mode))
          /* add folders to the folder list */
          GWEN_StringList_AppendString(folderList, GWEN_Buffer_GetStart(pbuf), 0, 0);
        else {
          if (mask==NULL || GWEN_Text_ComparePattern(buffer, mask, 0)!=-1)
            /* don't check for duplicates here (i.e. last param =0) */
            GWEN_StringList_AppendString(sl, GWEN_Buffer_GetStart(pbuf), 0, 0);
        }
      }
      GWEN_Buffer_Crop(pbuf, 0, pos);
    }
  }

  GWEN_Directory_Close(d);
  GWEN_Directory_free(d);

  if (GWEN_StringList_Count(folderList)) {
    GWEN_STRINGLISTENTRY *se;

    se=GWEN_StringList_FirstEntry(folderList);
    while(se) {
      const char *s;

      s=GWEN_StringListEntry_Data(se);
      if (s && *s)
        GWEN_Directory_GetMatchingFilesRecursively(s, sl, mask);
      se=GWEN_StringListEntry_Next(se);
    }
  }
  GWEN_StringList_free(folderList);
  GWEN_Buffer_free(pbuf);

  return 0;
}