bittuthegr8 1 Newbie Poster

hi my computer fried cause of a circut overload and i really need a program to be compiled. could someone compile this for windows 32

#include <stdio.h>
#include <sys/types.h>
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
#include <gtk/gtk.h>
#include <pthread.h>
#include <math.h>
GtkWidget *progress_bars[999], *list_labels[999][10], *list, *list_items[999], *list_items_table[999], *list_labels_vboxes[999], *list_scrolled_window, *abort_buttons[999], *dl_table;
int okay[999];
CURL *c[999];
pthread_t threads[999];
int list_items_nr=-1;
int prog(int pos, double t, double d, double ut, double ud)
{
	if(okay[pos]==1)
	{
		char p_text[10];
		char status_info[999];
		char type_all[5], type_current[5];
		double p;
		int real_p;
		int size_all, size_current;
		p = (d/t);
		real_p = p*100;
		gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bars[pos]), p);

		size_all = t;
		if(size_all>1024)
		{
			size_all = size_all / 1024;
			strcpy(type_all, "KB");
			if(size_all>1024)
			{
				size_all = size_all / 1024;
				strcpy(type_all, "MB");
				if(size_all>1024)
				{
					size_all = size_all / 1024;
					strcpy(type_all, "GB");
				}

			}
		}
		else
		{
			strcpy(type_all, "B");
		}
		size_current = d;
		if(size_current>1024)
		{
			size_current = size_current / 1024;
			strcpy(type_current, "KB");
			if(size_current>1024)
			{
				size_current = size_current / 1024;
				strcpy(type_current, "MB");
				if(size_current>1024)
				{
					size_current = size_current / 1024;
					strcpy(type_current, "GB");
				}

			}
		}
		else
		{
			strcpy(type_current, "B");
		}
		sprintf(status_info, "%d%s of %d%s",size_current,type_current,size_all,type_all);

		sprintf(p_text, "%d%%", real_p);
		gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress_bars[pos]), p_text);
		gtk_label_set_text(GTK_LABEL(list_labels[pos][2]), status_info);
		return 0;
	}
	else
	{
		gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress_bars[pos]), "Aborted!");

		return -1;
	}

}
static void abort_download(GtkWidget *widget, int nr)
{

	okay[nr] = 0;

}
int *do_download(char data[3][9999])
{
	FILE *fp;
		fp = fopen(data[1], "w");
		c[list_items_nr] = curl_easy_init();
		curl_easy_setopt(c[list_items_nr], CURLOPT_PROGRESSFUNCTION, prog);
		curl_easy_setopt(c[list_items_nr], CURLOPT_PROGRESSDATA, list_items_nr);

		curl_easy_setopt(c[list_items_nr], CURLOPT_URL, data[0]);
		curl_easy_setopt(c[list_items_nr], CURLOPT_WRITEDATA, fp);
		curl_easy_setopt(c[list_items_nr], CURLOPT_NOPROGRESS, 0);


		curl_easy_perform(c[list_items_nr]);
		curl_easy_cleanup(c[list_items_nr]);
		fclose(fp);
	return 0;
}

static void download(GtkWidget *widget, GtkWidget *widgets[])
{
	char *url, *target;
	char data[3][9999];
	char message[999];
	char status_info[999];
	//GList *il=NULL;
	list_items_nr = list_items_nr + 1;

	strcpy(data[0], gtk_entry_get_text(GTK_ENTRY(widgets[0])));
	strcpy(data[1], gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widgets[1])));


	//list_items[list_items_nr] = gtk_list_item_new();
	//list_items_table[list_items_nr] = gtk_table_new(3, 3, FALSE);

	progress_bars[list_items_nr] = gtk_progress_bar_new();
	abort_buttons[list_items_nr] = gtk_button_new_with_label("Abort Download!");
	gtk_signal_connect(GTK_OBJECT(abort_buttons[list_items_nr]), "clicked", G_CALLBACK(abort_download), list_items_nr);


	list_labels[list_items_nr][0] = gtk_label_new(data[0]);
	list_labels[list_items_nr][1] = gtk_label_new(data[1]);
	list_labels[list_items_nr][2] = gtk_label_new("");

	list_labels_vboxes[list_items_nr] = gtk_vbox_new(FALSE, 0);

	gtk_box_pack_start(GTK_BOX(list_labels_vboxes[list_items_nr]), list_labels[list_items_nr][0], TRUE, TRUE, 0);	
	gtk_box_pack_start(GTK_BOX(list_labels_vboxes[list_items_nr]), list_labels[list_items_nr][1], TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(list_labels_vboxes[list_items_nr]), list_labels[list_items_nr][2], TRUE, TRUE, 0);


	//gtk_table_attach_defaults(GTK_TABLE(list_items_table[list_items_nr]), progress_bars[list_items_nr], 0, 1, 0, 3);
	//gtk_table_attach_defaults(GTK_TABLE(list_items_table[list_items_nr]), list_labels[list_items_nr][0], 1, 2, 0, 1);
	//gtk_table_attach_defaults(GTK_TABLE(list_items_table[list_items_nr]), list_labels[list_items_nr][1], 1, 2, 1, 2);
	//gtk_table_attach_defaults(GTK_TABLE(list_items_table[list_items_nr]), list_labels[list_items_nr][2], 1, 2, 2, 3);
	//gtk_table_attach_defaults(GTK_TABLE(list_items_table[list_items_nr]), abort_buttons[list_items_nr], 2, 3, 0, 3);

	gtk_table_attach_defaults(GTK_TABLE(dl_table), progress_bars[list_items_nr], 0, 1, list_items_nr, list_items_nr+1);
	gtk_table_attach_defaults(GTK_TABLE(dl_table), list_labels_vboxes[list_items_nr], 1, 2, list_items_nr, list_items_nr+1);
	
	gtk_table_attach_defaults(GTK_TABLE(dl_table), abort_buttons[list_items_nr], 2, 3, list_items_nr, list_items_nr+1);


	// gtk_container_add(GTK_CONTAINER(list_items[list_items_nr]), list_items_table[list_items_nr]);
	
	// il = g_list_prepend(il, list_items[list_items_nr]);
	// gtk_list_prepend_items(GTK_LIST(list), il);


	//gtk_widget_show(list_items[list_items_nr]);
	gtk_widget_show(progress_bars[list_items_nr]);
	gtk_widget_show(list_labels[list_items_nr][0]);
	gtk_widget_show(list_labels[list_items_nr][1]);
	gtk_widget_show(list_labels[list_items_nr][2]);
	gtk_widget_show(list_labels_vboxes[list_items_nr]);
	//gtk_widget_show(list_items_table[list_items_nr]);
	gtk_widget_show(abort_buttons[list_items_nr]);

	okay[list_items_nr] = 1;	

	threads[list_items_nr] = pthread_create(&threads[list_items_nr], NULL, &do_download, data);
}
static void destroy(GtkWidget *widget, gpointer *cb)
{
	gtk_main_quit();
	exit(0);
}
static void show_file_chooser(GtkWidget *widget, GtkWidget *file_chooser_dialog)
{
	gtk_widget_show(file_chooser_dialog);
}
static void hide_aborted_downloads(GtkWidget *widget, gpointer *callback_data)
{
	int i;
	for(i=0;i<list_items_nr+1;i++)
	{
		if(okay[i]==0||gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(progress_bars[i]))==1)
		{
			gtk_widget_hide(list_labels_vboxes[i]);
			gtk_widget_hide(progress_bars[i]);
			gtk_widget_hide(abort_buttons[i]);
		}
	}
}
int main(int argc, char *argv[])
{
	GtkWidget  *hbox_url, *url_label, *url_entry, *hbox_target,  *vbox, *start_button, *file_chooser, *h_separator, *global_hbox, *global_vbox, *h_separator2, *label_data[30], *window, *hide_aborted_button, *target_label;

	gtk_init(&argc, &argv);

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	//gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
	hbox_url = gtk_hbox_new(FALSE, 5);
	global_hbox = gtk_hbox_new(FALSE, 5);
	global_vbox = gtk_vbox_new(FALSE, 5);
	vbox = gtk_vbox_new(FALSE, 5);
	hbox_target = gtk_hbox_new(FALSE, 5);
	url_label = gtk_label_new("Source URL:");
	target_label = gtk_label_new("Target:");
	url_entry = gtk_entry_new();
	file_chooser = gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_SAVE);
	h_separator = gtk_hseparator_new();	
	h_separator2 = gtk_hseparator_new();	
	start_button = gtk_button_new_with_label("Start download!");
	//list = gtk_list_new();
	dl_table = gtk_table_new(3, 3, FALSE);
	list_scrolled_window = gtk_scrolled_window_new(NULL, NULL);
	hide_aborted_button = gtk_button_new_with_label("Hide aborted and finished Downloads!");
	gtk_signal_connect(GTK_OBJECT(hide_aborted_button), "clicked", G_CALLBACK(hide_aborted_downloads), NULL);
	// gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(list_scrolled_window), list);
	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(list_scrolled_window), dl_table);

	label_data[0] = url_entry;
	label_data[1] = file_chooser;

	gtk_signal_connect(GTK_OBJECT(start_button), "clicked", G_CALLBACK(download), label_data);

	gtk_box_pack_start_defaults(GTK_BOX(hbox_target), file_chooser);



	gtk_box_pack_start(GTK_BOX(vbox), url_label, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), url_entry, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), h_separator, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), target_label, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox_target, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), h_separator2, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), start_button, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), list_scrolled_window, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hide_aborted_button, FALSE, FALSE, 0);

	gtk_box_pack_start(GTK_BOX(global_hbox), vbox, TRUE, TRUE, 0);	
	gtk_box_pack_start(GTK_BOX(global_vbox), global_hbox, TRUE, TRUE, 0);	

	gtk_container_add(GTK_CONTAINER(window), global_vbox);
	gtk_window_set_title(GTK_WINDOW(window), "gCurl");


	gtk_widget_show(window);
	gtk_widget_show(vbox);
	gtk_widget_show(hbox_target);
	gtk_widget_show(url_label);
	gtk_widget_show(target_label);
	gtk_widget_show(hbox_url);
	gtk_widget_show(file_chooser);
	gtk_widget_show(h_separator);
	gtk_widget_show(h_separator2);
	gtk_widget_show(url_entry);
	gtk_widget_show(global_hbox);
	gtk_widget_show(global_vbox);
	gtk_widget_show(start_button);
	gtk_widget_show(hide_aborted_button);
	//gtk_widget_show(list);
	gtk_widget_show(dl_table);
	gtk_widget_show(list_scrolled_window);
	
	gtk_signal_connect(GTK_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL);

	gtk_main();
	return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.