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

C++ ARRAYLENGTH函数代码示例

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

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



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

示例1: inter_parse_frommap

int inter_parse_frommap(int fd)
{
	int cmd;
	int len = 0;
	cmd = RFIFOW(fd,0);
	// inter鯖管轄かを調べる
	if(cmd < 0x3000 || cmd >= 0x3000 + ARRAYLENGTH(inter_recv_packet_length) || inter_recv_packet_length[cmd - 0x3000] == 0)
		return 0;

	// パケット長を調べる
	if((len = inter_check_length(fd, inter_recv_packet_length[cmd - 0x3000])) == 0)
		return 2;

	switch(cmd) {
	case 0x3000: mapif_parse_broadcast(fd); break;
	case 0x3001: mapif_parse_WisRequest(fd); break;
	case 0x3002: mapif_parse_WisReply(fd); break;
	case 0x3003: mapif_parse_WisToGM(fd); break;
	case 0x3004: mapif_parse_Registry(fd); break;
	case 0x3005: mapif_parse_RegistryRequest(fd); break;
	case 0x3006: mapif_parse_NameChangeRequest(fd); break;
	default:
		if(  inter_party_parse_frommap(fd)
		  || inter_guild_parse_frommap(fd)
		  || inter_storage_parse_frommap(fd)
		  || inter_pet_parse_frommap(fd)
		  || inter_homunculus_parse_frommap(fd)
		  || inter_mercenary_parse_frommap(fd)
		  || inter_mail_parse_frommap(fd)
		  || inter_auction_parse_frommap(fd)
		  || inter_quest_parse_frommap(fd)
		   )
			break;
		else
			return 0;
	}

	RFIFOSKIP(fd, len);
	return 1;
}
开发者ID:Aeromesi,项目名称:PkRO_Translation,代码行数:40,代码来源:inter.c


示例2: read_homunculus_expdb

void read_homunculus_expdb(void)
{
	int i;
	char *filename[]={
		DBPATH"exp_homun.txt",
		DBIMPORT"/exp_homun.txt"
	};

	memset(hexptbl,0,sizeof(hexptbl));
	for(i=0; i<ARRAYLENGTH(filename); i++){
		FILE *fp;
		char line[1024];
		int j=0;
		
		sprintf(line, "%s/%s", db_path, filename[i]);
		fp=fopen(line,"r");
		if(fp == NULL){
			if(i != 0)
				continue;
			if(i==0) ShowError("Can't read %s\n",line);
			return;
		}
		while(fgets(line, sizeof(line), fp) && j < MAX_LEVEL)
		{
			if(line[0] == '/' && line[1] == '/')
				continue;

			hexptbl[j] = strtoul(line, NULL, 10);
			if (!hexptbl[j++])
				break;
		}
		if (hexptbl[MAX_LEVEL - 1]) // Last permitted level have to be 0!
		{
			ShowWarning("read_hexptbl: Reached max level in %s [%d]. Remaining lines were not read.\n ",filename,MAX_LEVEL);
			hexptbl[MAX_LEVEL - 1] = 0;
		}
		fclose(fp);
		ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' levels in '"CL_WHITE"%s/%s"CL_RESET"'.\n", j, db_path, filename[i]);
	}
}
开发者ID:2serv,项目名称:rathena,代码行数:40,代码来源:homunculus.c


示例3: chat_createchat

/// Initializes a chatroom object (common functionality for both pc and npc chatrooms).
/// Returns a chatroom object on success, or NULL on failure.
static struct chat_data* chat_createchat(struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl)
{
	struct chat_data* cd;
	nullpo_retr(NULL, bl);

	cd = (struct chat_data *) aMalloc(sizeof(struct chat_data));

	safestrncpy(cd->title, title, sizeof(cd->title));
	safestrncpy(cd->pass, pass, sizeof(cd->pass));
	cd->pub = pub;
	cd->users = 0;
	cd->limit = min(limit, ARRAYLENGTH(cd->usersd));
	cd->trigger = trigger;
	cd->zeny = zeny;
	cd->minLvl = minLvl;
	cd->maxLvl = maxLvl;
	memset(cd->usersd, 0, sizeof(cd->usersd));
	cd->owner = bl;
	safestrncpy(cd->npc_event, ev, sizeof(cd->npc_event));

	cd->bl.id   = map_get_new_object_id();
	cd->bl.m    = bl->m;
	cd->bl.x    = bl->x;
	cd->bl.y    = bl->y;
	cd->bl.type = BL_CHAT;
	cd->bl.next = cd->bl.prev = NULL;

	if( cd->bl.id == 0 )
	{
		aFree(cd);
		cd = NULL;
	}

	map_addiddb(&cd->bl);

	if( bl->type != BL_NPC )
		cd->kick_list = idb_alloc(DB_OPT_BASE);
	
	return cd;
}
开发者ID:Jefte-Netyul,项目名称:Radices,代码行数:42,代码来源:chat.c


示例4: handle_kmsg_cred_new_creds

/* Handler for KMSG_CRED_NEW_CREDS */
khm_int32
handle_kmsg_cred_new_creds(khui_new_creds * nc) {

    wchar_t wshortdesc[KHUI_MAXCCH_SHORT_DESC];
    size_t cb = 0;
    struct nc_dialog_data * d;

    /* This is a minimal handler that just adds a dialog pane to the
       new credentials window to handle new credentials acquisition
       for this credentials type. */

    /* TODO: add additional initialization etc. as needed */

    d = malloc(sizeof(*d));
    ZeroMemory(d, sizeof(*d));

    d->nct.type = credtype_id;
    d->nct.ordinal = -1;

    LoadString(hResModule, IDS_CT_SHORT_DESC,
               wshortdesc, ARRAYLENGTH(wshortdesc));
    StringCbLength(wshortdesc, sizeof(wshortdesc), &cb);
#ifdef DEBUG
    assert(cb > 0);
#endif
    cb += sizeof(wchar_t);

    d->nct.name = malloc(cb);
    StringCbCopy(d->nct.name, cb, wshortdesc);

    d->nct.h_module = hResModule;
    d->nct.dlg_proc = nc_dlg_proc;
    d->nct.dlg_template = MAKEINTRESOURCE(IDD_NEW_CREDS);

    khui_cw_add_type(nc, &d->nct);

    khui_cw_add_selector(nc, idsel_factory, NULL);

    return KHM_ERROR_SUCCESS;
}
开发者ID:secure-endpoints,项目名称:netidmgr,代码行数:41,代码来源:credacq.c


示例5: chat_createchat

/// Initializes a chatroom object (common functionality for both pc and npc chatrooms).
/// Returns a chatroom object on success, or NULL on failure.
struct chat_data* chat_createchat(struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl)
{
    struct chat_data* cd;
    nullpo_retr(NULL, bl);

    /* Given the overhead and the numerous instances (npc allocated or otherwise) wouldn't it be beneficial to have it use ERS? [Ind] */
    cd = (struct chat_data *) aMalloc(sizeof(struct chat_data));

    safestrncpy(cd->title, title, sizeof(cd->title));
    safestrncpy(cd->pass, pass, sizeof(cd->pass));
    cd->pub = pub;
    cd->users = 0;
    cd->limit = min(limit, ARRAYLENGTH(cd->usersd));
    cd->trigger = trigger;
    cd->zeny = zeny;
    cd->minLvl = minLvl;
    cd->maxLvl = maxLvl;
    memset(cd->usersd, 0, sizeof(cd->usersd));
    cd->owner = bl;
    safestrncpy(cd->npc_event, ev, sizeof(cd->npc_event));

    cd->bl.id   = map->get_new_object_id();
    cd->bl.m    = bl->m;
    cd->bl.x    = bl->x;
    cd->bl.y    = bl->y;
    cd->bl.type = BL_CHAT;
    cd->bl.next = cd->bl.prev = NULL;

    if( cd->bl.id == 0 ) {
        aFree(cd);
        return NULL;
    }

    map->addiddb(&cd->bl);

    if( bl->type != BL_NPC )
        cd->kick_list = idb_alloc(DB_OPT_BASE);

    return cd;
}
开发者ID:kwang1go,项目名称:Hercules,代码行数:42,代码来源:chat.c


示例6: k4_update_display

void k4_update_display(k4_dlg_data * d, BOOL update_methods) {
    CheckDlgButton(d->hwnd, IDC_NCK4_OBTAIN,
                   (d->k4_enabled)?BST_CHECKED: BST_UNCHECKED);

    if (d->k4_enabled) {
        EnableWindow(GetDlgItem(d->hwnd, IDC_NCK4_AUTO), TRUE);
        EnableWindow(GetDlgItem(d->hwnd, IDC_NCK4_K524), TRUE);
        EnableWindow(GetDlgItem(d->hwnd, IDC_NCK4_PWD ), TRUE);
    } else {
        EnableWindow(GetDlgItem(d->hwnd, IDC_NCK4_AUTO), FALSE);
        EnableWindow(GetDlgItem(d->hwnd, IDC_NCK4_K524), FALSE);
        EnableWindow(GetDlgItem(d->hwnd, IDC_NCK4_PWD ), FALSE);
    }

#ifdef DEBUG
    assert(d->method >= 0 && d->method < ARRAYLENGTH(method_to_id));
#endif

    CheckRadioButton(d->hwnd, IDC_NCK4_AUTO, IDC_NCK4_PWD, method_to_id[d->method]);

    khui_cw_enable_type(d->nc, credtype_id_krb4, d->k4_enabled);
}
开发者ID:secure-endpoints,项目名称:netidmgr,代码行数:22,代码来源:krb4newcreds.c


示例7: console_load_defaults

void console_load_defaults(void) {
	struct {
		char *name;
		CParseFunc func;
		char *connect;
		struct CParseEntry *self;
	} default_list[] = {
		CP_DEF(help),
		CP_DEF_C(server),
		CP_DEF_S(ers_report,server),
		CP_DEF_S(mem_report,server),
		CP_DEF_S(malloc_usage,server),
		CP_DEF_S(exit,server),
	};
	unsigned int i, len = ARRAYLENGTH(default_list);
	struct CParseEntry *cmd;
	
	RECREATE(console->cmds,struct CParseEntry *, len);
	
	for(i = 0; i < len; i++) {
		CREATE(cmd, struct CParseEntry, 1);
		
		safestrncpy(cmd->cmd, default_list[i].name, CP_CMD_LENGTH);
		
		if( default_list[i].func )
			cmd->u.func = default_list[i].func;
		else
			cmd->u.next = NULL;
		
		cmd->next_count = 0;
		
		console->cmd_count++;
		console->cmds[i] = cmd;
		default_list[i].self = cmd;
		if( !default_list[i].connect ) {
			RECREATE(console->cmd_list,struct CParseEntry *, ++console->cmd_list_count);
			console->cmd_list[console->cmd_list_count - 1] = cmd;
		}
	}
开发者ID:Carlinhos55,项目名称:Cronus,代码行数:39,代码来源:console.c


示例8: va_start

void
HttpRequest::ReportStatus(kherr_severity severity,
                          const wchar_t * message,
                          const wchar_t * long_desc, ...)
{
    HttpRequestStatusListener * listener;
    va_list args;
    DWORD gle;

    va_start(args, long_desc);
    gle = GetLastError();

    listener = (HttpRequestStatusListener *) m_listener;

    if (listener && !m_muted) {
        wchar_t ld[2048];

        if (long_desc)
            StringCchVPrintf(ld, ARRAYLENGTH(ld), long_desc, args);
        listener->HttpRequestStatus(severity, message, ((long_desc)? ld: NULL));
    }
}
开发者ID:secure-endpoints,项目名称:netidmgr,代码行数:22,代码来源:HttpRequest.cpp


示例9: memset

void
HttpRequest::FetchImageFromURL()
{
    HANDLE hFile = INVALID_HANDLE_VALUE;

    do {
        URL_COMPONENTS uc;
        wchar_t domain[MAX_PATH];

        memset(&uc, 0, sizeof(uc));
        uc.dwStructSize = sizeof(uc);
        uc.lpszHostName = domain;
        uc.dwHostNameLength = ARRAYLENGTH(domain);
        uc.lpszUrlPath = NULL;
        uc.dwUrlPathLength = 1;

        if (!WinHttpCrackUrl(m_target.c_str(), 0, 0, &uc))
            break;

        FetchResource(domain, uc.lpszUrlPath, image_mimetypes);

    } while(FALSE);
}
开发者ID:secure-endpoints,项目名称:netidmgr,代码行数:23,代码来源:HttpRequest.cpp


示例10: load_message_file_source

void load_message_file_source(void)
{
#define ARRAYLENGTH(A) ( sizeof(A)/sizeof((A)[0]) )
	config_setting_t *main_group = NULL;
	config_t group_ext;
	int index=0;
	
	if (libconfig->read_file(&group_ext, bra_config.lang_file))
		return;
	
	memset(lang_s, 0, sizeof(LANG));
	
	if((main_group = config_lookup(&group_ext, "Source"))) {
		int i, h, k = 0, groups_count = libconfig->setting_length(main_group);
		config_setting_t *group_ele;
		config_setting_t *groups;
		
		for(i = 0; i < groups_count; ++i) {
			group_ele = libconfig->setting_get_elem(main_group, i);

			while(k < ARRAYLENGTH(Source) && (groups = libconfig->setting_get_member(group_ele, Source[k]))) {
				int group_count = config_setting_length(groups);

				for(h = 0; h < group_count; h++) {
					config_setting_t *group_e = libconfig->setting_get_elem(groups, h);

					copy_to_list((char *)config_setting_name(group_e), (char *)config_setting_get_string_elem(groups, h), index);
					index++;
				}
				k++;
			}
		}
	}
	
	ShowConf("Leitura de '"CL_WHITE"%d"CL_RESET"' mensagens em '"CL_WHITE"%s"CL_RESET"'.\n", index, bra_config.lang_file);
}
开发者ID:Mateuus,项目名称:brathena-1,代码行数:36,代码来源:lang.c


示例11: itemdb_searchname

/*==========================================
 * Return item data from item name. (lookup)
 *------------------------------------------*/
struct item_data* itemdb_searchname(const char *str)
{
	struct item_data* item;
	struct item_data* item2 = NULL;
	int i;

	for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i ) {
		item = itemdb_array[i];
		if( item == NULL )
			continue;

		//Absolute priority to Aegis code name.
		if( strcasecmp(item->name,str) == 0 )
			return item;

		//Second priority to Client displayed name.
		if( strcasecmp(item->jname,str) == 0 )
			item2 = item;
	}

	item = NULL;
	itemdb_other->foreach(itemdb_other,itemdb_searchname_sub,str,&item,&item2);
	return item ? item : item2;
}
开发者ID:icxbb-xx,项目名称:trunk,代码行数:27,代码来源:itemdb.c


示例12:

/*==========================================
 * Loads (and creates if not found) an item from the db.
 *------------------------------------------*/
struct item_data *itemdb_load (int nameid)
{
	struct item_data *id;

	if (nameid >= 0 && nameid < ARRAYLENGTH (itemdb_array))
	{
		id = itemdb_array[nameid];

		if (id == NULL || id == &dummy_item)
			id = itemdb_array[nameid] = create_item_data (nameid);

		return id;
	}

	id = (struct item_data *) idb_get (itemdb_other, nameid);

	if (id == NULL || id == &dummy_item)
	{
		id = create_item_data (nameid);
		idb_put (itemdb_other, nameid, id);
	}

	return id;
}
开发者ID:Zellukas,项目名称:Radices,代码行数:27,代码来源:itemdb.c


示例13: k4_handle_wmnc_notify

void k4_handle_wmnc_notify(k4_dlg_data * d,
                           WPARAM wParam,
                           LPARAM lParam) {
    switch(HIWORD(wParam)) {

    case WMNC_IDENTITY_CHANGE:
        k4_read_identity_data(d);
        k4_update_display(d, TRUE);
        break;

    case WMNC_CREDTEXT_LINK:
        {
            wchar_t wid[KHUI_MAXCCH_HTLINK_FIELD];
            wchar_t * wids;
            khui_htwnd_link * l;

            l = (khui_htwnd_link *) lParam;

            StringCchCopyN(wid, ARRAYLENGTH(wid), l->id, l->id_len);
            wids = wcschr(wid, L':');

            if (!wids)
                break;
            else
                wids++;

            if (!wcscmp(wids, L"Enable")) {
                d->k4_enabled = TRUE;

                k4_update_display(d, TRUE);
                khui_cw_enable_type(d->nc, credtype_id_krb4, TRUE);
            }
        }
        break;
    }
}
开发者ID:secure-endpoints,项目名称:netidmgr,代码行数:36,代码来源:krb4newcreds.c


示例14: itemdb_readdb

/*==========================================
 * アイテムデータベースの読み込み
 *------------------------------------------*/
static int itemdb_readdb(void)
{
	const char* filename[] = {
#if REMODE
		"re/item_db.txt",
#else
		"pre-re/item_db.txt",
#endif
		"item_db2.txt" };

	int fi;

	for( fi = 0; fi < ARRAYLENGTH(filename); ++fi )
	{
		uint32 lines = 0, count = 0;
		char line[1024];

		char path[256];
		FILE* fp;

		sprintf(path, "%s/%s", db_path, filename[fi]);
		fp = fopen(path, "r");
		if( fp == NULL )
		{
			ShowWarning("itemdb_readdb: File not found \"%s\", skipping.\n", path);
			continue;
		}

		// process rows one by one
		while(fgets(line, sizeof(line), fp))
		{
			char *str[32], *p;
			int i;

			lines++;
			if(line[0] == '/' && line[1] == '/')
				continue;
			memset(str, 0, sizeof(str));

			p = line;
			while( ISSPACE(*p) )
				++p;
			if( *p == '\0' )
				continue;// empty line
			for( i = 0; i < 19; ++i )
			{
				str[i] = p;
				p = strchr(p,',');
				if( p == NULL )
					break;// comma not found
				*p = '\0';
				++p;
			}

			if( p == NULL )
			{
				ShowError("itemdb_readdb: Insufficient columns in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
				continue;
			}

			// Script
			if( *p != '{' )
			{
				ShowError("itemdb_readdb: Invalid format (Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
				continue;
			}
			str[19] = p;
			p = strstr(p+1,"},");
			if( p == NULL )
			{
				ShowError("itemdb_readdb: Invalid format (Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
				continue;
			}
			p[1] = '\0';
			p += 2;

			// OnEquip_Script
			if( *p != '{' )
			{
				ShowError("itemdb_readdb: Invalid format (OnEquip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
				continue;
			}
			str[20] = p;
			p = strstr(p+1,"},");
			if( p == NULL )
			{
				ShowError("itemdb_readdb: Invalid format (OnEquip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
				continue;
			}
			p[1] = '\0';
			p += 2;

			// OnUnequip_Script (last column)
			if( *p != '{' )
			{
				ShowError("itemdb_readdb: Invalid format (OnUnequip_Script column) in line %d of \"%s\" (item with id %d), skipping.\n", lines, path, atoi(str[0]));
				continue;
//.........这里部分代码省略.........
开发者ID:greenboxal,项目名称:Cronus-Emulator,代码行数:101,代码来源:itemdb.c


示例15: read_config


//.........这里部分代码省略.........
		
		// Check if all commands and permissions exist
		iter = db_iterator(pc_group_db);
		for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) {
			config_setting_t *commands = group_settings->commands, *permissions = group_settings->permissions;
			int count = 0, j;

			// Make sure there is "commands" group
			if (commands == NULL)
				commands = group_settings->commands = config_setting_add(group_settings->root, "commands", CONFIG_TYPE_GROUP);
			count = config_setting_length(commands);

			for (j = 0; j < count; ++j) {
				config_setting_t *command = config_setting_get_elem(commands, j);
				const char *name = config_setting_name(command);
				if (!atcommand_exists(name)) {
					ShowConfigWarning(command, "pc_groups:read_config: non-existent command name '%s', removing...", name);
					config_setting_remove(commands, name);
					--j;
					--count;
				}
			}

			// Make sure there is "permissions" group
			if (permissions == NULL)
				permissions = group_settings->permissions = config_setting_add(group_settings->root, "permissions", CONFIG_TYPE_GROUP);
			count = config_setting_length(permissions);

			for(j = 0; j < count; ++j) {
				config_setting_t *permission = config_setting_get_elem(permissions, j);
				const char *name = config_setting_name(permission);
				int p;

				ARR_FIND(0, ARRAYLENGTH(pc_g_permission_name), p, strcmp(pc_g_permission_name[p].name, name) == 0);
				if (p == ARRAYLENGTH(pc_g_permission_name)) {
					ShowConfigWarning(permission, "pc_groups:read_config: non-existent permission name '%s', removing...", name);
					config_setting_remove(permissions, name);
					--p;
					--count;
				}
			}
		}
		dbi_destroy(iter);

		// Apply inheritance
		i = 0; // counter for processed groups
		while (i < group_count) {
			iter = db_iterator(pc_group_db);
			for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) {
				config_setting_t *inherit = NULL,
				                 *commands = group_settings->commands,
					             *permissions = group_settings->permissions;
				int j, inherit_count = 0, done = 0;
				
				if (group_settings->inheritance_done) // group already processed
					continue; 

				if ((inherit = group_settings->inherit) == NULL ||
				    (inherit_count = config_setting_length(inherit)) <= 0) { // this group does not inherit from others
					++i;
					group_settings->inheritance_done = true;
					continue;
				}
				
				for (j = 0; j < inherit_count; ++j) {
					GroupSettings *inherited_group = NULL;
开发者ID:AsaK,项目名称:rathena,代码行数:67,代码来源:pc_groups.c


示例16: mercenary_killbonus

/**
* Gives bonus to Mercenary
* @param md Mercenary
**/
void mercenary_killbonus(struct mercenary_data *md) {
	const enum sc_type scs[] = { SC_MERC_FLEEUP, SC_MERC_ATKUP, SC_MERC_HPUP, SC_MERC_SPUP, SC_MERC_HITUP };
	uint8 index = rnd() % ARRAYLENGTH(scs);

	sc_start(&md->bl,&md->bl, scs[index], 100, rnd() % 5, 600000);
}
开发者ID:AlScarface,项目名称:rathena,代码行数:10,代码来源:mercenary.c


示例17: mmo_auth_fromstr

/// parse input string into the provided account data structure
static bool mmo_auth_fromstr(struct mmo_account* a, char* str, unsigned int version)
{
	char* fields[32];
	int count;
	char* regs;
	int i, n;

	// zero out the destination first
	memset(a, 0x00, sizeof(struct mmo_account));

	// extract tab-separated columns from line
	count = sv_split(str, strlen(str), 0, '\t', fields, ARRAYLENGTH(fields), (e_svopt)(SV_TERMINATE_LF|SV_TERMINATE_CRLF));

	if( version == ACCOUNT_TXT_DB_VERSION && count == 13 )
	{
		a->account_id = strtol(fields[1], NULL, 10);
		safestrncpy(a->userid, fields[2], sizeof(a->userid));
		safestrncpy(a->pass, fields[3], sizeof(a->pass));
		a->sex = fields[4][0];
		safestrncpy(a->email, fields[5], sizeof(a->email));
		a->level = strtoul(fields[6], NULL, 10);
		a->state = strtoul(fields[7], NULL, 10);
		a->unban_time = strtol(fields[8], NULL, 10);
		a->expiration_time = strtol(fields[9], NULL, 10);
		a->logincount = strtoul(fields[10], NULL, 10);
		safestrncpy(a->lastlogin, fields[11], sizeof(a->lastlogin));
		safestrncpy(a->last_ip, fields[12], sizeof(a->last_ip));
		regs = fields[13];
	}
	else
	if( version == 0 && count == 14 )
	{
		a->account_id = strtol(fields[1], NULL, 10);
		safestrncpy(a->userid, fields[2], sizeof(a->userid));
		safestrncpy(a->pass, fields[3], sizeof(a->pass));
		safestrncpy(a->lastlogin, fields[4], sizeof(a->lastlogin));
		a->sex = fields[5][0];
		a->logincount = strtoul(fields[6], NULL, 10);
		a->state = strtoul(fields[7], NULL, 10);
		safestrncpy(a->email, fields[8], sizeof(a->email));
		//safestrncpy(a->error_message, fields[9], sizeof(a->error_message));
		a->expiration_time = strtol(fields[10], NULL, 10);
		safestrncpy(a->last_ip, fields[11], sizeof(a->last_ip));
		//safestrncpy(a->memo, fields[12], sizeof(a->memo));
		a->unban_time = strtol(fields[13], NULL, 10);
		regs = fields[14];
	}
	else
	if( version == 0 && count == 13 )
	{
		a->account_id = strtol(fields[1], NULL, 10);
		safestrncpy(a->userid, fields[2], sizeof(a->userid));
		safestrncpy(a->pass, fields[3], sizeof(a->pass));
		safestrncpy(a->lastlogin, fields[4], sizeof(a->lastlogin));
		a->sex = fields[5][0];
		a->logincount = strtoul(fields[6], NULL, 10);
		a->state = strtoul(fields[7], NULL, 10);
		safestrncpy(a->email, fields[8], sizeof(a->email));
		//safestrncpy(a->error_message, fields[9], sizeof(a->error_message));
		a->expiration_time = strtol(fields[10], NULL, 10);
		safestrncpy(a->last_ip, fields[11], sizeof(a->last_ip));
		//safestrncpy(a->memo, fields[12], sizeof(a->memo));
		regs = fields[13];
	}
	else
	if( version == 0 && count == 8 )
	{
		a->account_id = strtol(fields[1], NULL, 10);
		safestrncpy(a->userid, fields[2], sizeof(a->userid));
		safestrncpy(a->pass, fields[3], sizeof(a->pass));
		safestrncpy(a->lastlogin, fields[4], sizeof(a->lastlogin));
		a->sex = fields[5][0];
		a->logincount = strtoul(fields[6], NULL, 10);
		a->state = strtoul(fields[7], NULL, 10);
		regs = fields[8];
	}
	else
	{// unmatched row
		return false;
	}

	// extract account regs
	// {reg name<COMMA>reg value<SPACE>}*
	n = 0;
	for( i = 0; i < ACCOUNT_REG2_NUM; ++i )
	{
		char key[32];
		char value[256];
	
		regs += n;

		if (sscanf(regs, "%31[^\t,],%255[^\t ] %n", key, value, &n) != 2)
		{
			// We must check if a str is void. If it's, we can continue to read other REG2.
			// Account line will have something like: str2,9 ,9 str3,1 (here, ,9 is not good)
			if (regs[0] == ',' && sscanf(regs, ",%[^\t ] %n", value, &n) == 1) { 
				i--;
				continue;
			} else
//.........这里部分代码省略.........
开发者ID:KimKyung-wook,项目名称:ilathena-project,代码行数:101,代码来源:account_txt.c


示例18: LOCALE_DEF

    /* there needs to be at least one language that is supported.
       Here we declare that to be US English, and make it the
       default. */
    LOCALE_DEF(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),
               MYPLUGIN_DLLBASEW L"_en_us.dll", /* this is the name of
                                                  the DLL. We paste a
                                                  trailer to basename
                                                  of the DLL.  This
                                                  DLL should reside in
                                                  the same directory
                                                  as the plugin
                                                  DLL. */
               KMM_MLOC_FLAG_DEFAULT)
};
int n_locales = ARRAYLENGTH(locales);

/*******************************************************************
   init_module
   *****************************************************************

   This is the entry point for the module.  Each module can provide
   multiple plugins and each plugin will need a separate entry point.
   Generally, the module entry point will set up localized resources
   and register the plugins.

*/
KHMEXP khm_int32 KHMAPI init_module(kmm_module h_module) {

    khm_int32 rv = KHM_ERROR_SUCCESS;
    kmm_plugin_reg pi;
开发者ID:bagdxk,项目名称:openafs,代码行数:30,代码来源:main.c


示例19: path_search

/*==========================================
 * path search (x0,y0)->(x1,y1)
 * wpd: path info will be written here
 * flag: &1 = easy path search only
 * cell: type of obstruction to check for
 *------------------------------------------*/
bool path_search (struct walkpath_data *wpd, int m, int x0, int y0, int x1, int y1, int flag, cell_chk cell)
{
	int heap[MAX_HEAP + 1];
	struct tmp_path tp[MAX_WALKPATH * MAX_WALKPATH];
	register int i, j, len, x, y, dx, dy;
	int rp, xs, ys;
	struct map_data *md;
	struct walkpath_data s_wpd;

	if (wpd == NULL)
		wpd = &s_wpd; // use dummy output variable

	if (!map[m].cell)
		return false;

	md = &map[m];
#ifdef CELL_NOSTACK

	//Do not check starting cell as that would get you stuck.
	if (x0 < 0 || x0 >= md->xs || y0 < 0 || y0 >= md->ys)
#else
	if (x0 < 0 || x0 >= md->xs || y0 < 0 || y0 >= md->ys /*|| map_getcellp(md,x0,y0,cell)*/)
#endif
		return false;

	if (x1 < 0 || x1 >= md->xs || y1 < 0 || y1 >= md->ys || map_getcellp (md, x1, y1, cell))
		return false;

	// calculate (sgn(x1-x0), sgn(y1-y0))
	dx = ( (dx = x1 - x0)) ? ( (dx < 0) ? -1 : 1) : 0;
	dy = ( (dy = y1 - y0)) ? ( (dy < 0) ? -1 : 1) : 0;
	// try finding direct path to target
	x = x0;
	y = y0;
	i = 0;

	while (i < ARRAYLENGTH (wpd->path))
	{
		wpd->path[i] = walk_choices[-dy + 1][dx + 1];
		i++;
		x += dx;
		y += dy;

		if (x == x1) dx = 0;

		if (y == y1) dy = 0;

		if (dx == 0 && dy == 0)
			break; // success

		if (map_getcellp (md, x, y, cell))
			break; // obstacle = failure
	}

	if (x == x1 && y == y1)
	{
		//easy path successful.
		wpd->path_len = i;
		wpd->path_pos = 0;
		return true;
	}

	if (flag & 1)
		return false;

	memset (tp, 0, sizeof (tp));
	i = calc_index (x0, y0);
	tp[i].x = x0;
	tp[i].y = y0;
	tp[i].dist = 0;
	tp[i].before = 0;
	tp[i].cost = calc_cost (&tp[i], x1, y1);
	tp[i].flag = 0;
	heap[0] = 0;
	push_heap_path (heap, tp, calc_index (x0, y0));
	xs = md->xs - 1; // あらかじめ1減算しておく
	ys = md->ys - 1;

	for (;;)
	{
		int e = 0, f = 0, dist, cost, dc[4] = {0, 0, 0, 0};

		if (heap[0] == 0)
			return false;

		rp   = pop_heap_path (heap, tp);
		x    = tp[rp].x;
		y    = tp[rp].y;
		dist = tp[rp].dist + 10;
		cost = tp[rp].cost;

		if (x == x1 && y == y1)
			break;

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


示例20: on_browse

static INT_PTR
on_browse(HWND hwnd)
{
    OPENFILENAME ofn;
    wchar_t path[MAX_PATH] = L"";
    wchar_t filter[128];
    wchar_t title[64];

    ZeroMemory(&ofn, sizeof(ofn));

    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = hwnd;
    ofn.hInstance = hResModule;
    ofn.lpstrFilter = filter;
    ofn.lpstrCustomFilter = NULL;
    ofn.nMaxCustFilter = 0;
    ofn.nFilterIndex = 1;
    ofn.lpstrFile = path;
    ofn.nMaxFile = MAX_PATH;
    ofn.lpstrTitle = title;
    ofn.Flags = OFN_DONTADDTORECENT | OFN_NOREADONLYRETURN;
    ofn.lpstrDefExt = L"keystore";

    GetDlgItemText(hwnd, IDC_PATH, path, ARRAYLENGTH(path));
    LoadString(hResModule, IDS_NC_BROW_TITLE, title, ARRAYLENGTH(title));
    LoadString(hResModule, IDS_NC_BROW_FILTER, filter, ARRAYLENGTH(filter));
    {
        wchar_t * c = filter;
        for (; *c; c++) {
            if (*c == L'%') *c = L'\0';
        }
    }

    if (GetOpenFileName(&ofn)) {
        keystore_t * ks = NULL;
        wchar_t fpath[MAX_PATH+5];

        SetDlgItemText(hwnd, IDC_PATH, path);

        if (PathFileExists(path)) {
            StringCbCopy(fpath, sizeof(fpath), L"FILE:");
            StringCbCat(fpath, sizeof(fpath), path);

            ks = create_keystore_from_location(fpath, NULL);
            if (ks) {
                wchar_t buf[KCDB_MAXCCH_SHORT_DESC];
                khm_size cb;

                cb = sizeof(buf);
                if (KHM_SUCCEEDED(ks_keystore_get_string(ks, KCDB_RES_DISPLAYNAME,
                                                         buf, &cb))) {
                    SetDlgItemText(hwnd, IDC_NAME, buf);
                }
                if (KHM_SUCCEEDED(ks_keystore_get_string(ks, KCDB_RES_DESCRIPTION,
                                                         buf, &cb))) {
                    SetDlgItemText(hwnd, IDC_DESCRIPTION, buf);
                }

                ks_keystore_release(ks);
            }
        }
    }

    return TRUE;
}
开发者ID:secure-endpoints,项目名称:netidmgr,代码行数:65,代码来源:idselect.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ ARRAYSIZE函数代码示例发布时间:2022-05-30
下一篇:
C++ ARRAYLEN函数代码示例发布时间: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