[fix] changed path to app to julian's home instate oft tobias's should change that completly

This commit is contained in:
Julian Sparber
2017-08-15 12:00:21 +02:00
parent 3cdafec827
commit cc74445f13
5 changed files with 79 additions and 41 deletions

View File

@@ -24,16 +24,6 @@ finished (SoupSession *session, SoupMessage *msg, gpointer loop)
g_main_loop_quit (loop);
}
char*
concat(const char *s1, const char *s2)
{
char *result = malloc(strlen(s1)+strlen(s2)+1);//+1 for the zero-terminator
//in real code you would check for errors in malloc here
strcpy(result, s1);
strcat(result, s2);
return result;
}
int
get (char *url, const gchar *output_file_path)
{
@@ -59,9 +49,9 @@ get (char *url, const gchar *output_file_path)
loop = g_main_loop_new (NULL, TRUE);
const char *name;
SoupMessage *msg;
const char *header;
const char *name;
FILE *output_file = NULL;
msg = soup_message_new ("GET", url);
@@ -80,18 +70,23 @@ get (char *url, const gchar *output_file_path)
if (SOUP_STATUS_IS_REDIRECTION (msg->status_code)) {
g_print ("%s: %d %s\n", name, msg->status_code, msg->reason_phrase);
} else if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
g_print ("###########Name: %s\n", concat(output_file_path, name));
output_file = fopen (concat(output_file_path, "name"), "w");
if (!output_file)
g_printerr ("Error trying to create file %s.\n", output_file_path);
//if there is no file name and path the page will not get saved
if (output_file_path == NULL) {
g_print ("Got a file offered form a other peer. Will not save anything.\n");
}
else {
output_file = fopen (output_file_path, "w");
if (!output_file)
g_printerr ("Error trying to create file %s.\n", output_file_path);
if (output_file) {
fwrite (msg->response_body->data,
1,
msg->response_body->length,
output_file);
if (output_file) {
fwrite (msg->response_body->data,
1,
msg->response_body->length,
output_file);
fclose (output_file);
fclose (output_file);
}
}
}
@@ -100,20 +95,17 @@ get (char *url, const gchar *output_file_path)
return 0;
}
//int do_get_request (char * url)
int do_client_notify (char * url)
{
//url and absoulte path to download dir
//get ("http://juliansparber.com/index.html", "./test_download");
get (g_strdup(url),"./test_download");
get (g_strdup(url), NULL);
return 0;
}
int do_downloading (char * url)
int do_downloading (char * url, char * file_name)
{
g_print("Downloading url %s\n", url);
//get (g_strdup(url),"./test_download");
get ("http://juliansparber.com/index.html", "./test_download");
//get ("http://juliansparber.com/index.html", "./test_download");
return 0;
}
@@ -121,5 +113,5 @@ int do_downloading (char * url)
/*int main () {
get ("http://juliansparber.com/index.html", "./test_download");
return 0;
}
*/
}
*/