Ejemplo n.º 1
0
/*
 * Routine: mk_author()
 * Purpose: create A_LNAME as required in Clause 4.6.2.18
 * Params: int author: author number to base the last name upon
 * Returns: char *
 * Called By: main()
 * Calls: digsyl(), tpc_random()
 * Side Effects: since the result is stored in a static char[], the result
 *				will be over-written by a subsequent call
 * TODO: None
 */
char * 
mk_author(int author)
{
	static	char res[A_LNAME_MAX + 1];
	char 	*dig,
			pad[A_LPAD_MAX + 1];
	int		lname_pad,
			len;

	memset(res, ' ', A_LNAME_MAX);
	if (author <= (author_count / A_AUTHOR_DEN))
		dig = digsyl(author, SYL_CNT);
	else
		{
		dig = digsyl(
			tpc_random(A_AUTHOR_MIN, (long)(author_count / A_AUTHOR_DEN), 
				A_LNAME_SD), SYL_CNT);
		}

	strncpy(res, dig, SYL_CNT * SYL_WIDTH);

	/* 75% of names are digsyl() alone; the rest have a a_rnd suffix */
	lname_pad = (tpc_random(1, 100, I_TITLE_SD) <= A_LPAD_PROB)?1:0;
	if (lname_pad)
		{
		len = a_rnd(A_LPAD_MIN, A_LPAD_MAX, A_LNAME_SD, pad);
		strncpy(&res[SYL_CNT * SYL_WIDTH], pad, len);
		}

	res[A_LNAME_MAX] = '\0';

	return(res);
}
Ejemplo n.º 2
0
/*
 * embed a randomly selected member of distribution d in alpha-numeric
 * noise of a length rendomly selected between min and max at a random
 * position
 */
void e_str(distribution *d, int min, int max, int stream, char *dest) {
  char strtmp[MAXAGG_LEN + 1];
  long loc;
  int len;

  a_rnd(min, max, stream, dest);
  pick_str(d, stream, strtmp);
  len = strlen(strtmp);
  RANDOM(loc, 0, (strlen(dest) - 1 - len), stream);
  strncpy(dest + loc, strtmp, len);

  return;
}