[uim-commit] r305 - in trunk: . uim xim
ekato@freedesktop.org
ekato@freedesktop.org
Sun Jan 16 02:49:18 PST 2005
Author: ekato
Date: 2005-01-16 02:49:15 -0800 (Sun, 16 Jan 2005)
New Revision: 305
Added:
trunk/uim/strsep.c
Modified:
trunk/configure.ac
trunk/uim/Makefile.am
trunk/uim/prime.c
trunk/uim/uim-ipc.c
trunk/uim/uim.h
trunk/xim/util.cpp
Log:
* This commit is a workaround for r304.
* uim/uim.h : Add new prototype uim_ipc_open_command_with_option.
* uim/uim-ipc.c (uim_ipc_open_command_with_option) : New function.
Most of the code is from old uim_ipc_open_command(), but use execvp
instead of execlp. const char *option is used as a command line
argument.
(uim_ipc_open_command) : Call uim_ipc_open_command_with_option()
with option NULL.
* uim/prime.c (prime_ud_command) : Removed.
(prime_init_ud) : Don't free path here.
(prime_ud_get_path) : Use "/tmp/uim-prime-user" as the socket path.
(prime_get_ud_command) : Removed.
(prime_lib_init) : Use proper option for
uim_ipc_open_command_with_option().
* uim/strsep.c : New file. Add strsep() for system without it.
* uim/Makefile.am (libuim_la_SOURCES) : Remove prime.c. Add
strsep.c if it is needed.
* xim/util.cpp (strsep) : Removed.
* configure.ac : Add AM_CONDITIONAL for NEED_STRSEP_C.
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2005-01-15 17:14:22 UTC (rev 304)
+++ trunk/configure.ac 2005-01-16 10:49:15 UTC (rev 305)
@@ -367,6 +367,7 @@
AM_CONDITIONAL(SCM_NESTED_EVAL, test x$enable_scm_nested_eval = xyes)
AM_CONDITIONAL(CALLBACK_QUEUE, test x$enable_callback_queue = xyes)
AM_CONDITIONAL(NEED_SETENV_C, test $ac_cv_func_setenv = no -o $ac_cv_func_unsetenv = no)
+AM_CONDITIONAL(NEED_STRSEP_C, test $ac_cv_func_strsep = no)
GTK_BINARY_VERSION=`pkg-config gtk+-2.0 --variable=gtk_binary_version`
AC_SUBST(GTK_BINARY_VERSION)
Modified: trunk/uim/Makefile.am
===================================================================
--- trunk/uim/Makefile.am 2005-01-15 17:14:22 UTC (rev 304)
+++ trunk/uim/Makefile.am 2005-01-16 10:49:15 UTC (rev 305)
@@ -14,7 +14,6 @@
libuim_la_SOURCES = uim.c uim-scm.c uim-util.c uim-func.c uim-key.c \
siod.h context.h gettext.h \
uim-helper.c uim-helper-client.c \
- prime.c \
intl.c \
uim-ipc.c \
getpeereid.c \
@@ -23,6 +22,9 @@
if NEED_SETENV_C
libuim_la_SOURCES += setenv.c
endif
+if NEED_STRSEP_C
+libuim_la_SOURCES += strsep.c
+endif
if COMPAT_TABLE
libuim_la_SOURCES += uim-table.c
Modified: trunk/uim/prime.c
===================================================================
--- trunk/uim/prime.c 2005-01-15 17:14:22 UTC (rev 304)
+++ trunk/uim/prime.c 2005-01-16 10:49:15 UTC (rev 305)
@@ -56,7 +56,6 @@
static int prime_pid = 0;
static char *prime_command = "prime";
-static char *prime_ud_command;
static char *prime_ud_path;
static int prime_fd;
static int use_unix_domain_socket;
@@ -74,8 +73,6 @@
server.sun_family = PF_UNIX;
strcpy(server.sun_path, path);
- free(path);
-
fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
perror("fail to create socket");
@@ -92,7 +89,7 @@
if(connect(fd, (struct sockaddr *)&server,sizeof(server)) == -1){
close(fd);
- printf("connect failed\n");
+ //fprintf(stderr, "connect failed\n");
return -1;
}
@@ -118,7 +115,7 @@
}
path = (char *)malloc(strlen(login)+ 20);
- sprintf(path, "/tmp/prime-%s",login);
+ sprintf(path, "/tmp/uim-prime-%s", login);
if (pw) {
free(login);
}
@@ -126,16 +123,6 @@
}
static char *
-prime_get_ud_command(void)
-{
- char *command = (char *) malloc(strlen(prime_command)
- + strlen(prime_ud_path) + 5);
-
- sprintf(command, "%s -u %s", prime_command, prime_ud_path);
- return command;
-}
-
-static char *
prime_read_msg_from_ud(int fd)
{
char *read_buf = strdup("");
@@ -208,6 +195,7 @@
static uim_lisp
prime_lib_init(uim_lisp use_udp_)
{
+ char *option;
#ifdef UIM_SCM_NESTED_EVAL
uim_bool use_udp = uim_scm_c_bool(use_udp_);
if(use_udp == UIM_TRUE)
@@ -222,13 +210,12 @@
if(!prime_ud_path)
return uim_scm_f();
- prime_ud_command = prime_get_ud_command();
- if(!prime_ud_command)
- return uim_scm_f();
-
prime_fd = prime_init_ud(prime_ud_path);
if(prime_fd == -1) {
- prime_pid = uim_ipc_open_command_with_opt(prime_pid, &primer, &primew, prime_command, "-u /tmp/prime-tkng");
+ option = malloc(strlen("-u ") + strlen(prime_ud_path) + 1);
+ sprintf(option, "-u %s", prime_ud_path);
+ prime_pid = uim_ipc_open_command_with_option(prime_pid, &primer, &primew, prime_command, option);
+ free(option);
if(prime_pid == 0) {
return uim_scm_f();
} else {
Added: trunk/uim/strsep.c
===================================================================
--- trunk/uim/strsep.c 2005-01-15 17:14:22 UTC (rev 304)
+++ trunk/uim/strsep.c 2005-01-16 10:49:15 UTC (rev 305)
@@ -0,0 +1,74 @@
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include <string.h>
+#include <stdio.h>
+
+#if !defined(HAVE_STRSEP)
+
+/*
+ * Get next token from string *stringp, where tokens are possibly-empty
+ * strings separated by characters from delim.
+ *
+ * Writes NULs into the string at *stringp to end tokens.
+ * delim need not remain constant from call to call.
+ * On return, *stringp points past the last NUL written (if there might
+ * be further tokens), or is NULL (if there are definitely no more tokens).
+ *
+ * If *stringp is NULL, strsep returns NULL.
+ */
+char *
+strsep(char **stringp, const char *delim)
+{
+ char *s;
+ const char *spanp;
+ int c, sc;
+ char *tok;
+
+ if ((s = *stringp) == NULL)
+ return (NULL);
+ for (tok = s;;) {
+ c = *s++;
+ spanp = delim;
+ do {
+ if ((sc = *spanp++) == c) {
+ if (c == 0)
+ s = NULL;
+ else
+ s[-1] = 0;
+ *stringp = s;
+ return (tok);
+ }
+ } while (sc != 0);
+ }
+ /* NOTREACHED */
+}
+
+#endif /* !defined(HAVE_STRSEP) */
Modified: trunk/uim/uim-ipc.c
===================================================================
--- trunk/uim/uim-ipc.c 2005-01-15 17:14:22 UTC (rev 304)
+++ trunk/uim/uim-ipc.c 2005-01-16 10:49:15 UTC (rev 305)
@@ -46,6 +46,10 @@
#include "context.h"
#include "uim-helper.h"
+#ifndef HAVE_STRSEP
+char *strsep(char **stringp, const char *delim);
+#endif
+
/* This function is come from the GNU C Library manual */
static int
set_cloexec(int fd)
@@ -142,10 +146,12 @@
}
int
-uim_ipc_open_command(int old_pid, FILE **read_fp,
- FILE **write_fp, const char *command)
+uim_ipc_open_command_with_option(int old_pid, FILE **read_fp,
+ FILE **write_fp, const char *command, const char *option)
{
int new_pid, result;
+ char **ap, *argv[10];
+ char *p;
if (*read_fp != NULL) {
fclose(*read_fp);
@@ -177,8 +183,22 @@
set_cloexec(i);
}
- result = execlp(command, command, NULL);
-
+ if (!option) {
+ argv[0] = (char *)command;
+ argv[1] = NULL;
+ } else {
+ argv[0] = (char *)command;
+ p = (char *)option;
+ for (ap = &argv[1]; (*ap = strsep(&p, " ")) != NULL;) {
+ if (**ap != '\0')
+ if (++ap >= &argv[10])
+ break;
+ }
+ *ap = NULL;
+ }
+
+ result = execvp(command, argv);
+
if(result == -1) {
write(1,"err",strlen("err"));
}
@@ -186,7 +206,13 @@
}
return new_pid;
+}
+int
+uim_ipc_open_command(int old_pid, FILE **read_fp,
+ FILE **write_fp, const char *command)
+{
+ return uim_ipc_open_command_with_option(old_pid, read_fp, write_fp, command, NULL);
}
char *
Modified: trunk/uim/uim.h
===================================================================
--- trunk/uim/uim.h 2005-01-15 17:14:22 UTC (rev 304)
+++ trunk/uim/uim.h 2005-01-16 10:49:15 UTC (rev 305)
@@ -568,6 +568,8 @@
/* Utility functions */
int
uim_ipc_open_command(int old_pid, FILE **read_handler, FILE **write_handler, const char *command);
+int
+uim_ipc_open_command_with_option(int old_pid, FILE **read_handler, FILE **write_handler, const char *command, const char *option);
char *
uim_ipc_send_command(int *pid, FILE **read_handler,
FILE **write_handler, const char *command, const char *str);
Modified: trunk/xim/util.cpp
===================================================================
--- trunk/xim/util.cpp 2005-01-15 17:14:22 UTC (rev 304)
+++ trunk/xim/util.cpp 2005-01-16 10:49:15 UTC (rev 305)
@@ -112,72 +112,3 @@
return len;
}
#endif
-
-#if !defined(HAVE_STRSEP)
-/*
- * strsep Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Get next token from string *stringp, where tokens are possibly-empty
- * strings separated by characters from delim.
- *
- * Writes NULs into the string at *stringp to end tokens.
- * delim need not remain constant from call to call.
- * On return, *stringp points past the last NUL written (if there might
- * be further tokens), or is NULL (if there are definitely no more tokens).
- *
- * If *stringp is NULL, strsep returns NULL.
- */
-char *
-strsep(char **stringp, const char *delim)
-{
- char *s;
- const char *spanp;
- int c, sc;
- char *tok;
-
- if ((s = *stringp) == NULL)
- return (NULL);
- for (tok = s;;) {
- c = *s++;
- spanp = delim;
- do {
- if ((sc = *spanp++) == c) {
- if (c == 0)
- s = NULL;
- else
- s[-1] = 0;
- *stringp = s;
- return (tok);
- }
- } while (sc != 0);
- }
- /* NOTREACHED */
-}
-#endif /* !defined(HAVE_STRSEP) */
More information about the Uim-commit
mailing list