Commit 1c73b5bd authored by Dafydd Harries's avatar Dafydd Harries
Browse files

tidy up local/ code and export its functions

darcs-hash:20070203095751-c9803-2606e0f7ec35e1e4280aaafff2cb0b27287f29bd.gz
parent 5669dcb9
#include <glib.h>
#include "local.h"
int
......@@ -9,11 +7,11 @@ main (void)
GSList *i;
GSList *interfaces;
interfaces = list_local_interfaces ();
interfaces = nice_list_local_interfaces ();
for (i = interfaces; i; i = i->next)
{
interface *iface = (interface *) i->data;
NiceInterface *iface = i->data;
g_print ("%s: %d.%d.%d.%d\n",
iface->name,
......@@ -21,7 +19,7 @@ main (void)
(iface->addr & 0x00ff0000) >> 16,
(iface->addr & 0x0000ff00) >> 8,
(iface->addr & 0x000000ff));
interface_free (iface);
nice_interface_free (iface);
}
g_slist_free (interfaces);
......
......@@ -8,21 +8,21 @@
#include "local.h"
interface *
interface_new ()
NiceInterface *
nice_interface_new ()
{
return g_slice_new0 (interface);
return g_slice_new0 (NiceInterface);
}
void
interface_free (interface *iface)
nice_interface_free (NiceInterface *iface)
{
g_free (iface->name);
g_slice_free (interface, iface);
g_slice_free (NiceInterface, iface);
}
GSList *
list_local_interfaces ()
nice_list_local_interfaces ()
{
char buf[1024];
gint sock;
......@@ -48,13 +48,13 @@ list_local_interfaces ()
{
struct ifreq *ifr = ifc.ifc_req + i;
struct sockaddr_in *sin;
interface *iface;
NiceInterface *iface;
if (ifr->ifr_addr.sa_family != AF_INET)
/* this probably shouldn't happen */
continue;
iface = g_slice_new0 (interface);
iface = g_slice_new0 (NiceInterface);
iface->name = g_strdup (ifr->ifr_name);
sin = (struct sockaddr_in *) &(ifr->ifr_addr);
......
......@@ -8,22 +8,22 @@ G_BEGIN_DECLS
typedef guint32 addr_ipv4;
typedef struct _interface interface;
typedef struct _NiceInterface NiceInterface;
struct _interface
struct _NiceInterface
{
gchar *name;
addr_ipv4 addr;
};
interface *
interface_new ();
NiceInterface *
nice_interface_new ();
void
interface_free (interface *iface);
nice_interface_free (NiceInterface *iface);
GSList *
list_local_interfaces ();
nice_list_local_interfaces ();
G_END_DECLS
......
......@@ -21,6 +21,9 @@ T nice_candidate_jingle_priority
T nice_candidate_new
T nice_event_free
T nice_glib_rng_new
T nice_interface_free
T nice_interface_new
T nice_list_local_interfaces
T nice_rng_free
T nice_rng_generate_bytes
T nice_rng_generate_bytes_print
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment