diff libfdproto/messages.c @ 1423:67c263056d78

fd_msg_search_avp: search msg_or_avp, not just msg Change fd_msg_search_avp() to support searching struct msg or struct avp, and not just struct msg.
author Luke Mewburn <luke@mewburn.net>
date Wed, 19 Feb 2020 10:20:20 +1100
parents 3cbe458fbfa9
children 915450ee91c7
line wrap: on
line diff
--- a/libfdproto/messages.c	Wed Feb 19 10:07:17 2020 +1100
+++ b/libfdproto/messages.c	Wed Feb 19 10:20:20 2020 +1100
@@ -596,29 +596,29 @@
 	return 0;
 }
 
-/* Search a given AVP model in a message */
-int fd_msg_search_avp ( struct msg * msg, struct dict_object * what, struct avp ** avp )
+/* Search a given AVP model in a message or AVP */
+int fd_msg_search_avp ( msg_or_avp * reference, struct dict_object * what, struct avp ** avp )
 {
 	struct avp * nextavp;
 	struct dict_avp_data 	dictdata;
 	enum dict_object_type 	dicttype;
 	
-	TRACE_ENTRY("%p %p %p", msg, what, avp);
+	TRACE_ENTRY("%p %p %p", reference, what, avp);
 	
-	CHECK_PARAMS( CHECK_MSG(msg) && what );
+	CHECK_PARAMS( VALIDATE_OBJ(reference) && what );
 	
 	CHECK_PARAMS( (fd_dict_gettype(what, &dicttype) == 0) && (dicttype == DICT_AVP) );
 	CHECK_FCT(  fd_dict_getval(what, &dictdata)  );
 	
-	/* Loop on all top AVPs */
-	CHECK_FCT(  fd_msg_browse(msg, MSG_BRW_FIRST_CHILD, (void *)&nextavp, NULL)  );
+	/* Loop on all top AVPs in message or AVP */
+	CHECK_FCT(  fd_msg_browse(reference, MSG_BRW_FIRST_CHILD, (void *)&nextavp, NULL)  );
 	while (nextavp) {
 		
 		if ( (nextavp->avp_public.avp_code   == dictdata.avp_code)
 		  && (nextavp->avp_public.avp_vendor == dictdata.avp_vendor) ) /* always 0 if no V flag */
 			break;
 		
-		/* Otherwise move to next AVP in the message */
+		/* Otherwise move to next AVP in the message or AVP */
 		CHECK_FCT( fd_msg_browse(nextavp, MSG_BRW_NEXT, (void *)&nextavp, NULL) );
 	}
 	
"Welcome to our mercurial repository"