当前位置: 首页>>代码示例>>C++>>正文


C++ ConfigFile::dump_string方法代码示例

本文整理汇总了C++中ConfigFile::dump_string方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigFile::dump_string方法的具体用法?C++ ConfigFile::dump_string怎么用?C++ ConfigFile::dump_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConfigFile的用法示例。


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

示例1: handlePluginEvent

/*
 * Handle an event that was generated in Bareos
 */
static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value)
{
   struct plugin_ctx *p_ctx = (struct plugin_ctx *)ctx->pContext;
   restore_object_pkt *rop;
   if (!p_ctx) {
      return bRC_Error;
   }

// char *name;

   switch (event->eventType) {
   case bEventJobStart:
      Dmsg(ctx, dbglvl, "test-plugin-fd: JobStart=%s\n", (char *)value);
      break;
   case bEventEndFileSet:
      /*
       * End of Dir FileSet commands, now we can add excludes
       */
      bfuncs->NewOptions(ctx);
      bfuncs->AddWild(ctx, "*.c", ' ');
      bfuncs->AddWild(ctx, "*.cpp", ' ');
      bfuncs->AddOptions(ctx, "ei");         /* exclude, ignore case */
      bfuncs->AddExclude(ctx, "/home/user/bareos/regress/README");
      break;
   case bEventRestoreObject: {
      FILE *fp;
      POOLMEM *q;
      char *working;
      static int _nb = 0;

      printf("Plugin RestoreObject\n");
      if (!value) {
         Dmsg(ctx, dbglvl, "test-plugin-fd: End restore objects\n");
         break;
      }
      rop = (restore_object_pkt *)value;
      Dmsg(ctx, dbglvl, "Get RestoreObject len=%d JobId=%d oname=%s type=%d data=%.127s\n",
           rop->object_len, rop->JobId, rop->object_name, rop->object_type, rop->object);
      q = get_pool_memory(PM_FNAME);

      bfuncs->getBareosValue(ctx, bVarWorkingDir, &working);
      Mmsg(q, "%s/restore.%d", working, _nb++);
      if ((fp = fopen(q, "w")) != NULL) {
         fwrite(rop->object, rop->object_len, 1, fp);
         fclose(fp);
      }

      free_pool_memory(q);

      if (!strcmp(rop->object_name, INI_RESTORE_OBJECT_NAME)) {
         ConfigFile ini;
         if (!ini.dump_string(rop->object, rop->object_len)) {
            break;
         }
         ini.register_items(test_items, sizeof(struct ini_items));
         if (ini.parse(ini.out_fname)) {
            Jmsg(ctx, M_INFO, "string1 = %s\n", ini.items[0].val.strval);
         } else {
            Jmsg(ctx, M_ERROR, "Can't parse config\n");
         }
      }

      break;
   }
   case bEventEstimateCommand:
      /* Fall-through wanted */
   case bEventBackupCommand: {
      /*
       * Plugin command e.g. plugin = <plugin-name>:<name-space>:read command:write command
       */
      char *p;

      Dmsg(ctx, dbglvl, "test-plugin-fd: pluginEvent cmd=%s\n", (char *)value);
      p_ctx->cmd = bstrdup((char *)value);
      p = strchr(p_ctx->cmd, ':');
      if (!p) {
         Jmsg(ctx, M_FATAL, "Plugin terminator not found: %s\n", (char *)value);
         Dmsg(ctx, dbglvl, "Plugin terminator not found: %s\n", (char *)value);
         return bRC_Error;
      }
      *p++ = 0;           /* terminate plugin */
      p_ctx->fname = p;
      p = strchr(p, ':');
      if (!p) {
         Jmsg(ctx, M_FATAL, "File terminator not found: %s\n", (char *)value);
         Dmsg(ctx, dbglvl, "File terminator not found: %s\n", (char *)value);
         return bRC_Error;
      }
      *p++ = 0;           /* terminate file */
      p_ctx->reader = p;
      p = strchr(p, ':');
      if (!p) {
         Jmsg(ctx, M_FATAL, "Reader terminator not found: %s\n", (char *)value);
         Dmsg(ctx, dbglvl, "Reader terminator not found: %s\n", (char *)value);
         return bRC_Error;
      }
      *p++ = 0;           /* terminate reader string */
//.........这里部分代码省略.........
开发者ID:aussendorf,项目名称:bareos,代码行数:101,代码来源:test-plugin-fd.c


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