Back to index

texmacs  1.0.7.15
Functions | Variables
dyn_link.cpp File Reference
#include "dyn_link.hpp"
#include "url.hpp"
#include "hashmap.hpp"
#include <dlfcn.h>
#include <TeXmacs.h>

Go to the source code of this file.

Functions

string symbol_install (string lib, string symb, pointer &f)
string symbols_install (string lib, string *symb, pointer *f, int n)
tm_link make_dynamic_link (string lib, string symb, string init, string session)

Variables

static hashmap< string, pointerdyn_linked (NULL)
static TeXmacs_exports_1 TeXmacs

Function Documentation

tm_link make_dynamic_link ( string  lib,
string  symb,
string  init,
string  session 
)

Definition at line 101 of file dyn_link.cpp.

                                                                         {
  return tm_new<dyn_link_rep> (lib, symb, init, session);
}

Here is the call graph for this function:

Here is the caller graph for this function:

string symbol_install ( string  lib,
string  symb,
pointer f 
)

Definition at line 27 of file dyn_link.cpp.

                                                     {
#ifndef __MINGW32__
  // f becomes NULL in case of failure
  // status message returned
  string out;

  if (!dyn_linked->contains (lib)) {
    url name= resolve (url ("$LD_LIBRARY_PATH", lib));
    if (is_none (name)) out= "Library '" * lib * "' not found";
    else {
      lib= concretize (name);
      char* _lib = as_charp (lib);
      dyn_linked (lib)= dlopen (_lib, RTLD_LAZY);
      if (dyn_linked [lib] == NULL) {
       const char *err = dlerror();
       if (err != NULL) out= string ((char *) err);
      }
      tm_delete_array (_lib);
    }
  }

  pointer handle= dyn_linked [lib];
  if (handle) {
    char* _symb= as_charp (symb);
    string tag= lib * ":" * symb;
    if (!dyn_linked->contains (tag))
      dyn_linked (tag)= dlsym (handle, _symb);
    f= dyn_linked [tag];
    if (f != NULL) out= "Dynamically linked symbol '" * symb * "'";
    else out= "Can not find symbol '" * symb * "' in  '" * lib * "'";
    tm_delete_array (_symb);
  }
  else {
    f= NULL;
    if (out == "") out= "Couldn't find dynamic library '" * lib * "'";
  }

  if (DEBUG_AUTO) cout << "TeXmacs] " << out << "\n";
  return out;
#else
  return "Dynamic linking not implemented";
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

string symbols_install ( string  lib,
string symb,
pointer f,
int  n 
)

Definition at line 72 of file dyn_link.cpp.

                                                              {
#ifndef __MINGW32__
  int i;
  for (i=0; i<n; i++) f[i]= NULL;
  for (i=0; i<n; i++) {
    string message= symbol_install (lib, symb[i], f[i]);
    if (f[i] == NULL) return message;
  }
  return "Symbols installed for library '" * lib * "'";
#else
  return "Dynamic linking not implemented";
#endif
}

Here is the call graph for this function:


Variable Documentation

hashmap<string,pointer> dyn_linked(NULL) [static]
Initial value:
 {
  const_cast<char*> ("TeXmacs communication protocol 1"),
  const_cast<char*> ("TeXmacs " TEXMACS_VERSION),
}

Definition at line 105 of file dyn_link.cpp.