*
*/
-#include <unistd.h>
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <curl/curl.h>
static gchar *cookie_fn = "cookies.txt";
const gchar *viking_dir = a_get_viking_dir();
cookie_file = g_build_filename(viking_dir, cookie_fn, NULL);
- unlink(cookie_file);
+ g_unlink(cookie_file);
return NULL;
}
g_assert(cookie_file != NULL);
g_mutex_lock(mutex);
- if (access(cookie_file, F_OK)) { /* file not there */
+ if (g_file_test(cookie_file, G_FILE_TEST_EXISTS) == FALSE) { /* file not there */
FILE * out_file = fopen("/dev/null", "w");
CURLcode res;
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_COOKIEJAR, cookie_file);
res = curl_easy_perform(curl);
if (res != CURLE_OK) {
- g_warning("%s() Curl perform failed: %s\n", __PRETTY_FUNCTION__,
+ g_warning(_("%s() Curl perform failed: %s"), __PRETTY_FUNCTION__,
curl_easy_strerror(res));
- unlink(cookie_file);
+ g_unlink(cookie_file);
}
curl_easy_cleanup(curl);
}
return(res);
}
-int curl_download_get_url ( const char *hostname, const char *uri, FILE *f, DownloadOptions *options )
+int curl_download_get_url ( const char *hostname, const char *uri, FILE *f, DownloadOptions *options, gboolean ftp )
{
int ret;
gchar *full = NULL;
/* Compose the full url */
- full = g_strdup_printf ( "http://%s%s", hostname, uri );
+ full = g_strdup_printf ( "%s://%s%s", (ftp?"ftp":"http"), hostname, uri );
ret = curl_download_uri ( full, f, options );
g_free ( full );
full = NULL;