Re: s48_extract_string?

Taylor R Campbell <[email protected]>
Newsgroups gmane.lisp.scheme.scheme48
Message-ID <[email protected]>
   Date: Sat, 28 Feb 2009 13:46:47 +0100
   From: Donald Allen <[email protected]>

   I get

   > (load-dynamic-externals "/home/dca/Scheme48/test.so" #f #f #f)

   Error: vm-exception
          os-error
          (call-external-value "shared_object_dlopen"
   "/home/dca/Scheme48/test.so: undefined symbol: s48_extract_string")

   If I substitute a call in the C code to, say, s48_extract_byte_vector,
   then load-dynamic-externals is happy.

The documentation appears to be outdated.  Since Scheme48 1.5 or so,
when R6RSoid support for Unicode was introduced, s48_extract_string
has been no more.  Instead you must use `OS strings' on the Scheme
side and translate them to byte vectors for C use.  The relevant `OS
string' procedures are provided by the OS-STRINGS structure For
instance, here is how Scheme48's POSIX library currently wraps
getenv(3):

;;; scheme/proc/posix-env.scm

(define (lookup-environment-variable name)
  (cond
   ((external-lookup-environment-variable
     (os-string->byte-vector
      (x->os-string name)))
    => x->os-string)
   (else #f)))

(import-lambda-definition external-lookup-environment-variable (name)
  "posix_get_env")

;;; c/posix/proc-env.c

static s48_value
posix_get_env(s48_value name)
{
  char *value;

  value = getenv(s48_extract_byte_vector(name));

  return (value == NULL) ? S48_FALSE : s48_enter_byte_string(value);
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.