@@ -576,30 +576,22 @@ static char* plist_dict_get_string_val(plist_t dict, const char* key)
576576 return str ;
577577}
578578
579- static void update_client_info ( struct mux_client * client , plist_t dict )
579+ static void copy_plist_item ( const char * key , plist_type type , plist_t src , plist_t dest )
580580{
581- plist_t node = NULL ;
582- plist_t info = plist_new_dict ();
583-
584- node = plist_dict_get_item (dict , "BundleID" );
585- if (node && (plist_get_node_type (node ) == PLIST_STRING )) {
586- plist_dict_set_item (info , "BundleID" , plist_copy (node ));
587- }
588-
589- node = plist_dict_get_item (dict , "ClientVersionString" );
590- if (node && (plist_get_node_type (node ) == PLIST_STRING )) {
591- plist_dict_set_item (info , "ClientVersionString" , plist_copy (node ));
581+ plist_t item = plist_dict_get_item (src , key );
582+ if (item && (plist_get_node_type (item ) == type )) {
583+ plist_dict_set_item (dest , key , plist_copy (item ));
592584 }
585+ }
593586
594- node = plist_dict_get_item (dict , "ProgName" );
595- if (node && (plist_get_node_type (node ) == PLIST_STRING )) {
596- plist_dict_set_item (info , "ProgName" , plist_copy (node ));
597- }
587+ static void update_client_info (struct mux_client * client , plist_t dict )
588+ {
589+ plist_t info = plist_new_dict ();
598590
599- node = plist_dict_get_item ( dict , "kLibUSBMuxVersion" );
600- if ( node && ( plist_get_node_type ( node ) == PLIST_UINT )) {
601- plist_dict_set_item ( info , "kLibUSBMuxVersion " , plist_copy ( node ) );
602- }
591+ copy_plist_item ( "BundleID" , PLIST_STRING , dict , info );
592+ copy_plist_item ( "ClientVersionString" , PLIST_STRING , dict , info );
593+ copy_plist_item ( "ProgName " , PLIST_STRING , dict , info );
594+ copy_plist_item ( "kLibUSBMuxVersion" , PLIST_UINT , dict , info );
603595 plist_free (client -> info );
604596 client -> info = info ;
605597}
0 commit comments