Esempio n. 1
0
/* If returns TRUE, then 
 *   The tree has a leaf L that covers untagged_w
 *   *leaf_recv           := L
 *   *first_addr_for_leaf := start of L's bitmap
 * Otherwise the tree has no such leaf 
 *   (untagged_w is not a member of the set).
 * 
 * (Parameter alloc_if_unfound implies that this must return TRUE.)
 */
static bool find_leaf_calc_offset( extbmp_t *ebmp, word untagged_w,
                                   leaf_t **leaf_recv, 
                                   word *first_addr_for_leaf_recv,
                                   bool alloc_if_unfound )
{
  tnode_t *tree;
  int depth;
  word start_addr_of_node_coverage;
  bool retval;

  dbmsg(     "find_leaf_calc_offset"
             "( ebmp, 0x%08x, "
             "leaf_recv, first_addr_for_leaf, "
             "alloc_if_unfound=%s )", 
             untagged_w, (alloc_if_unfound?"TRUE":"FALSE") );

  if (ebmp->mru_cache.leaf != NULL 
      && (ebmp->mru_cache.first_addr_for_leaf 
          <= strip_tag(untagged_w))
      && (strip_tag(untagged_w)
          < leaf_wordaddr_lim( ebmp, ebmp->mru_cache.first_addr_for_leaf))) {
    *leaf_recv                = ebmp->mru_cache.leaf;
    *first_addr_for_leaf_recv = ebmp->mru_cache.first_addr_for_leaf;
    return TRUE;
  }

  tree = ebmp->tree;
  depth = ebmp->depth;
  start_addr_of_node_coverage = 0;

  retval = 
    find_leaf_calc_offset_recur( ebmp, untagged_w, 
                                 tree, depth, start_addr_of_node_coverage,
                                 leaf_recv, first_addr_for_leaf_recv, 
                                 alloc_if_unfound );
  if (retval) {
    ebmp->mru_cache.leaf                = *leaf_recv;
    ebmp->mru_cache.first_addr_for_leaf = *first_addr_for_leaf_recv;
  }
  return retval;
}
Esempio n. 2
0
//strip a tag within a string
wchar_t* strip_tag_within(wchar_t* begin, wchar_t* end)
{
	while(wchar_t* sub_begin=wcsstr(begin,L"<"))
	{	
		if(sub_begin<end)//less than the original ending
		{
			wchar_t* sub_end=wcsstr(begin,L">");
			strip_tag(sub_begin,sub_end);
			end=end-(sub_end-sub_begin)-1;
		}
		else
			break;
	}
	return end;
}
Esempio n. 3
0
//strip a tag within a string
char* strip_tag_within(char* begin, char* end)
{
	while(char* sub_begin=strstr(begin,"<"))
	{	
		if(sub_begin<end)//less than the original ending
		{
			char* sub_end=strstr(begin,">");
			strip_tag(sub_begin,sub_end);
			end=end-(sub_end-sub_begin)-1;
		}
		else
			break;
	}
	return end;
}
Esempio n. 4
0
int command_remove_tag(int argc, char **argv, int optind, int flags) {
  const char *filename = argv[argc-1];
  char *str, *nstr, *p, *q;
  const char *d;
  int i;

  for(i = optind; i < argc; ++i) {
    check_access_flags(argv[i], F_OK | R_OK | W_OK, 1);
    str = get_basename((char*)argv[i]);
    if((nstr = strip_tag((const char*) str, crcregex_stripper)) == NULL) {
      log_failure(argv[i], "no hexstring found");
      return EXIT_FAILURE;
    }
    d = (const char*) dirname((char*)argv[i]);
    p = pathcat(d, (const char*)str);
    q = pathcat(d, (const char*)nstr);
    if(rename((const char*) p, (const char*) q) != 0)
      LERROR(EXIT_FAILURE, errno, "rename() failed");
    free(p);
    free(q);
    free(nstr);
  }
  return EXIT_SUCCESS;
}