Пример #1
0
void						write_param(int argc, char **argv, t_clist *param)
{
	if (argc != 2)
		put_list();
	if (ft_strequ(argv[1], "Mandelbrot"))
		CONTENT(0) = 1;
	else if (ft_strequ(argv[1], "Julia"))
		CONTENT(0) = 2;
	else if (ft_strequ(argv[1], "Chromosome"))
		CONTENT(0) = 3;
	else
		put_list();
}
Пример #2
0
Файл: dict.c Проект: Uyouii/dict
int main()
{
	int driver=0, mode=VESA_800x600x8bit;
	int yes; 
	int i=0;
	int t=0;
	int style1=-1,style2=-1;
	char c;
	int n;
	int eee=0;

	initgraph(&driver, &mode, "");
	mydict();
	outtextxy(0,580,"Search:");
	
	while(strcmp(str,"exit")!=0&&strcmp(str,"quit")!=0)
	{
		num=0;
		clear_entry(str);
		if(eee==0)
		{
			t=bioskey(0);
		}
		eee=0;
		while(t!=Enter||num==0)
		{
			if(((char)t>=32&&(char)t<=126)||t==Bspace||t==ESC) 
			{
				if(t==Bspace)
				{
					if( num>0 ){
						num--;
						str[num] = '\0';
					}
				}
				else
				{
					if(t!=Enter)
					{
						c=t&0XFF;
						str[num++]=c;
						str[num] = '\0';
					}
				}
				if(t==ESC)
				{
					clear_entry(str);
					num=0;
				}
				input_entry();
				t=bioskey(0);
				
				if(num>=20)
				{
					clear_entry(str);
					num=0;
				}
			}
			else t=bioskey(0);
		}
		clear_translation();
		
		n=strlen(str);
		
		style1=-1;style2=-1;
		for(i=0;i<n;i++)
		{
			if(str[i]=='*'&&i<n) 	style1=i; 
			if(str[i]=='?'&&i<n) 	style2=i;
		}
		if(style1>0||style2>0)
		{
			search(str);
			if(count!=0) put_list();
		}
		
		show_translation(str);
			
		if(record>0) total=2;
		else total=1;
		show_page();
		if(record>0)
		{
			eee=1;
			t=bioskey(0);
			while(t==LEFT||t==RIGHT||t==DOWN||t==UP)
			{
				if(page==1&&(t==RIGHT||t==DOWN))
				{
					clear_translation();
					page++;
					copy_example( example, example2, record);
					put_translation2(example2);
					show_page();
				}
				if(page==2&&(t==LEFT||t==UP))
				{
					clear_translation();
					page--;
					show_translation(str);
					show_page();
				}
				t=bioskey(0);
			}	
		}
		for(i=0;i<2000;i++)
		{
			translation[i]=0;
			example[i]=0;
			example2[i]=0;
		}
		page=1;
		record=0;
	}
	closegraph();
	return 0; 
}
Пример #3
0
void
init()
{
	struct ext_mem_format *ptr_exts; // structure-pointer to structure
	struct ext_mem_format temp_struc; // temporary structure
	struct inode ino_kern;
	struct ext_mem_format ext_mem_strucs[50]; // 386 usable RAM list format

	usec_t ino_sec;
	ubyte_t num_servs; // number of servers to read to memory
	uint_t tot_mem, counter, counter1; // counters
	byte *ptr_mem=(byte *)ext_mem_strucs; // byte-pointer to structure

	/* 
	 * Get absolute sector for first ivector.
	 * It is stored in a global variable.
	 */
	sosfs_ivec_first();

	/* read kernel's and server's inode sector */
	ino_sec = sosfs_iget("/boot/kernel");
	/* if error */
	if (ino_sec == -1) {
		low_putstr("Inode not found\n"); 
		while (1);
	}
	/* read kernel's inode */
	sosfs_read_raw(ino_sec, &ino_kern);

	/* zero out the vector */
	for (tot_mem=0; tot_mem<512; tot_mem++)
		buffer[tot_mem]=0;

	/* 
	 * Copy arguments from real-mode to protected-mode.
	 * The monitor program wishes to pass the arguments to the kernel.
	 * This is done by a little hack that uses an interrupt instruction
	 * passing a buffer to copy from real-mode to protected-mode using
	 * BIOS.
	 */
	kargs_init();

	/* 
	 * Get total amount of RAM.
	 * The most reliable way to know the system's memory-mapping
	 * is by using the BIOS; we use int $0x15 function 0xe820.
	 */
	low_tot_ram(ext_mem_strucs);

	/* point to memory-map vector */
	ptr_exts=ext_mem_strucs;
	/* 
	 * Traverse the structures until magic number found.
	 * Our interrupt handler set a magic number after the last
	 * entry returned by the BIOS handler.
	 */
	kprintf("\n");
	kprintf("BIOS-provided physical-memory mappings\n");
	kprintf("======================================================\n");
	while (ptr_exts->acpi_ext != 0x12345) {
		/* if we must ignore the entry, so we do */
		if (ptr_exts->reg_len == 0)
			continue;
		/* print type of memory to terminal */
		switch (ptr_exts->reg_type) {
			case 1:
				kprintf("Usable RAM at ");
				if (ptr_exts->base_addr[0] != 0) {
					zero_mem(ptr_exts);
					put_list(ptr_exts);
				}
				break;
			case 2:
				kprintf("Reserved/unusable RAM at ");
				break;
			case 3:
			case 4:
			case 5:
				kprintf("ACPI RAM at ");
				break;
		}
		/*
		 * Create a temporary structure and copy the entire structure
		 * to it.
		 * Print the address range.
		 */
		temp_struc = *ptr_exts; // copy structure
		temp_struc.reg_len[0] += temp_struc.base_addr[0];
		kprintf("%x-", &temp_struc);
		kprintf("%x", temp_struc.reg_len);
		kprintf("\n");
		for (tot_mem=0; tot_mem<512; tot_mem++)
			buffer[tot_mem]=0;
		ptr_exts++; // advance one structure
	}
	kprintf("======================================================\n");

	/* 
	 * Set up initial memory mappings.
	 * Load user-level servers to predefined physical memory and
	 * identically map them. Map the monitor program and the kernel
	 * also to identical physical addresses. Also map those programs'
	 * heaps.
	 */
	load_init();
	heap_init();
	/* list returned by BIOS might be unsorted */
	sort_free_list();
	/* machine-dependent format to machine-independent format */
	dep_2_indep_list(ptr_list);
	mmap_init();
	enable_paging();
	SOS_init();
}
Пример #4
0
/*---------------------------------------------------------
  dds_prepare_nodes
---------------------------------------------------------*/
int dds_prepare_nodes(
    int Mesh_id,      /* in: mesh ID */
    int Gen_lev /* generation to consider */
)
{

    int max_elem_id, max_node_id;
    int i, nel, nno, ino, ipr;
    int el_nodes[MMC_MAXELVNO+1];

    /*++++++++++++++++ executable statements ++++++++++++++++*/

    max_elem_id = mmr_get_max_elem_id(Mesh_id);
    sub_ind_el = malloc((max_elem_id+1)*sizeof(int));
    for(i=0; i<=max_elem_id; i++) sub_ind_el[i]=0;

    max_node_id = mmr_get_max_node_id(Mesh_id);
    front_ind = malloc((max_node_id+1)*sizeof(int));
    for(i=0; i<=max_node_id; i++) front_ind[i]=0;
    elems = malloc((max_node_id+1)*sizeof(int *));
    for(ino=0; ino<=max_node_id; ino++) {
        elems[ino] = malloc(MAXELNO*sizeof(int));
        for(i=0; i<MAXELNO; i++) elems[ino][i]=0;
    }

    /* loop over elements */
    nel=0;
    while((nel=mmr_get_next_elem_all(Mesh_id, nel))!=0) {

        if(mmr_el_gen(Mesh_id,nel)==Gen_lev) {

            mmr_el_node_coor(Mesh_id,nel,el_nodes,NULL);

            for(nno=1; nno<=el_nodes[0]; nno++) {
                ino=el_nodes[nno];
                i=put_list(nel,elems[ino],MAXELNO);
                if(i<0) {
                    printf("Something wrong with filling NODES->elems for node %d\n",ino);
                    for(ipr=0; ipr<MAXELNO; ipr++)
                        printf("%d\n",elems[ino][ipr]);
                    printf("\n");
                    getchar();
                }

                /*kbw
                #ifdef DEBUG
                      printf("node %d (%d), added element %d, list:",
                	     ino, el_nodes[nno], nel);
                      ipr=0;
                      while(elems[ino][ipr]!=0) {
                	printf("%d ",elems[ino][ipr]);
                	ipr++;
                      }
                      printf("\n");
                #endif
                /*kew*/

            }
        }
    }
    return(0);
}