Exemple #1
0
void print_puzzle() {
	int r; // Incrementation variable

	print_dashes();

	for(r = 1; r < 10; r++){
		
		print_row(r);

		if (( r % 3 ) == 0 ){
			print_dashes();
		}	

	}
}
void chunkedbag_dispatch_by_property() {
  util::cmdline::argmap_dispatch c;
  c.add("pushpop", [] { // run push pop tests
    auto msg = "we get consistent results on randomly selected "
    "sequences of pushes and pops";
    checkit<typename Properties::push_pop_sequence_same>(msg);
  });
  c.add("split", [] { // run split tests
    auto msg = "we get consistent results for calls to split on a "
    "random position in the sequence";
    checkit<typename Properties::split_same>(msg);
  });
  c.add("concat", [] { // run concat tests
    auto msg = "we get consistent results on calls to concat";
    checkit<typename Properties::concat_same>(msg);
  });
  c.add("iterator", [] {
    auto msg = "we get consistent results on iterator-based traversal";
    checkit<typename Properties::iterator_same>(msg);
  });
  c.add("for_each_segment", [] {
    auto msg = "we get correct results over calls to for_each_segment";
    checkit<typename Properties::for_each_segment_correct>(msg);
  });
  c.add("pushn_popn", [] {
    auto msg = "we get correct results over calls to pushn and to popn";
    checkit<typename Properties::pushn_popn_sequence_same>(msg);
  });
  c.add("backn_frontn", [] {
    auto msg = "we get correct results over calls to backn and frontn";
    checkit<typename Properties::backn_frontn_sequence_same>(msg);
  });
  print_dashes();
  util::cmdline::dispatch_by_argmap_with_default_all(c, "property");
  print_dashes();
}
void
process_result_set (CHAR_DATA *ch, MYSQL *db, MYSQL_RES *res)
{
	MYSQL_FIELD *field;
	MYSQL_ROW row;
	unsigned int i, c, col_len;
	
	char sbuf[MSL];
	/* determine column display widths */
	mysql_field_seek (res, 0);
	unsigned int clen[1000];
	for (i = 0; i < mysql_num_fields (res); i++)
	{	
		field = mysql_fetch_field (res);
		clen[i] = strlen (field->name);
		if (clen[i] < field->max_length)
			clen[i]=field->max_length;
		if (clen[i] < 4 && !IS_NOT_NULL (field->flags))
			clen[i] = 4; /* 4 = length of the word “NULL” */
		if(!strcmp(field->name,"timestamp"))
			clen[i] -= 18;
		
	}
	print_dashes (ch, res);
	mysql_field_seek (res, 0);
	for (i = 0; i < mysql_num_fields (res); i++)
	{
		field = mysql_fetch_field (res);
		sprintf (sbuf,"#8| #C%-*s #0", clen[i], field->name);
		stc(sbuf, ch);
	}
	sprintf (sbuf,"\n");
	stc(sbuf, ch);
	print_dashes (ch, res);
	while ((row = mysql_fetch_row (res)) != NULL)
	{
		mysql_field_seek (res, 0);
		for (i = 0; i < mysql_num_fields (res); i++)
		{
			field = mysql_fetch_field (res);
			if (row[i] == NULL)
			{
				sprintf (sbuf,"#8| %-*s #0", clen[i], "NULL");
				stc(sbuf, ch);
			}
			else if (IS_NUM (field->type))
			{	
				sprintf (sbuf,"#8| #R%*s #0", clen[i], row[i]);
				stc(sbuf, ch);
			}
			else
			{
					c = strlen(field->name);
					sprintf (sbuf,"#8| #W%-*s #0", clen[i], row[i]);
				
				stc(sbuf, ch);
			}
		}
		sprintf (sbuf,"\n");
		stc(sbuf, ch);
	}
	print_dashes (ch, res);
	sprintf (sbuf,"\n\r#R%lu #8Records returned#0\n\r", (unsigned long) mysql_num_rows (res));
	stc(sbuf, ch);
}