static void _verve_history_cache_load (void) { const gchar *basename = _verve_history_cache_get_filename (); gchar *filename = xfce_resource_lookup (XFCE_RESOURCE_CONFIG, basename); if (G_UNLIKELY (filename == NULL)) return; GError *error = NULL; GIOChannel *handle = g_io_channel_new_file (filename, "r", &error); if (error) g_error_free (error); if (G_LIKELY (handle != NULL)) { gchar *line; gsize length; GIOStatus status; status = g_io_channel_read_line (handle, &line, &length, NULL, &error); while (status != G_IO_STATUS_EOF && error == NULL) { GString *strline = g_string_new (g_strstrip (line)); g_free (line); if (strline->len > 0) { _verve_history_append (strline->str); } g_string_free (strline, FALSE); status = g_io_channel_read_line (handle, &line, &length, NULL, &error); } if (error) g_error_free (error); g_io_channel_shutdown (handle, TRUE, &error); if (error) g_error_free (error); g_io_channel_unref (handle); } g_free (filename); }
static void read_playlist_file (SnraManager * manager, const char *filename) { GError *error = NULL; GIOChannel *io = g_io_channel_new_file (filename, "r", &error); GIOStatus result; gchar *line; if (error) { g_message ("Failed to open playlist file %s: %s", filename, error->message); g_error_free (error); return; } do { result = g_io_channel_read_line (io, &line, NULL, NULL, NULL); if (result == G_IO_STATUS_AGAIN) continue; if (result != G_IO_STATUS_NORMAL) break; g_strchomp (line); g_ptr_array_add (manager->playlist, line); snra_media_db_add_file (manager->media_db, line); } while (TRUE); g_print ("Read %u entries\n", manager->playlist->len); g_io_channel_unref (io); }
void keywords_load(void) { GError *err = NULL; GIOChannel *channel = NULL; gchar *path = NULL, *buf = NULL; gchar **tokens = NULL; keywords = g_hash_table_new(g_str_hash, g_str_equal); path = g_build_filename(g_get_user_config_dir(), __NAME__, "keywordsearch", NULL); channel = g_io_channel_new_file(path, "r", &err); if (channel != NULL) { while (g_io_channel_read_line(channel, &buf, NULL, NULL, NULL) == G_IO_STATUS_NORMAL) { g_strstrip(buf); if (buf[0] != '#') { tokens = g_strsplit(buf, " ", 2); if (tokens[0] != NULL && tokens[1] != NULL) g_hash_table_insert(keywords, g_strdup(tokens[0]), g_strdup(tokens[1])); g_strfreev(tokens); } g_free(buf); } g_io_channel_shutdown(channel, FALSE, NULL); } g_free(path); }
static gboolean read_pipe_from_child (GIOChannel *source, GIOCondition condition, gpointer data) { if (condition & G_IO_IN) { gchar *message = NULL; gchar *error_message = NULL; GtkWidget *dialog; GIOStatus status; status = g_io_channel_read_line (source, &error_message, NULL, NULL, NULL); if (status == G_IO_STATUS_NORMAL) { message = g_strdup_printf ("Unable to save the screenshot to disk:\n\n%s", error_message); dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", message); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); exit (1); } } (*save_callback) (save_user_data); return FALSE; }
/* Hacky conf file parsing to not write logic twice */ void parse_conf(void) { GIOChannel *f; gchar *conf = g_build_filename(g_get_user_config_dir(), PNAME, CONFIG_FNAME, NULL); if ((f = g_io_channel_new_file(conf, "r", NULL))) { char *line = NULL; GError *err = NULL; while (g_io_channel_read_line(f, &line, NULL, NULL, NULL) == G_IO_STATUS_NORMAL) { char *temp = NULL, **argv = NULL; gint argc; /* strip newlines and comments */ g_strdelimit(line, "\n#", '\0'); temp = g_strdup_printf(PNAME " --%s", line); if (!g_shell_parse_argv(temp, &argc, &argv, &err) || (argc != 2 && argc != 3) || !g_option_context_parse(bm.context, &argc, &argv, &err)) { g_printerr("Error parsing config file arguments: %s (%s)\n", err?err->message:"Invalid number of params", line); exit(1); } g_strfreev(argv); } g_free(line); g_io_channel_shutdown(f, TRUE, &err); g_io_channel_unref(f); } g_free(conf); }
static gboolean _user_input_handler ( GIOChannel* channel, GIOCondition /*condition*/, gpointer data_ptr) { GError* error = NULL; char* str = NULL; size_t len; SourceAppData* data = static_cast<SourceAppData*>(data_ptr); switch (g_io_channel_read_line(channel, &str, &len, NULL, &error)) { case G_IO_STATUS_NORMAL: parse_input_and_call_source(str, data->source); g_free(str); return true; case G_IO_STATUS_ERROR: std::cout << "User input error: " << error->message << std::endl; g_error_free(error); return false; case G_IO_STATUS_EOF: case G_IO_STATUS_AGAIN: return true; default: return false; } return false; }
static GIOStatus get_next_module_line(GIOChannel *input_channel, GQuark *match, gchar **output, gchar **start_pos, GError **error) { static const gchar *search_strings[] = { "i8042: ", "ps2emu: " }; int index; gchar *current_line; GIOStatus rc; while ((rc = g_io_channel_read_line(input_channel, ¤t_line, NULL, NULL, error)) == G_IO_STATUS_NORMAL) { for (index = 0; index < G_N_ELEMENTS(search_strings); index++) { *start_pos = strstr(current_line, search_strings[index]); if (*start_pos) break; } if (*start_pos) break; g_free(current_line); } if (rc != G_IO_STATUS_NORMAL) { return rc; } /* Move the start position after the initial 'i8042: ' */ *start_pos += strlen(search_strings[index]); *output = current_line; *match = g_quark_from_static_string(search_strings[index]); return rc; }
/** * IO channel watcher. * Read one line from the current channel and forward it to the user function. * * Return true as long as the channel has to stay registered, false otherwise. */ static gboolean readline_cb(GIOChannel *channel, GIOCondition cond, gpointer ud) { struct io_chan_arg *args = ud; GError *error = NULL; gchar *line; gsize size; GIOStatus res; /* The channel is closed, no more data to read */ if (cond == G_IO_HUP) { g_io_channel_unref(channel); ctx_decref(args->exec_ctx); return false; } res = g_io_channel_read_line(channel, &line, &size, NULL, &error); if (res != G_IO_STATUS_NORMAL) { DisplayLog(LVL_MAJOR, TAG, "Cannot read from child: %s", error->message); g_error_free(error); g_io_channel_unref(channel); ctx_decref(args->exec_ctx); return false; } if (args->cb != NULL) args->cb(args->udata, line, size, args->ident); g_free(line); return true; }
static VALUE rg_readline(gint argc, VALUE *argv, VALUE self) { gchar* str; VALUE line_term, ret; GIOStatus status; GError* err = NULL; const gchar* old_line_term = NULL; gint old_line_term_len; rb_scan_args(argc, argv, "01", &line_term); if (! NIL_P(line_term)){ StringValue(line_term); old_line_term = g_io_channel_get_line_term(_SELF(self), &old_line_term_len); g_io_channel_set_line_term(_SELF(self), RVAL2CSTR(line_term), RSTRING_LEN(line_term)); } status = g_io_channel_read_line(_SELF(self), &str, NULL, NULL, &err); if (! NIL_P(line_term)){ g_io_channel_set_line_term(_SELF(self), old_line_term, old_line_term_len); } ioc_error(status, err); ret = str ? CSTR2RVAL(str) : CSTR2RVAL(""); g_free(str); return ret; }
static gboolean client_stdout_cb (GIOChannel *source, GIOCondition condition, gpointer data) { gchar *str_return; gsize length; gsize terminator_pos; GError *error; if (condition & G_IO_IN) { while (g_io_channel_read_line (source, &str_return, &length, &terminator_pos, &error) == G_IO_STATUS_NORMAL) { if (getenv ("DEBUG")) g_print ("%s", str_return); } } return TRUE; }
void loadfile(Client *c, const gchar *f) { GIOChannel *chan = NULL; GError *e = NULL; GString *code; gchar *line, *uri; Arg arg; if(strcmp(f, "-") == 0) { chan = g_io_channel_unix_new(STDIN_FILENO); if (chan) { code = g_string_new(""); while(g_io_channel_read_line(chan, &line, NULL, NULL, &e) == G_IO_STATUS_NORMAL) { g_string_append(code, line); g_free(line); } webkit_web_view_load_html_string(c->view, code->str, "file://."); g_io_channel_shutdown(chan, FALSE, NULL); g_string_free(code, TRUE); } arg.v = uri = g_strdup("stdin"); } else { arg.v = uri = g_strdup_printf("file://%s", f); loaduri(c, &arg); } c->title = copystr(&c->title, uri); update(c); g_free(uri); }
static gboolean stdin_read(GIOChannel *source, GIOCondition condition, void *data) { GIOStatus status; GError *error = NULL; gchar *buf = NULL; gsize size = 0; if ( condition & G_IO_HUP ) { exit(EXIT_FAILURE); return FALSE; } status = g_io_channel_read_line(stdin_channel, &buf, &size, NULL, &error); if ( status == G_IO_STATUS_NORMAL ) { if ( buf != NULL ) { parse_command(buf); g_free(buf); } } else if ( status != G_IO_STATUS_AGAIN ) { if ( status == G_IO_STATUS_ERROR ) { eprintf("read(stdin): %s\n", error->message); return FALSE; } } return TRUE; }
static gboolean fifo_watch(GIOChannel *gio, GIOCondition condition) { char *line; GIOStatus ret; GError *err = NULL; if (condition & G_IO_HUP) { g_error("fifo: read end of pipe died"); } if (!gio) { g_error("fifo: GIOChannel broken"); } ret = g_io_channel_read_line(gio, &line, NULL, NULL, &err); if (ret == G_IO_STATUS_ERROR) { g_error("fifo: error reading from fifo: %s", err->message); g_error_free(err); } /* simulate the typed flag to allow to record the commands in history */ vb.state.typed = true; map_handle_string(line, true); g_free(line); /* unset typed flag */ vb.state.typed = false; return true; }
static gboolean stdin_remote_info_cb (GIOChannel *source, GIOCondition cond, gpointer data) { NiceAgent *agent = data; gchar *line = NULL; int rval; gboolean ret = TRUE; if (g_io_channel_read_line (source, &line, NULL, NULL, NULL) == G_IO_STATUS_NORMAL) { // Parse remote candidate list and set it on the agent rval = parse_remote_data(agent, stream_id, 1, line); if (rval == EXIT_SUCCESS) { // Return FALSE so we stop listening to stdin since we parsed the // candidates correctly ret = FALSE; g_debug("waiting for state READY or FAILED signal..."); } else { fprintf(stderr, "ERROR: failed to parse remote data\n"); printf("Enter remote data (single line, no wrapping):\n"); printf("> "); fflush (stdout); } g_free (line); } return ret; }
static gboolean up_devd_event_cb (GIOChannel *source, GIOCondition condition, gpointer user_data) { gchar *event; gsize terminator; GIOStatus status; status = g_io_channel_read_line(source, &event, NULL, &terminator, NULL); if (status == G_IO_STATUS_NORMAL) { event[terminator] = 0; up_devd_process_event(event, user_data); g_free(event); } else if (status == G_IO_STATUS_AGAIN) { up_devd_init (UP_BACKEND(user_data)); if (up_devd_inited) { int fd; fd = g_io_channel_unix_get_fd (source); g_io_channel_shutdown (source, FALSE, NULL); close (fd); return FALSE; } } return TRUE; }
void loadfile(const Client *c, const gchar *f) { GIOChannel *chan = NULL; GError *e = NULL; GString *code = g_string_new(""); GString *uri = g_string_new(f); gchar *line; if(strcmp(f, "-") == 0) { chan = g_io_channel_unix_new(STDIN_FILENO); if (chan) { while(g_io_channel_read_line(chan, &line, NULL, NULL, &e) == G_IO_STATUS_NORMAL) { g_string_append(code, line); g_free(line); } webkit_web_view_load_html_string(c->view, code->str, NULL); g_io_channel_shutdown(chan, FALSE, NULL); } } else { g_string_prepend(uri, "file://"); loaduri(c, uri->str); } }
static gboolean aprsis_got_packet(GIOChannel *gio, GIOCondition condition, gpointer data) { // callback when GIOChannel tells us there's an APRS packet to be handled GIOStatus ret; GError *err = NULL; gchar *msg; gsize len; aprsis_ctx *ctx = (aprsis_ctx *) data; if (condition & G_IO_HUP) g_error ("Read end of pipe died!"); // FIXME - handle this more gracefully if (condition & G_IO_ERR) { g_message ("IO error"); return FALSE; } ret = g_io_channel_read_line (gio, &msg, &len, NULL, &err); if (ret == G_IO_STATUS_ERROR) g_message("Error reading: %s", err->message); if (ret == G_IO_STATUS_EOF) { g_message("EOF (server disconnected)"); return FALSE; // shut down the callback, for now } aprsis_write_log(ctx, msg, len); if (msg[0] == '#') { printf("can ignore comment message: %s\n", msg); } else { printf ("\n------------------------------------------\nRead %u bytes: %s", (unsigned int) len, msg); process_packet(msg); } g_free(msg); return TRUE; }
static gboolean handle_stdin (GIOChannel * ch, GIOCondition cond, gpointer d) { gchar *buf; GBytes *data; GError *err = NULL; switch (g_io_channel_read_line (ch, &buf, NULL, NULL, &err)) { case G_IO_STATUS_NORMAL: g_string_append (inbuf, buf); return TRUE; case G_IO_STATUS_ERROR: g_printerr ("yad_html_handle_stdin(): %s\n", err->message); g_error_free (err); return FALSE; case G_IO_STATUS_EOF: data = g_bytes_new (inbuf->str, inbuf->len); g_string_free (inbuf, TRUE); webkit_web_view_load_bytes (view, data, options.html_data.mime, options.html_data.encoding, NULL); g_bytes_unref (data); return FALSE; case G_IO_STATUS_AGAIN: return TRUE; } return FALSE; }
void mk_key_value_read_file(GNode* root, const gchar* filename, const gboolean read_only) { GError* error = NULL; GIOChannel* chan; GIOStatus status; gchar* line = NULL; gsize length; // If not in read-only mode, accept that the file may not already exist. if (!read_only && !g_file_test(filename, G_FILE_TEST_EXISTS)) return; chan = g_io_channel_new_file(filename, "r", &error); if (error != NULL) g_critical("Error opening %s: %s", filename, error->message); while ((status = g_io_channel_read_line(chan, &line, &length, NULL, &error)) == G_IO_STATUS_NORMAL ) { if (length > 0) g_strchomp(line); mk_key_value_read_line(root, line, NULL, NULL); } g_io_channel_unref(chan); g_free(line); }
static gboolean hostname_is_dynamic (void) { GIOChannel *channel; const char *pattern = "DHCLIENT_SET_HOSTNAME="; char *str = NULL; int pattern_len; gboolean dynamic = FALSE; channel = g_io_channel_new_file (CONF_DHCP, "r", NULL); if (!channel) return dynamic; pattern_len = strlen (pattern); while (g_io_channel_read_line (channel, &str, NULL, NULL, NULL) != G_IO_STATUS_EOF) { if (!strncmp (str, pattern, pattern_len)) { if (!strncmp (str + pattern_len, "\"yes\"", 5)) dynamic = TRUE; break; } g_free (str); } g_io_channel_shutdown (channel, FALSE, NULL); g_io_channel_unref (channel); return dynamic; }
static gboolean handle_output_ready (GIOChannel *channel, GIOCondition condition, GString *str, BlockData *data) { g_debug ("output handler"); /* if there is aready an error, abort */ if (data->error) { return FALSE; } if (condition & (G_IO_IN | G_IO_PRI)) { GIOStatus status; do { gchar *line; gsize len; /*g_debug ("reading...");*/ status = g_io_channel_read_line (channel, &line, &len, NULL, &data->error); /*g_debug ("read %lu bytes: %s", len, line);*/ if (line != NULL) { g_string_append_len (str, line, (gssize)len); g_free (line); } } while (status == G_IO_STATUS_NORMAL || status == G_IO_STATUS_AGAIN); } g_io_channel_shutdown(channel, FALSE, data->error ? NULL : &data->error); return FALSE; }
static gboolean output_out(GIOChannel *channel, GIOCondition cond, gpointer type) { if(cond == G_IO_HUP) { g_io_channel_unref(channel); return FALSE; } gchar *string, **column; GeanyDocument *doc = document_get_current(); if((g_io_channel_read_line(channel, &string, NULL, NULL, NULL)) == G_IO_STATUS_NORMAL && string) { column = g_strsplit(string, ":", 3); gchar *code = column[2]; column[2] = g_regex_replace(trim_regex, column[2], -1, 0, "", 0, NULL); g_free(code); gtk_tree_store_append(list, &row, NULL); gtk_tree_store_set(list, &row, 0, row_pos, 1, column[1], 2, column[0], 3, g_strstrip(column[2]), -1); g_strfreev(column); row_pos++; } g_free(string); return TRUE; }
gboolean control_fifo(GIOChannel *gio, GIOCondition condition) { if (uzbl.state.verbose) printf("triggered\n"); gchar *ctl_line; GIOStatus ret; GError *err = NULL; if (condition & G_IO_HUP) g_error ("Fifo: Read end of pipe died!\n"); if(!gio) g_error ("Fifo: GIOChannel broke\n"); ret = g_io_channel_read_line(gio, &ctl_line, NULL, NULL, &err); if (ret == G_IO_STATUS_ERROR) { g_error ("Fifo: Error reading: %s\n", err->message); g_error_free (err); } parse_cmd_line(ctl_line, NULL); g_free(ctl_line); return TRUE; }
static gboolean child_stdout_data_cb (GIOChannel *source, GIOCondition condition, gpointer user_data) { VpnSecretsInfo *info = user_data; AppletVpnRequest *self = info->vpn; AppletVpnRequestPrivate *priv = APPLET_VPN_REQUEST_GET_PRIVATE (self); const char *buf = "QUIT\n\n"; char *str; int len; if (!(condition & G_IO_IN)) return TRUE; if (g_io_channel_read_line (source, &str, NULL, NULL, NULL) == G_IO_STATUS_NORMAL) { len = strlen (str); if (len == 1 && str[0] == '\n') { /* on second line with a newline newline */ if (++priv->num_newlines == 2) { /* terminate the child */ if (write (priv->child_stdin, buf, strlen (buf)) == -1) return TRUE; } } else if (len > 0) { /* remove terminating newline */ str[len - 1] = '\0'; priv->lines = g_slist_append (priv->lines, str); } } return TRUE; }
void load_clustering(const char* filename) { GError* err = NULL; GIOChannel* ch = g_io_channel_new_file(filename, "r", &err); if (err != NULL){ g_critical("error while opening clustering file"); return; } gchar* line; while(g_io_channel_read_line(ch, &line, NULL, NULL, NULL) == G_IO_STATUS_NORMAL) { gchar** cluster_strings = g_strsplit(line, ",", 50000); GArray* cluster = g_array_new(FALSE, FALSE, sizeof(Sequence*)); guint n = 0; while (cluster_strings[n] != NULL) { gchar* seq_id = g_strstrip(cluster_strings[n]); Sequence* seq = (Sequence*) g_hash_table_lookup(fasta->hash, seq_id); if (seq == NULL){ g_critical("Sequence '%s' not found!\n", seq_id); } n++; g_array_append_val(cluster, seq); } //g_message("found %d sequences\n", n); g_array_append_val(clusters, cluster); g_free(line); } }
FirmwareType detect_firmware(gchar * filename) { GIOChannel *chan = NULL; GError *error = NULL; gchar * buf = NULL; gsize len = 0; FirmwareType type = MS1; if (NULL != g_strrstr(filename,"bootstrap.s19")) return MS2; chan = g_io_channel_new_file(filename,"r",&error); while (G_IO_STATUS_NORMAL == g_io_channel_read_line(chan, &buf,&len,NULL,&error)) { if (g_strrstr(buf,"S2")) { type = MS2; g_free(buf); g_io_channel_shutdown(chan,FALSE,&error); return type; } g_free(buf); } g_io_channel_shutdown(chan, FALSE,&error); return type; }
/* Process keyboard input */ static gboolean handle_keyboard (GIOChannel *source, GIOCondition cond, CustomData *data) { gchar *str = NULL; if (g_io_channel_read_line (source, &str, NULL, NULL, NULL) != G_IO_STATUS_NORMAL) { return TRUE; } switch (g_ascii_tolower (str[0])) { case 'c': update_color_channel ("CONTRAST", g_ascii_isupper (str[0]), GST_COLOR_BALANCE (data->pipeline)); break; case 'b': update_color_channel ("BRIGHTNESS", g_ascii_isupper (str[0]), GST_COLOR_BALANCE (data->pipeline)); break; case 'h': update_color_channel ("HUE", g_ascii_isupper (str[0]), GST_COLOR_BALANCE (data->pipeline)); break; case 's': update_color_channel ("SATURATION", g_ascii_isupper (str[0]), GST_COLOR_BALANCE (data->pipeline)); break; case 'q': g_main_loop_quit (data->loop); break; default: break; } g_free (str); print_current_values (data->pipeline); return TRUE; }
static gpointer run_client_thread (gpointer data) { gint *socket = data; GError *error = NULL; GkdGpgAgentCall call; GIOStatus status; gboolean cont = TRUE; gchar *line; gsize n_line; g_assert (GCK_IS_MODULE (pkcs11_module)); call.sock = g_atomic_int_get (socket); call.channel = g_io_channel_unix_new (call.sock); g_io_channel_set_encoding (call.channel, NULL, NULL); g_io_channel_set_close_on_unref (call.channel, FALSE); call.module = g_object_ref (pkcs11_module); /* Initial response on the connection */ gkd_gpg_agent_send_reply (&call, TRUE, "your orders please"); while (cont) { line = NULL; n_line = 0; /* Read in a line */ status = g_io_channel_read_line (call.channel, &line, &n_line, NULL, &error); switch (status) { case G_IO_STATUS_ERROR: g_critical ("gpg agent couldn't read from socket: %s", egg_error_message (error)); g_clear_error (&error); cont = FALSE; break; case G_IO_STATUS_NORMAL: cont = process_line (&call, line); g_free (line); break; case G_IO_STATUS_EOF: cont = FALSE; break; case G_IO_STATUS_AGAIN: break; default: g_return_val_if_reached (NULL); break; }; } g_io_channel_shutdown (call.channel, FALSE, NULL); g_object_unref (call.module); close (call.sock); g_atomic_int_set (socket, -1); return NULL; }
gboolean DictClient::on_io_event(GIOChannel *ch, GIOCondition cond, gpointer user_data) { DictClient *dict_client = static_cast<DictClient *>(user_data); g_assert(dict_client); if (!dict_client->channel_) { g_warning("No channel available\n"); return FALSE; } if (cond & G_IO_ERR) { gchar *mes = g_strdup_printf("Connection failed to the dictionary server at %s:%d", dict_client->host_.c_str(), dict_client->port_); on_error_.emit(mes); g_free(mes); return FALSE; } GError *err = NULL; gsize term, len; gchar *line; GIOStatus res; for (;;) { if (!dict_client->channel_) break; res = g_io_channel_read_line(dict_client->channel_, &line, &len, &term, &err); if (res == G_IO_STATUS_ERROR) { if (err) { on_error_.emit("Error while reading reply from server: " + std::string(err->message)); g_error_free(err); } dict_client->disconnect(); return FALSE; } if (!len) break; //truncate the line terminator before parsing line[term] = '\0'; int status_code = get_status_code(line); bool res = dict_client->parse(line, status_code); g_free(line); if (!res) { dict_client->disconnect(); return FALSE; } } return TRUE; }
//! //! @brief To be written //! static gboolean _kanjipadwindow_engine_input_handler (GIOChannel *source, GIOCondition condition, gpointer data) { GwKanjipadWindow *window; GwKanjipadWindowPrivate *priv; static gchar *p; static gchar *line; GError *error; GIOStatus status; int i; window = GW_KANJIPADWINDOW (data); priv = window->priv; error = NULL; status = g_io_channel_read_line (priv->from_engine, &line, NULL, NULL, &error); switch (status) { case G_IO_STATUS_ERROR: fprintf (stderr, "Error reading from engine: %s\n", error->message); exit(EXIT_FAILURE); break; case G_IO_STATUS_NORMAL: break; case G_IO_STATUS_EOF: fprintf (stderr, "Engine no longer exists"); exit (EXIT_FAILURE); break; case G_IO_STATUS_AGAIN: g_assert_not_reached (); break; } if (line[0] == 'K') { unsigned int t1, t2; p = line + 1; for (i = 0; i < GW_KANJIPADWINDOW_MAX_GUESSES; i++) { while (*p && isspace(*p)) p++; if (!*p || sscanf(p, "%2x%2x", &t1, &t2) != 2) { i--; break; } priv->kanji_candidates[i][0] = t1; priv->kanji_candidates[i][1] = t2; while (*p && !isspace(*p)) p++; } priv->total_candidates = i + 1; gw_kanjipadwindow_draw_candidates (window); } g_free (line); return TRUE; }