newLISP v.10.6.4 development

Started by Lutz, September 23, 2015, 07:53:56 PM

Previous topic - Next topic

Lutz

newLISP v.10.6.4 development release fixes bugs and enhances some functions.



Release notes: http://www.newlisp.org/downloads/development/newLISP-10.6.4-Release.html">http://www.newlisp.org/downloads/develo ... lease.html">http://www.newlisp.org/downloads/development/newLISP-10.6.4-Release.html



Files: http://www.newlisp.org/downloads/development">http://www.newlisp.org/downloads/development



Thanks to everybody who participated  in this release with feature proposals, code and discovering bugs.



One important change in this release is the new installation directory prefix /usr/local/ for /usr/local/bin on Mac OS X, Linux and all other Unix like platforms. The change was prompted by the pending new Mac OS X 10.11 El Capitan, which does not allow installs in /usr/bin etc.. The alternate configure script configure-alt already has been using /usr/local.



Unix based scripts having #!/usr/bin/newlisp int the first line will have to be changed to #!/usr/local/bin/newlisp or #!/usr/bin/env newlisp. The last would work for all directories in the executable path of a platform.

kosh

#1
Nice work, Lutz.



However newlisp-10.6.4.tgz can not be decompressed.


$ curl -O http://www.newlisp.org/downloads/development/newlisp-10.6.4.tgz
$ tar xf newlisp-10.6.4.tgz
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.
$ shasum *
82c51584a894e6f8dc02597d9ddfb68bd836966a  newlisp-10.6.4-OSX-intel.dmg
82c51584a894e6f8dc02597d9ddfb68bd836966a  newlisp-10.6.4.tgz

Lutz

#2
Thanks Kosh, newlisp-10.6.4.tgz re-uploaded and tested.

irr

#3
Great news Lutz!



Please, to compile on CentOS you need to modify the following file:

newlisp-10.6.4/configure



Here is the patch:

$ diff -ur newlisp-10.6.4-original newlisp-10.6.4

diff -ur newlisp-10.6.4-original/configure newlisp-10.6.4/configure

--- newlisp-10.6.4-original/configure   2015-09-23 14:19:13.000000000 -0300

+++ newlisp-10.6.4/configure   2015-09-25 13:26:25.908544173 -0300

@@ -72,7 +72,7 @@

    cp makefile_darwinLP64_utf8_ffi makefile_build

 elif [ ${os_type} = LINUX ] ; then

    if [ -f /etc/redhat-release ] ; then

-      libffi_version=$(ls -d /usr/lib*/libffi*/include &>/dev/null)

+      libffi_version=$(ls -d /usr/lib*/libffi*/include)

         if [ -z "${libffi_version}" ] ; then

             libffi_version="/usr/include"

         fi



In summary, you need to remove the redirection (&> /dev/null).



Regards,



  Ivan

protozen

#4
with 10.6.3 and 10.6.4 on windows newlisp crashes when trying to make ffi calls - I've not tested various libraries but curl.lsp definitely crashes.

xytroxon

#5
Quote from: "protozen"with 10.6.3 and 10.6.4 on windows newlisp crashes when trying to make ffi calls - I've not tested various libraries but curl.lsp definitely crashes.


Hi protozen!



sqlite3.lsp and sqlite3.dll work fine on my Win7 system (with both versions of newLISP).



Did you install 64 bit newLISP version? 32 bit dlls don't work with 64 bit newLSP and vice versa.



-- xytroxon
\"Many computers can print only capital letters, so we shall not use lowercase letters.\"

-- Let\'s Talk Lisp (c) 1976

protozen

#6
It happens with 32 and 64 bit on Windows 10. I've tried curl, crypto and SQLite (but not for both 32 and 64 for all). I've been using 10.6.2 because of this, as 10.6.3 and 10.6.4 crashes consistently (at least on windows 10, I haven to tried other platforms). Unfortunately I've not had the time to figure out why, so I'll stay on 10.6.2 until I do.

xytroxon

#7
That sucks!



Another thing to check is that ostype "Win32" was changed to "Windows"



kosh's cURL module has both "Win32"  "Windows" so should work?

https://github.com/kosh04/newlisp-curl">//https://github.com/kosh04/newlisp-curl



-- xytroxon
\"Many computers can print only capital letters, so we shall not use lowercase letters.\"

-- Let\'s Talk Lisp (c) 1976

xytroxon

#8
Okay, I tried Kosh's code and (curl-version) "libcurl") always works,

but crashes on (curl-easy-escape "newlisp.org/?q=index.html#123") or

(curl-get "http://localhost/wiki/">http://localhost/wiki/")



Compiled 10.6.4 on Win 7 without FFI enabled and it has the same hang problem!



As  protozen noted, this code works on 10.6.2 or before and fails on 10.6.3 and 10.6.4 versions.



My sqlite3.dll is from 2010, but works with versions 2.7 and 2.83 sqlite3.lsp on newLISP 10.6.4



-- xytroxon
\"Many computers can print only capital letters, so we shall not use lowercase letters.\"

-- Let\'s Talk Lisp (c) 1976

Lutz

#9
Try adding the "cdecl" option on the import statement and start trying with the 32-bit version of newLISP. See here:



http://www.newlisp.org/downloads/newlisp_manual.html#import">http://www.newlisp.org/downloads/newlis ... tml#import">http://www.newlisp.org/downloads/newlisp_manual.html#import



Assuming you are using the simple version of the FFI without libffi support.

xytroxon

#10
Lutz to the rescue!!!



Adding "cdecl" to import works for all 32bit versions of newLISP I have on my Win7 system.



Below is an emergency working version of curl.lsp, (you may want to wait until kosh fixes his code and tests it more ;>)



While the cURL website has both 32 and 64 bit dlls, the sqlite3 website seems to only be pre-compiled for 32 bit systems, so you may need to stick to 32bit newLISP distros.



http://curl.haxx.se/">//http://curl.haxx.se/

http://www.sqlite.org/">//http://www.sqlite.org/



;;; curl.lsp

;; @module curl.lsp
;; @description libcurl wrapper
;; @version 0.2
;; @author KOBAYASHI Shigeru (kosh)
;; @license MIT
;; @location https://github.com/kosh04/newlisp-curl

;; ChangeLog:
;; 2015-09-28  add "cdecl" to import calls (xytroxon)
;; 2015-03-10  add testing
;; 2013-12-04  add function curl-get. add dylib (osx).
;; 2011-08-02  first commit.

;; Link:
;;
;; libcurl - API
;; - http://curl.haxx.se/libcurl/c/
;; libcurl - source code examples
;; - http://curl.haxx.se/libcurl/c/example.html

(case ostype
  ("Win32"
   (define libcurl "libcurl.dll"))
  ("Windows" ; v.10.6.3+
   (define libcurl "libcurl.dll"))
  ("Cygwin"
   (define libcurl "cygcurl-4.dll"))
  ("BSD"
   (define libcurl "libcurl.so"))
  ("OSX"
   (define libcurl "libcurl.dylib"))
  ("Linux"
   (define libcurl "libcurl.so.3"))
  (true
   ;; assume unix flavor
   (define libcurl "libcurl.so")))

#include <curl/curl.h>
(import libcurl "curl_strequal" "cdecl")
(import libcurl "curl_strnequal" "cdecl")
(import libcurl "curl_formadd" "cdecl")
(import libcurl "curl_formget" "cdecl")
(import libcurl "curl_formfree" "cdecl")
(import libcurl "curl_getenv" "cdecl")
(import libcurl "curl_version" "cdecl")       ; char *curl_version();
(import libcurl "curl_easy_escape" "cdecl")   ; char *curl_easy_escape(CURL *curl, char *url, int length);
(import libcurl "curl_escape" "cdecl")        ; XXX (deprecated, do not use)
(import libcurl "curl_easy_unescape" "cdecl") ; char *curl_easy_unescape(CURL *curl, char *url, int inlength, int * outlength);
(import libcurl "curl_unescape" "cdecl")
(import libcurl "curl_free" "cdecl")          ; void curl_free(char *ptr);
(import libcurl "curl_global_init" "cdecl")   ; CURLcode curl_global_init(long flags);
(import libcurl "curl_global_init_mem" "cdecl")
(import libcurl "curl_global_cleanup" "cdecl")
(import libcurl "curl_slist_append" "cdecl")
(import libcurl "curl_slist_free_all" "cdecl")
(import libcurl "curl_getdate" "cdecl")
(import libcurl "curl_share_init" "cdecl")
(import libcurl "curl_share_setopt" "cdecl")
(import libcurl "curl_share_cleanup" "cdecl")
(import libcurl "curl_version_info" "cdecl")
(import libcurl "curl_easy_strerror" "cdecl") ; const char *curl_easy_strerror(CURLcode errornum);
(import libcurl "curl_share_strerror" "cdecl")
(import libcurl "curl_easy_pause" "cdecl")

#include <curl/easy.h>
(import libcurl "curl_easy_init" "cdecl")     ; CURL *curl_easy_init();
(import libcurl "curl_easy_setopt" "cdecl")   ; CURLcode curl_easy_setopt(CURL *handle, CURLoption option, parameter);
(import libcurl "curl_easy_perform" "cdecl")  ; CURLcode curl_easy_perform(CURL *handle);
(import libcurl "curl_easy_cleanup" "cdecl")  ; void curl_easy_cleanup(CURL * handle);
(import libcurl "curl_easy_getinfo" "cdecl")  ; CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);
(import libcurl "curl_easy_duphandle" "cdecl")
(import libcurl "curl_easy_reset" "cdecl")
(import libcurl "curl_easy_recv" "cdecl")
(import libcurl "curl_easy_send" "cdecl")

#include <curl/mprintf.h>
(import libcurl "curl_mprintf" "cdecl")
(import libcurl "curl_mfprintf" "cdecl")
(import libcurl "curl_msprintf" "cdecl")
(import libcurl "curl_msnprintf" "cdecl")
(import libcurl "curl_mvprintf" "cdecl")
(import libcurl "curl_mvfprintf" "cdecl")
(import libcurl "curl_mvsprintf" "cdecl")
(import libcurl "curl_mvsnprintf" "cdecl")
(import libcurl "curl_maprintf" "cdecl")
(import libcurl "curl_mvaprintf" "cdecl")

#include <curl/multi.h>
(import libcurl "curl_multi_init" "cdecl")
(import libcurl "curl_multi_add_handle" "cdecl")
(import libcurl "curl_multi_remove_handle" "cdecl")
(import libcurl "curl_multi_fdset" "cdecl")
(import libcurl "curl_multi_perform" "cdecl")
(import libcurl "curl_multi_cleanup" "cdecl")
(import libcurl "curl_multi_info_read" "cdecl")
(import libcurl "curl_multi_strerror" "cdecl")
(import libcurl "curl_multi_socket" "cdecl")
(import libcurl "curl_multi_socket_action" "cdecl")
(import libcurl "curl_multi_socket_all" "cdecl")
(import libcurl "curl_multi_timeout" "cdecl")
(import libcurl "curl_multi_setopt" "cdecl")
(import libcurl "curl_multi_assign" "cdecl")

#include <curl/curl.h>
(define CURL_MAX_WRITE_SIZE 16384)

;; typedef enum { ... } CURLcode;
(define CURLE_OK 0)
(define CURLE_UNSUPPORTED_PROTOCOL 1)
(define CURLE_WRITE_ERROR 23)

(define CURL_ERROR_SIZE 256)

#define CURLOPTTYPE_LONG          0
#define CURLOPTTYPE_OBJECTPOINT   10000
#define CURLOPTTYPE_FUNCTIONPOINT 20000
#define CURLOPTTYPE_OFF_T         30000

;; typedef enum { ... } CURLoption;
(define CURLOPT_FILE (+ 10000 1))
(define CURLOPT_URL (+ 10000 2))
(define CURLOPT_PORT 3)
(define CURLOPT_INFILE (+ 10000 9))
(define CURLOPT_ERRORBUFFER (+ 10000 10))
(define CURLOPT_WRITEFUNCTION (+ 20000 11))
(define CURLOPT_POSTFIELDS (+ 10000 15))
(define CURLOPT_USERAGENT (+ 10000 18))
(define CURLOPT_HTTPHEADER (+ 10000 23))
(define CURLOPT_WRITEHEADER (+ 10000 29))

(define CURLOPT_VERBOSE 41)
(define CURLOPT_HEADER 42)
(define CURLOPT_NOPROGRESS 43)
(define CURLOPT_NOBODY 43)
(define CURLOPT_POST 47)

(define CURLOPT_FOLLOWLOCATION 52)
(define CURLOPT_SSL_VERIFYPEER 64)
(define CURLOPT_SSL_VERIFYHOST 81)

(define SSL_VERIFYHOST 81)

(define CURLOPT_WRITEDATA CURLOPT_FILE)
(define CURLOPT_READDATA  CURLOPT_INFILE)
(define CURLOPT_HEADERDATA CURLOPT_WRITEHEADER)

(define CURL_GLOBAL_SSL (<< 1 0))
(define CURL_GLOBAL_WIN32 (<< 1 1))
(define CURL_GLOBAL_ALL (| CURL_GLOBAL_SSL CURL_GLOBAL_WIN32))
(define CURL_GLOBAL_NOTHING 0)
(define CURL_GLOBAL_DEFAULT CURL_GLOBAL_ALL)

(define (curl--getstring ptr (len 0))
  (first (unpack (format "s%u" len) ptr)))

;; @syntax (curl-version)
;; @return <string> Returns the libcurl version string.
;; @example
;; (curl-version) => "libcurl/7.30.0 SecureTransport zlib/1.2.5"

(define (curl-version)
  (get-string (curl_version)))

;; @syntax (curl-easy-escape <url>)
;; @param <url>
;; @return <string> Return the encoded url.
;; @example
;; (curl-easy-escape "newlisp.org/?q=index.html#123")
;; => "newlisp.org%2F%3Fq%3Dindex.html%23123"

(define (curl-easy-escape url)
  (letn ((curl (curl_easy_init))
         (res (curl_easy_escape curl url 0))
         (str (get-string res)))
    (curl_free res)
    (curl_easy_cleanup curl)
    str))

;; @syntax (curl-easy-unescape <url>)
;; @param <url>
;; @return <string> Returns the unescaped url.
;; @example
;; (curl-easy-unescape "newlisp.org%2F%3Fq%3Dindex.html%23123")
;; => "newlisp.org/?q=index.html#123"

(define (curl-easy-unescape url)
  (letn ((curl (curl_easy_init))
         (outlen (pack "lu" 0))
         (res (curl_easy_unescape curl url 0 outlen))
         (str (curl--getstring res (get-int outlen))))
    (curl_free res)
    (curl_easy_cleanup curl)
    str))

;; @syntax (curl-simple <url>)
;; @param <url>
;; @example
;; (curl-simple "https://www.google.com/")
;; -> print html data to stdout

(define (curl-simple url (verbose nil))
  (local (curl res)
    (setq curl (curl_easy_init))
    (when (!= curl 0)
      (curl_easy_setopt curl CURLOPT_URL url)
      (curl_easy_setopt curl CURLOPT_VERBOSE (if verbose 1 0))
      ;;(curl_easy_setopt curl CURLOPT_HEADER 0)
      (curl_easy_setopt curl CURLOPT_SSL_VERIFYPEER 0)
      ;;(curl_easy_setopt curl CURLOPT_SSL_VERIFYHOST 0)
      (setf res (curl_easy_perform curl))
      (curl_easy_cleanup curl)
      (if (!= res CURLE_OK)
          (write-line 2 (get-string (curl_easy_strerror res))))
      (= res CURLE_OK))))

;; @syntax (curl-get <url>)
;; @param <url>
;; @return <string> Returns html data.
;; @example
;; (curl-get "https://www.google.com/")
;; => "<HTML><HEAD><meta http-equiv="content-type" ..."
;; (curl-simple url) ~= (print (curl-get url))

(define (curl-get url)
  (local (curl buffer writefn res)
    (curl_global_init CURL_GLOBAL_ALL)
    (setq curl (curl_easy_init))
    (when (!= curl 0)
      (curl_easy_setopt curl CURLOPT_URL url)
      (curl_easy_setopt curl CURLOPT_USERAGENT "Mozilla/5.0")
      (curl_easy_setopt curl CURLOPT_FOLLOWLOCATION 0)
      (curl_easy_setopt curl CURLOPT_NOPROGRESS 1)
      (curl_easy_setopt curl CURLOPT_SSL_VERIFYPEER 0) ; option -k/--insecure
      ;;(curl_easy_setopt curl CURLOPT_SSL_VERIFYHOST 0)
      (setq buffer "")
      (setq writefn (lambda (buf size n data)
                      (extend buffer (curl--getstring buf (* size n)))
                      (* size n)))
      (curl_easy_setopt curl CURLOPT_WRITEFUNCTION (callback 0 'writefn))
      (setq res (curl_easy_perform curl))
      (when (!= res CURLE_OK)
        (setq buffer nil)
        (write-line 2 (get-string (curl_easy_strerror res))))
      (curl_easy_cleanup curl))
    (curl_global_cleanup)
    buffer))

(context MAIN)



-- xytroxon
\"Many computers can print only capital letters, so we shall not use lowercase letters.\"

-- Let\'s Talk Lisp (c) 1976

protozen

#11
Thanks xytroxon and Lutz. Adding cdecl works, at least with crypto.lsp in the distribution that I just tried.



Binary was this 32bit windows on windows 10:



http://newlisp.nfshost.com/downloads/development/newlisp-10604-win-gs-164.exe">http://newlisp.nfshost.com/downloads/de ... gs-164.exe">http://newlisp.nfshost.com/downloads/development/newlisp-10604-win-gs-164.exe



Build label states:



newLISP v.10.6.4 32-bit on Windows IPv4/6 libffi, options: newlisp -h

kanen

#12
Issue in release notes -- it's /usr/local and not /ust/local/ as the notes suggest.
. Kanen Flowers http://kanen.me[/url] .