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


C++ POOL_MEM类代码示例

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


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

示例1: wvalue

void OUTPUT_FORMATTER::object_key_value(const char *key, const char *key_fmt,
                                        const char *value, const char *value_fmt,
                                        int wrap)
{
   POOL_MEM string;
   POOL_MEM wvalue(value);
   rewrap(wvalue, wrap);

   switch (api) {
#if HAVE_JANSSON
   case API_MODE_JSON:
      json_key_value_add(key, wvalue.c_str());
      break;
#endif
   default:
      if (key_fmt) {
         string.bsprintf(key_fmt, key);
         result_message_plain->strcat(string);
      }
      if (value_fmt) {
         string.bsprintf(value_fmt, wvalue.c_str());
         result_message_plain->strcat(string);
      }
      Dmsg2(800, "obj: %s:%s\n", key, wvalue.c_str());
   }
}
开发者ID:NextGenIntelligence,项目名称:bareos,代码行数:26,代码来源:output_formatter.c

示例2: json_finalize_result

void OUTPUT_FORMATTER::json_finalize_result(bool result)
{
   POOL_MEM string;
   json_t *msg_obj = json_object();
   json_t *error_obj;

   /*
    * We mimic json-rpc result and error messages,
    * To make it easier to implement real json-rpc later on.
    */
   json_object_set(msg_obj, "jsonrpc", json_string("2.0"));
   json_object_set(msg_obj, "id", json_null());
   if (result) {
      json_object_set(msg_obj, "result", result_array_json);
   } else {
      error_obj = json_object();
      json_object_set_new(error_obj, "code", json_integer(1));
      json_object_set_new(error_obj, "message", json_string("failed"));
      json_object_set(error_obj, "data", result_array_json);
      json_object_set_new(msg_obj, "error", error_obj);
   }

   string.bsprintf("%s\n", json_dumps(msg_obj, UA_JSON_FLAGS));
   send_func(send_ctx, string.c_str());
   json_array_clear(result_array_json);
   json_object_clear(msg_obj);
}
开发者ID:NextGenIntelligence,项目名称:bareos,代码行数:27,代码来源:output_formatter.c

示例3: configure_create_fd_resource_string

static inline bool configure_create_fd_resource_string(UAContext *ua, POOL_MEM &resource, const char *clientname)
{
   CLIENTRES *client;
   s_password *password;
   POOL_MEM temp(PM_MESSAGE);

   client = ua->GetClientResWithName(clientname);
   if (!client) {
      return false;
   }
   password = &client->password;

   resource.strcat("Director {\n");
   config_add_directive(NULL, NULL, "Name", me->name(), resource);

   switch (password->encoding) {
   case p_encoding_clear:
      Mmsg(temp, "\"%s\"", password->value);
      break;
   case p_encoding_md5:
      Mmsg(temp, "\"[md5]%s\"", password->value);
      break;
   default:
      break;
   }
   config_add_directive(NULL, NULL, "Password", temp.c_str(), resource);

   resource.strcat("}\n");

   return true;
}
开发者ID:dl5rcw,项目名称:bareos,代码行数:31,代码来源:ua_configure.c

示例4: dump_resource

/*
 * Dump contents of resource
 */
void dump_resource(int type, RES *reshdr,
                   void sendit(void *sock, const char *fmt, ...),
                   void *sock, bool hide_sensitive_data)
{
   POOL_MEM buf;
   URES *res = (URES *)reshdr;
   BRSRES *resclass;
   bool recurse = true;

   if (res == NULL) {
      sendit(sock, _("Warning: no \"%s\" resource (%d) defined.\n"), res_to_str(type), type);
      return;
   }
   if (type < 0) {                    /* no recursion */
      type = - type;
      recurse = false;
   }

   switch (type) {
      default:
         resclass = (BRSRES *)reshdr;
         resclass->print_config(buf);
         break;
   }
   sendit(sock, "%s", buf.c_str());

   if (recurse && res->res_dir.hdr.next) {
      dump_resource(type, res->res_dir.hdr.next, sendit, sock, hide_sensitive_data);
   }
}
开发者ID:gearsforwork,项目名称:bareos,代码行数:33,代码来源:console_conf.c

示例5: pm_strcpy

int pm_strcpy(POOLMEM *&pm, POOL_MEM &str)
{
   int len = strlen(str.c_str()) + 1;

   pm = check_pool_memory_size(pm, len);
   memcpy(pm, str.c_str(), len);
   return len - 1;
}
开发者ID:rkorzeniewski,项目名称:bacula,代码行数:8,代码来源:mem_pool.c

示例6: pm_strcat

int pm_strcat(POOLMEM *&pm, POOL_MEM &str)
{
   int pmlen = strlen(pm);
   int len = strlen(str.c_str()) + 1;

   pm = check_pool_memory_size(pm, pmlen + len);
   memcpy(pm+pmlen, str.c_str(), len);
   return pmlen + len - 1;
}
开发者ID:rkorzeniewski,项目名称:bacula,代码行数:9,代码来源:mem_pool.c

示例7: archive_name

/*
 * Edit codes into (Un)MountCommand, Write(First)PartCommand
 *  %% = %
 *  %a = archive device name
 *  %e = erase (set if cannot mount and first part)
 *  %n = part number
 *  %m = mount point
 *  %v = last part name
 *
 *  omsg = edited output message
 *  imsg = input string containing edit codes (%x)
 *
 */
void DEVICE::edit_mount_codes(POOL_MEM &omsg, const char *imsg)
{
   const char *p;
   const char *str;
   char add[20];

   POOL_MEM archive_name(PM_FNAME);

   omsg.c_str()[0] = 0;
   Dmsg1(800, "edit_mount_codes: %s\n", imsg);
   for (p=imsg; *p; p++) {
      if (*p == '%') {
         switch (*++p) {
         case '%':
            str = "%";
            break;
         case 'a':
            str = dev_name;
            break;
         case 'e':
            if (num_dvd_parts == 0) {
               if (truncating || blank_dvd) {
                  str = "2";
               } else {
                  str = "1";
               }
            } else {
               str = "0";
            }
            break;
         case 'n':
            bsnprintf(add, sizeof(add), "%d", part);
            str = add;
            break;
         case 'm':
            str = device->mount_point;
            break;
         default:
            add[0] = '%';
            add[1] = *p;
            add[2] = 0;
            str = add;
            break;
         }
      } else {
         add[0] = *p;
         add[1] = 0;
         str = add;
      }
      Dmsg1(1900, "add_str %s\n", str);
      pm_strcat(omsg, (char *)str);
      Dmsg1(1800, "omsg=%s\n", omsg.c_str());
   }
}
开发者ID:prelegalwonder,项目名称:bacula,代码行数:67,代码来源:dev.c

示例8: get_config_include_path

bool CONFIG::get_config_include_path(POOL_MEM &full_path, const char *config_dir)
{
   bool found = false;

   if (m_config_include_dir) {
      /*
       * Set full_path to the initial part of the include path,
       * so it can be used as result, even on errors.
       * On success, full_path will be overwritten with the full path.
       */
      full_path.strcpy(config_dir);
      path_append(full_path, m_config_include_dir);
      if (path_is_directory(full_path)) {
         m_config_dir = bstrdup(config_dir);
         /*
          * Set full_path to wildcard path.
          */
         if (get_path_of_resource(full_path, NULL, NULL, NULL, true)) {
            m_use_config_include_dir = true;
            found = true;
         }
      }
   }

   return found;
}
开发者ID:razvip91,项目名称:bareos,代码行数:26,代码来源:parse_conf.c

示例9: get_and_display_basejobs

/* 
 * Fill the rx->BaseJobIds and display the list
 */
static void get_and_display_basejobs(UAContext *ua, RESTORE_CTX *rx)
{
   db_list_ctx jobids;

   if (!db_get_used_base_jobids(ua->jcr, ua->db, rx->JobIds, &jobids)) {
      ua->warning_msg("%s", db_strerror(ua->db));
   }
   
   if (jobids.count) {
      POOL_MEM q;
      Mmsg(q, uar_print_jobs, jobids.list);
      ua->send_msg(_("The restore will use the following job(s) as Base\n"));
      db_list_sql_query(ua->jcr, ua->db, q.c_str(), prtit, ua, 1, HORZ_LIST);
   }
   pm_strcpy(rx->BaseJobIds, jobids.list);
}
开发者ID:anarexia,项目名称:bacula,代码行数:19,代码来源:ua_restore.c

示例10: decoration

void OUTPUT_FORMATTER::decoration(const char *fmt, ...)
{
   POOL_MEM string;
   va_list arg_ptr;

   switch (api) {
   case API_MODE_ON:
   case API_MODE_JSON:
      break;
   default:
      va_start(arg_ptr, fmt);
      string.bvsprintf(fmt, arg_ptr);
      result_message_plain->strcat(string);
      va_end(arg_ptr);
      break;
   }
}
开发者ID:NextGenIntelligence,项目名称:bareos,代码行数:17,代码来源:output_formatter.c

示例11: add_file_and_part_name

static void add_file_and_part_name(DEVICE *dev, POOL_MEM &archive_name)
{
   char partnumber[20];

   if (!IsPathSeparator(archive_name.c_str()[strlen(archive_name.c_str())-1])) {
      pm_strcat(archive_name, "/");
   }

   pm_strcat(archive_name, dev->getVolCatName());
   /* if part > 1, append .# to the filename (where # is the part number) */
   if (dev->part > 1) {
      pm_strcat(archive_name, ".");
      bsnprintf(partnumber, sizeof(partnumber), "%d", dev->part);
      pm_strcat(archive_name, partnumber);
   }
   Dmsg2(400, "Exit add_file_part_name: arch=%s, part=%d\n",
                  archive_name.c_str(), dev->part);
}  
开发者ID:anarexia,项目名称:bacula,代码行数:18,代码来源:dvd.c

示例12: configure_lex_error_handler

static void configure_lex_error_handler(const char *file, int line, LEX *lc, POOL_MEM &msg)
{
   UAContext *ua;

   lc->error_counter++;
   if (lc->caller_ctx) {
      ua = (UAContext *)(lc->caller_ctx);
      ua->error_msg("configure error: %s\n", msg.c_str());
   };
}
开发者ID:dl5rcw,项目名称:bareos,代码行数:10,代码来源:ua_configure.c

示例13: bash_spaces

/* Convert spaces to non-space character.
 * This makes scanf of fields containing spaces easier.
 */
void
bash_spaces(POOL_MEM &pm)
{
   char *str = pm.c_str();
   while (*str) {
      if (*str == ' ')
         *str = 0x1;
      str++;
   }
}
开发者ID:NilByMouth,项目名称:bareos,代码行数:13,代码来源:util.c

示例14: unbash_spaces

/* Convert non-space characters (0x1) back into spaces */
void
unbash_spaces(POOL_MEM &pm)
{
   char *str = pm.c_str();
   while (*str) {
     if (*str == 0x1)
        *str = ' ';
     str++;
   }
}
开发者ID:NilByMouth,项目名称:bareos,代码行数:11,代码来源:util.c

示例15: send_accurate_current_files

/*
 * Send current file list to FD
 *    DIR -> FD : accurate files=xxxx
 *    DIR -> FD : /path/to/file\0Lstat
 *    DIR -> FD : /path/to/dir/\0Lstat
 *    ...
 *    DIR -> FD : EOD
 */
bool send_accurate_current_files(JCR *jcr)
{
   POOL_MEM buf;

   if (!jcr->accurate || job_canceled(jcr) || jcr->get_JobLevel()==L_FULL) {
      return true;
   }
   POOLMEM *jobids = get_pool_memory(PM_FNAME);

   db_accurate_get_jobids(jcr, jcr->db, &jcr->jr, jobids);

   if (*jobids == 0) {
      free_pool_memory(jobids);
      Jmsg(jcr, M_FATAL, 0, _("Cannot find previous jobids.\n"));
      return false;
   }
   Jmsg(jcr, M_INFO, 0, _("Sending Accurate information.\n"));

   /* to be able to allocate the right size for htable */
   POOLMEM *nb = get_pool_memory(PM_FNAME);
   *nb = 0;                           /* clear buffer */
   Mmsg(buf, "SELECT sum(JobFiles) FROM Job WHERE JobId IN (%s)",jobids);
   db_sql_query(jcr->db, buf.c_str(), db_get_int_handler, nb);
   Dmsg2(200, "jobids=%s nb=%s\n", jobids, nb);
   jcr->file_bsock->fsend("accurate files=%s\n", nb); 

   if (!db_open_batch_connexion(jcr, jcr->db)) {
      Jmsg0(jcr, M_FATAL, 0, "Can't get dedicate sql connexion");
      return false;
   }

   db_get_file_list(jcr, jcr->db_batch, jobids, accurate_list_handler, (void *)jcr);

   /* TODO: close the batch connexion ? (can be used very soon) */

   free_pool_memory(jobids);
   free_pool_memory(nb);

   jcr->file_bsock->signal(BNET_EOD);

   return true;
}
开发者ID:halgandd,项目名称:bacula,代码行数:50,代码来源:backup.c


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