コード例 #1
0
ファイル: common-gtk.c プロジェクト: na4zagin3/uim
static gboolean
fd_read_cb(GIOChannel *channel, GIOCondition c, gpointer p)
{
    gchar *msg;
    int fd = g_io_channel_unix_get_fd(channel);
    GtkWidget *widget = GTK_WIDGET(p);

    uim_helper_read_proc(fd);

    while ((msg = uim_helper_get_message())) {
        helper_toolbar_parse_helper_str(widget, msg);
        free(msg);
    }

    return TRUE;
}
コード例 #2
0
ファイル: uim.c プロジェクト: qsniyg/uim-led
void* uimled_uim_read_thread(void* data)
{
  char* s;
  char* s1;
  char* s2;
  char c;

  int fd = *((int*)data);

  while (1)
    {
      /* sleep until message */
      recv(fd, &c, 1, MSG_PEEK);

      uim_helper_read_proc(fd);
      while ((s = uim_helper_get_message()))
        {
          if (strncmp(s, "prop_list_update", sizeof("prop_list_update") - 1))
            goto endloop;

          s1 = s;

          while (1)
            {
              s1 = strstr(s1, "\nbranch\t");
              if (!s1)
                break;

              s1 += sizeof("\nbranch\t") - 1;
              s2 = strchr(s1, '\t');
              s2[0] = 0;

              pthread_mutex_lock(&uimled_uim_text_mut);
              uimled_uim_text = s1;
              pthread_mutex_unlock(&uimled_uim_text_mut);
              pthread_cond_signal(&uimled_uim_text_cond);

              s1 = s2 + 1;
            }

        endloop:
          free(s);
        }
    }

  return NULL;
}
コード例 #3
0
ファイル: uim-el-helper-agent.c プロジェクト: DirtYiCE/uim
int
main(int argc, char *argv[])
{
  int opt;

  while ((opt = getopt(argc, argv, "d")) != -1) {
	switch (opt) {
	case 'd':
	  debug_level ++;
	  break;
	}
  }

  if (debug_level == 0) fclose(stderr);

  if (uim_init() < 0) {
	debug_printf(DEBUG_ERROR, "uim_init failed\n");
	return -1;
  }

  atexit(cleanup);

  a_printf("OK\n");

  cmdbuf_len = DEFAULT_MESSAGE_SIZE;
  cmdbuf = uim_malloc(cmdbuf_len);
  cmdbuf[0] = '\0';

  while (1) {
	char *msg;
	fd_set rfds;

	check_helper_connection();

	wait_data_arrival(&rfds);

	debug_printf(DEBUG_NOTE, "data arrive\n");

	if (FD_ISSET(STDIN_FILENO, &rfds)) {
	  if (!read_command())
	    goto QUIT;
	}

	if (FD_ISSET(helper_fd, &rfds)) {
	  /* read message from helper */
	  uim_helper_read_proc(helper_fd);
	}

	while (command_exists_in_cmdbuf())
	  process_command();

	while ((msg = uim_helper_get_message())) {
	  process_message(msg);
	}
	fflush(NULL);
  }

 QUIT:
  uim_quit();
  return 0;
}