~vcs-imports/gnome-media/main

« back to all changes in this revision

Viewing changes to cddb-slave2/tcp.c

  • Committer: thomasvs
  • Date: 2004-05-10 08:52:25 UTC
  • Revision ID: vcs-imports@canonical.com-20040510085225-zb6tqc12yi1h08gd
remove unneccesary whitespace

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 * Library General Public License for more details.
14
14
 *
15
15
 * You should have received a copy of the GNU Library General Public
16
 
 * License along with this library; if not, write to the 
 
16
 * License along with this library; if not, write to the
17
17
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
18
 * Boston, MA  02111-1307, USA.
19
19
 */
42
42
 *
43
43
 **/
44
44
GTcpSocketConnectAsyncID
45
 
gnet_tcp_socket_connect_async (const gchar* hostname, gint port, 
46
 
                               GTcpSocketConnectAsyncFunc func, 
 
45
gnet_tcp_socket_connect_async (const gchar* hostname, gint port,
 
46
                               GTcpSocketConnectAsyncFunc func,
47
47
                               gpointer data)
48
48
{
49
49
  GTcpSocketConnectState* state;
56
56
  state->func = func;
57
57
  state->data = data;
58
58
 
59
 
  id = gnet_inetaddr_new_async(hostname, port,  
60
 
                               gnet_tcp_socket_connect_inetaddr_cb, 
 
59
  id = gnet_inetaddr_new_async(hostname, port,
 
60
                               gnet_tcp_socket_connect_inetaddr_cb,
61
61
                               state);
62
62
 
63
63
  /* Note that gnet_inetaddr_new_async can fail immediately and call
74
74
 
75
75
 
76
76
void
77
 
gnet_tcp_socket_connect_inetaddr_cb (GInetAddr* inetaddr, 
78
 
                                     GInetAddrAsyncStatus status, 
 
77
gnet_tcp_socket_connect_inetaddr_cb (GInetAddr* inetaddr,
 
78
                                     GInetAddrAsyncStatus status,
79
79
                                     gpointer data)
80
80
{
81
81
  GTcpSocketConnectState* state = (GTcpSocketConnectState*) data;
85
85
      state->ia = inetaddr;
86
86
 
87
87
      state->inetaddr_id = NULL;
88
 
      state->tcp_id = gnet_tcp_socket_new_async(inetaddr, 
89
 
                                                gnet_tcp_socket_connect_tcp_cb, 
 
88
      state->tcp_id = gnet_tcp_socket_new_async(inetaddr,
 
89
                                                gnet_tcp_socket_connect_tcp_cb,
90
90
                                                state);
91
91
      /* Note that this call may delete the state. */
92
92
    }
93
93
  else
94
94
    {
95
 
      (*state->func)(NULL, NULL, GTCP_SOCKET_CONNECT_ASYNC_STATUS_INETADDR_ERROR, 
 
95
      (*state->func)(NULL, NULL, GTCP_SOCKET_CONNECT_ASYNC_STATUS_INETADDR_ERROR,
96
96
                     state->data);
97
97
      g_free(state);
98
98
    }
99
99
}
100
100
 
101
 
void 
102
 
gnet_tcp_socket_connect_tcp_cb(GTcpSocket* socket, 
103
 
                               GTcpSocketConnectAsyncStatus status, 
 
101
void
 
102
gnet_tcp_socket_connect_tcp_cb(GTcpSocket* socket,
 
103
                               GTcpSocketConnectAsyncStatus status,
104
104
                               gpointer data)
105
105
{
106
106
  GTcpSocketConnectState* state = (GTcpSocketConnectState*) data;
119
119
 *
120
120
 *  Cancel an asynchronous connection that was started with
121
121
 *  gnet_tcp_socket_connect_async().
122
 
 * 
 
122
 *
123
123
 */
124
124
void
125
125
gnet_tcp_socket_connect_async_cancel(GTcpSocketConnectAsyncID id)
158
158
 *
159
159
 **/
160
160
GTcpSocketNewAsyncID
161
 
gnet_tcp_socket_new_async (const GInetAddr* addr, 
 
161
gnet_tcp_socket_new_async (const GInetAddr* addr,
162
162
                           GTcpSocketNewAsyncFunc func,
163
163
                           gpointer data)
164
164
{
231
231
  if (socks_addr_save)
232
232
    addr = socks_addr_save;
233
233
 
234
 
  /* Save address */ 
 
234
  /* Save address */
235
235
  memcpy(&s->sa, &addr->sa, sizeof(s->sa));
236
236
  sa_in = (struct sockaddr_in*) &sa;
237
237
  sa_in->sin_family = AF_INET;
250
250
  state->socks_addr = socks_addr;
251
251
  state->connect_watch = g_io_add_watch(GNET_SOCKET_IOCHANNEL_NEW(s->sockfd),
252
252
                                        GNET_ANY_IO_CONDITION,
253
 
                                        gnet_tcp_socket_new_async_cb, 
 
253
                                        gnet_tcp_socket_new_async_cb,
254
254
                                        state);
255
255
 
256
256
  return state;
257
257
}
258
258
 
259
259
 
260
 
gboolean 
261
 
gnet_tcp_socket_new_async_cb (GIOChannel* iochannel, 
262
 
                              GIOCondition condition, 
 
260
gboolean
 
261
gnet_tcp_socket_new_async_cb (GIOChannel* iochannel,
 
262
                              GIOCondition condition,
263
263
                              gpointer data)
264
264
{
265
265
  GTcpSocketAsyncState* state = (GTcpSocketAsyncState*) data;
416
416
 *  Returns: A #GIOChannel; NULL on failure.
417
417
 *
418
418
 **/
419
 
GIOChannel* 
 
419
GIOChannel*
420
420
gnet_tcp_socket_get_iochannel(GTcpSocket* socket)
421
421
{
422
422
  g_return_val_if_fail (socket != NULL, NULL);
423
423
 
424
424
  if (socket->iochannel == NULL)
425
425
    socket->iochannel = GNET_SOCKET_IOCHANNEL_NEW(socket->sockfd);
426
 
  
 
426
 
427
427
  g_io_channel_ref (socket->iochannel);
428
428
 
429
429
  return socket->iochannel;