aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os_unix.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2014-06-28 14:44:34 -0400
committerJustin M. Keyes <justinkz@gmail.com>2014-06-28 14:44:34 -0400
commit2ddeb74202633784b9ebb4b963e2df06ed7332df (patch)
tree0ddf05ea55842969d23a9f1dfe41c980150c3fca /src/nvim/os_unix.c
parent2fcc07892fcf05479fa1142e6a4fe5101c1cdf7a (diff)
parent8c51804d525b771e0751603d0cb4470249dc0ae0 (diff)
downloadrneovim-2ddeb74202633784b9ebb4b963e2df06ed7332df.tar.gz
rneovim-2ddeb74202633784b9ebb4b963e2df06ed7332df.tar.bz2
rneovim-2ddeb74202633784b9ebb4b963e2df06ed7332df.zip
Merge #802 'implement VimL libcall with os_libcall'
Diffstat (limited to 'src/nvim/os_unix.c')
-rw-r--r--src/nvim/os_unix.c190
1 files changed, 0 insertions, 190 deletions
diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c
index 6d1b06dbcf..01c2ef4164 100644
--- a/src/nvim/os_unix.c
+++ b/src/nvim/os_unix.c
@@ -70,11 +70,6 @@
# include <termios.h>
#endif
-/* shared library access */
-#if defined(HAVE_DLFCN_H) && defined(USE_DLOPEN)
-# include <dlfcn.h>
-#endif
-
#ifdef HAVE_SELINUX
# include <selinux/selinux.h>
static int selinux_enabled = -1;
@@ -102,36 +97,6 @@ void mch_write(char_u *s, int len)
}
/*
- * A simplistic version of setjmp() that only allows one level of using.
- * Don't call twice before calling mch_endjmp()!.
- * Usage:
- * mch_startjmp();
- * if (SETJMP(lc_jump_env) != 0)
- * {
- * mch_didjmp();
- * EMSG("crash!");
- * }
- * else
- * {
- * do_the_work;
- * mch_endjmp();
- * }
- * Note: Can't move SETJMP() here, because a function calling setjmp() must
- * not return before the saved environment is used.
- * Returns OK for normal return, FAIL when the protected code caused a
- * problem and LONGJMP() was used.
- */
-void mch_startjmp()
-{
- lc_active = TRUE;
-}
-
-void mch_endjmp()
-{
- lc_active = FALSE;
-}
-
-/*
* If the machine has job control, use it to suspend the program,
* otherwise fake it by starting a new shell.
*/
@@ -1490,158 +1455,3 @@ static int have_dollars(int num, char_u **file)
return TRUE;
return FALSE;
}
-
-#if defined(FEAT_LIBCALL) || defined(PROTO)
-typedef char_u * (*STRPROCSTR)(char_u *);
-typedef char_u * (*INTPROCSTR)(int);
-typedef int (*STRPROCINT)(char_u *);
-typedef int (*INTPROCINT)(int);
-
-/*
- * Call a DLL routine which takes either a string or int param
- * and returns an allocated string.
- */
-int mch_libcall(char_u *libname,
- char_u *funcname,
- char_u *argstring, /* NULL when using an argint */
- int argint,
- char_u **string_result, /* NULL when using number_result */
- int *number_result)
-{
-# if defined(USE_DLOPEN)
- void *hinstLib;
- char *dlerr = NULL;
-# else
- shl_t hinstLib;
-# endif
- STRPROCSTR ProcAdd;
- INTPROCSTR ProcAddI;
- char_u *retval_str = NULL;
- int retval_int = 0;
- int success = FALSE;
-
- /*
- * Get a handle to the DLL module.
- */
-# if defined(USE_DLOPEN)
- /* First clear any error, it's not cleared by the dlopen() call. */
- (void)dlerror();
-
- hinstLib = dlopen((char *)libname, RTLD_LAZY
-# ifdef RTLD_LOCAL
- | RTLD_LOCAL
-# endif
- );
- if (hinstLib == NULL) {
- /* "dlerr" must be used before dlclose() */
- dlerr = (char *)dlerror();
- if (dlerr != NULL)
- EMSG2(_("dlerror = \"%s\""), dlerr);
- }
-# else
- hinstLib = shl_load((const char*)libname, BIND_IMMEDIATE|BIND_VERBOSE, 0L);
-# endif
-
- /* If the handle is valid, try to get the function address. */
- if (hinstLib != NULL) {
- /*
- * Catch a crash when calling the library function. For example when
- * using a number where a string pointer is expected.
- */
- mch_startjmp();
- if (SETJMP(lc_jump_env) != 0) {
- success = FALSE;
-# if defined(USE_DLOPEN)
- dlerr = NULL;
-# endif
- } else
- {
- retval_str = NULL;
- retval_int = 0;
-
- if (argstring != NULL) {
-# if defined(USE_DLOPEN)
- ProcAdd = (STRPROCSTR)dlsym(hinstLib, (const char *)funcname);
- dlerr = (char *)dlerror();
-# else
- if (shl_findsym(&hinstLib, (const char *)funcname,
- TYPE_PROCEDURE, (void *)&ProcAdd) < 0)
- ProcAdd = NULL;
-# endif
- if ((success = (ProcAdd != NULL
-# if defined(USE_DLOPEN)
- && dlerr == NULL
-# endif
- ))) {
- if (string_result == NULL)
- retval_int = ((STRPROCINT)ProcAdd)(argstring);
- else
- retval_str = (ProcAdd)(argstring);
- }
- } else {
-# if defined(USE_DLOPEN)
- ProcAddI = (INTPROCSTR)dlsym(hinstLib, (const char *)funcname);
- dlerr = (char *)dlerror();
-# else
- if (shl_findsym(&hinstLib, (const char *)funcname,
- TYPE_PROCEDURE, (void *)&ProcAddI) < 0)
- ProcAddI = NULL;
-# endif
- if ((success = (ProcAddI != NULL
-# if defined(USE_DLOPEN)
- && dlerr == NULL
-# endif
- ))) {
- if (string_result == NULL)
- retval_int = ((INTPROCINT)ProcAddI)(argint);
- else
- retval_str = (ProcAddI)(argint);
- }
- }
-
- /* Save the string before we free the library. */
- /* Assume that a "1" or "-1" result is an illegal pointer. */
- if (string_result == NULL)
- *number_result = retval_int;
- else if (retval_str != NULL
- && retval_str != (char_u *)1
- && retval_str != (char_u *)-1)
- *string_result = vim_strsave(retval_str);
- }
-
- mch_endjmp();
-# ifdef SIGHASARG
- if (lc_signal != 0) {
- int i;
-
- /* try to find the name of this signal */
- for (i = 0; signal_info[i].sig != -1; i++)
- if (lc_signal == signal_info[i].sig)
- break;
- EMSG2("E368: got SIG%s in libcall()", signal_info[i].name);
- }
-# endif
-
-# if defined(USE_DLOPEN)
- /* "dlerr" must be used before dlclose() */
- if (dlerr != NULL)
- EMSG2(_("dlerror = \"%s\""), dlerr);
-
- /* Free the DLL module. */
- (void)dlclose(hinstLib);
-# else
- (void)shl_unload(hinstLib);
-# endif
- }
-
- if (!success) {
- EMSG2(_(e_libcall), funcname);
- return FAIL;
- }
-
- return OK;
-}
-#endif
-
-
-