Beispiel #1
0
void
copyplane_test(void)
{
  int num_copies = 200;
  int i;
  long totaltime;
  char buf[80];

  if(!X.gcv.plane_mask || (X.gcv.plane_mask & (X.gcv.plane_mask - 1))) {
    show_result("exactly one bit in plane mask must be set for this test");
    return;
  }


  num_copies *= X.percent;

  XSetPlaneMask(X.dpy, X.gc, ~0L);
  XSetFillStyle(X.dpy,X.miscgc,FillTiled);
  XFillRectangle(X.dpy,X.win,X.miscgc,0,0,400,400);

  XSync(X.dpy,0);
  timer(StartTimer);
  for (i=0;i<num_copies;++i)
    XCopyPlane(X.dpy,X.win,X.win,X.gc,i,200-i,
	      200,200,200-i,i,X.gcv.plane_mask);
  XSync(X.dpy,0);
  totaltime = timer(EndTimer);
  XSetPlaneMask(X.dpy, X.gc, X.gcv.plane_mask);

  snprintf(buf,sizeof buf,"%.2f seconds.",(double)totaltime/1000000.);
  show_result(buf);
}
Beispiel #2
0
/* Test Window Report - VT340, VT420 */
static int
tst_DECRQDE(MENU_ARGS)
{
  char *report;
  char chr;
  int Ph, Pw, Pml, Pmt, Pmp;

  vt_move(1, 1);
  println("Testing DECRQDE/DECRPDE Window Report");

  set_tty_raw(TRUE);
  set_tty_echo(FALSE);

  do_csi("\"v");
  report = get_reply();
  vt_move(3, 10);
  chrprint(report);

  if ((report = skip_csi(report)) != 0
      && sscanf(report, "%d;%d;%d;%d;%d\"%c",
                &Ph, &Pw, &Pml, &Pmt, &Pmp, &chr) == 6
      && chr == 'w') {
    vt_move(5, 10);
    show_result("lines:%d, cols:%d, left col:%d, top line:%d, page %d",
                Ph, Pw, Pml, Pmt, Pmp);
  } else {
    show_result(SHOW_FAILURE);
  }

  restore_ttymodes();
  vt_move(max_lines - 1, 1);
  return MENU_HOLD;
}
Beispiel #3
0
/* -----------------------------------------------------------------------------------*/
void main(void){
	struct create_process_error_type c_p_e;
	RETURN_CODE_TYPE retCode;
	PROCESS_ID_TYPE procMainIdMT;
	PROCESS_ID_TYPE procMainId1;
	char sal_code[MAX_CAD];

	/* Create Process Master Test */
	CREATE_PROCESS (&processTable[0],  /* process attribute */
                    &procMainIdMT,    /* process Id */
                    &retCode);

 	CHECK_CODE(": CREATE_PROCESS Process Master Test", retCode, sal_code);
    printf("%s\n", sal_code);

    /* Create Process 1 */
    CREATE_PROCESS (&processTable[1],  /* process attribute */
                    &procMainId1,    /* process Id */
                    &retCode);

	c_p_e = checkcreate_process(processTable[1], procMainId1, retCode, NO_ERROR);

	show_result(c_p_e);

	/* Create Process 1 again */
	CREATE_PROCESS (&processTable[1],  /* process attribute */
                    &procMainId1,    /* process Id */
                    &retCode);


	c_p_e = checkcreate_process(processTable[1], procMainId1, retCode, NO_ACTION);

	show_result(c_p_e);
}
Beispiel #4
0
int
any_DSR(MENU_ARGS, const char *text, void (*explain) (char *report))
{
    char *report;
    unsigned pmode = (unsigned) ((*text == '?') ? 1 : 0);

    vt_move(1, 1);
    printf("Testing DSR: %s\n", the_title);

    set_tty_raw(TRUE);
    set_tty_echo(FALSE);

    do_csi("%s", text);
    report = get_reply();
    vt_move(3, 10);
    chrprint(report);
    if ((report = skip_csi(report)) != 0
            && strlen(report) > (1 + pmode)
            && (!pmode || (*report++ == '?'))) {
        if (explain != 0)
            (*explain) (report);
        else
            show_result(SHOW_SUCCESS);
    } else {
        show_result(SHOW_FAILURE);
    }

    restore_ttymodes();
    vt_move(max_lines - 1, 1);
    return MENU_HOLD;
}
Beispiel #5
0
/********************MAIN*****************/
int main(int argc, char **argv){
  srand(time(NULL));
  initialize("cyclotron.dat");
  print_map(map);
  max=0;RANGE=13; /* Set max and RANGE*/
  search(map); /* Searching*/
  show_result(optimum,max); /* Show result*/
  printf("\n");
  max=0; RANGE=13; /* Reset max and RANGE*/
  print_map(map1);
  search(map1);
  show_result(optimum,max);
  return 0;
}
Beispiel #6
0
int
main (int argc, char **argv)
{
	GnomeVFSResult    result;
	GnomeVFSHandle   *handle;
	gchar             buffer[1024];
	GnomeVFSFileSize  bytes_read;
	GnomeVFSURI 	 *uri;
	gchar            *text_uri;

	if (argc != 2) {
		printf ("Usage: %s <uri>\n", argv[0]);
		return 1;
	}

	if (! gnome_vfs_init ()) {
		fprintf (stderr, "Cannot initialize gnome-vfs.\n");
		return 1;
	}

	uri = gnome_vfs_uri_new (argv[1]);
	if (uri == NULL) {
		fprintf (stderr, "URI not valid.\n");
		return 1;
	}

	text_uri = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);

	result = gnome_vfs_open_uri (&handle, uri, GNOME_VFS_OPEN_WRITE);
	show_result (result, "open", text_uri);

	while( result==GNOME_VFS_OK && !feof(stdin)) {
		GnomeVFSFileSize temp;

		bytes_read = fread(buffer, 1, sizeof buffer - 1, stdin);
		if(!bytes_read) break;
		buffer[bytes_read] = 0;
		result = gnome_vfs_write (handle, buffer, bytes_read,
				 	&temp);
		show_result (result, "write", text_uri);
	
	}

	result = gnome_vfs_close (handle);
	show_result (result, "close", text_uri);

	g_free (text_uri);

	return 0;
}
Beispiel #7
0
void history_back()
{
	RESULT *result;
	GList *previous;

	LOG(LOG_DEBUG, "IN : history_back()");

	if(current_in_history == NULL) {
		LOG(LOG_DEBUG, "OUT : history_back() = nop1");
		return;
	}

	previous = g_list_previous(current_in_history);
	if(previous == NULL){
		LOG(LOG_DEBUG, "OUT : history_back() = nop2");
		return;
	}
	
	result = (RESULT *)(previous->data);
	g_assert(result != NULL);

	show_result(result, FALSE, FALSE);
	
	current_in_history = previous;

	LOG(LOG_DEBUG, "OUT : history_back()");
}
Beispiel #8
0
bool UIProperty::compute_value( ItemUpgrades_type const& item_upgrades )
{
	if ( !get_property() )
	{
		return false;
	}

	int prop_count = 0;
	string2048 buf; buf[0] = 0;
	ItemUpgrades_type::const_iterator ib_upg = item_upgrades.begin();
	ItemUpgrades_type::const_iterator ie_upg = item_upgrades.end();
	for ( ; ib_upg != ie_upg; ++ib_upg )
	{
		Upgrade_type* upgr = ai().alife().inventory_upgrade_manager().get_upgrade( *ib_upg );
		VERIFY( upgr );
		if ( upgr->get_property_name()._get() == m_property_id._get() )
		{
			LPCSTR upgr_section = upgr->section();
			if ( prop_count > 0 )
			{
				strcat_s( buf, sizeof(buf), ", " );
			}
			strcat_s( buf, sizeof(buf), upgr_section );
			++prop_count;
		}
	}
	if ( prop_count > 0 )
	{
		return show_result( buf );
	}
	return false;
}
Beispiel #9
0
void get_part(int n)
{
	int i, part_no, sum, size;
	int *p, *q;
	p = (int *)malloc(n * sizeof(int));
	q = (int *)malloc(n * sizeof(int));
	// init
	p[1] = n, q[1] = part_no = 1;

	while(1) {
		show_result(p, q, part_no);
		if(p[1] == 1)
			break;
		sum = p[part_no] == 1 ? q[part_no--] + 1 : 1;
		size = p[part_no] - 1;
		if(q[part_no] != 1)
			q[part_no++]--;
		p[part_no] = size;
		q[part_no] = sum / size + 1;
		if(sum % size)
			p[++part_no] = sum % size, q[part_no] = 1;
	}

	free(p);
	free(q);
}
Beispiel #10
0
int
main (int argc, char **argv)
{
	MateVFSResult    result;
	MateVFSURI 	 *uri;
	gchar            *text_uri;

	if (argc != 2) {
		printf ("Usage: %s <uri>\n", argv[0]);
		return 1;
	}

	if (! mate_vfs_init ()) {
		fprintf (stderr, "Cannot initialize mate-vfs.\n");
		return 1;
	}

	uri = mate_vfs_uri_new (argv[1]);
	if (uri == NULL) {
		fprintf (stderr, "URI not valid.\n");
		return 1;
	}

        text_uri = mate_vfs_uri_to_string (uri, MATE_VFS_URI_HIDE_NONE);

	result = mate_vfs_unlink (text_uri);
	show_result (result, "unlink", text_uri);

	g_free (text_uri);

	return 0;
}
Beispiel #11
0
void
putimage_test(void)
{
  int num_copies = 200;
  int i;
  long totaltime;
  char buf[80];

  num_copies *= X.percent;

  XSetFillStyle(X.dpy,X.miscgc,FillTiled);
  XFillRectangle(X.dpy,X.win,X.miscgc,0,0,400,400);

  X.image = XGetImage(X.dpy,X.win,0,0,200,200,~0,XYPixmap);

  XSync(X.dpy,0);
  timer(StartTimer);
  for (i=0;i<num_copies;++i)
    XPutImage(X.dpy,X.win,X.gc,X.image,0,0,i,i,200,200);
  XSync(X.dpy,0);
  totaltime = timer(EndTimer);

  snprintf(buf,sizeof buf,"%.2f seconds.",(double)totaltime/1000000.);
  show_result(buf);
}
Beispiel #12
0
void
imagetext16_test(void)
{
  int num_strings = 50;
  int i;
  long totaltime;
  char buf[80];

  num_strings *= X.percent;

  GC_change_font(unicode_font,FALSE);

  XSync(X.dpy,0);
  start_timer();
  for (i=0;i<num_strings;++i) {
    XDrawImageString16(X.dpy,X.win,X.gc,(i%2 ? i : num_strings - i),10*i,
		       string16,sizeof(string16)/sizeof(XChar2b));
  }
  XSync(X.dpy,0);
  totaltime = end_timer();

  GC_change_font(X.fontname,FALSE);

  snprintf(buf,sizeof buf,"%d strings in %.2f seconds.",num_strings,
	  (double) totaltime/1000000.);
  show_result(buf);
}
Beispiel #13
0
void
genericarc_test(Boolean fill)
{
  XArc *arcs;
  int num_arcs = 180;
  int i;
  long totaltime;
  char buf[80];

  num_arcs *= X.percent;

  arcs = (XArc *) malloc(sizeof(XArc) * num_arcs);

  for (i=0;i<num_arcs;++i) {
    arcs[i].x = i;
    arcs[i].y = i;
    arcs[i].width = i;
    arcs[i].height = i;
    arcs[i].angle1 = i * 128;
    arcs[i].angle2 = i * 128;
  }

  XSync(X.dpy,0);
  start_timer();
  if (fill) XFillArcs(X.dpy,X.win,X.gc,arcs,num_arcs);
  else XDrawArcs(X.dpy,X.win,X.gc,arcs,num_arcs);
  XSync(X.dpy,0);
  totaltime = end_timer();

  snprintf(buf,sizeof buf,"An uncounted number of pixels in %.3f seconds.",
	  (double)totaltime/1000000.);
  show_result(buf);

  free(arcs);
}
Beispiel #14
0
void
polypoint_test(void)
{
  XPoint *points;
  int num_points = 100000;
  long totaltime;
  char buf[80];
  int i;
  
  num_points *= X.percent;

  points = (XPoint *) malloc(sizeof(XPoint) * num_points);

  points[0].x = random()%400; points[0].y = random()%400;
  points[1].x = random()%400; points[1].y = random()%400;

  for (i=2;i<num_points;++i) {
    points[i].x = (points[i-1].x+points[i-2].y+i*3/200)%400;
    points[i].y = (points[i-1].y+points[i-2].x+i*5/200)%400;
  }

  XSync(X.dpy,0);
  start_timer();
  XDrawPoints(X.dpy,X.win,X.gc,points,num_points,CoordModeOrigin);
  XSync(X.dpy,0);
  totaltime = end_timer();

  snprintf(buf,sizeof buf,"%d points in %.3f seconds.",num_points,
	  (double)totaltime/1000000.);
  show_result(buf);

  free(points);
}
Beispiel #15
0
void
polysegment_test(void)
{
  XSegment *segments;
  int num_segments = 600;
  long totaltime;
  char buf[80];
  int i;

  num_segments *= X.percent;

  segments = (XSegment *) malloc(sizeof(XSegment) * num_segments);

  segments[0].x1 = random()%400; segments[0].y1 = random()%400;
  segments[0].x2 = random()%400; segments[0].y2 = random()%400;

  for(i=1;i<num_segments;++i) {
    segments[i].x1 = (segments[i-1].x1-segments[i-1].y2+400+i)%400;
    segments[i].y1 = (segments[i-1].y1+segments[i-1].x2+i)%400;
    segments[i].x2 = (segments[i-1].x1-segments[i-1].y1+400+i)%400;
    segments[i].y2 = (segments[i-1].x2+segments[i-1].y2+i)%400;
  }

  XSync(X.dpy,0);
  start_timer();
  XDrawSegments(X.dpy,X.win,X.gc,segments,num_segments);
  XSync(X.dpy,0);
  totaltime = end_timer();
  
  snprintf(buf,sizeof buf,"%d segments in %.3f seconds.",num_segments,
	  (double)totaltime/1000000.);
  show_result(buf);

  free(segments);
}
Beispiel #16
0
void history_forward()
{
	RESULT *result;
	GList *next;

	LOG(LOG_DEBUG, "IN : history_forward()");

	if(current_in_history == NULL){
		LOG(LOG_DEBUG, "OUT : history_forward() = nop1");
		return;
	}

	next = g_list_next(current_in_history);
	if(next == NULL){
		LOG(LOG_DEBUG, "OUT : history_forward() = nop2");
		return;
	}
	
	result = (RESULT *)(next->data);
	g_assert(result != NULL);

	show_result(result, FALSE, FALSE);
	
	current_in_history = next;

	LOG(LOG_DEBUG, "OUT : history_forward()");
}
int
main (int argc, char **argv)
{
    GnomeVFSResult    result;
    gchar            *text_uri = "/tmp/";
    GnomeVFSMonitorHandle *handle;

    if (! gnome_vfs_init ()) {
        fprintf (stderr, "Cannot initialize gnome-vfs.\n");
        return 1;
    }

    if (argc == 2) {
        text_uri = argv[1];
    }

    result = gnome_vfs_monitor_add (&handle, text_uri,
                                    GNOME_VFS_MONITOR_DIRECTORY, callback, "user data");
    printf ("handle is %p\n", handle);
    show_result (result, "monitor_add", text_uri);

    g_timeout_add (1000, timeout_cb, NULL);

    if (result == GNOME_VFS_OK) {
        main_loop = g_main_loop_new (NULL, TRUE);
        g_main_loop_run (main_loop);
        g_main_loop_unref (main_loop);
    }

    g_free (text_uri);

    return 0;
}
Beispiel #18
0
int ser_data_handle(int fd,char *buf,int len)
{
	int ret,cmd_type;
	void *cmd;
	query_result *result;

	//将套接字的数据读到buf中去
	do{
		ret=read(fd,buf,BUFSIZ-1);
	}while(ret<0&&EINTR==errno);
	if(ret<0)
	{
		perror("read fail");
		return -1;
	}
	if(!ret)
		return -1;

	//按照协议拆包!!!
	//unpack_cmd(1,&cmd_type,cmd,buf,len);
	cmd_type = json_head_unpack(buf);// FIXME

	printf("receive message:\n");
	switch(cmd_type){
		case MSG_RECV_MDC_BOX:
			result = (query_result *)cmd;
			show_result(*result);
			break;
		case MSG_EAT_NOTIFY:
			break;
	}

	return 0;
}
Beispiel #19
0
static void
report_ok(const char *ref, const char *tst)
{
    if ((tst = skip_csi_2(tst)) == 0)
        tst = "?";
    show_result(!strcmp(ref, tst) ? SHOW_SUCCESS : SHOW_FAILURE);
}
Beispiel #20
0
/* -----------------------------------------------------------------------------------*/
void Process1(void){
	PROCESS_ID_TYPE procMainId2;
	struct suspend_error_type s_e;
	RETURN_CODE_TYPE retCode;
	char sal_code[MAX_CAD];

	printf("Process 1 starts ...\n");

	/* To get the procMainId2 value */
	GET_PROCESS_ID("tProc2", &procMainId2, &retCode);
	CHECK_CODE(": GET_PROCESS_ID Process 2", retCode, sal_code);
    printf("%s\n", sal_code);

	START(procMainId2 ,&retCode);
	CHECK_CODE(": START Process 2", retCode, sal_code);
    printf("%s\n", sal_code);

	/* TIMED_WAIT(REGULAR_TIME_WAIT, &retCode);
	CHECK_CODE(": TIMED_WAIT", retCode, sal_code);
    printf("%s\n", sal_code);				*/

	s_e = checksuspend(procMainId2, NO_ERROR);

	show_result(s_e);

	STOP_SELF();
}
Beispiel #21
0
static void
show_ExtendedCursorPosition(char *report)
{
  int pos = 0;
  int Pl = scan_any(report, &pos, 'R');
  int Pc = scan_any(report, &pos, 'R');
  int Pp = scan_any(report, &pos, 'R');

  if (Pl != 0 && Pc != 0) {
    if (Pp != 0)
      show_result("Line %d, Column %d, Page %d", Pl, Pc, Pp);
    else
      show_result("Line %d, Column %d (Page?)", Pl, Pc);
  } else
    show_result(SHOW_FAILURE);
}
Beispiel #22
0
/* Request Terminal State Report */
static int
tst_DECRQTSR(MENU_ARGS)
{
  char *report;
  const char *show;

  vt_move(1, 1);
  println("Testing Terminal State Reports (DECRQTSR/DECTSR)");

  set_tty_raw(TRUE);
  set_tty_echo(FALSE);

  do_csi("1$u");
  report = get_reply();

  vt_move(3, 10);
  chrprint(report);

  if ((report = skip_dcs(report)) != 0
      && strip_terminator(report)
      && !strncmp(report, "1$s", (size_t) 3)) {
    show = SHOW_SUCCESS;
  } else {
    show = SHOW_FAILURE;
  }
  show_result("%s", show);

  restore_ttymodes();
  vt_move(max_lines - 1, 1);
  return MENU_HOLD;
}
Beispiel #23
0
/* Test User-Preferred Supplemental Set - VT320 */
static int
tst_DECRQUPSS(MENU_ARGS)
{
  char *report;
  const char *show;

  __(vt_move(1, 1), println("Testing DECRQUPSS/DECAUPSS Window Report"));

  set_tty_raw(TRUE);
  set_tty_echo(FALSE);

  do_csi("&u");
  report = get_reply();
  vt_move(3, 10);
  chrprint(report);
  if ((report = skip_dcs(report)) != 0
      && strip_terminator(report)) {
    if (!strcmp(report, "0!u%5"))
      show = "DEC Supplemental Graphic";
    else if (!strcmp(report, "1!uA"))
      show = "ISO Latin-1 supplemental";
    else
      show = "unknown";
  } else {
    show = SHOW_FAILURE;
  }
  show_result("%s", show);

  restore_ttymodes();
  vt_move(max_lines - 1, 1);
  return MENU_HOLD;
}
Beispiel #24
0
static int
j_fselect(JUMPARGS)
{
    *offset_add = arg_rest(av);
    return show_result(dialog_fselect(t,
				      av[1],
				      numeric_arg(av, 2),
				      numeric_arg(av, 3)));
}
Beispiel #25
0
static int
j_passwordbox(JUMPARGS)
{
    *offset_add = arg_rest(av);
    return show_result(dialog_inputbox(t,
				       av[1],
				       numeric_arg(av, 2),
				       numeric_arg(av, 3),
				       optional_str(av, 4, 0), 1));
}
Beispiel #26
0
void CCusQueryDlg::OnBnClickedQueryBtn()
{
	// TODO: Add your control notification handler code here
	m_queryEdt.GetWindowText(m_buffer,CKMYSQL_BUFF_LENGTH);
	if(m_pKmySql->query(m_buffer))
	{
		m_pKmySql->store_result();
		show_result();
	}	
}
Beispiel #27
0
	void BazARTracker::update()
	{
		// Do not update with a null image
		if (m_imageptr == NULL) return;

		// Image format conversion for BAZAR
		for(int i=0; i<m_cparam->cparam.xsize*m_cparam->cparam.ysize*4; i++)
		{
			image->imageData[i] = m_imageptr[i];
		}
		
		// Image format change for processing color->gray
		if(image->nChannels == 4) 
		{
			cvCvtColor(image, gray, CV_RGBA2GRAY);
		} 
		else if(image->nChannels == 3) 
		{
			cvCvtColor(image, gray, CV_BGR2GRAY);
		} 
		else 
		{
			gray = image;
		}
		
		cvFlip(gray, gray);				// bazar uses hoizontially flipped input images
		
		if(getDebugMode()) cvShowImage("Gray", gray);		// show what bazar will see
		

		// if the trained planar surface is detected
		if (detector.detect(gray))  
		{
			// start on a new frame
			augment.Clear();

			// we have only 1 camera
			add_detected_homography(detector, augment);

			// bundle adjust
			augment.Accomodate(4, 1e-4);
		
			show_result(augment, image, &display);	// GL-projection matrix, if debug: render additional output
			
			if (getDebugMode()) cvShowImage("Result_BAZAR", display);

			(static_cast<BazARMarker*>(m_markerlist[0].get()))->update(matCameraRT4_4);
		} 
		else 
		{
			if (getDebugMode()) cvShowImage("Result_BAZAR", display);
			
			(static_cast<BazARMarker*>(m_markerlist[0].get()))->update(NULL);
		}
	}
Beispiel #28
0
void save_save(GtkWindow* parent)
{
	if (cur_save_uri) {
		const gchar * frz_file = game_state_get_frz_file();
		gchar * frz_uri = gnome_vfs_get_uri_from_local_path(frz_file);
		show_result(copy_file(frz_uri, cur_save_uri), parent, "Game saved");
		g_free(frz_uri);
	} else {
		save_save_as(parent);
	}
}
int main(int argc, char *argv[])
{
	AdjMatrix *G;

	G = init(G);
	Creat(G);
	show(G);
	show_result(G);

	return EXIT_SUCCESS;
}
Beispiel #30
0
static int
j_timebox(JUMPARGS)
{
    *offset_add = arg_rest(av);
    return show_result(dialog_timebox(t,
				      av[1],
				      numeric_arg(av, 2),
				      numeric_arg(av, 3),
				      optional_num(av, 4, -1),
				      optional_num(av, 5, -1),
				      optional_num(av, 6, -1)));
}