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


C++ cfg_size函数代码示例

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


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

示例1: locker

/*
* Return the number of stored devices
*/
int Settings::getNumberOfNodes(Node node) const {
	TelldusCore::MutexLocker locker(&mutex);
	if (d->cfg > 0) {
		if (node == Device) {
			return cfg_size(d->cfg, "device");
		} else if (node == Controller) {
			return cfg_size(d->cfg, "controller");
		}
	}
	return 0;
}
开发者ID:stromnet,项目名称:telldus,代码行数:14,代码来源:SettingsConfuse.cpp

示例2: parse_mapping_cfg_params

int
parse_mapping_cfg_params(cfg_t *map, conf_mapping_t *conf_mapping, uint8_t is_local)
{

    int ctr;
    cfg_t *rl;
    conf_loc_t *conf_loc;
    conf_loc_iface_t *conf_loc_iface;
    int afi;

    strcpy(conf_mapping->eid_prefix,cfg_getstr(map, "eid-prefix"));
    conf_mapping->iid = cfg_getint(map, "iid");

    for (ctr = 0; ctr < cfg_size(map, "rloc-address"); ctr++){
        rl = cfg_getnsec(map, "rloc-address", ctr);
        conf_loc = conf_loc_new_init(
                cfg_getstr(rl, "address"),
                cfg_getint(rl, "priority"),
                cfg_getint(rl, "weight"),
                255,0);
        glist_add_tail(conf_loc,conf_mapping->conf_loc_list);
    }

    if (is_local){

        for (ctr = 0; ctr < cfg_size(map, "rloc-iface"); ctr++){
            rl = cfg_getnsec(map, "rloc-iface", ctr);
            afi = cfg_getint(rl, "ip_version");
            if (afi == 4){
                afi = AF_INET;
            }else if (afi == 6){
                afi = AF_INET6;
            }else{
                OOR_LOG(LERR,"Configuration file: The conf_loc_iface->ip_version of the locator should be 4 (IPv4) or 6 (IPv6)");
                return (BAD);
            }
            conf_loc_iface = conf_loc_iface_new_init(
                    cfg_getstr(rl, "interface"),
                    afi,
                    cfg_getint(rl, "priority"),
                    cfg_getint(rl, "weight"),
                    255,0);
            glist_add_tail(conf_loc_iface,conf_mapping->conf_loc_iface_list);
        }
    }

    return (GOOD);
}
开发者ID:muharif,项目名称:oor2,代码行数:48,代码来源:oor_config_confuse.c

示例3: 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

示例4: file_path_ignore

/* Checks if the file path is configured to be ignored */
static int
file_path_ignore(const char *path)
{
  cfg_t *lib;
  regex_t regex;
  int n;
  int i;
  int ret;

  lib = cfg_getsec(cfg, "library");
  n = cfg_size(lib, "filepath_ignore");

  for (i = 0; i < n; i++)
    {
      ret = regcomp(&regex, cfg_getnstr(lib, "filepath_ignore", i), 0);
      if (ret != 0)
	{
	  DPRINTF(E_LOG, L_SCAN, "Could not compile regex for matching with file path\n");
	  return 0;
	}

      ret = regexec(&regex, path, 0, NULL, 0);
      regfree(&regex);

      if (ret == 0)
	{
	  DPRINTF(E_DBG, L_SCAN, "Regex match: %s\n", path);
	  return 1;
	}
    }

  return 0;
}
开发者ID:snourry,项目名称:forked-daapd,代码行数:34,代码来源:filescanner.c

示例5: print_systems

static void print_systems(cfg_t *cfg)
{
	size_t i;

	for (i = 0; i < cfg_size(cfg, "provider"); i++)
		print_system(cfg_getnsec(cfg, "provider", i));
}
开发者ID:troglobit,项目名称:toolbox,代码行数:7,代码来源:confuse.c

示例6: E_ProcessInventoryDefs

//
// E_ProcessInventoryDefs
//
// Resolves and loads all information for the inventory structures.
//
void E_ProcessInventoryDefs(cfg_t *cfg)
{
   unsigned int i, numInventory;

   E_EDFLogPuts("\t* Processing inventory data\n");

   if(!(numInventory = cfg_size(cfg, EDF_SEC_INVENTORY)))
      return;

   // allocate inheritance stack and hitlist
   inv_pstack = ecalloc(inventory_t **, numInventoryDefs, sizeof(inventory_t *));

   // TODO: any first-time-only processing?

   for(i = 0; i < numInventory; i++)
   {
      cfg_t       *invsec = cfg_getnsec(cfg, EDF_SEC_INVENTORY, i);
      const char  *name   = cfg_title(invsec);
      inventory_t *inv    = E_InventoryForName(name);

      // reset the inheritance stack
      E_ResetInventoryPStack();

      // add this def to the stack
      E_AddInventoryToPStack(inv);

      E_ProcessInventory(inv, invsec, cfg, true);

      E_EDFLogPrintf("\t\tFinished inventory %s(#%d)\n", inv->name, inv->numkey);
   }

   // free tables
   efree(inv_pstack);
}
开发者ID:doomtech,项目名称:eternity,代码行数:39,代码来源:e_inventory.cpp

示例7: parse_script

int parse_script(char *filename, script_ent_t * script) {
    cfg_t *pcfg;
    int i;

    memset(script, 0, sizeof(script_ent_t));

    printf("eins\n");
    pcfg = cfg_init(script_opts, CFGF_NONE);
    printf("zwei\n");
    if (cfg_parse(pcfg, filename) == CFG_PARSE_ERROR)
	return -1;

    strcpy(script->name, cfg_getstr(pcfg, "name"));	/* max 28 chars !!! */
    strcpy(script->org_name, cfg_getstr(pcfg, "org_name"));	/* max 64 chars !!! */
    strcpy(script->comment, cfg_getstr(pcfg, "comment"));	/* max 128 chars !!! */

    script->script_num = cfg_getint(pcfg, "id");
    script->version = cfg_getint(pcfg, "version");
    script->unused1 = cfg_getint(pcfg, "unused1");

    script->script_length = cfg_size(pcfg, "script");
    if (script->script_length & 1) {
	printf("WARNING: odd number of bytes in script ... truncating\n");
    }
    script->script_length >>= 1;
    for (i = 0; i < (script->script_length << 1); i++)
	script->script[i] = (uint8_t) cfg_getnint(pcfg, "script", i);

    cfg_free(pcfg);
    return 0;
}
开发者ID:GBert,项目名称:misc,代码行数:31,代码来源:pk2dft.c

示例8: E_MetaTableFromCfg

//
// E_MetaTableFromCfg
//
// haleyjd 06/30/13: Convert a cfg_t to fields in a MetaTable, with optional
// inheritance from a prototype table.
//
void E_MetaTableFromCfg(cfg_t *cfg, MetaTable *table, MetaTable *prototype)
{
   table->clearTable();

   if(prototype)
   {
      table->copyTableFrom(prototype);
      table->setString("super", prototype->getKey());
   }

   for(auto opt = cfg->opts; opt->type != CFGT_NONE; opt++)
   {
      if(cfg_size(cfg, opt->name) == 0)
         continue;

      switch(opt->type)
      {
      case CFGT_INT:
         E_MetaIntFromCfgInt(table, cfg, opt->name);
         break;
      case CFGT_STR:
         E_MetaStringFromCfgString(table, cfg, opt->name);
         break;
      case CFGT_BOOL:
         E_MetaIntFromCfgBool(table, cfg, opt->name);
         break;
      case CFGT_FLAG:
         E_MetaIntFromCfgFlag(table, cfg, opt->name);
         break;
      default:
         break;
      }
   }
}
开发者ID:Blastfrog,项目名称:eternity,代码行数:40,代码来源:e_lib.cpp

示例9: getNodeString

int Settings::setIntSetting(Node type, int intDeviceId, const std::wstring &name, int value, bool parameter) {
	// already locked
	if (d->cfg == 0) {
		return TELLSTICK_ERROR_PERMISSION_DENIED;
	}
	std::string strType = getNodeString(type);
	cfg_t *cfg_device;
	for (int i = 0; i < cfg_size(d->cfg, strType.c_str()); ++i) {
		cfg_device = cfg_getnsec(d->cfg, strType.c_str(), i);
		if (cfg_getint(cfg_device, "id") == intDeviceId)  {
			if (parameter) {
				cfg_t *cfg_parameters = cfg_getsec(cfg_device, "parameters");
				cfg_setint(cfg_parameters, TelldusCore::wideToString(name).c_str(), value);
			} else {
				cfg_setint(cfg_device, TelldusCore::wideToString(name).c_str(), value);
			}
			FILE *fp = fopen(CONFIG_FILE, "we");  // e for setting O_CLOEXEC on the file handle
			if (!fp) {
				return TELLSTICK_ERROR_PERMISSION_DENIED;
			}
			cfg_print(d->cfg, fp);
			fclose(fp);
			return TELLSTICK_SUCCESS;
		}
	}
	return TELLSTICK_ERROR_DEVICE_NOT_FOUND;
}
开发者ID:stromnet,项目名称:telldus,代码行数:27,代码来源:SettingsConfuse.cpp

示例10: main

int main(void)
{
    unsigned int i;

    read_config();
    signal(SIGHUP, sighandler);
    signal(SIGUSR1, usr1handler);

    while(loop)
    {
        printf("Message: %s", cfg_getstr(cfg, "message"));
        for(i = 0; i < cfg_size(cfg, "argument"); i++)
        {
            cfg_t *arg = cfg_getnsec(cfg, "argument", i);
            printf(", %s", cfg_getstr(arg, "value"));
        }
        printf("\n");

        sleep(cfg_getint(cfg, "delay"));
    }

    cfg_free(cfg);
    cfg = 0;

    return 0;
}
开发者ID:DSMan195276,项目名称:libconfuse,代码行数:26,代码来源:reread.c

示例11: E_ProcessSpriteVars

//
// E_ProcessSpriteVars
//
// Sets the sprite numbers to be used for the player and blank
// sprites by looking up a provided name in the sprite hash
// table.
//
static void E_ProcessSpriteVars(cfg_t *cfg)
{
   static bool firsttime = true;
   int sprnum;
   const char *str;

   E_EDFLogPuts("\t* Processing sprite variables\n");

   // haleyjd 11/11/09: removed processing of obsolete playersprite variable

   // haleyjd 11/21/11: on subsequent runs, only replace if changed
   if(!firsttime && cfg_size(cfg, ITEM_BLANKSPRITE) == 0)
      return;

   firsttime = false;

   // load blank sprite number

   str = cfg_getstr(cfg, ITEM_BLANKSPRITE);
   sprnum = E_SpriteNumForName(str);
   if(sprnum == -1)
   {
      E_EDFLoggedErr(2, 
         "E_ProcessSpriteVars: invalid blank sprite name: '%s'\n", str);
   }
   E_EDFLogPrintf("\t\tSet sprite %s(#%d) as blank sprite\n", str, sprnum);
   blankSpriteNum = sprnum;
}
开发者ID:fragglet,项目名称:autodoom,代码行数:35,代码来源:e_edf.cpp

示例12: parse_database_mapping

int
parse_database_mapping(cfg_t *cfg, lisp_xtr_t *xtr, shash_t *lcaf_ht)
{
    int n,i;
    mapping_t *mapping;
    map_local_entry_t *map_loc_e;
    void *fwd_map_inf;

    n = cfg_size(cfg, "database-mapping");
    for (i = 0; i < n; i++) {
        mapping = parse_mapping(cfg_getnsec(cfg, "database-mapping", i),&(xtr->super),lcaf_ht,TRUE);
        if (mapping == NULL){
            continue;
        }
        map_loc_e = map_local_entry_new_init(mapping);
        if (map_loc_e == NULL){
            mapping_del(mapping);
            continue;
        }
        fwd_map_inf = xtr->fwd_policy->new_map_loc_policy_inf(xtr->fwd_policy_dev_parm,mapping,NULL);
        if (fwd_map_inf == NULL){
            OOR_LOG(LERR, "Couldn't create forward information for mapping with EID: %s. Discarding it...",
                    lisp_addr_to_char(mapping_eid(mapping)));
            map_local_entry_del(map_loc_e);
            continue;
        }
        map_local_entry_set_fwd_info(map_loc_e, fwd_map_inf, xtr->fwd_policy->del_map_loc_policy_inf);
        if (add_local_db_map_local_entry(map_loc_e,xtr) != GOOD){
            map_local_entry_del(map_loc_e);
            continue;
        }
    }

    return (GOOD);
}
开发者ID:muharif,项目名称:oor2,代码行数:35,代码来源:oor_config_confuse.c

示例13: parse_mcinfo_list

static void
parse_mcinfo_list(cfg_t *cfg, shash_t *ht)
{
    mc_t *mc;
    lisp_addr_t *laddr;
    char *name;
    int i, count;

    count = 0;
    for (i = 0; i < cfg_size(cfg, "multicast-info"); i++) {
        cfg_t *mcnode = cfg_getnsec(cfg, "multicast-info", i);
        name = cfg_getstr(mcnode, "mc-info-name");

        laddr = lisp_addr_new_lafi(LM_AFI_LCAF);
        lisp_addr_lcaf_set_type(laddr, LCAF_MCAST_INFO);

        mc = mc_type_new();
        lisp_addr_ip_from_char(cfg_getstr(mcnode, "source"), mc->src);
        mc->src_plen = cfg_getint(mcnode, "source-mask-length");
        lisp_addr_ip_from_char(cfg_getstr(mcnode, "group"), mc->grp);
        mc->src_plen = cfg_getint(mcnode, "group-mask-length");
        mc->iid = cfg_getint(mcnode, "iid");

        lisp_addr_lcaf_set_addr(laddr, mc);
        OOR_LOG(LDBG_1, "Configuration file: parsed multicast-info: %s",
                lisp_addr_to_char(laddr));

        shash_insert(ht, strdup(name), laddr);
        count ++;
    }

    if (count != 0) {
        OOR_LOG(LINF, "Parsed configured multicast addresses");
    }
}
开发者ID:muharif,项目名称:oor2,代码行数:35,代码来源:oor_config_confuse.c

示例14: find_module_config

static cfg_t* find_module_config(char *modname)
{
    cfg_t *modules_cfg;
    int j;

    modules_cfg = cfg_getsec(python_module.config_file, "modules");
    for (j = 0; j < cfg_size(modules_cfg, "module"); j++) {
        char *modName, *modLanguage;
        int modEnabled;

        cfg_t *pymodule = cfg_getnsec(modules_cfg, "module", j);

        /* Check the module language to make sure that
           the language designation is python.
        */
        modLanguage = cfg_getstr(pymodule, "language");
        if (!modLanguage || strcasecmp(modLanguage, "python")) 
            continue;

        modName = cfg_getstr(pymodule, "name");
        if (strcasecmp(modname, modName)) {
            continue;
        }

        /* Check to make sure that the module is enabled.
        */
        modEnabled = cfg_getbool(pymodule, "enabled");
        if (!modEnabled) 
            continue;

        return pymodule;
    }
    return NULL; 
}
开发者ID:AsherBond,项目名称:monitor-core,代码行数:34,代码来源:mod_python.c

示例15: add_filter_restrictions

static void add_filter_restrictions(filter *f, cfg_t *sec)
{
    for (int i = 0; i < NUM_FILTER_OPTIONS; ++i) {
        filter_option *opt = &filter_options[i];
        if (cfg_size(sec, opt->config_name)) {
            switch (opt->type) {
                case FILTER_OPTION_TYPE_BOOL: {
                    int value = cfg_getbool(sec, opt->config_name) == cfg_true ? 1 : 0;
                    filter_add_restriction_bool(f, opt->data.property_name, value);
                    break;
                }
                case FILTER_OPTION_TYPE_STRING: {
                    const char *value = cfg_getstr(sec, opt->config_name);
                    filter_add_restriction_string(f, opt->data.property_name, value);
                    break;
                }
                case FILTER_OPTION_TYPE_CUSTOM: {
                    intptr_t value = cfg_getbool(sec, opt->config_name) == cfg_true ? 1 : 0;
                    filter_add_restriction_custom(f, opt->data.custom.match_func,
                            opt->data.custom.free_func, opt->data.custom.cookie, value);
                    break;
                }
                default:
                    assert(0);
                    break;
            }
        }
    }
}
开发者ID:codeparity,项目名称:udisks-glue,代码行数:29,代码来源:filters.c


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