[svn r30] Some fixes to the string list - append_uint64 couldn't put the right MythTV offset format.
1.1 --- a/gmyth/src/gmyth_socket.c Mon Oct 09 19:31:49 2006 +0100
1.2 +++ b/gmyth/src/gmyth_socket.c Wed Oct 11 22:46:27 2006 +0100
1.3 @@ -125,7 +125,6 @@
1.4 g_static_mutex_lock( &mutex );
1.5
1.6 gethostname(localhostname, 1024);
1.7 -
1.8 gint err = gmyth_socket_toaddrinfo( localhostname, -1, &addr_info_data );
1.9
1.10 addr_info0 = addr_info_data;
1.11 @@ -149,11 +148,11 @@
1.12
1.13 if ( found_addr == FALSE ) {
1.14 g_warning("[%s] Could not determine the local hostname address. Setting to %s\n",
1.15 - __FUNCTION__, localaddr );
1.16 - if ( localaddr != NULL )
1.17 - str = g_string_assign( str, localaddr );
1.18 - else
1.19 - str = g_string_assign( str, "127.0.0.1" );
1.20 + __FUNCTION__, localhostname );
1.21 + //if ( localaddr != NULL )
1.22 + // str = g_string_assign( str, localaddr );
1.23 + //else
1.24 + str = g_string_assign( str, g_strdup( localhostname ) );
1.25 }
1.26
1.27 g_static_mutex_unlock( &mutex );
1.28 @@ -331,7 +330,7 @@
1.29 * @param command The string command to be sent.
1.30 */
1.31 gboolean
1.32 -gmyth_socket_send_command(GMythSocket *gmyth_socket, GString *command)
1.33 +gmyth_socket_send_command(GMythSocket *gmyth_socket, const GString *command)
1.34 {
1.35 gboolean ret = TRUE;
1.36
1.37 @@ -342,14 +341,14 @@
1.38
1.39 gsize bytes_written = 0;
1.40
1.41 - if( command == NULL || ( command->len <= 0 ) ) {
1.42 + if( command == NULL || ( command->len <= 0 ) || command->str == NULL ) {
1.43 g_warning ("[%s] Invalid NULL command parameter!\n", __FUNCTION__);
1.44 ret = FALSE;
1.45 goto done;
1.46 }
1.47
1.48 g_static_mutex_lock( &mutex );
1.49 - g_debug ("[%s] Sending command to backend: %s\n", __FUNCTION__, command->str);
1.50 + g_print ("[%s] Sending command to backend: %s\n", __FUNCTION__, command->str);
1.51
1.52 /*
1.53 io_cond = g_io_channel_get_buffer_condition( gmyth_socket->sd_io_ch );
1.54 @@ -650,6 +649,8 @@
1.55
1.56 g_static_mutex_unlock( &mutex );
1.57
1.58 + g_print( "[%s]\t\tSending the String list = %s\n", __FUNCTION__, str_array );
1.59 +
1.60 // Sends message to backend
1.61 // TODO: implement looping to send remaining data, and add timeout testing!
1.62 gmyth_socket_send_command(gmyth_socket, g_string_new(str_array));
2.1 --- a/gmyth/src/gmyth_socket.h Mon Oct 09 19:31:49 2006 +0100
2.2 +++ b/gmyth/src/gmyth_socket.h Wed Oct 11 22:46:27 2006 +0100
2.3 @@ -87,7 +87,7 @@
2.4 gboolean gmyth_socket_is_able_to_write (GMythSocket *gmyth_socket );
2.5
2.6 gboolean gmyth_socket_send_command (GMythSocket *gmyth_socket,
2.7 - GString *command);
2.8 + const GString *command);
2.9 GString * gmyth_socket_receive_response (GMythSocket *gmyth_socket);
2.10 int gmyth_socket_sendreceive_stringlist (GMythSocket * gmyth_socket,
2.11 GMythStringList *str_list);
3.1 --- a/gmyth/src/gmyth_stringlist.c Mon Oct 09 19:31:49 2006 +0100
3.2 +++ b/gmyth/src/gmyth_stringlist.c Wed Oct 11 22:46:27 2006 +0100
3.3 @@ -81,8 +81,7 @@
3.4 GMythStringList *
3.5 gmyth_string_list_new ()
3.6 {
3.7 - GMythStringList *gmyth_string_list = GMYTH_STRING_LIST (g_object_new(GMYTH_STRING_LIST_TYPE, NULL));
3.8 -
3.9 + GMythStringList *gmyth_string_list = GMYTH_STRING_LIST (g_object_new (GMYTH_STRING_LIST_TYPE, NULL));
3.10 return gmyth_string_list;
3.11 }
3.12
3.13 @@ -115,26 +114,30 @@
3.14 GString*
3.15 gmyth_string_list_append_uint64 ( GMythStringList *strlist, const guint64 value)
3.16 {
3.17 - GString *tmp_str = g_string_new ("");
3.18 + GString *tmp_str1 = g_string_new ("");
3.19 + GString *tmp_str2 = g_string_new ("");
3.20
3.21 - glong l2 = ( (guint64)(value) & 0xffffffffLL );
3.22 - glong l1 = ( ((guint64)(value) >> 32 ) & 0xffffffffLL );
3.23 + glong l2 = ( (guint64)value & 0xffffffff );
3.24 + glong l1 = ( (guint64)value >> 32 );
3.25
3.26 /* high order part of guint64 value */
3.27 - g_string_printf (tmp_str, "%ld", l1);
3.28 + g_string_printf (tmp_str1, "%ld", l1);
3.29
3.30 - g_debug( "[%s] uint64 (high) = %s\n", __FUNCTION__, tmp_str->str );
3.31 + g_debug( "[%s] uint64 (high) = %s\n", __FUNCTION__, tmp_str1->str );
3.32
3.33 - gmyth_string_list_append_string (strlist, tmp_str);
3.34 + //gmyth_string_list_append_string (strlist, tmp_str1);
3.35 + strlist->glist = g_list_append( strlist->glist, tmp_str1 );
3.36
3.37 /* low order part of guint64 value */
3.38 - g_string_printf (tmp_str, "%ld", l2);
3.39 + g_string_printf (tmp_str2, "%ld", l2);
3.40
3.41 - g_debug( "[%s] uint64 (low) = %s\n", __FUNCTION__, tmp_str->str );
3.42 + g_debug( "[%s] uint64 (low) = %s\n", __FUNCTION__, tmp_str2->str );
3.43
3.44 - gmyth_string_list_append_string (strlist, tmp_str);
3.45 + strlist->glist = g_list_append( strlist->glist, tmp_str2 );
3.46
3.47 - return tmp_str;
3.48 + //gmyth_string_list_append_string (strlist, tmp_str2);
3.49 +
3.50 + return tmp_str2;
3.51 }
3.52
3.53 /** Appends a char array to the string list.
3.54 @@ -195,7 +198,7 @@
3.55
3.56 g_return_val_if_fail( tmp_str != NULL && tmp_str->str != NULL, 0 );
3.57
3.58 - return (gint) ( 0x00000000ffffffffL & g_ascii_strtoull ( tmp_str->str, NULL, 0 ) );
3.59 + return (gint) ( 0x00000000ffffffffL & g_ascii_strtoull ( tmp_str->str, NULL, 10 ) );
3.60 }
3.61
3.62 /** Gets a guint64 value from the string list at the given position.
3.63 @@ -220,8 +223,10 @@
3.64
3.65 glong l1 = (glong)g_ascii_strtoull (tmp_str1->str, NULL, 10);
3.66 glong l2 = (glong)g_ascii_strtoull (tmp_str2->str, NULL, 10);
3.67 +
3.68 + g_print ( "[%s]\t[l1 == %ld, l2 == %ld]\n", __FUNCTION__, l1, l2 );
3.69
3.70 - ret_value = ((guint64)(l2) & 0xffffffffLL) | ((guint64)(l1) << 32);
3.71 + ret_value = ((guint64)(l2) /*& 0xffffffff*/) | ((guint64)l1 << 32);
3.72
3.73 g_debug( "[%s] returning uint64 value = %llu\n", __FUNCTION__, ret_value );
3.74
3.75 @@ -246,14 +251,15 @@
3.76 }
3.77
3.78
3.79 +#if 0
3.80 static void
3.81 gmyth_string_list_clear_element( GString *str_elem, void *data_aux )
3.82 {
3.83 if ( str_elem != NULL ) {
3.84 - g_string_free( str_elem, FALSE );
3.85 - str_elem = NULL;
3.86 + g_string_free( str_elem, TRUE );
3.87 }
3.88 }
3.89 +#endif
3.90
3.91 /** Removes all strings from the string list.
3.92 *
3.93 @@ -263,7 +269,7 @@
3.94 gmyth_string_list_clear_all ( GMythStringList *strlist )
3.95 {
3.96 if ( strlist != NULL && strlist->glist ) {
3.97 - g_list_foreach( strlist->glist, (GFunc)gmyth_string_list_clear_element, NULL );
3.98 + //g_list_foreach( strlist->glist, (GFunc)gmyth_string_list_clear_element, NULL );
3.99 g_list_free (strlist->glist);
3.100 strlist->glist = NULL;
3.101 }
4.1 --- a/gmyth/src/gmyth_stringlist.h Mon Oct 09 19:31:49 2006 +0100
4.2 +++ b/gmyth/src/gmyth_stringlist.h Wed Oct 11 22:46:27 2006 +0100
4.3 @@ -70,7 +70,7 @@
4.4
4.5 GType gmyth_string_list_get_type (void);
4.6
4.7 -GMythStringList * gmyth_string_list_new ();
4.8 +GMythStringList * gmyth_string_list_new (void);
4.9
4.10 void gmyth_string_list_clear_all (GMythStringList *strlist);
4.11 int gmyth_string_list_length (GMythStringList *strlist);