int main(int argc, char *argv[])
{
   bool ret = true;
   dstring dynamic_dstring = DSTRING_INIT;
   dstring static_dstring;
   char    static_buffer[MAX_STRING_SIZE];
   
   sge_dstring_init(&static_dstring, static_buffer, STATIC_SIZE);

   printf("running all checks with a dynamic dstring\n");
   ret = check_all(&dynamic_dstring);
   test_dstring_performance(&dynamic_dstring, 100000, "test_data"); 
   test_dstring_performance_dynamic(100000, "test_data"); 
   printf("%s\n", sge_dstring_get_string(&dynamic_dstring));

   if (ret) {
      printf("\n\nrunning all checks with a static dstring of length %d\n", 
             STATIC_SIZE);
         ret = check_all(&static_dstring);
         test_dstring_performance(&static_dstring, 100000, "test_data"); 
         test_dstring_performance_static(100000, "test_data"); 
         printf("%s\n", sge_dstring_get_string(&static_dstring));
   }



   sge_dstring_free(&dynamic_dstring);

   return ret ? EXIT_SUCCESS : EXIT_FAILURE;
}
예제 #2
0
void
check_random (int argc, char *argv[])
{
  gmp_randstate_t rands;
  mpz_t  w, x, y;
  int    i, reps = 2000;

  gmp_randinit_default(rands);
  mpz_init (w);
  mpz_init (x);
  mpz_init (y);

  if (argc == 2)
    reps = atoi (argv[1]);

  for (i = 0; i < reps; i++)
    {
      mpz_errandomb (w, rands, 5*BITS_PER_MP_LIMB);
      mpz_errandomb (x, rands, 5*BITS_PER_MP_LIMB);
      mpz_errandomb (y, rands, 5*BITS_PER_MP_LIMB);
      check_all (w, x, y);
      check_all_inplace (w, y);

      mpz_errandomb (w, rands, 5*BITS_PER_MP_LIMB);
      mpz_errandomb (x, rands, 5*BITS_PER_MP_LIMB);
      mpz_errandomb (y, rands, BITS_PER_ULONG);
      check_all (w, x, y);
      check_all_inplace (w, y);
    }

  mpz_clear (w);
  mpz_clear (x);
  mpz_clear (y);
  gmp_randclear(rands);
}
예제 #3
0
파일: check.c 프로젝트: xrf/coulomb_ho2d
int main(int argc, char **argv) {
    if (argc < 2) {
        check_all(NULL);
    } else {
        char **arg;
        for (arg = argv + 1; *arg; ++arg)
            check_all(*arg);
    }
    return EXIT_SUCCESS;
}
예제 #4
0
void
check_data (void)
{
  static const struct {
    int         base;
    const char  *num;
    const char  *den;
    const char  *want;
  } data[] = {
    { 10, "0", "1", "0" },
    { 10, "1", "1", "1" },

    { 16, "ffffffff", "1", "ffffffff" },
    { 16, "ffffffffffffffff", "1", "ffffffffffffffff" },

    { 16, "1", "ffffffff", "1/ffffffff" },
    { 16, "1", "ffffffffffffffff", "1/ffffffffffffffff" },
    { 16, "1", "10000000000000003", "1/10000000000000003" },

    { 10, "12345678901234567890", "9876543210987654323",
      "12345678901234567890/9876543210987654323" },
  };

  mpq_t  q;
  int    i;

  mpq_init (q);
  for (i = 0; i < numberof (data); i++)
    {
      mpz_set_str_or_abort (mpq_numref(q), data[i].num, data[i].base);
      mpz_set_str_or_abort (mpq_denref(q), data[i].den, data[i].base);
      check_all (q, data[i].base, data[i].want);
    }
  mpq_clear (q);
}
예제 #5
0
// 현재 i 에 대해 해당 값을 선택 / 비선택
int game_board2(std::vector<std::string> maps, int col_size, int i)
{
  if (maps.size() * col_size - 1 == i) 
  {
    if (check_all(maps)) 
    {
      std::cout << maps << std::endl;
      return 1;
    } 
    else return 0;
  }

  int r = i / col_size;
  int c = i % col_size;

  if (maps[r][c] != '.')
  {
    return game_board2(maps, col_size, i+1);
  }
  else
  {
    return game_board3(maps, col_size, i, 0) + game_board3(maps, col_size, i, 1) + 
           game_board3(maps, col_size, i, 2) + game_board3(maps, col_size, i, 3);
  }
}
예제 #6
0
파일: t-div_2exp.c 프로젝트: AllardJ/Tomato
void
check_random (int argc, char *argv[])
{
  gmp_randstate_ptr  rands = RANDS;
  int            reps = 100;
  mpz_t          a;
  unsigned long  d;
  int            i;

  if (argc == 2)
    reps = atoi (argv[1]);

  mpz_init (a);

  for (i = 0; i < reps; i++)
    {
      /* exponentially within 2 to 257 bits */
      mpz_erandomb (a, rands, urandom () % 8 + 2);

      d = urandom () % 256;

      check_all (a, d);
    }

  mpz_clear (a);
}
예제 #7
0
static int	resolve(char **tab, int position)
{
  int	row;
  int	column;
  int	number;

  if (position == 81)
    return (1);
  row = position / 9 + 1;
  column = position % 9;
  if (tab[row][column] != '.')
    return (resolve(tab, position + 1));
  number = 1;
  while (number < 10)
    {
      if (check_all(tab, position, number))
	{
	  tab[row][column] = (char)(number + '0');
	  if (resolve(tab, position + 1))
	    return (1);
	}
      number++;
    }
  tab[row][column] = '.';
  return (0);
}
void
check_rand (void)
{
  mpq_t  x, y, want_add, want_sub;
  int i;
  gmp_randstate_ptr  rands = RANDS;

  mpq_init (x);
  mpq_init (y);
  mpq_init (want_add);
  mpq_init (want_sub);

  for (i = 0; i < 500; i++)
    {
      mpz_errandomb (mpq_numref(x), rands, 512L);
      mpz_errandomb_nonzero (mpq_denref(x), rands, 512L);
      mpq_canonicalize (x);

      mpz_errandomb (mpq_numref(y), rands, 512L);
      mpz_errandomb_nonzero (mpq_denref(y), rands, 512L);
      mpq_canonicalize (y);

      refmpq_add (want_add, x, y);
      refmpq_sub (want_sub, x, y);

      check_all (x, y, want_add, want_sub);
    }

  mpq_clear (x);
  mpq_clear (y);
  mpq_clear (want_add);
  mpq_clear (want_sub);
}
int main(int argc, char *argv[])
{
  int sudoku[81];
  int *ptr;
  int i;
  i=0;
  if (argc!=2)
    {
      printf("USAGE: ./sudoku_solver FILENAME\n");
      printf("FILENAME is the file where the sudoku is stored. It has to be a string of 81 integers from 0 to 9, without spaces\n");
      printf("The 0's represent the blank cells\n");
      return 1;
    }
  // Open File
  if(!(file_2_sudoku(sudoku,argv[1])))
    printf("[FILE 2 SUDOKU] File format not valid");
  // Check that the given sudoku is valid
  if (check_all(sudoku))
    {
      printf("Error. Invalid Sudoku.\n");
      return 1;
    }
  printf("Problem\n");
  print_sudoku(sudoku);
  printf("Solving... Be patient!\n");
  solve_sudoku(sudoku);
  printf("Solution\n");
  print_sudoku(sudoku);
  return 0;
}
예제 #10
0
파일: qmem_task.c 프로젝트: husthl/qos
// check memory leak
bool qmem_task_at_exit(void) {
    if( 0 == GCFG_MEM_EN ) {
        return true;
    }

    return_false_if( !printf_leak_memory() );
    return_false_if( !check_all() );
    return true;
}
예제 #11
0
Filter::Filter(QWidget *parent) : QWidget(), ui(new Ui::filter)
{
    settings = static_cast<DFRSSFilter*>(parent)->settings;
    lineEdit = new QLineEdit(this);
    filters.clear();
    lineEdit->setPlaceholderText("Введите фильтр...");

    QPushButton *add_button = new QPushButton;       // добавить фильтр
    add_button->setText("Добавить");
    QPushButton *del_button = new QPushButton;       // удалить фильтр
    del_button->setText("Удалить");
    QPushButton *check_all_button = new QPushButton;       // выбрать все
    check_all_button->setText("Выбрать все");
    QPushButton *uncheck_all_button = new QPushButton;       // снять выбор
    uncheck_all_button->setText("Отменить все");

    filter_hint = new QLabel(this);

    filers_list = new QTreeWidget(this);
    filers_list->setSelectionMode(QAbstractItemView::ExtendedSelection); // чтобы можно было выделять несколько элементов с помощью Ctrl и Shift
    set_filters_header_label();
    // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    // здесь решается вопрос растяжения - нужно его решить
    filers_list->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
    filers_list->header()->hide(); // скроем заголовок таблицы - он нафиг не нужен
    show_filters(filers_list, filters);

    choice_hint = new QLabel(this);
    choice_hint->setText("Используйте Ctrl и Shift для множественного выделения удаляемых фильтров");

    QHBoxLayout *h_layout = new QHBoxLayout;         //
    h_layout->addWidget(lineEdit);
    h_layout->addWidget(add_button);
    h_layout->addWidget(del_button);

    QHBoxLayout *bottom_h_layout = new QHBoxLayout;  // нижний
    bottom_h_layout->addWidget(choice_hint);
    bottom_h_layout->addWidget(check_all_button);
    bottom_h_layout->addWidget(uncheck_all_button);

    QVBoxLayout *v_layout = new QVBoxLayout;         //
    v_layout->addLayout(h_layout);
    v_layout->addWidget(filter_hint);
    v_layout->addWidget(filers_list);
    v_layout->addLayout(bottom_h_layout);
    setLayout(v_layout); // установка главного лэйаута
    resize(640,480);

    // соединим кнопки с функциями
    connect(add_button, SIGNAL(clicked()), this, SLOT(add_filter()));  //
    connect(del_button, SIGNAL(clicked()), this, SLOT(del_filter()));  //
    connect(check_all_button, SIGNAL(clicked()), this, SLOT(check_all()));  //
    connect(uncheck_all_button, SIGNAL(clicked()), this, SLOT(uncheck_all()));  //
    //connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(add_filter())); // добавление по нажатию клавиши ENTER

    this->setWindowIcon(QIcon(":/filter.ico"));
}
예제 #12
0
int main(int argc, char** argv){
  setlocale(LC_ALL, "en_US.utf8");  
  initial_check();
  get_files_list();

  ESCDELAY = 1;
  menu_index = 0;
  previous_index = -1;
  
  initscr();
  noecho();
  keypad(stdscr, TRUE);
  getmaxyx(stdscr,rows,cols);
  diff_col_width = cols/2-1;
  start_color();
  use_default_colors();
  init_pair(1, COLOR_RED,     -1);
  init_pair(2, COLOR_GREEN,   -1);
  init_pair(3, COLOR_CYAN,    -1);
  refresh();

  print_files_menu();
  show_git_diff();

  ch = getch();  
  while(ch != 27 && ch != 'q'){
    switch(ch){
      case KEY_UP: 
        move_menu(-1);
        break;
      case KEY_DOWN: 
        move_menu(1);
        break;
      case 'h':
        show_help();
        break;
      case '?':
        show_help();
        break;
      case ' ':
        check_row();
        break;
      case 'a':
        check_all();
        break;
      case 'c':
        open_system_index_add_window();
        break;
    }
    ch = getch();  
  }
  
  endwin();
  git_threads_shutdown();
  return(EXIT_SUCCESS);
}
예제 #13
0
int main(int argc, char *argv[])
{
  MPI_Init(&argc, &argv);
  int rank;
  int size;
  size_t mem_size = 0x1000000;
  size_t shared_blocks[] = {
    0,         0x123456,
    0x130000, 0x130001,
    0x345678, 0x345789,
    0x444444, 0x555555,
    0x555556, 0x560000,
    0x800000, 0x1000000
  };
  int nb_blocks = (sizeof(shared_blocks)/sizeof(size_t))/2;
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  MPI_Comm_size(MPI_COMM_WORLD, &size);
  //Let's Allocate a shared memory buffer
  uint8_t *buf;
  buf = SMPI_PARTIAL_SHARED_MALLOC(mem_size, shared_blocks, nb_blocks);
  set(buf, 0, mem_size, 0);
  MPI_Barrier(MPI_COMM_WORLD);

  // Process 0 write in shared blocks
  if(rank == 0) {
    for(int i = 0; i < nb_blocks; i++) {
      size_t start = shared_blocks[2*i];
      size_t stop = shared_blocks[2*i+1];
      set(buf, start, stop, 42);
    }
  }
  MPI_Barrier(MPI_COMM_WORLD);
  // All processes check that their shared blocks have been written (at least partially)
  for(int i = 0; i < nb_blocks; i++) {
    size_t start = shared_blocks[2*i];
    size_t stop = shared_blocks[2*i+1];
    int is_shared = check_enough(buf, start, stop, 42);
    printf("[%d] The result of the shared check for block (0x%zx, 0x%zx) is: %d\n", rank, start, stop, is_shared);
  }


  // Check the private blocks
  MPI_Barrier(MPI_COMM_WORLD);
  for(int i = 0; i < nb_blocks-1; i++) {
    size_t start = shared_blocks[2*i+1];
    size_t stop = shared_blocks[2*i+2];
    int is_private = check_all(buf, start, stop, 0);
    printf("[%d] The result of the private check for block (0x%zx, 0x%zx) is: %d\n", rank, start, stop, is_private);
  }

  SMPI_SHARED_FREE(buf);

  MPI_Finalize();
  return 0;
}
예제 #14
0
파일: mice.c 프로젝트: ymqqqqdx/FrameBuffer
int mouse_test(fb_info fb)
{
    int fd;
    int xx = 123, yy = 234;
    if((fd = mouse_open("/dev/input/mice")) < 0)
    {
        perror("mouse_open");
        exit(1);
    }
    mevent_t mevent;
    u8_t buf[] = {0xf3,0xc8,0xf3,0x64,0xf3,0x50};
    if(write(fd, buf, sizeof(buf)) < sizeof(buf))
    {
        perror("mouse_write");
        fprintf(stderr, "Error write to mice device\n");
    }
    save_cursor(fb,xx,yy,cursor_save);
    while(1)
    {
        if(mouse_parse(fd, &mevent) == 0 && (mevent.x || mevent.y || mevent.z || mevent.button))
        {
            restore_cursor(fb,xx,yy,cursor_save);
            xx += mevent.x;
            yy += mevent.y;
            if(xx > 1366) xx = 1366;
            if(xx < 0)    xx = 0;
            if(yy > 721)  yy = 721;
            if(yy < 0)    yy = 0;
            if(mevent.button == 1 && xx < 420)
            {
                if(xx >= 300 && yy >=210 && yy <= 290)
                    who = 2;
                else if(xx >= 300 && yy >= 510 && yy <= 590)
                    who = 1;
            }
            if(mevent.button == 1 && xx >= 420 && yy <= 710 && xx <= 1320)
            {
                if(! check(xx,yy))
                {
                    draw_piece(fb,(xx + 15)/30 * 30,yy/30 * 30 + 15,13,(who - 1) ? 0x00000000 : 0xffffffff);
                    chess_count(xx, yy);
                    if(check_all(fb))
                        exit(0);
                    printf("%d %d\n",(xx + 15 - 420) / 30, (yy) / 30);
                    who = (who - 1) ? 1 : 2;
                }
            }
            save_cursor(fb,xx,yy,cursor_save);
            draw_cursor(fb,xx,yy,cursor_16_25);
        }
        usleep(100);
    }
}
예제 #15
0
void simulate(node **head, int step, int duration, date_time *time_stamp) {
    FILE *log = fopen(log_file, "w");
    fclose(log);
    int elapsed = 0;
    while (elapsed <= duration) {
        update_all(head, step, *time_stamp);
        check_all(head, *time_stamp);
        remove_node(head);
        elapsed = elapsed + step;
        update_time(step, time_stamp);
    }
}
예제 #16
0
int
main (int argc, char *argv[])
{
  char *prog;

  set_program_name (argv[0]);

  if (argc != 2)
    {
      fprintf (stderr, "%s: need 1 argument\n", argv[0]);
      return 2;
    }
  prog = argv[1];

#ifdef WINDOWS_NATIVE
  /* Make PROG suitable for native Windows system calls and cmd.exe:
     Replace '/' with '\\'.  */
  {
    char *p;
    for (p = prog; *p != '\0'; p++)
      if (*p == '/')
        *p = '\\';
  }
#endif

#ifdef WINDOWS_NATIVE
  check_all (SCI_SYSTEM, true, prog); /* equivalent to SCI_WINDOWS_CMD */
  check_all (SCI_WINDOWS_CREATEPROCESS, false, prog);
  check_all (SCI_WINDOWS_CMD, true, prog);
#else
  check_all (SCI_SYSTEM, false, prog); /* equivalent to SCI_POSIX_SH */
#endif

  /* Clean up.  */
  unlink (EXPECTED_DATA_FILE);

  return failed;
}
예제 #17
0
void main(void)
{
  conditioninit();
  check_all();
  /*
  check_size(7);
  check_size(17);
  check_size(20);
  check_size(21);
  check_size(37);
  check_size(78);
  */
  //conditionshow();
}
/*
 *  Function: solve sudoku
 *  This is the 'heart'  of the program. solve_sudoku is a recursive function
 *  which solves the given sudoku.
 *  Imput arguments: 
 *   int *problem : pointer where the sudoku is stored
 *  Return:
 *   1 if there is an error
 *   0 otherwise
 */
int solve_sudoku(int *problem)
{
  int *ptr;
  int i=0;
  ptr=problem;
  int solve=1;
  // Looking for first non-zero (i.e. blank) character
  while((*ptr!=0))
    {
      ptr++;
      i++;
      //If we are in the last cell, return Ok!
      if (i==82)
	{
	  return 0;
	}
    }
  // We write the first valid number in that position
  (*ptr)=1;
  while(check_all(problem)!=0)
    {
      (*ptr)++;
      if ((*ptr)==10)
	{
	  // If there is not a valid number, we write a 0 and return an error
	  (*ptr)=0;
	  return 1;
	}
    }
  // If there is a number, we call the function solve_sudoku with the new sudoku.
  solve=solve_sudoku(problem);  
  // If we are returned a '1' (problem!) we increment the cell and call the function again.
  // If we can't increment the cell more, we write a 0 and return an error.
  while(solve==1)
    {

      (*ptr)++;

      if ((*ptr)==10)
	{
	  (*ptr)=0;
	  return 1;
	}
      solve=solve_sudoku(problem);
    }
  
  // If we reach this instruction, all is good.
  return 0;
}
예제 #19
0
int recv_msg(void)
{

    int i = 0,j = 0;
    server_len = sizeof(server);

    recvfrom(client_sock, buffer, BUFFER_SIZE, 0, (struct sockaddr *)&server, &server_len);
    memcpy((char*)&i,(char *)&buffer[4],4);
    memcpy((char*)&j,(char *)&buffer[8],4);

    printf("%d %d\n",i,j);
    fb_circle(X_BEGUN+i*SIZE, Y_BEGUN+j*SIZE, 12, 0xffffffff);
    board[i+j*V_NUM]  = 2;

    check_all();
    return 0;
}
void
check_data (void)
{
  static const struct {
    const char  *x;
    const char  *y;
    const char  *want_add;
    const char  *want_sub;

  } data[] = {

    { "0", "0", "0", "0" },
    { "1", "0", "1", "1" },
    { "1", "1", "2", "0" },

    { "1/2", "1/2", "1", "0" },
    { "5/6", "14/15", "53/30", "-1/10" },
  };

  mpq_t  x, y, want_add, want_sub;
  int i;

  mpq_init (x);
  mpq_init (y);
  mpq_init (want_add);
  mpq_init (want_sub);

  for (i = 0; i < numberof (data); i++)
    {
      mpq_set_str_or_abort (x, data[i].x, 0);
      mpq_set_str_or_abort (y, data[i].y, 0);
      mpq_set_str_or_abort (want_add, data[i].want_add, 0);
      mpq_set_str_or_abort (want_sub, data[i].want_sub, 0);

      check_all (x, y, want_add, want_sub);
    }

  mpq_clear (x);
  mpq_clear (y);
  mpq_clear (want_add);
  mpq_clear (want_sub);
}
예제 #21
0
파일: check.c 프로젝트: Otatsumi/sudoku
int		get_value(int x, int y, char **map)
{
  int		i;
  int		correct_value;

  i = '1';
  correct_value = 0;
  while (i <= '9')
    {
      if (check_all(x, y, i, map) == 1)
	{
	  if (correct_value != 0)
	    return (MORE);
	  else
	    correct_value = i;
	}
      ++i;
    }
  return (correct_value - 48);
}
예제 #22
0
int
main (int argc, char **argv)
{
  int debug = 0;

  if (argc > 1 && !strcmp (argv[1], "--verbose"))
    verbose = 1;
  else if (argc > 1 && !strcmp (argv[1], "--debug"))
    verbose = debug = 1;

  if (!gcry_check_version (GCRYPT_VERSION))
    die ("version mismatch\n");

  gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
  gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
  if (debug)
    gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0);
  check_all ();

  return error_count ? 1 : 0;
}
예제 #23
0
파일: t-div_2exp.c 프로젝트: AllardJ/Tomato
void
check_various (void)
{
  static const unsigned long  table[] = {
    0, 1, 2, 3, 4, 5,
    GMP_NUMB_BITS-1, GMP_NUMB_BITS, GMP_NUMB_BITS+1,
    2*GMP_NUMB_BITS-1, 2*GMP_NUMB_BITS, 2*GMP_NUMB_BITS+1,
    3*GMP_NUMB_BITS-1, 3*GMP_NUMB_BITS, 3*GMP_NUMB_BITS+1,
    4*GMP_NUMB_BITS-1, 4*GMP_NUMB_BITS, 4*GMP_NUMB_BITS+1
  };

  int            i, j;
  unsigned long  n, d;
  mpz_t          a;

  mpz_init (a);

  /* a==0, and various d */
  mpz_set_ui (a, 0L);
  for (i = 0; i < numberof (table); i++)
    check_one (a, table[i]);

  /* a==2^n, and various d */
  for (i = 0; i < numberof (table); i++)
    {
      n = table[i];
      mpz_set_ui (a, 1L);
      mpz_mul_2exp (a, a, n);

      for (j = 0; j < numberof (table); j++)
	{
	  d = table[j];
	  check_all (a, d);
	}
    }

  mpz_clear (a);
}
예제 #24
0
파일: main.c 프로젝트: Oussamazz/MY-fillit
int		main(int ac, char **av)
{
	int			fd;
	int			size;
	char		*line;
	t_tetris	*tr;

	size = 0;
	tr = NULL;
	if (ac != 2)
	{
		ft_putendl_fd("usage: ./fillit file", 1);
		exit(EXIT_SUCCESS);
	}
	fd = open(av[1], O_RDONLY);
	if (fd < 0)
		exit_error();
	line = read_file(fd);
	check_all(line);
	tr = get_all_tetri(line);
	size = ft_sqrt(count_tetri(line) * 4);
	solve(size, tr);
	return (0);
}
예제 #25
0
void recv_msg(void)
{
  
    client_len = sizeof(client);
    len = recvfrom(server_sock, buffer, BUFFER_SIZE, 0, (struct sockaddr *)&client, &client_len);
    if (len >= 0)
    {
       cx = p->x;
       cy = p->y;
       board[cx+cy*P_NUM] = 2;

       printf("%d\n",cx);
       printf("%d\n",cy);

       cx = (cx)*SIZE + X_BEGUN;    
       cy = (cy)*SIZE + Y_BEGUN;    

       color_choice = 0x01000000;  

       fb_circle(cx,cy, 12, 0xffffffff);
       check_all();
    }
    
}
예제 #26
0
 void
 Receiver_exec_i::test_all ()
 {
   const char * test = "GET ALL";
   try
     {
       get_all ();
       test = "READ ALL";
       read_all ();
       // reading all samples on a different port.
        check_all ();
     }
   catch (const CCM_DDS::NonExistent& ex)
     {
       for (CORBA::ULong i = 0; i < ex.indexes.length (); ++i)
         {
           ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ERROR %C: ")
                 ACE_TEXT ("caught expected exception: index <%u>\n"),
                 test,
                 ex.indexes[i]));
         }
     }
   catch (const CCM_DDS::InternalError& ex)
     {
       ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR: %C: ")
             ACE_TEXT ("caught InternalError exception: retval <%u>\n"),
             test,
             ex.error_code));
     }
   catch (const ::CORBA::Exception& ex)
     {
       ex._tao_print_exception (test);
       ACE_ERROR ((LM_ERROR,
         ACE_TEXT ("ERROR: Receiver_exec_i::test_all : Exception caught\n")));
     }
 }
예제 #27
0
int
main (int argc, char *argv[])
{
  gl_oset_t set1, set2;

  /* Allow the user to provide a non-default random seed on the command line.  */
  if (argc > 1)
    srand (atoi (argv[1]));

  {
    size_t initial_size = RANDOM (20);
    size_t i;
    unsigned int repeat;

    /* Create set1.  */
    set1 = gl_oset_create_empty (GL_ARRAY_OSET, (gl_setelement_compar_fn) strcmp, NULL);

    /* Create set2.  */
    set2 = gl_oset_create_empty (GL_AVLTREE_OSET, (gl_setelement_compar_fn) strcmp, NULL);

    check_all (set1, set2);

    /* Initialize them.  */
    for (i = 0; i < initial_size; i++)
      {
        const char *obj = RANDOM_OBJECT ();
        ASSERT (gl_oset_add (set1, obj) == gl_oset_add (set2, obj));
        check_all (set1, set2);
      }

    for (repeat = 0; repeat < 100000; repeat++)
      {
        unsigned int operation = RANDOM (3);
        switch (operation)
          {
          case 0:
            {
              const char *obj = RANDOM_OBJECT ();
              ASSERT (gl_oset_search (set1, obj) == gl_oset_search (set2, obj));
            }
            break;
          case 1:
            {
              const char *obj = RANDOM_OBJECT ();
              ASSERT (gl_oset_add (set1, obj) == gl_oset_add (set2, obj));
            }
            break;
          case 2:
            {
              const char *obj = RANDOM_OBJECT ();
              ASSERT (gl_oset_remove (set1, obj) == gl_oset_remove (set2, obj));
            }
            break;
          }
        check_all (set1, set2);
      }

    gl_oset_free (set1);
    gl_oset_free (set2);
  }

  return 0;
}
예제 #28
0
파일: fsck.c 프로젝트: emuikernel/WNR2000v4
int fsck_main(int argc, char *argv[])
{
	int i, status = 0;
	int interactive = 0;
	const char *fstab;
	struct fs_info *fs;

	setvbuf(stdout, NULL, _IONBF, BUFSIZ);
	setvbuf(stderr, NULL, _IONBF, BUFSIZ);

	blkid_get_cache(&cache, NULL);
	PRS(argc, argv);

	if (!notitle)
		printf("fsck %s (%s)\n", E2FSPROGS_VERSION, E2FSPROGS_DATE);

	fstab = getenv("FSTAB_FILE");
	if (!fstab)
		fstab = _PATH_MNTTAB;
	load_fs_info(fstab);

	fsck_path = e2fs_set_sbin_path();

	if ((num_devices == 1) || (serialize))
		interactive = 1;

	/* If -A was specified ("check all"), do that! */
	if (doall)
		return check_all();

	if (num_devices == 0) {
		serialize++;
		interactive++;
		return check_all();
	}
	for (i = 0 ; i < num_devices; i++) {
		if (cancel_requested) {
			if (!kill_sent) {
				kill_all(SIGTERM);
				kill_sent++;
			}
			break;
		}
		fs = lookup(devices[i]);
		if (!fs) {
			fs = create_fs_device(devices[i], 0, "auto",
					      0, -1, -1);
			if (!fs)
				continue;
		}
		fsck_device(fs, interactive);
		if (serialize ||
		    (max_running && (num_running >= max_running))) {
			struct fsck_instance *inst;

			inst = wait_one(0);
			if (inst) {
				status |= inst->exit_status;
				free_instance(inst);
			}
			if (verbose > 1)
				printf("----------------------------------\n");
		}
	}
	status |= wait_many(FLAG_WAIT_ALL);
	blkid_put_cache(cache);
	return status;
}
예제 #29
0
int main(int argc, char *argv[])
{
	int i;
	int status = 0;
	int interactive = 0;
	char *oldpath = getenv("PATH");
	const char *fstab;

#ifdef ENABLE_NLS
	setlocale(LC_MESSAGES, "");
	setlocale(LC_CTYPE, "");
	bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
	textdomain(NLS_CAT_NAME);
#endif
	PRS(argc, argv);

	if (!notitle)
		printf("fsck %s (%s)\n", E2FSPROGS_VERSION, E2FSPROGS_DATE);

	fstab = getenv("FSTAB_FILE");
	if (!fstab)
		fstab = _PATH_MNTTAB;
	load_fs_info(fstab);

	/* Update our search path to include uncommon directories. */
	if (oldpath) {
		fsck_path = malloc (strlen (fsck_prefix_path) + 1 +
				    strlen (oldpath) + 1);
		strcpy (fsck_path, fsck_prefix_path);
		strcat (fsck_path, ":");
		strcat (fsck_path, oldpath);
	} else {
		fsck_path = string_copy(fsck_prefix_path);
	}
	
	if ((num_devices == 1) || (serialize))
		interactive = 1;

	/* If -A was specified ("check all"), do that! */
	if (doall)
		return check_all();

	if (num_devices == 0) {
		serialize++;
		interactive++;
		return check_all();
	}
	for (i = 0 ; i < num_devices; i++) {
		if (cancel_requested) {
			if (!kill_sent) {
				kill_all(SIGTERM);
				kill_sent++;
			}
			break;
		}
		fsck_device(devices[i], interactive);
		if (serialize ||
		    (max_running && (num_running >= max_running))) {
			struct fsck_instance *inst;

			inst = wait_one(0);
			if (inst) {
				status |= inst->exit_status;
				free_instance(inst);
			}
			if (verbose > 1) 
				printf("----------------------------------\n");
		}
	}
	status |= wait_all(0);
	free(fsck_path);
	return status;
}
예제 #30
0
tracking_window::tracking_window(QWidget *parent,ODFModel* new_handle,bool handle_release_) :
        QMainWindow(parent),handle(new_handle),handle_release(handle_release_),
        ui(new Ui::tracking_window),scene(*this,new_handle),slice(new_handle)

{

    ODFModel* odf_model = (ODFModel*)handle;
    FibData& fib_data = odf_model->fib_data;

    odf_size = fib_data.fib.odf_table.size();
    odf_face_size = fib_data.fib.odf_faces.size();
    has_odfs = fib_data.fib.has_odfs() ? 1:0;
    // check whether first index is "fa0"
    is_dti = (fib_data.view_item[0].name[0] == 'f');

    ui->setupUi(this);
    {
        setGeometry(10,10,800,600);

        ui->regionDockWidget->setMinimumWidth(0);
        ui->dockWidget->setMinimumWidth(0);
        ui->dockWidget_3->setMinimumWidth(0);
        ui->renderingLayout->addWidget(renderWidget = new RenderingTableWidget(*this,ui->renderingWidgetHolder,has_odfs));
        ui->centralLayout->insertWidget(1,glWidget = new GLWidget(renderWidget->getData("anti_aliasing").toInt(),
                                                                  *this,renderWidget,ui->centralwidget));
        ui->verticalLayout_3->addWidget(regionWidget = new RegionTableWidget(*this,ui->regionDockWidget));
        ui->tractverticalLayout->addWidget(tractWidget = new TractTableWidget(*this,ui->TractWidgetHolder));
        ui->graphicsView->setScene(&scene);
        ui->graphicsView->setCursor(Qt::CrossCursor);
        scene.statusbar = ui->statusbar;
        color_bar.reset(new color_bar_dialog(this));
    }

    // setup fa threshold
    {
        for(int index = 0;index < fib_data.fib.index_name.size();++index)
            ui->tracking_index->addItem((fib_data.fib.index_name[index]+" threshold").c_str());
        ui->tracking_index->setCurrentIndex(0);
        ui->step_size->setValue(fib_data.vs[0]/2.0);
    }

    // setup sliders
    {
        slice_no_update = true;
        ui->SagSlider->setRange(0,slice.geometry[0]-1);
        ui->CorSlider->setRange(0,slice.geometry[1]-1);
        ui->AxiSlider->setRange(0,slice.geometry[2]-1);
        ui->SagSlider->setValue(slice.slice_pos[0]);
        ui->CorSlider->setValue(slice.slice_pos[1]);
        ui->AxiSlider->setValue(slice.slice_pos[2]);

        ui->glSagBox->setRange(0,slice.geometry[0]-1);
        ui->glCorBox->setRange(0,slice.geometry[1]-1);
        ui->glAxiBox->setRange(0,slice.geometry[2]-1);
        ui->glSagBox->setValue(slice.slice_pos[0]);
        ui->glCorBox->setValue(slice.slice_pos[1]);
        ui->glAxiBox->setValue(slice.slice_pos[2]);
        slice_no_update = false;
        on_SliceModality_currentIndexChanged(0);

        for (unsigned int index = 0;index < fib_data.view_item.size(); ++index)
        {
            ui->sliceViewBox->addItem(fib_data.view_item[index].name.c_str());
            if(fib_data.view_item[index].is_overlay)
                ui->overlay->addItem(fib_data.view_item[index].name.c_str());
        }
        ui->sliceViewBox->setCurrentIndex(0);
        ui->overlay->setCurrentIndex(0);
        if(ui->overlay->count() == 1)
           ui->overlay->hide();
    }

    is_qsdr = !handle->fib_data.trans_to_mni.empty();

    // setup atlas
    if(!fa_template_imp.I.empty() && fib_data.vs[0] > 0.5 && !is_qsdr)
    {
        mi3_arg.scaling[0] = slice.voxel_size[0] / std::fabs(fa_template_imp.tran[0]);
        mi3_arg.scaling[1] = slice.voxel_size[1] / std::fabs(fa_template_imp.tran[5]);
        mi3_arg.scaling[2] = slice.voxel_size[2] / std::fabs(fa_template_imp.tran[10]);
        image::reg::align_center(slice.source_images,fa_template_imp.I,mi3_arg);
        mi3.reset(new manual_alignment(this,slice.source_images,fa_template_imp.I,mi3_arg));
        is_qsdr = false;
    }
    else
        ui->actionManual_Registration->setEnabled(false);
    ui->actionConnectometry->setEnabled(handle->fib_data.fib.has_odfs() && is_qsdr);
    for(int index = 0;index < atlas_list.size();++index)
        ui->atlasListBox->addItem(atlas_list[index].name.c_str());


    {
        if(is_dti)
            ui->actionQuantitative_anisotropy_QA->setText("Save FA...");
        for (int index = fib_data.other_mapping_index; index < fib_data.view_item.size(); ++index)
            {
                std::string& name = fib_data.view_item[index].name;
                QAction* Item = new QAction(this);
                Item->setText(QString("Save %1...").arg(name.c_str()));
                Item->setData(QString(name.c_str()));
                Item->setVisible(true);
                connect(Item, SIGNAL(triggered()),tractWidget, SLOT(save_tracts_data_as()));
                ui->menuSave->addAction(Item);
            }
    }

    // opengl
    {
        connect(renderWidget->treemodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
                glWidget,SLOT(updateGL()));
        connect(ui->tbDefaultParam,SIGNAL(clicked()),renderWidget,SLOT(setDefault()));
        connect(ui->tbDefaultParam,SIGNAL(clicked()),glWidget,SLOT(updateGL()));

        connect(ui->glSagSlider,SIGNAL(valueChanged(int)),this,SLOT(glSliderValueChanged()));
        connect(ui->glCorSlider,SIGNAL(valueChanged(int)),this,SLOT(glSliderValueChanged()));
        connect(ui->glAxiSlider,SIGNAL(valueChanged(int)),this,SLOT(glSliderValueChanged()));

        connect(ui->glSagCheck,SIGNAL(stateChanged(int)),glWidget,SLOT(updateGL()));
        connect(ui->glCorCheck,SIGNAL(stateChanged(int)),glWidget,SLOT(updateGL()));
        connect(ui->glAxiCheck,SIGNAL(stateChanged(int)),glWidget,SLOT(updateGL()));

        connect(ui->glSagView,SIGNAL(clicked()),this,SLOT(on_SagView_clicked()));
        connect(ui->glCorView,SIGNAL(clicked()),this,SLOT(on_CorView_clicked()));
        connect(ui->glAxiView,SIGNAL(clicked()),this,SLOT(on_AxiView_clicked()));

        connect(ui->addSlices,SIGNAL(clicked()),this,SLOT(on_actionInsert_T1_T2_triggered()));
        connect(ui->actionAdd_surface,SIGNAL(triggered()),glWidget,SLOT(addSurface()));
        connect(ui->SliceModality,SIGNAL(currentIndexChanged(int)),glWidget,SLOT(updateGL()));
        connect(ui->actionSave_Screen,SIGNAL(triggered()),glWidget,SLOT(catchScreen()));
        connect(ui->actionSave_3D_screen_in_high_resolution,SIGNAL(triggered()),glWidget,SLOT(catchScreen2()));
        connect(ui->actionLoad_Camera,SIGNAL(triggered()),glWidget,SLOT(loadCamera()));
        connect(ui->actionSave_Camera,SIGNAL(triggered()),glWidget,SLOT(saveCamera()));
        connect(ui->actionLoad_mapping,SIGNAL(triggered()),glWidget,SLOT(loadMapping()));
        connect(ui->actionSave_mapping,SIGNAL(triggered()),glWidget,SLOT(saveMapping()));
        connect(ui->actionSave_Rotation_Images,SIGNAL(triggered()),glWidget,SLOT(saveRotationSeries()));
        connect(ui->actionSave_Left_Right_3D_Image,SIGNAL(triggered()),glWidget,SLOT(saveLeftRight3DImage()));
    }
    // scene view
    {
        connect(ui->SagSlider,SIGNAL(valueChanged(int)),this,SLOT(SliderValueChanged()));
        connect(ui->CorSlider,SIGNAL(valueChanged(int)),this,SLOT(SliderValueChanged()));
        connect(ui->AxiSlider,SIGNAL(valueChanged(int)),this,SLOT(SliderValueChanged()));


        connect(&scene,SIGNAL(need_update()),&scene,SLOT(show_slice()));
        connect(&scene,SIGNAL(need_update()),glWidget,SLOT(updateGL()));
        connect(ui->fa_threshold,SIGNAL(valueChanged(double)),&scene,SLOT(show_slice()));
        connect(ui->contrast,SIGNAL(valueChanged(int)),&scene,SLOT(show_slice()));
        connect(ui->offset,SIGNAL(valueChanged(int)),&scene,SLOT(show_slice()));
        connect(ui->show_fiber,SIGNAL(clicked()),&scene,SLOT(show_slice()));
        connect(ui->show_pos,SIGNAL(clicked()),&scene,SLOT(show_slice()));
        connect(ui->show_lr,SIGNAL(clicked()),&scene,SLOT(show_slice()));

        connect(ui->zoom,SIGNAL(valueChanged(double)),&scene,SLOT(show_slice()));
        connect(ui->zoom,SIGNAL(valueChanged(double)),&scene,SLOT(center()));


        connect(ui->actionAxial_View,SIGNAL(triggered()),this,SLOT(on_AxiView_clicked()));
        connect(ui->actionCoronal_View,SIGNAL(triggered()),this,SLOT(on_CorView_clicked()));
        connect(ui->actionSagittal_view,SIGNAL(triggered()),this,SLOT(on_SagView_clicked()));


        connect(ui->actionSave_ROI_Screen,SIGNAL(triggered()),&scene,SLOT(catch_screen()));

        connect(ui->actionSave_Anisotrpy_Map_as,SIGNAL(triggered()),&scene,SLOT(save_slice_as()));


        connect(ui->overlay,SIGNAL(currentIndexChanged(int)),this,SLOT(on_sliceViewBox_currentIndexChanged(int)));

    }

    // regions
    {

        connect(regionWidget,SIGNAL(need_update()),&scene,SLOT(show_slice()));
        connect(regionWidget,SIGNAL(need_update()),glWidget,SLOT(updateGL()));



        connect(ui->whole_brain,SIGNAL(clicked()),regionWidget,SLOT(whole_brain()));

        connect(ui->view_style,SIGNAL(currentIndexChanged(int)),&scene,SLOT(show_slice()));

        //atlas
        connect(ui->addRegionFromAtlas,SIGNAL(clicked()),regionWidget,SLOT(add_atlas()));


        connect(ui->actionNewRegion,SIGNAL(triggered()),regionWidget,SLOT(new_region()));
        connect(ui->actionOpenRegion,SIGNAL(triggered()),regionWidget,SLOT(load_region()));
        connect(ui->actionSaveRegionAs,SIGNAL(triggered()),regionWidget,SLOT(save_region()));
        connect(ui->actionSave_Voxel_Data_As,SIGNAL(triggered()),regionWidget,SLOT(save_region_info()));
        connect(ui->actionDeleteRegion,SIGNAL(triggered()),regionWidget,SLOT(delete_region()));
        connect(ui->actionDeleteRegionAll,SIGNAL(triggered()),regionWidget,SLOT(delete_all_region()));


        // actions
        connect(ui->actionShift_X,SIGNAL(triggered()),regionWidget,SLOT(action_shiftx()));
        connect(ui->actionShift_X_2,SIGNAL(triggered()),regionWidget,SLOT(action_shiftnx()));
        connect(ui->actionShift_Y,SIGNAL(triggered()),regionWidget,SLOT(action_shifty()));
        connect(ui->actionShift_Y_2,SIGNAL(triggered()),regionWidget,SLOT(action_shiftny()));
        connect(ui->actionShift_Z,SIGNAL(triggered()),regionWidget,SLOT(action_shiftz()));
        connect(ui->actionShift_Z_2,SIGNAL(triggered()),regionWidget,SLOT(action_shiftnz()));

        connect(ui->actionFlip_X,SIGNAL(triggered()),regionWidget,SLOT(action_flipx()));
        connect(ui->actionFlip_Y,SIGNAL(triggered()),regionWidget,SLOT(action_flipy()));
        connect(ui->actionFlip_Z,SIGNAL(triggered()),regionWidget,SLOT(action_flipz()));

        connect(ui->actionThreshold,SIGNAL(triggered()),regionWidget,SLOT(action_threshold()));



        connect(ui->actionSmoothing,SIGNAL(triggered()),regionWidget,SLOT(action_smoothing()));
        connect(ui->actionErosion,SIGNAL(triggered()),regionWidget,SLOT(action_erosion()));
        connect(ui->actionDilation,SIGNAL(triggered()),regionWidget,SLOT(action_dilation()));
        connect(ui->actionNegate,SIGNAL(triggered()),regionWidget,SLOT(action_negate()));
        connect(ui->actionDefragment,SIGNAL(triggered()),regionWidget,SLOT(action_defragment()));

        connect(ui->actionCheck_all_regions,SIGNAL(triggered()),regionWidget,SLOT(check_all()));
        connect(ui->actionUnckech_all_regions,SIGNAL(triggered()),regionWidget,SLOT(uncheck_all()));

        connect(ui->actionWhole_brain_seeding,SIGNAL(triggered()),regionWidget,SLOT(whole_brain()));
        connect(ui->actionRegion_statistics,SIGNAL(triggered()),regionWidget,SLOT(show_statistics()));


    }
    // tracts
    {
        connect(ui->perform_tracking,SIGNAL(clicked()),tractWidget,SLOT(start_tracking()));
        connect(ui->stopTracking,SIGNAL(clicked()),tractWidget,SLOT(stop_tracking()));

        connect(tractWidget,SIGNAL(need_update()),glWidget,SLOT(makeTracts()));
        connect(tractWidget,SIGNAL(need_update()),glWidget,SLOT(updateGL()));

        connect(glWidget,SIGNAL(edited()),tractWidget,SLOT(edit_tracts()));
        connect(glWidget,SIGNAL(region_edited()),glWidget,SLOT(updateGL()));
        connect(glWidget,SIGNAL(region_edited()),&scene,SLOT(show_slice()));

        connect(ui->actionOpenTract,SIGNAL(triggered()),tractWidget,SLOT(load_tracts()));
        connect(ui->actionMerge_All,SIGNAL(triggered()),tractWidget,SLOT(merge_all()));
        connect(ui->actionCopyTrack,SIGNAL(triggered()),tractWidget,SLOT(copy_track()));
        connect(ui->actionDeleteTract,SIGNAL(triggered()),tractWidget,SLOT(delete_tract()));
        connect(ui->actionDeleteTractAll,SIGNAL(triggered()),tractWidget,SLOT(delete_all_tract()));

        connect(ui->actionOpen_Colors,SIGNAL(triggered()),tractWidget,SLOT(load_tracts_color()));
        connect(ui->actionSave_Tracts_Colors_As,SIGNAL(triggered()),tractWidget,SLOT(save_tracts_color_as()));

        connect(ui->actionUndo,SIGNAL(triggered()),tractWidget,SLOT(undo_tracts()));
        connect(ui->actionRedo,SIGNAL(triggered()),tractWidget,SLOT(redo_tracts()));
        connect(ui->actionTrim,SIGNAL(triggered()),tractWidget,SLOT(trim_tracts()));

        connect(ui->actionSet_Color,SIGNAL(triggered()),tractWidget,SLOT(set_color()));

        connect(ui->actionK_means,SIGNAL(triggered()),tractWidget,SLOT(clustering_kmeans()));
        connect(ui->actionEM,SIGNAL(triggered()),tractWidget,SLOT(clustering_EM()));
        connect(ui->actionHierarchical,SIGNAL(triggered()),tractWidget,SLOT(clustering_hie()));
        connect(ui->actionOpen_Cluster_Labels,SIGNAL(triggered()),tractWidget,SLOT(open_cluster_label()));

        //setup menu
        connect(ui->actionSaveTractAs,SIGNAL(triggered()),tractWidget,SLOT(save_tracts_as()));
        connect(ui->actionSave_All_Tracts_As,SIGNAL(triggered()),tractWidget,SLOT(save_all_tracts_as()));
        connect(ui->actionQuantitative_anisotropy_QA,SIGNAL(triggered()),tractWidget,SLOT(save_fa_as()));
        connect(ui->actionSave_End_Points_As,SIGNAL(triggered()),tractWidget,SLOT(save_end_point_as()));
        connect(ui->actionStatistics,SIGNAL(triggered()),tractWidget,SLOT(show_tracts_statistics()));

        connect(ui->track_up,SIGNAL(clicked()),tractWidget,SLOT(move_up()));
        connect(ui->track_down,SIGNAL(clicked()),tractWidget,SLOT(move_down()));

    }




    // recall the setting
    {

        QSettings settings;
        if(!default_geo.size())
            default_geo = saveGeometry();
        if(!default_state.size())
            default_state = saveState();
        restoreGeometry(settings.value("geometry").toByteArray());
        restoreState(settings.value("state").toByteArray());
        ui->turning_angle->setValue(settings.value("turning_angle",60).toDouble());
        ui->smoothing->setValue(settings.value("smoothing",0.0).toDouble());
        ui->min_length->setValue(settings.value("min_length",0.0).toDouble());
        ui->max_length->setValue(settings.value("max_length",500).toDouble());
        ui->tracking_method->setCurrentIndex(settings.value("tracking_method",0).toInt());
        ui->seed_plan->setCurrentIndex(settings.value("seed_plan",0).toInt());
        ui->initial_direction->setCurrentIndex(settings.value("initial_direction",0).toInt());
        ui->interpolation->setCurrentIndex(settings.value("interpolation",0).toInt());
        ui->tracking_plan->setCurrentIndex(settings.value("tracking_plan",0).toInt());
        ui->track_count->setValue(settings.value("track_count",2000).toInt());
        ui->thread_count->setCurrentIndex(settings.value("thread_count",0).toInt());

        ui->glSagCheck->setChecked(settings.value("SagSlice",1).toBool());
        ui->glCorCheck->setChecked(settings.value("CorSlice",1).toBool());
        ui->glAxiCheck->setChecked(settings.value("AxiSlice",1).toBool());
        ui->RenderingQualityBox->setCurrentIndex(settings.value("RenderingQuality",1).toInt());

        ui->view_style->setCurrentIndex((settings.value("view_style",0).toInt()));
        ui->RAS->setChecked(settings.value("RAS",0).toBool());
    }

    {
        scene.center();
        slice_no_update = false;
        copy_target = 0;
    }

    on_glAxiView_clicked();
    if(scene.neurology_convention)
        on_glAxiView_clicked();
    qApp->installEventFilter(this);
}