Back to index

texmacs  1.0.7.15
Classes | Functions
dyn_link.hpp File Reference
#include "tm_link.hpp"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  dyn_link_rep

Functions

string symbol_install (string lib, string symb, pointer &f)
string symbols_install (string lib, string *symb, pointer *f, int n)

Function Documentation

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: