hmmer-3.3/src/p7_hmm.c
/* Function: p7_hmm_AppendComlog()
 * Synopsis: Concatenate and append command line to the command line log.
 * 
 * Purpose:  Concatenate command line options and append as a new line in the
 *           command line log. Command line log is multiline, with each line
 *           ending in newline char, except for last line.
 *           
 * Returns:  <eslOK> on success.
 * 
 * Throws:   <eslEMEM> on allocation failure.          
 */
p7_hmm_AppendComlog()
Synopsis: Concatenate and append command line to the command line log.

Concatenate command line options and append as a new line in the
command line log. Command line log is multiline, with each line
ending in newline char, except for last line.

 on success.

 on allocation failure.
p7_hmm_AppendComlog () Synopsis : Concatenate and append command line to the command line log . Concatenate command line options and append as a new line in the command line log . Command line log is multiline with each line ending in newline char except for last line . on success . on allocation failure .
int
p7_hmm_AppendComlog(P7_HMM *hmm, int argc, char **argv)
{
  int   status;
  void *tmp;
  int   n;
  int   i;
  n = argc-1;	
  for (i = 0; i < argc; i++)
    n += strlen(argv[i]);
  if (hmm->comlog != NULL) {
    n += strlen(hmm->comlog) + 1; 
    ESL_RALLOC(hmm->comlog, tmp, sizeof(char)* (n+1));
    strcat(hmm->comlog, "\n");
  } else {
    ESL_ALLOC(hmm->comlog, sizeof(char)* (n+1));
    *(hmm->comlog) = '\0'; 
  }
  for (i = 0; i < argc-1; i++)
    {
      strcat(hmm->comlog, argv[i]);
      strcat(hmm->comlog, " ");
    }
  strcat(hmm->comlog, argv[argc-1]);
  return eslOK;
 ERROR:
  return status;
}
int p7_hmm_AppendComlog ( P7_HMM * hmm , int argc , char * * argv ) { int status ; void * tmp ; int n ; int i ; n = argc - 1 ; for ( i = 0 ; i < argc ; i ++ ) n += strlen ( argv [ i ] ) ; if ( hmm -> comlog != NULL ) { n += strlen ( hmm -> comlog ) + 1 ; ESL_RALLOC ( hmm -> comlog , tmp , sizeof ( char ) * ( n + 1 ) ) ; strcat ( hmm -> comlog , " \n " ) ; } else { ESL_ALLOC ( hmm -> comlog , sizeof ( char ) * ( n + 1 ) ) ; * ( hmm -> comlog ) = ' \0 ' ; } for ( i = 0 ; i < argc - 1 ; i ++ ) { strcat ( hmm -> comlog , argv [ i ] ) ; strcat ( hmm -> comlog , " " ) ; } strcat ( hmm -> comlog , argv [ argc - 1 ] ) ; return eslOK ; ERROR : return status ; }
Function: p7_hmm_AppendComlog()
 Synopsis: Concatenate and append command line to the command line log.
Function : p7_hmm_AppendComlog () Synopsis : Concatenate and append command line to the command line log .
/* figure out length of added command line, and (re)allocate comlog */ /* account for 1 space per arg, except last one */ /* +1 for the \n we're going to add to the old comlog */ /* need this to make strcat work */