1 #include <glib-object.h>
3 #include <gmyth/gmyth.h>
8 main (int args, const char **argv)
10 const char *uri = argv[1];
11 GMythURI *gmyth_uri = NULL;
13 GMythBackendInfo *backend_info = NULL;
17 fprintf(stdout, SYNC_STRING);
21 backend_info = gmyth_backend_info_new ();
22 gmyth_uri = gmyth_uri_new_with_value (uri);
24 gmyth_backend_info_set_hostname (backend_info, gmyth_uri_get_host (gmyth_uri));
25 gmyth_backend_info_set_port (backend_info, gmyth_uri_get_port (gmyth_uri));
27 res = gmyth_util_file_exists (backend_info, uri);
29 g_debug ("file not exists");
32 GMythFileTransfer *file_transfer = gmyth_file_transfer_new (backend_info);
33 GString *hostname = g_string_new (uri);
34 res = gmyth_file_transfer_open (file_transfer, uri);
36 g_debug ("Fail to open server");
40 gint64 filesize = gmyth_file_transfer_get_filesize (file_transfer);
42 g_debug ("filesize is 0");
46 GByteArray *data = g_byte_array_new ();
47 guint num = gmyth_file_transfer_read (file_transfer, data, filesize, FALSE);
48 g_debug ("read %d bytes", num);
51 g_byte_array_free (data, TRUE);
52 if ( file_transfer != NULL )
53 g_object_unref (file_transfer);
54 if ( gmyth_uri != NULL )
55 g_object_unref (gmyth_uri);
56 if ( hostname != NULL )
57 g_string_free (hostname, TRUE);