⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nabhandling.c

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 C
📖 第 1 页 / 共 3 页
字号:
				return FALSE;

			if (f_SetHeadMemberNode)	{
				pt_headMember = *ppt_tailMember;
				f_SetHeadMemberNode = FALSE;
			}

			//Free the list of group members contained by the current group. 
			//	I believe this step is necessary to guard against infinite 
			//	group recursion (PR 9/12/99).
			e_FreeList( &pt_nest->t.pt_headMember, TRUE);

			//recursively tack on any groups containing this container 
			//	group, for the user name must be a part of those too
			if (!f_TackOnNestings( (*ppt_tailMember)->pc, pt_headNest, 
														ppt_tailMember, NULL))
				return FALSE;
		} //if (ef_ListContainsString( pc_GROUPNM,

		pt_nest = pt_nest->pt_next;
	} //while (pt_nest)

	if (pt_headMember)
		*ppt_headMember = pt_headMember;

	return TRUE;
} //f_TackOnNestings(


/** f_AddGroupInfoNodeFifo( ***


--- parameters & return ----

RETURN: !eus_SUCCESS if invalid parameters were passed; eus_SUCCESS if no 
	error occured; the Notes API error code otherwise

--- revision history -------
9/12/99 PR: documentation adjustment
1/8/99 PR: created			*/
//DOC!!
static BOOL f_AddGroupInfoNodeFifo( char *const  pc, 
									const WORD  us_POSITION, 
									GroupInfoNode * *const  ppt_tail)	{
	GroupInfoNode * pt_tail;

	_ASSERTE( pc && ppt_tail);

	if (!( pt_tail = *ppt_tail))	{
		if (!(pt_tail = calloc( 1, sizeof( GroupInfoNode))))
			return FALSE;
	//else string on a new entry
	}else
		if (!(pt_tail = pt_tail->pt_next = calloc( 1, 
													sizeof( GroupInfoNode))))
			return FALSE;

	//transfer control of the string to the just-created node, and copy the 
	//	position information
	pt_tail->t.pc_name = pc;
	pt_tail->t.us_position = us_POSITION;

	*ppt_tail = pt_tail;

	return TRUE;
} //f_AddGroupInfoNodeFifo(


/** eus_CreateNameMatchTextItemCopy( ***
Purpose is to return a string copy of a particular text item's content 
furnished via a prior call to the NAMELookup() Notes C API call. If the item 
is a text-list item, only the first list member is copied and returned.

--- parameters & return ----
us_ITEM: The index to the item, within the name entry provided by 
	pv_NAME_MATCH, whose textual contents should be copied. If the item turns 
	out to be a text-list item, only the first list member is copied and 
	returned.
pv_NAME_MATCH: pointer to the name entry, in the NAMELookup() results 
	buffer, that contains the item being sought
ppc: Output. Pointer to the pointer variable this procedure should set to 
	point to the string buffer this procedure will allocate and populate with 
	a copy of the textual content requested by the caller. CALLER IS 
	RESPONSIBLE for freeing the allocated buffer to the operating system. If 
	the textual content is not text, or if the textual content is the null 
	string, or if the procedure is unsuccessful, no buffer will be allocated 
	and the pointer variable is guaranteed to be NULL upon return.
RETURN: !eus_SUCCESS if invalid parameters were passed; eus_SUCCESS if no 
	error occured; the Notes API error code otherwise

--- revision history -------
9/12/99 PR
+ return failure if not a text or text-list item
+ documentation completed

1/8/99 PR: created			*/
STATUS eus_CreateNameMatchTextItemCopy( const WORD  us_ITEM, 
										void *const  pv_NAME_MATCH, 
										char * *const  ppc)	{
	BYTE * puc;
	WORD  us_type, us_len;
	char * pc = NULL;
	STATUS  us_err;

	if (!( pv_NAME_MATCH && ppc))
		return !eus_SUCCESS;

	*ppc = NULL;

	if (!( puc = NAMELocateItem( pv_NAME_MATCH, us_ITEM, &us_type, &us_len)))
		return eus_SUCCESS;

	switch (us_type)	{
		case TYPE_TEXT_LIST:
			if (us_err = eus_CreateTextListEntryCopy( 0, puc, TRUE, &pc))
				return us_err;
			if (!pc)
				us_len = NULL;
			break;

		case TYPE_TEXT:
			puc += sizeof( WORD);
			us_len -= sizeof( WORD);
			break;

		default:
			return !eus_SUCCESS;
	} //switch (us_type)

	//if the entry contains a non-blank resolved name...
	if (us_len)
		//if the name has already been extracted from a string in a 
		//	text-list match...
		if (pc)
			//transfer ownership of the string to the caller's string pointer
			*ppc = pc;
		//else allocate caller-controlled space for the resolved name, then 
		//	copy in the name
		else	{
			pc = malloc( us_len + 1);
			memcpy( pc, puc, us_len);
			pc[ us_len] = NULL;
			*ppc = pc;
		} //if (pc)

	return eus_SUCCESS;
} //eus_CreateNameMatchTextItemCopy(


/** epc_NotesNmAbbreviate( ***
Purpose is to return the abbreviated version of the passed-in Notes 
canonicalized name.

--- parameters & return ----
pc_CANONICALIZED: address of the canonicalized version of the Notes name
pc_abbrev: Output. Address of the buffer in which to store the abbreviated 
	version. The caller may use the same pointer for this parameter as is 
	used in the pc_CANONICALIZED parameter.
RETURN: address of abbreviated name (pc_abbrev) if successful; NULL otherwise

--- revision history -------
3/20/00 PR: documentation, formatting adjustment
9/12/99 PR: created			*/
char * epc_NotesNmAbbreviate( const char  pc_CANONICALIZED[], 
								char *const  pc_abbrev)	{
	//static for speed
	static const char  pc_TKN_LEVEL[] = "/", pc_TKN_CONTENT[] = "=", 
						pc_TKN_ORG[] = "O", pc_TKN_COUNTRY[] = "C";
	static const UINT  ui_LEN_TKN_CONTENT = sizeof( pc_TKN_CONTENT) - 1, 
						ui_LEN_TKN_ORG = sizeof( pc_TKN_ORG) - 1, 
						ui_LEN_TKN_COUNTRY = sizeof( pc_TKN_COUNTRY) - 1, 
						ui_LEN_TKN_COMMON_NM = sizeof( mpc_TKN_COMMON_NM) - 1;

	const char * pc, * pc_src;
	UINT  ui_offset = NULL, ui;
	BOOL  f_orgLocated = FALSE, f_CountryReached = FALSE;

	if (!( pc_CANONICALIZED && pc_abbrev && memcmp( pc_CANONICALIZED, 
										mpc_TKN_CANONICAL, 
										mui_LEN_TKN_CANONICAL) == ei_SAME))
		return NULL;

	pc = pc_src = pc_CANONICALIZED;
	do	{
		if (!( pc_src = strstr( pc_src, pc_TKN_CONTENT)))
			return NULL;
		if (pc = strstr( pc + 1, pc_TKN_LEVEL))	{
			if (pc < pc_src + ui_LEN_TKN_CONTENT)
				return NULL;
		}else
			pc = pc_CANONICALIZED + strlen( pc_CANONICALIZED);

		if (!f_orgLocated)	{
			if (memcmp( pc_src - ui_LEN_TKN_ORG, pc_TKN_ORG, 
												ui_LEN_TKN_ORG) == ei_SAME)
				f_orgLocated = TRUE;
		}else if (!f_CountryReached && memcmp( pc_src - ui_LEN_TKN_COUNTRY, 
											pc_TKN_COUNTRY, 
											ui_LEN_TKN_COUNTRY) == ei_SAME)
			f_CountryReached = TRUE;
		else
			return NULL;

		pc_src += ui_LEN_TKN_CONTENT;
		memcpy( pc_abbrev + ui_offset, pc_src, ui = ++pc - pc_src);
		ui_offset += ui;
	} while (*((pc_src = pc) - 1));

	if (!f_orgLocated)
		return NULL;

	return pc_abbrev;
} //epc_NotesNmAbbreviate(


/** eus_ResolveMailAddresses( ***
Purpose is to resolve a list of mail addressees according to the current 
configuration of the Domino Directory (Notes Name & Address Book). Groups, 
even nested groups, are resolved to member individuals.

--- parameters & return ----
pt_unresolved: Input & Output. Pointer to the list of addresses to be 
	resolved via the Domino Directory. Procedure will set to TRUE the f_found 
	member of the NameFoundInfo structure contained by each node if the 
	address was located during the call.  If members of any _groups_ among 
	the addresses looked up by this procedure cannot be resolved, the 
	procedure will add the unresolved names to the list with their f_found 
	members set to FALSE.
f_LOOKUP_EXHAUST: Flag telling whether the directories should be searched 
	exhaustively for each name so as to be sure all matches are accounted 
	for. If FALSE, the first match found will be used.
pc_SERVERNM: pointer to the name of the server holding the Domino Directory 
	to be used in the resolution process
ppt_encountered: Optional Input & Output. Pointer to a pointer variable that 
	refers to a list of group names to be ignored by this procedure, 
	typically in order to guard against infinite recursion via nested groups. 
	If ppt_encountered pointer is null, the procedure will carry out the guard 
	against infinite recursion itself, but if sequential calls are being made 
	to this procedure with the same list of resolved names, it is more 
	efficient for the caller to control the list and allow it to grow. If the 
	caller wishes to control the list, the caller's _pointer variable_ 
	(*ppt_encountered) must be NULL at the first call so the procedure will 
	know to start the list on the behalf of the caller. If in control of the 
	list, CALLER IS RESPONSIBLE for freeing resources allocated to the list, 
	typically via e_FreeList(). Pointer variable is guaranteed to be null if 
	list wasn't already started upon procedure entry and procedure fails or 
	resolves no entries.
ppt_resolved: Input & Output. Pointer to the pointer variable that refers to 
	the current list of fully resolved addesses generated by this procedure. 
	If the pointer variable is NULL, this procedure will start the list on 
	behalf of the caller. CALLER IS RESPONSIBLE for freeing resources 
	allocated to the list, typically via e_FreeList(). Pointer variable is 
	guaranteed to be null if list wasn't already started upon procedure entry 
	and procedure fails or resolves no entries. Procedure will only add 
	entries unique to the list. Ambiguous matches (e.g. five entries matching 
	the input name "john") are all treated as resolutions and added to the 
	list.
pui_resolved: Optional Output. Pointer to the variable in which to store the 
	number of items returned in the list of resolved addresses. If returned 
	negative, ambiguous matches were encountered. Providing a null pointer as 
	this parameter causes this functionality to be ignored.
pf_ambiguous: Optional Output. Pointer to the flag variable to set according 
	to whether ambiguous resolutions were encountered. If omitted, 
	functionality is ignored.
RETURN: eus_SUCCESS if no error occured; the Notes API error code otherwise

--- revision history -------
9/12/99 PR: created			*/
STATUS eus_ResolveMailAddresses( NameFoundNode *const  pt_unresolved, 
									const BOOL  f_LOOKUP_EXHAUST, 
									char  pc_SERVERNM[], 
									StringNode * *const  ppt_encountered, 
									StringNode * *const  ppt_resolved, 
									UINT *const  pui_resolved, 
									BOOL *const  pf_ambiguous)	{
	static const WORD  us_LOOKUP_VIEWS = 1, us_LOOKUP_ITEMS = 4, 
						us_MAILADDRESS = 0, us_FULLNAME = 1, us_GRP_TYPE = 2, 
						us_MEMBERS = 3;
	static char  pc_VIEWNM_USERS[] = "$Users", 
					pc_ITMNM_MAILADDRESS[] = "MailAddress", 
					pc_ITMNM_FULLNAME[] = "FullName", 
					pc_ITMNM_GRP_TYPE[] = "GroupType", 
					pc_ITMNM_MEMBERS[] = "Members";

	static BYTE  puc_ItmNms[ sizeof( pc_ITMNM_MAILADDRESS) + 
										sizeof( pc_ITMNM_FULLNAME) + 
										sizeof( pc_ITMNM_GRP_TYPE) + 
										sizeof( pc_ITMNM_MEMBERS)] = {NULL};

	NameFoundNode * pt, * pt_members = NULL, 
					* pt_nde;
	BYTE * puc;
	DWORD  ul = 0, ul_offset = 0;
	HANDLE  h = NULL;
	void * pv_results, * pv, * pv_entry = NULL;
	char * pc;
	BOOL  f_NullAtStart_ResolvedList, f_NullAtStart_EncounteredList, 
			f_ambiguous = FALSE, f_failure = FALSE;
	WORD  us = 0;
	UINT  ui_resolved = 0;
	StringNode * pt_resolved, * pt_encountered = NULL, 
				* pt_lastEncountered = NULL, * pt_nd;
	STATUS  us_err;

	if (!( pt_unresolved && ppt_resolved))
		return !eus_SUCCESS;

	if (pui_resolved)
		*pui_resolved = NULL;
	if (pf_ambiguous)
		*pf_ambiguous = FALSE;

	f_NullAtStart_ResolvedList = !(pt_resolved = *ppt_resolved);
	f_NullAtStart_EncounteredList = !(pt_encountered = pt_lastEncountered = 
													(ppt_encountered ? 
													*ppt_encountered : NULL));

	//if not done already, put together the item input needed to do a lookup 
	//	against the Domino Directory
	if (!*puc_ItmNms)	{
		strcpy( puc = puc_ItmNms, pc_ITMNM_MAILADDRESS);
		strcpy( puc += sizeof( pc_ITMNM_MAILADDRESS), pc_ITMNM_FULLNAME);
		strcpy( puc += sizeof( pc_ITMNM_FULLNAME), pc_ITMNM_GRP_TYPE);
		strcpy( puc + sizeof( pc_ITMNM_GRP_TYPE), pc_ITMNM_MEMBERS);
	} //if (!*puc_ItmNms)

	//as a start to performing an aggregate lookup on the Notes directory, 
	//	allocate a buffer and then copy in the names as specified by 
	//	NAMELookup()
	pt = pt_unresolved;
	do	{
		ul += strlen( pt->pt_name->pc_nm) + 1;
		us++;
	}while (pt = pt->pt_next);
	if (!( puc = malloc( ul)))
		return !eus_SUCCESS;
	pt = pt_unresolved;
	do	{
		ul = strlen( pt->pt_name->pc_nm) + 1;
		memcpy( puc + ul_offset, pt->pt_name->pc_nm, ul);
		ul_offset += ul;
	} while (pt = pt->pt_next);

	//perform the aggregate lookup
	us_err = NAMELookup( pc_SERVERNM, (WORD) (f_LOOKUP_EXHAUST ? 
										NULL : NAME_LOOKUP_NOSEARCHING), 
										us_LOOKUP_VIEWS, pc_VIEWNM_USERS, us, 
										puc, us_LOOKUP_ITEMS, puc_ItmNms, &h);
	free( puc);
	if (us_err)
		goto errJump;

	//for each record in the returned lookup buffer...
	pv_results = OSLockObject( h);
	pt = pt_unresolved;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -