/* netprovider.c generated by valac 0.22.1, the Vala compiler
 * generated from netprovider.vala, do not modify */


#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include "glibtop.h"
#include "glibtop/netlist.h"
#include "glibtop/netload.h"
#include <glib/gstdio.h>
#include <float.h>
#include <math.h>


#define TYPE_PROVIDER (provider_get_type ())
#define PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PROVIDER, Provider))
#define PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PROVIDER, ProviderClass))
#define IS_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PROVIDER))
#define IS_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PROVIDER))
#define PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PROVIDER, ProviderClass))

typedef struct _Provider Provider;
typedef struct _ProviderClass ProviderClass;
typedef struct _ProviderPrivate ProviderPrivate;

#define TYPE_NET_PROVIDER (net_provider_get_type ())
#define NET_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NET_PROVIDER, NetProvider))
#define NET_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_NET_PROVIDER, NetProviderClass))
#define IS_NET_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NET_PROVIDER))
#define IS_NET_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_NET_PROVIDER))
#define NET_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NET_PROVIDER, NetProviderClass))

typedef struct _NetProvider NetProvider;
typedef struct _NetProviderClass NetProviderClass;
typedef struct _NetProviderPrivate NetProviderPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _Provider {
	GObject parent_instance;
	ProviderPrivate * priv;
};

struct _ProviderClass {
	GObjectClass parent_class;
	void (*update) (Provider* self);
};

struct _NetProvider {
	Provider parent_instance;
	NetProviderPrivate * priv;
};

struct _NetProviderClass {
	ProviderClass parent_class;
};

struct _NetProviderPrivate {
	guint64* lastdata;
	gint lastdata_length1;
	gint _lastdata_size_;
	guint64 lasttime;
	gchar** devicefields;
	gint devicefields_length1;
	gint _devicefields_size_;
};


static gpointer net_provider_parent_class = NULL;

GType provider_get_type (void) G_GNUC_CONST;
GType net_provider_get_type (void) G_GNUC_CONST;
#define NET_PROVIDER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_NET_PROVIDER, NetProviderPrivate))
enum  {
	NET_PROVIDER_DUMMY_PROPERTY
};
static gchar** net_provider_fields (gchar*** devices, int* devices_length1, int* result_length1);
NetProvider* net_provider_new (void);
NetProvider* net_provider_construct (GType object_type);
Provider* provider_construct (GType object_type, const gchar* id, gchar** keys, int keys_length1, gchar displaytype);
static gchar** _vala_array_dup21 (gchar** self, int length);
static void net_provider_real_update (Provider* base);
gchar** provider_get_keys (Provider* self, int* result_length1);
gdouble* provider_get_values (Provider* self, int* result_length1);
static guint64* _vala_array_dup22 (guint64* self, int length);
static void net_provider_finalize (GObject* obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
static gint _vala_array_length (gpointer array);


static const gchar* string_to_string (const gchar* self) {
	const gchar* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}


static gchar** net_provider_fields (gchar*** devices, int* devices_length1, int* result_length1) {
	gchar** _vala_devices = NULL;
	int _vala_devices_length1 = 0;
	gchar** result = NULL;
	glibtop_netlist netlist = {0};
	glibtop_netlist _tmp0_ = {0};
	gchar** _tmp1_ = NULL;
	gchar** _tmp2_ = NULL;
	gchar** _result_ = NULL;
	glibtop_netlist _tmp3_ = {0};
	guint32 _tmp4_ = 0U;
	gchar** _tmp5_ = NULL;
	gint _result__length1 = 0;
	gint __result__size_ = 0;
	gchar** _tmp6_ = NULL;
	gint _tmp6__length1 = 0;
	gchar* _tmp7_ = NULL;
	gchar* _tmp8_ = NULL;
	gchar** _tmp9_ = NULL;
	gint _tmp9__length1 = 0;
	gchar* _tmp10_ = NULL;
	gchar* _tmp11_ = NULL;
	gchar** _tmp12_ = NULL;
	gint _tmp12__length1 = 0;
	gchar* _tmp13_ = NULL;
	gchar* _tmp14_ = NULL;
	gchar** _tmp37_ = NULL;
	gint _tmp37__length1 = 0;
	glibtop_init ();
	_tmp2_ = _tmp1_ = glibtop_get_netlist (&_tmp0_);
	netlist = _tmp0_;
	_vala_devices = (_vala_array_free (_vala_devices, _vala_devices_length1, (GDestroyNotify) g_free), NULL);
	_vala_devices = _tmp2_;
	_vala_devices_length1 = _vala_array_length (_tmp1_);
	_tmp3_ = netlist;
	_tmp4_ = _tmp3_.number;
	_tmp5_ = g_new0 (gchar*, (3 + (2 * _tmp4_)) + 1);
	_result_ = _tmp5_;
	_result__length1 = 3 + (2 * _tmp4_);
	__result__size_ = _result__length1;
	_tmp6_ = _result_;
	_tmp6__length1 = _result__length1;
	_tmp7_ = g_strdup ("down");
	_g_free0 (_tmp6_[0]);
	_tmp6_[0] = _tmp7_;
	_tmp8_ = _tmp6_[0];
	_tmp9_ = _result_;
	_tmp9__length1 = _result__length1;
	_tmp10_ = g_strdup ("up");
	_g_free0 (_tmp9_[1]);
	_tmp9_[1] = _tmp10_;
	_tmp11_ = _tmp9_[1];
	_tmp12_ = _result_;
	_tmp12__length1 = _result__length1;
	_tmp13_ = g_strdup ("local");
	_g_free0 (_tmp12_[2]);
	_tmp12_[2] = _tmp13_;
	_tmp14_ = _tmp12_[2];
	{
		guint j = 0U;
		j = (guint) 0;
		{
			gboolean _tmp15_ = FALSE;
			_tmp15_ = TRUE;
			while (TRUE) {
				gboolean _tmp16_ = FALSE;
				guint _tmp18_ = 0U;
				glibtop_netlist _tmp19_ = {0};
				guint32 _tmp20_ = 0U;
				gchar* device = NULL;
				gchar** _tmp21_ = NULL;
				gint _tmp21__length1 = 0;
				guint _tmp22_ = 0U;
				const gchar* _tmp23_ = NULL;
				gchar* _tmp24_ = NULL;
				gchar** _tmp25_ = NULL;
				gint _tmp25__length1 = 0;
				guint _tmp26_ = 0U;
				const gchar* _tmp27_ = NULL;
				const gchar* _tmp28_ = NULL;
				gchar* _tmp29_ = NULL;
				gchar* _tmp30_ = NULL;
				gchar** _tmp31_ = NULL;
				gint _tmp31__length1 = 0;
				guint _tmp32_ = 0U;
				const gchar* _tmp33_ = NULL;
				const gchar* _tmp34_ = NULL;
				gchar* _tmp35_ = NULL;
				gchar* _tmp36_ = NULL;
				_tmp16_ = _tmp15_;
				if (!_tmp16_) {
					guint _tmp17_ = 0U;
					_tmp17_ = j;
					j = _tmp17_ + 1;
				}
				_tmp15_ = FALSE;
				_tmp18_ = j;
				_tmp19_ = netlist;
				_tmp20_ = _tmp19_.number;
				if (!(_tmp18_ < ((guint) _tmp20_))) {
					break;
				}
				_tmp21_ = _vala_devices;
				_tmp21__length1 = _vala_devices_length1;
				_tmp22_ = j;
				_tmp23_ = _tmp21_[_tmp22_];
				_tmp24_ = g_strdup (_tmp23_);
				device = _tmp24_;
				_tmp25_ = _result_;
				_tmp25__length1 = _result__length1;
				_tmp26_ = j;
				_tmp27_ = device;
				_tmp28_ = string_to_string (_tmp27_);
				_tmp29_ = g_strconcat (_tmp28_, ".down", NULL);
				_g_free0 (_tmp25_[3 + (2 * _tmp26_)]);
				_tmp25_[3 + (2 * _tmp26_)] = _tmp29_;
				_tmp30_ = _tmp25_[3 + (2 * _tmp26_)];
				_tmp31_ = _result_;
				_tmp31__length1 = _result__length1;
				_tmp32_ = j;
				_tmp33_ = device;
				_tmp34_ = string_to_string (_tmp33_);
				_tmp35_ = g_strconcat (_tmp34_, ".up", NULL);
				_g_free0 (_tmp31_[(3 + (2 * _tmp32_)) + 1]);
				_tmp31_[(3 + (2 * _tmp32_)) + 1] = _tmp35_;
				_tmp36_ = _tmp31_[(3 + (2 * _tmp32_)) + 1];
				_g_free0 (device);
			}
		}
	}
	_tmp37_ = _result_;
	_tmp37__length1 = _result__length1;
	if (result_length1) {
		*result_length1 = _tmp37__length1;
	}
	result = _tmp37_;
	if (devices) {
		*devices = _vala_devices;
	} else {
		_vala_devices = (_vala_array_free (_vala_devices, _vala_devices_length1, (GDestroyNotify) g_free), NULL);
	}
	if (devices_length1) {
		*devices_length1 = _vala_devices_length1;
	}
	return result;
}


static gchar** _vala_array_dup21 (gchar** self, int length) {
	gchar** result;
	int i;
	result = g_new0 (gchar*, length + 1);
	for (i = 0; i < length; i++) {
		gchar* _tmp0_ = NULL;
		_tmp0_ = g_strdup (self[i]);
		result[i] = _tmp0_;
	}
	return result;
}


NetProvider* net_provider_construct (GType object_type) {
	NetProvider * self = NULL;
	gchar** devices = NULL;
	gint devices_length1 = 0;
	gint _devices_size_ = 0;
	gchar** _tmp0_ = NULL;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	gchar** _tmp3_ = NULL;
	gchar** _tmp4_ = NULL;
	gint _tmp4__length1 = 0;
	gchar** _tmp5_ = NULL;
	gint _tmp5__length1 = 0;
	_tmp3_ = net_provider_fields (&_tmp0_, &_tmp1_, &_tmp2_);
	devices = (_vala_array_free (devices, devices_length1, (GDestroyNotify) g_free), NULL);
	devices = _tmp0_;
	devices_length1 = _tmp1_;
	_devices_size_ = devices_length1;
	_tmp4_ = _tmp3_;
	_tmp4__length1 = _tmp2_;
	self = (NetProvider*) provider_construct (object_type, "net", _tmp4_, _tmp2_, 's');
	_tmp4_ = (_vala_array_free (_tmp4_, _tmp4__length1, (GDestroyNotify) g_free), NULL);
	_tmp5_ = (devices != NULL) ? _vala_array_dup21 (devices, devices_length1) : ((gpointer) devices);
	_tmp5__length1 = devices_length1;
	self->priv->devicefields = (_vala_array_free (self->priv->devicefields, self->priv->devicefields_length1, (GDestroyNotify) g_free), NULL);
	self->priv->devicefields = _tmp5_;
	self->priv->devicefields_length1 = _tmp5__length1;
	self->priv->_devicefields_size_ = self->priv->devicefields_length1;
	devices = (_vala_array_free (devices, devices_length1, (GDestroyNotify) g_free), NULL);
	return self;
}


NetProvider* net_provider_new (void) {
	return net_provider_construct (TYPE_NET_PROVIDER);
}


static guint64* _vala_array_dup22 (guint64* self, int length) {
	return g_memdup (self, length * sizeof (guint64));
}


static void net_provider_real_update (Provider* base) {
	NetProvider * self;
	guint64* newdata = NULL;
	gchar** _tmp0_ = NULL;
	gint _tmp0__length1 = 0;
	gchar** _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	guint64* _tmp2_ = NULL;
	gint newdata_length1 = 0;
	gint _newdata_size_ = 0;
	guint64 newtime = 0ULL;
	guint64 _tmp3_ = 0ULL;
	glibtop_netlist netlist = {0};
	gchar** devices = NULL;
	glibtop_netlist _tmp4_ = {0};
	gchar** _tmp5_ = NULL;
	gchar** _tmp6_ = NULL;
	gint devices_length1 = 0;
	gint _devices_size_ = 0;
	glibtop_netlist _tmp7_ = {0};
	guint32 _tmp8_ = 0U;
	guint64* _tmp163_ = NULL;
	gint _tmp163__length1 = 0;
	guint64* _tmp184_ = NULL;
	gint _tmp184__length1 = 0;
	guint64* _tmp185_ = NULL;
	gint _tmp185__length1 = 0;
	guint64 _tmp186_ = 0ULL;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_NET_PROVIDER, NetProvider);
	_tmp0_ = provider_get_keys (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_PROVIDER, Provider), &_tmp0__length1);
	_tmp1_ = _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	_tmp2_ = g_new0 (guint64, _tmp1__length1);
	newdata = _tmp2_;
	newdata_length1 = _tmp1__length1;
	_newdata_size_ = newdata_length1;
	_tmp3_ = g_get_monotonic_time ();
	newtime = _tmp3_;
	_tmp6_ = _tmp5_ = glibtop_get_netlist (&_tmp4_);
	netlist = _tmp4_;
	devices = _tmp6_;
	devices_length1 = _vala_array_length (_tmp5_);
	_devices_size_ = devices_length1;
	_tmp7_ = netlist;
	_tmp8_ = _tmp7_.number;
	g_debug ("netprovider.vala:54: Netlist: %u entries", (guint) _tmp8_);
	{
		guint i = 0U;
		i = (guint) 0;
		{
			gboolean _tmp9_ = FALSE;
			_tmp9_ = TRUE;
			while (TRUE) {
				gboolean _tmp10_ = FALSE;
				guint _tmp12_ = 0U;
				glibtop_netlist _tmp13_ = {0};
				guint32 _tmp14_ = 0U;
				gchar* device = NULL;
				gchar** _tmp15_ = NULL;
				gint _tmp15__length1 = 0;
				guint _tmp16_ = 0U;
				const gchar* _tmp17_ = NULL;
				gchar* _tmp18_ = NULL;
				glibtop_netload netload = {0};
				const gchar* _tmp19_ = NULL;
				glibtop_netload _tmp20_ = {0};
				const gchar* _tmp21_ = NULL;
				gchar* _tmp22_ = NULL;
				gchar* _tmp23_ = NULL;
				glibtop_netload _tmp24_ = {0};
				guint64 _tmp25_ = 0ULL;
				glibtop_netload _tmp26_ = {0};
				guint64 _tmp27_ = 0ULL;
				glibtop_netload _tmp28_ = {0};
				guint32 _tmp29_ = 0U;
				gchar* _tmp30_ = NULL;
				gchar* _tmp31_ = NULL;
				gchar* _tmp32_ = NULL;
				gchar* _tmp33_ = NULL;
				glibtop_netload _tmp34_ = {0};
				guint32 _tmp35_ = 0U;
				gchar* _tmp36_ = NULL;
				gchar* _tmp37_ = NULL;
				gchar* _tmp38_ = NULL;
				gchar* _tmp39_ = NULL;
				glibtop_netload _tmp40_ = {0};
				guint32 _tmp41_ = 0U;
				gchar* _tmp42_ = NULL;
				gchar* _tmp43_ = NULL;
				gchar* _tmp44_ = NULL;
				gchar* _tmp45_ = NULL;
				glibtop_netload _tmp46_ = {0};
				guint64 _tmp47_ = 0ULL;
				gchar* _tmp48_ = NULL;
				gchar* _tmp49_ = NULL;
				gchar* _tmp50_ = NULL;
				gchar* _tmp51_ = NULL;
				glibtop_netload _tmp52_ = {0};
				guint64 _tmp53_ = 0ULL;
				gchar* _tmp54_ = NULL;
				gchar* _tmp55_ = NULL;
				gchar* _tmp56_ = NULL;
				gchar* _tmp57_ = NULL;
				glibtop_netload _tmp58_ = {0};
				guint64 _tmp59_ = 0ULL;
				gchar* _tmp60_ = NULL;
				gchar* _tmp61_ = NULL;
				gchar* _tmp62_ = NULL;
				gchar* _tmp63_ = NULL;
				glibtop_netload _tmp64_ = {0};
				guint64 _tmp65_ = 0ULL;
				gchar* _tmp66_ = NULL;
				gchar* _tmp67_ = NULL;
				gchar* _tmp68_ = NULL;
				gchar* _tmp69_ = NULL;
				glibtop_netload _tmp70_ = {0};
				guint64 _tmp71_ = 0ULL;
				gchar* _tmp72_ = NULL;
				gchar* _tmp73_ = NULL;
				gchar* _tmp74_ = NULL;
				gchar* _tmp75_ = NULL;
				glibtop_netload _tmp76_ = {0};
				guint64 _tmp77_ = 0ULL;
				gchar* _tmp78_ = NULL;
				gchar* _tmp79_ = NULL;
				gchar* _tmp80_ = NULL;
				gchar* _tmp81_ = NULL;
				glibtop_netload _tmp82_ = {0};
				guint64 _tmp83_ = 0ULL;
				gchar* _tmp84_ = NULL;
				gchar* _tmp85_ = NULL;
				gchar* _tmp86_ = NULL;
				gchar* _tmp87_ = NULL;
				glibtop_netload _tmp88_ = {0};
				guint64 _tmp89_ = 0ULL;
				gchar* _tmp90_ = NULL;
				gchar* _tmp91_ = NULL;
				gchar* _tmp92_ = NULL;
				gchar* _tmp93_ = NULL;
				glibtop_netload _tmp94_ = {0};
				guint64 _tmp95_ = 0ULL;
				gchar* _tmp96_ = NULL;
				gchar* _tmp97_ = NULL;
				gchar* _tmp98_ = NULL;
				gchar* _tmp99_ = NULL;
				glibtop_netload _tmp100_ = {0};
				guint64 _tmp101_ = 0ULL;
				gchar* _tmp102_ = NULL;
				gchar* _tmp103_ = NULL;
				gchar* _tmp104_ = NULL;
				gchar* _tmp105_ = NULL;
				glibtop_netload _tmp106_ = {0};
				guint64 _tmp107_ = 0ULL;
				gint _tmp108_ = 0;
				glibtop_netload _tmp109_ = {0};
				guint64 _tmp110_ = 0ULL;
				gint _tmp111_ = 0;
				_tmp10_ = _tmp9_;
				if (!_tmp10_) {
					guint _tmp11_ = 0U;
					_tmp11_ = i;
					i = _tmp11_ + 1;
				}
				_tmp9_ = FALSE;
				_tmp12_ = i;
				_tmp13_ = netlist;
				_tmp14_ = _tmp13_.number;
				if (!(_tmp12_ < ((guint) _tmp14_))) {
					break;
				}
				_tmp15_ = devices;
				_tmp15__length1 = devices_length1;
				_tmp16_ = i;
				_tmp17_ = _tmp15_[_tmp16_];
				_tmp18_ = g_strdup (_tmp17_);
				device = _tmp18_;
				_tmp19_ = device;
				glibtop_get_netload (&_tmp20_, _tmp19_);
				netload = _tmp20_;
				_tmp21_ = device;
				_tmp22_ = g_strconcat ("Netload: ", _tmp21_, NULL);
				_tmp23_ = _tmp22_;
				g_debug ("netprovider.vala:59: %s", _tmp23_);
				_g_free0 (_tmp23_);
				_tmp24_ = netload;
				_tmp25_ = _tmp24_.flags;
				g_debug ("netprovider.vala:60:   flags: %x", (guint) ((guint32) _tmp25_));
				_tmp26_ = netload;
				_tmp27_ = _tmp26_.if_flags;
				g_debug ("netprovider.vala:61:   if flags: %x", (guint) ((guint32) _tmp27_));
				_tmp28_ = netload;
				_tmp29_ = _tmp28_.mtu;
				_tmp30_ = g_strdup_printf ("%u", _tmp29_);
				_tmp31_ = _tmp30_;
				_tmp32_ = g_strconcat ("  mtu: ", _tmp31_, NULL);
				_tmp33_ = _tmp32_;
				g_debug ("netprovider.vala:62: %s", _tmp33_);
				_g_free0 (_tmp33_);
				_g_free0 (_tmp31_);
				_tmp34_ = netload;
				_tmp35_ = _tmp34_.subnet;
				_tmp36_ = g_strdup_printf ("%u", _tmp35_);
				_tmp37_ = _tmp36_;
				_tmp38_ = g_strconcat ("  subnet: ", _tmp37_, NULL);
				_tmp39_ = _tmp38_;
				g_debug ("netprovider.vala:63: %s", _tmp39_);
				_g_free0 (_tmp39_);
				_g_free0 (_tmp37_);
				_tmp40_ = netload;
				_tmp41_ = _tmp40_.address;
				_tmp42_ = g_strdup_printf ("%u", _tmp41_);
				_tmp43_ = _tmp42_;
				_tmp44_ = g_strconcat ("  address: ", _tmp43_, NULL);
				_tmp45_ = _tmp44_;
				g_debug ("netprovider.vala:64: %s", _tmp45_);
				_g_free0 (_tmp45_);
				_g_free0 (_tmp43_);
				_tmp46_ = netload;
				_tmp47_ = _tmp46_.packets_in;
				_tmp48_ = g_strdup_printf ("%" G_GUINT64_FORMAT, _tmp47_);
				_tmp49_ = _tmp48_;
				_tmp50_ = g_strconcat ("  packets in: ", _tmp49_, NULL);
				_tmp51_ = _tmp50_;
				g_debug ("netprovider.vala:65: %s", _tmp51_);
				_g_free0 (_tmp51_);
				_g_free0 (_tmp49_);
				_tmp52_ = netload;
				_tmp53_ = _tmp52_.packets_out;
				_tmp54_ = g_strdup_printf ("%" G_GUINT64_FORMAT, _tmp53_);
				_tmp55_ = _tmp54_;
				_tmp56_ = g_strconcat ("  packets out: ", _tmp55_, NULL);
				_tmp57_ = _tmp56_;
				g_debug ("netprovider.vala:66: %s", _tmp57_);
				_g_free0 (_tmp57_);
				_g_free0 (_tmp55_);
				_tmp58_ = netload;
				_tmp59_ = _tmp58_.packets_total;
				_tmp60_ = g_strdup_printf ("%" G_GUINT64_FORMAT, _tmp59_);
				_tmp61_ = _tmp60_;
				_tmp62_ = g_strconcat ("  packets total: ", _tmp61_, NULL);
				_tmp63_ = _tmp62_;
				g_debug ("netprovider.vala:67: %s", _tmp63_);
				_g_free0 (_tmp63_);
				_g_free0 (_tmp61_);
				_tmp64_ = netload;
				_tmp65_ = _tmp64_.bytes_in;
				_tmp66_ = g_strdup_printf ("%" G_GUINT64_FORMAT, _tmp65_);
				_tmp67_ = _tmp66_;
				_tmp68_ = g_strconcat ("  bytes in: ", _tmp67_, NULL);
				_tmp69_ = _tmp68_;
				g_debug ("netprovider.vala:68: %s", _tmp69_);
				_g_free0 (_tmp69_);
				_g_free0 (_tmp67_);
				_tmp70_ = netload;
				_tmp71_ = _tmp70_.bytes_out;
				_tmp72_ = g_strdup_printf ("%" G_GUINT64_FORMAT, _tmp71_);
				_tmp73_ = _tmp72_;
				_tmp74_ = g_strconcat ("  bytes out: ", _tmp73_, NULL);
				_tmp75_ = _tmp74_;
				g_debug ("netprovider.vala:69: %s", _tmp75_);
				_g_free0 (_tmp75_);
				_g_free0 (_tmp73_);
				_tmp76_ = netload;
				_tmp77_ = _tmp76_.bytes_total;
				_tmp78_ = g_strdup_printf ("%" G_GUINT64_FORMAT, _tmp77_);
				_tmp79_ = _tmp78_;
				_tmp80_ = g_strconcat ("  bytes total: ", _tmp79_, NULL);
				_tmp81_ = _tmp80_;
				g_debug ("netprovider.vala:70: %s", _tmp81_);
				_g_free0 (_tmp81_);
				_g_free0 (_tmp79_);
				_tmp82_ = netload;
				_tmp83_ = _tmp82_.errors_in;
				_tmp84_ = g_strdup_printf ("%" G_GUINT64_FORMAT, _tmp83_);
				_tmp85_ = _tmp84_;
				_tmp86_ = g_strconcat ("  errors in: ", _tmp85_, NULL);
				_tmp87_ = _tmp86_;
				g_debug ("netprovider.vala:71: %s", _tmp87_);
				_g_free0 (_tmp87_);
				_g_free0 (_tmp85_);
				_tmp88_ = netload;
				_tmp89_ = _tmp88_.errors_out;
				_tmp90_ = g_strdup_printf ("%" G_GUINT64_FORMAT, _tmp89_);
				_tmp91_ = _tmp90_;
				_tmp92_ = g_strconcat ("  errors out: ", _tmp91_, NULL);
				_tmp93_ = _tmp92_;
				g_debug ("netprovider.vala:72: %s", _tmp93_);
				_g_free0 (_tmp93_);
				_g_free0 (_tmp91_);
				_tmp94_ = netload;
				_tmp95_ = _tmp94_.errors_total;
				_tmp96_ = g_strdup_printf ("%" G_GUINT64_FORMAT, _tmp95_);
				_tmp97_ = _tmp96_;
				_tmp98_ = g_strconcat ("  errors total: ", _tmp97_, NULL);
				_tmp99_ = _tmp98_;
				g_debug ("netprovider.vala:73: %s", _tmp99_);
				_g_free0 (_tmp99_);
				_g_free0 (_tmp97_);
				_tmp100_ = netload;
				_tmp101_ = _tmp100_.collisions;
				_tmp102_ = g_strdup_printf ("%" G_GUINT64_FORMAT, _tmp101_);
				_tmp103_ = _tmp102_;
				_tmp104_ = g_strconcat ("  collisions: ", _tmp103_, NULL);
				_tmp105_ = _tmp104_;
				g_debug ("netprovider.vala:74: %s", _tmp105_);
				_g_free0 (_tmp105_);
				_g_free0 (_tmp103_);
				_tmp106_ = netload;
				_tmp107_ = _tmp106_.if_flags;
				_tmp108_ = GLIBTOP_IF_FLAGS_UP;
				_tmp109_ = netload;
				_tmp110_ = _tmp109_.if_flags;
				_tmp111_ = GLIBTOP_IF_FLAGS_RUNNING;
				if (((_tmp107_ & (1L << _tmp108_)) == ((guint64) 0)) | ((_tmp110_ & (1L << _tmp111_)) == ((guint64) 0))) {
					g_debug ("netprovider.vala:78:   down or not running");
				} else {
					const gchar* _tmp112_ = NULL;
					gchar* _tmp113_ = NULL;
					gchar* _tmp114_ = NULL;
					gboolean _tmp115_ = FALSE;
					gboolean _tmp116_ = FALSE;
					_tmp112_ = device;
					_tmp113_ = g_strdup_printf ("/sys/class/net/%s/device", _tmp112_);
					_tmp114_ = _tmp113_;
					_tmp115_ = g_file_test (_tmp114_, G_FILE_TEST_EXISTS);
					_tmp116_ = _tmp115_;
					_g_free0 (_tmp114_);
					if (_tmp116_) {
						guint64* _tmp117_ = NULL;
						gint _tmp117__length1 = 0;
						glibtop_netload _tmp118_ = {0};
						guint64 _tmp119_ = 0ULL;
						guint64 _tmp120_ = 0ULL;
						guint64* _tmp121_ = NULL;
						gint _tmp121__length1 = 0;
						glibtop_netload _tmp122_ = {0};
						guint64 _tmp123_ = 0ULL;
						guint64 _tmp124_ = 0ULL;
						_tmp117_ = newdata;
						_tmp117__length1 = newdata_length1;
						_tmp118_ = netload;
						_tmp119_ = _tmp118_.bytes_in;
						_tmp117_[0] += _tmp119_;
						_tmp120_ = _tmp117_[0];
						_tmp121_ = newdata;
						_tmp121__length1 = newdata_length1;
						_tmp122_ = netload;
						_tmp123_ = _tmp122_.bytes_out;
						_tmp121_[1] += _tmp123_;
						_tmp124_ = _tmp121_[1];
						g_debug ("netprovider.vala:82:   existing device link");
					} else {
						glibtop_netload _tmp125_ = {0};
						guint64 _tmp126_ = 0ULL;
						gint _tmp127_ = 0;
						_tmp125_ = netload;
						_tmp126_ = _tmp125_.if_flags;
						_tmp127_ = GLIBTOP_IF_FLAGS_POINTOPOINT;
						if ((_tmp126_ & (1L << _tmp127_)) > ((guint64) 0)) {
							guint64* _tmp128_ = NULL;
							gint _tmp128__length1 = 0;
							glibtop_netload _tmp129_ = {0};
							guint64 _tmp130_ = 0ULL;
							guint64 _tmp131_ = 0ULL;
							guint64* _tmp132_ = NULL;
							gint _tmp132__length1 = 0;
							glibtop_netload _tmp133_ = {0};
							guint64 _tmp134_ = 0ULL;
							guint64 _tmp135_ = 0ULL;
							_tmp128_ = newdata;
							_tmp128__length1 = newdata_length1;
							_tmp129_ = netload;
							_tmp130_ = _tmp129_.bytes_in;
							_tmp128_[0] += _tmp130_;
							_tmp131_ = _tmp128_[0];
							_tmp132_ = newdata;
							_tmp132__length1 = newdata_length1;
							_tmp133_ = netload;
							_tmp134_ = _tmp133_.bytes_out;
							_tmp132_[1] += _tmp134_;
							_tmp135_ = _tmp132_[1];
							g_debug ("netprovider.vala:86:   pointtopoint");
						} else {
							glibtop_netload _tmp136_ = {0};
							guint64 _tmp137_ = 0ULL;
							gint _tmp138_ = 0;
							_tmp136_ = netload;
							_tmp137_ = _tmp136_.if_flags;
							_tmp138_ = GLIBTOP_IF_FLAGS_LOOPBACK;
							if ((_tmp137_ & (1L << _tmp138_)) > ((guint64) 0)) {
								guint64* _tmp139_ = NULL;
								gint _tmp139__length1 = 0;
								glibtop_netload _tmp140_ = {0};
								guint64 _tmp141_ = 0ULL;
								guint64 _tmp142_ = 0ULL;
								_tmp139_ = newdata;
								_tmp139__length1 = newdata_length1;
								_tmp140_ = netload;
								_tmp141_ = _tmp140_.bytes_in;
								_tmp139_[2] += _tmp141_;
								_tmp142_ = _tmp139_[2];
								g_debug ("netprovider.vala:89:   loopback");
							} else {
								g_debug ("netprovider.vala:91:   unknown");
							}
						}
					}
				}
				{
					guint j = 0U;
					guint isize = 0U;
					gchar** _tmp143_ = NULL;
					gint _tmp143__length1 = 0;
					j = (guint) 0;
					_tmp143_ = self->priv->devicefields;
					_tmp143__length1 = self->priv->devicefields_length1;
					isize = (guint) _tmp143__length1;
					{
						gboolean _tmp144_ = FALSE;
						_tmp144_ = TRUE;
						while (TRUE) {
							gboolean _tmp145_ = FALSE;
							guint _tmp147_ = 0U;
							guint _tmp148_ = 0U;
							gchar** _tmp149_ = NULL;
							gint _tmp149__length1 = 0;
							guint _tmp150_ = 0U;
							const gchar* _tmp151_ = NULL;
							const gchar* _tmp152_ = NULL;
							_tmp145_ = _tmp144_;
							if (!_tmp145_) {
								guint _tmp146_ = 0U;
								_tmp146_ = j;
								j = _tmp146_ + 1;
							}
							_tmp144_ = FALSE;
							_tmp147_ = j;
							_tmp148_ = isize;
							if (!(_tmp147_ < _tmp148_)) {
								break;
							}
							_tmp149_ = self->priv->devicefields;
							_tmp149__length1 = self->priv->devicefields_length1;
							_tmp150_ = j;
							_tmp151_ = _tmp149_[_tmp150_];
							_tmp152_ = device;
							if (g_strcmp0 (_tmp151_, _tmp152_) == 0) {
								guint64* _tmp153_ = NULL;
								gint _tmp153__length1 = 0;
								guint _tmp154_ = 0U;
								glibtop_netload _tmp155_ = {0};
								guint64 _tmp156_ = 0ULL;
								guint64 _tmp157_ = 0ULL;
								guint64* _tmp158_ = NULL;
								gint _tmp158__length1 = 0;
								guint _tmp159_ = 0U;
								glibtop_netload _tmp160_ = {0};
								guint64 _tmp161_ = 0ULL;
								guint64 _tmp162_ = 0ULL;
								_tmp153_ = newdata;
								_tmp153__length1 = newdata_length1;
								_tmp154_ = j;
								_tmp155_ = netload;
								_tmp156_ = _tmp155_.bytes_in;
								_tmp153_[3 + (_tmp154_ * 2)] = _tmp156_;
								_tmp157_ = _tmp153_[3 + (_tmp154_ * 2)];
								_tmp158_ = newdata;
								_tmp158__length1 = newdata_length1;
								_tmp159_ = j;
								_tmp160_ = netload;
								_tmp161_ = _tmp160_.bytes_out;
								_tmp158_[(3 + (_tmp159_ * 2)) + 1] = _tmp161_;
								_tmp162_ = _tmp158_[(3 + (_tmp159_ * 2)) + 1];
								break;
							}
						}
					}
				}
				_g_free0 (device);
			}
		}
	}
	_tmp163_ = self->priv->lastdata;
	_tmp163__length1 = self->priv->lastdata_length1;
	if (_tmp163__length1 != 0) {
		gdouble delta = 0.0;
		guint64 _tmp164_ = 0ULL;
		guint64 _tmp165_ = 0ULL;
		_tmp164_ = newtime;
		_tmp165_ = self->priv->lasttime;
		delta = (_tmp164_ - _tmp165_) / 1e6;
		{
			guint i = 0U;
			guint isize = 0U;
			gdouble* _tmp166_ = NULL;
			gint _tmp166__length1 = 0;
			gdouble* _tmp167_ = NULL;
			gint _tmp167__length1 = 0;
			i = (guint) 0;
			_tmp166_ = provider_get_values (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_PROVIDER, Provider), &_tmp166__length1);
			_tmp167_ = _tmp166_;
			_tmp167__length1 = _tmp166__length1;
			isize = (guint) _tmp167__length1;
			{
				gboolean _tmp168_ = FALSE;
				_tmp168_ = TRUE;
				while (TRUE) {
					gboolean _tmp169_ = FALSE;
					guint _tmp171_ = 0U;
					guint _tmp172_ = 0U;
					gdouble* _tmp173_ = NULL;
					gint _tmp173__length1 = 0;
					gdouble* _tmp174_ = NULL;
					gint _tmp174__length1 = 0;
					guint _tmp175_ = 0U;
					guint64* _tmp176_ = NULL;
					gint _tmp176__length1 = 0;
					guint _tmp177_ = 0U;
					guint64 _tmp178_ = 0ULL;
					guint64* _tmp179_ = NULL;
					gint _tmp179__length1 = 0;
					guint _tmp180_ = 0U;
					guint64 _tmp181_ = 0ULL;
					gdouble _tmp182_ = 0.0;
					gdouble _tmp183_ = 0.0;
					_tmp169_ = _tmp168_;
					if (!_tmp169_) {
						guint _tmp170_ = 0U;
						_tmp170_ = i;
						i = _tmp170_ + 1;
					}
					_tmp168_ = FALSE;
					_tmp171_ = i;
					_tmp172_ = isize;
					if (!(_tmp171_ < _tmp172_)) {
						break;
					}
					_tmp173_ = provider_get_values (G_TYPE_CHECK_INSTANCE_CAST (self, TYPE_PROVIDER, Provider), &_tmp173__length1);
					_tmp174_ = _tmp173_;
					_tmp174__length1 = _tmp173__length1;
					_tmp175_ = i;
					_tmp176_ = newdata;
					_tmp176__length1 = newdata_length1;
					_tmp177_ = i;
					_tmp178_ = _tmp176_[_tmp177_];
					_tmp179_ = self->priv->lastdata;
					_tmp179__length1 = self->priv->lastdata_length1;
					_tmp180_ = i;
					_tmp181_ = _tmp179_[_tmp180_];
					_tmp182_ = delta;
					_tmp174_[_tmp175_] = (_tmp178_ - _tmp181_) / _tmp182_;
					_tmp183_ = _tmp174_[_tmp175_];
				}
			}
		}
	}
	_tmp184_ = newdata;
	_tmp184__length1 = newdata_length1;
	_tmp185_ = (_tmp184_ != NULL) ? _vala_array_dup22 (_tmp184_, _tmp184__length1) : ((gpointer) _tmp184_);
	_tmp185__length1 = _tmp184__length1;
	self->priv->lastdata = (g_free (self->priv->lastdata), NULL);
	self->priv->lastdata = _tmp185_;
	self->priv->lastdata_length1 = _tmp185__length1;
	self->priv->_lastdata_size_ = self->priv->lastdata_length1;
	_tmp186_ = newtime;
	self->priv->lasttime = _tmp186_;
	devices = (_vala_array_free (devices, devices_length1, (GDestroyNotify) g_free), NULL);
	newdata = (g_free (newdata), NULL);
}


static void net_provider_class_init (NetProviderClass * klass) {
	net_provider_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (NetProviderPrivate));
	PROVIDER_CLASS (klass)->update = net_provider_real_update;
	G_OBJECT_CLASS (klass)->finalize = net_provider_finalize;
}


static void net_provider_instance_init (NetProvider * self) {
	self->priv = NET_PROVIDER_GET_PRIVATE (self);
}


static void net_provider_finalize (GObject* obj) {
	NetProvider * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_NET_PROVIDER, NetProvider);
	self->priv->lastdata = (g_free (self->priv->lastdata), NULL);
	self->priv->devicefields = (_vala_array_free (self->priv->devicefields, self->priv->devicefields_length1, (GDestroyNotify) g_free), NULL);
	G_OBJECT_CLASS (net_provider_parent_class)->finalize (obj);
}


/******************************************************************************
 * Copyright (C) 2011-2013  Michael Hofmann <mh21@mh21.de>                    *
 *                                                                            *
 * This program is free software; you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by       *
 * the Free Software Foundation; either version 3 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 General Public License for more details.                               *
 *                                                                            *
 * You should have received a copy of the GNU General Public License along    *
 * with this program; if not, write to the Free Software Foundation, Inc.,    *
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.                *
 ******************************************************************************/
GType net_provider_get_type (void) {
	static volatile gsize net_provider_type_id__volatile = 0;
	if (g_once_init_enter (&net_provider_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (NetProviderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) net_provider_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NetProvider), 0, (GInstanceInitFunc) net_provider_instance_init, NULL };
		GType net_provider_type_id;
		net_provider_type_id = g_type_register_static (TYPE_PROVIDER, "NetProvider", &g_define_type_info, 0);
		g_once_init_leave (&net_provider_type_id__volatile, net_provider_type_id);
	}
	return net_provider_type_id__volatile;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}


static gint _vala_array_length (gpointer array) {
	int length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}



