コード例 #1
0
ファイル: wlfiler6.c プロジェクト: ctierney/c-class
int update( char str[], int val )
{
	LINK *linkp;

	for( linkp = table[get_char_index(str[0])].next ; linkp; linkp = linkp->next ) {

		if (DEBUG)
			printf("update: scanning for %s, linkp is %s\n", str, (linkp) ? "not null" : "null");

		if ( strcmp( linkp->word, str) == 0 ){  

			if (DEBUG)
				printf("update: found %s updating value to %d \n", str, val );

			linkp->value = val;	

			if (DEBUG)
				show_table();

			return YES;	

		} else {
			if (DEBUG)
				show_table();
		}
	}
	if (DEBUG)
		show_table();

	return 0;
}
コード例 #2
0
ファイル: testing2.c プロジェクト: qiubix/Cyclops
void gameplay()
{
    int i=0;
    char c=0;
    char choice=0;

    printf("Wpisz T aby dobrac karte.\n");
    printf("Wpisz Q aby zakonczyc.\n");

    while(c=getchar())
    {
        if(i==0)
        {
            if(c=='T'||c=='t'||c=='Q'||c=='q') choice = c;
            else choice = 0;
            i++;
        }
        else
        {
            if(choice&&i==1&&c=='\n')
                switch(choice)
                {
                case 't': {
                    take();
                    show_table(d,p);
                    printf("Wpisz T aby dobrac karte.\n");
                    printf("Wpisz Q aby zakonczyc.\n");
                    i=0;
                    break;
                }
                case 'T': {
                    take();
                    show_table(d,p);
                    printf("Wpisz T aby dobrac karte.\n");
                    printf("Wpisz Q aby zakonczyc.\n");
                    i=0;
                    break;
                }
                case 'q':
                    break;
                case 'Q':
                    break;
                }/*switch*/
            else if (c=='\n') {
                printf("Niewlasciwa komenda! Mozesz dobrac karte (T) lub zakonczyc ture (Q)\n");
                i=0;
            }
            else i++;

        }/*else*/
        if((choice=='Q'||choice=='q')&&c=='\n'&&i==1) {
            /*show_table(d,p);*/break;
        }
    }

    winner();
}/*gameplay()*/
コード例 #3
0
    void show_data() const {
      for (unsigned int ti = 0; ti != number_tables; ti++) {
	cout << "\n" << Meldungen[menu_tables[ti].first][language] << ": " << menu_tables[ti].second -> get_last_nresults() << " " << Meldungen[15][language] << "\n";
	show_table(menu_tables[ti].second);
      }
      cout << "\n";
    }
コード例 #4
0
ファイル: AllDlg.cpp プロジェクト: khiemnv/utilities
void CAllDlg::OnNMDblclkAllList(NMHDR *pNMHDR, LRESULT *pResult)
{
	/*LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<NMITEMACTIVATE>(pNMHDR);*/
	// TODO: Add your control notification handler code here
	show_table();
	*pResult = 0;
}
コード例 #5
0
void
uim_cand_win_horizontal_gtk_set_page(UIMCandWinHorizontalGtk *horizontal_cwin, gint page)
{
  guint len, new_page;
  gint new_index;
  UIMCandWinGtk *cwin;

  g_return_if_fail(UIM_IS_CAND_WIN_HORIZONTAL_GTK(horizontal_cwin));
  cwin = UIM_CAND_WIN_GTK(horizontal_cwin);
  g_return_if_fail(cwin->stores);

  len = cwin->stores->len;
  g_return_if_fail(len);

  if (page < 0)
    new_page = len - 1;
  else if (page >= (gint) len)
    new_page = 0;
  else
    new_page = page;

  update_table_button(horizontal_cwin, new_page);
#if GTK_CHECK_VERSION(3, 4, 0)
  show_table(GTK_GRID(cwin->view), horizontal_cwin->buttons);
#else
  show_table(GTK_TABLE(cwin->view), horizontal_cwin->buttons);
#endif

  cwin->page_index = new_page;

  if (cwin->display_limit) {
    if (cwin->candidate_index >= 0)
      new_index
        = (new_page * cwin->display_limit) + (cwin->candidate_index % cwin->display_limit);
    else
      new_index = -1;
  } else {
    new_index = cwin->candidate_index;
  }

  if (new_index >= (gint) cwin->nr_candidates)
    new_index = cwin->nr_candidates - 1;

  /* check if (cwin->candidate_index != new_index) ?? */
  uim_cand_win_gtk_set_index(cwin, new_index);
}
コード例 #6
0
ファイル: hash_table.cpp プロジェクト: wazzuck/vunderland
int main ( void ) 
{
	/* This is our hash table */
	char table[10] = {0};

	fill_table ( table );
	show_table ( table, length ( table ) );

	return 0;
}
コード例 #7
0
ファイル: election.c プロジェクト: zj9205/ECS-30
int main(int argc, char *argv[])
{
  FILE *inp = fopen(argv[1],"r");
  int vote[6][4];
  char names[4]={'A', 'B', 'C', 'D'};

  read_file(inp, vote);
  sort(vote, names);
  show_table(vote, names);
  declare_winner(vote, names);
  return 0;
}//main
コード例 #8
0
ファイル: election.c プロジェクト: Jvlythical/ECS30
int main () {
	FILE *fp;
	int **buff;
	int valid;
	int order[] = {0, 1, 2, 3, 4};

	valid = read_file ("election1.txt", buff);

	sort (buff, order);
	show_table (buff, order);
	declare_winner (order);

	return 0;
}
コード例 #9
0
ファイル: kernelRead.c プロジェクト: ivinyo16/hello-world
/* This function reads in data from the user into the kernel */
int kernelRead (struct file *file, const char *buffer, unsigned long count, void *data) { 


  char *kernelBuffer; /* the kernel buffer */
 
  
  struct lineList *tmp;

  kernelBuffer = kmalloc (BUFFERLENGTH, GFP_KERNEL); /* allocate memory */
   
  if (!kernelBuffer) {
    return -ENOMEM;
  }


  if (count > BUFFERLENGTH) { /* make sure we don't get buffer overflow */
    kfree (kernelBuffer);
    return -EFAULT;
  }

  
  /* copy data from user space */
  if (copy_from_user (kernelBuffer, buffer, count)) { 
    kfree (kernelBuffer);
    return -EFAULT;
  }
      
  kernelBuffer[BUFFERLENGTH -1]  ='\0';
  printk (KERN_INFO "kernelRead: Having read %s\n", kernelBuffer);

  switch (kernelBuffer[0]) {
    case ADD_ENTRY:
      tmp = add_entry (kernelList, &(kernelBuffer[1]));
      if (!tmp) {
	kfree (kernelBuffer);
	return -EFAULT;
      }
      else {
	kernelList = tmp;
      }
      break;
    case SHOW_TABLE:
      show_table (kernelList);
    default: 
      printk (KERN_INFO "kernelRead: Illegal command \n");
  }
  return count;
}
コード例 #10
0
ファイル: cubesTable.c プロジェクト: lonbon7/cpe101
int main(void)
{
    int table_size;
    int first;
    int increment;

    /* loop until sentinel is reached */
    table_size = get_table_size();
    while (table_size != 0)
    {
        first = get_first();
        increment = get_increment();
        show_table(table_size, first, increment);
        table_size = get_table_size();
    }
    return 0;
}
コード例 #11
0
ファイル: lls.c プロジェクト: SapphireStart/ls_tree
void my_ls(const char * cur_path,int model){
        DIR *dir;
        struct dirent *ptr;
        struct stat buf;
        if(MODEL_R(model)){
                list(cur_path);
        }else{
                if((dir=opendir(cur_path))==NULL){//打开文件夹
                        perror("No Such file or diector!\n");
                }else{
                        int length=strlen(cur_path);
                        if(MODEL_L(model)){
                                int i,type=MODEL_U(model);
                                while((ptr=readdir(dir))!=NULL){//读取文件夹下的内容
                                        strcpy(collector.vector[collector.count++],ptr->d_name);
                                }
                                qsort(collector.vector,collector.count,sizeof(collector.vector[0]),method_cmp);
                                for(i=0;i<collector.count;i++){
                                        char absolute[max_len];
                                        strcpy(absolute,cur_path);
                                        strcpy(absolute+length,collector.vector[i]);
                                        print_for_name(collector.vector[i],absolute,type);
                                }
                        }else{
                                collector.count=0;
                                int i;
                                while((ptr=readdir(dir))!=NULL){//读取文件夹下的内容
                                        char absolute[max_len];        
                                        strcpy(absolute,cur_path);
                                        strcpy(absolute+length,ptr->d_name);
                                        lstat(absolute,&buf);//获取文件的绝对路径
                                        if(MODEL_A(model) || (MODEL_A(model)==0 && ptr->d_name[0]!='.')){
                                                strcpy(collector.vector[collector.count++],ptr->d_name);
                                        }
                                }
                                if(MODEL_T(model)){
                                        show_table(collector.vector,collector.count,collector.itemlength,screen.colums);
                                }else{
                                        show_standard();
                                }
                        }
                        closedir(dir);//关闭文件夹子
                }
        }
}
コード例 #12
0
ファイル: table_show.c プロジェクト: D-TOKIOKA/lagopus
static void
show_bridge_domains_table_flow(struct confsys *confsys,
                               struct bridge *bridge) {
  uint8_t i;
  struct flowdb *flowdb;
  struct table *table;

  flowdb = bridge->flowdb;
  flowdb_rdlock(flowdb);
  show(confsys, "Bridge: %s\n", bridge->name);

  for (i = 0; i < flowdb->table_size; i++) {
    if ((table = flowdb->tables[i]) != NULL) {
      show_table(confsys, table, i);
    }
  }
  flowdb_rdunlock(flowdb);
}
コード例 #13
0
 void	mailmerge( symtab_t *tp, FILE *fp) {
	
	int c;
	
	if ( strcmp(firstword(tp),"complete") == 0 ) {
			printf("\nMailmerge found the complete marker\n");
			while( ( c = fgetc(fp)) != EOF ) {
				putchar(c);
			}
			show_table(tp);
			fseek(fp, 0L, 0);
	}
	else {
			printf("\nMailmerge did not find complete\n");
			//error out here
	}
	//exit(1);
}
コード例 #14
0
ファイル: arp.cpp プロジェクト: Droker/wirelessui
void arp::make_model()
{
    arp_model->setHorizontalHeaderItem(0, new QStandardItem(QObject::tr("Internet地址")));
    arp_model->setHorizontalHeaderItem(1, new QStandardItem(QObject::tr("物理地址")));
    arp_model->setHorizontalHeaderItem(2, new QStandardItem(QObject::tr("类型")));
    //利用setModel()方法将数据模型与QTableView绑定
    ui->arp_table->setModel(arp_model);
    //设置表格的各列的宽度值
    ui->arp_table->setColumnWidth(0,180);
    ui->arp_table->setColumnWidth(1,250);
    ui->arp_table->setColumnWidth(2,65);
    //隐藏行头
    ui->arp_table->verticalHeader()->hide();
    //设置选中时为整行选中
    ui->arp_table->setSelectionBehavior(QAbstractItemView::SelectRows);
    //只读
    ui->arp_table->setEditTriggers(QAbstractItemView::NoEditTriggers);
    show_table();
}
コード例 #15
0
ファイル: main.c プロジェクト: ChingfanTsou/cattydb
int main(int args, char* argvs[])
{
    int result, col_length;
    char col_type[ITEM_TYPE_LEN], col_name[ITEM_NAME_LEN];
    struct msg_st string_item;
    int msgqid;
    char tb_name[TABLE_NAME_LEN];
    char tmp[10][ITEM_NAME_LEN];

    msgqid = msgget((key_t)3570, 0666 | IPC_CREAT);
    if (msgqid == -1) {
        ipc_msgget_failed(errno);
    }
    
    while (receive(0)) {
        switch (*string_item.text) {        
        case '0':
            result=receive(0);
            string_item.text[result]='\0';
	    strcpy(tb_name, string_item.text);
            create_table(string_item.text);
            result = 0;
            while ((result = receive(0)) != -1) {
                string_item.text[result]='\0';
                if (!strcmp(string_item.text, "TAIL"))
                    break;
                sscanf(string_item.text, "%s %s %s %d", tmp[0], col_type, col_name, &col_length);
                if (tmp[0][0] == '0')
                    create_col(col_name, col_type, col_length, 0);
                else create_col(col_name, col_type, col_length, 1);
            }
            
            if (-1 == result)
                ipc_msgrcv_failed(errno);
            create_table_on_close();
            printf("CATTYDB : database %s successfully created.\n",tb_name);
            break;
        case '1':
            result=receive(0);
            string_item.text[result]='\0';
            //printf("%s\n", string_item.text);
            describe_table(string_item.text);
            break;
        case '2':
            result = receive(0);
            string_item.text[result]='\0';
            //printf("%s\n", string_item.text);
            insert_on_open(string_item.text);
            while ((result=receive(0)) != -1) {
                string_item.text[result]='\0';
                if (!strcmp(string_item.text, "TAIL"))
                    break;
                insert_item(string_item.text);
            }
            if (-1 == result)
                ipc_msgrcv_failed(errno);
            insert_on_close();
            break;
        case '3':
            result = receive(0);
            string_item.text[result]='\0';
            //printf("%s\n", string_item.text);
            delete_on_open(string_item.text);
            int i = 0;
            while ((result = receive(0)) != -1) {
                string_item.text[result]='\0';
                if (!strcmp(string_item.text, "TAIL"))
                    break;
                delete(string_item.text);
                //strcpy(tmp[i++], string_item.text);
                //puts(tmp[i-1]);
            }
            if (-1 == result)
                ipc_msgrcv_failed(errno);
            puts("del suc!");
            break;
        case '6':
            puts("bye");
            exit(0);
        case '7':
            result = receive(0);
            string_item.text[result]='\0';
            printf("%s\n", string_item.text);
            show_table(string_item.text);
            break;
        case '8':
            result=receive(0);
            string_item.text[result]='\0';
            select_where_on_open(string_item.text, "tmp");
            
            result=receive(0);
            string_item.text[result]='\0';
            select_where(string_item.text);
            select_where_on_close();

            select_col_on_open("tmp", "tmp2");
            
            result = 0;
            while ((result = receive(0)) != -1) {
                string_item.text[result]='\0';
                if (!strcmp(string_item.text, "TAIL"))
                    break;
                select_col_get_pos(string_item.text);
            }
            if (-1 == result)
                ipc_msgrcv_failed(errno);

            select_col();
            select_col_on_close();
            show_table("tmp2");
            break;
        case '9':
            result = receive(0);
            string_item.text[result]='\0';
            update_on_open(string_item.text);
            result = receive(0);
            string_item.text[result]='\0';
            strcpy(tmp[0], string_item.text);
            result = receive(0);
            string_item.text[result]='\0';
            update(tmp[0], string_item.text); 
            break;
        case 'a':
            result = receive(0);
            string_item.text[result]='\0';
            strcpy(tmp[0], string_item.text);
            result = receive(0);
            string_item.text[result]='\0';
            equijoins_on_open(tmp[0], string_item.text, "tmp");
            result = receive(0);
            string_item.text[result]='\0';
            equijoins(string_item.text);
            equijoins_on_close();
            show_table("tmp");
        }
    }

    return 0;
}
コード例 #16
0
int main_classtable(void)
{
	char c;
	int x = 1, y = 1;
	int fd;

#ifdef	HAVE_CLASSTABLEALERT
	classtable_free();
#endif
	usr_fpath(fpath_classtable, cuser.userid, FN_CLASSTABLE2);

	init_classtable();
	show_icon_classtable(x, y, 1);

	do
	{
		c = vkey();
		switch (c)
		{
		case 'q' :
			break;
		case KEY_DOWN :
			show_icon_classtable(x, y, 0);
			x++;
			if (x == 14) x = 1;
			show_icon_classtable(x, y, 1);
			break;
		case KEY_UP:
			show_icon_classtable(x, y, 0);
			x--;
			if (x == 0) x = 13;
			show_icon_classtable(x, y, 1);
			break;
		case KEY_LEFT:
			show_icon_classtable(x, y, 0);
			y--;
			if (y == 0) y = 6;
			show_icon_classtable(x, y, 1);
			break;
		case KEY_RIGHT :
			show_icon_classtable(x, y, 0);
			y++;
			if (y == 7) y = 1;
			show_icon_classtable(x, y, 1);
			break;
		case 'a' :
			add_classtable(x, y);
			break;
		case 'd' :
			del_classtable(x, y);
			break;
		case 'e' :
			edit_classtable(x, y);
			break;
		case 'i' :
			import_classtable(x, y);
			break;
		case 'c' :
			if (vans("確定刪除嗎?[y/N] ") == 'y')
			{
				memset(tmp_table, 0, sizeof(CLASS_TABLE2)*78);
				show_table();
			}
			break;
		case '\n' :
			if (tmp_table[x+y*13-14].valid == 1)
				edit_classtable(x, y);
			else
				add_classtable(x, y);
			break;
		}
	}
	while (c != 'q');

	fd = open(fpath_classtable, O_WRONLY | O_CREAT | O_TRUNC, 0600);
	if (fd >= 0)
	{
		write(fd, tmp_table, sizeof(CLASS_TABLE2)*78);
		close(fd);
	}
#ifdef	HAVE_CLASSTABLEALERT
	classtable_main();
#endif

	vmsg(NULL);
	return 0;
}
コード例 #17
0
int init_classtable()
{
	show_table();
	load_table();
	return 0;
}
コード例 #18
0
ファイル: wlfiler6.c プロジェクト: ctierney/c-class
int
insert( char str[], int val )
{
	
	/* get the correct linked list for this letter */
	LINK *linkp = table[get_char_index(str[0])].next; 

	char *new_string; 
	LINK *new_link; 

	new_string = malloc(strlen(str) + 1); 		/* create new space in memory for string, 
													leave room for null char */
	if (new_string == NULL) { 			 		/* this happens if there's no memory free */
		return NO;
	}

	strcpy( new_string , str );		     		/* copy into new space */ 

	new_link = malloc(sizeof(LINK));	    /* create memory for new link	*/

	if ( new_link == NULL ) {					/* again check for memory overflow */

		free(new_string);						/* don't leak this memory */
		return NO;
	}

	// 
	new_link->word  = new_string;		
	new_link->value = val;
	new_link->next  = NULL;

	// first case: empty list 
	if (linkp == NULL) {

		table[get_char_index(str[0])].next = new_link;

		if (DEBUG)
			show_table();

		return YES;

	// if new_link->word preceeds the word at the front 
	//  of the list, make new_link the front of the list.	
	} else if ( strcmp(linkp->word, new_link->word) > 0 ) {

		new_link->next = table[get_char_index(str[0])].next;
		table[get_char_index(str[0])].next = new_link;
		
		if (DEBUG)
			show_table();

		return YES;	

	} else {

		/* seek to the link before where we want to insert */
		while ( linkp != NULL ) {

			/* if the next word in the list is null 
				then insert after current link */
			if (linkp->next == NULL) {

				if (DEBUG)
					printf("adding %s at the end of the list \n", linkp->word);
				break;
			
			/* if the next word in the link after this is 
				greater than the insert string, insert after current */
			} else if ( strcmp( linkp->next->word, str ) > 0 ) {

				if (DEBUG)
					printf("adding %s after %s and before %s \n", new_link->word, linkp->word, linkp->next->word);
				
				break;

			} else {

				linkp = linkp->next;
				continue;
			}
				
			printf("UNDEFINED BEHAVIOR: Infinite looping will occur\n");

		}

		new_link->next = linkp->next;
		linkp->next = new_link;

	}

	if (DEBUG)
		show_table();

	return YES;
}
コード例 #19
0
ファイル: testing2.c プロジェクト: qiubix/Cyclops
void deal()
{
    d=p=0;
    srand((unsigned)(time(0)));
    while (d<2)
    {
        dealer[d]=draw();
        switch(dealer[d])
        {
        case '2':
            dealer_sum+=2;
            break;
        case '3':
            dealer_sum+=3;
            break;
        case '4':
            dealer_sum+=4;
            break;
        case '5':
            dealer_sum+=5;
            break;
        case '6':
            dealer_sum+=6;
            break;
        case '7':
            dealer_sum+=7;
            break;
        case '8':
            dealer_sum+=8;
            break;
        case '9':
            dealer_sum+=9;
            break;
        case 'T':
            dealer_sum+=10;
            break;
        case 'J':
            dealer_sum+=2;
            break;
        case 'Q':
            dealer_sum+=3;
            break;
        case 'K':
            dealer_sum+=4;
            break;
        case 'A':
            dealer_sum+=11;
            break;
        }
        d++;
        player[p]=draw();
        switch(player[p])
        {
        case '2':
            player_sum+=2;
            break;
        case '3':
            player_sum+=3;
            break;
        case '4':
            player_sum+=4;
            break;
        case '5':
            player_sum+=5;
            break;
        case '6':
            player_sum+=6;
            break;
        case '7':
            player_sum+=7;
            break;
        case '8':
            player_sum+=8;
            break;
        case '9':
            player_sum+=9;
            break;
        case 'T':
            player_sum+=10;
            break;
        case 'J':
            player_sum+=2;
            break;
        case 'Q':
            player_sum+=3;
            break;
        case 'K':
            player_sum+=4;
            break;
        case 'A':
            player_sum+=11;
            break;
        }
        p++;
    }
    show_table(d,p);

    gameplay();
}/*=======================================================koniec deal() */