hmmer-3.3/easel/miniapps/esl-alimerge.c
/* Function: read_list_file
 * Date:     EPN, Fri Nov 20 16:41:32 2009
 * 
 * Read a file listing alignment files to merge.
 * Store file names in *ret_alifile_list and return it,
 * return number of files in ret_nalifile and return it.
 * Each white-space delimited token is considered a 
 * different alignment name. 
 * 
 * Dies if we encounter an error.
 * 
 * Returns: void.
 */


Read a file listing alignment files to merge.
Store file names in *ret_alifile_list and return it,
return number of files in ret_nalifile and return it.
Each white-space delimited token is considered a
different alignment name.

Dies if we encounter an error.

void.
Read a file listing alignment files to merge . Store file names in * ret_alifile_list and return it return number of files in ret_nalifile and return it . Each white - space delimited token is considered a different alignment name . Dies if we encounter an error . void .
void
read_list_file(char *listfile, char ***ret_alifile_list, int *ret_nalifile)
{
  int             status;
  ESL_FILEPARSER *efp;
  char           *tok;
  int nalloc     = 10;
  int chunksize  = 10;
  char **alifile_list = NULL;
  int n = 0;
  void *tmp;
  ESL_ALLOC(alifile_list, sizeof(char *) * nalloc);
  status = esl_fileparser_Open(listfile, NULL,  &efp);
  if     (status == eslENOTFOUND) esl_fatal("List file %s does not exist or is not readable\n", listfile);
  else if(status == eslEMEM)      esl_fatal("Ran out of memory when opening list file %s\n", listfile);
  else if(status != eslOK)        esl_fatal("Error opening list file %s\n", listfile);
  esl_fileparser_SetCommentChar(efp, '#');
  while((status = esl_fileparser_GetToken(efp, &tok, NULL)) != eslEOF) {
    if(n == nalloc) { nalloc += chunksize; ESL_RALLOC(alifile_list, tmp, sizeof(char *) * nalloc); }
    if((status = esl_strdup(tok, -1, &(alifile_list[n++]))) != eslOK) {
      esl_fatal("Error storing alignment file name while reading list file %s, error status: %d\n", listfile, status);
    }
  }
  esl_fileparser_Close(efp);
  *ret_alifile_list = alifile_list;
  *ret_nalifile = n;
  return;
 ERROR:
  esl_fatal("Out of memory.");
  return; 
}
void read_list_file ( char * listfile , char * * * ret_alifile_list , int * ret_nalifile ) { int status ; ESL_FILEPARSER * efp ; char * tok ; int nalloc = 10 ; int chunksize = 10 ; char * * alifile_list = NULL ; int n = 0 ; void * tmp ; ESL_ALLOC ( alifile_list , sizeof ( char * ) * nalloc ) ; status = esl_fileparser_Open ( listfile , NULL , & efp ) ; if ( status == eslENOTFOUND ) esl_fatal ( " \n " , listfile ) ; else if ( status == eslEMEM ) esl_fatal ( " \n " , listfile ) ; else if ( status != eslOK ) esl_fatal ( " \n " , listfile ) ; esl_fileparser_SetCommentChar ( efp , ' ' ) ; while ( ( status = esl_fileparser_GetToken ( efp , & tok , NULL ) ) != eslEOF ) { if ( n == nalloc ) { nalloc += chunksize ; ESL_RALLOC ( alifile_list , tmp , sizeof ( char * ) * nalloc ) ; } if ( ( status = esl_strdup ( tok , -1 , & ( alifile_list [ n ++ ] ) ) ) != eslOK ) { esl_fatal ( " \n " , listfile , status ) ; } } esl_fileparser_Close ( efp ) ; * ret_alifile_list = alifile_list ; * ret_nalifile = n ; return ; ERROR : esl_fatal ( " " ) ; return ; }
Function: read_list_file
 Date:     EPN, Fri Nov 20 16:41:32 2009
Function : read_list_file Date : EPN Fri Nov 20 16 : 41 : 32 2009
/*NOTREACHED*/