loudmouth/inc/lm-internals.h
changeset 10 59927b2d3b75
parent 0 d0f3a028347a
equal deleted inserted replaced
0:d0f3a028347a 10:59927b2d3b75
     1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
       
     2 /*
       
     3  * Copyright (C) 2003 Imendio AB
       
     4  *
       
     5  * This program is free software; you can redistribute it and/or
       
     6  * modify it under the terms of the GNU Lesser General Public License as
       
     7  * published by the Free Software Foundation; either version 2 of the
       
     8  * License, or (at your option) any later version.
       
     9  *
       
    10  * This program is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    13  * Lesser General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU Lesser General Public
       
    16  * License along with this program; if not, write to the
       
    17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       
    18  * Boston, MA 02111-1307, USA.
       
    19  */
       
    20 
       
    21 /* Private functions that are internal to the library */
       
    22 
       
    23 #ifndef __LM_INTERNALS_H__
       
    24 #define __LM_INTERNALS_H__
       
    25 
       
    26 #include <glib.h>
       
    27 
       
    28 #include <sys/types.h>
       
    29 
       
    30 #include "lm-message.h"
       
    31 #include "lm-message-handler.h"
       
    32 #include "lm-message-node.h"
       
    33 #include "lm-sock.h"
       
    34 #include "lm-socket.h"
       
    35 
       
    36 #ifndef G_OS_WIN32
       
    37 typedef int LmSocketT;
       
    38 #else  /* G_OS_WIN32 */
       
    39 typedef SOCKET LmSocketT;
       
    40 #endif /* G_OS_WIN32 */
       
    41 
       
    42 typedef struct {
       
    43 	gpointer       func;
       
    44 	gpointer       user_data;
       
    45 	GDestroyNotify notify;
       
    46 } LmCallback;
       
    47 
       
    48 typedef struct {
       
    49 	LmConnection *connection;
       
    50 	LmSocket *socket;
       
    51 
       
    52 	/* struct to save resolved address */
       
    53 	struct addrinfo *resolved_addrs;
       
    54 	struct addrinfo *current_addr;
       
    55 	LmSocketT         fd;
       
    56 	GIOChannel      *io_channel;
       
    57 } LmConnectData;
       
    58 
       
    59 gboolean         _lm_socket_failed_with_error (LmConnectData *connect_data,
       
    60                                                    int error);
       
    61 gboolean         _lm_socket_failed            (LmConnectData *connect_data);
       
    62 void             _lm_socket_succeeded         (LmConnectData *connect_data);
       
    63 gboolean _lm_connection_async_connect_waiting (LmConnection *connection);
       
    64 void _lm_connection_set_async_connect_waiting (LmConnection *connection,
       
    65 					       gboolean      waiting);
       
    66 
       
    67 LmCallback *     _lm_utils_new_callback             (gpointer          func, 
       
    68 						     gpointer          data,
       
    69 						     GDestroyNotify    notify);
       
    70 void             _lm_utils_free_callback            (LmCallback       *cb);
       
    71 
       
    72 gchar *          _lm_utils_generate_id              (void);
       
    73 gchar *          _lm_utils_base64_encode            (const gchar      *str);
       
    74 gchar *          _lm_utils_hostname_to_punycode     (const gchar      *hostname);
       
    75 const gchar *    _lm_message_type_to_string         (LmMessageType     type);
       
    76 const gchar *    _lm_message_sub_type_to_string     (LmMessageSubType  type);
       
    77 LmMessage *      _lm_message_new_from_node          (LmMessageNode    *node);
       
    78 void             _lm_message_node_add_child_node    (LmMessageNode    *node,
       
    79 						     LmMessageNode    *child);
       
    80 LmMessageNode *  _lm_message_node_new               (const gchar      *name);
       
    81 void             _lm_debug_init                     (void);
       
    82 
       
    83 
       
    84 gboolean         _lm_proxy_connect_cb               (GIOChannel *source,
       
    85                                                      GIOCondition condition,
       
    86                                                      gpointer data);
       
    87 LmHandlerResult    
       
    88 _lm_message_handler_handle_message                (LmMessageHandler *handler,
       
    89 						   LmConnection     *connection,
       
    90 						   LmMessage        *messag);
       
    91 gboolean         _lm_sock_library_init            (void);
       
    92 void             _lm_sock_library_shutdown        (void);
       
    93 void             _lm_sock_set_blocking            (LmSocketT               sock,
       
    94 						   gboolean               block);
       
    95 void             _lm_sock_shutdown                (LmSocketT               sock);
       
    96 void             _lm_sock_close                   (LmSocketT               sock);
       
    97 LmSocketT         _lm_sock_makesocket              (int                    af,
       
    98 						   int                    type,
       
    99 						   int                    protocol);
       
   100 int              _lm_sock_connect                 (LmSocketT               sock,
       
   101 						   const struct sockaddr *name,
       
   102 						   int                    namelen);
       
   103 gboolean         _lm_sock_is_blocking_error       (int                    err);
       
   104 gboolean         _lm_sock_is_blocking_success     (int                    err);
       
   105 int              _lm_sock_get_last_error          (void);
       
   106 void             _lm_sock_get_error               (LmSocketT               sock, 
       
   107 						   void                  *error, 
       
   108 						   socklen_t             *len);
       
   109 const gchar *    _lm_sock_get_error_str           (int                    err);
       
   110 const gchar *    _lm_sock_addrinfo_get_error_str  (int                    err);
       
   111 gchar       *    _lm_sock_get_local_host          (LmSocketT              sock);
       
   112 
       
   113 #ifdef USE_TCP_KEEPALIVES
       
   114 gboolean         _lm_sock_set_keepalive (LmSocketT sock, int delay);
       
   115 #endif /* USE_TCP_KEEPALIVES */
       
   116 
       
   117 #endif /* __LM_INTERNALS_H__ */