Esempio n. 1
0
co_elf_symbol_t *co_get_symbol_by_name(co_elf_data_t *pl, const char *name)
{
	int index =0 ;
	uintptr_t symbols;

	symbols = pl->symbol_table_section->sh_size / sizeof(Elf32_Sym);

	for (index=0; index < symbols; index++) {
		Elf32_Sym *symbol = co_get_symbol(pl, index);

		if (strcmp(name, co_get_string(pl, symbol->st_name)) == 0)
			return (co_elf_symbol_t *)symbol;
	}

	return NULL;
}
Esempio n. 2
0
int main(int argc, char* argv[])
{
  time_t start;
  struct llist **headptr;
  int *sortedocc, *sortedfreq, ngoodlmers;
  long *sortedindex;
  FILE* fp;

  start = time(0);

  /* Gather command-line options... */
  if( 0 == 1*
      co_get_string(argc, argv, "-sequence", &SEQUENCE_FILE) *
      co_get_string(argc, argv, "-freq",     &LMER_TABLE_FILE)
  ) {
      usage();
  }

  co_get_int(argc, argv, "-tandem", &TANDEMDIST) || (TANDEMDIST = 500);
  co_get_int(argc, argv, "-min", &MINTHRESH) || (MINTHRESH = 3);

  co_get_bool(argc, argv, "-sort", &SORT);
  co_get_bool(argc, argv, "-v", &VERBOSE);

  co_get_int(argc, argv, "-start", &START);
  co_get_int(argc, argv, "-stop", &STOP);

  fp = fopen( SEQUENCE_FILE, "ro" );
  if( NULL == fp ) {
     fprintf(stderr, "Could not open sequence file %s\n", SEQUENCE_FILE);
     exit(1);
  }
  fseek(fp, 0, SEEK_END);
  MAXLENGTH = ftell(fp);  /* This is an approximation, but an overestimate, so we're ok! */
  fclose(fp);

  co_get_int(argc, argv, "-l", &l) || (l = default_l(MAXLENGTH));

  sequence = (char *)malloc( (MAXLENGTH + PADLENGTH) * sizeof(char) );
  if( NULL == sequence ) {
     fprintf(stderr, "Unable to allocate %d bytes for the sequence\n", MAXLENGTH + PADLENGTH );
     exit(1);
  }

  /* build sequence */
  length = build_sequence(sequence,SEQUENCE_FILE);

  /* build headptr */
  if((headptr = (struct llist **) malloc(HASH_SIZE*sizeof(*headptr))) == NULL)
  {
    fprintf(stderr,"Out of memory\n");  exit(1);
  } 
  if(VERBOSE) fprintf(stderr,"  Done allocating headptr\n");
  build_headptr(headptr); if(VERBOSE) fprintf(stderr,"  Done building headptr\n");

  /* sort headptr */
  ngoodlmers = count_headptr(headptr);
  if(VERBOSE) fprintf(stderr,"  There are %d l-mers\n",ngoodlmers);
  if((sortedfreq = (int *) malloc(ngoodlmers*sizeof(*sortedfreq))) == NULL)
  {
    fprintf(stderr,"Out of memory\n");  exit(1);
  } 
  if((sortedocc = (int *) malloc(ngoodlmers*sizeof(*sortedocc))) == NULL)
  {
    fprintf(stderr,"Out of memory\n");  exit(1);
  } 
  if((sortedindex = (long *) malloc(ngoodlmers*sizeof(*sortedindex))) == NULL)
  {
    fprintf(stderr,"Out of memory\n");  exit(1);
  } 
  sort_headptr(headptr, sortedfreq, sortedocc, sortedindex, ngoodlmers);
  if(VERBOSE) fprintf(stderr,"  Done sorting headptr\n");
  if(ngoodlmers == 0) { fprintf(stderr,"OOPS no good lmers\n"); exit(1); }

  print_lmers(headptr, sortedfreq, sortedocc, sortedindex, ngoodlmers);

  exit(0);
}