• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GWEN_Buffer_free函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GWEN_Buffer_free函数的典型用法代码示例。如果您正苦于以下问题:C++ GWEN_Buffer_free函数的具体用法?C++ GWEN_Buffer_free怎么用?C++ GWEN_Buffer_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GWEN_Buffer_free函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: AH_User_SetPinStatus

int AH_User_SetPinStatus(AB_USER *u,
			 const char *pin,
			 GWEN_GUI_PASSWORD_STATUS status){
  GWEN_BUFFER *nbuf;
  int rv;

  nbuf=GWEN_Buffer_new(0, 256 ,0 ,1);
  AH_User_MkPinName(u, nbuf);
  rv=GWEN_Gui_SetPasswordStatus(GWEN_Buffer_GetStart(nbuf),
				pin,
				status,
				0);
  GWEN_Buffer_free(nbuf);
  return rv;
}
开发者ID:maduhu,项目名称:aqbanking-1,代码行数:15,代码来源:user.c


示例2: assert

AB_PROVIDER *AB_Provider_new(AB_BANKING *ab, const char *name){
  AB_PROVIDER *pro;
  GWEN_BUFFER *nbuf;

  assert(ab);
  assert(name);

  nbuf=GWEN_Buffer_new(0, 256, 0, 1);
  if (GWEN_Text_EscapeToBufferTolerant(name, nbuf)) {
    DBG_ERROR(AQBANKING_LOGDOMAIN,
              "Bad backend name, aborting.");
    GWEN_Buffer_free(nbuf);
    abort();
  }
  else {
    char *s;

    s=GWEN_Buffer_GetStart(nbuf);
    while(*s) {
      *s=tolower(*s);
      s++;
    }
  }

  GWEN_NEW_OBJECT(AB_PROVIDER, pro);
  pro->usage=1;
  GWEN_INHERIT_INIT(AB_PROVIDER, pro);
  GWEN_LIST_INIT(AB_PROVIDER, pro);

  pro->banking=ab;
  pro->name=strdup(name);
  pro->escName=strdup(GWEN_Buffer_GetStart(nbuf));
  GWEN_Buffer_free(nbuf);

  return pro;
}
开发者ID:Zauberstuhl,项目名称:aqbanking,代码行数:36,代码来源:provider.c


示例3: AIO_OfxXmlCtx_SanitizeData

int AIO_OfxXmlCtx_SanitizeData(GWEN_XML_CONTEXT *ctx,
			       const char *data,
			       GWEN_BUFFER *buf) {
  AIO_OFX_XMLCTX *xctx;

  assert(ctx);
  xctx=GWEN_INHERIT_GETDATA(GWEN_XML_CONTEXT, AIO_OFX_XMLCTX, ctx);
  assert(xctx);

  if (xctx->charset) {
    GWEN_BUFFER *tbuf;
    int rv;

    tbuf=GWEN_Buffer_new(0, 256, 0, 1);
    rv=AIO_OfxXmlCtx_CleanupData(ctx, data, tbuf);
    if (rv<0) {
      DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d)", rv);
      GWEN_Buffer_free(tbuf);
      return rv;
    }

    rv=GWEN_Text_ConvertCharset(xctx->charset, "UTF-8",
				GWEN_Buffer_GetStart(tbuf),
				GWEN_Buffer_GetUsedBytes(tbuf),
				buf);
    if (rv<0) {
      DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d)", rv);
      GWEN_Buffer_free(tbuf);
      return rv;
    }
    GWEN_Buffer_free(tbuf);
    return 0;
  }
  else
    return AIO_OfxXmlCtx_CleanupData(ctx, data, buf);
}
开发者ID:Zauberstuhl,项目名称:aqbanking,代码行数:36,代码来源:ofxxmlctx.c


示例4: GWEN_Logger_Log

int GWEN_Logger_Log(const char *logDomain,
                    GWEN_LOGGER_LEVEL priority, const char *s) {
  if (!GWEN_Gui_LogHook(logDomain, priority, s)) {
    const char *p;
    int rv;
    unsigned int i;
    GWEN_BUFFER *mbuf;
    GWEN_LOGGER *lg;

    lg=GWEN_LoggerDomain_GetLogger(logDomain);
    assert(lg);

    if (!lg->enabled)
      return 1;

    if (priority>lg->logLevel)
      /* priority too low, don't log */
      return 0;

    /* temporarily disable logging to avoid endless loops */
    lg->enabled=0;
    /* copy buffer, exchange all newlines by 0 */
    mbuf=GWEN_Buffer_new(0, strlen(s)+1, 0, 1);
    for (i=0; i<strlen(s)+1; i++) {
      if (s[i]=='\n') {
        GWEN_Buffer_AppendByte(mbuf, 0);
      }
      else
        GWEN_Buffer_AppendByte(mbuf, s[i]);
    }

    /* now log each line */
    rv=0;
    p=GWEN_Buffer_GetStart(mbuf);
    while (*p) {
      rv|=GWEN_Logger__Log(lg, priority, p);
      while(*p)
        p++;
      p++;
    }
    GWEN_Buffer_free(mbuf);
    /* reenable logging */
    lg->enabled=1;
    return rv;
  }
  else
    return 0;
}
开发者ID:aqbanking,项目名称:gwenhywfar,代码行数:48,代码来源:logger.c


示例5: GWEN_XML_AddNameSpace

int GWEN_XML_AddNameSpace(GWEN_STRINGLIST2 *sl,
                          const char *prefix,
                          const char *name) {
  GWEN_BUFFER *nbuf;
  int rv;

  nbuf=GWEN_Buffer_new(0, 32, 0, 1);
  if (prefix)
    GWEN_Buffer_AppendString(nbuf, prefix);
  GWEN_Buffer_AppendByte(nbuf, ':');
  GWEN_Buffer_AppendString(nbuf, name);
  rv=GWEN_StringList2_AppendString(sl, GWEN_Buffer_GetStart(nbuf), 0,
                                   GWEN_StringList2_IntertMode_NoDouble);
  GWEN_Buffer_free(nbuf);
  return rv;
}
开发者ID:aqbanking,项目名称:gwenhywfar,代码行数:16,代码来源:xml.c


示例6: AB_Value_Dump

void AB_Value_Dump(const AB_VALUE *v, FILE *f, unsigned int indent) {
  unsigned int i;

  for (i=0; i<indent; i++)
    fprintf(f, " ");
  fprintf(f, "Value: ");
  if (v) {
    GWEN_BUFFER *nbuf;

    nbuf=GWEN_Buffer_new(0, 128, 0, 1);
    AB_Value_toHumanReadableString(v, nbuf, 2);
    gmp_fprintf(f, "%Qi (%s)\n", v->value, GWEN_Buffer_GetStart(nbuf));
    GWEN_Buffer_free(nbuf);
  }
  else
    fprintf(f, "[none]\n");
}
开发者ID:Zauberstuhl,项目名称:aqbanking,代码行数:17,代码来源:value.c


示例7: GWEN_Directory_GetFileEntries

int GWEN_Directory_GetFileEntries(const char *folder, GWEN_STRINGLIST *sl,
                                  const char *mask) {
  GWEN_DIRECTORY *d;
  int rv;
  char buffer[256];
  GWEN_BUFFER *pbuf;
  uint32_t pos;

  d=GWEN_Directory_new();
  rv=GWEN_Directory_Open(d, folder);
  if (rv<0) {
    DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
    GWEN_Directory_free(d);
    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))) {
    if (strcmp(buffer, ".")!=0 &&
        strcmp(buffer, "..")!=0 &&
        (mask==NULL ||
         GWEN_Text_ComparePattern(buffer+1, mask, 0)!=-1)) {
      struct stat st;

      GWEN_Buffer_AppendString(pbuf, buffer);
      if (stat(GWEN_Buffer_GetStart(pbuf), &st)==0) {
        if (S_ISREG(st.st_mode))
          GWEN_StringList_AppendString(sl, buffer, 0, 1);
      }
      GWEN_Buffer_Crop(pbuf, 0, pos);
    }
  }

  GWEN_Buffer_free(pbuf);
  GWEN_Directory_Close(d);
  GWEN_Directory_free(d);
  return 0;
}
开发者ID:aqbanking,项目名称:gwenhywfar,代码行数:42,代码来源:directory_all.c


示例8: AHB_DTAUS__AddWord

int AHB_DTAUS__AddWord(GWEN_BUFFER *dst,
                       unsigned int size,
                       const char *s) {
  unsigned int i;
  unsigned int ssize;
  GWEN_BUFFER *nbuf;

  assert(dst);
  assert(size);
  assert(s);

  DBG_DEBUG(AQBANKING_LOGDOMAIN, "Adding word: %s", s);

  nbuf=GWEN_Buffer_new(0, size, 0, 1);
  AB_ImExporter_Utf8ToDta(s, -1, nbuf);
  s=GWEN_Buffer_GetStart(nbuf);

  ssize=strlen(s);
  if (ssize>size) {
    /* Error out here because e.g. truncated accountid will lead to failed jobs. */
    DBG_ERROR(AQBANKING_LOGDOMAIN, "Word \"%s\" too long: Has length %d but must not be longer than %d characters",
	      s, ssize, size);
    return -1;
  }

  for (i=0; i<size; i++) {
    char c;

    if (i>=ssize)
      c=0;
    else
      c=s[i];

    if (c)
      GWEN_Buffer_AppendByte(dst, c);
    else
      GWEN_Buffer_AppendByte(dst, ' ');
  } /* for */
  GWEN_Buffer_free(nbuf);
  return 0;
}
开发者ID:Zauberstuhl,项目名称:aqbanking,代码行数:41,代码来源:dtaus-export.c


示例9: assert

GWEN_DB_NODE *AH_User_GetUpdForAccountIdAndSuffix(const AB_USER *u,
                                                  const char *sAccountNumber,
                                                  const char *sAccountSuffix) {
  AH_USER *ue;
  GWEN_DB_NODE *db;
  GWEN_BUFFER *tbuf;

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

  db=AH_User_GetUpd(u);
  if (db==NULL) {
    DBG_INFO(AQHBCI_LOGDOMAIN, "No upd");
    return NULL;
  }

  tbuf=GWEN_Buffer_new(0, 64, 0, 1);
  GWEN_Buffer_AppendString(tbuf, sAccountNumber);
  GWEN_Buffer_AppendString(tbuf, "-");
  /* take into account the "Unterkontomerkmal", don't rely solely on account id */
  if (sAccountSuffix && *sAccountSuffix)
    GWEN_Buffer_AppendString(tbuf, sAccountSuffix);
  else
    GWEN_Buffer_AppendString(tbuf, "none");
  DBG_INFO(AQHBCI_LOGDOMAIN, "Checking upd for account \"%s\"", GWEN_Buffer_GetStart(tbuf));
  db=GWEN_DB_GetGroup(db,
                      GWEN_PATH_FLAGS_NAMEMUSTEXIST,
                      GWEN_Buffer_GetStart(tbuf));
  GWEN_Buffer_free(tbuf);

  if (db==NULL) {
    DBG_INFO(AQHBCI_LOGDOMAIN, "Falling back to old storage of UPD for account \"%s\"", sAccountNumber);
    db=AH_User_GetUpd(u);
    db=GWEN_DB_GetGroup(db,
                        GWEN_PATH_FLAGS_NAMEMUSTEXIST,
                        sAccountNumber);
  }

  return db;
}
开发者ID:maduhu,项目名称:aqbanking-1,代码行数:41,代码来源:user.c


示例10: AH_NewKeyFileDialog_HandleActivatedFileButton

int AH_NewKeyFileDialog_HandleActivatedFileButton(GWEN_DIALOG *dlg) {
  AH_NEWKEYFILE_DIALOG *xdlg;
  int rv;
  const char *s;
  GWEN_BUFFER *pathBuffer;

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

  pathBuffer=GWEN_Buffer_new(0, 256, 0, 1);
  s=GWEN_Dialog_GetCharProperty(dlg, "wiz_filename_edit", GWEN_DialogProperty_Value, 0, NULL);
  if (s && *s)
    GWEN_Buffer_AppendString(pathBuffer, s);
  rv=GWEN_Gui_GetFileName(I18N("Create Keyfile"),
			  GWEN_Gui_FileNameType_SaveFileName,
			  0,
			  I18N("All Files (*)\tOHBCI Files (*ohbci;*.medium)"),
			  pathBuffer,
			  GWEN_Dialog_GetGuiId(dlg));
  if (rv==0) {
    GWEN_Dialog_SetCharProperty(dlg,
				"wiz_filename_edit",
				GWEN_DialogProperty_Value,
				0,
				GWEN_Buffer_GetStart(pathBuffer),
				0);
    rv=AH_NewKeyFileDialog_GetFilePageData(dlg);
    if (rv<0)
      GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 0, 0);
    else
      GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 1, 0);
  }
  else {
    DBG_NOTICE(AQHBCI_LOGDOMAIN, "here (%d)", rv);
  }
  GWEN_Buffer_free(pathBuffer);
  return GWEN_DialogEvent_ResultHandled;
}
开发者ID:Zauberstuhl,项目名称:aqbanking,代码行数:39,代码来源:dlg_newkeyfile.c


示例11: GWEN_Crypt_Token_ModuleInit

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;
}
开发者ID:cstim,项目名称:gwenhywfar,代码行数:38,代码来源:ctplugin.c


示例12: GWEN_PathManager_AddPath

int GWEN_PathManager_AddPath(const char *callingLib,
                             const char *destLib,
                             const char *pathName,
                             const char *pathValue) {
  GWEN_DB_NODE *dbT;
  GWEN_BUFFER *buf;

  assert(destLib);
  assert(pathName);
  assert(pathValue);
  assert(gwen__paths);
  dbT=GWEN_DB_GetGroup(gwen__paths, GWEN_PATH_FLAGS_NAMEMUSTEXIST,
                       destLib);
  if (!dbT)
    return GWEN_ERROR_NOT_FOUND;
  dbT=GWEN_DB_GetGroup(dbT, GWEN_PATH_FLAGS_NAMEMUSTEXIST,
                       pathName);
  if (!dbT)
    return GWEN_ERROR_NOT_FOUND;
  dbT=GWEN_DB_GetGroup(dbT, GWEN_PATH_FLAGS_CREATE_GROUP,
                       "pair");
  assert(dbT);

  if (callingLib) {
    GWEN_DB_SetCharValue(dbT, GWEN_DB_FLAGS_DEFAULT,
                         "lib", callingLib);
  }

  buf=GWEN_Buffer_new(0, 256, 0, 1);
  GWEN_Directory_OsifyPath(pathValue, buf, 1);

  GWEN_DB_SetCharValue(dbT, GWEN_DB_FLAGS_DEFAULT,
                       "path",
                       GWEN_Buffer_GetStart(buf));
  GWEN_Buffer_free(buf);

  return 0;
}
开发者ID:Zauberstuhl,项目名称:gwenhywfar,代码行数:38,代码来源:pathmanager.c


示例13: LC_DDVCard_Open

LC_CLIENT_RESULT CHIPCARD_CB LC_DDVCard_Open(LC_CARD *card){
  LC_CLIENT_RESULT res;
  LC_DDVCARD *ddv;

  DBG_INFO(LC_LOGDOMAIN, "Opening card as DDV card");

  assert(card);
  ddv=GWEN_INHERIT_GETDATA(LC_CARD, LC_DDVCARD, card);
  assert(ddv);

  ddv->ddvType=-1;
  GWEN_DB_Group_free(ddv->db_ef_id_1);
  ddv->db_ef_id_1=0;
  GWEN_Buffer_free(ddv->bin_ef_id_1);
  ddv->bin_ef_id_1=0;

  if (strcasecmp(LC_Card_GetCardType(card), "PROCESSOR")!=0) {
    DBG_ERROR(LC_LOGDOMAIN, "Not a processor card (%s)",
              LC_Card_GetCardType(card));
    return LC_Client_ResultNotSupported;
  }

  res=ddv->openFn(card);
  if (res!=LC_Client_ResultOk) {
    DBG_INFO(LC_LOGDOMAIN, "here");
    return res;
  }

  res=LC_DDVCard_Reopen(card);
  if (res!=LC_Client_ResultOk) {
    DBG_INFO(LC_LOGDOMAIN, "here");
    ddv->closeFn(card);
    return res;
  }

  return LC_Client_ResultOk;
}
开发者ID:aqbanking,项目名称:libchipcard,代码行数:37,代码来源:ddvcard.c


示例14: GWEN_DBIO__XmlDb_ReadDataTags

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);
}
开发者ID:kleopatra999,项目名称:gwenhywfar,代码行数:24,代码来源:xmldb.c


示例15: addToList

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;
}
开发者ID:Zauberstuhl,项目名称:gwenhywfar,代码行数:77,代码来源:add.c


示例16: add2Archive

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);
//.........这里部分代码省略.........
开发者ID:Zauberstuhl,项目名称:gwenhywfar,代码行数:101,代码来源:add.c


示例17: main

int main(int argc, char **argv) {
  int rv;
  GWEN_DB_NODE *db;
  const char *s;
  LC_CLIENT *cl;
  LC_CLIENT_RESULT res;
  GWEN_GUI *gui;
  int v;

  gui=GWEN_Gui_CGui_new();
  GWEN_Gui_SetGui(gui);

  db=GWEN_DB_Group_new("arguments");
  rv=GWEN_Args_Check(argc, argv, 1,
                     GWEN_ARGS_MODE_ALLOW_FREEPARAM,
                     prg_args,
                     db);
  if (rv==GWEN_ARGS_RESULT_HELP) {
    GWEN_BUFFER *ubuf;

    ubuf=GWEN_Buffer_new(0, 256, 0, 1);
    if (GWEN_Args_Usage(prg_args, ubuf, GWEN_ArgsOutType_Txt)) {
      fprintf(stderr, "Could not generate usage string.\n");
      GWEN_Buffer_free(ubuf);
      return RETURNVALUE_PARAM;
    }
    usage(argv[0], GWEN_Buffer_GetStart(ubuf));
    GWEN_Buffer_free(ubuf);
    return 0;
  }
  if (rv<1) {
    fprintf(stderr, "ERROR: Error in argument list (%d)\n", rv);
    return RETURNVALUE_PARAM;
  }

  v=GWEN_DB_GetIntValue(db, "verbosity", 0, 0);
  if (v<2)
    GWEN_Gui_AddFlags(gui, GWEN_GUI_FLAGS_NONINTERACTIVE);

  /* get command */
  s=GWEN_DB_GetCharValue(db, "params", 0, 0);
  if (!s) {
    fprintf(stderr, "No command given.\n");
    GWEN_DB_Group_free(db);
    return RETURNVALUE_PARAM;
  }

  cl=LC_Client_new("kvkcard", PROGRAM_VERSION);
  res=LC_Client_Init(cl);
  if (res!=LC_Client_ResultOk) {
    showError(0, res, "Init");
    return RETURNVALUE_SETUP;
  }

  /* handle command */
  if (strcasecmp(s, "read")==0) {
    rv=kvkRead(cl, db);
  }
  else if (strcasecmp(s, "daemon")==0) {
    fprintf(stderr, "KVK daemon no longer supported.\n");
    return RETURNVALUE_SETUP;
  }
  else if (strcasecmp(s, "rdvd")==0) {
    rv=rdvd(cl, db);
  }
  else if (strcasecmp(s, "rdpd")==0) {
    rv=rdpd(cl, db);
  }
  else if (strcasecmp(s, "psvd")==0) {
    rv=psvd(cl, db);
  }
  else {
    fprintf(stderr, "Unknown command \"%s\"", s);
    rv=RETURNVALUE_PARAM;
  }

  LC_Client_free(cl);
  GWEN_DB_Group_free(db);
  return 0;
}
开发者ID:aqbanking,项目名称:libchipcard,代码行数:80,代码来源:main.c


示例18: LC_ZkaCard_Reopen

LC_CLIENT_RESULT LC_ZkaCard_Reopen(LC_CARD *card) {
  LC_CLIENT_RESULT res;
  LC_ZKACARD *xc;
  GWEN_BUFFER *mbuf;

  DBG_INFO(LC_LOGDOMAIN, "Opening ZkaCard card");

  assert(card);
  xc=GWEN_INHERIT_GETDATA(LC_CARD, LC_ZKACARD, card);
  assert(xc);

  LC_Card_SetLastResult(card, 0, 0, 0, 0);
  GWEN_Buffer_free(xc->bin_ef_gd_0);
  xc->bin_ef_gd_0=NULL;

  GWEN_Buffer_free(xc->bin_ef_id);
  xc->bin_ef_id=NULL;

  GWEN_Buffer_free(xc->bin_ef_ssd);
  xc->bin_ef_ssd=NULL;

  res=LC_Card_SelectCard(card, "zkacard");
  if (res!=LC_Client_ResultOk) {
    DBG_INFO(LC_LOGDOMAIN, "here");
    return res;
  }

  /* first select generic app for all ZKACARD HBCI cards */
  res=LC_Card_SelectApp(card, "zkacard");
  if (res!=LC_Client_ResultOk) {
    DBG_INFO(LC_LOGDOMAIN, "here");
    return res;
  }

  DBG_INFO(LC_LOGDOMAIN, "Selecting MF...");
  res=LC_Card_SelectMf(card);
  if (res!=LC_Client_ResultOk) {
    DBG_INFO(LC_LOGDOMAIN, "here");
    return res;
  }

  /* read EF_ID */
  DBG_INFO(LC_LOGDOMAIN, "Selecting EF_ID...");
  res=LC_Card_SelectEf(card, "EF_ID");
  if (res!=LC_Client_ResultOk) {
    DBG_INFO(LC_LOGDOMAIN, "here");
    return res;
  }

  DBG_INFO(LC_LOGDOMAIN, "Reading record...");
  mbuf=GWEN_Buffer_new(0, 32, 0, 1);
  res=LC_Card_IsoReadRecord(card, LC_CARD_ISO_FLAGS_RECSEL_GIVEN, 1, mbuf);
  if (res!=LC_Client_ResultOk) {
    DBG_INFO(LC_LOGDOMAIN, "here");
    GWEN_Buffer_free(mbuf);
    return res;
  }
  xc->bin_ef_id=mbuf;


  /* read EG_GD0 */
  DBG_INFO(LC_LOGDOMAIN, "Selecting EF_GD0...");
  res=LC_Card_SelectEf(card, "EF_GD0");
  if (res!=LC_Client_ResultOk) {
    DBG_INFO(LC_LOGDOMAIN, "here");
    return res;
  }

  DBG_INFO(LC_LOGDOMAIN, "Reading data...");
  mbuf=GWEN_Buffer_new(0, 16, 0, 1);
  res=LC_Card_IsoReadBinary(card, 0, 0, 12, mbuf);
  if (res!=LC_Client_ResultOk) {
    DBG_INFO(LC_LOGDOMAIN, "here");
    GWEN_Buffer_free(mbuf);
    return res;
  }
  if (GWEN_Buffer_GetUsedBytes(mbuf)<12) {
    DBG_INFO(LC_LOGDOMAIN, "here");
    GWEN_Buffer_free(mbuf);
    return LC_Client_ResultDataError;
  }
  xc->bin_ef_gd_0=mbuf;


  /* select DF_SIG */
  DBG_INFO(LC_LOGDOMAIN, "Selecting DF_SIG...");
  res=LC_Card_SelectDf(card, "DF_SIG");
  if (res!=LC_Client_ResultOk) {
    DBG_INFO(LC_LOGDOMAIN, "here");
    return res;
  }

  /* read EG_SSD */
  DBG_INFO(LC_LOGDOMAIN, "Selecting EF_SSD...");
  res=LC_Card_SelectEf(card, "EF_SSD");
  if (res!=LC_Client_ResultOk) {
    DBG_INFO(LC_LOGDOMAIN, "here");
    return res;
  }

//.........这里部分代码省略.........
开发者ID:rhvall,项目名称:SmartCard,代码行数:101,代码来源:zkacard.c


示例19: GWEN_CryptMgrKeys_VerifyData

GWENHYWFAR_CB
int GWEN_CryptMgrKeys_VerifyData(GWEN_CRYPTMGR *cm,
                                 const uint8_t *pData, uint32_t lData,
                                 const uint8_t *pSignature, uint32_t lSignature) {
  GWEN_CRYPTMGR_KEYS *xcm;
  GWEN_MDIGEST *md;
  int rv;
  GWEN_BUFFER *tbuf;
  int ksize;
  uint32_t l;

  assert(cm);
  xcm=GWEN_INHERIT_GETDATA(GWEN_CRYPTMGR, GWEN_CRYPTMGR_KEYS, cm);
  assert(xcm);

  if (xcm->peerKey==NULL) {
    DBG_ERROR(GWEN_LOGDOMAIN, "No peer key");
    return GWEN_ERROR_GENERIC;
  }

  ksize=GWEN_Crypt_Key_GetKeySize(xcm->peerKey);

  /* the padding algo uses random numbers, so we must use the encrypt function and
   * compare the decoded and unpadded signature with the hash of the source data
   */
  tbuf=GWEN_Buffer_new(0, ksize+16, 0, 1);
  l=GWEN_Buffer_GetMaxUnsegmentedWrite(tbuf);
  rv=GWEN_Crypt_Key_Encipher(xcm->peerKey,
                             pSignature, lSignature,
                             (uint8_t*)GWEN_Buffer_GetPosPointer(tbuf),
                             &l);
  if (rv<0) {
    DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
    GWEN_Buffer_free(tbuf);
    return rv;
  }
  GWEN_Buffer_IncrementPos(tbuf, l);
  GWEN_Buffer_AdjustUsedBytes(tbuf);

  /* unpadd */
  rv=GWEN_Padd_UnpaddWithIso9796_2(tbuf);
  if (rv<0) {
    DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
    GWEN_Buffer_free(tbuf);
    return rv;
  }
  /* tbuf now contains the hash */

  /* hash source data */
  md=GWEN_MDigest_Rmd160_new();
  rv=GWEN_MDigest_Begin(md);
  if (rv<0) {
    DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
    GWEN_MDigest_free(md);
    GWEN_Buffer_free(tbuf);
    return rv;
  }
  rv=GWEN_MDigest_Update(md, pData, lData);
  if (rv<0) {
    DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
    GWEN_MDigest_free(md);
    GWEN_Buffer_free(tbuf);
    return rv;
  }
  rv=GWEN_MDigest_End(md);
  if (rv<0) {
    DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
    GWEN_MDigest_free(md);
    GWEN_Buffer_free(tbuf);
    return rv;
  }

  if (GWEN_MDigest_GetDigestSize(md)!=GWEN_Buffer_GetUsedBytes(tbuf)) {
    DBG_ERROR(GWEN_LOGDOMAIN, "Invalid signature");
    GWEN_MDigest_free(md);
    GWEN_Buffer_free(tbuf);
    return GWEN_ERROR_VERIFY;
  }

  if (memcmp(GWEN_MDigest_GetDigestPtr(md),
             GWEN_Buffer_GetStart(tbuf),
             GWEN_MDigest_GetDigestSize(md))!=0) {
    DBG_ERROR(GWEN_LOGDOMAIN, "Invalid signature");
    GWEN_MDigest_free(md);
    GWEN_Buffer_free(tbuf);
    return GWEN_ERROR_VERIFY;
  }

  GWEN_MDigest_free(md);
  GWEN_Buffer_free(tbuf);

  return 0;
}
开发者ID:Zauberstuhl,项目名称:gwenhywfar,代码行数:93,代码来源:cryptmgrkeys.c


示例20: GWEN_CryptMgrKeys_SignData

GWENHYWFAR_CB
int GWEN_CryptMgrKeys_SignData(GWEN_CRYPTMGR *cm,
                               const uint8_t *pData, uint32_t lData,
                               GWEN_BUFFER *dbuf) {
  GWEN_CRYPTMGR_KEYS *xcm;
  GWEN_MDIGEST *md;
  int rv;
  GWEN_BUFFER *tbuf;
  int ksize;
  uint32_t signatureLen;

  assert(cm);
  xcm=GWEN_INHERIT_GETDATA(GWEN_CRYPTMGR, GWEN_CRYPTMGR_KEYS, cm);
  assert(xcm);

  if (xcm->localKey==NULL) {
    DBG_ERROR(GWEN_LOGDOMAIN, "No local key");
    return GWEN_ERROR_GENERIC;
  }

  ksize=GWEN_Crypt_Key_GetKeySize(xcm->localKey);

  /* hash pData */
  md=GWEN_MDigest_Rmd160_new();
  rv=GWEN_MDigest_Begin(md);
  if (rv<0) {
    DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
    GWEN_MDigest_free(md);
    return rv;
  }
  rv=GWEN_MDigest_Update(md, pData, lData);
  if (rv<0) {
    DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
    GWEN_MDigest_free(md);
    return rv;
  }
  rv=GWEN_MDigest_End(md);
  if (rv<0) {
    DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
    GWEN_MDigest_free(md);
    return rv;
  }

  /* padd */
  tbuf=GWEN_Buffer_new(0, ksize, 0, 1);
  GWEN_Buffer_AppendBytes(tbuf,
                          (const char*)GWEN_MDigest_GetDigestPtr(md),
                          GWEN_MDigest_GetDigestSize(md));
  GWEN_MDigest_free(md);
  GWEN_Padd_PaddWithIso9796_2(tbuf, ksize);

  /* sign */
  GWEN_Buffer_AllocRoom(dbuf, ksize);
  signatureLen=GWEN_Buffer_GetMaxUnsegmentedWrite(dbuf);
  rv=GWEN_Crypt_Key_Sign(xcm->localKey,
                         (uint8_t*)GWEN_Buffer_GetStart(tbuf),
                         GWEN_Buffer_GetUsedBytes(tbuf),
                         (uint8_t*)GWEN_Buffer_GetPosPointer(dbuf),
                         &signatureLen);
  GWEN_Buffer_free(tbuf);
  if (rv<0) {
    DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
    return rv;
  }

  GWEN_Buffer_IncrementPos(dbuf, signatureLen);
  GWEN_Buffer_AdjustUsedBytes(dbuf);

  return 0;
}
开发者ID:Zauberstuhl,项目名称:gwenhywfar,代码行数:70,代码来源:cryptmgrkeys.c



注:本文中的GWEN_Buffer_free函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GWEN_Buffer_new函数代码示例发布时间:2022-05-30
下一篇:
C++ GWEN_Buffer_GetStart函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap