loudmouth/lm-internals.h
author hallski <hallski>
Wed, 19 Apr 2006 11:42:53 +0000
changeset 140 103227122f45
parent 137 18785575aa7a
child 155 d24c4392d4e3
permissions -rw-r--r--
2006-04-19 Mikael Hallendal <micke@imendio.com> * Landing a patch by Martyn Russell for Win32. * configure.ac: Updated for Win32 work * examples/*: Updated and improved. * loudmouth/Makefile.am: * loudmouth/lm-connection.c: - Abstracted out the low level socket handling to lm-sock.[ch] to make this file clean from OS dependant socket code. * loudmouth/lm-internals.h: * loudmouth/lm-parser.c: * loudmouth/lm-proxy.c: * loudmouth/lm-sha.c: * loudmouth/lm-utils.c: - Win32 work * loudmouth/lm-sock.[ch]: - Network abstraction layer.

/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * Copyright (C) 2003 Imendio AB
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

/* Private functions that are internal to the library */

#ifndef __LM_INTERNALS_H__
#define __LM_INTERNALS_H__

#include <glib.h>

#include <sys/types.h>

#include "lm-message.h"
#include "lm-message-handler.h"
#include "lm-message-node.h"
#include "lm-sock.h"

#ifndef G_OS_WIN32
typedef int LmSocket;
#else  /* G_OS_WIN32 */
typedef SOCKET LmSocket;
#endif /* G_OS_WIN32 */

typedef struct {
	gpointer       func;
	gpointer       user_data;
	GDestroyNotify notify;
} LmCallback;

typedef struct {
	LmConnection    *connection;

	/* struct to save resolved address */
	struct addrinfo *resolved_addrs;
	struct addrinfo *current_addr;
	LmSocket         fd;
	GIOChannel      *io_channel;
} LmConnectData;

void             _lm_connection_failed_with_error (LmConnectData *connect_data,
                                                   int error);
void             _lm_connection_failed            (LmConnectData *connect_data);
void             _lm_connection_succeeded         (LmConnectData *connect_data);
LmCallback *     _lm_utils_new_callback             (gpointer          func, 
						     gpointer          data,
						     GDestroyNotify    notify);
void             _lm_utils_free_callback            (LmCallback       *cb);

gchar *          _lm_utils_generate_id              (void);
gchar *          _lm_utils_base64_encode            (const gchar      *str);
const gchar *    _lm_message_type_to_string         (LmMessageType     type);
const gchar *    _lm_message_sub_type_to_string     (LmMessageSubType  type);
LmMessage *      _lm_message_new_from_node          (LmMessageNode    *node);
void             _lm_message_node_add_child_node    (LmMessageNode    *node,
						     LmMessageNode    *child);
LmMessageNode *  _lm_message_node_new               (const gchar      *name);
void             _lm_debug_init                     (void);


gboolean         _lm_proxy_connect_cb               (GIOChannel *source,
                                                     GIOCondition condition,
                                                     gpointer data);
LmHandlerResult    
_lm_message_handler_handle_message                (LmMessageHandler *handler,
						   LmConnection     *connection,
						   LmMessage        *messag);
gboolean         _lm_sock_library_init            (void);
void             _lm_sock_library_shutdown        (void);
void             _lm_sock_set_blocking            (LmSocket               sock,
						   gboolean               block);
void             _lm_sock_shutdown                (LmSocket               sock);
void             _lm_sock_close                   (LmSocket               sock);
LmSocket         _lm_sock_makesocket              (int                    af,
						   int                    type,
						   int                    protocol);
int              _lm_sock_connect                 (LmSocket               sock,
						   const struct sockaddr *name,
						   int                    namelen);
gboolean         _lm_sock_is_blocking_error       (int                    err);
gboolean         _lm_sock_is_blocking_success     (int                    err);
int              _lm_sock_get_last_error          (void);
void             _lm_sock_get_error               (LmSocket               sock, 
						   void                  *error, 
						   socklen_t             *len);
const gchar *    _lm_sock_get_error_str           (int                    err);
const gchar *    _lm_sock_addrinfo_get_error_str  (int                    err);

#endif /* __LM_INTERNALS_H__ */