loudmouth/lm-socket.c
changeset 249 2cca5ec7b573
parent 245 df2655dbe873
child 256 2266e56746ed
equal deleted inserted replaced
248:09a3e0e55ab8 249:2cca5ec7b573
    75 	gpointer         user_data;
    75 	gpointer         user_data;
    76 
    76 
    77 	guint          ref_count;
    77 	guint          ref_count;
    78 }; 
    78 }; 
    79 
    79 
    80 static void         socket_free                 (LmSocket      *socket);
    80 static void         socket_free               (LmSocket       *socket);
    81 static gboolean     socket_do_connect        (LmConnectData *connect_data);
    81 static gboolean     socket_do_connect         (LmConnectData  *connect_data);
    82 static gboolean     socket_connect_cb       (GIOChannel    *source, 
    82 static gboolean     socket_connect_cb         (GIOChannel     *source, 
    83 						 GIOCondition   condition,
    83 					       GIOCondition    condition,
    84 						 LmConnectData *connect_data);
    84 					       LmConnectData  *connect_data);
    85 static gboolean socket_in_event          (GIOChannel   *source,
    85 static gboolean     socket_in_event           (GIOChannel     *source,
    86 					      GIOCondition  condition,
    86 					       GIOCondition    condition,
    87 					      LmSocket     *socket);
    87 					       LmSocket       *socket);
    88 static gboolean socket_hup_event         (GIOChannel   *source,
    88 static gboolean     socket_hup_event          (GIOChannel     *source,
    89 					      GIOCondition  condition,
    89 					       GIOCondition    condition,
    90 					      LmSocket     *socket);
    90 					       LmSocket       *socket);
    91 static gboolean
    91 static gboolean     socket_buffered_write_cb  (GIOChannel     *source, 
    92 socket_buffered_write_cb (GIOChannel   *source, 
    92 					       GIOCondition    condition,
    93 			      GIOCondition  condition,
    93 					       LmSocket       *socket);
    94 			      LmSocket     *socket);
    94 static gboolean     socket_parse_srv_response (unsigned char  *srv, 
    95 static gboolean socket_parse_srv_response (unsigned char  *srv, 
    95 					       int             srv_len, 
    96 					   int             srv_len, 
    96 					       gchar         **out_server, 
    97 					   gchar         **out_server, 
    97 					       guint          *out_port);
    98 					   guint          *out_port);
       
    99 
    98 
   100 static void
    99 static void
   101 socket_free (LmSocket *socket)
   100 socket_free (LmSocket *socket)
   102 {
   101 {
   103 	g_free (socket->server);
   102 	g_free (socket->server);
   116 
   115 
   117 	g_free (socket);
   116 	g_free (socket);
   118 }
   117 }
   119 
   118 
   120 gint
   119 gint
   121 lm_socket_do_write (LmSocket     *socket,
   120 lm_socket_do_write (LmSocket *socket, const gchar *buf, gint len)
   122 		     const gchar  *buf,
       
   123 		     gint          len)
       
   124 {
   121 {
   125 	gint b_written;
   122 	gint b_written;
   126 
   123 
   127 	if (socket->ssl) {
   124 	if (socket->ssl) {
   128 		b_written = _lm_ssl_send (socket->ssl, buf, len);
   125 		b_written = _lm_ssl_send (socket->ssl, buf, len);
   146 
   143 
   147 	return b_written;
   144 	return b_written;
   148 }
   145 }
   149 
   146 
   150 static gboolean
   147 static gboolean
   151 socket_read_incoming (LmSocket     *socket,
   148 socket_read_incoming (LmSocket *socket,
   152 		      gchar        *buf,
   149 		      gchar    *buf,
   153 		      gsize         buf_size,
   150 		      gsize     buf_size,
   154 		      gsize        *bytes_read,
   151 		      gsize    *bytes_read,
   155 		      gboolean     *hangup)
   152 		      gboolean *hangup)
   156 {
   153 {
   157 	GIOStatus status;
   154 	GIOStatus status;
   158 
   155 
   159 	*hangup = FALSE;
   156 	*hangup = FALSE;
   160 
   157 
   565 
   562 
   566 	return FALSE;
   563 	return FALSE;
   567 }
   564 }
   568 
   565 
   569 void
   566 void
   570 lm_socket_setup_output_buffer (LmSocket     *socket,
   567 lm_socket_setup_output_buffer (LmSocket *socket, const gchar *buffer, gint len)
   571 				const gchar  *buffer,
       
   572 				gint          len)
       
   573 {
   568 {
   574 	lm_verbose ("OUTPUT BUFFER ENABLED\n");
   569 	lm_verbose ("OUTPUT BUFFER ENABLED\n");
   575 
   570 
   576 	socket->out_buf = g_string_new_len (buffer, len);
   571 	socket->out_buf = g_string_new_len (buffer, len);
   577 
   572