#include "ui/gtk/main.h" #include "ui/gtk/follow_udp.h" static gboolean udp_queue_packet_data(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const void *data) { follow_record_t *follow_record; follow_info_t *follow_info = (follow_info_t *)tapdata; tvbuff_t *next_tvb = (tvbuff_t *)data; follow_record = g_new(follow_record_t,1); follow_record->data = g_byte_array_sized_new(tvb_captured_length(next_tvb)); follow_record->data = g_byte_array_append(follow_record->data, tvb_get_ptr(next_tvb, 0, -1), tvb_captured_length(next_tvb)); if (follow_info->client_port == 0) { follow_info->client_port = pinfo->srcport; COPY_ADDRESS(&follow_info->client_ip, &pinfo->src); } if (ADDRESSES_EQUAL(&follow_info->client_ip, &pinfo->src) && follow_info->client_port == pinfo->srcport) follow_record->is_server = FALSE; else follow_record->is_server = TRUE; /* update stream counter */ follow_info->bytes_written[follow_record->is_server] += follow_record->data->len;
int main(int argc, char **argv) { char c; guint i; struct termios tcattr; GByteArray *bytes; gboolean done = FALSE, saved = FALSE; struct timeval tv; fd_set readset; /* Start up: save the cursor location and put the terminal in * raw mode. */ bytes = g_byte_array_new(); save_cursor(); if (tcgetattr(STDIN_FILENO, &tcattr) != 0) { perror("tcgetattr"); return 1; } original = tcattr; signal(SIGINT, sigint_handler); /* Here we approximate what cfmakeraw() would do, for the benefit * of systems which don't actually provide the function. */ tcattr.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON); tcattr.c_oflag &= ~(OPOST); tcattr.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); tcattr.c_cflag &= ~(CSIZE | PARENB); tcattr.c_cflag |= CS8; #ifdef HAVE_CFMAKERAW cfmakeraw(&tcattr); #endif if (tcsetattr(STDIN_FILENO, TCSANOW, &tcattr) != 0) { perror("tcsetattr"); return 1; } /* Switch to the alternate screen, clear it, and reset the keyboard. */ decset(MODE_ALTERNATE_SCREEN, TRUE); clear(); reset(); /* Main processing loop. */ while (!done) { print_help(); set_scrolling_region(); if (saved) { restore_cursor(); } /* Read a single byte. */ if (read(STDIN_FILENO, &c, 1) != 1) { done = TRUE; } switch (c) { case 'A': case 'a': keypad_mode = 1 - keypad_mode; if (keypad_mode == normal) { g_print(MODE_NORMAL_KEYPAD); } else { g_print(MODE_APPLICATION_KEYPAD); } break; case 'B': case 'b': cursor_mode = 1 - cursor_mode; decset(MODE_APPLICATION_CURSOR_KEYS, cursor_mode == application); break; case 'C': case 'c': sun_fkeys = !sun_fkeys; decset(MODE_SUN_FUNCTION_KEYS, sun_fkeys); break; case 'D': case 'd': hp_fkeys = !hp_fkeys; decset(MODE_HP_FUNCTION_KEYS, hp_fkeys); break; case 'E': case 'e': xterm_fkeys = !xterm_fkeys; decset(MODE_XTERM_FUNCTION_KEYS, xterm_fkeys); break; case 'F': case 'f': vt220_fkeys = !vt220_fkeys; decset(MODE_VT220_FUNCTION_KEYS, vt220_fkeys); break; case 'R': case 'r': keypad_mode = cursor_mode = normal; sun_fkeys = hp_fkeys = xterm_fkeys = vt220_fkeys = FALSE; reset(); break; case 'Q': case 'q': done = TRUE; break; case 0x0c: /* ^L */ clear(); if (saved) { restore_cursor(); saved = FALSE; } break; default: /* We get here if it's not one of the keys we care * about, so it might be a sequence. */ if (saved) { restore_cursor(); } g_byte_array_append(bytes, &c, 1); /* Wait for up to just under 1/50 second. */ tv.tv_sec = 0; tv.tv_usec = 1000000 / 50; FD_ZERO(&readset); FD_SET(STDIN_FILENO, &readset); while (select(STDIN_FILENO + 1, &readset, NULL, NULL, &tv) == 1) { if (read(STDIN_FILENO, &c, 1) == 1) { g_byte_array_append(bytes, &c, 1); } else { break; } tv.tv_sec = 0; tv.tv_usec = 1000000 / 50; FD_ZERO(&readset); FD_SET(STDIN_FILENO, &readset); } /* Clear this line, and print the sequence. */ g_print(ESC "[K"); for (i = 0; i < bytes->len; i++) { if (bytes->data[i] == 27) { g_print("<ESC> "); } else if ((((guint8)bytes->data[i]) < 32) || (((guint8)bytes->data[i]) > 126)) { g_print("<0x%02x> ", bytes->data[i]); } else { g_print("`%c' ", bytes->data[i]); } } g_print("\r\n"); g_byte_array_set_size(bytes, 0); save_cursor(); saved = TRUE; break; } reset_scrolling_region(); } decset(MODE_ALTERNATE_SCREEN, FALSE); if (tcsetattr(STDIN_FILENO, TCSANOW, &original) != 0) { perror("tcsetattr"); return 1; } g_byte_array_free(bytes, TRUE); reset(); return 0; }
int main (int argc, char *argv[]) { char *bad_domains = NULL; GError *error = NULL; gboolean wrote_pidfile = FALSE; gs_free char *pidfile = NULL; gs_unref_object NMDhcpClient *dhcp4_client = NULL; gs_unref_object NMRDisc *rdisc = NULL; GByteArray *hwaddr = NULL; size_t hwaddr_len = 0; gconstpointer tmp; gs_free NMUtilsIPv6IfaceId *iid = NULL; guint sd_id; nm_g_type_init (); setpgid (getpid (), getpid ()); do_early_setup (&argc, &argv); if (global_opt.g_fatal_warnings) { GLogLevelFlags fatal_mask; fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK); fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL; g_log_set_always_fatal (fatal_mask); } if (global_opt.show_version) { fprintf (stdout, NM_DIST_VERSION "\n"); exit (0); } nm_main_utils_ensure_root (); if (!global_opt.ifname || !global_opt.uuid) { fprintf (stderr, _("An interface name and UUID are required\n")); exit (1); } ifindex = if_nametoindex (global_opt.ifname); if (ifindex <= 0) { fprintf (stderr, _("Failed to find interface index for %s (%s)\n"), global_opt.ifname, strerror (errno)); exit (1); } pidfile = g_strdup_printf (NMIH_PID_FILE_FMT, ifindex); nm_main_utils_ensure_not_running_pidfile (pidfile); nm_main_utils_ensure_rundir (); if (!nm_logging_setup (global_opt.opt_log_level, global_opt.opt_log_domains, &bad_domains, &error)) { fprintf (stderr, _("%s. Please use --help to see a list of valid options.\n"), error->message); exit (1); } else if (bad_domains) { fprintf (stderr, _("Ignoring unrecognized log domain(s) '%s' passed on command line.\n"), bad_domains); g_clear_pointer (&bad_domains, g_free); } if (global_opt.become_daemon && !global_opt.debug) { if (daemon (0, 0) < 0) { int saved_errno; saved_errno = errno; fprintf (stderr, _("Could not daemonize: %s [error %u]\n"), g_strerror (saved_errno), saved_errno); exit (1); } if (nm_main_utils_write_pidfile (pidfile)) wrote_pidfile = TRUE; } /* Set up unix signal handling - before creating threads, but after daemonizing! */ main_loop = g_main_loop_new (NULL, FALSE); setup_signals (); nm_logging_syslog_openlog (global_opt.logging_backend ? global_opt.logging_backend : (global_opt.debug ? "debug" : NULL)); nm_log_info (LOGD_CORE, "nm-iface-helper (version " NM_DIST_VERSION ") is starting..."); /* Set up platform interaction layer */ nm_linux_platform_setup (); /* Set up dummy network namespace control */ nm_netns_controller_setup (); tmp = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &hwaddr_len); if (tmp) { hwaddr = g_byte_array_sized_new (hwaddr_len); g_byte_array_append (hwaddr, tmp, hwaddr_len); } if (global_opt.iid_str) { GBytes *bytes; gsize ignored = 0; bytes = nm_utils_hexstr2bin (global_opt.iid_str); if (!bytes || g_bytes_get_size (bytes) != sizeof (*iid)) { fprintf (stderr, _("(%s): Invalid IID %s\n"), global_opt.ifname, global_opt.iid_str); exit (1); } iid = g_bytes_unref_to_data (bytes, &ignored); } if (global_opt.dhcp4_address) { nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip4_property_path (global_opt.ifname, "promote_secondaries"), "1"); dhcp4_client = nm_dhcp_manager_start_ip4 (nm_dhcp_manager_get (), global_opt.ifname, ifindex, hwaddr, global_opt.uuid, global_opt.priority_v4, !!global_opt.dhcp4_hostname, global_opt.dhcp4_hostname, global_opt.dhcp4_fqdn, global_opt.dhcp4_clientid, 45, NULL, global_opt.dhcp4_address); g_assert (dhcp4_client); g_signal_connect (dhcp4_client, NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED, G_CALLBACK (dhcp4_state_changed), NULL); } if (global_opt.slaac) { nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, ifindex, TRUE); rdisc = nm_lndp_rdisc_new (NM_PLATFORM_GET, ifindex, global_opt.ifname, global_opt.uuid, global_opt.addr_gen_mode, NULL); g_assert (rdisc); if (iid) nm_rdisc_set_iid (rdisc, *iid); nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra"), "1"); nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_defrtr"), "0"); nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_pinfo"), "0"); nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_rtr_pref"), "0"); g_signal_connect (NM_PLATFORM_GET, NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, G_CALLBACK (ip6_address_changed), rdisc); g_signal_connect (rdisc, NM_RDISC_CONFIG_CHANGED, G_CALLBACK (rdisc_config_changed), NULL); g_signal_connect (rdisc, NM_RDISC_RA_TIMEOUT, G_CALLBACK (rdisc_ra_timeout), NULL); nm_rdisc_start (rdisc); } sd_id = nm_sd_event_attach_default (); g_main_loop_run (main_loop); g_clear_pointer (&hwaddr, g_byte_array_unref); if (pidfile && wrote_pidfile) unlink (pidfile); nm_log_info (LOGD_CORE, "exiting"); nm_clear_g_source (&sd_id); exit (0); }
static gpointer build_ip6_address_or_route (const char *key_name, const char *address_str, guint32 plen, const char *gateway_str, const char *metric_str, gboolean route) { GValueArray *result; struct in6_addr addr; GByteArray *address; GByteArray *gateway; guint32 metric = 0; GValue value = G_VALUE_INIT; int err; g_return_val_if_fail (address_str, NULL); result = g_value_array_new (3); /* add address */ err = inet_pton (AF_INET6, address_str, &addr); if (err <= 0) { g_warning ("%s: ignoring invalid IPv6 address '%s'", __func__, address_str); goto error_out; } address = g_byte_array_new (); g_byte_array_append (address, (guint8 *) addr.s6_addr, 16); g_value_init (&value, DBUS_TYPE_G_UCHAR_ARRAY); g_value_take_boxed (&value, address); g_value_array_append (result, &value); g_value_unset (&value); /* add prefix length */ g_value_init (&value, G_TYPE_UINT); g_value_set_uint (&value, plen); g_value_array_append (result, &value); g_value_unset (&value); /* add gateway */ if (gateway_str && gateway_str[0]) { err = inet_pton (AF_INET6, gateway_str, &addr); if (err <= 0) { /* Try workaround for routes written by broken keyfile writer. * Due to bug bgo#719851, an older version of writer would have * written "a:b:c:d::/plen,metric" if the gateway was ::, instead * of "a:b:c:d::/plen,,metric" or "a:b:c:d::/plen,::,metric" * Try workaround by interepeting gateway_str as metric to accept such * invalid routes. This broken syntax should not be not officially * supported. **/ if (route && !metric_str && get_one_int (gateway_str, G_MAXUINT32, NULL, &metric)) addr = in6addr_any; else { g_warning ("%s: ignoring invalid IPv6 gateway '%s'", __func__, gateway_str); goto error_out; } } } else addr = in6addr_any; /* parse metric, default to 0 */ if (metric_str) { if (!get_one_int (metric_str, G_MAXUINT32, key_name, &metric)) goto error_out; } gateway = g_byte_array_new (); g_byte_array_append (gateway, (guint8 *) addr.s6_addr, 16); g_value_init (&value, DBUS_TYPE_G_UCHAR_ARRAY); g_value_take_boxed (&value, gateway); g_value_array_append (result, &value); g_value_unset (&value); /* add metric (for routing) */ if (route) { g_value_init (&value, G_TYPE_UINT); g_value_set_uint (&value, metric); g_value_array_append (result, &value); g_value_unset (&value); } return result; error_out: g_value_array_free (result); return NULL; }
static guint8 * mongo_message_update_save_to_data (MongoMessage *message, gsize *length) { static const guint8 empty_bson[] = { 5, 0, 0, 0, 0 }; MongoMessageUpdatePrivate *priv; MongoMessageUpdate *update = (MongoMessageUpdate *)message; GByteArray *bytes; guint32 v32; guint8 *ret; ENTRY; g_assert(MONGO_IS_MESSAGE_UPDATE(update)); g_assert(length); priv = update->priv; bytes = g_byte_array_sized_new(64); v32 = 0; g_byte_array_append(bytes, (guint8 *)&v32, sizeof v32); v32 = GINT32_TO_LE(mongo_message_get_request_id(message)); g_byte_array_append(bytes, (guint8 *)&v32, sizeof v32); v32 = GINT32_TO_LE(mongo_message_get_response_to(message)); g_byte_array_append(bytes, (guint8 *)&v32, sizeof v32); v32 = GUINT32_TO_LE(MONGO_OPERATION_UPDATE); g_byte_array_append(bytes, (guint8 *)&v32, sizeof v32); /* Zero, reserved. */ v32 = 0; g_byte_array_append(bytes, (guint8 *)&v32, sizeof v32); /* Collection name */ g_byte_array_append(bytes, (guint8 *)(priv->collection ?: ""), strlen(priv->collection ?: "") + 1); /* Update flags. */ v32 = GUINT32_TO_LE(priv->flags); g_byte_array_append(bytes, (guint8 *)&v32, sizeof v32); /* Query */ if (priv->query) { g_byte_array_append(bytes, priv->query->data, priv->query->len); } else { g_byte_array_append(bytes, empty_bson, G_N_ELEMENTS(empty_bson)); } /* Update */ if (priv->update) { g_byte_array_append(bytes, priv->update->data, priv->update->len); } else { g_byte_array_append(bytes, empty_bson, G_N_ELEMENTS(empty_bson)); } /* Update the message length */ v32 = GUINT32_TO_LE(bytes->len); memcpy(bytes->data, &v32, sizeof v32); *length = bytes->len; DUMP_BYTES(buf, bytes->data, bytes->len); ret = g_byte_array_free(bytes, FALSE); RETURN(ret); }
static GPtrArray * read_ip6_routes (GKeyFile *file, const char *setting_name, const char *key) { GPtrArray *routes; struct in6_addr addr; guint32 prefix, metric; int i = 0; routes = g_ptr_array_sized_new (3); /* Look for individual routes */ while (i++ < 1000) { gchar **tmp; char *key_name, *str_prefix; gsize length = 0; int ret; GValueArray *values; GByteArray *address; GValue value = { 0 }; key_name = g_strdup_printf ("%s%d", key, i); tmp = g_key_file_get_string_list (file, setting_name, key_name, &length, NULL); g_free (key_name); if (!tmp || !length) break; /* all done */ if (length != 3) { g_warning ("%s: ignoring invalid IPv6 address item '%s'", __func__, key_name); goto next; } /* convert the string array into IPv6 routes */ values = g_value_array_new (4); /* NMIP6Route has 4 items */ /* Split the route and prefix */ str_prefix = split_prefix (tmp[0]); /* destination address */ ret = inet_pton (AF_INET6, tmp[0], &addr); if (ret <= 0) { g_warning ("%s: ignoring invalid IPv6 %s element '%s'", __func__, key_name, tmp[0]); g_value_array_free (values); goto next; } address = g_byte_array_new (); g_byte_array_append (address, (guint8 *) addr.s6_addr, 16); g_value_init (&value, DBUS_TYPE_G_UCHAR_ARRAY); g_value_take_boxed (&value, address); g_value_array_append (values, &value); g_value_unset (&value); /* prefix */ prefix = 0; if (str_prefix) { if (!get_one_int (str_prefix, 128, key_name, &prefix)) { g_value_array_free (values); goto next; } } else { /* default to 64 if unspecified */ prefix = 64; } g_value_init (&value, G_TYPE_UINT); g_value_set_uint (&value, prefix); g_value_array_append (values, &value); g_value_unset (&value); /* next hop address */ ret = inet_pton (AF_INET6, tmp[1], &addr); if (ret <= 0) { g_warning ("%s: ignoring invalid IPv6 %s element '%s'", __func__, key_name, tmp[1]); g_value_array_free (values); goto next; } address = g_byte_array_new (); g_byte_array_append (address, (guint8 *) addr.s6_addr, 16); g_value_init (&value, DBUS_TYPE_G_UCHAR_ARRAY); g_value_take_boxed (&value, address); g_value_array_append (values, &value); g_value_unset (&value); /* metric */ metric = 0; if (!get_one_int (tmp[2], G_MAXUINT32, key_name, &metric)) { g_value_array_free (values); goto next; } g_value_init (&value, G_TYPE_UINT); g_value_set_uint (&value, metric); g_value_array_append (values, &value); g_value_unset (&value); g_ptr_array_add (routes, values); next: g_strfreev (tmp); } if (routes->len < 1) { g_ptr_array_free (routes, TRUE); routes = NULL; } return routes; }
/* Setup header fields (From:/To:/Date: etc) and message body for the e-mail. * This data is supposed to be sent to libcurl just before any media data. * This function is called once for each e-mail: * 1. we are about the send the first attachment * 2. we have sent all the attachments and continue sending new ones within * a new e-mail (transfer options have been reset). */ static gboolean gst_curl_smtp_sink_set_transfer_options_unlocked (GstCurlBaseSink * bcsink) { GstCurlSmtpSink *sink = GST_CURL_SMTP_SINK (bcsink); GstCurlTlsSinkClass *parent_class; gchar *request_headers; GDateTime *date; gchar *date_str; gchar **tmp_list = NULL; gchar *subject_header = NULL; gchar *message_body = NULL; gchar *rcpt_header = NULL; gchar *enc_rcpt; gchar *from_header = NULL; gchar *enc_from; gint i; g_assert (sink->payload_headers == NULL); g_assert (sink->mail_rcpt != NULL); g_assert (sink->mail_from != NULL); /* time */ date = g_date_time_new_now_local (); date_str = g_date_time_format (date, "%a %b %e %H:%M:%S %Y"); g_date_time_unref (date); /* recipient, sender and subject are all UTF-8 strings, which are additionally * base64-encoded */ /* recipient */ enc_rcpt = generate_encoded_word (sink->mail_rcpt); rcpt_header = g_strdup_printf ("%s <%s>", enc_rcpt, sink->mail_rcpt); g_free (enc_rcpt); /* sender */ enc_from = generate_encoded_word (sink->mail_from); from_header = g_strdup_printf ("%s <%s>", enc_from, sink->mail_from); g_free (enc_from); /* subject */ if (sink->subject != NULL) { subject_header = generate_encoded_word (sink->subject); } /* message */ if (sink->message_body != NULL) { message_body = g_base64_encode ((const guchar *) sink->message_body, strlen (sink->message_body)); } request_headers = g_strdup_printf ( /* headers */ "To: %s\r\n" "From: %s\r\n" "Subject: %s\r\n" "Date: %s\r\n" MIME_VERSION "\r\n" "Content-Type: multipart/mixed; boundary=%s\r\n" "\r\n" /* body headers */ "--" BOUNDARY_STRING "\r\n" "Content-Type: text/plain; charset=utf-8\r\n" "Content-Transfer-Encoding: BASE64\r\n" /* message body */ "\r\n%s\r\n", rcpt_header, from_header, subject_header ? subject_header : "", date_str, BOUNDARY_STRING, message_body ? message_body : ""); sink->payload_headers = g_byte_array_new (); g_byte_array_append (sink->payload_headers, (guint8 *) request_headers, strlen (request_headers)); g_free (date_str); g_free (subject_header); g_free (message_body); g_free (rcpt_header); g_free (from_header); g_free (request_headers); curl_easy_setopt (bcsink->curl, CURLOPT_MAIL_FROM, sink->mail_from); if (sink->curl_recipients != NULL) { curl_slist_free_all (sink->curl_recipients); sink->curl_recipients = NULL; } tmp_list = g_strsplit_set (sink->mail_rcpt, MAIL_RCPT_DELIMITER, -1); for (i = 0; i < g_strv_length (tmp_list); i++) { sink->curl_recipients = curl_slist_append (sink->curl_recipients, tmp_list[i]); } g_strfreev (tmp_list); /* note that the CURLOPT_MAIL_RCPT takes a list, not a char array */ curl_easy_setopt (bcsink->curl, CURLOPT_MAIL_RCPT, sink->curl_recipients); parent_class = GST_CURL_TLS_SINK_GET_CLASS (sink); if (sink->use_ssl) { return parent_class->set_options_unlocked (bcsink); } return TRUE; }
static gboolean complete_connection (NMDevice *device, NMConnection *connection, const char *specific_object, const GSList *existing_connections, GError **error) { NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device); NMSettingBluetooth *s_bt; const GByteArray *setting_bdaddr; struct ether_addr *devaddr = ether_aton (priv->bdaddr); const char *ctype; gboolean is_dun = FALSE, is_pan = FALSE; NMSettingGsm *s_gsm; NMSettingCdma *s_cdma; NMSettingSerial *s_serial; NMSettingPPP *s_ppp; const char *format = NULL, *preferred = NULL; s_gsm = nm_connection_get_setting_gsm (connection); s_cdma = nm_connection_get_setting_cdma (connection); s_serial = nm_connection_get_setting_serial (connection); s_ppp = nm_connection_get_setting_ppp (connection); s_bt = nm_connection_get_setting_bluetooth (connection); if (!s_bt) { s_bt = (NMSettingBluetooth *) nm_setting_bluetooth_new (); nm_connection_add_setting (connection, NM_SETTING (s_bt)); } ctype = nm_setting_bluetooth_get_connection_type (s_bt); if (ctype) { if (!strcmp (ctype, NM_SETTING_BLUETOOTH_TYPE_DUN)) is_dun = TRUE; else if (!strcmp (ctype, NM_SETTING_BLUETOOTH_TYPE_PANU)) is_pan = TRUE; } else { if (s_gsm || s_cdma) is_dun = TRUE; else if (priv->capabilities & NM_BT_CAPABILITY_NAP) is_pan = TRUE; } if (is_pan) { /* Make sure the device supports PAN */ if (!(priv->capabilities & NM_BT_CAPABILITY_NAP)) { g_set_error_literal (error, NM_SETTING_BLUETOOTH_ERROR, NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, "PAN required but Bluetooth device does not support NAP"); return FALSE; } /* PAN can't use any DUN-related settings */ if (s_gsm || s_cdma || s_serial || s_ppp) { g_set_error_literal (error, NM_SETTING_BLUETOOTH_ERROR, NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, "PAN incompatible with GSM, CDMA, or serial settings"); return FALSE; } g_object_set (G_OBJECT (s_bt), NM_SETTING_BLUETOOTH_TYPE, NM_SETTING_BLUETOOTH_TYPE_PANU, NULL); format = _("PAN connection %d"); } else if (is_dun) { /* Make sure the device supports PAN */ if (!(priv->capabilities & NM_BT_CAPABILITY_DUN)) { g_set_error_literal (error, NM_SETTING_BLUETOOTH_ERROR, NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, "DUN required but Bluetooth device does not support DUN"); return FALSE; } /* Need at least a GSM or a CDMA setting */ if (!s_gsm && !s_cdma) { g_set_error_literal (error, NM_SETTING_BLUETOOTH_ERROR, NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, "Setting requires DUN but no GSM or CDMA setting is present"); return FALSE; } g_object_set (G_OBJECT (s_bt), NM_SETTING_BLUETOOTH_TYPE, NM_SETTING_BLUETOOTH_TYPE_DUN, NULL); if (s_gsm) { format = _("GSM connection %d"); if (!nm_setting_gsm_get_number (s_gsm)) g_object_set (G_OBJECT (s_gsm), NM_SETTING_GSM_NUMBER, "*99#", NULL); } else if (s_cdma) { format = _("CDMA connection %d"); if (!nm_setting_cdma_get_number (s_cdma)) g_object_set (G_OBJECT (s_cdma), NM_SETTING_GSM_NUMBER, "#777", NULL); } else format = _("DUN connection %d"); } else { g_set_error_literal (error, NM_SETTING_BLUETOOTH_ERROR, NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, "Unknown/unhandled Bluetooth connection type"); return FALSE; } nm_utils_complete_generic (connection, NM_SETTING_BLUETOOTH_SETTING_NAME, existing_connections, format, preferred, is_dun ? FALSE : TRUE); /* No IPv6 yet for DUN */ setting_bdaddr = nm_setting_bluetooth_get_bdaddr (s_bt); if (setting_bdaddr) { /* Make sure the setting BT Address (if any) matches the device's */ if (memcmp (setting_bdaddr->data, devaddr->ether_addr_octet, ETH_ALEN)) { g_set_error_literal (error, NM_SETTING_BLUETOOTH_ERROR, NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY, NM_SETTING_BLUETOOTH_BDADDR); return FALSE; } } else { GByteArray *bdaddr; const guint8 null_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 }; /* Lock the connection to this device by default */ if (memcmp (devaddr->ether_addr_octet, null_mac, ETH_ALEN)) { bdaddr = g_byte_array_sized_new (ETH_ALEN); g_byte_array_append (bdaddr, devaddr->ether_addr_octet, ETH_ALEN); g_object_set (G_OBJECT (s_bt), NM_SETTING_BLUETOOTH_BDADDR, bdaddr, NULL); g_byte_array_free (bdaddr, TRUE); } } return TRUE; }
static int mash_ply_loader_vertex_read_cb (p_ply_argument argument) { long prop_num; MashPlyLoaderData *data; gint32 length, index; double value; ply_get_argument_user_data (argument, (void **) &data, &prop_num); ply_get_argument_property (argument, NULL, &length, &index); if (length != 1 || index != 0) { g_set_error (&data->error, MASH_DATA_ERROR, MASH_DATA_ERROR_INVALID, "List type property not supported for vertex element '%s'", mash_ply_loader_properties[prop_num].name); return 0; } value = ply_get_argument_value (argument); /* Colors are specified as a byte so we need to treat them specially */ if (((1 << prop_num) & MASH_PLY_LOADER_COLOR_PROPS)) data->current_vertex[data->prop_map[prop_num]] = value; else *(gfloat *) (data->current_vertex + data->prop_map[prop_num]) = value; data->got_props |= 1 << prop_num; /* If we've got enough properties for a complete vertex then add it to the array */ if (data->got_props == data->available_props) { int i; /* Flip any axes that have been specified in the MashPlyLoaderFlags */ if ((data->available_props & MASH_PLY_LOADER_VERTEX_PROPS) == MASH_PLY_LOADER_VERTEX_PROPS) for (i = 0; i < 3; i++) if ((data->flags & (MASH_DATA_NEGATE_X << i))) { gfloat *pos = (gfloat *) (data->current_vertex + data->prop_map[i]); *pos = -*pos; } if ((data->available_props & MASH_PLY_LOADER_NORMAL_PROPS) == MASH_PLY_LOADER_NORMAL_PROPS) for (i = 0; i < 3; i++) if ((data->flags & (MASH_DATA_NEGATE_X << i))) { gfloat *pos = (gfloat *) (data->current_vertex + data->prop_map[i + 3]); *pos = -*pos; } g_byte_array_append (data->vertices, data->current_vertex, data->n_vertex_bytes); data->got_props = 0; /* Update the bounding box for the data */ for (i = 0; i < 3; i++) { gfloat *min = &data->min_vertex.x + i; gfloat *max = &data->max_vertex.x + i; gfloat value = *(gfloat *) (data->current_vertex + data->prop_map[i]); if (value < *min) *min = value; if (value > *max) *max = value; } } return 1; }
static gboolean ipc_read(G_GNUC_UNUSED GIOChannel *source, GIOCondition condition, Input *input ){ gboolean error_occured=FALSE; GError *err=NULL; gboolean again=TRUE; gboolean got_zero=FALSE; if(condition &(G_IO_ERR | G_IO_HUP)) if(errno != EINTR && errno != EAGAIN) error_occured=TRUE; while(again && !error_occured && !err) { char c; int bytes_read; struct pollfd fd={input->pipe, POLLIN | POLLPRI, 0}; int res=poll(&fd, 1, 0); switch(res){ case -1: if(errno != EINTR && errno != EAGAIN) error_occured=TRUE; perror("poll"); break; case 0: again=FALSE; break; case 1: if(fd.revents &(POLLERR)){ if(errno != EINTR && errno != EAGAIN) error_occured=TRUE; perror("poll"); }else{ bytes_read=read(input->pipe, &c, 1); if(bytes_read == 1){ g_byte_array_append(input->buffer, (guint8 *)&c, 1); if(!c){ got_zero=TRUE; again=FALSE; } }else if(bytes_read == -1){ perror("read"); if(errno != EINTR && errno != EAGAIN) error_occured=TRUE; }else{ again=FALSE; } } break; default: g_assert_not_reached(); } } if(error_occured || err){ g_critical("%s: error", G_STRLOC); if(err){ g_critical("%s: %s", G_STRLOC, err->message); g_error_free(err); } ipc_deinit(); return FALSE; } if(got_zero) ipc_commit(input); return TRUE; }
/** * Implemented #b_event_handler for the read of #fb_mqtt->fd. * * @param data The user defined data, which is #fb_mqtt. * @param fd The event file descriptor. * @param cond The #b_input_condition. * * @return TRUE for continued event handling, otherwise FALSE. **/ static gboolean fb_mqtt_cb_read(gpointer data, gint fd, b_input_condition cond) { fb_mqtt_t *mqtt = data; fb_mqtt_msg_t *msg; gchar buf[1024]; guint8 byte; guint mult; gssize rize; gint res; if (mqtt->remz < 1) { /* Reset the read buffer */ g_byte_array_set_size(mqtt->rbuf, 0); res = ssl_read(mqtt->ssl, (gchar*) &byte, sizeof byte); g_byte_array_append(mqtt->rbuf, &byte, sizeof byte); if (res != sizeof byte) goto error; mult = 1; do { res = ssl_read(mqtt->ssl, (gchar*) &byte, sizeof byte); g_byte_array_append(mqtt->rbuf, &byte, sizeof byte); if (res != sizeof byte) goto error; mqtt->remz += (byte & 127) * mult; mult *= 128; } while ((byte & 128) != 0); } if (mqtt->remz > 0) { rize = ssl_read(mqtt->ssl, buf, MIN(mqtt->remz, sizeof buf)); if (rize < 1) goto error; g_byte_array_append(mqtt->rbuf, (guint8*) buf, rize); mqtt->remz -= rize; } if (mqtt->remz < 1) { msg = fb_mqtt_msg_new_bytes(mqtt->rbuf); mqtt->remz = 0; if (G_UNLIKELY(msg == NULL)) goto error; fb_mqtt_read(mqtt, msg); fb_mqtt_msg_free(msg); } return TRUE; error: fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL, "Short read"); return FALSE; }
/* WSLUA_ATTRIBUTE FieldInfo_value RO The value of this field. */ WSLUA_METAMETHOD FieldInfo__call(lua_State* L) { /* Obtain the Value of the field. Previous to 1.11.4, this function retrieved the value for most field types, but for `ftypes.UINT_BYTES` it retrieved the `ByteArray` of the field's entire `TvbRange`. In other words, it returned a `ByteArray` that included the leading length byte(s), instead of just the *value* bytes. That was a bug, and has been changed in 1.11.4. Furthermore, it retrieved an `ftypes.GUID` as a `ByteArray`, which is also incorrect. If you wish to still get a `ByteArray` of the `TvbRange`, use `FieldInfo:get_range()` to get the `TvbRange`, and then use `Tvb:bytes()` to convert it to a `ByteArray`. */ FieldInfo fi = checkFieldInfo(L,1); switch(fi->ws_fi->hfinfo->type) { case FT_BOOLEAN: lua_pushboolean(L,(int)fvalue_get_uinteger(&(fi->ws_fi->value))); return 1; case FT_UINT8: case FT_UINT16: case FT_UINT24: case FT_UINT32: case FT_FRAMENUM: lua_pushnumber(L,(lua_Number)(fvalue_get_uinteger(&(fi->ws_fi->value)))); return 1; case FT_INT8: case FT_INT16: case FT_INT24: case FT_INT32: lua_pushnumber(L,(lua_Number)(fvalue_get_sinteger(&(fi->ws_fi->value)))); return 1; case FT_FLOAT: case FT_DOUBLE: lua_pushnumber(L,(lua_Number)(fvalue_get_floating(&(fi->ws_fi->value)))); return 1; case FT_INT64: { pushInt64(L,(Int64)(fvalue_get_sinteger64(&(fi->ws_fi->value)))); return 1; } case FT_UINT64: { pushUInt64(L,fvalue_get_uinteger64(&(fi->ws_fi->value))); return 1; } case FT_ETHER: { Address eth = (Address)g_malloc(sizeof(address)); eth->type = AT_ETHER; eth->len = fi->ws_fi->length; eth->data = tvb_memdup(NULL,fi->ws_fi->ds_tvb,fi->ws_fi->start,fi->ws_fi->length); pushAddress(L,eth); return 1; } case FT_IPv4:{ Address ipv4 = (Address)g_malloc(sizeof(address)); ipv4->type = AT_IPv4; ipv4->len = fi->ws_fi->length; ipv4->data = tvb_memdup(NULL,fi->ws_fi->ds_tvb,fi->ws_fi->start,fi->ws_fi->length); pushAddress(L,ipv4); return 1; } case FT_IPv6: { Address ipv6 = (Address)g_malloc(sizeof(address)); ipv6->type = AT_IPv6; ipv6->len = fi->ws_fi->length; ipv6->data = tvb_memdup(NULL,fi->ws_fi->ds_tvb,fi->ws_fi->start,fi->ws_fi->length); pushAddress(L,ipv6); return 1; } case FT_FCWWN: { Address fcwwn = (Address)g_malloc(sizeof(address)); fcwwn->type = AT_FCWWN; fcwwn->len = fi->ws_fi->length; fcwwn->data = tvb_memdup(NULL,fi->ws_fi->ds_tvb,fi->ws_fi->start,fi->ws_fi->length); pushAddress(L,fcwwn); return 1; } case FT_IPXNET:{ Address ipx = (Address)g_malloc(sizeof(address)); ipx->type = AT_IPX; ipx->len = fi->ws_fi->length; ipx->data = tvb_memdup(NULL,fi->ws_fi->ds_tvb,fi->ws_fi->start,fi->ws_fi->length); pushAddress(L,ipx); return 1; } case FT_ABSOLUTE_TIME: case FT_RELATIVE_TIME: { NSTime nstime = (NSTime)g_malloc(sizeof(nstime_t)); *nstime = *(NSTime)fvalue_get(&(fi->ws_fi->value)); pushNSTime(L,nstime); return 1; } case FT_STRING: case FT_STRINGZ: { gchar* repr = fvalue_to_string_repr(&fi->ws_fi->value,FTREPR_DISPLAY,BASE_NONE,NULL); if (repr) lua_pushstring(L,repr); else luaL_error(L,"field cannot be represented as string because it may contain invalid characters"); return 1; } case FT_NONE: if (fi->ws_fi->length > 0 && fi->ws_fi->rep) { /* it has a length, but calling fvalue_get() on an FT_NONE asserts, so get the label instead (it's a FT_NONE, so a label is what it basically is) */ lua_pushstring(L, fi->ws_fi->rep->representation); return 1; } return 0; case FT_BYTES: case FT_UINT_BYTES: case FT_REL_OID: case FT_SYSTEM_ID: case FT_OID: { ByteArray ba = g_byte_array_new(); g_byte_array_append(ba, (const guint8 *) fvalue_get(&fi->ws_fi->value), fvalue_length(&fi->ws_fi->value)); pushByteArray(L,ba); return 1; } case FT_PROTOCOL: { ByteArray ba = g_byte_array_new(); tvbuff_t* tvb = (tvbuff_t *) fvalue_get(&fi->ws_fi->value); g_byte_array_append(ba, (const guint8 *)tvb_memdup(wmem_packet_scope(), tvb, 0, tvb_captured_length(tvb)), tvb_captured_length(tvb)); pushByteArray(L,ba); return 1; } case FT_GUID: default: luaL_error(L,"FT_ not yet supported"); return 1; } }
static GstFlowReturn gst_vp8_enc_process (GstVP8Enc * encoder) { vpx_codec_iter_t iter = NULL; const vpx_codec_cx_pkt_t *pkt; GstBaseVideoEncoder *base_video_encoder; GstVP8EncCoderHook *hook; GstVideoFrame *frame; GstFlowReturn ret = GST_FLOW_OK; base_video_encoder = GST_BASE_VIDEO_ENCODER (encoder); pkt = vpx_codec_get_cx_data (&encoder->encoder, &iter); while (pkt != NULL) { GstBuffer *buffer; gboolean invisible; GST_DEBUG_OBJECT (encoder, "packet %u type %d", (guint) pkt->data.frame.sz, pkt->kind); if (pkt->kind == VPX_CODEC_STATS_PKT && encoder->multipass_mode == VPX_RC_FIRST_PASS) { GST_LOG_OBJECT (encoder, "handling STATS packet"); g_byte_array_append (encoder->first_pass_cache_content, pkt->data.twopass_stats.buf, pkt->data.twopass_stats.sz); frame = gst_base_video_encoder_get_oldest_frame (base_video_encoder); if (frame != NULL) { buffer = gst_buffer_new (); GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_PREROLL); frame->src_buffer = buffer; gst_base_video_encoder_finish_frame (base_video_encoder, frame); } pkt = vpx_codec_get_cx_data (&encoder->encoder, &iter); continue; } else if (pkt->kind != VPX_CODEC_CX_FRAME_PKT) { GST_LOG_OBJECT (encoder, "non frame pkt: %d", pkt->kind); pkt = vpx_codec_get_cx_data (&encoder->encoder, &iter); continue; } invisible = (pkt->data.frame.flags & VPX_FRAME_IS_INVISIBLE) != 0; frame = gst_base_video_encoder_get_oldest_frame (base_video_encoder); g_assert (frame != NULL); frame->is_sync_point = (pkt->data.frame.flags & VPX_FRAME_IS_KEY) != 0; hook = frame->coder_hook; buffer = gst_buffer_new_and_alloc (pkt->data.frame.sz); memcpy (GST_BUFFER_DATA (buffer), pkt->data.frame.buf, pkt->data.frame.sz); if (hook->image) g_slice_free (vpx_image_t, hook->image); hook->image = NULL; if (invisible) { hook->invisible = g_list_append (hook->invisible, buffer); } else { frame->src_buffer = buffer; ret = gst_base_video_encoder_finish_frame (base_video_encoder, frame); } pkt = vpx_codec_get_cx_data (&encoder->encoder, &iter); } return ret; }
int main (int argc, char **argv) { GError *err = NULL; GOptionContext *g_option_context; double x_zoom = 1.0; double y_zoom = 1.0; double dpi_x = -1.0; double dpi_y = -1.0; int width = -1; int height = -1; int bVersion = 0; char *bg_color = NULL; char *base_uri = NULL; int bKeepAspect = 0; char *id = NULL; int xid = -1; int from_stdin = 0; ViewerCbInfo info; struct RsvgSizeCallbackData size_data; char **args = NULL; gint n_args = 0; GOptionEntry options_table[] = { #ifdef ENABLE_XEMBED {"xid", 'i', 0, G_OPTION_ARG_INT, &xid, N_("XWindow ID [for X11 embedding]"), N_("<int>")}, #endif {"stdin", 's', 0, G_OPTION_ARG_NONE, &from_stdin, N_("Read from stdin instead of a file"), NULL}, {"dpi-x", 'd', 0, G_OPTION_ARG_DOUBLE, &dpi_x, N_("Set the # of Pixels Per Inch"), N_("<float>")}, {"dpi-y", 'p', 0, G_OPTION_ARG_DOUBLE, &dpi_y, N_("Set the # of Pixels Per Inch"), N_("<float>")}, {"x-zoom", 'x', 0, G_OPTION_ARG_DOUBLE, &x_zoom, N_("Set the x zoom factor"), N_("<float>")}, {"y-zoom", 'y', 0, G_OPTION_ARG_DOUBLE, &y_zoom, N_("Set the y zoom factor"), N_("<float>")}, {"width", 'w', 0, G_OPTION_ARG_INT, &width, N_("Set the image's width"), N_("<int>")}, {"height", 'h', 0, G_OPTION_ARG_INT, &height, N_("Set the image's height"), N_("<int>")}, {"bg-color", 'b', 0, G_OPTION_ARG_STRING, &bg_color, N_("Set the image background color (default: transparent)"), N_("<string>")}, {"base-uri", 'u', 0, G_OPTION_ARG_STRING, &base_uri, N_("Set the base URI (default: none)"), N_("<string>")}, {"id", 0, 0, G_OPTION_ARG_STRING, &id, N_("Only show one node (default: all)"), N_("<string>")}, {"keep-aspect", 'k', 0, G_OPTION_ARG_NONE, &bKeepAspect, N_("Preserve the image's aspect ratio"), NULL}, {"version", 'v', 0, G_OPTION_ARG_NONE, &bVersion, N_("Show version information"), NULL}, {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &args, NULL, N_("[FILE...]")}, {NULL} }; g_thread_init (NULL); info.pixbuf = NULL; info.svg_bytes = NULL; info.window = NULL; info.popup_menu = NULL; g_option_context = g_option_context_new ("- SVG Viewer"); g_option_context_add_main_entries (g_option_context, options_table, NULL); g_option_context_add_group (g_option_context, gtk_get_option_group (TRUE)); g_option_context_set_help_enabled (g_option_context, TRUE); if (!g_option_context_parse (g_option_context, &argc, &argv, NULL)) { exit (1); } g_option_context_free (g_option_context); if (bVersion != 0) { g_message (_("rsvg-view version %s\n"), VERSION); return 0; } if (args) { while (args[n_args] != NULL) n_args++; } if ((!from_stdin) && (n_args != 1)) { g_print (_("No files specified, and not using --stdin\n")); return 1; } /* initialize gtk+ and rsvg */ rsvg_init (); rsvg_set_default_dpi_x_y (dpi_x, dpi_y); /* if both are unspecified, assume user wants to zoom the pixbuf in at least 1 dimension */ if (width == -1 && height == -1) { size_data.type = RSVG_SIZE_ZOOM; size_data.x_zoom = x_zoom; size_data.y_zoom = y_zoom; } /* if both are unspecified, assume user wants to resize pixbuf in at least 1 dimension */ else if (x_zoom == 1.0 && y_zoom == 1.0) { size_data.type = RSVG_SIZE_WH; size_data.width = width; size_data.height = height; } /* assume the user wants to zoom the pixbuf, but cap the maximum size */ else { size_data.type = RSVG_SIZE_ZOOM_MAX; size_data.x_zoom = x_zoom; size_data.y_zoom = y_zoom; size_data.width = width; size_data.height = height; } size_data.keep_aspect_ratio = bKeepAspect; if (!from_stdin) { if (base_uri == NULL) base_uri = (char *) args[0]; info.svg_bytes = _rsvg_acquire_xlink_href_resource (args[0], base_uri, NULL); } else { info.svg_bytes = g_byte_array_new (); for (;;) { unsigned char buf[1024 * 8]; size_t nread = fread (buf, 1, sizeof (buf), stdin); if (nread > 0) g_byte_array_append (info.svg_bytes, buf, nread); if (nread < sizeof (buf)) { if (ferror (stdin)) { g_print (_("Error reading\n")); g_byte_array_free (info.svg_bytes, TRUE); fclose (stdin); return 1; } else if (feof (stdin)) break; } } fclose (stdin); } if (!info.svg_bytes || !info.svg_bytes->len) { g_print (_("Couldn't open %s\n"), args[0]); return 1; } info.base_uri = base_uri; info.id = id; info.pixbuf = pixbuf_from_data_with_size_data (info.svg_bytes->data, info.svg_bytes->len, &size_data, base_uri, id, &err); if (!info.pixbuf) { g_print (_("Error displaying image")); if (err) { g_print (": %s", err->message); g_error_free (err); } g_print ("\n"); return 1; } info.accel_group = gtk_accel_group_new (); view_pixbuf (&info, xid, bg_color); /* run the gtk+ main loop */ gtk_main (); g_object_unref (G_OBJECT (info.pixbuf)); g_byte_array_free (info.svg_bytes, TRUE); rsvg_term (); return 0; }
static void read_one_setting_value (NMSetting *setting, const char *key, const GValue *value, GParamFlags flags, gpointer user_data) { ReadInfo *info = user_data; const char *setting_name; GType type; GError *err = NULL; gboolean check_for_key = TRUE; KeyParser *parser = &key_parsers[0]; /* Property is not writable */ if (!(flags & G_PARAM_WRITABLE)) return; /* Setting name gets picked up from the keyfile's section name instead */ if (!strcmp (key, NM_SETTING_NAME)) return; /* Don't read the NMSettingConnection object's 'read-only' property */ if ( NM_IS_SETTING_CONNECTION (setting) && !strcmp (key, NM_SETTING_CONNECTION_READ_ONLY)) return; setting_name = nm_setting_get_name (setting); /* Look through the list of handlers for non-standard format key values */ while (parser->setting_name) { if (!strcmp (parser->setting_name, setting_name) && !strcmp (parser->key, key)) { check_for_key = parser->check_for_key; break; } parser++; } /* VPN properties don't have the exact key name */ if (NM_IS_SETTING_VPN (setting)) check_for_key = FALSE; /* Check for the exact key in the GKeyFile if required. Most setting * properties map 1:1 to a key in the GKeyFile, but for those properties * like IP addresses and routes where more than one value is actually * encoded by the setting property, this won't be true. */ if (check_for_key && !g_key_file_has_key (info->keyfile, setting_name, key, &err)) { /* Key doesn't exist or an error ocurred, thus nothing to do. */ if (err) { g_warning ("Error loading setting '%s' value: %s", setting_name, err->message); g_error_free (err); } return; } /* If there's a custom parser for this key, handle that before the generic * parsers below. */ if (parser && parser->setting_name) { (*parser->parser) (setting, key, info->keyfile, info->keyfile_path); return; } type = G_VALUE_TYPE (value); if (type == G_TYPE_STRING) { char *str_val; str_val = g_key_file_get_string (info->keyfile, setting_name, key, NULL); g_object_set (setting, key, str_val, NULL); g_free (str_val); } else if (type == G_TYPE_UINT) { int int_val; int_val = g_key_file_get_integer (info->keyfile, setting_name, key, NULL); if (int_val < 0) g_warning ("Casting negative value (%i) to uint", int_val); g_object_set (setting, key, int_val, NULL); } else if (type == G_TYPE_INT) { int int_val; int_val = g_key_file_get_integer (info->keyfile, setting_name, key, NULL); g_object_set (setting, key, int_val, NULL); } else if (type == G_TYPE_BOOLEAN) { gboolean bool_val; bool_val = g_key_file_get_boolean (info->keyfile, setting_name, key, NULL); g_object_set (setting, key, bool_val, NULL); } else if (type == G_TYPE_CHAR) { int int_val; int_val = g_key_file_get_integer (info->keyfile, setting_name, key, NULL); if (int_val < G_MININT8 || int_val > G_MAXINT8) g_warning ("Casting value (%i) to char", int_val); g_object_set (setting, key, int_val, NULL); } else if (type == G_TYPE_UINT64) { char *tmp_str; guint64 uint_val; tmp_str = g_key_file_get_value (info->keyfile, setting_name, key, NULL); uint_val = g_ascii_strtoull (tmp_str, NULL, 10); g_free (tmp_str); g_object_set (setting, key, uint_val, NULL); } else if (type == DBUS_TYPE_G_UCHAR_ARRAY) { gint *tmp; GByteArray *array; gsize length; int i; tmp = g_key_file_get_integer_list (info->keyfile, setting_name, key, &length, NULL); array = g_byte_array_sized_new (length); for (i = 0; i < length; i++) { int val = tmp[i]; unsigned char v = (unsigned char) (val & 0xFF); if (val < 0 || val > 255) { g_warning ("%s: %s / %s ignoring invalid byte element '%d' (not " " between 0 and 255 inclusive)", __func__, setting_name, key, val); } else g_byte_array_append (array, (const unsigned char *) &v, sizeof (v)); } g_object_set (setting, key, array, NULL); g_byte_array_free (array, TRUE); g_free (tmp); } else if (type == DBUS_TYPE_G_LIST_OF_STRING) { gchar **sa; gsize length; int i; GSList *list = NULL; sa = g_key_file_get_string_list (info->keyfile, setting_name, key, &length, NULL); for (i = 0; i < length; i++) list = g_slist_prepend (list, sa[i]); list = g_slist_reverse (list); g_object_set (setting, key, list, NULL); g_slist_free (list); g_strfreev (sa); } else if (type == DBUS_TYPE_G_MAP_OF_STRING) { read_hash_of_string (info->keyfile, setting, key); } else if (type == DBUS_TYPE_G_UINT_ARRAY) { if (!read_array_of_uint (info->keyfile, setting, key)) { g_warning ("Unhandled setting property type (read): '%s/%s' : '%s'", setting_name, key, G_VALUE_TYPE_NAME (value)); } } else { g_warning ("Unhandled setting property type (read): '%s/%s' : '%s'", setting_name, key, G_VALUE_TYPE_NAME (value)); } }
static void foreach_property_cb (gpointer key, gpointer value, gpointer user_data) { GValue *variant = (GValue *) value; NMAccessPoint *ap = (NMAccessPoint *) user_data; if (G_VALUE_HOLDS_BOXED (variant)) { GArray *array = g_value_get_boxed (variant); if (!strcmp (key, "SSID")) { guint32 len = MIN (32, array->len); GByteArray *ssid; /* Stupid ieee80211 layer uses <hidden> */ if (((len == 8) || (len == 9)) && (memcmp (array->data, "<hidden>", 8) == 0)) return; if (nm_utils_is_empty_ssid ((const guint8 *) array->data, len)) return; ssid = g_byte_array_sized_new (len); g_byte_array_append (ssid, (const guint8 *) array->data, len); nm_ap_set_ssid (ap, ssid); g_byte_array_free (ssid, TRUE); } else if (!strcmp (key, "BSSID")) { struct ether_addr addr; if (array->len != ETH_ALEN) return; memset (&addr, 0, sizeof (struct ether_addr)); memcpy (&addr, array->data, ETH_ALEN); nm_ap_set_address (ap, &addr); } else if (!strcmp (key, "Rates")) { guint32 maxrate = 0; int i; /* Find the max AP rate */ for (i = 0; i < array->len; i++) { guint32 r = g_array_index (array, guint32, i); if (r > maxrate) { maxrate = r; nm_ap_set_max_bitrate (ap, r / 1000); } } } else if (!strcmp (key, "WPA")) { NM80211ApSecurityFlags flags = nm_ap_get_wpa_flags (ap); flags |= security_from_dict (g_value_get_boxed (variant)); nm_ap_set_wpa_flags (ap, flags); } else if (!strcmp (key, "RSN")) { NM80211ApSecurityFlags flags = nm_ap_get_rsn_flags (ap); flags |= security_from_dict (g_value_get_boxed (variant)); nm_ap_set_rsn_flags (ap, flags); } } else if (G_VALUE_HOLDS_UINT (variant)) { guint32 val = g_value_get_uint (variant); if (!strcmp (key, "Frequency")) nm_ap_set_freq (ap, val); } else if (G_VALUE_HOLDS_INT (variant)) { gint val = g_value_get_int (variant); if (!strcmp (key, "Signal")) nm_ap_set_strength (ap, nm_ap_utils_level_to_quality (val)); } else if (G_VALUE_HOLDS_STRING (variant)) { const char *val = g_value_get_string (variant); if (val && !strcmp (key, "Mode")) { if (strcmp (val, "infrastructure") == 0) nm_ap_set_mode (ap, NM_802_11_MODE_INFRA); else if (strcmp (val, "ad-hoc") == 0) nm_ap_set_mode (ap, NM_802_11_MODE_ADHOC); } } else if (G_VALUE_HOLDS_BOOLEAN (variant)) { gboolean val = g_value_get_boolean (variant); if (strcmp (key, "Privacy") == 0) { if (val) { NM80211ApFlags flags = nm_ap_get_flags (ap); nm_ap_set_flags (ap, flags | NM_802_11_AP_FLAGS_PRIVACY); } } } }
static GPtrArray * read_ip6_addresses (GKeyFile *file, const char *setting_name, const char *key) { GPtrArray *addresses; struct in6_addr addr, gw; guint32 prefix; int i = 0; addresses = g_ptr_array_sized_new (3); /* Look for individual addresses */ while (i++ < 1000) { char *tmp, *key_name, *str_prefix, *str_gw; int ret; GValueArray *values; GByteArray *address; GByteArray *gateway; GValue value = { 0 }; key_name = g_strdup_printf ("%s%d", key, i); tmp = g_key_file_get_string (file, setting_name, key_name, NULL); g_free (key_name); if (!tmp) break; /* all done */ /* convert the string array into IPv6 addresses */ values = g_value_array_new (2); /* NMIP6Address has 2 items */ /* Split the address and prefix */ str_prefix = split_prefix (tmp); /* address */ ret = inet_pton (AF_INET6, tmp, &addr); if (ret <= 0) { g_warning ("%s: ignoring invalid IPv6 %s element '%s'", __func__, key_name, tmp); g_value_array_free (values); goto next; } address = g_byte_array_new (); g_byte_array_append (address, (guint8 *) addr.s6_addr, 16); g_value_init (&value, DBUS_TYPE_G_UCHAR_ARRAY); g_value_take_boxed (&value, address); g_value_array_append (values, &value); g_value_unset (&value); /* prefix */ prefix = 0; if (str_prefix) { if (!get_one_int (str_prefix, 128, key_name, &prefix)) { g_value_array_free (values); goto next; } } else { /* Missing prefix defaults to /64 */ prefix = 64; } g_value_init (&value, G_TYPE_UINT); g_value_set_uint (&value, prefix); g_value_array_append (values, &value); g_value_unset (&value); /* Gateway (optional) */ str_gw = split_gw (str_prefix); if (str_gw) { ret = inet_pton (AF_INET6, str_gw, &gw); if (ret <= 0) { g_warning ("%s: ignoring invalid IPv6 %s gateway '%s'", __func__, key_name, tmp); g_value_array_free (values); goto next; } if (!IN6_IS_ADDR_UNSPECIFIED (&gw)) { gateway = g_byte_array_new (); g_byte_array_append (gateway, (guint8 *) gw.s6_addr, 16); g_value_init (&value, DBUS_TYPE_G_UCHAR_ARRAY); g_value_take_boxed (&value, gateway); g_value_array_append (values, &value); g_value_unset (&value); } } g_ptr_array_add (addresses, values); next: g_free (tmp); } if (addresses->len < 1) { g_ptr_array_free (addresses, TRUE); addresses = NULL; } return addresses; }
static void fb_mqtt_cb_read(gpointer data, gint fd, PurpleInputCondition cond) { FbMqtt *mqtt = data; FbMqttMessage *msg; FbMqttPrivate *priv = mqtt->priv; gint res; guint mult; guint8 buf[1024]; guint8 byte; gsize size; gssize rize; if (priv->remz < 1) { /* Reset the read buffer */ g_byte_array_set_size(priv->rbuf, 0); res = purple_ssl_read(priv->gsc, &byte, sizeof byte); g_byte_array_append(priv->rbuf, &byte, sizeof byte); if (res != sizeof byte) { fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL, _("Failed to read fixed header")); return; } mult = 1; do { res = purple_ssl_read(priv->gsc, &byte, sizeof byte); g_byte_array_append(priv->rbuf, &byte, sizeof byte); if (res != sizeof byte) { fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL, _("Failed to read packet size")); return; } priv->remz += (byte & 127) * mult; mult *= 128; } while ((byte & 128) != 0); } if (priv->remz > 0) { size = MIN(priv->remz, sizeof buf); rize = purple_ssl_read(priv->gsc, buf, size); if (rize < 1) { fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL, _("Failed to read packet data")); return; } g_byte_array_append(priv->rbuf, buf, rize); priv->remz -= rize; } if (priv->remz < 1) { msg = fb_mqtt_message_new_bytes(priv->rbuf); priv->remz = 0; if (G_UNLIKELY(msg == NULL)) { fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL, _("Failed to parse message")); return; } fb_mqtt_read(mqtt, msg); g_object_unref(msg); } }
static gboolean gst_curl_smtp_sink_event (GstBaseSink * bsink, GstEvent * event) { GstCurlBaseSink *bcsink = GST_CURL_BASE_SINK (bsink); GstCurlSmtpSink *sink = GST_CURL_SMTP_SINK (bsink); GByteArray *array; gchar *boundary_end; switch (event->type) { case GST_EVENT_EOS: GST_DEBUG_OBJECT (sink, "received EOS"); gst_curl_base_sink_set_live (bcsink, FALSE); GST_OBJECT_LOCK (sink); sink->eos = TRUE; GST_OBJECT_UNLOCK (sink); if (sink->base64_chunk != NULL) { gsize len; gint save, state; gchar *data_out; array = sink->base64_chunk->chunk_array; g_assert (array); GST_DEBUG ("adding final boundary"); /* it will need up to 5 bytes if line-breaking is enabled * additional byte is needed for <CR> as it is not automatically added by glib */ data_out = g_malloc (6); save = sink->base64_chunk->save; state = sink->base64_chunk->state; len = g_base64_encode_close (TRUE, data_out, &state, &save); /* workaround */ data_out[len - 1] = '\r'; data_out[len] = '\n'; /* +1 for CR */ g_byte_array_append (array, (guint8 *) data_out, (guint) (len + 1)); g_free (data_out); boundary_end = g_strdup_printf ("\r\n%s\r\n", BOUNDARY_STRING_END); g_byte_array_append (array, (guint8 *) boundary_end, strlen (boundary_end)); g_free (boundary_end); } gst_curl_base_sink_transfer_thread_notify_unlocked (bcsink); GST_OBJECT_LOCK (sink); if (sink->base64_chunk != NULL && bcsink->flow_ret == GST_FLOW_OK) { gst_curl_smtp_sink_wait_for_transfer_end_unlocked (sink); } GST_OBJECT_UNLOCK (sink); gst_curl_base_sink_transfer_thread_close (bcsink); break; default: break; } return GST_BASE_SINK_CLASS (parent_class)->event (bsink, event); }
int main (int argc, char *argv[]) { GByteArray *gbarray; gint i; int user_data = 1; #ifdef SYMBIAN g_log_set_handler (NULL, G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL); #endif /*SYMBIAN*/ gbarray = g_byte_array_new (); g_byte_array_prepend(gbarray,(guint8 *)"c",1); g_byte_array_prepend(gbarray,(guint8 *)"b",1); g_byte_array_prepend(gbarray,(guint8 *)"a",1); g_assert(gbarray->data[0] == 'a'); g_assert(gbarray->data[1] == 'b'); g_assert(gbarray->data[2] == 'c'); g_byte_array_remove_index(gbarray,1); g_assert(gbarray->data[0] == 'a'); g_assert(gbarray->data[1] == 'c'); g_byte_array_append(gbarray,(guint8 *)"b",1); g_byte_array_remove_index_fast(gbarray,1); g_assert(gbarray->data[1] == 'b'); g_byte_array_append(gbarray,(guint8 *)"c",1); g_byte_array_append(gbarray,(guint8 *)"d",1); g_byte_array_append(gbarray,(guint8 *)"e",1); g_byte_array_remove_range(gbarray,0,3); g_assert(gbarray->data[0] == 'd'); g_assert(gbarray->data[1] == 'e'); g_byte_array_set_size(gbarray,10); g_assert(gbarray->len == 10); g_byte_array_free(gbarray,TRUE); gbarray = g_byte_array_sized_new (10); g_assert(gbarray->len == 0); g_byte_array_append(gbarray,(guint8 *)"c",1); g_byte_array_append(gbarray,(guint8 *)"b",1); g_byte_array_append(gbarray,(guint8 *)"a",1); g_byte_array_sort(gbarray,ascending); g_assert(gbarray->data[0] == 'a'); g_assert(gbarray->data[1] == 'b'); g_assert(gbarray->data[2] == 'c'); g_byte_array_sort_with_data(gbarray,sort_func,&user_data); g_assert(gbarray->data[0] == 'c'); g_assert(gbarray->data[1] == 'b'); g_assert(gbarray->data[2] == 'a'); g_byte_array_free(gbarray,TRUE); #if SYMBIAN testResultXml("byte_array_test"); #endif /* EMULATOR */ return 0; }
static size_t transfer_chunk (void *curl_ptr, TransferBuffer * buffer, Base64Chunk * chunk, size_t block_size, guint * last_chunk) { size_t bytes_to_send; const guchar *data_in = buffer->ptr; size_t data_in_offset = buffer->offset; gint state = chunk->state; gint save = chunk->save; GByteArray *array = chunk->chunk_array; gchar *data_out; bytes_to_send = MIN (block_size, buffer->len); if (bytes_to_send == 0) { bytes_to_send = MIN (block_size, array->len); } /* base64 encode data */ if (buffer->len > 0) { gsize len; gchar *ptr_in; gchar *ptr_out; gsize size_out; gint i; /* if line-breaking is enabled, at least: ((len / 3 + 1) * 4 + 4) / 72 + 1 * bytes of extra space is required. However, additional <CR>'s are required, * thus we need ((len / 3 + 2) * 4 + 4) / 72 + 2 extra bytes. */ size_out = (bytes_to_send / 3 + 1) * 4 + 4 + bytes_to_send + ((bytes_to_send / 3 + 2) * 4 + 4) / 72 + 2; data_out = g_malloc (size_out); len = g_base64_encode_step (data_in + data_in_offset, bytes_to_send, TRUE, data_out, &state, &save); chunk->state = state; chunk->save = save; /* LF->CRLF filter */ ptr_in = ptr_out = data_out; for (i = 0; i < len; i++) { if (*ptr_in == '\n') { *ptr_in = '\r'; g_byte_array_append (array, (guint8 *) ptr_out, ptr_in - ptr_out); g_byte_array_append (array, (guint8 *) "\r\n", strlen ("\r\n")); ptr_out = ptr_in + 1; } ptr_in++; } if (ptr_in - ptr_out) { g_byte_array_append (array, (guint8 *) ptr_out, ptr_in - ptr_out); } g_free (data_out); data_out = NULL; buffer->offset += bytes_to_send; buffer->len -= bytes_to_send; bytes_to_send = MIN (block_size, array->len); memcpy ((guint8 *) curl_ptr, array->data, bytes_to_send); g_byte_array_remove_range (array, 0, bytes_to_send); if (array->len == 0) { *last_chunk = 1; } return bytes_to_send; } /* at this point all data has been encoded */ memcpy ((guint8 *) curl_ptr, array->data, bytes_to_send); g_byte_array_remove_range (array, 0, bytes_to_send); if (array->len == 0) { *last_chunk = 1; } return bytes_to_send; }
static GError * _client_manage_event_in_buffer(struct gridd_client_s *client, guint8 *d, gsize ds) { ssize_t rc; switch (client->step) { case CONNECTING: EXTRA_ASSERT(client->fd >= 0); EXTRA_ASSERT(client->request != NULL); client->step = REQ_SENDING; return NULL; case REQ_SENDING: client->step = REQ_SENDING; g_get_current_time(&(client->tv_step)); if (!client->request) return NULL; _client_reset_reply(client); /* Continue to send the request */ rc = metautils_syscall_write(client->fd, client->request->data + client->sent_bytes, client->request->len - client->sent_bytes); if (rc < 0) return (errno == EINTR || errno == EAGAIN) ? NULL : NEWERROR(errno, "write error (%s)", strerror(errno)); if (rc > 0) client->sent_bytes += rc; if (client->sent_bytes < client->request->len) return NULL; client->step = REP_READING_SIZE; case REP_READING_SIZE: client->step = REP_READING_SIZE; g_get_current_time(&(client->tv_step)); if (!client->reply) client->reply = g_byte_array_new(); if (client->reply->len < 4) { /* Continue reading the size */ rc = metautils_syscall_read(client->fd, d, (4 - client->reply->len)); if (rc < 0) return (errno == EINTR || errno == EAGAIN) ? NULL : NEWERROR(errno, "read error (%s)", strerror(errno)); if (rc > 0) g_byte_array_append(client->reply, d, rc); if (client->reply->len < 4) { if (!rc) return NEWERROR(errno, "EOF!"); return NULL; } } EXTRA_ASSERT (client->reply->len == 4); client->size = l4v_get_size(client->reply->data); case REP_READING_DATA: client->step = REP_READING_DATA; g_get_current_time(&(client->tv_step)); rc = 0; EXTRA_ASSERT (client->reply->len <= client->size + 4); if (client->reply->len < client->size + 4) { gsize remaiming = client->size + 4 - client->reply->len; gsize dmax = ds; if (dmax > remaiming) dmax = remaiming; rc = metautils_syscall_read(client->fd, d, dmax); if (rc < 0) return (errno == EINTR || errno == EAGAIN) ? NULL : NEWERROR(errno, "read error (%s)", strerror(errno)); if (rc > 0) g_byte_array_append(client->reply, d, rc); } EXTRA_ASSERT (client->reply->len <= client->size + 4); if (client->reply->len == client->size + 4) { GError *err = _client_manage_reply_data(client); if (err) { client->step = STATUS_FAILED; return err; } else { if (client->step != CONNECTING && client->step != STATUS_FAILED && client->step != STATUS_OK) { client->reply = g_byte_array_set_size(client->reply, 0); client->step = REP_READING_SIZE; client->size = 0; } } } else if (!rc) return NEWERROR(errno, "EOF!"); return NULL; default: g_assert_not_reached(); return NEWERROR(0, "Invalid state"); } g_assert_not_reached(); return NEWERROR(0, "BUG unreachable code"); }
static GByteArray * get_uchar_array (GKeyFile *keyfile, const char *setting_name, const char *key, gboolean zero_terminate, gboolean unescape_semicolon) { GByteArray *array = NULL; char *tmp_string; gint *tmp_list; gsize length; int i; /* New format: just a string * Old format: integer list; e.g. 11;25;38; */ tmp_string = nm_keyfile_plugin_kf_get_string (keyfile, setting_name, key, NULL); if (tmp_string) { GRegex *regex; GMatchInfo *match_info; const char *pattern = "^[[:space:]]*[[:digit:]]{1,3}[[:space:]]*;([[:space:]]*[[:digit:]]{1,3}[[:space:]]*;)*([[:space:]]*)?$"; regex = g_regex_new (pattern, 0, 0, NULL); g_regex_match (regex, tmp_string, 0, &match_info); if (!g_match_info_matches (match_info)) { /* Handle as a simple string (ie, new format) */ if (unescape_semicolon) unescape_semicolons (tmp_string); length = strlen (tmp_string); if (zero_terminate) length++; array = g_byte_array_sized_new (length); g_byte_array_append (array, (guint8 *) tmp_string, length); } g_match_info_free (match_info); g_regex_unref (regex); g_free (tmp_string); } if (!array) { /* Old format; list of ints */ tmp_list = nm_keyfile_plugin_kf_get_integer_list (keyfile, setting_name, key, &length, NULL); array = g_byte_array_sized_new (length); for (i = 0; i < length; i++) { int val = tmp_list[i]; unsigned char v = (unsigned char) (val & 0xFF); if (val < 0 || val > 255) { g_warning ("%s: %s / %s ignoring invalid byte element '%d' (not " " between 0 and 255 inclusive)", __func__, setting_name, key, val); } else g_byte_array_append (array, (const unsigned char *) &v, sizeof (v)); } g_free (tmp_list); } if (array->len == 0) { g_byte_array_free (array, TRUE); array = NULL; } return array; }
WSLUA_METAMETHOD FieldInfo__call(lua_State* L) { /* Obtain the Value of the field */ FieldInfo fi = checkFieldInfo(L,1); switch(fi->hfinfo->type) { case FT_NONE: lua_pushnil(L); return 1; case FT_BOOLEAN: lua_pushboolean(L,(int)fvalue_get_uinteger(&(fi->value))); return 1; case FT_UINT8: case FT_UINT16: case FT_UINT24: case FT_UINT32: case FT_FRAMENUM: lua_pushnumber(L,(lua_Number)fvalue_get_uinteger(&(fi->value))); return 1; case FT_INT8: case FT_INT16: case FT_INT24: case FT_INT32: lua_pushnumber(L,(lua_Number)fvalue_get_sinteger(&(fi->value))); return 1; case FT_FLOAT: case FT_DOUBLE: lua_pushnumber(L,(lua_Number)fvalue_get_floating(&(fi->value))); return 1; case FT_INT64: { Int64 num = (Int64)g_malloc(sizeof(gint64)); *num = fvalue_get_integer64(&(fi->value)); pushInt64(L,num); return 1; } case FT_UINT64: { UInt64 num = (UInt64)g_malloc(sizeof(guint64)); *num = fvalue_get_integer64(&(fi->value)); pushUInt64(L,num); return 1; } case FT_ETHER: { Address eth = (Address)g_malloc(sizeof(address)); eth->type = AT_ETHER; eth->len = fi->length; eth->data = tvb_memdup(fi->ds_tvb,fi->start,fi->length); pushAddress(L,eth); return 1; } case FT_IPv4:{ Address ipv4 = (Address)g_malloc(sizeof(address)); ipv4->type = AT_IPv4; ipv4->len = fi->length; ipv4->data = tvb_memdup(fi->ds_tvb,fi->start,fi->length); pushAddress(L,ipv4); return 1; } case FT_IPv6: { Address ipv6 = (Address)g_malloc(sizeof(address)); ipv6->type = AT_IPv6; ipv6->len = fi->length; ipv6->data = tvb_memdup(fi->ds_tvb,fi->start,fi->length); pushAddress(L,ipv6); return 1; } case FT_IPXNET:{ Address ipx = (Address)g_malloc(sizeof(address)); ipx->type = AT_IPX; ipx->len = fi->length; ipx->data = tvb_memdup(fi->ds_tvb,fi->start,fi->length); pushAddress(L,ipx); return 1; } case FT_ABSOLUTE_TIME: case FT_RELATIVE_TIME: { NSTime nstime = (NSTime)g_malloc(sizeof(nstime_t)); *nstime = *(NSTime)fvalue_get(&(fi->value)); pushNSTime(L,nstime); return 1; } case FT_STRING: case FT_STRINGZ: { gchar* repr = fvalue_to_string_repr(&fi->value,FTREPR_DISPLAY,NULL); if (repr) lua_pushstring(L,repr); else luaL_error(L,"field cannot be represented as string because it may contain invalid characters"); return 1; } case FT_BYTES: case FT_UINT_BYTES: case FT_GUID: case FT_PROTOCOL: case FT_OID: { ByteArray ba = g_byte_array_new(); g_byte_array_append(ba, (const guint8 *)ep_tvb_memdup(fi->ds_tvb,fi->start,fi->length),fi->length); pushByteArray(L,ba); return 1; } default: luaL_error(L,"FT_ not yet supported"); return 1; } }