downstream_manager::path_ptr downstream_manager::add_path(stream_slot slot, strong_actor_ptr target) { CAF_LOG_TRACE(CAF_ARG(slot) << CAF_ARG(target)); unique_path_ptr ptr{new outbound_path(slot, std::move(target))}; auto result = ptr.get(); return insert_path(std::move(ptr)) ? result : nullptr; }
void analize_tree(TREEPTR root, short condition, short reg, int level) { char neigh[10],path[10]; PATHPTR path_list=NULL, neigh_list=NULL, breath_h=NULL, breath_q=NULL; short length, merged, end; TREEPTR node,neigh_node; MERGEPTR node1, node2; initialize_label(path,0); node=root; end=False; while (!end) { node=get_leaf(path); /*Compute merge operations*/ if (node->region!=NULL) { /*A leaf has been found*/ /*Merge its neighbours if condition is satisfied*/ if (node->included!=yes) { /*Add a new element to the list of merged regions*/ add_new_merged_region(&merged_region_list); /*Insert the region in the list of merged regions*/ insert_leaf_list(&merged_region_list, node); node->included=yes; /*Actualize the pointer to the merged region which includes it*/ node->pmerge = merged_region_list; } /* Obtain the list of neighbours of the node referenced by path */ get_neighbours(&neigh_list,root,path); while (neigh_list!=NULL) { initialize_label(neigh,0); /* Get and delete the first element in the list of neighbours */ delete_first(&neigh_list,neigh); neigh_node=get_leaf(neigh); /* Get the pointers to the candidate regions */ node1=*get_location(node); node2=*get_location(neigh_node); if ( node1!=node2 ) { /* The neighbour region doesn't belong to a merged region yet*/ if (neigh_node->included!=yes) { /* Check whether both regions are homogeneous or not */ if (similar(path,neigh,condition)) { /* Insert the neighbour in the same list than path */ /* All the regions that are homogeneous belong to */ /* the same list */ insert_leaf_list(get_location(node),neigh_node); neigh_node->included=yes; /* Set pmerge field to point to the list */ /* where it has been inserted */ neigh_node->pmerge=*get_location(node); } } else { /* Each region belongs to a different merged region */ /* Check whether both regions are homogeneous or not */ if (similar(path,neigh,condition)) { /* Check whether both merged regions are homogeneous */ if (abs( node1->mean - node2->mean ) < condition) /* Merge both lists of merged regions */ merge_lists(&node1,&node2); } } } } } else { length = strlen(path); /* Insert new nodes to be analised using the breath first method */ path[length]='0'; insert_path(&breath_h,&breath_q,path); path[length]='1'; insert_path(&breath_h,&breath_q,path); path[length]='2'; insert_path(&breath_h,&breath_q,path); path[length]='3'; insert_path(&breath_h,&breath_q,path); } /* Take a node from the list to analize it if there are nodes left */ if (breath_h==NULL) end=True; else delete_first(&breath_h,path); } }
/* ---------------------------------------------------------------------- * signature is because this is called by VectorDoUntil */ static void CC handle_path (void * item_, void * data_) { if ((item_ != NULL) && (data_ != NULL)) { VPath * vpath = item_; rc_data * data = data_; size_t z; rc_t rc; char pbuff [8193]; /* char tbuff [8193]; */ if (data->rc) return; /* -1 saves room for a guaranteed NUL */ rc = VPathReadPath (vpath, pbuff, sizeof (pbuff) - 1, &z); if (rc) LOGERR (klogErr, rc, "failed to pull path out of VPath"); else if (z) { KPathType kpt; /* force a NUL just in case: we saved room for it */ pbuff[z] = '\0'; /* what type of path is this? */ kpt = KDirectoryPathType (options.base, "%s", pbuff); #if 0 /* ain't doing this now, and may never because of the root versus base problems */ /* dereference links until we're done */ while (kpt & kptAlias) { rc = KDirectoryResolveAlias (options.base, true, tbuff, sizeof tbuff, "%s", pbuff); if (rc) { PLOGERR (klogErr, (klogErr, rc, "error resolving path '$(P)'", "P=%s", pbuff)); break; } else { memcpy (tbuff, pbuff, sizeof pbuff); z = string_size (pbuff); kpt = KDirectoryPathType (options.root, "%s", pbuff); } } #endif /* if we didn't crash this path dereferecing it. */ if (rc == 0) { if (kpt & kptAlias) kpt = kptAlias; switch (kpt) { default: rc = RC (rcExe, rcPath, rcAccessing, rcPath, rcInvalid); PLOGERR (klogErr, (klogErr, rc, "unknown problem with path '$(P)'", "P=%s", pbuff)); break; case kptNotFound: PLOGERR (klogErr, (klogErr, rc, "path is a not found in archive '$(P)'", "P=%s", pbuff)); break; case kptZombieFile: rc = RC (rcExe, rcPath, rcAccessing, rcPath, rcNotFound); PLOGERR (klogErr, (klogErr, rc, "path is a not in archive but should be '$(P)'", "P=%s", pbuff)); break; case kptBadPath: rc = RC (rcExe, rcPath, rcAccessing, rcPath, rcInvalid); PLOGERR (klogErr, (klogErr, rc, "unusable path form '$(P)'", "P=%s", pbuff)); break; case kptFile: { uint64_t offset = 0; rc = walk_path_file (pbuff, z, &offset, kptFile); if (rc) PLOGERR (klogErr, (klogErr, rc, "couldn't walk path '$(P)'", "P=%s", pbuff)); else { rc = insert_path (vpath, offset); if (rc) PLOGERR (klogErr, (klogErr, rc, "couldn't sort path '$(P)'", "P=%s", pbuff)); } break; } case kptDir: rc = walk_path_tree (pbuff, z); break; case kptCharDev: case kptBlockDev: case kptFIFO: case kptAlias: rc = RC (rcExe, rcPath, rcAccessing, rcPath, rcIncorrect); PLOGERR (klogErr, (klogErr, rc, "unusable path target type '$(P)'", "P=%s", pbuff)); break; } } } data->rc = rc; } }