static PRFileDesc *filter_iolayer(SYS_NETFD fd, const Filter *filter) { // Like filter_layer(), but will also return pseudo-filters // If this looks like a pseudo-filter... if (filter->insert == &filtermethod_never_insert) { PRFileDesc *layer = fd; if (filter == &_filter_top) { // Return top layer if (layer) { while (layer->higher) layer = layer->higher; } if (layer->identity == PR_IO_LAYER_HEAD) layer = layer->lower; return layer; } else if (filter == &_filter_bottom) { // Return bottom layer if (layer) { while (layer->lower) layer = layer->lower; } return layer; } if (filter == &_filter_network) { // Return NSPR IO layer while (layer) { if (layer->identity == PR_NSPR_IO_LAYER) return layer; layer = layer->lower; } } else if (filter == &_filter_ssl) { // Return NSS IO layer while (layer) { if (layer->identity == _filter_ssl_identity) return layer; layer = layer->lower; } } } return (PRFileDesc *)filter_layer(fd, filter); }
static Bool start_macro_definition(PCL5Context *pcl5_ctxt, MacroInfo *macro_info) { pcl5_macro macro, *old_macro, *new_macro ; PCL5MacroStorage *private_macro_data ; FILELIST *filter; HQASSERT(pcl5_ctxt != NULL, "pcl5_ctxt is NULL") ; HQASSERT(macro_info != NULL, "macro_info is NULL") ; pcl5_recording_a_macro = TRUE ; if (! create_macro_storage(&private_macro_data)) return FALSE ; if (is_string_macro(macro_info, FALSE)) { uint8 *string ; int32 length ; string = macro_info->macro_string_id.buf ; length = macro_info->macro_string_id.length ; /* Clobber the macro if it already exists. */ if ((old_macro = pcl5_string_id_cache_get_macro(pcl5_ctxt->resource_caches.string_macro, string, length)) != NULL) { pcl5_string_id_cache_remove(pcl5_ctxt->resource_caches.string_macro, pcl5_ctxt->resource_caches.macro, string, length, FALSE) ; } macro.detail.resource_type = SW_PCL5_MACRO ; macro.detail.numeric_id = 0 ; macro.detail.string_id.buf = NULL ; macro.detail.string_id.length = 0 ; macro.detail.permanent = FALSE ; macro.detail.device = NULL ; macro.detail.private_data = private_macro_data ; macro.detail.PCL5FreePrivateData = free_private_data_callback ; if (! pcl5_string_id_cache_insert_macro(pcl5_ctxt->resource_caches.string_macro, pcl5_ctxt->resource_caches.macro, string, length, ¯o, &new_macro)) { destroy_macro_storage(&private_macro_data) ; return FALSE ; } } else { pcl5_resource_numeric_id macro_numeric_id = macro_info->macro_numeric_id ; /* Clobber the macro if it already exists. */ if ((old_macro = pcl5_id_cache_get_macro(pcl5_ctxt->resource_caches.macro, macro_numeric_id)) != NULL) { pcl5_id_cache_remove(pcl5_ctxt->resource_caches.macro, macro_numeric_id, FALSE) ; pcl5_id_cache_kill_zombies(pcl5_ctxt->resource_caches.macro) ; } macro.detail.resource_type = SW_PCL5_MACRO ; macro.detail.numeric_id = macro_numeric_id ; macro.detail.permanent = FALSE ; macro.detail.device = NULL ; macro.detail.private_data = private_macro_data ; macro.detail.PCL5FreePrivateData = free_private_data_callback ; if (! pcl5_id_cache_insert_macro(pcl5_ctxt->resource_caches.macro, macro_numeric_id, ¯o, &new_macro)) { destroy_macro_storage(&private_macro_data) ; return FALSE ; } } if (! filter_layer(pcl5_ctxt->flptr, NAME_AND_LENGTH("PCL5MacroRecord"), NULL, &filter)) { destroy_macro_storage(&private_macro_data) ; return FALSE ; } pcl5_ctxt->flptr = filter ; macro_being_defined = new_macro ; return TRUE ; }