int main( int argc, char *argv[] )
{
    int         i, j;
    int         d[N];
    
    //srand
    srand((unsigned) time(NULL));
    
    // set data
    for (i = 0; i < N; i++ )
        d[i] = rand() % 10;
    
    // show
/*
    printf("     ");
    for (i = 0; i < N; i++)
        printf("%2d", i);
    printf("\n");
*/
    
    show_data(d, N);
    
    ssort(d, N);

    show_data(d, N);
    
    return 0;
}//int main( int argc, char *argv[] )
Beispiel #2
0
void 
show_data(BTREE *root)
{
    if (root != NULL)
    {
        show_data(root->lchild);
        printf("%d  ", *(const int *)&root->pdata);
        show_data(root->rchild);
    }
}
Beispiel #3
0
static void __show_extra_register_data(struct pt_regs *regs, int nbytes)
{
	mm_segment_t fs;
	unsigned long sp;

	if (user_mode_vm(regs))
		sp = regs->sp;
	else
		sp = kernel_stack_pointer(regs);

	fs = get_fs();
	set_fs(KERNEL_DS);

	show_data(regs->ip - nbytes, nbytes * 2, "EIP");
	show_data(regs->ax - nbytes, nbytes * 2, "EAX");
	show_data(regs->bx - nbytes, nbytes * 2, "EBX");
	show_data(regs->cx - nbytes, nbytes * 2, "ECX");
	show_data(regs->dx - nbytes, nbytes * 2, "EDX");
	show_data(regs->si - nbytes, nbytes * 2, "ESI");
	show_data(regs->di - nbytes, nbytes * 2, "EDI");
	show_data(regs->bp - nbytes, nbytes * 2, "EBP");
	show_data(sp - nbytes, nbytes * 2, "ESP");

	set_fs(fs);
}
Beispiel #4
0
void got_packet (u_char *args, const struct pcap_pkthdr *header, const u_char *packet) {
	static int count = 1;
	int etype=0, protocol=0;
	int size_ip, size_tcp, size_total;
	const struct sniff_ethernet * ethernet;
	const struct sniff_ip * ip;
	const struct sniff_tcp *tcp;

	ethernet = (struct sniff_ethernet*)(packet);
	ip = (struct sniff_ip*)(packet + 14);
	size_ip = IP_HL(ip);
	tcp = (struct sniff_tcp*)(packet + 14 + size_ip);
	size_tcp = TH_OFF(tcp)*4;

	size_total = ntohs(ip->ip_len) + 14;

	printf("\ncount : %d\n", count);
	count++;

	printf("------------------------------\n");
	etype = show_addr(packet);
	if (etype == IPV4) {
		protocol = show_ipv4_ip(packet);
		
		if (protocol == TCP) {
			show_port(packet);

			if (size_total != (size_ip + size_tcp + 14)) {
				printf("------------------------------\n");

				show_data(args, header, packet, *(packet+size_total), size_total);

				printf("------------------------------\n");
			}
		} else if (protocol == UDP) {
			show_port(packet);
			printf("------------------------------\n");

			show_data(args, header, packet, 42, size_total);

			printf("------------------------------\n");
		}

		printf("------------------------------\n");
	} else if (etype == ARP) {
		show_ark_ip(packet);
	}
}
void *quick_sort(void *sort_data, int low, int high)
{
	int i,j,pivot;
	int *psd=(int *)sort_data;
	if(low<high){
		pivot=*(psd+low);
		i=low;
		j=high;
		while(i<j){
			while((i<j)&&pivot<*(psd+j))
				j--;
			if(i<j)
				*(psd+i++)=*(psd+j);
			while((i<j)&&pivot>*(psd+i))
				i++;
			if(i<j)
				*(psd+j--)=*(psd+i);
		}
		*(psd+i)=pivot;
		show_data(psd,dt_len);	//just for debug
		quick_sort(psd,low,i-1);
		quick_sort(psd,i+1,high);
	}

	return psd;
}
void *select_sort(void *sort_data, int sort_data_len)
{
	int *psd=sort_data;
	int sd_len=sort_data_len;
	int i=0,j=0;
	int tmp=0;
	int index=0;

	for(i=0; i<sd_len-1; i++){
		index=i;

		for(j=i+1; j<sd_len; j++){
			if(*(psd+index)>*(psd+j)){
				index=j;
			}
		}

		if(index!=i){
			tmp=*(psd+index);
			*(psd+index)=*(psd+i);
			*(psd+i)=tmp;
		}

		show_data(psd,sd_len);	//just for debug
	}

	return psd;
}
void *bubble_sort(void *sort_data, int sort_data_len)
{
	int *psd=(int *)sort_data;
	int sd_len=sort_data_len;
	int sort_finish_flag=1;
	int i=0;
	int j=0;
	int tmp_data=0;

	for(i=0; i<sd_len-1; i++){
		sort_finish_flag=1;
		for(j=0; j<sd_len-1-i; j++){
			if(*(psd+j)>*(psd+j+1)){
				tmp_data=*(psd+j);
				*(psd+j)=*(psd+j+1);
				*(psd+j+1)=tmp_data;
				sort_finish_flag=0;
			}
		}
		show_data(psd,sd_len);	//just for debug
		if(1==sort_finish_flag){
			break;
		}
	}

	return psd;
}
Beispiel #8
0
void aplist::get_ap_list()
{
    QDataStream in(&tcpSocket);
    quint8 type;
    quint8 request_type;
    char ssid_buf[512] = {0};
    in.setByteOrder(QDataStream::LittleEndian);
    in>>type>>request_type>>n_ap;
    if(type!=0x02)
    {
        tcpSocket.close();
        //error();
    }
    else if(type==0x02)
    {
        in.setByteOrder(QDataStream::LittleEndian);
        if(request_type==0x01)
        {
            for(int i=0;i<n_ap;i++)
            {
                in>>ap_li[i].ssid_len;
                in.readRawData(ssid_buf, ap_li[i].ssid_len);
                ssid_buf[ap_li[i].ssid_len] = '\0';
                ap_li[i].ssid = QString(ssid_buf);
                in>>ap_li[i].encrypt_type;
                in.readRawData((char *)ap_li[i].bssid, sizeof(ap_li[i].bssid));
            }
            show_data();
        }
    }
static int show_data_for_item(const void *blob, struct display_info *disp,
		int node, const char *property)
{
	const void *value = NULL;
	int len, err = 0;

	switch (disp->mode) {
	case MODE_LIST_PROPS:
		err = list_properties(blob, node);
		break;

	case MODE_LIST_SUBNODES:
		err = list_subnodes(blob, node);
		break;

	default:
		assert(property);
		value = fdt_getprop(blob, node, property, &len);
		if (value) {
			if (show_data(disp, value, len))
				err = -1;
			else
				printf("\n");
		} else if (disp->default_val) {
			puts(disp->default_val);
		} else {
			report_error(property, len);
			err = -1;
		}
		break;
	}

	return err;
}
Beispiel #10
0
void fakeap::get_fake_list()
{
    QDataStream in(&tcpSocket);
    quint8 type;
    quint8 request_type;
    char ssid_buf[512] = {0};
    in.setByteOrder(QDataStream::LittleEndian);
    in>>type>>request_type>>n_fake;
    n_fake = 1;
    ui->fake_num->display(n_fake);
    if(type!=0x02)
    {
        tcpSocket.close();
        //error();
    }
    else if(type==0x02)
    {
        in.setByteOrder(QDataStream::LittleEndian);
        if(request_type==0x02)
        {
            for(int i=0;i<n_fake;i++)
            {
                in>>fake_li[i].ssid_len;
                in.readRawData(ssid_buf, fake_li[i].ssid_len);
                ssid_buf[fake_li[i].ssid_len] = '\0';
                fake_li[i].ssid = QString(ssid_buf);
                in>>fake_li[i].encrypt_type;
                in.readRawData((char *)fake_li[i].bssid, sizeof(fake_li[i].bssid));
            }
            show_data();
        }
    }
Beispiel #11
0
void loop()
{
    if (AP_HAL::millis() < 5000) {
        show_timing();
    } else {
        show_data();
    }
}
Beispiel #12
0
void loop()
{
    if (hal.scheduler->millis() < 5000) {
        show_timing();
    } else {
        show_data();
    }
}
Beispiel #13
0
// リストをすべて表示
void show_all(){
	Bookdata *tail;

	puts("---");
	for(tail = booklist_head; tail != NULL; tail = tail->next){
		show_data(tail);
		puts("---");
	}
}
Beispiel #14
0
int main(void)
{ int i;
  const int nrows = 13;
  const int ncols = 4;
  double** data = malloc(nrows*sizeof(double*) );
  int** mask = malloc(nrows*sizeof(int*));
  double** distmatrix;

  for (i = 0; i < nrows; i++)
  { data[i] = malloc(ncols*sizeof(double));
    mask[i] = malloc(ncols*sizeof(int));
  }

  /* Test data, roughly distributed in 0-5, 6-8, 9-12 */
  data[ 0][ 0]=0.1; data[ 0][ 1]=0.0; data[ 0][ 2]=9.6; data[ 0][ 3] = 5.6;
  data[ 1][ 0]=1.4; data[ 1][ 1]=1.3; data[ 1][ 2]=0.0; data[ 1][ 3] = 3.8;
  data[ 2][ 0]=1.2; data[ 2][ 1]=2.5; data[ 2][ 2]=0.0; data[ 2][ 3] = 4.8;
  data[ 3][ 0]=2.3; data[ 3][ 1]=1.5; data[ 3][ 2]=9.2; data[ 3][ 3] = 4.3;
  data[ 4][ 0]=1.7; data[ 4][ 1]=0.7; data[ 4][ 2]=9.6; data[ 4][ 3] = 3.4;
  data[ 5][ 0]=0.0; data[ 5][ 1]=3.9; data[ 5][ 2]=9.8; data[ 5][ 3] = 5.1;
  data[ 6][ 0]=6.7; data[ 6][ 1]=3.9; data[ 6][ 2]=5.5; data[ 6][ 3] = 4.8;
  data[ 7][ 0]=0.0; data[ 7][ 1]=6.3; data[ 7][ 2]=5.7; data[ 7][ 3] = 4.3;
  data[ 8][ 0]=5.7; data[ 8][ 1]=6.9; data[ 8][ 2]=5.6; data[ 8][ 3] = 4.3;
  data[ 9][ 0]=0.0; data[ 9][ 1]=2.2; data[ 9][ 2]=5.4; data[ 9][ 3] = 0.0;
  data[10][ 0]=3.8; data[10][ 1]=3.5; data[10][ 2]=5.5; data[10][ 3] = 9.6;
  data[11][ 0]=0.0; data[11][ 1]=2.3; data[11][ 2]=3.6; data[11][ 3] = 8.5;
  data[12][ 0]=4.1; data[12][ 1]=4.5; data[12][ 2]=5.8; data[12][ 3] = 7.6;

  /* Some data are actually missing */
  mask[ 0][ 0]=1; mask[ 0][ 1]=1; mask[ 0][ 2]=1; mask[ 0][ 3] = 1;
  mask[ 1][ 0]=1; mask[ 1][ 1]=1; mask[ 1][ 2]=0; mask[ 1][ 3] = 1;
  mask[ 2][ 0]=1; mask[ 2][ 1]=1; mask[ 2][ 2]=0; mask[ 2][ 3] = 1;
  mask[ 3][ 0]=1; mask[ 3][ 1]=1; mask[ 3][ 2]=1; mask[ 3][ 3] = 1;
  mask[ 4][ 0]=1; mask[ 4][ 1]=1; mask[ 4][ 2]=1; mask[ 4][ 3] = 1;
  mask[ 5][ 0]=0; mask[ 5][ 1]=1; mask[ 5][ 2]=1; mask[ 5][ 3] = 1;
  mask[ 6][ 0]=1; mask[ 6][ 1]=1; mask[ 6][ 2]=1; mask[ 6][ 3] = 1;
  mask[ 7][ 0]=0; mask[ 7][ 1]=1; mask[ 7][ 2]=1; mask[ 7][ 3] = 1;
  mask[ 8][ 0]=1; mask[ 8][ 1]=1; mask[ 8][ 2]=1; mask[ 8][ 3] = 1;
  mask[ 9][ 0]=1; mask[ 9][ 1]=1; mask[ 9][ 2]=1; mask[ 9][ 3] = 0;
  mask[10][ 0]=1; mask[10][ 1]=1; mask[10][ 2]=1; mask[10][ 3] = 1;
  mask[11][ 0]=0; mask[11][ 1]=1; mask[11][ 2]=1; mask[11][ 3] = 1;
  mask[12][ 0]=1; mask[12][ 1]=1; mask[12][ 2]=1; mask[12][ 3] = 1;

  show_data(nrows, ncols, data, mask);
  example_mean_median(nrows, ncols, data, mask);
  distmatrix = example_distance_gene(nrows, ncols, data, mask);
  if (distmatrix) example_hierarchical(nrows, ncols, data, mask, distmatrix);
  example_distance_array(nrows, ncols, data, mask);
  example_kmeans(nrows, ncols, data, mask);
  example_som(nrows, ncols, data, mask);

  return 0;
}
Beispiel #15
0
void clean_thread(void)
{
    long i;
    show_data();
    for (i=0 ; i<MAX_THREAD; i++) {
        long reader = reader_bitmap & 1<<i;
        if(thread[i]) {
            printk("thread %ld exit....%s\n", i, reader?"reader":"writer");
            kthread_stop(thread[i]);
        }
    }

}
Beispiel #16
0
/* Test sort function.  Optionally compare results to library version.
   If comp_ptr non-NULL, set it to the number of comparisons
   Return number of seconds */
static double run_test(sort_fun_t sfun, size_t nele, int check,
		       size_t *comp_ptr) {
  /* Generate data */
  double t;
  int ncpy = check ? 3 : 2;
  gen_data(ncpy, nele);
  if (verbose >= 2) {
    printf("Initial data:");
    show_data(data[0], nele);
  }
  start_timer();
  comp_cnt = 0;
  sfun(data[0], nele, data[1]);
  t = elapsed_time();
  if (verbose >= 2) {
    printf("Sorted data:");
    show_data(data[0], nele);
  }
  if (comp_ptr)
    *comp_ptr = comp_cnt;
  if (check) {
    size_t i;
    qsort_lib(data[2], nele, data[1]);
    for (i = 0; i < nele; i++) {
      if (data[0][i] != data[2][i]) {
	printf("Sort error.  Element %lu/%lu.  Library value = %llu.  Sort value = %llu.\n",
	       (printi_t) i, (printi_t) nele, (printd_t) data[2][i], (printd_t) data[0][i]);
	exit(0);
      }
      if (i < nele-1 && data[0][i] > data[0][i+1]) {
	printf("Sort error.  Element %lu = %llu.  Element %lu = %llu.\n",
	       (printi_t) i, (printd_t) data[0][i], (printi_t) i+1, (printd_t) data[0][i+1]);
	exit(0);
      }
    }
  }
  free_data();
  return t;
}
Beispiel #17
0
void test_port(portctrl::type* p, unsigned bits)
{
	char out[512];
	unsigned char buffer[512];
	unsigned char buffer2[512];
	unsigned char buffer3[512];
	memset(buffer, 255, 512);
	memset(buffer3, 0, 512);
	for(int i = 0; i < p->storage_size; i++)
		buffer[i] = rand();
	if(bits % 8) {
		buffer[bits / 8] &= ((1 << (bits % 8)) - 1);
	}
	int x = p->serialize(p, buffer, out);
	out[x] = '|';
	out[x+1] = 'X';
	out[x+2] = '\0';
	//std::cout << p->name << ":\t" << out << std::endl;
	int k = 0;
	if(out[0] == '|') k++;
	int y = p->deserialize(p, buffer2, out + k);
	if(memcmp(buffer, buffer2, p->storage_size) || y + k != x)
		std::cerr << "Error! (" << out << ") [" << p->hname << "]" << std::endl;

	if(p->controller_info->controllers.size()) {
		int pc = rand() % p->controller_info->controllers.size();
		int pi = rand() % p->controller_info->controllers[pc].buttons.size();
		short v = 1;
		if(p->controller_info->controllers[pc].buttons[pi].is_analog())
			v = rand();
		if(p->controller_info->controllers[pc].buttons[pi].type == portctrl::button::TYPE_NULL)
			v = 0;
		p->write(p, buffer3, pc, pi, v);
		for(int i = 0; i < p->controller_info->controllers.size(); i++) {
			for(int j = 0; j < p->controller_info->controllers[pc].buttons.size(); j++) {
				int k2 = p->read(p, buffer3, i, j);
				if(k2 != v && (i == pc && j == pi)) {
					std::cerr << "Error (" << i << "," << j << "," << k2 << ")!=" << v
						<< std::endl;
					show_data(buffer3, p->storage_size);
				}
				if(k2 != 0 && (i != pc || j != pi))
					std::cerr << "Error (" << i << "," << j << "," << k2 << ")!=0" << std::endl;
			}
		}
	}

}
Beispiel #18
0
/* Show the screen layout defined.  */
static void
show_layout (enum tui_layout_type layout)
{
  enum tui_layout_type cur_layout = tui_current_layout ();

  if (layout != cur_layout)
    {
      /* Since the new layout may cause changes in window size, we
         should free the content and reallocate on next display of
         source/asm.  */
      tui_free_all_source_wins_content ();
      tui_clear_source_windows ();
      if (layout == SRC_DATA_COMMAND 
	  || layout == DISASSEM_DATA_COMMAND)
	{
	  show_data (layout);
	  tui_refresh_all (tui_win_list);
	}
      else
	{
	  /* First make the current layout be invisible.  */
	  tui_make_all_invisible ();
	  tui_make_invisible (tui_locator_win_info_ptr ());

	  switch (layout)
	    {
	      /* Now show the new layout.  */
	    case SRC_COMMAND:
	      show_source_command ();
	      tui_add_to_source_windows (TUI_SRC_WIN);
	      break;
	    case DISASSEM_COMMAND:
	      show_disasm_command ();
	      tui_add_to_source_windows (TUI_DISASM_WIN);
	      break;
	    case SRC_DISASSEM_COMMAND:
	      show_source_disasm_command ();
	      tui_add_to_source_windows (TUI_SRC_WIN);
	      tui_add_to_source_windows (TUI_DISASM_WIN);
	      break;
	    default:
	      break;
	    }
	}
    }
}
Beispiel #19
0
int address(void)
{
    struct address_data data;
    ADDRESS_BOOK address_config;

    /* initialize config of address book */
    strcpy(address_config.filename, "address.txt");
    address_config.last_id = 1;

    load_file(&address_config);

    for(;;) {
        switch(menu()) {
        case INPUT:
            input_data(&address_config, &data);
            append_data_to_file(address_config, data);
            break;
        case SHOW:
            show_data(address_config);
            break;
        case EDIT:
            edit_data(&address_config);
            break;
        case DELETE:
            delete_data(address_config);
            break;
        case SEARCH:
            search(address_config);
            break;
        case EXIT:
            exit(0);
            break;
        case CONFIG:
            config(&address_config);
            break;
        case STATUS:
            show_status(address_config);
            break;
        default:
            break;
        }
    }

    return 0;
}
Beispiel #20
0
int
main(int argc, char *argv[])
{
    BTREE *root = NULL;

    setvbuf(stdout, NULL, _IONBF, 0);

    insert_data(&root, (const void *)10, cmp);
    insert_data(&root, (const void *)20, cmp);
    insert_data(&root, (const void *)15, cmp);
    insert_data(&root, (const void *)2, cmp);
    insert_data(&root, (const void *)30, cmp);
    insert_data(&root, (const void *)11, cmp);

    show_data(root);
    printf("\n");

    return EXIT_SUCCESS;
}
Beispiel #21
0
extern int 
autoboot_test (void)
{
	int ret = 0;

	//Those setting match with image default setting
	nand_info->flash_info->page_size = 2048;
	nand_info->flash_info->sp_size = 64;
	
	socle_nand_prepare_pattern((u8 *) TEST_PATTERN_TX_ADDR, TEST_PATTERN_BUF_SIZE);
#if 0//def NFC_CTRL_DEBUG
	show_nand_reg();
	show_data((u8 *)nand_info->buf_addr,nand_info->flash_info->page_size);
	show_spara_data((u8 *)nand_info->buf_addr, nand_info->flash_info->sp_size);
#endif

    	if(socle_nand_compare_pattern(nand_info->buf_addr,TEST_PATTERN_TX_ADDR, nand_info->flash_info->page_size)) 
		return -1;
	return ret;
}
Beispiel #22
0
// 検索する
void search(){
	char buff[1024];
	char pattern[1024];
	Bookdata *tail;
	Bookdata *matches[1024];
	int count;
	int i;
	
	printf("/");
	input_line(pattern, 1024);
	
	count = 0;
	for(tail = booklist_head; tail != NULL; tail = tail->next){
		if(smatch(pattern, tail->title)
		|smatch(pattern, tail->author)
		|smatch(pattern, tail->publisher)
		|smatch(pattern, tail->note)){
			puts("---");
			matches[count++] = tail;
			show_data(tail);
		}
	}
	
	if(count <= 0) return; // 見つからないので、戻る
	puts("---");
	printf("削除[d] 戻る[x] ");
	input_line(buff, 1024);
	strtolower(buff);
	
	if(strcmp(buff, "d") == 0){
		printf("削除します。よろしいですか? [y/N] ");
		if(select_y('N')){
			for(i=0; i<count; i++){
				delete_data(matches[i]);
			}
		}
		return;
	}else if(strcmp(buff, "x") == 0){
		return;
	}
}
void ssort(int *d, int n)
{
    int         i, j, h;
    static int  cnt = 1;
    
    for (h = n / 2; h > 0; h /= 2) {
        printf("<pass: %d>\n", cnt);
        for (i = h; i < n; i++) {
            int tmp = d[i];
            printf("<for:j start>\n");
            for (j = i - h; 
                    j >= 0 && d[j] > tmp; j -= h) {
                d[j+h] = d[j];
                show_data(d, N);
            }//for (j = i - h;
            printf("<for:j done>\n");
            d[j+h] = tmp;
        }//for (i = h; i < n; i++) {
        cnt ++;
    }//for (h = n / 2; h > 0; h /= 2) {
    
}//void ssort(int *d, int n)
static void show_extra_register_data(struct pt_regs *regs, int nbytes)
{
	mm_segment_t fs;

	fs = get_fs();
	set_fs(KERNEL_DS);
	show_data(regs->ARM_pc - nbytes, nbytes * 2, "PC");
	show_data(regs->ARM_lr - nbytes, nbytes * 2, "LR");
	show_data(regs->ARM_sp - nbytes, nbytes * 2, "SP");
	show_data(regs->ARM_ip - nbytes, nbytes * 2, "IP");
	show_data(regs->ARM_fp - nbytes, nbytes * 2, "FP");
	show_data(regs->ARM_r0 - nbytes, nbytes * 2, "R0");
	show_data(regs->ARM_r1 - nbytes, nbytes * 2, "R1");
	show_data(regs->ARM_r2 - nbytes, nbytes * 2, "R2");
	show_data(regs->ARM_r3 - nbytes, nbytes * 2, "R3");
	show_data(regs->ARM_r4 - nbytes, nbytes * 2, "R4");
	show_data(regs->ARM_r5 - nbytes, nbytes * 2, "R5");
	show_data(regs->ARM_r6 - nbytes, nbytes * 2, "R6");
	show_data(regs->ARM_r7 - nbytes, nbytes * 2, "R7");
	show_data(regs->ARM_r8 - nbytes, nbytes * 2, "R8");
	show_data(regs->ARM_r9 - nbytes, nbytes * 2, "R9");
	show_data(regs->ARM_r10 - nbytes, nbytes * 2, "R10");
	set_fs(fs);
}
Beispiel #25
0
void dump_packet( Huint size, Huint *data, FILE *fl)
{
    Huint   i;
    Huint   val;
    float   temp;
    float   sum;
    
    fwrite( data, sizeof(Huint), size, fl );
    fflush( fl );

    num_bytes   += size * sizeof(Huint);
    num_packets += 1;

    for( i = 0; i < size; i++ )
    {
        val = ntohl( data[i] );

        res_total   += val;
        res_number  += 1;

        if( val > res_max || res_number == 1 )  res_max = val;
        if( val < res_min || res_number == 1 )  res_min = val;
    }

    if( res_number > 0 )    res_mean = (float)res_total / (float)res_number;
    else                    res_mean = 0.0f;
    
    sum = 0;
    for( i = 0; i < size; i++ )
    {
        val     = ntohl( data[i] );
        temp    = val - res_mean;
        sum     += (temp * temp); 
    }

    sum /= (size - 1);
    res_std = sqrt( sum );

    show_size( size_win, num_bytes, num_packets );
    show_packet( pack_win, (Hubyte*)data, size*sizeof(Huint) );
    show_mini( mini_win, res_min );
    show_maxi( maxi_win, res_max );
    show_mean( mean_win, res_mean );
    show_stdd( stdd_win, res_std );
    show_data( data_win, (Hubyte*)data, size*sizeof(Huint) );
    show_operation( oper_win, "Showing Data..." );

    box( size_win, 0, 0 );
    box( pack_win, 0, 0 );
    box( mini_win, 0, 0 );
    box( maxi_win, 0, 0 );
    box( mean_win, 0, 0 );
    box( stdd_win, 0, 0 );
    box( data_win, 0, 0 );
    box( oper_win, 0, 0 );
    
    wrefresh( size_win );
    wrefresh( pack_win );
    wrefresh( mini_win );
    wrefresh( maxi_win );
    wrefresh( mean_win );
    wrefresh( stdd_win );
    wrefresh( data_win );
    wrefresh( oper_win );
}
Beispiel #26
0
void setup_ncurses( void )
{
    main_win = initscr();
    keypad(main_win, TRUE);     // enable keyboard mapping
    nonl();                     // tell curses not to do NL->CR/NL on output
    cbreak();                   // input chars one at a time, no wait for \n
    noecho();                   // don't echo input
    nodelay(main_win, TRUE);    // do non-blocking input
    curs_set( 0 );              // don't show the cursor

    size_win = create_window( main_win, 6, COLS/2, 0, 0 );
    pack_win = create_window( main_win, 6, COLS/2, 0, COLS/2 );
    mini_win = create_window( main_win, 5, COLS/4, 6, 0*(COLS/4) );
    maxi_win = create_window( main_win, 5, COLS/4, 6, 1*(COLS/4) );
    mean_win = create_window( main_win, 5, COLS/4, 6, 2*(COLS/4) );
    stdd_win = create_window( main_win, 5, COLS/4, 6, 3*(COLS/4) );
    data_win = create_window( main_win, LINES - 16, COLS, 11, 0 );
    oper_win = create_window( main_win, 5, COLS, LINES-5, 0 );

    // Use colors if the terminal has them
    if( has_colors() )
    {
        start_color();
        /*
        * Simple color assignment, often all we need.
        */
        init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK);
        init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK);
        init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK);
        init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
        init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK);
        init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
        init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK);
        init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK);
    }

    show_size( size_win, 0, 0 );
    show_packet( pack_win, NULL, 0 );
    show_mini( mini_win, 0 );
    show_maxi( maxi_win, 0 );
    show_mean( mean_win, 0 );
    show_stdd( stdd_win, 0 );
    show_data( data_win, NULL, 0 );
    show_operation( oper_win, "Waiting for Data..." );

    box( size_win, 0, 0 );
    box( pack_win, 0, 0 );
    box( mini_win, 0, 0 );
    box( maxi_win, 0, 0 );
    box( mean_win, 0, 0 );
    box( stdd_win, 0, 0 );
    box( data_win, 0, 0 );
    box( oper_win, 0, 0 );
    
    wrefresh( size_win );
    wrefresh( pack_win );
    wrefresh( mini_win );
    wrefresh( maxi_win );
    wrefresh( mean_win );
    wrefresh( stdd_win );
    wrefresh( data_win );
    wrefresh( oper_win );
}
Beispiel #27
0
        in.setByteOrder(QDataStream::LittleEndian);
        if(request_type==0x01)
        {
            for(int i=0;i<n_ap;i++)
            {
                in>>ap_li[i].ssid_len;
                in.readRawData(ssid_buf, ap_li[i].ssid_len);
                ssid_buf[ap_li[i].ssid_len] = '\0';
                ap_li[i].ssid = QString(ssid_buf);
                in>>ap_li[i].encrypt_type;
                in.readRawData((char *)ap_li[i].bssid, sizeof(ap_li[i].bssid));
            }
            show_data();
        }
    }
    connect(&tcpSocket,SIGNAL(readyRead()),this,SLOT(show_data()));
}

   void aplist::show_data()
    {
        for(int i=0;i<n_ap;i++)
        {
            char bssid_buf[256];
            /* SSID */
            ap_model->setItem(i, 0, new QStandardItem(ap_li[i].ssid));
            ap_model->item(i,0)->setTextAlignment(Qt::AlignCenter);
            ap_model->item(i, 0)->setFont( QFont( "Times", 10, QFont::Black ) );

            /* BSSID */
            sprintf(bssid_buf, "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x", ap_li[i].bssid[0],
                    ap_li[i].bssid[1], ap_li[i].bssid[2],
int main()
{
    
	int number_demand,number_supply,total_demand,total_supply; 
	// variable to store number of demand and supply points
    printf("\nEnter the number of supply points:\t");
    scanf("%d",&number_supply);
    printf("\nEnter the number of demand points:\t");
    scanf("%d",&number_demand);
    
	int i,j;
    int demand_array[10];//to store the demands for each node
    int supply_array[10];//to store the supplies from each node
    int cost_matrix[10][10];//to store the cost matrix
    int allocated_matrix[10][10];//to store the allocated resources
    int distance_matrix[10][10]			;//to store the distance 
    int u[10],v[10];//to store u(i) and v(j)
    total_demand=0;
    total_supply=0;

    for(i=0;i<=9;i++)
	{
		u[i]=-1;
		v[i]=-1;
		for(j=0;j<=9;j++)
		{

			allocated_matrix[i][j]=0;
			distance_matrix[i][j]=0;
		}
	}
    
    feed_data(allocated_matrix,cost_matrix,u,v,distance_matrix,demand_array,supply_array,number_demand,number_supply) ; //give inputs
	printf("\nMatrices after feeding the data:\n");    
	for(i=0;i<number_demand;i++)
            total_demand+=demand_array[i];
    	for(j=0;j<number_supply;j++)
            total_supply+=supply_array[j];
    

    show_data(allocated_matrix,cost_matrix,distance_matrix,number_demand,number_supply);

    /*balancing(cost_matrix,demand_array,supply_array,number_demand,number_supply,total_demand,total_supply);//Balance to get feasible solutin*/
    if(total_demand!=total_supply)
    {
        printf("\nUnbalanced Situation:");
        if(total_demand<total_supply)//demand is less than supply
        {
            number_demand++;//add a dummy column
            for(i=0;i<number_supply;i++)
            cost_matrix[i][number_demand-1]=0;//dummy column is equated to 0
            demand_array[number_demand-1]=total_supply-total_demand;//equate the remaining supply to the demand
            total_demand=total_supply;
        }
        else //supply is less than demand
        {
            number_supply++;//add a dummy row
            for(i=0;i<number_demand;i++)
            cost_matrix[number_supply-1][i]=0;//dummy row is equated to 0
            supply_array[number_supply-1]=total_demand-total_supply;//equate the remaining demand to supply
            total_supply=total_demand;
        } 
    }
    
	else
    printf("\nBalanced Situation");
    
	
   	printf("\nMatrices after Balancing:\n");
    show_data(allocated_matrix,cost_matrix,distance_matrix,number_demand,number_supply); 
  	
	printf("\nMatrices after allocating the resources:\n");
  	leastcost_allocation(allocated_matrix,cost_matrix,demand_array,supply_array,number_demand,number_supply,total_supply ) ;//allocate based on least cost algo
    show_data(allocated_matrix,cost_matrix,distance_matrix,number_demand,number_supply);
    
	printf("\n Cost after balncing:\t");
	cost_calculation(allocated_matrix,cost_matrix,number_demand,number_supply);//display the cost
    optimal_calculation(allocated_matrix,cost_matrix,distance_matrix,u,v,number_demand,number_supply);//calculate the most optimal cost
    
	printf("\nMatrices after removing negative values:\n");
    show_data(allocated_matrix,cost_matrix,distance_matrix,number_demand,number_supply);
    
	printf("\n Optimal Cost:\t");
	cost_calculation(allocated_matrix,cost_matrix,number_demand		,number_supply);//print the most optimal cost    	

}
Beispiel #29
0
extern int 
interrupt_test(int autotest)
{
#if 1
	int ret = 0;

	nand_info->irq_on = 1;
	//socle_init_nfc_int();	//all interrupt, DMA, RnB, Protect

	NDEBUG("Start Test Interrupt\n");
	ret = test_item_ctrl(&nfc_ctrl_interrupt_test_container, autotest);

	nand_info->irq_on = 0;
	//socle_exit_nfc_int();
	return ret;

#else
	struct socle_nand_flash *flash_info = nand_info->flash_info;
	int ret = 0;
	u32 block_erase_num = 0;

	socle_nfc_int_flag = 0;
	socle_nfc_int_state = 0;

	nand_info->dma_on = 0;
	nand_info->ecc_on = 0;
	socle_nfc_set_ecc(nand_info);

	//test RnB interrupt
	NDEBUG("------------Int test 1--------------------\n");
	nand_info->dma_on = 1;
	nand_info->dma_size= NF_DMA_SIZE_8;//NF_DMA_SIZE_16
	nand_info->dma_mode = NF_DMA_BURST_8_ADDR_INC;

	socle_nand_initial_buf(BUFFER_READ);
	if (!(socle_nfc_interrupt_page_read(nand_info, NAND_TEST_PAGE_ADDR, flash_info->page_size) & NAND_STATUS_READY))
		return -1;
	 free_irq(NAND_INT);
	 
#if 0//def NFC_CTRL_DEBUG
	show_data((u8 *)nand_info->buf_addr, 128);
	show_data((u8 *)TEST_PATTERN_RX_ADDR, 128);
#endif
	//compare
	if(socle_nand_compare_pattern(TEST_PATTERN_RX_ADDR,nand_info->buf_addr, flash_info->page_size))
		ret= -1;


	//test Prot_IE  interrupt
	NDEBUG("------------Int test 2--------------------\n");
	socle_nfc_set_protected_area(TEST_BEGIN_PROTECT_BLOCK, TEST_END_PROTECT_BLOCK);

    	socle_nand_initial_buf(BUFFER_WRITE);
	if (!(socle_nfc_interrupt_page_program(nand_info, (TEST_BEGIN_PROTECT_BLOCK+1) *(flash_info->page_per_block),flash_info->page_size) & NAND_STATUS_WP))
		ret = -1;
	free_irq(NAND_INT);
	NDEBUG(" Protect  socle_nfc_int_state =0x%x\n",socle_nfc_int_state);
	socle_nfc_set_protected_area(0, 0);


	//Test DMA IE
	NDEBUG("------------Int test 3--------------------\n");
	nand_info->dma_on= 1;
	nand_info->dma_size= NF_DMA_SIZE_8;//NF_DMA_SIZE_16
	nand_info->dma_mode = NF_DMA_BURST_8_ADDR_INC;

	if ((page_number %flash_info->page_per_block)==0)
	{
		block_erase_num = (int)(NAND_TEST_PAGE_ADDR + page_number)/flash_info->page_per_block; 		
		NDEBUG("Block erase number = 0x%x\n", block_erase_num);
		if(socle_nfc_block_erase(nand_info, block_erase_num))
			return -1;
		if (socle_nfc_read_status(nand_info) & NAND_STATUS_FAIL)
			return -1;
		page_number = 0;
	}
	page_number ++;
	NDEBUG("===Int write page\n");	
	socle_nand_initial_buf(BUFFER_WRITE);
	if (!(socle_nfc_dma_interrupt_page_program(nand_info, NAND_TEST_PAGE_ADDR + page_number, flash_info->page_size) & NAND_STATUS_READY))
		return -1;
	free_irq(NAND_INT);

	NDEBUG("===Int read page\n");	
	socle_nand_initial_buf(BUFFER_READ);		
	if (!(socle_nfc_dma_interrupt_page_read(nand_info, NAND_TEST_PAGE_ADDR + page_number, flash_info->page_size) & NAND_STATUS_READY))
		return -1;
	free_irq(NAND_INT);

	//compare
	if(socle_nand_compare_pattern(TEST_PATTERN_TX_ADDR,TEST_PATTERN_RX_ADDR, nand_info->flash_info->page_size))
		ret= -1;


	socle_nfc_write(socle_nfc_read( NF_SFR_FLCTRL) &~ (NF_CTRL_INT_EN|NF_CTRL_ACC_ERR_EN|NF_CTRL_PROT_IE|NF_CTRL_RNB_IE|NF_CTRL_DMA_IE|NF_CTRL_DMA_TRIGGER|NF_CTRL_TRANS_COMPLETE) , NF_SFR_FLCTRL);        

	return ret;
#endif
}