Пример #1
0
FRAME          *
fr_create(int entries, int size)
{
	FRAME          *tab;

	if (size < sizeof(char **))
		size = sizeof(char **);	/* ensure size for free list */

	if ((tab = ALLOCMEM(FRAME, 1)) == 0) {
		return 0;
	}
	tab->nentry = entries;
	tab->nsize = size;
	if ((tab->frbuf = MALLOCMEM(entries * size)) == 0) {
		FREEMEM(tab);
		return 0;
	}
	init_list(tab);
	tab->next = 0;		/* continuation block */
	return tab;
}
Пример #2
0
Файл: batch.c Проект: husthl/qos
static bool batch_auto_grow_up( int id ){
    uverify( id_valid( id ) );

    batch_t* const batch = (batch_t*)id;

    const int len = batch->len;
    const int increase_len = 50;
    const int new_len = len + increase_len;

    callback_arg_t* const new_list = qrealloc( batch->list, new_len * sizeof( callback_arg_t ) );
    // 如果没有足够的空间,老空间没有释放,仍然存在。简单返回false,说明grow_up失败。
    return_false_if( NULL == new_list );
    batch->list = new_list;
    // 老空间内容,已经拷贝在前面,只用初始化后面一段即可。
    return_false_if( !init_list( batch->list + len, increase_len ) );

    batch->len = new_len;

    uverify( id_valid( id ) );
    return true;
}
Пример #3
0
extern status read_poly( polynomial *p_poly ) {

  /* Read standard input for coefficients and degrees and create a list of terms( a polynomial). Input is terminated when 0,0 is entered */

  int coef, degree ;

  if( init_list( p_poly ) == ERROR ) return ERROR ;

  do {
    printf( "Enter the coefficient, degree (0,0 when done):" ) ;
    scanf( "%d,%d", &coef, &degree ) ; 
    if( coef != 0 ) {
      if( term_insert( p_poly, coef, degree ) == ERROR ) {
	return ERROR ;
      }
    }
  } while (  coef != 0  || degree != 0  ) ;

  return OK ; 

}
Пример #4
0
int main(int argc, char *argv[]) {
     double start, end;
     struct node *p=NULL;
     struct node *temp=NULL;
     struct node *head=NULL;
     
	 printf("Process linked list\n");
     printf("  Each linked list node will be processed by function 'processwork()'\n");
     printf("  Each ll node will compute %d fibonacci numbers beginning with %d\n",N,FS);      
 
     p = init_list(p);
     head = p;

     start = omp_get_wtime();
#pragma omp parallel firstprivate(p)
     {
#pragma omp single
         {
        while (p != NULL) {
#pragma omp task firstprivate(p)
		   processwork(p);
		   p = p->next;
        }
         }
     }

     end = omp_get_wtime();
     p = head;
	 while (p != NULL) {
        printf("%d : %d\n",p->data, p->fibdata);
        temp = p->next;
        free (p);
        p = temp;
     }  
	 free (p);

     printf("Compute Time: %f seconds\n", end - start);

     return 0;
}
Пример #5
0
int main(void)
{
  Node *head = NULL;
  int sel;

  init_list(&head);

  while(1){
    sel=disp_menu();
    if(sel==0) break;
    switch(sel){
      case 1: add_employee(head); break;
      case 2: retrieve_employee(head); break;
      case 3: remove_employee(head); break;
      default: break;
    }
  }
  deallocate_list(head);

  system("pause");
  return 0;
}
Пример #6
0
int main (void)
{
    char *line;
    Variable_List vars;
    
    // intro
    printf("Poseidon C-SHELL\n");
    printf("Please not the current limitations: maximum token length: 12\n");

    init_list(&vars);
    line = (char *)malloc(256);
    
    while(false)
    {
	printf("C-Shell: ");
	fgets(line,256,stdin);

	if(parse_line(&vars, line) == -1)
	    return 0;
    }
    return 0; 
}
Пример #7
0
void load(void){
	FILE* fp;
	register int i;
	
	if((fp = fopen("maillist", "rb")) == NULL){
		printf("Cannot open file. \n");
	}
	
	init_list();

	for(i = 0; i < MAX; i++){
		if(fread(&addr_list[i], sizeof(struct addr), 1, fp) != 1){
			if(feof(fp)){
				break;
			}
			printf("File read error.\n");
		}
	}
	
	fclose(fp);
	
}
Пример #8
0
Файл: batch.c Проект: husthl/qos
// len: it's startup len, when batch list is full ,it will be auto growed up.
// return: batch_id
int batch_open( int len ){
    uverify( 0 < len );

    callback_arg_t* const list = qmalloc( len * sizeof( callback_arg_t ) );
    return_0_if( NULL == list );
    return_0_if( !init_list( list, len ) );

    batch_t* const batch = qmalloc( sizeof( batch_t ) );
    if( NULL == batch ){
        qfree( list );
        uverify(  false );
        return 0;
    }

    batch->list = list;
    batch->len = len;
    batch->num = 0;

    const int id = (int)batch;
    uverify( id_valid( id ) );
    return id;
}
Пример #9
0
int 
main (int argc, char **argv)
{
	GtkWidget *window;

	gtk_init (&argc, &argv);

	gnome_vfs_init();

  	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	init_list (window);
puts("showing...");
	gtk_widget_show (window);

puts("running...");
	gtk_main();
puts("exiting...");
	gtk_exit(0);

	return 0;

}	
Пример #10
0
int __init_text pgt_init(void)
{
	size_t size;
	int i; u32 align;
	struct page *page;
	int count = CONFIG_PGT_PDE_BUFFER_MIN;

	/* this function needed called after mmu is init */
	memset((char *)&pgt_buffer, 0, sizeof(struct pgt_buffer));
	size = PDE_TABLE_SIZE;
	align = PDE_TABLE_ALIGN_SIZE;
	init_list(&pgt_buffer.list);
	spin_lock_init(&pgt_buffer.pgt_lock);

	/* do not alloc buffer if align size is PAGE_SIZE */
	if (align == PAGE_SIZE)
		count = 0;

	/* Boot pde need to be care about */
	page = va_to_page(mmu_get_boot_pde());
	if (page) {
		add_page_to_list_tail(page, &pgt_buffer.list);
		pgt_buffer.alloc_nr++;
		pgt_buffer.nr_free++;
	}

	for (i = 0; i < count; i++) {
		page = get_free_pages_align(page_nr(size),
				align, GFP_PGT);
		if (!page)
			break;

		add_page_to_list_tail(page, &pgt_buffer.list);
		pgt_buffer.alloc_nr++;
		pgt_buffer.nr_free++;
	}

	return 0;
}
Пример #11
0
int main() 
{
  // Allocate memory for a new list
  llist *list = (llist *)malloc(sizeof(llist));
  if (list == NULL) {
    printf("Unable to allocate memory\n");
    exit(1);
  }
  init_list(list);

  int option = 0;
  bool quit = false;

  // Display menu and prompt user for action
  while (!quit) {
    option = prompt_user();
    switch (option) {
      case 1:
	printf("\n\tNumber of elements in list: %d\n", list->length);
	print(list);
	break;
      case 2: test_insert(list);
	break;
      case 3: test_delete(list);
	break;
      case 4: test_search(list);
	break;
      case 5: print_backwards(list);
	break;
      case 6: printf("Bye.\n");
	quit = true;
	break;
    }
  }
  // call function to free memory for entire list
  delete_list(list);

  return 0;
}
Пример #12
0
main()
{
	char c;			/* input character */
	item_type d;		/* input item */
	list *l;		/* list under construction */
	list *tmp;		/* returned list from search */
	list *search_list();
	void insert_list();

	l = init_list();

	while (scanf("%c",&c) != EOF) {
		if (tolower(c) == 'p')
			print_list(l);
		if (tolower(c) == 'i') {
			scanf("%d",&d);
printf("new item: %d\n",d);
			insert_list(&l,d);
		}
		if (tolower(c) == 's') {
			scanf("%d",&d);
			tmp = search_list(l,d);
			if (tmp == NULL) 
				printf("item %d not found\n",d);
			else
				printf("item %d found\n",d);
		}
		if (tolower(c) == 'd') {
			scanf("%d",&d);
                        tmp = search_list(l,d);
                        if (tmp == NULL)
                                printf("item to delete %d not found\n",d);
			else
				printf("item %d deleted\n",d);
			delete_list(&l,d);
		}
	}
}
Пример #13
0
t_listp			*init_env(char **tab)
{
  int			i;
  t_listp		*env;

  i = 0;
  env = init_list();
  if (ins_elem(env, tab[i++], 1) == -1)
    {
      my_rprintf("Error to take the envirronement");
      return (NULL);
    }
  while (tab[i])
    {
      if (ins_elem(env, tab[i++], env->size) == -1)
	{
	  my_rprintf("Error to take the envirronement");
	  return (NULL);
	}
    }
  ins_elem(env, tab[i], env->size);
  return (env);
}
Пример #14
0
int dblLinear(int n) {
  Heap *heap = init_heap(SIZE);
  List *lst = init_list();
  push(heap, 1);
  cons(lst, 1);
  int i = 0;
  while (i < n) {
    int x = pop(heap);
    int y = 2 * x + 1;
    int z = 3 * x + 1;
    if (x > head(lst)) {
      cons(lst, x);
      i++;
    }
    push(heap, y);
    push(heap, z);
  }

  int ans = head(lst);
  free(heap);
  free(lst);
  return ans;
}
Пример #15
0
int get_nameservers(list *servers, const char *def_port)
{
	if (servers == NULL || def_port == NULL) {
		DBG_NULL;
		return KNOT_EINVAL;
	}

	// Initialize list of servers.
	init_list(servers);

	// Read nameservers from resolv file.
	int ret = get_resolv_nameservers(servers, def_port);

	// If found nameservers or error.
	if (ret != 0) {
		return ret;
	// If no nameservers.
	} else {
		server_t *server;

		// Add default ipv6 nameservers.
		server = server_create(DEFAULT_IPV6_NAME, def_port);

		if (server != NULL) {
			add_tail(servers, (node *)server);
		}

		// Add default ipv4 nameservers.
		server = server_create(DEFAULT_IPV4_NAME, def_port);

		if (server != NULL) {
			add_tail(servers, (node *)server);
		}

		return list_size(servers);
	}
}
Пример #16
0
void main (void)
{
  char opcao;
  init_list();
  clrscr();
  for(;;)
  {
     opcao=menu();
     puts("");
     switch(opcao)
     {
       case 'i':
		insere();
		break;
       case 'e':
		exibe();
		break;
       case 'o':
		ordena_por_media_imprime();
		break;
       case 'm':
		maior_menor_media();
		break;
       case 't':
		return;
       case 'a':
		maior_menor_final();
		break;
       case 'c':
		carrega();
		break;
       case 's':
		salva();
		break;
      }
   }
}
Пример #17
0
main()
{
    struct sqlist list;
    printf("Initialize sequence list.\n");
    init_list(&list, 10);
    printf("Insert ten elements and then print the list.\n");
    int i;
    for (i = 0; i < 10; i++)
	list_insert(&list, i, i);
    print_list(&list);
    printf("Insert ten more elements.\n");
    for (i = 10; i < 20; i++)
	list_insert(&list, i, i);
    print_list(&list);
    printf("Locate element '3'.\n");
    printf("%3d\n", locate_element(&list, 3));
    printf("Delete trailing 5 elements.\n");
    for (i = 19; i > 14; i--)
	list_delete(&list, i);
    print_list(&list);
    printf("Finally we destroy the entire list.\n");
    destroy_list(&list);
    return 0;
}
Пример #18
0
int main()
{
	LINKED_LIST *mylist;

	mylist = init_list();
	add_node(mylist,100);
	print_list(mylist);
	add_node(mylist,200);
	print_list(mylist);
	add_node(mylist,300);
	print_list(mylist);
	add_node(mylist,400);
	print_list(mylist);
	add_node(mylist,500);
	print_list(mylist);
	insert_node(mylist,250,200);
	print_list(mylist);
	delete_node(mylist,300);
	print_list(mylist);

	delete_all(mylist);
	
	return 0;
}
Пример #19
0
errcode_t
profile_get_values(profile_t profile, const char *const *names,
		   char ***ret_values)
{
	errcode_t		retval;
	void			*state;
	char			*value;
	struct profile_string_list values;

	if ((retval = profile_iterator_create(profile, names,
					      PROFILE_ITER_RELATIONS_ONLY,
					      &state)))
		return retval;

	if ((retval = init_list(&values)))
		return retval;

	do {
		if ((retval = profile_iterator(&state, 0, &value)))
			goto cleanup;
		if (value)
			add_to_list(&values, value);
	} while (state);

	if (values.num == 0) {
		retval = PROF_NO_RELATION;
		goto cleanup;
	}

	end_list(&values, ret_values);
	return 0;

cleanup:
	end_list(&values, 0);
	return retval;
}
Пример #20
0
//---------------------------------------------------------------------------//
void 
Schema::set(const Schema &schema)
{
    bool init_children = false;
    index_t dt_id = schema.m_dtype.id();
    if (dt_id == DataType::OBJECT_ID)
    {
       init_object();
       init_children = true;

       object_map() = schema.object_map();
       object_order() = schema.object_order();
    } 
    else if (dt_id == DataType::LIST_ID)
    {
       init_list();
       init_children = true;
    }
    else 
    {
        m_dtype = schema.m_dtype;
    }

    
    if (init_children) 
    {
       std::vector<Schema*> &my_children = children();
       const std::vector<Schema*> &their_children = schema.children();
       for (index_t i = 0; i < (index_t)their_children.size(); i++) 
       {
           Schema *child_schema = new Schema(*their_children[i]);
           child_schema->m_parent = this;
           my_children.push_back(child_schema);
       }
    }
}
Пример #21
0
static int
apply_transformation(transformation *tr, json_object *obj, string_list *result)
{
    int status = U1DB_OK;
    string_list *tmp_values = NULL;
    if (tr->next != NULL)
    {
        init_list(&tmp_values);
        status = apply_transformation(tr->next, obj, tmp_values);
        if (status != U1DB_OK)
            goto finish;
        if (tr->args->head != NULL)
        {
            status = ((op_function)tr->op)(result, tmp_values, tr->args);
        } else {
            status = ((op_function)tr->op)(result, tmp_values, NULL);
        }
    } else {
        status = extract_field_values(result, obj, tr->args, tr->value_type);
    }
finish:
    destroy_list(tmp_values);
    return status;
}
Пример #22
0
struct terminal *init_term(int fdin, int fdout, void (*root_window)(struct window *, struct event *, int))
{
    struct terminal *term;
    struct window *win;
    term = mem_alloc(sizeof (struct terminal));
    memset(term, 0, sizeof(struct terminal));
    term->fdin = fdin;
    term->fdout = fdout;
    term->master = term->fdout == get_output_handle();
    /*term->x = 0;
    term->y = 0;
    term->cx = 0;
    term->cy = 0;*/
    term->lcx = -1;
    term->lcy = -1;
    term->dirty = 1;
    term->redrawing = 0;
    term->blocked = -1;
    term->screen = DUMMY;
    term->last_screen = DUMMY;
    term->spec = &dumb_term;
    term->term[0] = 0;
    term->cwd[0] = 0;
    term->input_queue = DUMMY;
    term->qlen = 0;
    init_list(term->windows);
    win = mem_alloc(sizeof (struct window));
    win->handler = root_window;
    win->data = NULL;
    win->term = term;
    add_to_list(term->windows, win);
    /*alloc_term_screen(term, 80, 25);*/
    add_to_list(terminals, term);
    set_handlers(fdin, (void (*)(void *))in_term, NULL, (void (*)(void *))destroy_terminal, term);
    return term;
}
int main(int argc, char *argv[]){

  LIST L;
  int i;
  int cnt = 0;
  position tmp;

  L = init_list();
  for(i=0; i<20; i++)
    insert_list(random(100), L);
    
  print_list(L);
  
  tmp = L->next;
  for(i=0; i<10; i++)
    tmp = tmp->next;
  
  delet_middle(tmp);
  print_list(L);
  
  delet_list(L);

  return 0; 
}
Пример #24
0
int main(int argc, char *argv[])
{
    struct node *file_list;
    struct node *p;
    int max_item_len;

    struct winsize w;
    ioctl(0, TIOCGWINSZ, &w);

    LINE_LEN = w.ws_col;
    printf("Line Length: %d\n", LINE_LEN);

    file_list = init_list();
    file_list->next = NULL;

    printf("argc: %d\n", argc);
    handle_argv(argc, argv);

    printf("a_flag: %d\nr_flag: %d\n", a_flag, r_flag);

    if (argc == 1) {
        do_ls(".", file_list);
    } else {
        while (--argc) {
            printf("%s\n", *++argv);
            if (*argv[0] != '-') {
                do_ls(*argv, file_list);
            }
        }
    }

    //print_list(file_list);
    //printf("Max item length: %d", get_item_max_len(file_list));
    free_list(file_list);
    return 0;
}
Пример #25
0
int main()
{
	HEAD *head;
	int a=15,b=10, c=23;
	int *ptra, *ptrb, *ptrc;

	ptra = &a;
	ptrb = &b;
	ptrc = &c;


	if((head=init_list()) == NULL)
	{
		fprintf(stdout,"Error at list_init()");
		return EXIT_FAILURE;
	}


//	print_list(head);
	append_front(head,ptra);
	print_list(head);
	append_back(head,ptrb);
	print_list(head);
	insert_node(head,head->first,ptrc);
	print_list(head);
	insert_node(head,head->last,ptrc);
	print_list(head);

	printf("DATA: %d\n",*((int*)head->first->data));

	del_node(head, head->first->next);
	print_list(head);

	del_list(head);
	return 0;
}
Пример #26
0
void show_exif_window(GtkWidget* widget, ExifWin * win)
{	
	GError* error = NULL;
	
	const char* current_image = image_list_get_current_file_path(win->mw->img_list);
		
	win->exif_window = (GtkWindow*)gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_resizable (win->exif_window, TRUE);
	gtk_window_set_default_size (win->exif_window, 400, 400);
    gtk_window_set_position(win->exif_window,GTK_WIN_POS_CENTER);
    gtk_window_set_title(win->exif_window, "Exif information");
	
	win->box =  (GtkVBox*)gtk_vbox_new (FALSE,0);
	win->hbox = (GtkHBox*)gtk_hbox_new (FALSE,0);
	
	win->exif_label = (GtkLabel*)gtk_label_new("Exif data");
	gtk_label_set_justify(GTK_LABEL(win->exif_label), GTK_JUSTIFY_CENTER);
    gtk_box_pack_start(GTK_BOX(win->box), (GtkWidget*)win->exif_label, FALSE, FALSE, 5);
	
	win->exif_button = (GtkButton*)gtk_button_new_with_label("Close");

	win->list = gtk_tree_view_new();
    gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(win->list), FALSE);
	
	win->align = gtk_alignment_new( 1,0 ,0,0);
    gtk_container_add( (GtkContainer*)win->align, (GtkWidget*)win->exif_button);
	
	win->scroll = (GtkScrolledWindow*)gtk_scrolled_window_new(NULL,NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(win->scroll),
                				   GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_add_with_viewport(win->scroll, win->list);
	
    gtk_box_pack_start(GTK_BOX(win->box), GTK_WIDGET(win->scroll), TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(win->box), GTK_WIDGET(gtk_hseparator_new()), FALSE, TRUE,0);
	gtk_box_pack_start(GTK_BOX(win->box), GTK_WIDGET(win->hbox), FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(win->hbox),GTK_WIDGET(win->align), TRUE, TRUE,  0);
	
	int Modified = FALSE;
    ReadMode_t ReadMode;
    ReadMode = READ_METADATA;
    CurrentFile = current_image;
    FilesMatched = 1; 

    ResetJpgfile();

    memset(&ImageInfo, 0, sizeof(ImageInfo));
    ImageInfo.FlashUsed = -1;
    ImageInfo.MeteringMode = -1;
    ImageInfo.Whitebalance = -1;
	
	    {
        struct stat st;
        if (stat(current_image, &st) >= 0){
            ImageInfo.FileDateTime = st.st_mtime;
            ImageInfo.FileSize = st.st_size;
        }else{
            printf("No such file");
        }
    }
	
	if (current_image == NULL)
		return;
	
	strncpy(ImageInfo.FileName, current_image, PATH_MAX);  
		
    if (!ReadJpegFile(current_image, READ_METADATA)) return;

	DoModify = TRUE;
	Modified = TRUE;
    ReadMode = READ_IMAGE;

    if (!ReadJpegFile(current_image, ReadMode)) return;

	create_EXIF();
    CheckFileSkip();
	ShowTags = TRUE;
	ShowConciseImageInfo();
    ShowImageInfo(TRUE);

	
	char  buf[35];
	char  buf1[35];
	char  buf2[35];
	char  buf3[35];
	char  buf4[35];
	char  buf5[35];
	char  buf6[35];
	char  buf7[35];
	char  buf8[35];
	char  buf9[35];
	char buf10[35];
	
	char* size = itoa(ImageInfo.FileSize,buf);
	
	char* width = itoa(ImageInfo.Width, buf1);
	char* height = itoa(ImageInfo.Height, buf2);
	
	char Temp[20];
    FileTimeAsString(Temp);
	
	const char* largest_offset = itoa(ImageInfo.LargestExifOffset, buf3);
	const char* thumbnail_size    = itoa(ImageInfo.ThumbnailSize, buf4);
	const char* ThumbnailOffset   = itoa(ImageInfo.ThumbnailOffset, buf5);
	const char* image_xdensity    = itoa(ImageInfo.JfifHeader.XDensity, buf6);
	const char* image_ydensity    = itoa(ImageInfo.JfifHeader.XDensity, buf7);
	const char* zoom              = itoa(ImageInfo.DigitalZoomRatio, buf8);
	const char* iso               = itoa(ImageInfo.ISOequivalent, buf9);
	const char* distance          = itoa(ImageInfo.DistanceRange, buf10);
	
    float value = ImageInfo.ExposureTime; 
	char *str = (char*)malloc(20);
	sprintf(str, "%f\n", value);
	
	float value2 = ImageInfo.ApertureFNumber;
	char *str2   = (char*)malloc(20);
	sprintf(str2, "f/%3.1f" , value2); 
	
	float value3 = ImageInfo.FocalLength35mmEquiv;
	char *str3   = (char*)malloc(20);
	sprintf(str3, "f(35)=%dmm" , value3); 
	
	init_list(win->list);

	add_to_list(win->list, "File name:   ", ImageInfo.FileName);
	add_to_list(win->list, "File size (bytes)   :", size);
	add_to_list(win->list, "File date:   ", Temp);
	
	if (ImageInfo.CameraMake[0]){
	    add_to_list(win->list, "Camera make:   ", ImageInfo.CameraMake);
	    add_to_list(win->list, "Camer model:   ", ImageInfo.CameraModel);
    }

	add_to_list(win->list, "Date time:   ", ctime(&ImageInfo.FileDateTime));
	
	if (ImageInfo.IsColor == 0)
	{
        add_to_list(win->list, "Color/bw:   ", "Black and White");
    }
	else
	{
	    add_to_list(win->list, "Color/bw:   ", "Non Black and White");
	}
	
	add_to_list(win->list, "Image type   :", "image/jpg");
	
	add_to_list(win->list, "Image Width:   ", width);
	add_to_list(win->list, "Image Height:   ",height);
	
    add_to_list(win->list, "Largest Exif Offset:   ", largest_offset);
    
	add_to_list(win->list, "Thumbnail size:   ", thumbnail_size);
	add_to_list(win->list, "Thumbnail offset:   ", ThumbnailOffset);
	
	add_to_list(win->list, "Image comments:   ", ImageInfo.Comments);
	
	add_to_list(win->list, "Image X Density:   ",image_xdensity);
	add_to_list(win->list, "Image Y Density:   ", image_xdensity);
	
	add_to_list(win->list, "Digital zoom ratio:   ", zoom);
	
	if (ImageInfo.FlashUsed > 0)
		add_to_list(win->list, "Flash used:   ", "yes");
	else
		add_to_list(win->list, "Flash used:   ", "No");
	
	add_to_list(win->list, "Exposure Time (s):   ", str);
	add_to_list(win->list, "Aperture FNumber:   ", str2);
	add_to_list(win->list, "Focal Length 35mm Equiv:   ", str3);
	add_to_list(win->list, "ISOequivalent:   ", iso);
	add_to_list(win->list, "Distance range:   ", distance);
	
	switch(ImageInfo.ExposureProgram)
	{
	    case 1:
            add_to_list(win->list, "Expusure:   ", "manual");
            break;
        case 2:
		    add_to_list(win->list, "Expusure:   ", "program (auto)");
            break;
        case 3:
			add_to_list(win->list, "Expusure:   ", "aperture priority (semi-auto)");
            break;
        case 4:
		    add_to_list(win->list, "Expusure:   ", "shutter priority (semi-auto)");
            break;
        case 5:
	    	add_to_list(win->list, "Expusure:   ", "Creative Program (based towards depth of field)");
            break;
        case 6:
		    add_to_list(win->list, "Expusure:   ", "Action program (based towards fast shutter speed)");
            break;
        case 7:
			add_to_list(win->list, "Expusure:   ", "Portrait Mode");
            break;
        case 8:
		    add_to_list(win->list, "Expusure:   ", "LandscapeMode");
            break;
        default:
            break;
	}
	
	if (ImageInfo.MeteringMode > 0)\
	   {
             switch(ImageInfo.MeteringMode) 
		     {
                case 1:
				     add_to_list(win->list, "Metering Mode:   ", "average");
					 break;
                case 2: 
				     add_to_list(win->list, "Metering Mode:   ", "center weight");
					 break;
                case 3:
				     add_to_list(win->list, "Metering Mode:   ", "spot");
					 break;
                case 4:
				     add_to_list(win->list, "Metering Mode:   ", "multi spot");
					 break;
                case 5: 
				     add_to_list(win->list, "Metering Mode:   ", "pattern");
					 break;
                case 6: 
					 printf("partial\n"); 
					 break;
                case 255:
					 printf("other\n");
					 break;
                default: 
					 printf("unknown (%d)\n",ImageInfo.MeteringMode); 
					 break;
             }
	    }
	
	g_signal_connect( win->exif_button, "clicked", G_CALLBACK(on_close), win );
	
	
	gtk_container_add(GTK_CONTAINER(win->exif_window), GTK_WIDGET(win->box));
	gtk_widget_show_all((GtkWidget*)win->exif_window);
	
	g_free(str);
	g_free(str2);
	g_free(str3);
}
Пример #27
0
int main(void) {
	list_t * list1 = init_list();
	node_t * node1 = 
}
Пример #28
0
struct tree *cast(data_type type, struct tree *t) {
	if (type == INT) {
		switch (t->type) {
			case INT:
				break;
			case DOUBLE:
				t->data.i = (int)t->data.d;
				break;
			case CHAR:
				t->data.i = (int)t->data.c;
				break;
			default:
				t->data.i = 0;
		}
		t->type = INT;
				

}

struct tree* inc_refcount(struct tree *t) {
	if (t) {
		t->refcount++;
	}

	return t;
}

struct tree *dec_refcount(struct tree *t) {
	if (t) {
		if (--(t->refcount) <= 0) {
			free_tree(t);
			t = NULL;
		}
	}

	return t;
}

struct tree *sub(struct tree *lhs, struct tree *rhs) {
	struct tree *retval;

	inc_refcount(lhs);
	inc_refcount(rhs);

	if (lhs->type != rhs->type) {
		retval = NULL;
	} else {
		switch (lhs->type) {
			case CHAR:
				retval = char_treemake(lhs->data.c - rhs->data.c, NULL);
				break;
			case INT:
				retval =  int_treemake(lhs->data.i - rhs->data.i, NULL);
				break;
			case DOUBLE:
				retval =  double_treemake(lhs->data.d - rhs->data.d, NULL);
				break;
			default:	
				retval =  NULL;
		}
	}

	dec_refcount(rhs);
	dec_refcount(lhs);

	return retval;
}
struct tree *add(struct tree *lhs, struct tree *rhs) {
	struct tree *retval;

	inc_refcount(lhs);
	inc_refcount(rhs);

	if (lhs->type != rhs->type) {
		retval = NULL;
	} else {
		switch (lhs->type) {
			case CHAR:
				retval = char_treemake(lhs->data.c + rhs->data.c, NULL);
				break;
			case INT:
				retval =  int_treemake(lhs->data.i + rhs->data.i, NULL);
				break;
			case DOUBLE:
				retval =  double_treemake(lhs->data.d + rhs->data.d, NULL);
				break;
			default:	
				retval =  NULL;
		}
	}

	dec_refcount(rhs);
	dec_refcount(lhs);

	return retval;
}

struct tree *mult(struct tree *lhs, struct tree *rhs) {
	struct tree *retval;

	inc_refcount(lhs);
	inc_refcount(rhs);

	if (lhs->type != rhs->type) {
		retval = NULL;
	} else {
		switch (lhs->type) {
			case CHAR:
				retval = char_treemake(lhs->data.c * rhs->data.c, NULL);
				break;
			case INT:
				retval =  int_treemake(lhs->data.i * rhs->data.i, NULL);
				break;
			case DOUBLE:
				retval =  double_treemake(lhs->data.d * rhs->data.d, NULL);
				break;
			default:	
				retval =  NULL;
		}
	}

	dec_refcount(rhs);
	dec_refcount(lhs);

	return retval;

}

struct tree *divd(struct tree *lhs, struct tree *rhs) {
	struct tree *retval;

	inc_refcount(lhs);
	inc_refcount(rhs);

	if (lhs->type != rhs->type) {
		retval = NULL;
	} else {
		switch (lhs->type) {
			case CHAR:
				retval = char_treemake(lhs->data.c / rhs->data.c, NULL);
				break;
			case INT:
				retval =  int_treemake(lhs->data.i / rhs->data.i, NULL);
				break;
			case DOUBLE:
				retval =  double_treemake(lhs->data.d / rhs->data.d, NULL);
				break;
			default:	
				retval =  NULL;
		}
	}

	dec_refcount(rhs);
	dec_refcount(lhs);

	return retval;
}

struct tree *mod(struct tree *lhs, struct tree *rhs) {
	struct tree *retval;

	inc_refcount(lhs);
	inc_refcount(rhs);

	if (lhs->type != rhs->type) {
		retval = NULL;
	} else {
		switch (lhs->type) {
			case CHAR:
				retval = char_treemake(lhs->data.c % rhs->data.c, NULL);
				break;
			case INT:
				retval =  int_treemake(lhs->data.i % rhs->data.i, NULL);
				break;
			default:	
				retval =  NULL;
		}
	}

	dec_refcount(rhs);
	dec_refcount(lhs);

	return retval;
}
void init_tree(struct tree *root) {
	root->children = malloc(sizeof(struct List));
	root->type = VOID;
	root->width = 0;
	root->refcount = 0;
	init_list(root->children);
}
Пример #29
0
int main(int argc, char **argv)
{
	int i, modus=0;
	char *filepath_source = NULL,*filepath_result = NULL;
	HEAD *list_pt;
	//Read programm parameters

	if(argc <= 1)
        {
                fprintf(stderr,"To few options for function!");
                return EXIT_FAILURE;
        }

	for(i=1;i<argc;i++)
        {
                if(strcmp(argv[i],"-f") == 0) //Sourcefile path
                {
			filepath_source = (char*) malloc(strlen(argv[i]));

                        if(i+1 < argc)
			{
				i++;
				filepath_source = argv[i];
			}else
			{
		                fprintf(stderr,"To few arguments for option '-f'!");
			}

                }else if(strcmp(argv[i],"-o") == 0) //Option if Output should be stored in File
                {
                        filepath_result = (char*) malloc(strlen(argv[i]));
                        modus = 1;

                        if(i+1 < argc)
			{
				i++;
				filepath_result = argv[i];
			}else
			{
				strcpy(filepath_result,"output.txt");
			}

                }else if(strcmp(argv[i],"--help") == 0) //Option that show help text
                {
                        printf("\n\n-- txt_analyse -- \n  is designed to provide a List of the words contained in a Text and how often they appear.\n");
			printf("\n\nOPTIONS\n");
			printf("   -f path of textfile wich should be analysed\n");
			printf("   -o path of the output file where results will be stored\n");
			printf("\n\n   if there is no name present after -o the standard output file is 'output.txt'\n");
			printf("   if option '-o' is not provided output will be on 'stdout'\n");
			printf("\nEXAMPLE\n");
			printf("   ./txt_analyse -f input_text.txt -o result.txt\n\n\n");
			return EXIT_SUCCESS;
                }

        }

	if((list_pt = init_list()) == NULL) 
	{
		fprintf(stderr,"Failed to init List Header\n");
		return EXIT_FAILURE;
	}
	if(txt_analyse(list_pt,filepath_source) == EXIT_FAILURE)
	{
		fprintf(stderr,"Failed to analyse text\n");
		return EXIT_FAILURE;
	}

//	print_list(list_pt);

	print_result(list_pt,modus,filepath_result);

	del_list(list_pt);
	return EXIT_SUCCESS;
}
Пример #30
0
int main() {
	struct keyval kvlist;

	init_list(&kvlist);

}