BOOL ExecuteOnAllContactsOfGroup(struct ClcGroup *group, ExecuteOnAllContactsFuncPtr func, void *param)
{
	int scanIndex, i;

	for(scanIndex = 0 ; scanIndex < group->contactCount ; scanIndex++)
	{
		if (group->contact[scanIndex].type == CLCIT_CONTACT)
		{
			if (!func(&group->contact[scanIndex], FALSE, param))
			{
				return FALSE;
			}

			if (group->contact[scanIndex].SubAllocated > 0)
			{
				for (i = 0 ; i < group->contact[scanIndex].SubAllocated ; i++)
				{
					if (!func(&group->contact[scanIndex].subcontacts[i], TRUE, param))
					{
						return FALSE;
					}
				}
			}
		}
		else if (group->contact[scanIndex].type == CLCIT_GROUP) 
		{
			if (!ExecuteOnAllContactsOfGroup(group->contact[scanIndex].group, func, param))
			{
				return FALSE;
			}
		}
	}

	return TRUE;
}
Example #2
0
static BOOL ExecuteOnAllContactsOfGroup(ClcGroup *group, ExecuteOnAllContactsFuncPtr func, void *param)
{
	if (!group)
		return TRUE;

	for (auto &it : group->cl) {
		if (it->type == CLCIT_CONTACT) {
			if (!func(it, FALSE, param))
				return FALSE;

			if (it->iSubAllocated > 0) {
				for (int i = 0; i < it->iSubAllocated; i++)
					if (!func(&it->subcontacts[i], TRUE, param))
						return FALSE;
			}
		}
		else if (it->type == CLCIT_GROUP)
			if (!ExecuteOnAllContactsOfGroup(it->group, func, param))
				return FALSE;
	}

	return TRUE;
}
static BOOL ExecuteOnAllContactsOfGroup(ClcGroup *group, ExecuteOnAllContactsFuncPtr func, void *param)
{
	if (!group)
		return TRUE;

	for (int scanIndex = 0; scanIndex < group->cl.count; scanIndex++) {
		if (group->cl.items[scanIndex]->type == CLCIT_CONTACT) {
			if (!func(group->cl.items[scanIndex], FALSE, param))
				return FALSE;

			if (group->cl.items[scanIndex]->SubAllocated > 0) {
				for (int i = 0; i < group->cl.items[scanIndex]->SubAllocated; i++)
					if (!func(&group->cl.items[scanIndex]->subcontacts[i], TRUE, param))
						return FALSE;
			}
		}
		else if (group->cl.items[scanIndex]->type == CLCIT_GROUP)
			if (!ExecuteOnAllContactsOfGroup(group->cl.items[scanIndex]->group, func, param))
				return FALSE;
	}

	return TRUE;
}
// If ExecuteOnAllContactsFuncPtr returns FALSE, stop loop
// Return TRUE if finished, FALSE if was stoped
BOOL ExecuteOnAllContacts(struct ClcData *dat, ExecuteOnAllContactsFuncPtr func, void *param)
{
	return ExecuteOnAllContactsOfGroup(&dat->list, func, param);
}
Example #5
0
// If ExecuteOnAllContactsFuncPtr returns FALSE, stop loop
// Return TRUE if finished, FALSE if was stoped
static BOOL ExecuteOnAllContacts(struct ClcData *dat, ExecuteOnAllContactsFuncPtr func, void *param)
{
    BOOL res;
    res=ExecuteOnAllContactsOfGroup(&dat->list, func, param);
    return res;
}