本文整理汇总了C++中ARRAYLENGTH函数的典型用法代码示例。如果您正苦于以下问题:C++ ARRAYLENGTH函数的具体用法?C++ ARRAYLENGTH怎么用?C++ ARRAYLENGTH使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ARRAYLENGTH函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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]);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
}
示例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));
}
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
//.........这里部分代码省略.........
示例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;