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


C++ cfg_free函数代码示例

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


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

示例1: main

int main(void)
{
	cfg_t *acfg, *bcfg;
	cfg_t *sec;

	acfg = create_config();
	fail_unless(cfg_parse(acfg, SRC_DIR "/a.conf") == 0);

	bcfg = create_config();
	fail_unless(cfg_parse(bcfg, SRC_DIR "/b.conf") == 0);

	sec = cfg_getnsec(acfg, "sec", 0);
	fail_unless(sec != 0);
	fail_unless(cfg_size(acfg, "sec") == 1);
	fail_unless(strcmp(cfg_title(sec), "acfg") == 0);
	fail_unless(cfg_getint(sec, "a") == 5);
	fail_unless(cfg_getint(sec, "b") == 2);

	sec = cfg_getnsec(bcfg, "sec", 0);
	fail_unless(sec != 0);
	fail_unless(cfg_size(bcfg, "sec") == 1);
	fail_unless(strcmp(cfg_title(sec), "bcfg") == 0);
	fail_unless(cfg_getint(sec, "a") == 1);
	fail_unless(cfg_getint(sec, "b") == 9);

	cfg_free(acfg);
	cfg_free(bcfg);

	return 0;
}
开发者ID:Gikoskos,项目名称:libconfuse,代码行数:30,代码来源:suite_dup.c

示例2: calloc

static struct cfg_obj *create_obj(struct cfg_section *sec_head, char *name, char *value)
{
    struct cfg_obj *p = calloc(1, sizeof(struct cfg_obj));

    if (p == NULL)
    {
        cfg_free(sec_head);

        return NULL;
    }

    if ((p->name = strdup(name)) == NULL)
    {
        cfg_free(sec_head);

        return NULL;
    }

    if ((p->value = strdup(value)) == NULL)
    {
        cfg_free(sec_head);

        return NULL;
    }

    return p;
}
开发者ID:leevon,项目名称:rhizel,代码行数:27,代码来源:conf.c

示例3: main

int main(void)
{
	FILE *fp;
	char *param;
	cfg_t *cfg = cfg_init(opts, CFGF_NONE);

	fail_unless(cfg);

	/* set a string parameter to a string including a quote character
	 */
	cfg_setstr(cfg, "parameter", "text \" with quotes and \\");

	/* print the config to a temporary file
	 */
	fp = tmpfile();
	fail_unless(fp);
	cfg_print(cfg, fp);
	cfg_free(cfg);

	/* read it back, we expect 'parameter' to include a quote character
	 */
	rewind(fp);
	cfg = cfg_init(opts, CFGF_NONE);
	fail_unless(cfg);
	fail_unless(cfg_parse_fp(cfg, fp) == CFG_SUCCESS);
	fail_unless(fclose(fp) == 0);

	param = cfg_getstr(cfg, "parameter");
	fail_unless(param);

	fail_unless(strcmp(param, "text \" with quotes and \\") == 0);
	cfg_free(cfg);

	return 0;
}
开发者ID:Gikoskos,项目名称:libconfuse,代码行数:35,代码来源:quote_before_print.c

示例4: main_loop_reload_config_initiate

/* initiate configuration reload */
void
main_loop_reload_config_initiate(void)
{
  if (main_loop_is_terminating())
    return;

  service_management_publish_status("Reloading configuration");

  if (main_loop_new_config)
    {
      /* This block is entered only if this function is reentered before
       * main_loop_reload_config_apply() would be called.  In that case we
       * drop the previously parsed configuration and start over again to
       * ensure that the contents of the running configuration matches the
       * contents of the file at the time the SIGHUP signal was received.
       */
      cfg_free(main_loop_new_config);
      main_loop_new_config = NULL;
    }

  main_loop_old_config = current_configuration;
  app_pre_config_loaded();
  main_loop_new_config = cfg_new(0);
  if (!cfg_read_config(main_loop_new_config, resolvedConfigurablePaths.cfgfilename, FALSE, NULL))
    {
      cfg_free(main_loop_new_config);
      main_loop_new_config = NULL;
      main_loop_old_config = NULL;
      msg_error("Error parsing configuration",
                evt_tag_str(EVT_TAG_FILENAME, resolvedConfigurablePaths.cfgfilename));
      service_management_publish_status("Error parsing new configuration, using the old config");
      return;
    }
  main_loop_worker_sync_call(main_loop_reload_config_apply);
}
开发者ID:Cytrian,项目名称:syslog-ng,代码行数:36,代码来源:mainloop.c

示例5: main_loop_reload_config_apply

/* called to apply the new configuration once all I/O worker threads have finished */
static void
main_loop_reload_config_apply(void)
{
  if (main_loop_is_terminating())
    {
      if (main_loop_new_config)
        {
          cfg_free(main_loop_new_config);
          main_loop_new_config = NULL;
        }
      return;
    }
  main_loop_old_config->persist = persist_config_new();
  cfg_deinit(main_loop_old_config);
  cfg_persist_config_move(main_loop_old_config, main_loop_new_config);

  if (cfg_init(main_loop_new_config))
    {
      msg_verbose("New configuration initialized");
      persist_config_free(main_loop_new_config->persist);
      main_loop_new_config->persist = NULL;
      cfg_free(main_loop_old_config);
      current_configuration = main_loop_new_config;
      service_management_clear_status();
    }
  else
    {
      msg_error("Error initializing new configuration, reverting to old config");
      service_management_publish_status("Error initializing new configuration, using the old config");
      cfg_persist_config_move(main_loop_new_config, main_loop_old_config);
      cfg_deinit(main_loop_new_config);
      if (!cfg_init(main_loop_old_config))
        {
          /* hmm. hmmm, error reinitializing old configuration, we're hosed.
           * Best is to kill ourselves in the hope that the supervisor
           * restarts us.
           */
          kill(getpid(), SIGQUIT);
          g_assert_not_reached();
        }
      persist_config_free(main_loop_old_config->persist);
      main_loop_old_config->persist = NULL;
      cfg_free(main_loop_new_config);
      current_configuration = main_loop_old_config;
      goto finish;
    }

  /* this is already running with the new config in place */
  app_post_config_loaded();
  msg_notice("Configuration reload request received, reloading configuration");

 finish:
  main_loop_new_config = NULL;
  main_loop_old_config = NULL;

  return;
}
开发者ID:Cytrian,项目名称:syslog-ng,代码行数:58,代码来源:mainloop.c

示例6: locker

/*
* Destructor
*/
Settings::~Settings(void) {
	TelldusCore::MutexLocker locker(&mutex);
	if (d->cfg > 0) {
		cfg_free(d->cfg);
	}
	if (d->var_cfg > 0) {
		cfg_free(d->var_cfg);
	}
	delete d;
}
开发者ID:stromnet,项目名称:telldus,代码行数:13,代码来源:SettingsConfuse.cpp

示例7: malloc

RBTree *import_database()
{
  ProgressPtr process_file;
  FilePathList *list;
  char path[80];
  RBTree *tree;
  
  tree = malloc(sizeof(RBTree));
  list = malloc(sizeof(FilePathList));
  
  // For each file indicated by the file specified by argument, it will parse
  // its content, searching for words, and it will store them in the global
  // structure.
  process_file = ^(FilePathItem *item, int total_files){
      HashList hl;
      int result;

      printf("Reading file [%s] with id [%d/%d]\n", item->path, item->id + 1, total_files);
      
      hl_initialize(&hl, HASH_LIST_SIZE);
      
      result = create_local_structure(&hl, item->path);
      if ( result == 0 )
      {
          update_global_structure(tree, &hl, item->id);
          hl_free(&hl);
      }
  };
  
  cfg_init(list);

  printf("Mode multifil\n");

  printf("Nom del fitxer de configuració: ");
  scanf("%s", path);
  flush();
  
  cfg_import_config(path, list);
  //cfg_print(list);

  if ( list->size == 0 )
  {
    cfg_free(list);
    free(tree);
    return NULL;
  }

  initTree(tree, list->size);
  cfg_mt_iterate(list, process_file, 32);
  
  cfg_free(list);

  return tree;
}
开发者ID:Mithrandir0x,项目名称:so2,代码行数:54,代码来源:practica4.c

示例8: saveConfFile

BOOL saveConfFile(user_input_data *user_dat)
{
    FILE *U2Mconf_file = fopen(cfg_filename, "w");

    if (!U2Mconf_file) return FALSE;

    cfg_opt_t email_opts[] = {
        CFG_STR("From", user_dat->FROM, CFGF_NONE),
        CFG_STR("To", user_dat->TO, CFGF_NONE),
        CFG_STR("Cc", user_dat->CC, CFGF_NONE),
        CFG_STR("Subject", user_dat->SUBJECT, CFGF_NONE),
        CFG_STR("Body", user_dat->BODY, CFGF_NONE),
        CFG_STR("Password", user_dat->pass, CFGF_NONE),
        CFG_STR("SMTP_server", user_dat->SMTP_SERVER, CFGF_NONE),
        CFG_INT("Port_number", (int)user_dat->PORT, CFGF_NONE),
        CFG_END()
    };

    cfg_t *U2MConf = cfg_init(email_opts, CFGF_NONE);
    cfg_print(U2MConf, U2Mconf_file);

    fclose(U2Mconf_file);
    cfg_free(U2MConf);

    return TRUE;
}
开发者ID:Gikoskos,项目名称:USB2Email_Win32,代码行数:26,代码来源:U2MConf.c

示例9: cfg_new

static struct cfg *cfg_parse(const struct cfg_string *str, size_t *current, enum cfg_status *status) 
{
    struct cfg *cfg=NULL;
    //int beg_found=0;

    struct cfg_field *field=NULL;
    size_t end=0;
    if (!str) {
        *status = CFG_READ_ERROR;
        goto _cfg_parse_bail;
    }

    // beginning { is optional for overall config, but not sub-configs
    if (CFG_CFG_BEG == str->data[*current]) {
        (*current) += 1;
    }
    cfg = cfg_new();
    while (1) {
        *current = find_nonwhite(str, *current, status);
        if (*status) { // EOF OK here
            *status=CFG_SUCCESS;
            break;
        }
        if (str->data[*current] == CFG_CFG_END) {
            break;
        }

        field=cfg_get_field(str, (*current), &end, status);
        if (CFG_FOUND_END == (*status)) {
            // just found end of config, break out
            *status=CFG_SUCCESS;
            break;
        }
        if (*status) {
            // an error occured
            break;
        }
        if (!field) {
            // probably natural end of file found
            break;
        }


        cfg_append(cfg,field);

        if (str->data[end] == CFG_CFG_END) {
            *current = end;
            break;
        }

        // skip past either the last letter, end quote, end array delim, etc.
        (*current) = end+1;
    }

_cfg_parse_bail:
    if (*status) {
        cfg=cfg_free(cfg);
    }
    return cfg;
};
开发者ID:esheldon,项目名称:misc,代码行数:60,代码来源:config.c

示例10: main

int main(void)
{
	static cfg_opt_t section_opts[] = {
		CFG_STR("prop", 0, CFGF_NONE),
		CFG_END()
	};

	cfg_opt_t opts[] = {
		CFG_SEC("section", section_opts, CFGF_TITLE | CFGF_MULTI),
		CFG_END()
	};

	const char *config_data =
		"section title_one { prop = 'value_one' }\n"
		"section title_two { prop = 'value_two' }\n";

	int rc;
	cfg_t *cfg = cfg_init(opts, CFGF_NONE);

	fail_unless(cfg);

	rc = cfg_parse_buf(cfg, config_data);
	fail_unless(rc == CFG_SUCCESS);

	fail_unless(cfg_addtsec(cfg, "section", "title_three"));
	fail_unless(cfg_size(cfg, "section") == 3);
	fail_unless(cfg_title(cfg_gettsec(cfg, "section", "title_three")));

	/* attempt to add a pre-existing section should fail */
	fail_unless(!cfg_addtsec(cfg, "section", "title_three"));

	cfg_free(cfg);

	return 0;
}
开发者ID:jqyy,项目名称:libconfuse,代码行数:35,代码来源:section_add.c

示例11: exit_cleanup

/** Perform cleanup on normal exit */
static void
exit_cleanup(void)
{
  debug("Cleaning resources up");

  /* Destroy CM window, thus giving up _NET_WM_CM_Sn ownership */
  if(globalconf.cm_window != XCB_NONE)
    xcb_destroy_window(globalconf.connection, globalconf.cm_window);

  /* Free resources related to the plugins */
  plugin_unload_all();

  /* Destroy the  linked-list of  windows which has  to be  done after
     unloading the plugins as the  plugins may use the windows list to
     free memory */
  window_list_cleanup();

  /* Free resources related  to the rendering backend which  has to be
     done  after the  windows  list  cleanup as  the  latter free  the
     rendering information associated with each window */
  rendering_unload();

  /* Free resources related to the keymaps */
  xcb_key_symbols_free(globalconf.keysyms);

  /* Free resources related to EWMH */
  xcb_ewmh_connection_wipe(&globalconf.ewmh);

  cfg_free(globalconf.cfg);
  free(globalconf.rendering_dir);
  free(globalconf.plugins_dir);

  xcb_disconnect(globalconf.connection);
}
开发者ID:ehntoo,项目名称:unagi,代码行数:35,代码来源:unagi.c

示例12: test_config

void test_config(void) {
    CfgFile* cfg = NULL;
    const char* file = NULL;
    const char* cfgname = NULL;

    file = "test.cfg";

    cfgname = "Test1";
    g_print("\n\rLoading '%s' configuration...\n\r", cfgname);
    cfg = cfg_load(file, cfgname);
    test_config_print_cfg(cfg);

    cfgname = "Test2";
    g_print("Loading '%s' configuration...\n\r", cfgname);
    cfg = cfg_load(file, cfgname);
    test_config_print_cfg(cfg);

    cfgname = "Test3";
    g_print("Creating a test configuration...\n\r");
    cfg = cfg_new(file, cfgname);

    cfg_add_item(cfg, "KeyT3_1", "Value1");
    cfg_add_item(cfg, "KeyT3_2", "Value2");
    cfg_add_item(cfg, "KeyT3_3", "Value3");

    g_print("Add the '%s' configuration\n\r", cfgname);
    cfg_store(cfg);

    g_print("The configuration size is %u...\n\r", cfg_get_size(cfg));
    g_print("Free up configuration resources...\n\r");

    cfg_free(cfg);
}
开发者ID:sawkita,项目名称:modular_framework,代码行数:33,代码来源:tester.c

示例13: main

int main(int argc, char *argv[])
{
    // Initialise the cfg structure (this sets up a linked list
    // of key / value pairs)
    struct Config *cfg = cfg_init("settings.cfg");

    // Search for a key. Note that the return value is a pointer
    // in the cfg structure so should NOT be freed (it is freed
    // eventually by cfg_free.);
    char *value = cfg_get_string(cfg, "barney", "The default value");
    printf("\"%s\"\n", value);

    // Search for a non-existent key to show default value being returned
    char *value2 = cfg_get_string(cfg, "non-existent", "A default value");
    printf("\"%s\"\n", value2);

    // Get a number
    long num = cfg_get_long(cfg, "NuMbEr", 69);
    printf("Number is %ld\n", num);

    // Dump everything - showing the cfg_foreach() function
    printf("DEBUG dump all:\n");
    cfg_foreach(cfg, callback);

    // Finally tear down the cfg structure. This will invalidate any 
    // strings we've been returned, so we should make copies of 
    // anything we want to keep first.
    cfg_free(cfg);

    return 0;
}
开发者ID:md81544,项目名称:c,代码行数:31,代码来源:main.c

示例14: get_db_info

db_info * get_db_info(const char * filename){

   cfg_opt_t * opts = get_opt();

   cfg_t *cfg;

   cfg = cfg_init(opts, CFGF_NONE);
   cfg_parse(cfg, filename);

   db_info * info;
   info = (db_info*)malloc(sizeof(db_info));

   char * user = cfg_getstr(cfg, "user");
   char * password = cfg_getstr(cfg,"password");
   char * dbname = cfg_getstr(cfg,"dbname");
   char * ip = cfg_getstr(cfg,"ip");
   
   info->user = (char*)malloc(strlen(user)*sizeof(char));
   info->password = (char*)malloc(strlen(user)*sizeof(char));
   info->dbname = (char*)malloc(strlen(user)*sizeof(char));
   info->ip = (char*)malloc(strlen(user)*sizeof(char));
   
   strcpy(info->user,user);
   strcpy(info->password,password);
   strcpy(info->dbname,dbname);
   strcpy(info->ip,ip);
   info->port = cfg_getint(cfg,"port");

   cfg_free(cfg);

   return info;
}
开发者ID:CristopherLeal,项目名称:SVMClassifier,代码行数:32,代码来源:config.c

示例15: read_config

int read_config(const char *filename, section_t &config)
{
   static const char *funcname = "conf::read_config";

   section_ptrs ptrs;
   build_section(&config, ptrs);

   cfg_t *cfg = cfg_init(ptrs[0].get(), CFGF_NONE);
   cfg_set_error_function(cfg, cfg_error_fnc);

   switch(cfg_parse(cfg, filename))
   {
      case CFG_FILE_ERROR:
         throw logging::error(funcname, "Configuration file '%s' cannot be read: %s", filename, strerror(errno));
      case CFG_PARSE_ERROR:
         throw logging::error(funcname, "Errors were encountered during config reading.");
      default:
         throw logging::error(funcname, "cfg_parse() returned unexpected value");

      case CFG_SUCCESS: break;
   }   

   std::stringstream errors;
   read_cfg_section(&config, cfg, errors);
   cfg_free(cfg);

   errors.peek();
   if (!errors.eof())
   {
      for (std::string line; getline(errors, line); )
         logger.log_message(LOG_ERR, funcname, line.c_str());
      return 0;
   }
   return 1;
}
开发者ID:oioi,项目名称:zbx_tools,代码行数:35,代码来源:config.cpp


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