diff -r 28c358053693 -r 8aa32fa19a8f branches/gmyth-0.1b/tests/main.c --- a/branches/gmyth-0.1b/tests/main.c Wed Feb 14 23:06:17 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -#include -#include "gmyth.h" - -int -main (int args, const char **argv) -{ - const char *uri = argv[1]; - GMythURI *gmyth_uri = NULL; - gboolean res; - GMythBackendInfo *backend_info; - g_type_init (); - g_thread_init (NULL); - - backend_info = gmyth_backend_info_new (); - gmyth_uri = gmyth_uri_new_with_value (uri); - - gmyth_backend_info_set_hostname (backend_info, gmyth_uri_get_host (gmyth_uri)); - gmyth_backend_info_set_port (backend_info, gmyth_uri_get_port (gmyth_uri)); - - res = gmyth_util_file_exists (backend_info, uri); - if (res == FALSE) { - g_debug ("file not exists"); - return -1; - } - GMythFileTransfer *file_transfer = gmyth_file_transfer_new (); - GString *hostname = g_string_new (uri); - res = gmyth_file_transfer_open (file_transfer, hostname); - if (res == FALSE) { - g_debug ("Fail to open server"); - return -1; - } - - guint64 filesize = gmyth_file_transfer_get_filesize (file_transfer); - if (filesize <= 0) { - g_debug ("filesize is 0"); - return -1; - } - - GByteArray *data = g_byte_array_new (); - guint num = gmyth_file_transfer_read (file_transfer, data, filesize, FALSE); - g_debug ("read %d bytes", num); - - g_byte_array_free (data, TRUE); - g_object_unref (file_transfer); - g_object_unref (gmyth_uri); - g_string_free (hostname, TRUE); - - return 0; -}