rest25/library/dl.rst => rest262/library/dl.rst
f1
2:mod:`dl` --- Call C functions in shared objects
3================================================
4
5.. module:: dl
6   :platform: Unix
7   :synopsis: Call C functions in shared objects.
n8+   :deprecated:
9+ 
10+.. deprecated:: 2.6
11+    The :mod:`dl` module has been removed in Python 3.0. Use the :mod:`ctypes`
12+    module instead.
13+ 
8.. sectionauthor:: Moshe Zadka <moshez@zadka.site.co.il>
n9- 
10- 
11-.. % ?????????? Anyone????????????
12
13The :mod:`dl` module defines an interface to the :cfunc:`dlopen` function, which
14is the most common interface on Unix platforms for handling dynamically linked
15libraries. It allows the program to call arbitrary functions in such a library.
16
17.. warning::
18
19   The :mod:`dl` module bypasses the Python type system and  error handling. If
23.. note::
24
25   This module will not work unless ``sizeof(int) == sizeof(long) == sizeof(char
26   *)`` If this is not the case, :exc:`SystemError` will be raised on import.
27
28The :mod:`dl` module defines the following function:
29
30
n31-.. function:: open(name[, mode\ ``= RTLD_LAZY``])
n34+.. function:: open(name[, mode=RTLD_LAZY])
32
33   Open a shared object file, and return a handle. Mode signifies late binding
34   (:const:`RTLD_LAZY`) or immediate binding (:const:`RTLD_NOW`). Default is
35   :const:`RTLD_LAZY`. Note that some systems do not support :const:`RTLD_NOW`.
36
37   Return value is a :class:`dlobject`.
38
39The :mod:`dl` module defines the following constants:
73.. _dl-objects:
74
75Dl Objects
76----------
77
78Dl objects, as returned by :func:`open` above, have the following methods:
79
80
n81-.. method:: XXX Class.close()
n84+.. method:: dl.close()
82
83   Free all resources, except the memory.
84
85
n86-.. method:: XXX Class.sym(name)
n89+.. method:: dl.sym(name)
87
88   Return the pointer for the function named *name*, as a number, if it exists in
89   the referenced shared object, otherwise ``None``. This is useful in code like::
90
n91-      >>> if a.sym('time'): 
n94+      >>> if a.sym('time'):
92      ...     a.call('time')
n93-      ... else: 
n96+      ... else:
94      ...     time.time()
95
96   (Note that this function will return a non-zero number, as zero is the *NULL*
97   pointer)
98
99
t100-.. method:: XXX Class.call(name[, arg1[, arg2...]])
t103+.. method:: dl.call(name[, arg1[, arg2...]])
101
102   Call the function named *name* in the referenced shared object. The arguments
103   must be either Python integers, which will be  passed as is, Python strings, to
104   which a pointer will be passed,  or ``None``, which will be passed as *NULL*.
105   Note that  strings should only be passed to functions as :ctype:`const char\*`,
106   as Python will not like its string mutated.
107
108   There must be at most 10 arguments, and arguments not given will be treated as
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op