[Chicken-users] Syslog without format

2011-12-09 Thread Vok Vojwo
The attached patch adds a syslog-str function to the syslog egg. The
function does not use sprintf. It requires an already formated string.
This is useful if one wants to use the fmt egg to format syslog
messages.
--- syslog.orig/syslog.scm	2011-12-09 13:27:31.0 +0100
+++ syslog/syslog.scm	2011-12-09 13:32:16.0 +0100
@@ -57,7 +57,7 @@
 
 
 (module syslog
-  (syslog openlog setlogmask closelog log-up-to log-mask
+  (syslog syslog-str openlog setlogmask closelog log-up-to log-mask
   
prio/info prio/emerg prio/alert prio/crit
prio/err prio/warning prio/notice prio/debug
@@ -175,6 +175,9 @@
   (define (syslog priority fmt . args)
 ((foreign-lambda* void ((int prio) (c-string msg)) "syslog(prio,\"%s\",msg);") priority (apply sprintf fmt args)))
 
+  (define (syslog-str priority str)
+((foreign-lambda* void ((int prio) (c-string msg)) "syslog(prio,\"%s\",msg);") priority str))
+
   (define setlogmask
 (foreign-lambda int "setlogmask" int))
 
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] How to get the kind list of a condition?

2011-12-09 Thread Vok Vojwo
Is there a way to get the kind list of a condition without converting
the whole condition into a list?

This example:

(let* ((fail (lambda () (open-input-file "")))
   (exn (call/cc (lambda (return)
   (with-exception-handler return fail)
  (map car (condition->list exn)))

Generates:

(exn i/o file)

But this converts the whole call-chain into a list, which might be
quite expensive. So the question is, if there is a cheaper way to do
the same.

I found get-condition-property to get properties of a specific kind
but no function which returns the kind list.

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Syslog string protection error

2011-12-08 Thread Vok Vojwo
It is possible to avoid the ident parameter:

(program-name "people-bridge")
(openlog #f opt/pid facility/local0)

But setting the program name does not have any effect on the generated
syslog message:

Dec  8 10:51:53 t4mshpapl104 csi[7448]: Starting program.

It does not have any effect on the process list either:

$ ps -ef|grep people-bridge
ziemann   7448  9311  0 10:51 pts/33   00:00:00 /usr/local/bin/csi -s
./people-bridge.scm

Does it have any effect?

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Syslog string protection error

2011-12-08 Thread Vok Vojwo
The code of the syslog egg uses

syslog(prio,\"%s\",msg);

to send the message. On Linux the above code is about 30% slower than this:

syslog(prio, msg);

Some time ago I did a performance test:
http://superuser.com/questions/305029/why-is-syslog-so-much-slower-than-file-io

And on Linux the manual page for openlog says that the use of openlog
is optional. But when I omit the call to openlog in Scheme nothing
gets send to syslog. I think this difference should be mentioned in
the documentation.

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Syslog string protection error

2011-12-08 Thread Vok Vojwo
I think there seems to be a string protection error in the syslog egg.
The C function openlog requires a const string and relies on the fact
that the string does not change. Normally Scheme strings are moved
around by the garbage collector. This is a problem for openlog. The
result are random strings in the syslog:

Dec  8 09:59:23 t4mshpapl104 people-bridge[6170]: Starting program.
Dec  8 09:59:32 t4mshpapl104  p[6170]: Got new request.
Dec  8 10:00:33 t4mshpapl104 [6185]: Starting program.
Dec  8 10:00:36 t4mshpapl104 [6185]: Got new request.
Dec  8 10:00:36 t4mshpapl104 p���  [6185]: Searching for:%s

I had the same problem with Gambit:
https://mercure.iro.umontreal.ca/pipermail/gambit-list/2011-November/005505.html

I solved it with strdup:
http://code.google.com/p/gs-syslog/source/browse/syslog.scm#56

Tested with:
$ chicken-status -v
4.7.0
$ chicken-status syslog
syslog .. version: 1.1

Tested on:
$ cat /etc/redhat-release
Red Hat Enterprise Linux Client release 5.5 (Tikanga)
$ uname -s -r -v -m -p -i -o
Linux 2.6.18-194.8.1.el5PAE #1 SMP Wed Jun 23 11:16:22 EDT 2010 i686
i686 i386 GNU/Linux

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] unbound variable: sxml:sxml->xml

2011-12-07 Thread Vok Vojwo
2011/12/7 Jim Ursetto :
>
> Other ways were to regularize and improve some of the identifier names, make 
> things more idiomatic, and in sxml-serializer's case, add some feature 
> enhancements.

Where is the improvement? Writing sxml-serializer instead of
srl:sxml->xml does not make much difference. It is even less idiomatic
because the inverse function is still called sxml:xml->sxml. And
renaming it makes the code incompatible to the original code. I can
not see any win. It is definitely a loss.

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] unbound variable: sxml:sxml->xml

2011-12-07 Thread Vok Vojwo
2011/12/7 Peter Bex :
>
> Actually, the main reason is that SSAX is a horrible mess which has
> many completely unrelated procedures all mixed together.
> There are several egg that provide different sets of procedures
> from the SSAX project.  Most eggs include all files from the SSAX
> project to make it easy to update them, but they don't install them
> all.
>
> The proper place to do this is in the sxml-serializer egg, and
> we definitely should *not* be adding random procedures to sxpath.
>
> (the *REALLY* proper way would be to drop SSAX and create a sane
> and consistent XML library from scratch, maybe reusing some algorithms
> from SSAX, but that's a whole other story...)

I can not see any reason why it should be necessary to split the Oleg
code. Someone who needs sxpath also needs sxml. Splitting the code
into different Chicken modules is pretty useless.

I would like if Olegs SSAX code stays together in one big module. This
is the easiest way to do it.

And if you like to write Olegs code once again from scratch in Chicken
modules it can be done.

But the current situation where people try to split something which is
not well suited to be split is not perfect.

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] unbound variable: sxml:sxml->xml

2011-12-07 Thread Vok Vojwo
2011/12/7 Vok Vojwo :
>
> I was looking for the srl:sxml->xml function:
> http://modis.ispras.ru/Lizorkin/Apidoc/index.html#docfunc15826
>

I got it. I had to include "sxml-tools/serializer.scm" in
sxpath-lolevel.scm. After that it is possible to export srl:sxml->xml.
And it seems to work:

(display (srl:sxml->xml
  '(*TOP*
(*PI* xml "version='1.0' encoding='UTF-8'")
(error
 (code "-12")
 (message "No person found!")

Generates:



  -12
  No person found!


Why is it not included if it is there?

Or why is there an sxml-serializer egg if the code is already part of
the SSAX libs, which is part of the sxpath egg?

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] unbound variable: sxml:sxml->xml

2011-12-07 Thread Vok Vojwo
2011/12/7 Peter Bex :
>
> Try this instead:
>
> csi -R sxpath-lolevel -e "(print (sxml:sxml->xml '()))"
>

Thanks. This works but not as expected ;-)

I was looking for the srl:sxml->xml function:
http://modis.ispras.ru/Lizorkin/Apidoc/index.html#docfunc15826

Is it also available?

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] unbound variable: sxml:sxml->xml

2011-12-07 Thread Vok Vojwo
The documentation of the sxpath egg describes the sxml:sxml->xml
function. But when I try to call it, I get an error:

csi -R sxpath -e "(display (sxml:sxml->xml '()))"

Error: unbound variable: sxml:sxml->xml

Call history:

sxml-tools/xpath-parser.scm:1354: txp:param-value
sxml-tools/xpath-parser.scm:1399: txp:param-value
sxml-tools/xpath-parser.scm:1491: txp:param-value
sxml-tools/xpath-parser.scm:1492: txp:param-value
sxml-tools/xpath-parser.scm:1494: txp:param-value
sxml-tools/txpath.scm:1049: sxml:api-helper
sxml-tools/txpath.scm:1051: sxml:api-helper
sxml-tools/txpath.scm:1053: sxml:api-helper
sxml-tools/txpath.scm:1102: sxml:api-index-helper
sxml-tools/txpath.scm:1104: sxml:api-index-helper
  (display (sxml:sxml->xml (quote (
  (sxml:sxml->xml (quote ()))
  (quote ())
  (##core#quote ())
(display (sxml:sxml->xml (quote (
(sxml:sxml->xml (quote ()))   <--

$ chicken-status -v sxpath
4.7.0
$ chicken-status sxpath
sxpath  version: 0.1.3

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Spiffy SSL Connection handshake error

2011-12-05 Thread Vok Vojwo
I got the following error while trying to use Spiffy with SSL:

primordial: Connection handshake error: "argument is not a port"

This is my simple test program:

#! /usr/local/bin/csi -s

(use spiffy openssl)

(server-port 8000)
(access-log (current-error-port))
(debug-log (current-error-port))

(let ((listener (ssl-listen (server-port
  (ssl-load-certificate-chain! listener "server.crt")
  (ssl-load-private-key! listener "server.key")
  (accept-loop listener ssl-accept))

#|
(let ((listener (tcp-listen (server-port
  (accept-loop listener tcp-accept))
|#

The TCP version works fine. I created the key and certificates with
the following Makefile:

all: server.key server.crt

clean:
-rm server.key server.csr server.crt

server.key:
openssl genrsa -out $@ 1024

server.csr: server.key
openssl req -new -batch \
-key $< -out $@ \
-subj /CN=`hostname -f`

server.crt: server.csr server.key
openssl x509 -req -days 365 \
-in $(filter %.csr,$^) \
-signkey $(filter %.key,$^) \
-out $@

Does anybody know who generates the error message? It does not seem to
be an exception. I have no idea where I should look for the error.

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Sendfile error on Red Hat 5.5 64 Bit

2011-12-01 Thread Vok Vojwo
2011/12/1 David Krentzlin :
>
> i think i might have found the culprit. Do you mind trying current tip from
> https://bitbucket.org/certainty/sendfile ?

Same error:

sendfile.c: In function `stub205':
sendfile.c:78: error: `POSIX_FADV_SEQUENTIAL' undeclared (first use in
this function)

But I found a difference between my 32 Bit and 64 Bit system. On the
32 Bit system I have two definitions:

$ find /usr/include/ -type f | xargs grep POSIX_FADV_SEQUENTIAL
/usr/include/linux/fadvise.h:#define POSIX_FADV_SEQUENTIAL  2 /*
Expect sequential page references.  */
/usr/include/bits/fcntl.h:# define POSIX_FADV_SEQUENTIAL2 /*
Expect sequential page references.  */

And on the 64 Bit system I have only one:

# find /usr/include/ -type f | xargs grep POSIX_FADV_SEQUENTIAL
/usr/include/bits/fcntl.h:# define POSIX_FADV_SEQUENTIAL2 /*
Expect sequential page references.  */

The file is part of the kernel headers:
$ rpm -qf /usr/include/linux/fadvise.h
kernel-headers-2.6.18-194.8.1.el5

And the kernel-headers are not installed on the 64 Bit system.

But the main problem seems to me that the probe works and the
compilation does not. So the probe includes something different than
the compilation. I did not try if the installation of the kernel
headers fixes the problem, because right now I do not know if I am
allowed to do it on the production system. But the difference between
the probe and the compilation is still a bug I think.

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Sendfile error on Red Hat 5.5 64 Bit

2011-12-01 Thread Vok Vojwo
2011/12/1 David Krentzlin :
>
> As a quick fix you can adjust the sendfile.setup to include the features
> that are present.
>
> Something like:
> (compile -s -O2 -d0 -D sendfile -D mmap -D madvise sendfile.scm -j sendfile)
>
> instead of:
> (compile -s -O2 -d0 ,@features sendfile.scm -j sendfile)
>

I did already something similar by removing the two lines:

;;  (when posix-fadvise?
;;(set! features (cons '-D (cons 'posix-fadvise features

from sendfile.setup which has the same effect I think.

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] chicken-install and proxy authentication

2011-11-30 Thread Vok Vojwo
I have still this problem although the authentication with Wget, Curl
and Firefox works fine. I think this must be a bug in chicken-install
or the underlying HTTP module.

As a workaround I did some reverse engineering and wrote a simple Bash
script to fetch an egg. It is attached.


2011/11/25 Vok Vojwo :
> I get an error during the proxy authentication of chicken-install:
>
> $ chicken-install -debug -n -proxy host:port -username me -password
> mypw http-client
> retrieving ...
> resolving alias `kitten-technologies' to:
> http://chicken.kitten-technologies.co.uk/henrietta.cgi
> connecting to host "chicken.kitten-technologies.co.uk", port 80 (via
> host:port) ...
> requesting "/henrietta.cgi?name=http-client&mode=default" ...
> reading response ...
> HTTP/1.0 407 Proxy Authentication Required
> HTTP/1.0 407 Proxy Authentication Required
> Proxy-Authenticate: BASIC realm="realm"
> Cache-Control: no-cache
> Pragma: no-cache
> Content-Type: text/html; charset=utf-8
> Set-Cookie: BCSI-CS-CEF7AF6AE527BB7D=2; Path=/
> Content-Length: 4209
> X-Cache: MISS from host
> Proxy-Connection: close
> reading files ...
>
>
> Error: invalid file name - possibly corrupt transmission: 
>
> I tried to use the -debug option but it does not offer additional
> information. How can I find out whats going wrong here?
>


chicken-retrieve.sh
Description: Bourne shell script
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Sendfile error on Red Hat 5.5 64 Bit

2011-11-30 Thread Vok Vojwo
I was able to compile sendfile on Red Hat 5.5 32 Bit but it fails on
64 Bit with the following error:

# chicken-install -t local -l . sendfile
retrieving ...
 deleting stale file `sendfile.import.so' from local build directory
 deleting stale file `sendfile.so' from local build directory
 sendfile located at /tmp/./sendfile
checking platform for `sendfile' ...
checking dependencies for `sendfile' ...
install order:
("sendfile")
installing sendfile: ...
changing current directory to /tmp/./sendfile
  /usr/local/bin/csi -bnq -setup-mode -e "(require-library setup-api)"
-e "(import setup-api)" -e "(setup-error-handling)" -e
"(extension-name-and-version '(\"sendfile\" \"\"))"
/tmp/sendfile/sendfile.setup
  /usr/local/bin/csc -feature compiling-extension -setup-mode-s
-O2 -d0 -D sendfile -D mmap -D posix-fadvise -D madvise sendfile.scm
-j sendfile
sendfile.c: In function `stub205':
sendfile.c:77: error: `POSIX_FADV_SEQUENTIAL' undeclared (first use in
this function)
sendfile.c:77: error: (Each undeclared identifier is reported only once
sendfile.c:77: error: for each function it appears in.)
sendfile.c:77: error: `POSIX_FADV_NOREUSE' undeclared (first use in
this function)

Error: shell command terminated with non-zero exit status 256: gcc
sendfile.c -o sendfile.o -c  -fno-strict-aliasing -fwrapv
-DHAVE_CHICKEN_CONFIG_H -DC_ENABLE_PTABLES -Os -fomit-frame-pointer
-fPIC -DPIC -DC_SHARED -I"/usr/local/include/chicken"

Error: shell command failed with nonzero exit status 256:

  /usr/local/bin/csc -feature compiling-extension -setup-mode-s
-O2 -d0 -D sendfile -D mmap -D posix-fadvise -D madvise sendfile.scm
-j sendfile


Error: shell command terminated with nonzero exit code
17920
"/usr/local/bin/csi -bnq -setup-mode -e \"(require-library
setup-api)\" -e \"(im...

Any idea what is going wrong there?

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] json-abnf fails to parse booleans

2011-11-28 Thread Vok Vojwo
2011/11/28 Ivan Raikov :
>
> - due to a limitation in abnf/lexgen-derived parsers, #f cannot be a
>  value returned by a parser. So the JSON true and false values are
>  represented by '(#t) and '(#f).
>

Can you explain this? I tried my patch with some booleans and it seems to work:

(pp (parse-json
"{\"pi\":3.14,\"f\":false,\"t\":true,\"n\":null,\"l\":[1,2],\"s\":\"\"}"))
;; => (("pi" . 3.14) ("f" . #f) ("t" . #t) ("n" . null) ("l" . #(1 2))
("s" . ""))

(pp (parse-json "[true]"))
;; => #(#t)

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] json-abnf fails to parse booleans

2011-11-27 Thread Vok Vojwo
2011/11/27 Vok Vojwo :
> The json-abnf module creates some strange results for booleans:
>
> (use json-abnf)
> (pp (parser "{\"str\":\"a\",\"true\":true,\"false\":false}"))
>
> prints:
>
> (object ("str" "a") ("true" (#t)) ("false"))
>
> true is a list and false is '().
>

I think the attached patch fixes the problem.

It does some additional changes:

- parser renamed to parse-json
- object tagging removed
- key value pairs stored as pairs instead of lists
- null as symbol null instead of empty list

I think it is now compatible to Medea.
--- json-abnf.orig/json-abnf.scm	2011-11-27 21:14:06.0 +0100
+++ json-abnf/json-abnf.scm	2011-11-27 22:25:51.0 +0100
@@ -26,7 +26,7 @@
 
 (module json-abnf
 
-	(parser)
+	(parse-json)
 
 	(import scheme chicken data-structures srfi-1 srfi-14)
 
@@ -35,7 +35,6 @@
 		(prefix abnf-consumers abnf:) 
 		)
 
-
 ;; helper macro for mutually-recursive parser definitions
 
 (define-syntax vac
@@ -53,7 +52,6 @@
 ((_ p)(abnf:bind consumed-chars->number p))
 ))
 
-
 (define escaped-char->control-char
   (abnf:consumed-chars->list 
(lambda (x) 
@@ -64,27 +62,24 @@
((#\r)#\return )
((#\t)#\tab )
(else (car x))
-			  
 
 (define-syntax bind-consumed->control-char
   (syntax-rules () 
 ((_ p)(abnf:bind escaped-char->control-char p))
 ))
 
-
 (define consumed-chars->char-code
   (abnf:consumed-chars->list 
(compose (lambda (x) (integer->char (string->number x 16)))
 	list->string)))
 
-
 (define-syntax bind-consumed->char-code
   (syntax-rules () 
 ((_ p)(abnf:bind consumed-chars->char-code p))
 ))
 
 (define (value?  x)(or (string? x) (number? x) (boolean? x)
-			   (vector? x) (list? x)))
+			   (vector? x) (pair? x) (symbol? x)))
 
 (define consumed-values (abnf:consumed-objects value?))
 (define consumed-values->list
@@ -97,6 +92,16 @@
 ((_ p)  (abnf:bind (consumed-values->list)p))
 ))
 
+(define consumed-values->pair
+  ((abnf:consumed-objects-lift consumed-values)
+   (lambda (l)
+ (cons (car l) (cadr l)
+
+(define-syntax bind-consumed-values->pair
+  (syntax-rules () 
+((_ p)  (abnf:bind consumed-values->pairp))
+))
+
 ;; construct vectors from consumed values
 (define consumed-values->vector 
   ((abnf:consumed-objects-lift consumed-values)
@@ -125,21 +130,21 @@
(abnf:alternatives 
 false null true number p-string object array)))
 
+(define true
+  (abnf:bind
+   (lambda x (list #t))
+   (abnf:lit "true")))
+
 (define false
   (abnf:bind
-   (abnf:consumed-chars->list (lambda x #f))
+   (lambda x (list #f))
(abnf:lit "false")))
 
 (define null
   (abnf:bind
-   (abnf:consumed-chars->list (lambda x '()))
+   (lambda x (list 'null))
(abnf:lit "null")))
 
-(define true
-  (abnf:bind
-   (abnf:consumed-chars->list (lambda x (list #t)))
-   (abnf:lit "true")))
-
 (define escaped 
   (abnf:concatenation
(abnf:drop-consumed (abnf:char #\\))
@@ -151,7 +156,6 @@
  (bind-consumed->char-code
   (abnf:repetition-n 4 abnf:hexadecimal)))
 )))
-
  
 (define char
   (abnf:alternatives
@@ -162,8 +166,6 @@
   (ucs-range->char-set #x5D #x10)))
escaped))
 
-
-
 (define p-string
   (abnf:alternatives
(abnf:bind-consumed->string
@@ -173,8 +175,6 @@
  (abnf:drop-consumed (abnf:char #\"
(abnf:bind (lambda (x) (list ""))  (abnf:concatenation (abnf:char #\") (abnf:char #\")))
))
-   
-
 
 (define number
   (let* ((digit(abnf:range #\0 #\9))
@@ -201,18 +201,16 @@
significand
(abnf:optional-sequence exp))
 
-
 (define p-member 
-  (bind-consumed-values->list
+  (bind-consumed-values->pair
(abnf:concatenation
 p-string
 name-separator 
 value
 )))
 
-
 (define object
-  (bind-consumed-values->list 'object
+  (bind-consumed-values->list 
 (abnf:concatenation
  (abnf:drop-consumed begin-object)
  (abnf:optional-sequence
@@ -224,7 +222,6 @@
 	 p-member
  (abnf:drop-consumed end-object
 
-
 (define array
   (bind-consumed-values->vector
(abnf:concatenation
@@ -238,23 +235,18 @@
 	value ) )))
 (abnf:drop-consumed end-array
 
-
-
 (define JSON-text
   (abnf:alternatives object array))
 
-
 (define (->char-list s)
   (if (string? s) (string->list s) s))
 
-
 (define (err s)
   (print "JSON parser error on stream: " s)
   `(error))
 
-
-(define parser
+(define parse-json
   (lambda (s)
 (JSON-text caar err `(() ,(->char-list s)
 
-)
\ Kein Zeilenumbruch am Dateiende.
+)
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] json-abnf fails to parse booleans

2011-11-27 Thread Vok Vojwo
The json-abnf module creates some strange results for booleans:

(use json-abnf)
(pp (parser "{\"str\":\"a\",\"true\":true,\"false\":false}"))

prints:

(object ("str" "a") ("true" (#t)) ("false"))

true is a list and false is '().

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Why does the JSON egg map JSON structs to Scheme vectors instead of alists?

2011-11-27 Thread Vok Vojwo
2011/11/27 Moritz Heidkamp :
>
> You may be interested in two alternative JSON eggs, namely json-abnf egg
> (GPLed) which represents both JSON objects as tagged lists alists
> (i.e. they have a symbol `object' their car) and arrays as vectors or
> the medea egg (BSD licensed) which uses alists for objects and vectors
> for arrays by default but can be parameterized to use whatever
> representation you prefer.

I think the Medea egg intends to do it the right way. But it seems to be buggy.

And it has a voracious appetite

; loading /usr/local/lib/chicken/6/chicken.import.so ...
; loading /usr/local/lib/chicken/6/data-structures.import.so ...
; loading /usr/local/lib/chicken/6/defstruct.so ...
; loading /usr/local/lib/chicken/6/extras.import.so ...
; loading /usr/local/lib/chicken/6/genturfahi.import.so ...
; loading /usr/local/lib/chicken/6/genturfahi-peg.so ...
; loading /usr/local/lib/chicken/6/genturfahi.so ...
; loading /usr/local/lib/chicken/6/irregex.import.so ...
; loading /usr/local/lib/chicken/6/iset.import.so ...
; loading /usr/local/lib/chicken/6/iset.so ...
; loading /usr/local/lib/chicken/6/lolevel.import.so ...
; loading /usr/local/lib/chicken/6/matchable.import.so ...
; loading /usr/local/lib/chicken/6/matchable.so ...
; loading /usr/local/lib/chicken/6/medea.import.so ...
; loading /usr/local/lib/chicken/6/medea.so ...
; loading /usr/local/lib/chicken/6/ports.import.so ...
; loading /usr/local/lib/chicken/6/posix.import.so ...
; loading /usr/local/lib/chicken/6/regex.import.so ...
; loading /usr/local/lib/chicken/6/regex.so ...
; loading /usr/local/lib/chicken/6/sandbox.so ...
; loading /usr/local/lib/chicken/6/scheme.import.so ...
; loading /usr/local/lib/chicken/6/srfi-13.import.so ...
; loading /usr/local/lib/chicken/6/srfi-14.import.so ...
; loading /usr/local/lib/chicken/6/srfi-18.import.so ...
; loading /usr/local/lib/chicken/6/srfi-1.import.so ...
; loading /usr/local/lib/chicken/6/srfi-4.import.so ...
; loading /usr/local/lib/chicken/6/srfi-69.import.so ...
; loading /usr/local/lib/chicken/6/unicode-char-sets.import.so ...
; loading /usr/local/lib/chicken/6/unicode-char-sets.so ...
; loading /usr/local/lib/chicken/6/utf8-case-map.import.so ...
; loading /usr/local/lib/chicken/6/utf8-case-map.so ...
; loading /usr/local/lib/chicken/6/utf8.import.so ...
; loading /usr/local/lib/chicken/6/utf8-lolevel.import.so ...
; loading /usr/local/lib/chicken/6/utf8-lolevel.so ...
; loading /usr/local/lib/chicken/6/utf8.so ...
; loading /usr/local/lib/chicken/6/utf8-srfi-13.import.so ...
; loading /usr/local/lib/chicken/6/utf8-srfi-13.so ...
; loading /usr/local/lib/chicken/6/utf8-srfi-14.import.so ...
; loading /usr/local/lib/chicken/6/utf8-srfi-14.so ...
; loading /usr/local/lib/chicken/6/vector-lib.import.so ...
; loading /usr/local/lib/chicken/6/vector-lib.so ...

compared to the Json egg:

; loading /usr/local/lib/chicken/6/json.import.so ...
; loading /usr/local/lib/chicken/6/scheme.import.so ...
; loading /usr/local/lib/chicken/6/chicken.import.so ...
; loading /usr/local/lib/chicken/6/ports.import.so ...
; loading /usr/local/lib/chicken/6/srfi-1.import.so ...
; loading /usr/local/lib/chicken/6/srfi-69.import.so ...
; loading /usr/local/lib/chicken/6/packrat.import.so ...
; loading /usr/local/lib/chicken/6/json.so ...
; loading /usr/local/lib/chicken/6/packrat.so ...

I am testing with Googles developer calendar:

(use http-client)
(define json
  (with-input-from-request
   
"http://www.google.com/calendar/feeds/developer-calen...@google.com/public/full?alt=json";
   #f read-string))

Medea fails to parse the data:

(use medea)
(read-json json) ;; => #f

Json works but it is quite slow:

(use json)
(time (begin (json-read (open-input-string json)) (if #f #f)))

0.228s CPU time, 0.12s GC time (major), 135063 mutations, 6/1835 GCs
(major/minor)
0.236s CPU time, 0.128s GC time (major), 135045 mutations, 6/1835 GCs
(major/minor)

compared to Json-abnf:

(use json-abnf)
(time (begin (parser json) (if #f #f)))

0.04s CPU time, 2380 mutations, 0/782 GCs (major/minor)
0.04s CPU time, 2398 mutations, 0/782 GCs (major/minor)

I am completely astonished that the performance difference is more
than 500%. Is this the typical packrat memorization penalty?

So in the end I have

- Medea which has the most useful data representation but does not work.
- Json which need the fewest number of modules, but which is slow and
produces strange pairs of vectors.
- Json-abnf which is the fastest but produces annoying object tags and
can not read from ports.

If it is possible to get rid of the object tags Json-abnf seems to be
the best choice right now.

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Why does the JSON egg map JSON structs to Scheme vectors instead of alists?

2011-11-27 Thread Vok Vojwo
2011/11/27 Christian Kellermann :
>
> My guess is that it makes it possible to write back to json, since
> alists are already used for representing a different datatype.

But json-write does not accept alists as values. This

(json-write (vector (cons "x" (list (cons "a" 1) (cons "b" 2)

throws the following error:

Error: Invalid JSON object in json-write: ("a" . 1)

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Why does the JSON egg map JSON structs to Scheme vectors instead of alists?

2011-11-27 Thread Vok Vojwo
I am a bit confused by the way the JSON egg maps JSON structures to
Scheme values. The JSON egg maps a structure to a vector:

(use json)
(with-input-from-string "{\"pi\":3.14,\"e\":2.71}" json-read)
;; => #(("pi" . 3.14) ("e" . 2.71))

This makes it impossible to use the standard Scheme function assoc to
read the data.

The following functions fix the problem:

(define (json->alist arg)
  (cond
   ((vector? arg)
(map (lambda (pair)
   (cons (car pair) (json->alist (cdr pair
 (vector->list arg)))
   ((list? arg)
(list->vector (map json->alist arg)))
   (else arg)))

(define (alist->json arg)
  (cond
   ((list? arg)
(list->vector (map (lambda (pair)
 (cons (car pair) (alist->json (cdr pair
   arg)))
   ((vector? arg)
(map alist->json (vector->list arg)))
   (else arg)))

A small verification test:

(use http-client)

(define (with-input-from-url url chunk)
  (with-input-from-request url #f chunk))

(define json
  (with-input-from-url
   
"http://www.google.com/calendar/feeds/developer-calen...@google.com/public/full?alt=json";
   json-read))

(equal? json (alist->json (json->alist json)))
;; => #t

By using alists it is possible to use assoc to access the data:

(define (assoc* alist . path)
  (let assoc* ((path path)
   (alist alist))
(if (null? path)
alist
(assoc* (cdr path)
(cdr (assoc (car path) alist))

(assoc* (json->alist json) "feed" "title" "$t")
;; => "Official Google External Developer Events"

Is there any reason why the JSON egg creates vectors of pairs?

If not I would suggest to fix it to make it more schemish.

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] How to deploy http-client?

2011-11-25 Thread Vok Vojwo
I tried to deploy an application which uses http-client, but I get the
following error:

./client: symbol lookup error: /home/.../client/http-client.so:
undefined symbol: C_srfi_2d1_toplevel

What I did so far:

I wrote a simple test program client.scm:

(use http-client)
(pp (with-input-from-request "http://www.google.com/"; #f read-string))

The program works fine, if I run it with: csi -s client.scm

After that I deployed it using the following command:

  $ csc -deploy client.scm

This creates the client directory with the binary and the chicken shared lib.

After that I tied to deploy http-client with all dependencies. For
that I wrote a simple script called chicken-deps to handle the
dependencies:

#! /usr/local/bin/csi -ss

(use irregex)

(define (chicken-deps egg thunk)
  (let incubate ((egg egg))
(thunk egg)
(letrec ((metafile (string-append egg "/" egg ".meta"))
 (metadata (read (open-input-file metafile
  (for-each
   (lambda (deps)
 (if deps
 (for-each
  incubate
  (map symbol->string
   (map (lambda (egg)
  (if (pair? egg) (car egg) egg))
(cdr deps))
   (list (assoc 'depends metadata)
 (assoc 'needs metadata))

(define (main args)
  (let ((cmd (car args))
(egg (cadr args)))
(chicken-deps
 egg
 (lambda (egg)
   (system (irregex-replace/all "{}" cmd egg))

I used this script to retrieve all eggs necessary for http-client by
this command:

  $ chicken-deps 'chicken-install -r {}' http-client

This results in a download of 20 eggs:

base64
check-errors
defstruct
http-client
intarweb
lookup-table
matchable
md5
message-digest
miscmacros
openssl
record-variants
regex
sendfile
setup-helper
string-utils
synch
uri-common
uri-generic
variable-item

I already installed the eggs in my development repository for csi.

Now I deployed all modules in my client directory with the command:

  $ chicken-install -deploy -p /.../client -t local -l . $egg

After that I have 102 files in the client directory. 60 of them are
shared libs. And when I try to run the client:

  $ ./client

I get the undefined symbol error. So my question:

  What did I wrong? Is it a bug?

I did all the above with 4.7.0 on Red Hat EL 5. I had to specify
ARCH=x86 option during make. Without the option I got an apply-hack
error. GCC is 4.1.2:

Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada
--enable-java-awt=gtk --disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
--with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] chicken-install: how to retrieve with dependencies

2011-11-25 Thread Vok Vojwo
2011/11/25 Mario Domenech Goulart :
>
> It's far from being a definitive solution, but you can find a quick hack
> here: http://parenteses.org/mario/misc/fetch-eggs.scm
>
> Just call it like:
>
>   $ csi -s fetch-eggs.scm egg1 egg2 ...
>

Thanks! I did already something similar:

(define (main args)
  (let ((egg (car args)))
(system (string-append "chicken-install -r " egg))
(letrec ((meta (string-append egg "/" egg ".meta"))
 (deps (assoc 'depends (read (open-input-file meta)
  (if deps
  (let ((eggs (map (lambda (egg) (if (pair? egg) (car egg) egg))
   (cdr deps
(for-each
 (lambda (egg)
   (main (list egg)))
 (map symbol->string eggs)))

But it would be nice if chicken-install can do this out of the box.

It would also be nice if the functionality of chicken-install is part
of some module to avoid the "system" calls.

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] chicken-install: how to retrieve with dependencies

2011-11-25 Thread Vok Vojwo
How can I retrieve an egg with all dependencies? I have the problem,
that I have to retrieve the eggs on system1 in order to build them on
system2.

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] chicken-install and proxy authentication

2011-11-25 Thread Vok Vojwo
I get an error during the proxy authentication of chicken-install:

$ chicken-install -debug -n -proxy host:port -username me -password
mypw http-client
retrieving ...
resolving alias `kitten-technologies' to:
http://chicken.kitten-technologies.co.uk/henrietta.cgi
connecting to host "chicken.kitten-technologies.co.uk", port 80 (via
host:port) ...
requesting "/henrietta.cgi?name=http-client&mode=default" ...
reading response ...
HTTP/1.0 407 Proxy Authentication Required
HTTP/1.0 407 Proxy Authentication Required
Proxy-Authenticate: BASIC realm="realm"
Cache-Control: no-cache
Pragma: no-cache
Content-Type: text/html; charset=utf-8
Set-Cookie: BCSI-CS-CEF7AF6AE527BB7D=2; Path=/
Content-Length: 4209
X-Cache: MISS from host
Proxy-Connection: close
reading files ...


Error: invalid file name - possibly corrupt transmission: 

I tried to use the -debug option but it does not offer additional
information. How can I find out whats going wrong here?

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users