source: trunk/abcl/contrib/posix-syscalls/posix-syscalls.org

Last change on this file was 15700, checked in by Mark Evenson, 12 months ago

Create POSIX-SYSCALLS contrib to set environment variables

Based on code provided by Alan Ruttenberg in
<https://github.com/alanruttenberg/lsw2/blob/owlapiv4/util/setenv.lisp>.

See
<https://mailman.common-lisp.net/pipermail/armedbear-devel/2023-April/004308.html>
ff.

See <file:contrib/posix-syscalls/posix-syscalls.org>.

File size: 1.2 KB
Line 
1#+title: POSIX SYSCALLS
2
3* POSIX_SYSCALLS contrib
4
5Created to respond to <https://mailman.common-lisp.net/pipermail/armedbear-devel/2023-April/004308.html>.
6
7This ABCL contrib provides and demonstrates the scaffolding for
8extending the implementation by use of direct syscalls via the foreign
9function interface (FFI) afforded by the JNA library.
10
11On loading this system, new implementations of the EXT:GETENV and
12UIOP/OS:GETENV functions are provided which use FFI to directly call
13the setenv() and getenv() library functions.  The setenv()
14functionality is provided by DEFSETF expander.
15
16** Usage
17
18*** Initialization
19#+begin_src lisp
20  (require :abcl-contrib)
21  (asdf:load-system :posix-syscalls)
22#+end_src
23
24*** Example
25
26#+begin_src
27CL-USER> (uiop/os:getenv "PATH")
28"/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin"
29CL-USER> (setf (uiop/os:getenv "PATH") "/usr/sbin")
30"/usr/sbin"
31CL-USER> (uiop/os:getenv "PATH")
32"/usr/sbin"
33CL-USER>
34#+end_src
35
36** Notes
37
38CFFI isn't used to minimize dependencies.
39
40Posix syscalls is perhaps a terrible name.
41
42This isn't expected work on Windows (untested).
43
44
45* Colophon 
46  #+begin_example
47    Mark <evenson@not.org>
48    Created: 24-MAY-2023
49    Revised: <2023-05-25 Thu 08:38>
50  #+end_example
51
52
53
Note: See TracBrowser for help on using the repository browser.