Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Dmi

#16
newLISP and the O.S. / mysql5.lsp
May 01, 2008, 02:21:45 PM
Here is a diff for mysql5.lsp to run on amd64/Debian



I think it should go in other 64 bit systems. There is a two places in original file, where sizeof(int)=4 was assumed. They are changed to 8.

Enjoy ;-)


--- /usr/share/newlisp/modules/mysql5.lsp       2008-03-23 02:37:50.000000000 +0300
+++ mysql5-64.lsp       2008-05-02 01:16:28.000000000 +0400
@@ -122,11 +122,12 @@
 ; check endianess of the host CPU
 (set 'big-endian (= (pack ">ld" 1) (pack "ld" 1)))

+(constant 'INT_SIZE 8) ; 4 for 32 bit, 8 for 64 bit
 (constant 'NUM_ROWS_OFFSET (if big-endian 4 0))
-(constant 'NUM_FIELDS_OFFSET 60)
-(constant 'ERROR_OFFSET 85)
-(constant 'INSERT_ID_OFFSET (if big-endian 708 704))
-(constant 'AFFECTED_ROWS_OFFSET (if big-endian 700 696))
+(constant 'NUM_FIELDS_OFFSET 96)
+(constant 'ERROR_OFFSET 141)
+(constant 'INSERT_ID_OFFSET (if big-endian 708 832))
+(constant 'AFFECTED_ROWS_OFFSET (if big-endian 700 824))

 ;; @syntax (MySQL:init)
 ;; @return 'true' on success, 'nil' on failure.
@@ -185,7 +186,7 @@
   ; The field type is the 20th field of the MySQL_FIELD structure
   ; since fields 1-19 are all 4 byte fields we get the enum value
   ; like so
-  (set 'data (get-int (int (+ type_ptr (* 19 4)))))
+  (set 'data (get-int (int (+ type_ptr (* 19 INT_SIZE)))))
   ; Consult 'enum_field_types' in mysql_com.h for values
   (if (= data 1) ;; boolean
         (get-string field_addr)
@@ -215,7 +216,7 @@
     (begin
       (set 'row '())
       (dotimes (field (num-fields))
-            (set 'field_addr (get-int (int (+ rdata (* field 4)))))
+            (set 'field_addr (get-int (int (+ rdata (* field INT_SIZE)))))
             (if (= field_addr 0)
               (push nil row -1) ;; what to do when the field contains NULL
               (push (keep-type MYSQL_RES field_addr field) row -1)))
#17
newLISP newS /
March 21, 2008, 09:29:23 AM
nice :-)
#18
newLISP newS / pop-assoc
March 21, 2008, 08:10:27 AM
Hi, Lutz!



I found a segfault:
dmi@stone:~$ newlisp
newLISP v.9.3.1 on Linux, execute 'newlisp -h' for more info.

> (set 'l '((1 2) (3 4) (5 (6 7))))
((1 2) (3 4) (5 (6 7)))
> (pop-assoc ('l 3))
Segmentation fault


I know that l must not be quoted, but this typo causes failure.



And a question: what for the extra parenthesis are in the syntax?



Oh! and another question:

Is there a non-destructive version for pop-assoc?
#19
newLISP newS /
March 18, 2008, 11:49:33 PM
Subsequental "apt-get update; apt-get source newlisp" in  the same directory will update your sources when the new versio/|patch will appear on the server.



I don't know if there's a separate mechanism in debian to check sources for updates.
#20
newLISP newS /
March 18, 2008, 08:48:41 AM
You can still compile this doing
apt-get source newlisp
cd newlisp-***
dpkg-buildpackage -rfakeroot


This will make your own deb
#21
newLISP newS /
March 18, 2008, 06:33:36 AM
Oh! Nice :-)
#22
newLISP newS / (column num lst)
March 18, 2008, 12:17:23 AM
Hi, All!



Testing with new function:
(define (column n lst)
  (map (fn(x) (x n)) lst))

> (set 'lst '((a 1 q)(b 2 w)(c 3 e)))
((a 1 q) (b 2 w) (c 3 e))
> (column 1 lst)
(1 2 3)
#23
newLISP newS /
March 17, 2008, 11:54:24 PM
Hi, Tim!

Look at http://en.feautec.pp.ru/SiteNews/NewLispDebian/">//http://en.feautec.pp.ru/SiteNews/NewLispDebian/

There is an Ubuntu version and source package which compiles both on Ubuntu and Debian.

I maintaining this stuff.

The debian version is at mentors.debian.net too. But, in fact, I haven't sufficient time at now for pushing it finally into debian unstable :-
#24
newLISP newS /
March 13, 2008, 03:32:20 AM
Version 1.2

Some improvements,code cleanups and fixes.
#25
newLISP newS / update
March 12, 2008, 09:01:13 AM
The timeout is moved from (sleep) to (select), Now in micro-seconds.
#26
newLISP newS / example
March 12, 2008, 07:09:15 AM
A usage example:
    ; use "nc host 8080" to connect, ? to request connections and x to shutdown server
     (define (net-do-test)
      (net-do 8080 nil 1000
      ; accept
      (fn(conn)
        (println "accept: " conn)
        (net-send conn "hello!n"))
      ; receive
      (fn(conn , (buf ""))
        (println "receive: "conn)
        (net-receive conn 'buf 1000)
        (if
          (starts-with buf "?")
          (net-send conn (string net-do:lconn))
          (starts-with buf "x")
          (set 'net-do:exit-cond true))
        (net-send conn "bye!n")
        (net-do:close conn))
      ; cleanout
      (fn(conn) (println "closed: " conn))
      ; cycle
      nil
      ; idle
      (fn()(println "idle: " net-do:lconn))))
#27
newLISP newS /
March 12, 2008, 07:05:58 AM
oh! write-buffer is sufficient! thanks again!
#28
newLISP newS /
March 12, 2008, 07:04:20 AM
Wow! Cool!



BTW, you can set EnFeautec link directly to the module index:



http://en.feautec.pp.ru/store/libs/doc/index.html">//http://en.feautec.pp.ru/store/libs/doc/index.html
#29
newLISP newS / TCP/IP server suite
March 12, 2008, 05:43:43 AM
Recently found that frequently I need a tcp server in newlisp to serve simple data requests.

But net-select etc. is a low-level stuff which needs many workarounds in a real usage.



So, once I'v decide to made a such one. Here is it:

http://en.feautec.pp.ru/store/libs/doc/net-do.lsp.html">//http://en.feautec.pp.ru/store/libs/doc/net-do.lsp.html
#30
newLISP newS /
March 12, 2008, 05:30:05 AM
Thanks.