/*****************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* $Id$
#include <curl/types.h> /* new for v7 */
#include <curl/easy.h> /* new for v7 */
-#include <pthread.h>
-
GtkWidget *Bar;
+size_t my_write_func(void *ptr, size_t size, size_t nmemb, FILE *stream)
+{
+ return fwrite(ptr, size, nmemb, stream);
+}
+
size_t my_read_func(void *ptr, size_t size, size_t nmemb, FILE *stream)
{
return fread(ptr, size, nmemb, stream);
CURLcode res;
FILE *outfile;
gchar *url = ptr;
-
+
curl = curl_easy_init();
if(curl)
{
- outfile = fopen("/tmp/test.curl", "w");
+ outfile = fopen("test.curl", "w");
curl_easy_setopt(curl, CURLOPT_URL, url);
- curl_easy_setopt(curl, CURLOPT_FILE, outfile);
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile);
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_write_func);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, my_read_func);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, FALSE);
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, my_progress_func);
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, Bar);
-
+
res = curl_easy_perform(curl);
fclose(outfile);
/* always cleanup */
curl_easy_cleanup(curl);
}
+
return NULL;
}
{
GtkWidget *Window, *Frame, *Frame2;
GtkAdjustment *adj;
- pthread_t curl_tid;
/* Init thread */
g_thread_init(NULL);
-
+
gtk_init(&argc, &argv);
Window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
Frame = gtk_frame_new(NULL);
gtk_container_add(GTK_CONTAINER(Frame2), Bar);
gtk_widget_show_all(Window);
- pthread_create(&curl_tid, NULL, curl_thread, argv[1]);
-
+ if (!g_thread_create(&curl_thread, argv[1], FALSE, NULL) != 0)
+ g_warning("can't create the thread");
+
+
gdk_threads_enter();
gtk_main();
gdk_threads_leave();