Пример #1
0
static void pukeit(const char *db, const char *defstring, char *retstring,
                   int retsize, int *cqnum)
{
    FILE     *fp;
    char    **help;
    int       i, nhlp;
    gmx_rng_t rng;

    if (be_cool() && ((fp = low_libopen(db, FALSE)) != NULL))
    {
        nhlp = fget_lines(fp, &help);
        /* for libraries we can use the low-level close routines */
        gmx_ffclose(fp);
        rng    = gmx_rng_init(gmx_rng_make_seed());
        *cqnum = static_cast<int>(nhlp*gmx_rng_uniform_real(rng));
        gmx_rng_destroy(rng);
        if (strlen(help[*cqnum]) >= STRLEN)
        {
            help[*cqnum][STRLEN-1] = '\0';
        }
        strncpy(retstring, help[*cqnum], retsize);
        for (i = 0; (i < nhlp); i++)
        {
            sfree(help[i]);
        }
        sfree(help);
    }
    else
    {
        *cqnum = -1;
        strncpy(retstring, defstring, retsize);
    }
}
Пример #2
0
static void pukeit(const char *db,const char *defstring, char *retstring, 
		   int retsize, int *cqnum)
{
  FILE *fp;
  char **help;
  int  i,nhlp;
  int  seed;
 
  if (be_cool() && ((fp = low_libopen(db,FALSE)) != NULL)) {
    nhlp=fget_lines(fp,&help);
    /* for libraries we can use the low-level close routines */
    ffclose(fp);
    seed=time(NULL);
    *cqnum=nhlp*rando(&seed);
    if (strlen(help[*cqnum]) >= STRLEN)
      help[*cqnum][STRLEN-1] = '\0';
    strncpy(retstring,help[*cqnum],retsize);
    f(retstring);
    for(i=0; (i<nhlp); i++)
      sfree(help[i]);
    sfree(help);
  }
  else 
    strncpy(retstring,defstring,retsize);
}
Пример #3
0
void thanx(FILE *fp)
{
  char cq[1024];
  int  cqnum;

  /* protect the audience from suggestive discussions */
  cool_quote(cq,1023,&cqnum);
  
  if (be_cool()) 
    fprintf(fp,"\ngcq#%d: %s\n\n",cqnum,cq);
  else
    fprintf(fp,"\n%s\n\n",cq);
}