Re: [Chicken-users] [EMAIL PROTECTED]: hygienic chicken: define-extension not working...]
hi, On Wed, Jul 30, 2008 at 11:24:27PM +0200, felix winkelmann wrote: > I added an `(export EXPORT ...)' macro. Note that the export > *must* textually precede the use/definition of the exported > binding. Great! Thank you! bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] import libraries
hi, On Sat, Jul 26, 2008 at 10:21:29PM +0200, felix winkelmann wrote: > On Fri, Jul 25, 2008 at 5:33 PM, Hans Bulfone <[EMAIL PROTECTED]> wrote: > > hi, > > > > i don't understand import libraries fully. is it useful to generate > > one if a module doesn't export syntax? > > The import library contains the compile-time information > and registers the module. The advantage is that this > registration code is pointless at runtime (unless you run > a REPL) and that it supports situation where the system > on which you compile is different from the system on where > your code runs (i.e. cross-compilation). so, if one wants to make an egg that is also statically linkable, one should still just compile the import lib to an .so (with the host compiler) as it is only used at compile-time and is not useful as .o ? > > doesn't that cause superfluous bindings to be imported into the > > toplevel when the import library is loaded? > > (especially when it's loaded manually, like described in the Modules > > and macros manual chapter) > > Yeah, that is sort of a hack. The point of it is to pull in any > syntax-definitions > that might be re-exported. The import-library is usually loaded via `import', > that is, under control of the macro-expander. I'm currently not totally sure > whether this is the right way, but as long as it works, I wouldn't worry. so the bindings are only imported into toplevel (and normally only at compile-time), not in another module i might be defining, which happens to import the mpd-client module, right? tnx&bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] [EMAIL PROTECTED]: hygienic chicken: define-extension not working...]
hi, On Sat, Jul 26, 2008 at 10:13:11PM +0200, felix winkelmann wrote: > Hi, Hans! > > `define-extension' is not available in the hygienic chicken (the > NEWS file is incorrect). I was never happy with that macro and > with the modules, the need for it isn't really there any more. didn't read the NEWS file, i just thought it was supposed to work because the error was 'during expansion of define-extension'... so far, using the new hygienic chicken has been a pleasure! i'm probably going to upload my first "hygienic egg" later today. i don't think i'll be using the old chicken again for anything new... just porting the directfb egg might be a bit of work... would it be possible to add a way to augment the set of exported bindings from inside a module (or more specifically, in a macro that is used in the module). like i could define a macro that expands to (define (some-computed-name ...) ...) (declare (export some-computed-name)) in the old chicken. that would save a lot of typing with those numerous directfb structure-accessors. anyway, i think the new hygienic version is a great step in the development of chicken - thanks, felix, for making it happen! bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] import libraries
hi, i don't understand import libraries fully. is it useful to generate one if a module doesn't export syntax? also, when i generate one for my mpd-client module, it starts with (eval '(import scheme (only chicken ...) ...)) which is the import declaration of my module. doesn't that cause superfluous bindings to be imported into the toplevel when the import library is loaded? (especially when it's loaded manually, like described in the Modules and macros manual chapter) bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] [EMAIL PROTECTED]: hygienic chicken: define-extension not working...]
hi, next time i'll use the traditional method again and just post to chicken-users :) bye, hans. - Forwarded message from [EMAIL PROTECTED] - You are not allowed to post to this mailing list, and your message has been automatically rejected. If you think that your messages are being rejected in error, contact the mailing list owner at [EMAIL PROTECTED] From: Hans Bulfone <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: hygienic chicken: define-extension not working... Date: Fri, 25 Jul 2008 16:52:59 +0200 User-Agent: Mutt/1.5.16 (2007-06-09) hi, ... and chicken-bug could not send the message: 451-You don't seem to have a reverse dns entry. You're greylisted for 20 451-minutes. Come back later. See http://www.fsf.org/about/systems/greylisting 451 for more information. perhaps chicken-bug should optionally also try a local mta. that would have worked in my case. File added: bug.txt hi, define-extension doesn't work with hygienic chicken, i get: $ /opt/hygienic-chicken/bin/csc -s mpd-client.scm Error: during expansion of (define-extension ...) - unbound variable: name Call history: (begin2 (define-extension mpd-client)) (define-extension mpd-client) <-- *** Shell command terminated with exit status 1: /opt/hygienic-chicken/bin/chicken mpd-client.scm -output-file mpd-client.c -dynamic -feature chicken-compile-shared -quiet $ tnx&bye, [EMAIL PROTECTED] -- This is a bug report generated by chicken-bug(1). Date: Fri Jul 25 16:33:57 2008 User information: ("jsb" "x" 1001 1001 "Hans Bulfone" "/home/jsb" "/bin/bash") Host information: machine type: x86-64 software type: unix software version: linux build platform: gnu CHICKEN version is: Version 4.0.0x - linux-unix-gnu-x86-64 [ 64bit manyargs ptables applyhook ] SVN rev. 11424 compiled 2008-07-25 on cartman (Linux) Home directory: /opt/hygienic-chicken/share/chicken Include path: ("/opt/hygienic-chicken/share/chicken") Features: applyhook chicken data-structures extras gnu hygienic-macros linux little-endian manyargspcre ports posix ptables regex srfi-0 srfi-10 srfi-12 srfi-13 srfi-14 srfi-17 srfi-2 srfi-23 srfi-28 srfi-30 srfi-39 srfi-55 srfi-6 srfi-61 srfi-62 srfi-69 srfi-8 srfi-9 syntax-rulestcp unix utils x86-64 chicken-config.h: #define HAVE_DIRENT_H 1 #define HAVE_DLFCN_H 1 #define HAVE_INTTYPES_H 1 #define HAVE_LIMITS_H 1 #define HAVE_LONG_LONG 1 #define HAVE_MEMMOVE 1 #define HAVE_MEMORY_H 1 #define HAVE_STDINT_H 1 #define HAVE_STDLIB_H 1 #define HAVE_STRERROR 1 #define HAVE_STRINGS_H 1 #define HAVE_STRING_H 1 #define HAVE_STRTOLL 1 #define HAVE_STRTOQ 1 #define HAVE_SYS_STAT_H 1 #define HAVE_SYS_TYPES_H 1 #define HAVE_UNISTD_H 1 #define HAVE_UNSIGNED_LONG_LONG 1 #define STDC_HEADERS 1 #define HAVE_ALLOCA 1 #define HAVE_ALLOCA_H 1 #define HAVE_GRP_H 1 #define HAVE_ERRNO_H 1 #define HAVE_GCVT 1 #define HAVE_SYSEXITS_H 1 #define HAVE_MEMMOVE 1 #define C_STACK_GROWS_DOWNWARD 1 #define C_HACKED_APPLY /* generated */ #define C_BUILD_TAG "compiled 2008-07-25 on cartman (Linux)" #define C_SVN_REVISION 11424 #ifndef C_INSTALL_CC # define C_INSTALL_CC "gcc" #endif #ifndef C_INSTALL_CXX # define C_INSTALL_CXX "g++" #endif #ifndef C_INSTALL_CFLAGS # define C_INSTALL_CFLAGS "-fno-strict-aliasing -DHAVE_CHICKEN_CONFIG_H -Os -fomit-frame-pointer" #endif #ifndef C_INSTALL_LDFLAGS # define C_INSTALL_LDFLAGS " " #endif #ifndef C_INSTALL_SHARE_HOME # define C_INSTALL_SHARE_HOME "/opt/hygienic-chicken/share/chicken" #endif #ifndef C_INSTALL_BIN_HOME # define C_INSTALL_BIN_HOME "/opt/hygienic-chicken/bin" #endif #ifndef C_INSTALL_EGG_HOME # define C_INSTALL_EGG_HOME "/opt/hygienic-chicken/lib/chicken/4" #endif #ifndef C_INSTALL_LIB_HOME # define C_INSTALL_LIB_HOME "/opt/hygienic-chicken/lib" #endif #ifndef C_INSTALL_STATIC_LIB_HOME # define C_INSTALL_STATIC_LIB_HOME "/opt/hygienic-chicken/lib" #endif #ifndef C_INSTALL_INCLUDE_HOME # define C_INSTALL_INCLUDE_HOME "/opt/hygienic-chicken/include" #endif #ifndef C_INSTALL_MORE_LIBS # define C_INSTALL_MORE_LIBS "-lm -ldl" #endif #ifndef C_INSTALL_MORE_STATIC_LIBS # define C_INSTALL_MORE_STATIC_LIBS "-lm -ldl" #endif #ifndef C_DEFAULT_TARGET_STACK_SIZE # define C_DEFAULT_TARGET_STACK_SIZE (256*1024) #endif #ifndef C_STACK_
[Chicken-users] hygienic chicken: char-ready? missing
hi, the procedure char-ready? (which is part of r5rs) seems to be missing in the scheme module. bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] chicken-setup
hi, On Tue, Jul 15, 2008 at 09:54:30AM -0300, Mario Domenech Goulart wrote: > Maybe we can do this automagically. We can keep a hash (e.g., md5, > sha) of the repository metadata file. chicken-setup always downloads > the hash file (which is small) and compares with the local copy. If > the remote and local hashes are different, chicken-setup fetches the > remote (most recent) repository metadata file and its hash. If the > remote and the local hash are the same, chicken-setup uses the local > metadata file. why not just use the normal http if-modified-since mechanism? bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Proposed addition to tcp unit
hi, On Wed, Jul 09, 2008 at 02:22:45PM +0200, Jörg F. Wittenberger wrote: > Hi all, > > I wanted to control tcp connections from chicken, but handle the actual > traffic by an external program. > > This appears not quite possible with the tcp unit as it stands. > tcp-accept starts reading from the accepted connection while my > connection handler starves. (Or at worst they will share the traffic in > an unpredictable way.) > > To cope with the situation I added "tcp-get-next-client" (which is > incidentally compatible with rscheme's "get-next-client", since that's > the code I'm porting). > > Is this a general useful addition? I'd appreciate if it would it make > it into chicken. Will it? i cannot decide this, but i have a question: your code looks just like tcp-accept (from chicken 3.1.0) except that you return (values fd (##net#getpeername fd)) and tcp-accept returns (##net#io-ports fd). i don't understand why wrapping the fd in scheme ports should read anything from the fd if the ports are not used in any way besides getting the fd out (which doesn't seem to be possible right now - perhaps also a useful addition :) otoh... ##net#io-ports makes the fd non-blocking and closes them at some point so you are probably right, a lower-level function should be available that just returns the plain fd. (and tcp-accept should then just be (##net#io-ports (tcp-get-next-client-or-something tcpl)) i'd prefer tcp-accept* or tcp-accept/fd over tcp-get-next-client. bye, hans. > > (define (tcp-get-next-client tcpl) > (##sys#check-structure tcpl 'tcp-listener) > (let ((fd (##sys#slot tcpl 1)) > (tma (tcp-accept-timeout))) > (let loop () > (if (eq? 1 (##net#select fd)) > (let ((fd (##net#accept fd #f #f))) > (when (eq? -1 fd) > (##sys#update-errno) > (##sys#signal-hook > #:network-error 'tcp-accept (##sys#string-append "could not > accept from listener - " strerror) > tcpl) ) > (values fd (##net#getpeername fd))) > (begin > (when tma > (##sys#thread-block-for-timeout! > ##sys#current-thread > (fx+ (##sys#fudge 16) tma) ) ) > (##sys#thread-block-for-i/o! ##sys#current-thread fd #t) > (yield) > (when (##sys#slot ##sys#current-thread 13) > (##sys#signal-hook > #:network-error > 'tcp-accept > "accept operation timed out" fd) ) > (loop) ) ) ) ) ) > > BTW: It works as expected. > > /Jörg > > > ___ > Chicken-users mailing list > Chicken-users@nongnu.org > http://lists.nongnu.org/mailman/listinfo/chicken-users ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] hygienic branch (progress report, sort of)
hi, On Wed, May 14, 2008 at 04:52:17PM +0200, felix winkelmann wrote: > It would be helpful if the chicken users and hackers take a moment > to consider whether this is acceptable and right, or whether we > should keep the current system, which is less scalable in terms of > modularity, but nevertheless quite stable. to me it sounds like the way to go; i always wanted to have a module system in the core that can be used by eggs without worrying about dependencies or incompatibilities. the same is true for a hygienic macro system i guess ... but i haven't used hygienic macros a lot before. my question is: will it still be possible to write a (er-) macro that creates new identifiers like define-record does? from previous postings i got differing impressions. i know it's not considered good style to do that but it saved me a lot of typing in the directfb egg and those macros are only used internally and not made available to user code. tnx&bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Request for general advice on reading binary data
hi, On Tue, Apr 29, 2008 at 06:33:44AM -0700, Matthew Welland wrote: > I'm using file-open and file-read and various blob to vector conversions to > read and parse binary files. Does anyone have any general suggestions or > guidelines for doing this efficiently? One possibility that occured to me > is to read large chunks into a blob and then process rather than reading > small chunks as needed. I'll probably give this a try but I'm hoping to > save exploring dead ends by tapping the wisdom of this group. if your data can be represented as c-structs you could read it in some malloc()ed memory block and then use accessors defined with define-foreign-record. or on unix you could mmap() it and then use define-foreign-record accessors. but this only works if the file really is laid out like a c struct (and thus is not very platform independent). i like peter seibel's binary file library in practical common lisp[1], i always wanted to write something like that for chicken, but didn't do it so far :( hth&bye, hans. [1] http://www.gigamonkeys.com/book/practical-parsing-binary-files.html ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] srfi-19, srfi-29 and required-extension-version
hi, when i want to install srfi-19 on a fresh chicken 3.1.0 installation (without old eggs or something) it tells me: Error: the required extension `srfi-29' is older than 1.5, which is what this extension requires but: # chicken-setup -l | grep srfi-29 srfi-29Version: 1.11.0 (Release 200804120109) which is probably better than 1.5 but required-extension-version compares the version string lexicographically so 1.11.0 seems older. nothing that can't be easily worked around... just wanted to report it... bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] working with bit- and byte-level structures
hi, On Wed, Apr 16, 2008 at 11:38:44AM -0700, Martin DeMello wrote: > Ah - okay, if it's serialisation-specific, it's not what I'm looking > for. I was looking for an analogue to the C trick of interpreting a > block of bits as a struct quickly and efficiently. maybe you can use define-foreign-record to define the struct. but this doesn't work at the bit level, afaik there is no way to say e.g. unsigned int flag : 1; see http://chicken.wiki.br/Accessing%20external%20objects and http://chicken.wiki.br/Foreign%20type%20specifiers hth&bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Re: srfi-18 and dynamic wind problem
hi, On Mon, Apr 07, 2008 at 11:18:51PM +0100, Alaric Snell-Pym wrote: > > On 7 Apr 2008, at 11:15 pm, Hans Bulfone wrote: > >> and i'd find it even better if we could change the behaviour of the >> default exception handler to unwind the dynamic-wind stack before >> exiting or terminating the thread. i think it's a more useful default >> behaviour... but i don't know if it's easily doable... > > Can it not be done by wrapping every thread (even the primordial one) > in a conventional exception catching block, which then generates a > normal exception handler which calls to a continuation up in the > dynamic scope of the catching block, thus unwinding the stack? Then > it can just catch the exception and report exceptional thread > termination, or in the normal course of events cleanly shut the > thread down. > > Should be an easy fix, no? semantically you are right but i don't know how easy this is for the default handler which is probably just a procedure and not defined with handle-exceptions or something. at least you can't just wrap everything the compiler sees in a handle-exceptions because then there would be no more toplevel expressions :) perhaps it's possible to somehow wrap the call to the main toplevel in a handle-exceptions but i don't know how this looks like. it requires some sort of process-exit-continuation... where the continuation would actually be the process who wait()s for the exit status of the chicken process :) bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Re: srfi-18 and dynamic wind problem
hi, On Sun, Apr 06, 2008 at 08:56:21PM -0600, Jim Ursetto wrote: > I have updated my copy of the sqlite3 egg to catch any exceptions > that occur within the body of the dynamic-wind and resignal them > in the after clause. I'll most likely commit this change along > with some other stuff relating to busy handlers. i'd rather not do that ... imho it's kind of a dirty hack. i'd find it better to just document that one has to use an exception handler that unwinds the dynamic-wind stack to ensure that everything is properly released. and i'd find it even better if we could change the behaviour of the default exception handler to unwind the dynamic-wind stack before exiting or terminating the thread. i think it's a more useful default behaviour... but i don't know if it's easily doable... just my 2 cents... hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] ANN: directfb.egg 0.8
hi! i'm happy to announce the first release of the directfb egg, a Chicken[1] scheme binding for the DirectFB[2] graphics library. it does not yet provide access to the full api, but already covers many interesting parts like DisplayLayers, Windows, Surfaces, Image- and VideoProviders, Fonts and InputDevices. see http://www.nil.at/download/dfb-examples-10.tar.gz for a few simple examples for using directfb from chicken. [3] i've tested it on linux-x86-64 using chicken 2.732 and linux-ppc using chicken 3.0.0. version 1.1.1 of directfb is required (and pkg-config). i've released it on both the 2 and 3 branch but for some reason the v2 release didn't show up on Eggs Unlimited 2 and in the egg repository, so if you are still using chicken 2.x you'll have to download the egg manually atm. (you can use the v3 egg for chicken 2.x). future releases of the directfb egg will only happen in the v3 branch. i'd very much appreciate any comments, bug reports or other feedback. bye, hans. [1] http://www.call-with-current-continuation.org/ [2] http://www.directfb.org [3] passing directfb arguments on the command line is not yet supported, so if you e.g. want to try out the examples under X11 you have to do export DFBARGS=system=x11 before starting them. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] srfi-18 and dynamic wind problem
hi, On Mon, Apr 07, 2008 at 12:41:52PM +0100, Alaric Snell-Pym wrote: > > On 7 Apr 2008, at 12:04 pm, Hans Bulfone wrote: >> >> whether with-output-to-file returns the current-output-port to its old >> value when you escape from its thunk is explicitly undefined by r5rs. > > I would argue, though, that it *should*... And it'd be easy to > implement it to do so, would it not? yes, i also think it should. bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] srfi-18 and dynamic wind problem
hi, On Mon, Apr 07, 2008 at 10:45:50AM +0100, Alaric Snell-Pym wrote: > > On 6 Apr 2008, at 5:41 am, Jim Ursetto wrote: > > (b1) and (a1) are written to bar, but then the current output port is > still to bar when (b2) is written, outside of the scope of the with- > output-to-file "bar"; it should go to foo. Likewise, (a2) gets > written to baz and not to foo, and (b1)(t1)(a1) goes to baz and not bar. whether with-output-to-file returns the current-output-port to its old value when you escape from its thunk is explicitly undefined by r5rs. bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] srfi-18 and dynamic wind problem
hi, On Sat, Apr 05, 2008 at 10:41:31PM -0600, Jim Ursetto wrote: > (define (foo) > (print "start") > (dynamic-wind > noop > (lambda () (error "during body")) > (lambda () (print "during cleanup"))) > (print "end")) > > ;;; Without thread > > #;1> (foo) > start > Error: during body > during cleanup > end btw. imho the "end" shouln't be printed and on my system (with 2.732) isn't. i get differing behaviour: csi, (load "test.scm") on the repl => "during cleanup" is printed after the error is reported. csi -script test.scm, csc => no "during cleanup" end is never printed. imho this makes sense. the default exception handler just exits after reporting the error. csi's repl uses its own exception handler. when end is printed this imho means that an exception handler is in place that doesn't actually terminate the program in some way after reporting the error but just returns. if you add a (print) after the (error "during body"), is that invoked? hth&bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] srfi-18 and dynamic wind problem
hi, On Sat, Apr 05, 2008 at 10:41:31PM -0600, Jim Ursetto wrote: > I'm seeing some odd behavior when using dynamic-wind within a thread. > If an error occurs during the thunk, the 'after' portion is never > called nor are any subsequent statements. thread-join! then throws > an exception. > > Can anyone shed light on this? It is causing problems with the > sqlite3 egg. i've had similar problems without threads. i think the default exception handler doesn't unwind the call stack but simply (exit)s / terminates the thread. it worked for me when i used handle-exceptions (which unwinds the call stack before the exception handling code runs) around my main function. hth&bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Win32 Threading Issue
hi, On Thu, Mar 27, 2008 at 06:12:15PM -0400, Raymond Medeiros wrote: > (define send-data > (lambda (ip port msg) > (define-values (i o) (tcp-connect (->string ip) port)) > (write msg o) > (let ((result (read-line i))) > (close-input-port i) > (close-output-port o) result))) if i had to guess i'd try to move the (close-output-port o) before the read-line. but i don't have windows. hth&bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] how to access all error info in with-exception-handler?
hi, On Fri, Mar 28, 2008 at 04:34:48PM -0500, Heinrich Taube wrote: > now, when i trap the same error in an environmentn with my error handler > all i seem to get is the first part of the string, ie the message without > the symbol name: > > >>> Error: unbound variable > > my question is: how can i get a string that will contain what error > messages normally show in the repl?? i think the rest is in (condition-property-accessor 'exn 'arguments). you can also use print-error-message and print-call-chain from the library unit. hth&bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] macroexpansion and csc
hi, > > > > ;; test1.scm > > > > (declare (uses srfi-13)) > > > > > > > > (eval-when (compile load eval) > > > > (require-extension srfi-13)) > (eval-when (compile eval load) (use srfi-13)) > aren't require-extension and use the same? at least on my machine (still with 2.732) both versions work. the (declare (uses srfi-13)) seems to cause the error, but i don't understand why. bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Documentation status
hi, On Sat, Mar 15, 2008 at 04:39:25PM +0100, Peter Bex wrote: > Here's a list of eggs that have eggdoc, but where the eggdoc sources > from which the html is generated are missing. This is *bad*, and I > urge the developers of these eggs to add the eggdoc sources to the > source repository as well. > > lirc-client > pipeline i've just added the eggdoc sources for those two eggs (and added trunk and tags directories). bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Hang problem with the http egg.
hi, On Thu, Mar 13, 2008 at 10:54:28AM +0900, Alex Shinn wrote: > >>>>> "Hans" == Hans Bulfone <[EMAIL PROTECTED]> writes: > > Hans> that said, i think i really am a quite humble > Hans> person :) > > By saying that your humble status has been revoked! :P well, good. it's not helping anyway. bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Hang problem with the http egg.
hi, On Wed, Mar 12, 2008 at 04:26:02PM -0400, Graham Fawcett wrote: > On Wed, Mar 12, 2008 at 3:47 PM, Hans Bulfone <[EMAIL PROTECTED]> wrote: > > hi, > > > What's happening is that eof never returns true, even though the > > > port is closed. ready returns #f, and the next operation (either > > > peek-char or read-char, I've tried both) hangs. > > > > eof-object? is imho not meant to be called with a port. > > $ grep imho hans-message | wc -l > 5 > $ grep -v imho hans-message | wc -l > 21 yeah i noticed that too but it was of course too late :) i somehow got used to write imho when i'm not 100% sure and i was too lazy to check a few things because i was hungry :) that said, i think i really am a quite humble person :) bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Hang problem with the http egg.
hi, On Wed, Mar 12, 2008 at 08:45:31AM -0700, Robin Lee Powell wrote: > On Wed, Mar 12, 2008 at 08:22:48AM -0700, Robin Lee Powell wrote: > > If something is choking on the lack of newline, it's in the http > > egg. > > Except apparently not; apparently it's quite a bit lower-level than > that. Here's some code I added: > > (let loop () > (format #t "eof: ~A.\n" (eof-object? input)) > (format #t "ready: ~A.\n" (char-ready? input)) > (format #t "peek-char: ~A.\n" (peek-char input)) > (cond > [(eof-object? input) noop] > [(format #t "read-char: ~A.\n" (read-char input)) > (loop)])) > > What's happening is that eof never returns true, even though the > port is closed. ready returns #f, and the next operation (either > peek-char or read-char, I've tried both) hangs. eof-object? is imho not meant to be called with a port. when a port is at eof, peek-char and read-char return a special end-of-file object that can be tested with eof-object? what you want is imho: (eof-object? (peek-char input)) or (and (char-ready? input) (eof-object? (peek-char input))) which doesn't hang when there's no data available but the connection is still open. is the connection actually closed by the server? the tcpdump output you posted imho doesn't indicate that it is closed. if the connection is not closed by the server it imho means this is a bug in the server that is somehow triggered by the request like peter bex already pointed out. e.g. probably curl and wget are sending http/1.1 requests, not 1.0 like the http egg. > I'm kind of stuck at this point; I can make my own string collector > that stops when char-ready? is #f, but there seems to be a more > general problem here. that imho wouldn't work when the response is longer. you then get only the data that is immediately available. hth&bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: finalizers and stuff (Re: [Chicken-users] Cairo binding)
hi, On Tue, Mar 11, 2008 at 06:53:14PM -0400, John Cowan wrote: > There are no guarantees about finalizers. You can call (gc #t) to > force them to be run, but you have to make sure that you control all > exit paths from the program, possibly including signals. with the thread-sleep! at the end it seems to be working ok now - even without (gc #t) and with csi. probably not when the app is killed by a signal or when (exit) is used but i'm not too worried about that for now... but i still need to think if using finalizers for the directfb objects is a good idea... > > also, it seemed to not work at all with csi, only when all code is > > compiled. > > Finalizers do work in csi, but be aware that csi saves the value of every > form typed into it in variables named #1, #2, #3, ... matching the prompt, > which will effectively suppress finalization of those values. aha thanks for the tip! in my case it wasn't the problem though... i used csi -script. i think it was the same thread-sleep! problem but the continuation that was left in the thread structure closed over more directfb objects (all i had in my case). it works fine now. bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
finalizers and stuff (Re: [Chicken-users] Cairo binding)
hi, On Tue, Mar 11, 2008 at 07:25:22PM +, Luke McCarthy wrote: > A question for the list... > > In the current Cairo egg resources like the cairo context must be > explicitly destroyed (with cairo-destroy). Do you think it's a good idea to > put these under control of the garbage collector by setting a finalizer to > automatically free the resources? Possibly we could leave both options > available, removing the finalizer if the resource is explicitly destroyed. We > could also have a macro like (with-cairo-context name surface . body) i've asked myself the same question for the directfb egg i'm currently working on. i've decided to have two versions of every constructor function, e.g. dfb-create-surface and dfb-create-surface*. the * version creates the object without the finalizer, the other version with finalizer. dfbs-release (the function registered as finalizer) may be called multiple times on the same surface, so it's ok to manually release a surface created with dfb-create-surface. (i have exposed the lower-level dfb-create-surface* like functions that don't register a finalizer only because i think i've read somewhere that having many objects with finalizers is slow so i wanted to make them optional). but i'm not sure if it was the right decision now... i've had some problems with finalizers not being invoked before the program terminates (and directfb complains when not all objects are released properly). i wonder if it's ok to depend on finalizers being called before the program terminates. also, it seemed to not work at all with csi, only when all code is compiled. in my case, the finalization problems go away when i do a (thread-sleep! 0.001) somewhere near the end, i think because a continuation with a reference to some directfb objects is still stored in the thread from a previous thread-sleep! call but i haven't checked thoroughly. but this has made me think that it might be better to make memory management for those resources more explicit, like with those with-xxx style macros you mentioned... otoh you might not always want to have resource creation and destruction in the same function... > Another question - how do you remove a finalizer? I suppose > (set-finalizer! obj (lambda (x) (void))) > might work, assuming it overrides the old one. Is there a better > way? this doesn't work (at least not with chicken 2.732 where i tested it). the old finalizer isn't overwritten, both are called when the object is garbage collected. bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] string->time bug
hi, i've just found a problem in string->time (in posixunix.scm): i think (strptime tim fmt (make-vector 10 #f)) should be (strptime (##sys#make-c-string tim) (##sys#make-c-string fmt) (make-vector 10 #f)) to ensure the strings are null-terminated. bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] read-u8vector! from tcp port
hi, On Tue, Jan 29, 2008 at 12:22:04PM -0800, Kon Lovett wrote: > Fixed in trunk/chicken. thanks, kon! bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] read-u8vector! from tcp port
hi graham, On Tue, Jan 29, 2008 at 02:44:18PM -0500, Graham Fawcett wrote: > Hi Hans, > > On Jan 28, 2008 7:38 PM, Hans Bulfone <[EMAIL PROTECTED]> wrote: > > on my system (linux-amd64) when i use read-u8vector! to read from a > > port created by tcp-accept or tcp-connect and give #f as LENGTH, i get > > the unrealistic error: > > > > out of memory - heap full while resizing - execution terminated > > Yeah, that's a ugly error message. But what would it mean to read an > arbitrary-length string from a network port? it's not supposed to read an arbitrary-length string; it should read into the provided u8-vector until it is full. [1] imho either the read-string! implementation in the tcp unit should check for its length parameter (n) being #f or read-u8vector! shouldn't pass #f as n to ##sys#read-string! in the first place. probably the latter as ##sys#custom-input-port's implementation of read-string! (in posixunix.scm) doesn't seem to check for #f either. btw. this is with chicken 2.732 but after a quick check i think it's the same in trunk. bye, hans. [1] http://chicken.wiki.br/Unit%20srfi-4: [procedure] (read-u8vector! LENGTH U8VECTOR [PORT [START]]) Reads LENGTH bytes from the PORT writing the read input into U8VECTOR beginning at START (or 0 if not given). PORT defaults to the value of (current-input-port). If LENGTH is #f, the vector will be filled completely until end-of-file is reached. This procedure returns the number of bytes read. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] read-u8vector! from tcp port
hi, on my system (linux-amd64) when i use read-u8vector! to read from a port created by tcp-accept or tcp-connect and give #f as LENGTH, i get the unrealistic error: out of memory - heap full while resizing - execution terminated when i use the length of the vector as LENGTH it works as expected. maybe this is because in tcp.scm in the read-string implementation there is no check for n being #f, as opposed to e.g. in library.scm in the definition of ##sys#string-port-class. bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Web applications
hi, On Wed, Jan 16, 2008 at 06:58:04PM +0100, Tobia Conforto wrote: > Hello Chicken all-knowers, > > I'm about to design a new, very AJAXy web application and I'd like to write > it in Chicken, plus jQuery on the client side. > > What framework/server/storage engine/miscellaneous eggs/deployment tactics > do you recommend or have worked with in the past? you may also want to check out the scgi and fastcgi eggs. for generating html i can also recommend the hart egg. bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] quasiquote, unquote-splicing and cons cells
hi, On Sat, Jan 05, 2008 at 03:10:51PM -0600, Zbigniew wrote: > Hans, > > If I understand correctly, you're asking whether this is valid: > > `(,@'() . x) ;=> x yes. i should have written my question more concisely :) > According to Quasiquotation in Lisp (Alan Bawden), "... the most thanks for the pointer! that's the best explanation about quasiquotation i've ever seen. now i even begin to understand how nested quasiquotation works and don't need to do it by trial and error any more :) also thanks for the other replies! after reading part of the paper and given that `(,@'() . x) is valid syntax according to the grammar in r5rs and that a symbol is a dotted list of length 0 (as per srfi-1) it seems to me that there really is no other useful expansion for `(,@'() . x) :) also, this is actually in code that is fairly chicken-specific :) > #;2> ,x `(,@'() . x) > (##sys#append '() 'x) ah - i didn't think about using ,x to expand qqs - good idea :) bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] quasiquote, unquote-splicing and cons cells
hi, in a macro i'm constructing a lambda-list in the following way: `(,@rqd-args . ,rest-arg) there are 3 cases: 1. (let ((rqd-args '(a b c)) (rest-arg 'r)) `(,@rqd-args . ,rest-arg)) ==> (a b c . r) 2. (let ((rqd-args '(a b c)) (rest-arg '())) `(,@rqd-args . ,rest-arg)) ==> (a b c) so far so good, nothing special... but: 3. (let ((rqd-args '()) (rest-arg 'r)) `(,@rqd-args . ,rest-arg)) ==> r this is exactly how i hoped it to be, but the question is if this is actually allowed or if it just works "accidentally". r5rs doesn't seem to specify this case and '( . x) is not allowed. i've tried the same expression with guile and sbcl and it worked there as well but i'm still not sure if i should use it. any opinions? tnx&bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Event Scheduling?
hi, On Thu, Jan 03, 2008 at 03:16:49PM -0600, Ozzi wrote: > I'm looking to write a daemon that will periodically poll a HTTP server. Is > there an event scheduling egg out there somewhere? If not, does anyone have > an opinion on how best to implement such a thing? > > I've considered using set-alarm! or thread-sleep!, or perhaps porting TIMER > (http://www.xach.com/lisp/timer/doc.html) > > Thoughts? i'd rather use thread-sleep! (perhaps in a dedicated thread) than set-alarm!. personally i use alarm signals only for implementing timeouts in simple single-threaded applications that don't have a select() loop (which chicken has inside its thread scheduler). signals are imho often somewhat problematic to deal with, especially when you want to use them for repeated background tasks when foreign libraries are involved that may not properly restart interrupted system calls. hth&bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] define-foreign-enum with a typedef
hi, On Wed, Dec 12, 2007 at 11:48:48PM -0700, Shawn Rutledge wrote: > > > (define-foreign-enum (dbus:bus (enum "DBusBusType")) > > > (dbus:session-bus DBUS_BUS_SESSION) > > > (dbus:system-bus DBUS_BUS_SYSTEM) > > > (dbus:starter-bus DBUS_BUS_STARTER) ) > > > > i've been using > > > > (define-foreign-enum (dbus:bus int) ...) > > > > in cases like this. don't know if it's the best solution, but it works. > > That seems like it ought to work, but the enum constants don't end up > being defined. yes, but the define-foreign-enum defines a foreign type named dbus:bus that converts between the symbols and the enumeration values. so you can just pass e.g. 'dbus:session-bus to a foreign procedure that expects a dbus:bus argument, it doesn't need to have a value as a variable. you can also pass '(dbus:session-bus dbus:system-bus) and get the two values or-ed together. afaik the dbus:bus foreign-type is only available in the same compilation unit as the define-foreign-enum, so you need to have the foreign-lambdas that use dbus:bus in the same file (but you can use the foreign functions from any file) hth&bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] define-foreign-enum with a typedef
hi, On Tue, Dec 11, 2007 at 10:02:56PM -0700, Shawn Rutledge wrote: > How do you use define-foreign-enum when the enum is typedef'd? e.g. for > > typedef enum > { > DBUS_BUS_SESSION,/**< The login session bus */ > DBUS_BUS_SYSTEM, /**< The systemwide bus */ > DBUS_BUS_STARTER /**< The bus that started us, if any */ > } DBusBusType; > > (define-foreign-enum (dbus:bus (enum "DBusBusType")) > (dbus:session-bus DBUS_BUS_SESSION) > (dbus:system-bus DBUS_BUS_SYSTEM) > (dbus:starter-bus DBUS_BUS_STARTER) ) i've been using (define-foreign-enum (dbus:bus int) ...) in cases like this. don't know if it's the best solution, but it works. hth&bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Concurrency, Blocking I/O
hi, On Sat, Dec 08, 2007 at 11:55:32PM +0200, Moe Aboulkheir wrote: > Hey, > > I've been using Chicken for some time for a variety of things, and am > considering using it for a large, upcoming project - one of its components > is a database-driven website. I'm concerned about blocking when performing > database access (PostgreSQL or similar) in the lightweight (SRFI-18) > threads spawned by Spiffy. How are you guys dealing with these kinds of > issues? I'd like to hear what everybody has to say. if the database api provides a non-blocking api it should be possible to integrate it with the thread scheduler, especially if the database api also provides access to a filedescriptor for select()ing (which is done internally by chicken). postgresql provides both so when using the postgresql egg database access doesn't block other threads. (i know because i've stolen this code from the postgresql egg for my own eggs :) it's also possible without a file descriptor, but imho one must use thread-sleep! then (between calls to a polling function provided by the api) to avoid wasting too much cpu time which introduces a delay. i once used this technique when i wanted to write an odbc egg. but then i found out that most odbc drivers don't seem to support the non-blocking api anyway, so i didn't finish the egg :( imho the lightweight threads provided by chicken are a good environment for network programming. hth&bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] RFC: Daemonize
hi, On Fri, Nov 30, 2007 at 11:08:08AM -0600, Ozzi wrote: >> i also wanted to create an egg from that code, along with some >> syslog functions, but was to lazy to do it as yet :) >> perhaps we should merge our code... as i now have more than one daemon i created an egg from my code yesterday, named daemon-tools. (this doesn't mean we can't still move things around of course) > Actually, I think there's three eggs here. > > Syslog: The syslog functions. > > Daemon: Mostly a clone of C's or Perl's daemon() function. Could be a > wrapper to the C function. > > Daemonize: A more robust daemonization function/library that can take care > of PID files, output redirection to log files, and anything else related to > managing a daemon. It may include functionality from Syslog, if appropriate > (I'm not sure right now). It should probably be named something other than > Daemonize, though. at least the syslog and daemon parts are rather small and don't have any dependencies beside chicken itself, so i'm not sure if it's worth separating them into multiple eggs. > The Syslog and Daemon eggs might be best off merged into the Posix unit. yes, you may be right, but on the other hand having them as separate egg has at least the advantage that apps that use them don't need to depend on the latest chicken version. also it seems to me that the "trend" at the moment is rather to move things out of the chicken core into separate eggs (like easyffi, dollar, etc.) which imho is a good thing. when the functions are included in chicken itself there probably also should be an implementation for windows, where they most likely won't work as-is... (which would of course also be good for the separate egg case, any volunteers? :) > Indeed, it may be appropriate to have different functions for daemonizing > the current processing and forking a new daemon process. yes - or just do (process-fork (cut daemonize-current-process pid-file: "/bla.pid" user: "foo" ...)) when one wants to create multiple daemons. bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] RFC: Daemonize
hi, sorry for the late reply, i didn't have much time/energy for chicken in the last few weeks :( i'm using the following code in a daemon i wrote: (iirc i translated it from a perl manpage or something) (require-extension posix) (define (daemon:ize) (change-directory "/") (let ((fd-r (file-open "/dev/null" open/rdonly)) (fd-w (file-open "/dev/null" open/wronly))) (duplicate-fileno fd-r 0) (duplicate-fileno fd-w 1) (file-close fd-r) (file-close fd-w)) (let ((child-pid (process-fork))) (if (not (zero? child-pid)) (exit 0))) (create-session) (duplicate-fileno 1 2) (void)) i also wanted to create an egg from that code, along with some syslog functions, but was to lazy to do it as yet :) perhaps we should merge our code... On Fri, Nov 16, 2007 at 01:21:25PM -0600, Ozzi wrote: > I'm most definitely not a scheme guru, so if someone with half a clue would > take a look at my little daemonize egg below and let me know what they > think, I'd appreciate it. > > I ended up using the (foreign-lambda int "daemon" int int) approach. afaik daemon() already calls fork() so i don't think you'd really need to call (process-fork) then. otoh - daemon() is like my (daemon:ize) function above, it terminates the parent process which means your api would change and it would no longer be directly possible to fork multiple independent daemon processes from a single master. i've attached my whole daemon library including the syslog functions. bye, hans. > I use on-exit to remove the PID file, which means that the daemon have to > handle signals and exit cleanly. I added a default handler for signal/term > to call (exit), there are probably other default handlers that should be > added. > > Oz > > > > (define (daemonize proc #!key (pidfile #f)) > > (define (create-pid-file filename pid) > (with-output-to-file filename (lambda () (print pid > > (define (remove-pid-file filename) > (delete-file* filename)) > > (define (run-pre-fork-tests) > (when pidfile > (when (file-exists? pidfile) > (error "PID file exists.")) > (unless (file-exists? (pathname-directory pidfile)) > (error "Directory for PID file does not exist.")) > (unless (and > (file-read-access? (pathname-directory pidfile)) > (file-write-access? (pathname-directory pidfile)) > (file-execute-access? (pathname-directory pidfile))) > (error "Insuficcient rights to create PID file." > > (define (set-default-signal-handlers) > (set-signal-handler! signal/term (lambda (signum) (exit > > (define (cleanup) > (if pidfile (remove-pid-file pidfile))) > > (run-pre-fork-tests) > > (process-fork >(lambda () > ((foreign-lambda int "daemon" int int) 0 0) > (on-exit cleanup) > (if pidfile (create-pid-file pidfile pid)) > (set-default-signal-handlers) > (proc))) #t) DJ Seppl! Da best deejay in town!! (c)2007 Hans Bulfone <[EMAIL PROTECTED]> (declare (unit daemon) (export daemon:openlog daemon:syslog daemon:ize) (foreign-declare "#include ")) (require-extension posix) (define-macro (def-c-constants prefix . constants) `(begin ,@(append-map (lambda (x) (let ((scm-name (string->symbol (string-append prefix (string-translate x "_" "-") `((define ,scm-name (foreign-value ,x integer)) (declare (export ,scm-name) constants))) (def-c-constants "daemon:" "LOG_CONS" "LOG_NDELAY" "LOG_NOWAIT" "LOG_ODELAY" "LOG_PID" "LOG_AUTHPRIV" "LOG_CRON" "LOG_DAEMON" "LOG_KERN" "LOG_LOCAL0" "LOG_LOCAL1" "LOG_LOCAL2" "LOG_LOCAL3" "LOG_LOCAL4" "LOG_LOCAL5" "LOG_LOCAL6" "LOG_LOCAL7" "LOG_LPR" "LOG_MAIL" "LOG_NEWS" "LOG_SYSLOG" "LOG_USER" "LOG_UUCP" "LOG_EMERG" "LOG_ALERT" "LOG_CRIT" "LOG_ERR" "LOG_WARNING" "LOG_NOTICE" "LOG_INFO" "LOG_DEBUG") ;; WARNING: openlog leaks memory if ident is not #f (define daemon:openlog (foreign-lambda* void ((c-string ident) (integer option) (integer facility)) "openlog(((ident)?strdup(ident):NULL), option, facility);")) (define %syslog (foreign-lambda* void ((integer priority) (nonnull-c-string message)) "syslog(priority, \"
[Chicken-users] uri.egg uri-encode-query patch
hi, imho the uri-encode-query function escapes too few characters, e.g. in the following example + and & should have been escaped to not be misinterpreted when decoding: #;4> (uri-encode-query '(("foo" . "test & co") ("bar" . "quux+bla"))) "foo=test+&+co&bar=quux+bla" #;5> (uri-decode-query "foo=test+&+co&bar=quux+bla") (("bar" . "quux bla") (" co" . #t) ("foo" . "test ")) as far as i see rfc3986 treats the whole query string as a unit, so i looked in the html 4 spec[1] that says that all reserved characters in query keys and values should be escaped. i've attached a patch that changes uri-encode-query accordingly, and also changes RFC3986-unreserved-char? to not treat ! as an unreserved char, as it imho shouldn't be according to rfc3986. #;10> (uri-encode-query '(("foo" . "test & co") ("bar" . "quux+bla"))) "foo=test+%26+co&bar=quux%2Bbla" #;11> (uri-decode-query "foo=test+%26+co&bar=quux%2Bbla") (("bar" . "quux+bla") ("foo" . "test & co")) bye, hans. [1] http://www.w3.org/TR/html401/interact/forms.html#h-17.13 Index: uri.scm === --- uri.scm (revision 6561) +++ uri.scm (working copy) @@ -284,7 +284,7 @@ (define (RFC3986-unreserved-char? chr) (or (char-alphabetic? chr) (char-numeric? chr) - (string-index "-_.!~" chr)) ) + (string-index "-_.~" chr)) ) ;; Split path root routines @@ -493,8 +493,8 @@ ;; ' ' -> '+' (define (uri-encode-query-item obj) - (uri-encode (string-translate (->string obj) #\space #\+) - RFC3986-PCHAR "/?") ) + (string-translate (uri-encode (->string obj) " ") +#\space #\+) ) ;; '+' -> ' ' ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: sql.egg 1.2 doesn't show up (Re: [Chicken-users] sql.egg: incompatible change)
hi mario, On Mon, Aug 27, 2007 at 05:55:58PM -0300, Mario Domenech Goulart wrote: > Problem an error occurred when the uploader script run. I've run it > manually some minutes ago to upload sql 1.2. > > The uploader log is at > http://chicken.wiki.br/chicken-projects/post-commit.log. It's > documented at http://chicken.wiki.br/periodic-tasks. thank you! i've added a link to periodic-tasks from the eggs tutorial page. at which time does the egg upload occur? btw. the salmonella-report and salmonella.log links on periodic-tasks do not work. but the atom feeds are very nice, i didn't know about them... a very good idea! sadly, firefox doesn't show the content of the summary or content tags when i add it as live bookmark. perhaps the OK / NOT OK could be added to the title? or is there some firefox option to show the summary that i missed? tnx&bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
sql.egg 1.2 doesn't show up (Re: [Chicken-users] sql.egg: incompatible change)
hi, On Thu, Aug 23, 2007 at 01:56:13AM +0200, Hans Bulfone wrote: > i've just commited version 1.2 of the sql.egg with the mentioned > change (and some others). version 1.2 of the sql.egg still isn't available on http://www.call-with-current-continuation.org/eggs/sql.html is there some problem with the egg or the upload process? i remember vaguely that there was a web page with the output of the egg-post-commit runs, but i can't find it now :( if there is such a page i think a link should be put on http://chicken.wiki.br/eggs%20tutorial tnx&bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] sql.egg: incompatible change
hi, On Sat, Aug 18, 2007 at 02:11:36PM +0200, Hans Bulfone wrote: > hi, > > i'm planning to make an incompatible change to the sql:select function > of the sql.egg. > > the signature is now: > > (sql:select what from where #!optional order-by) > > and i want to change it to: > > (sql:select what #!key from where group-by having order-by limit) > > is anyone using the sql.egg and has any objections to this change? i've just commited version 1.2 of the sql.egg with the mentioned change (and some others). bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] sql.egg: incompatible change
hi, On Sun, Aug 19, 2007 at 02:38:09PM -0700, Matthew Welland wrote: > Just a thought: would this work? > > (sql:select what from where #!optional optional-modifiers) > > Where optional-modifiers is a list of modifiers such as: > > ((limit 1)(order foo desc)) this is not much different from and imho would look more contrived than using keyword arguments. > > I have the opposite - please switch to keyword arguments. > > What would this look like? I'm concerned that nested queries would look a > bit contrived with keyword arguments. Also, select (and most other sql > commands) seem too regular to necesitate keywords. I think the sql egg > approach would lose elegance with keywords. imho supporting all parts of a select statement without using keyword arguments would make sql:select expressions harder to read because it wouldn't be obvious which subexpression serves what purpose. > 1. Positional arguments > ;; Know SQL fairly well? Then this is easy to read and understand (IMHO) > > (sql:exec db "SELECT id,name FROM people WHERE name=?" who) even with positional arguments available the sql egg can still be very useful to construct queries that consist of multiple optional conditions. > By the by I suspect that option 2. doesn't protect against SQL injection > threats to the same degree that option 1. does. imho the sql egg should protect against sql injection as long as you don't pass untrusted data as symbols. everything you pass as a string will be escaped properly. > Also, I believe that there > are optimizations that can be done with postional arguments for when a > query is called multiple times with different arguments. Can the sql egg > approach ever take advantage of those type of optimizations? not by itself, this must be supported by the database api. if supported, you can of course use this facility together with the sql.egg: (let ((stmt ((db:prepare (sql:select '(id name) from: '(people) where: '(= name ?)) (db:exec stmt "foo") (db:exec stmt "bar") ...) bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] sql.egg: incompatible change
hi, i'm planning to make an incompatible change to the sql:select function of the sql.egg. the signature is now: (sql:select what from where #!optional order-by) and i want to change it to: (sql:select what #!key from where group-by having order-by limit) is anyone using the sql.egg and has any objections to this change? tnx&bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] howto return a list from a c-function
hi, On Tue, Apr 03, 2007 at 01:14:20PM +0200, foobar wrote: > Hi, > > i need to be able to return a list from a c-function in an extension of > mine. > More specifically i need to convert an array of char-pointers into a > list of strings and > return that list. > > I looked into the docs and fount C_list which is responsible for > constructing lists. > The problem here is that the elements need to be C_alloc'ed, which is > not the case > in my extension. > > Maybe i have to copy the strings inside the array into an array of > C_alloc'ed > objects and pass this array to C_list? > If so how is that actually done correctly? i'd rather avoid the use of those functions because they are fairly tedious to use and afaik you cannot use them to return large amounts of data because the garbage collector is not invoked while your code runs and thus you are limited by the nursery size. imho it's better to return the array as a c-pointer and construct the list in a scheme wrapper function somehow like this: (let ((c-fn (foreign-lambda ...)) (get-string (foreign-lambda* c-string ((c-pointer a) (int i)) "C_return(((char**)a)[i]);"))) (let loop ((a (c-fn ...)) (i length-of-array) (l '())) (if (zero? i) l (loop a (- i 1) (cons (get-string a (- i 1)) l) bye, hans. ps: is foobar your first or your last name? :) ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] Re: srfi-19 local-timezone-locale
hi, On Mon, Apr 02, 2007 at 08:08:23AM -0700, Kon Lovett wrote: > Sorry you had to get them. (I will look into changing the srfi-19 > internals to posix tz offset interp, although I try not to chg too > much of the original code.) why this? as the public interface of srfi-19 uses positive values for east of gmt it seems perfectly reasonable to internally use the same interpretation and flip the sign when needed when 'importing' the tz data from the system or locale information. or do you see an advantage in using the posix interpretation internally? bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] Re: srfi-19 local-timezone-locale
hi, On Sun, Apr 01, 2007 at 12:35:05PM -0700, Kon Lovett wrote: > Sigh, please get 2.6.5; this is fixed. it now works as expected on my system! thanks very much for the fixes! bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] Re: srfi-19 local-timezone-locale
hi, On Fri, Mar 30, 2007 at 02:43:16PM -0700, Kon Lovett wrote: > Hi Hans, > > I released 2.6.4 which has the local-timezone-locale hack conditioned > on platform type. Also, the hack has been moved into 'make-local- > timezone-locale' & 'local-timezone-locale' is now a parameter. thanks! i hate to say this but it still doesn't work on my system :( should the tz offset in the tz string constructed in make-local-timezone-locale be east or west of utc? if i unterstand correctly, it should be west of utc, which is what seconds->local-time returns on my system (and also should return according to the docs @ callcc.org). so imho the sign of the timezone offset shouldn't be flipped on linux. imho seconds->local-time should be fixed so that it at least returns the timezone offset with the same sign interpretation on all systems. it imho now returns seconds east of utc on mac os x and seconds west of utc on all other platforms. felix, what do you think about this? > BTW, what does '(vector-ref (seconds->local-time (current-seconds)) > 8)' return? #;8> (vector-ref (seconds->local-time (current-seconds)) 8) #t bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] srfi-19 timezone problems
hi, On Tue, Mar 27, 2007 at 06:28:28PM -0700, Kon Lovett wrote: > Yes. The TZ env-var is parsed properly by the locale egg but the tz- > offset was used incorrectly by my srfi-19 code. (Well, I did have my > locale documentation wrong. Said the opposite of what is true.) > > 2.6.3 will be available Wed (earlier if I can figure out why I can't > build). thank you! it's now working correctly with TZ=CEST-2:00 (which i must admit i haven't tried before). but i still get the wrong result without TZ. i think this is because seconds->local-time also returns the offset in seconds west of UTC. i must admit, i'm rather surprised about those different tz offset interpretations :) until yesterday i thought everyone always means seconds east of utc, now i found out that the whole posix timezone api seems to use west of utc. there is no 'normal' way to specify the tz offset :) btw, at least on my system, timezone (and thus (vector-ref (seconds->local-time (current-seconds)) 9)) always returns -3600, no matter if it's summer time or not. this is also what localtime(3) says: [...] sets the external variables [...] timezone with the difference between UTC and local standard time in seconds, [...] tzset(3) contains the missing information about the sign: In a SysV-like environment it will also set the variables timezone (seconds West of GMT) also, (local-timezone-abbreviation) always returns "CET" and never "CEST" on my system. so imho it should be (let ([tzo (vector-ref tv 9)] and (current-timezone (string-append tzn (hms tzo) UNKNOWN-LOCAL-TZ-NAME (hms (- tzo DST-OFFSET in (local-timezone-locale), but i may be wrong, i'm too confused now :) C_decode_seconds in chicken's runtime.c contains this (version 2.6): #ifdef C_MACOSX C_fix(tmt->tm_gmtoff) #else C_fix(timezone) #endif my localtime(3) manpage (on linux) contains this: The glibc version of struct tm has additional fields long tm_gmtoff; /* Seconds east of UTC */ const char *tm_zone; /* Timezone abbreviation */ defined when _BSD_SOURCE was set before including . This is a BSD extension, present in 4.3BSD-Reno. if macosx has the same bsd extension, this means (vector-ref (seconds->local-time (current-seconds)) 9) will return a number with opposite sign on mac os x (but i cannot verify this as i don't have osx) this is all very confusing... :) bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] srfi-19 timezone problems
hi, On Mon, Mar 26, 2007 at 11:21:29PM -0700, Kon Lovett wrote: > Please get the new locale (0.3) & srfi-19 (2.6.2) eggs. > > With TZ=CEST2:00 (incorrect but enough to test) > > #;2> (values (current-date) (current-date (local-timezone-locale)) > (current-date 7200)) > #,(date 52274 10 15 6 27 3 2007 0 UTC #f 2 86) > #,(date 56300 10 15 8 27 3 2007 7200 CEST #f #f #f) > #,(date 56800 10 15 8 27 3 2007 7200 #f #f #f #f) > > Sorry you had to report this, > Kon np, thanks for the quick fix! but i still get the wrong time: #;7> (values (current-date) (current-date (local-timezone-locale)) (current-date 7200)) #,(date 403000116 9 36 21 27 3 2007 0 UTC #f 2 86) #,(date 40300 9 36 20 27 3 2007 -3600 CET #t #f #f) #,(date 40300 9 36 23 27 3 2007 7200 #f #f #f #f) #;8> (timezone-locale-offset (local-timezone-locale)) -3600 #;9> the timezone offset should be 3600 during winter and 7200 during summer time (which has started last weekend). i think the time zone offset from the locale is applied with the wrong sign. i just found this in libc.info about the TZ variable: The first format is used when there is no Daylight Saving Time (or summer time) in the local time zone: STD OFFSET The STD string specifies the name of the time zone. It must be three or more characters long [...] The OFFSET specifies the time value you must add to the local time to get a Coordinated Universal Time value. It has syntax like [`+'|`-']HH[`:'MM[`:'SS]]. This is positive if the local time zone is west of the Prime Meridian and negative if it is east. The hour must be between `0' and `23', and the minute and seconds between `0' and `59'. For example, here is how we would specify Eastern Standard Time, but without any Daylight Saving Time alternative: EST+5 this is the opposite of the normal way to specify the time zone offset where you specify the time value you must add to UTC to get local time (like in ISO 8601) so CEST-2:00 would be correct: [EMAIL PROTECTED]:~$ date ; TZ=CEST-2 date ; TZ=Europe/Vienna date Tue Mar 27 23:54:04 CEST 2007 Tue Mar 27 23:54:04 CEST 2007 Tue Mar 27 23:54:04 CEST 2007 [EMAIL PROTECTED]:~$ bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] srfi-19 timezone problems
hi, i'm having some timezone-related problems with srfi-19: it is now: [EMAIL PROTECTED]:~$ LC_ALL=C date Mon Mar 26 23:07:16 CEST 2007 CEST = central european summer time = UTC + 2 hours #;37> (values (current-date) (current-date (local-timezone-locale)) (current-date 7200)) #,(date 1773119 16 7 21 26 3 2007 -3600 UTC #f 1 85) #,(date 5640 16 7 21 26 3 2007 0 CET #t #f #f) #,(date 5650 16 7 23 26 3 2007 7200 #f #f #f #f) 1. the nanoseconds value seems to be wrong when a timezone (offset) is given to (current-date) 2. i'd expected the timezone offset in the first date to be 0 instead of -3600 as the returned time is UTC 3. the timezone offset of the 2nd date should imho be 7200 and the hour 23 #;39> (timezone-locale-offset (local-timezone-locale)) 0 #;40> (timezone-locale-dst? (local-timezone-locale)) #t this should be 7200 and #t this is on debian linux (etch), chicken 2.6, srfi-19 2.6.1 (Release 200703131612) bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] how do i set interface for tcp client socket etc.
hi, On Fri, Mar 16, 2007 at 08:59:45AM +0100, minh thu wrote: > Hi, > > I don't think it makes sense : a host connect to another host through > routing. > It means it use the routing tables on the first host to determine the route. > If you can reach the destination by multiple routes, it's the routing > protocol to decide by which interface you will emit. If you want to > use a sepecific interface, you have to change those routing tables. i think there are some cases where it makes sense to specify a source address. e.g. when you have multiple addresses on the same interface and want to use a specific one (for example if you have migrated some services from another machine on the same lan and those services need to connect to some backend behind a firewall and you can't get those firewall admins to allow connections from the primary ip of the host where the services have been migrated to :) but i agree that most of the time it doesn't make sense to request a specific source address for a connection. nevertheless i think it should be supported by chicken. bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] how do i set interface for tcp client socket etc.
hi, On Fri, Mar 16, 2007 at 08:46:43AM +0100, felix winkelmann wrote: > >I think the idea is to be able to connect *from* a specific address > >when you are on a box with multiple IP addresses. > > Sorry, but I have no idea how that is done. Anybody around who > knows more about socket programming? this can be done by calling bind() on the socket before calling connect(). if you set the address to INADDR_ANY the system decides the source address (and normally uses the address of the interface where the packet is going to be sent, but i don't know if this is required) if you set the port to 0, the system chooses a free port number for the local end of the connection. (actually, i didn't find anything about that in the docs that i've read, but i just tried it on linux and it works. also, i can't think of any other way of specifying the source address but letting the system decide the source port) not calling bind() before calling connect() is imho the same as calling bind() with INADDR_ANY and port 0. (but as i'm not 100% sure about the port 0 thing, i'd probably not call bind() if neither a specific source address nor port is requested). hth & bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Re: hart.egg
hi, On Thu, Mar 08, 2007 at 12:40:48PM +0100, felix winkelmann wrote: > On 3/8/07, Graham Fawcett <[EMAIL PROTECTED]> wrote: > >> > >> except that i'm getting this message while compiling hart :) > >> > >> Warning: declarations are ignored in interpreted code > >> (##core#declare (quote (export hart-parse hart-html-escape > >hart-vector-for-each*))) > > > >Odd; it's not happening for me here (Version 2.514 - > >linux-unix-gnu-x86). I'll try on 2.6 later. > > If you use -X , it probably prefers to use an already installed > (compiled) version. For someone installing without a preinstalled > (perhaps older) version, the source file will be prefered. To ensure > the local version is used use "-X .scm". i can confirm that the warning goes away when hart is already installed. actually it's the (use hart-support) in hart.scm that causes the already installed hart-support.so to be loaded (which doesn't matter because it's imho not needed in this case as -X hart.scm is only required for the hart-for macro, as far as i understand) bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] Re: hart.egg
hi, On Thu, Mar 08, 2007 at 06:31:50AM -0500, Graham Fawcett wrote: > OK, I've added (begin: ...). BTW, one of these days I plan to add a > (define-hart-keyword) procedure so you can write application-specific > keyword forms. sounds great! > I've also modified the parser and macros to accept multiple > expressions. So you can now write: > > (hart (raw: " (html (body ...))) > > as you suggested. Please update from svn and let me know how it works for > you. works fine, tnx! imho you can do (for-each hart-parse-form body) instead of (hart-emit (apply hart-parse body)) in the definition of (begin...) which generates more efficient code: #;2> ,x (hart (html (begin: "foo" (a "test") (t: x) 99))) (noop (begin (print* "footest") (apply print* (map hart-html-escape (list x))) (print* "99"))) vs #;10> ,x (hart (html (begin: "foo" (a "test") (t: x) 99))) (noop (begin (print* "") (begin (print* "footest") (apply print* (map hart-html-escape (list x))) (print* "99")) (print* ""))) bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] Re: hart.egg
hi, On Mon, Mar 05, 2007 at 07:08:38PM -0500, Graham Fawcett wrote: > Hi Hans, I had a bit of time tonight, so I've checked an updated Hart > into SVN. (Can anyone please tell me how to get a new egg built?) thank you for the quick update! > I ended up just adding (use hart-support) into hart.scm. This seems to > address the problem in the interpreter and compiler both. yes, works fine for me. except that i'm getting this message while compiling hart :) Warning: declarations are ignored in interpreted code (##core#declare (quote (export hart-parse hart-html-escape hart-vector-for-each*))) i guess this is because of -X hart.scm which does (use hart-support) which causes hart-support.scm to be loaded because hart-support.so isn't available yet. but i doubt this does any harm and i can't think of a good fix right now. > I've kept the (for) macro but renamed it to (hart-for) instead. The > hart keyword is still (for: ...) which makes sense. This should > prevent collisions. yes, tnx. > Agreed. Coming soon. :-) Until then you could do: > > (hart (let: () (raw: " Great point! I've added (scheme: ...). tnx! > Keep it coming, Hans! I've really enjoyed using Hart myself, and I'm > glad to know that someone else is enjoying it too. Your suggestions > have been first-rate. thanks :) bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] hart.egg
hi, thanks for your hart html generation library! i've recently started using it in a project and i really like it. it's easy to use, and also the implementation looks nice and is easy to understand. and have a few notes/suggestions: - when using the compiler, (use hart) is not enough to make the extension available because most of the functions in hart-support are needed at macro-expansion time. (actually it seems only html-escape and vector-for-each* are needed at runtime, the rest at compile-time) i'm using (eval-when (compile load eval) (use hart)) now. i don't know what the best solution for this is, perhaps just to put (eval-when (compile load eval) (require 'hart-support)) or something inside hart.scm? - i'm a little concerned about possible name-clashes because you are using short names like parse, emit and for. perhaps you could do something like: put (declare (export hart-parse hart-html-escape hart-vector-for-each*)) (define hart-parse parse) in hart-support.scm use hart-parse instead of parse in hart.scm and rename html-escape to hart-html-escape and vector-for-each* to hart-vector-for-each* also, i'd probably consider defining for as a function and calling it in parse-keyword-form instead of expanding to the (for ...) form, but then you'd have to use some other looping construct in emit-tag. at least i'd call it e.g. hart-for to avoid defining a name like for in an extension whose primary purpose is not to provide looping constructs - i'd like hart (and therefore probably parse / hart-parse) to take multiple hart forms so i can do this: (hart (raw: "http://www.call-with-current-continuation.org/eggs/hart.html is incorrectly formatted, the tags in the examples do not work correctly, they seem to be outputted as-is. i think that's all for now :) i hope some of my suggestions sound reasonable for you. :) bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] set-finalizer! and disable-interrupts
hi, the documentation of set-finalizer! contains: "Note that the finalizer will not be called when interrupts are disabled." does this mean that when an object with a finalizer happens to be garbage-collected while some code in a unit with disabled interrupts is running (a) the finalizer is not invoked at all or (b) the invokation is deferred until interrupts are enabled again? if (a) then i can't really depend on a finalizer being called, correct? if (b) then i'd change "when" to "while" in the documentation. bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] lolevel help: array of c-pointers from string-list?
hi, On Tue, Sep 26, 2006 at 04:44:21PM -0400, Graham Fawcett wrote: > Hi folks, > > I'm writing a basic openldap egg; it's going well, but I've hit a > small snag. The ldap_search() function takes a null-terminated array > of C strings -- char *attrs[] -- to specify the record attributes > you're interested in. (You can provide NULL instead if you want all > the attributes.) I'd like to be able to create such an array > dynamically, from a list of strings. some time ago i've also started with a openldap binding, but i didn't finish it and so far it only has support for ldap_search_s() (but that worked iirc) anyways, my solution to the attrs problem was to pass a list of strings as scheme-object and walk that list in c using C_u_i_car, C_u_i_cdr etc. i've attached my code, feel free to do whatever you want with it. (but if you use it you should replace the exit(1) with code that properly signals a type error :) > Given a list of attributes, e.g. (define attribs (list "name" "mail" > "phone")), my plan was to create a byte-vector, > > (define vec (string->byte-vector > (conc (string-intersperse attribs "\x00") "\x00"))) > > and then use (map string-length attribs) and (make-locative vec N) to > derive a list of pointers to the the strings in the byte-vector, and > then copy the list of pointers into a malloc'd array of pointers. I'm > not actually sure that's possible, though it seems like it might just > work, with sufficient effort. that also sounds like a good idea bye, hans. (declare (unit ldap) (uses lolevel) (foreign-declare "#include ")) (define (ldap*:scope->int scope) (case scope ((one onelevel) (foreign-value "LDAP_SCOPE_ONELEVEL" int)) ((sub subtree) (foreign-value "LDAP_SCOPE_SUBTREE" int)) ((base) (foreign-value "LDAP_SCOPE_BASE" int)) (else (error "invalid scope" scope (define (ldap*:int->scope scope-int) (cond ((eqv? scope-int (foreign-value "LDAP_SCOPE_ONELEVEL" int))'onelevel) ((eqv? scope-int (foreign-value "LDAP_SCOPE_SUBTREE" int)) 'subtree) ((eqv? scope-int (foreign-value "LDAP_SCOPE_BASE" int))'base) (else (error "invalid scope id" scope-int (define-foreign-type scope int ldap*:scope->int ldap*:int->scope) (define ldap:init (foreign-lambda c-pointer "ldap_init" nonnull-c-string int)) (define ldap:port (foreign-value "LDAP_PORT" int)) (define ldap:msg:free (foreign-lambda int "ldap_msgfree" c-pointer)) (define ldap:entry:count (foreign-lambda int "ldap_count_entries" nonnull-c-pointer nonnull-c-pointer)) (define ldap:entry:first (foreign-lambda c-pointer "ldap_first_entry" nonnull-c-pointer nonnull-c-pointer)) (define ldap:entry:next (foreign-lambda c-pointer "ldap_next_entry" nonnull-c-pointer nonnull-c-pointer)) (define ldap:unbind (foreign-lambda int "ldap_unbind" nonnull-c-pointer)) (define ldap:entry:dn (foreign-primitive ((nonnull-c-pointer ld) (nonnull-c-pointer entry)) "C_word *ptr; C_word dn; char *c_dn; c_dn = ldap_get_dn(ld, entry); ptr = C_alloc(C_SIZEOF_STRING(strlen(c_dn))); dn = C_string2(&ptr, c_dn); ldap_memfree(c_dn); C_values(3, C_SCHEME_UNDEFINED, C_k, dn);")) (define ldap:entry->alist (letrec ((pointer->string* (foreign-lambda* c-string ((c-pointer p)) "return(p);")) (pointer->string (lambda (p) (and p (let ((s (pointer->string* p))) (mem-free p) s (first-attribute (foreign-lambda c-pointer "ldap_first_attribute" nonnull-c-pointer nonnull-c-pointer nonnull-c-pointer)) (next-attribute (foreign-lambda c-pointer "ldap_next_attribute" nonnull-c-pointer nonnull-c-pointer nonnull-c-pointer)) (mem-free (foreign-lambda void "ldap_memfree" nonnull-c-pointer)) (get-values (foreign-lambda c-pointer "ldap_get_values_len" nonnull-c-pointer nonnull-c-pointer nonnull-c-string)) (free-values (foreign-lambda void "ldap_value_free_len" nonnull-c-pointer)) (ber-free (foreign-lambda void "ber_free" nonnull-c-pointer int)) (berval-ref (foreign-primitive ((nonnull-c-pointer berarray) (int n)) "C_word *aptr, outstr; struct berval **ber = berarray; if(ber[n]) { aptr = C_alloc(C_SIZEOF_STRING(ber[n]->bv_len)); outstr = C_string(&aptr, ber[n]->bv_len, ber[n]->bv_val); C_values(3, C_SCHEME_UNDEFINED, C_k, outstr); } else { C_values(3, C_SCHEME_UNDEFINED, C_k, C_SCHEME_FALSE); } "))) (lambda (ld entry) (let-location ((ber-pointer c-pointer (null-pointer))) (let loop ((attrname (pointer->string (first-attribute ld entry (location ber-pointer (attrlist '())) (if attrname (loop (pointer->string (next-attribute ld
[Chicken-users] wiki spam
hi, it seems that some spammer has found the chicken wiki and has put a lot of "order cialis online" and other links on it :( bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] [EMAIL PROTECTED]: sdl.egg]
hi, as i've gotten no reply from tony and also because the current version of the sdl egg did not compile on 2.41 anyway, i've commited my changes to svn and updated the egg. besides the changes shown below i've also removed these two lines and the #include from sdl-csi.scm: (define-foreign-variable installation-home c-string "C_INSTALL_HOME") (set! ##sys#include-pathnames (list installation-home)) those two lines don't seem to have an effect on my system because ##sys#include-pathnames by default has the value of C_INSTALL_HOME. i've also changed the version number to v0.4.51117.3 bye, hans. - Forwarded message from Hans Bulfone <[EMAIL PROTECTED]> - From: Hans Bulfone <[EMAIL PROTECTED]> To: Tony Garnock-Jones <[EMAIL PROTECTED]> Subject: sdl.egg Date: Fri, 11 Aug 2006 23:35:47 +0200 User-Agent: Mutt/1.5.9i hi, i've added a few functions to the sdl egg. may i commit them to the egg svn repo and update the egg? $ svn diff Index: sdl.scm === --- sdl.scm (revision 1387) +++ sdl.scm (working copy) @@ -293,6 +293,17 @@ (define sdl-set-color-key! (foreign-lambda int "SDL_SetColorKey" SDL_Surface unsigned-integer unsigned-integer)) +;; Modifies its first argument. +(define sdl-set-alpha! + (foreign-lambda int "SDL_SetAlpha" SDL_Surface unsigned-integer unsigned-byte)) + +(define sdl-display-format + (foreign-lambda SDL_Surface "SDL_DisplayFormat" SDL_Surface)) +(define sdl-display-format-alpha + (foreign-lambda SDL_Surface "SDL_DisplayFormatAlpha" SDL_Surface)) +(define sdl-convert-surface + (foreign-lambda SDL_Surface "SDL_ConvertSurface" SDL_Surface SDL_PixelFormat unsigned-integer)) + ;--- ;; NOTE: sdl-init does not work on MacOS X when called from a @@ -552,6 +563,8 @@ ; You can pass NULL for the args if you just want the button state (define sdl-get-mouse-state (foreign-lambda int "SDL_GetMouseState" s32vector s32vector)) +(define sdl-enable-unicode (foreign-lambda bool "SDL_EnableUNICODE" bool)) + ;--- (define sdl-get-video-surface (foreign-lambda SDL_Surface "SDL_GetVideoSurface")) $ bye, hans. - End forwarded message - ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] -DC_INSTALL_LIB_HOME and -DC_INSTALL_HOME
hi, i just came across the following problem using chicken 2.41 on a linux system: [EMAIL PROTECTED]:~/test$ cat test.scm (define-foreign-variable installation-home c-string "C_INSTALL_HOME") (printf "C_INSTALL_HOME = ~s\n" installation-home) [EMAIL PROTECTED]:~/test$ csc -v test.scm /usr/local/bin/chicken test.scm -output-file test.c -quiet gcc test.c -o test.o -c -DHAVE_CHICKEN_CONFIG_H -Os -fomit-frame-pointer -fno-strict-aliasing -Wall -Wno-unused -Wno-uninitialized -DHAVE_ALLOCA_H -DC_ENABLE_PTABLES -DC_STACK_GROWS_DOWNWARD=1 -DC_INSTALL_LIB_HOME="/usr/local/lib/chicken/1" -DC_INSTALL_HOME="/usr/local/share/chicken" -DC_USE_C_DEFAULTS -DC_NO_PIC_NO_DLL test.c: In function `f_18': test.c:122: error: syntax error before '/' token test.c:122: error: too many arguments to function `C_mpointer' test.c:122: error: syntax error before ';' token *** Shell command terminated with exit status 1: gcc test.c -o test.o -c -DHAVE_CHICKEN_CONFIG_H -Os -fomit-frame-pointer -fno-strict-aliasing -Wall -Wno-unused -Wno-uninitialized -DHAVE_ALLOCA_H -DC_ENABLE_PTABLES -DC_STACK_GROWS_DOWNWARD=1 -DC_INSTALL_LIB_HOME="/usr/local/lib/chicken/1" -DC_INSTALL_HOME="/usr/local/share/chicken" -DC_USE_C_DEFAULTS -DC_NO_PIC_NO_DLL [EMAIL PROTECTED]:~/test$ the problem are missing quotes around C_INSTALL_LIB_HOME and C_INSTALL_HOME. the quotes that are there are taken by the shell but additional ones are needed by the c compiler: [EMAIL PROTECTED]:~/test$ gcc test.c -o test.o -c -DHAVE_CHICKEN_CONFIG_H -Os -fomit-frame-pointer -fno-strict-aliasing -Wall -Wno-unused -Wno-uninitialized -DHAVE_ALLOCA_H -DC_ENABLE_PTABLES -DC_STACK_GROWS_DOWNWARD=1 -DC_INSTALL_LIB_HOME="\"/usr/local/lib/chicken/1\"" -DC_INSTALL_HOME="\"/usr/local/share/chicken\"" -DC_USE_C_DEFAULTS -DC_NO_PIC_NO_DLL [EMAIL PROTECTED]:~/test$ csc -v -o test test.o gcc test.o -lchicken -o test -L/usr/local/lib -Wl,-R/usr/local/lib -ldl -lpcre -lffi -lm -ldl -lpcre -lffi -lchicken [EMAIL PROTECTED]:~/test$ ./test C_INSTALL_HOME = "/usr/local/share/chicken" [EMAIL PROTECTED]:~/test$ i don't know if this bug has already been fixed in the current darcs version (as there has been some discussion about quotes on the list lately), i just wanted to report it in case it isn't. bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Weird behaviour in process / output / close-output-port
hi, On Thu, Jun 01, 2006 at 12:05:07PM -0500, Alejandro Forero Cuervo wrote: > > I can't reproduce this problem. I'll get lots of error > > messages and finally a "too many open files". > > Maybe its because of the (hypothetical) race condition? > What happens if you (sleep 1) before (newline out), as in the > following? > > (use posix) > > (let loop () > (receive (in out pid) >(process "foo") > (sleep 1) > (newline out)) > (loop)) $ ./proctest.scm ; echo $? bash: line 1: foo: command not found 141 imho this is normal on unix. the shell trying to execute "foo" has already terminated when you call (newline out), so you get a SIGPIPE signal which terminates the process if it's not handled or ignored. the bash manpage says: When a command terminates on a fatal signal N, bash uses the value of 128+N as the exit status. SIGPIPE is 13 on my system, that's why the "exit status" is 141. bye, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Help with foreign-lambda
hi, On Mon, May 15, 2006 at 11:59:09PM -0400, Jim Miller wrote: > I'm trying to least expensive way to wrap a C function into scheme. The > following is the C interface to the function I need: > > typedef long int integer; > typedef float real; > > int gtd6_(integer *iyd, real *sec, real *alt, real *glat, real *glong, real > *stl, real *f107a, real *f107, real *ap, integer *mass, real *d__, real *t); > > (Its actually a fortran function so the pointers to the function are not my > choice) > > The first 10 arguments (iyd - mass) are actually pointers to single values. > The final two must be pointers to arrays. d must be capable of holding 8 > elements while t must be capable of 2. > > [...] > > when I run the program I get the error: > Error: bad argument type - not a pointer: 138 > > So my questions are > > a) If I have to pass a pointer to an allocated array of memory in the C > function am I doing this correctly when I use the make-f32vector function? > I'm not sure if this is where the error is occurring but it seems like its > the only place that it could? the error occurs because c-pointer objects are expected as arguments to gtd6. you can use let-location to make c-pointer objects pointing to scheme data. imho the following should work: (define gtd6 (foreign-lambda integer "gtd6_" (nonnull-c-pointer integer) (nonnull-c-pointer float) (nonnull-c-pointer float) (nonnull-c-pointer float) (nonnull-c-pointer float) (nonnull-c-pointer float) (nonnull-c-pointer float) (nonnull-c-pointer float) (nonnull-c-pointer float) (nonnull-c-pointer integer) nonnull-f32vector nonnull-f32vector)) (let-location ([iyd integer 138] [sec float 345.0] [lat float 50.0] [alt float 100.0] [lon float 50.0] [stl float 100.0] [f107a float 150.0] [f107 float 150.0] [apfloat 8.0] [mass integer 48]) (let ([d (make-f32vector 8)] [t (make-f32vector 2)]) (gtd6 #$iyd #$sec #$alt #$lat #$lon #$stl #$f107a #$f107 #$ap #$mass d t))) regards, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] smtp.egg patch
hi, imho the way of doubling "." at the beginning of a line in the output port generated by smtp:open in the smtp egg is not correct as the output function could be called with a string containing multiple lines. the attached patch fixes this. regards, hans. --- smtp.scm.orig 2006-04-19 21:27:12.0 +0200 +++ smtp.scm2006-04-19 22:03:11.0 +0200 @@ -99,17 +99,20 @@ (cons to1 to) ) (send smtp "DATA") (fetch smtp) - (let ([last #f]) + (let ([bol #t]) (make-output-port (lambda (s) (let ([len (string-length s)]) (when (fx>= len 1) - (when (and last (char=? #\. (string-ref s 0))) -(write-char #\. (smtp-out smtp)) ) - (display s (smtp-out smtp)) - (when (char=? #\newline (string-ref s (fx- len 1))) -(set! last #t)) ) ) ) + (when (and bol (char=? #\. (string-ref s 0))) +(write-char #\. (smtp-out smtp))) + (display + (string-translate* s '(("\r\n." . "\r\n.."))) + (smtp-out smtp)) + (set! bol (char=? #\newline (string-ref s (fx- len 1 ) ) ) (lambda () + (unless bol +(display "\r\n")) (display ".\r\n" (smtp-out smtp)) (fetch smtp) (smtp-open-set! smtp #f) ) ) ) ) ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] read-byte, etc.
hi, On Mon, Apr 10, 2006 at 06:52:07AM +0200, felix winkelmann wrote: > On 4/6/06, Benedikt Rosenau <[EMAIL PROTECTED]> wrote: > > On Thu, Apr 06, 2006 at 08:41:55AM -0500, Alex Shinn wrote: > > > > > It looks like what the compiled C code ends up doing is just the > > > opposite of what you expected. Binding read-char in a LET creates a > > > closure, and the code for accessing a closure reference seems to take > > > one extra level of indirection compared to a global reference. Or > > > something :) But the difference is so small I wouldn't worry about it. > > > > The compiler assumes usual-integrations by default. So, it can resolve > > procedure calls at compile time. The level of indirection introduced by > > a LET harms the performance. > > Generally, yes, but not for `read-char'.. The extra binding in the let > is just needed > for r5rs-compliance. On the other hand the latter only matters when defining > standard procedures. I recommend just removing it. i'm not sure if i understand correctly... i've looked a bit into usual-integrations and the syntax-case module system and came to the following conclusions: - the compiler normally assumes that +, -, read-char, etc. are not globally redefined and resolves the bindings at compile time - the numbers egg can redefine +, -, etc. because code that uses it is compiled with (declare (not standard-bindings + - ...)) - read-char can be redefined in a syntax-case module that imports the utf8 module because it creates a local binding. - but importing the utf8 module into the toplevel should not be able to change read-char for code compiled with usual-integrations, even if that code is loaded after the utf8 module is imported. if that is correct, i guess i should remove the let. > (But Alex' posted code already is the fastest possible method, so this > is just a remark on the side). somehow i don't feel comfortable with using ##sys#... procedures when not really needed, so i'm not using it so far. thanks, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] mime.egg
hi, i've finished my port of the gauche rfc.mime module to chicken. it's available at: http://www.nil.at/software/mime.egg.sexp regards, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] read-byte, etc.
hi, On Tue, Apr 04, 2006 at 02:34:16AM -0500, Alex Shinn wrote: > At Mon, 3 Apr 2006 13:11:05 +0200, Hans Bulfone wrote: > > > > i would have also expected this version to be slightly > > faster because read-char doesn't need to be looked up > > on every invokation... but it got slightly slower; > > can anybody explain why? > > Did you change anything else? no. regards, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] read-byte, etc.
hi, On Wed, Mar 29, 2006 at 07:06:40PM -0600, Alex Shinn wrote: > The utf8 egg is a syntax-case module, so even if some other module is > using it, your code will see the original READ-CHAR. > > People can (import utf8) into the top-level if they want, but this > isn't always guaranteed to play well with other people's code. If you > want to guard against this you can: > > (define read-byte > (let ((read-char read-char)) > (lambda args > (let ((ch (apply read-char args))) > (if (eof-object? ch) > ch > (char->integer ch)) > > which will do the right thing no matter what. thanks for your suggestion. i would have also expected this version to be slightly faster because read-char doesn't need to be looked up on every invokation... but it got slightly slower; can anybody explain why? thanks, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] read-byte, etc.
hi, i'm porting the rfc.mime library from gauche to chicken. in the library the procedures read-byte, peek-byte and write-byte are used to read/write bytes which are given as integers. at the moment, i'm using (define (read-byte . args) (let ((ch (apply read-char args))) (if (eof-object? ch) ch (char->integer ch and similar definitions which seem to work, but i wonder if they are still correct with the utf8 egg. what is the correct way to read a single byte from a port? regards, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] egg versions
hi, the version numbers in the .setup files of a few eggs seem to be out of date. i've installed syntax-case, http and spiffy with chicken-setup and now chicken-setup -l shows: httpVersion: 1.33 spiffy Version: 1.52 syntax-caseVersion: 6.992 but: # csi -q -R spiffy #;1> spiffy-server-name "spiffy No. 2 (Release 1) on Chicken 2.3" the same with http and syntax-case, the installed html files have versions 1.40 and 6.993. regards, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] udp egg on win32
hi, On Sun, Feb 05, 2006 at 01:15:15PM +0900, Daishi Kato wrote: > Hi Hans, > > > imho, they should not be commented out, because they are > > needed to tell the scheduler that the thread is waiting > > for some socket to be ready for reading or writing. > > > > the scheduler then only invokes the thread when the > > socket is ready. > > So, is it like a select() call? yes, the scheduler uses select() internally and unblocks the thread when the fd is ready. this is done in ##sys#unblock-threads-for-i/o, which is called in ##sys#schedule. ##sys#thread-block-for-i/o! doesn't call select() itself, it only registers the fd and sets the thread's state to blocked. > > without the ##sys#thread-block-for-i/o call, the scheduler > > invokes the thread repeatedly, the thread calls recv(), > > gets EWOULDBLOCK and (yield)s again. this wastes a lot of > > cpu time, especially when all threads are waiting for i/o. > > Ah, you are right. This is why it worked on win32. > I guess ##sys#thread-block-for-i/o does not work correctly > on win32, and without it, the thread is invoked repeatedly, > letting the program work WITH lots of cpu time... > > Would there be a piece of code to see if > ##sys#thread-block-for-i/o is really working? i think it would be useful to test a simple program that does (udp-recvfrom) in one thread and maybe prints a message on stdout every second in the main thread. when you run this program with strace (which afaik is also available for windows), you should see if select() is called correctly and what it returns and if recv() behaves correctly and does not block. another option would be to recompile chicken with the dbg macro in scheduler.scm commented in. btw, i noticed, that in tcp.scm, fcntl() is used to set the O_NONBLOCK flag on both unix and windows, while in udp.scm ioctlsocket() is used on windows. does tcp.scm work on windows? maybe udp.scm should also use fcntl() on windows? regards, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] udp egg on win32
hi, On Fri, Feb 03, 2006 at 05:45:18PM +0900, Daishi Kato wrote: > Hi, > > Recently, I'm working on win32, and found one thing. > (udp-recvfrom) blocks when it's run in a thread. > Of cource, with a non-blocking socket. i don't know very much about windows networking stuff, but i hope my thoughts might be helpful anyway. i may be wrong, but imho the distinction between blocking and non-blocking sockets in udp-open-socket/udp-open-socket* is not very useful with chicken, because you always need non-blocking sockets if you don't want the recv()-calls to block all threads. (or you select() before every recv() call) the udp-recv... procedures always block the current thread because of the restart-nonblocking loop. > Looking into tcp.scm, I noticed that > some (##sys#thread-block-for-i/o) are commentted out. > So the same thing is done in udp.scm, > and it worked. you mean the (udp-recvfrom) does not block the current thread then? or does not block all threads? imho, they should not be commented out, because they are needed to tell the scheduler that the thread is waiting for some socket to be ready for reading or writing. the scheduler then only invokes the thread when the socket is ready. without the ##sys#thread-block-for-i/o call, the scheduler invokes the thread repeatedly, the thread calls recv(), gets EWOULDBLOCK and (yield)s again. this wastes a lot of cpu time, especially when all threads are waiting for i/o. but ihmo, (udp-recvfrom) would still block the current thread, calling recv() in a loop, when you remove the ##sys#thread-block-for-i/o. regards, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] Re: Thoughts on an O/RM library?
hi, On Sat, Feb 04, 2006 at 12:17:37AM -0600, Reed Sheridan wrote: > I really just don't want to manually > conc strings together, and have to remember to escape SQL strings, which I > will forget and then some 1337 Hax0r will drop my tables... then you might find my sql library useful: http://www.nil.at/software/sql.sexp it is a small (and incomplete) library for constructing sql queries: #;2> (define (some-scheme-function x) (+ x 99)) #;3> (sql:select '(f.data quux.name) '((as foobar f) quux) `(and (= f.quux quux.bla) (>= quux.xyz (some_database_function ,(some-scheme-function 1) "te'st" "SELECT f.data,quux.name FROM foobar AS f,quux WHERE ((f.quux=quux.bla) AND (quux.xyz>=some_database_function(100,'te''st')))" #;4> some special syntax and other things are probably missing, but it has already been useful in some programs. regards, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] lirc-client.egg
hi, i've written a chicken binding for the lirc[1] client library. it is available at: http://www.nil.at/software/lirc-client.egg.sexp regards, hans. [1] http://www.lirc.org LIRC is a package that allows you to decode and send infra-red signals of many (but not all) commonly used remote controls. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] pipeline.egg
hi, On Mon, Jan 09, 2006 at 08:21:28AM +0100, felix winkelmann wrote: > > i'd suggest adding procedures like fd->input-port and fd->output-port > > to chicken to reduce the amount of code duplication. > > Yes, that makes sense. I'm a bit busy in the moment but will do that > as soon as I get around doing it. thank you. > > also, i've wondered why the ##sys#thread-block-for-i/o! call for the > > output port is commented out in tcp.scm and not present at all in > > posix.scm. > > I just tried to remove synchronization points, and it seems to work ok. > Would it be safer to add it again? imho yes, because if the reading end of the connection reads too slow, the sender eats all cpu time repeatedly trying to write. for example, if you serve a large file using spiffy (i've used a 100mb file, but according to the truss output, 1mb would have been enough) and fetch it using a very slow http client[1], the following happens: fd 5 = http server listening socket fd 6 = connection to slow http client [...] sendto(0x6,0xbfbf8a74,0,0x0,NULL,0x0)= 1 (0x1) sendto(0x6,0x81487e4,0,0x0,NULL,0x0) = 10 (0xa) sendto(0x6,0xbfbf7594,0,0x0,NULL,0x0)= 1 (0x1) sendto(0x6,0xbfbf6ea4,0,0x0,NULL,0x0)= 1 (0x1) sendto(0x6,0xbfbf67b4,0,0x0,NULL,0x0)= 1 (0x1) sendto(0x6,0xbfbf60c4,0,0x0,NULL,0x0)= 1 (0x1) ==> http headers are sent... open("./test.dat",0x0,0744) = 7 (0x7) getrusage(0x0,0xbfbf4ce0)= 0 (0x0) getrusage(0x0,0xbfbf4ce0)= 0 (0x0) sigprocmask(0x3,0x2835a93c,0x0) = 0 (0x0) break(0x81e3000) = 0 (0x0) break(0x826a000) = 0 (0x0) read(0x7,0x817e790,0x186a0) = 10 (0x186a0) sendto(0x6,0x817e790,0,0x0,NULL,0x0) = 42888 (0xa788) sendto(0x6,0xbfbef624,0,0x0,NULL,0x0)= 43008 (0xa800) sigprocmask(0x1,0x0,0x28311b5c) = 0 (0x0) sigprocmask(0x3,0x2835a93c,0x0) = 0 (0x0) sendto(0x6,0x81a4df4,0,0x0,NULL,0x0) = 14104 (0x3718) read(0x7,0x817e790,0x186a0) = 10 (0x186a0) sendto(0x6,0x817e790,0,0x0,NULL,0x0) = 14568 (0x38e8) ==> test.dat is opened and the first few kb are sent sigprocmask(0x1,0x0,0x28311b5c) = 0 (0x0) sigprocmask(0x3,0x2835a93c,0x0) = 0 (0x0) sendto(0x6,0x81a8590,0,0x0,NULL,0x0) ERR#35 'Resource temporarily unavailable' select(1024,{5},{},0x0,{0 0})= 0 (0x0) sendto(0x6,0x81a8590,0,0x0,NULL,0x0) ERR#35 'Resource temporarily unavailable' select(1024,{5},{},0x0,{0 0})= 0 (0x0) sendto(0x6,0x81a8590,0,0x0,NULL,0x0) ERR#35 'Resource temporarily unavailable' select(1024,{5},{},0x0,{0 0})= 0 (0x0) sendto(0x6,0x81a8590,0,0x0,NULL,0x0) ERR#35 'Resource temporarily unavailable' select(1024,{5},{},0x0,{0 0})= 0 (0x0) sendto(0x6,0x81a8590,0,0x0,NULL,0x0) ERR#35 'Resource temporarily unavailable' select(1024,{5},{},0x0,{0 0})= 0 (0x0) sendto(0x6,0x81a8590,0,0x0,NULL,0x0) ERR#35 'Resource temporarily unavailable' ==> further sendto() calls fail because the output buffer space of the socket is exhausted. the server now eats all available cpu time trying to send the file. select() is only used for the listening socket. [1] i've used the following client: #!/usr/local/bin/csi -script (require-extension http-client posix) (receive (r h i o) (http:send-request "http://localhost:1234/test.dat";) (printf "Result: ~a\n" r) (for-each (lambda (x) (printf " ~a: ~a\n" (car x) (cdr x))) h) (let loop () (unless (eof-object? (read-char i)) (sleep 1) (loop regards, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] pipeline.egg
hi, i've just finished my first extension for chicken: pipeline.egg it allows running multiple subprocesses connected via pipes and scheme ports. for example to backup some files with tar and encrypt them with gpg, saving the stderr output of tar and gpg: (let ((passphrase "foobar") (tar-stderr #f) (gpg-stdout #f) (gpg-stderr #f)) (run-pipeline (pipeline:process "tar" (append '("-czf" "-") files) #f (pipeline:input-from-file 0 "/dev/null") (pipeline:output-to-pipe 1 'tar-out) (pipeline:output-to-port 2 (lambda (port) (set! tar-stderr (read-all port) (pipeline:process "gpg" (list "-o" outfile "--symmetric" "--passphrase-fd=3" "-") #f (pipeline:input-from-pipe 0 'tar-out) (pipeline:output-to-port 1 (lambda (port) (set! gpg-stdout (read-all port (pipeline:output-to-port 2 (lambda (port) (set! gpg-stderr (read-all port (pipeline:input-from-port 3 (lambda (port) (display passphrase port)) you can find it on http://www.nil.at/software/pipeline.egg.sexp so far i've used it on freebsd and linux. pipeline.egg defines the procedures fd->input-port and fd->output-port for making scheme ports out of file descripters that do not block other threads when read from/written to. i've borrowed the code from posix.scm and tcp.scm. i'd suggest adding procedures like fd->input-port and fd->output-port to chicken to reduce the amount of code duplication. also, i've wondered why the ##sys#thread-block-for-i/o! call for the output port is commented out in tcp.scm and not present at all in posix.scm. regards, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] patch for spiffy
hi, i have attached a simple patch that fixes a bug in content-transporter. regards, hans. diff -Nrc spiffy.orig/spiffy-base.scm spiffy/spiffy-base.scm *** spiffy.orig/spiffy-base.scm Fri Nov 11 20:54:49 2005 --- spiffy/spiffy-base.scm Mon Dec 19 23:59:45 2005 *** *** 179,186 (if (pair? proc) (let ([a (assq type content-transporters)]) (if a ! (set-cdr! a proc) ! (set! content-transporters (alist-cons type proc content-transporters)) ) ) (or (and-let* ([a (assq type content-transporters)]) (cdr a)) default-content-transporter) ) ) --- 179,186 (if (pair? proc) (let ([a (assq type content-transporters)]) (if a ! (set-cdr! a (car proc)) ! (set! content-transporters (alist-cons type (car proc) content-transporters)) ) ) (or (and-let* ([a (assq type content-transporters)]) (cdr a)) default-content-transporter) ) ) ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[EMAIL PROTECTED]: [Chicken-users] xml-rpc-client response parsing (+patch)]
hi, i've wondered if there's anything i can do for my xml-rpc.egg patch to be applied to the official version. the patch fixes the problem mentioned in the email below and also has support for basic http authentication on the client side. kind regards, hans. - Forwarded message from Hans Bulfone <[EMAIL PROTECTED]> ----- From: Hans Bulfone <[EMAIL PROTECTED]> To: chicken-users@nongnu.org Subject: [Chicken-users] xml-rpc-client response parsing (+patch) Date: Fri, 9 Sep 2005 13:37:34 +0200 User-Agent: Mutt/1.5.6+20040907i hi, i'm new to this list and also rather new to chicken and scheme in general. i've played with the xml-rpc egg recently and wanted to use it against an xml-rpc server implemented with ruby-on-rails. i noticed that fault responses from rails cannot be parsed by xml-rpc-client because the 'faultCode' is returned with type i4 instead of int (which is expected by xml-rpc-client). according to the xml-rpc specs, both types are equivalent. also, the specs say that two structs with the same fields in different order are the same, so i thought it would be better to parse the fault struct in a loop. i have attached a patch that fixes both, i hope you like it :) it works for me but i've not tested it thoroughly. thanks for your work on chicken, i really like it! regards, hans. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users - End forwarded message - diff -Nrc xml-rpc.orig/xml-rpc-client.scm xml-rpc/xml-rpc-client.scm *** xml-rpc.orig/xml-rpc-client.scm Wed Dec 8 18:59:54 2004 --- xml-rpc/xml-rpc-client.scm Thu Dec 15 00:16:31 2005 *** *** 5,10 --- 5,11 (require 'ssax-utils) (require 'xml-rpc-utils) (require 'url) + (require 'base64) (declare (uses extras) *** *** 19,25 (sprintf "Chicken ~A, XML-RPC ~A" (chicken-version) version) ) (define (xml-rpc:server host . more) ! (define (decode-arguments host port path) (let* ((endpoint-url (url host)) (endpoint-scheme (url-scheme endpoint-url)) (host-is-url (if endpoint-scheme --- 20,26 (sprintf "Chicken ~A, XML-RPC ~A" (chicken-version) version) ) (define (xml-rpc:server host . more) ! (define (decode-arguments host port path user pass) (let* ((endpoint-url (url host)) (endpoint-scheme (url-scheme endpoint-url)) (host-is-url (if endpoint-scheme *** *** 31,40 (values (url-host endpoint-url) (or (url-port endpoint-url) 80) ! (string-append "/" (or (url-path endpoint-url) ""))) ! (values host port path ! (let-optionals more ([port 80] [path "/RPC2"]) ! (let-values (((host port path) (decode-arguments host port path))) (lambda (name) (lambda args (let ([payload (create-payload name args)]) --- 32,43 (values (url-host endpoint-url) (or (url-port endpoint-url) 80) ! (string-append "/" (or (url-path endpoint-url) "")) ! (url-user endpoint-url) ! (url-password endpoint-url)) ! (values host port path user pass ! (let-optionals more ([port 80] [path "/RPC2"] [user #f] [pass #f]) ! (let-values (((host port path user pass) (decode-arguments host port path user pass))) (lambda (name) (lambda args (let ([payload (create-payload name args)]) *** *** 43,51 (http:make-request 'post (sprintf "~A:~A~A" host port path) ! `(("content-type" . "text/xml") ! ("content-length" . ,(number->string (string-length payload))) ! ("user-agent" . ,xml-rpc:version) ) payload 'http/1.0) ) ] ) (let ([x (parameterize ([case-sensitive #t]) --- 46,62 (http:make-request 'post (sprintf "~A:~A~A" host port path) ! (append !`(("content-type" . "text/xml") ! ("content-length" . ,(number->string (string-length payload))) ! ("user-agent" . ,xml-rpc:version) ) !(if (and user pass) !`(("authorization" . ,(string-append ! "Basic " !
Re: [Chicken-users] xml-rpc-client response parsing (+patch)
hi again, On Fri, Sep 09, 2005 at 01:37:34PM +0200, Hans Bulfone wrote: > i have attached a patch that fixes both, i hope you like it :) > it works for me but i've not tested it thoroughly. i've extended the patch to provide support for http basic authentication on the client side. regards, hans. diff -Nrc xml-rpc.orig/xml-rpc-client.scm xml-rpc/xml-rpc-client.scm *** xml-rpc.orig/xml-rpc-client.scm 2004-12-08 18:59:54.0 +0100 --- xml-rpc/xml-rpc-client.scm 2005-09-09 14:47:47.843111216 +0200 *** *** 5,10 --- 5,11 (require 'ssax-utils) (require 'xml-rpc-utils) (require 'url) + (require 'base64) (declare (uses extras) *** *** 19,25 (sprintf "Chicken ~A, XML-RPC ~A" (chicken-version) version) ) (define (xml-rpc:server host . more) ! (define (decode-arguments host port path) (let* ((endpoint-url (url host)) (endpoint-scheme (url-scheme endpoint-url)) (host-is-url (if endpoint-scheme --- 20,26 (sprintf "Chicken ~A, XML-RPC ~A" (chicken-version) version) ) (define (xml-rpc:server host . more) ! (define (decode-arguments host port path user pass) (let* ((endpoint-url (url host)) (endpoint-scheme (url-scheme endpoint-url)) (host-is-url (if endpoint-scheme *** *** 31,40 (values (url-host endpoint-url) (or (url-port endpoint-url) 80) ! (string-append "/" (or (url-path endpoint-url) ""))) ! (values host port path ! (let-optionals more ([port 80] [path "/RPC2"]) ! (let-values (((host port path) (decode-arguments host port path))) (lambda (name) (lambda args (let ([payload (create-payload name args)]) --- 32,43 (values (url-host endpoint-url) (or (url-port endpoint-url) 80) ! (string-append "/" (or (url-path endpoint-url) "")) ! (url-user endpoint-url) ! (url-password endpoint-url)) ! (values host port path user pass ! (let-optionals more ([port 80] [path "/RPC2"] [user #f] [pass #f]) ! (let-values (((host port path user pass) (decode-arguments host port path user pass))) (lambda (name) (lambda args (let ([payload (create-payload name args)]) *** *** 43,51 (http:make-request 'post (sprintf "~A:~A~A" host port path) ! `(("content-type" . "text/xml") ! ("content-length" . ,(number->string (string-length payload))) ! ("user-agent" . ,xml-rpc:version) ) payload 'http/1.0) ) ] ) (let ([x (parameterize ([case-sensitive #t]) --- 46,62 (http:make-request 'post (sprintf "~A:~A~A" host port path) ! (append !`(("content-type" . "text/xml") ! ("content-length" . ,(number->string (string-length payload))) ! ("user-agent" . ,xml-rpc:version) ) !(if (and user pass) !`(("authorization" . ,(string-append ! "Basic " ! (base64:encode !(string-append ! user ":" pass) !'())) payload 'http/1.0) ) ] ) (let ([x (parameterize ([case-sensitive #t]) *** *** 78,87 (apply values (map xml-rpc:unmarshall-value x)) ] [`(fault (value ! (struct !(member (name "faultCode") (value (int ,code))) !(member (name "faultString") (value (string ,str))) ) ) ) !(xml-rpc:error (string->number code) (sprintf "XML-RPC fault response (code ~A): ~A" code str)) ] [r (bad r r0)] ) ] [r (bad r r0)] ) ) ] [r (bad r r0)] ) ) ) ) --- 89,105 (apply values (map xml-rpc:unmarshall-value x)) ] [`(fault (value ! ,('struct members ...))) !(let loop ((code #f) (msg #f) (members members)) !
[Chicken-users] xml-rpc-client response parsing (+patch)
hi, i'm new to this list and also rather new to chicken and scheme in general. i've played with the xml-rpc egg recently and wanted to use it against an xml-rpc server implemented with ruby-on-rails. i noticed that fault responses from rails cannot be parsed by xml-rpc-client because the 'faultCode' is returned with type i4 instead of int (which is expected by xml-rpc-client). according to the xml-rpc specs, both types are equivalent. also, the specs say that two structs with the same fields in different order are the same, so i thought it would be better to parse the fault struct in a loop. i have attached a patch that fixes both, i hope you like it :) it works for me but i've not tested it thoroughly. thanks for your work on chicken, i really like it! regards, hans. diff -Nrc xml-rpc.orig/xml-rpc-client.scm xml-rpc/xml-rpc-client.scm *** xml-rpc.orig/xml-rpc-client.scm 2004-12-08 18:59:54.0 +0100 --- xml-rpc/xml-rpc-client.scm 2005-09-08 20:05:12.559767057 +0200 *** *** 78,87 (apply values (map xml-rpc:unmarshall-value x)) ] [`(fault (value ! (struct !(member (name "faultCode") (value (int ,code))) !(member (name "faultString") (value (string ,str))) ) ) ) !(xml-rpc:error (string->number code) (sprintf "XML-RPC fault response (code ~A): ~A" code str)) ] [r (bad r r0)] ) ] [r (bad r r0)] ) ) ] [r (bad r r0)] ) ) ) ) --- 78,94 (apply values (map xml-rpc:unmarshall-value x)) ] [`(fault (value ! ,('struct members ...))) !(let loop ((code #f) (msg #f) (members members)) ! (if (null? members) ! (xml-rpc:error (and code (string->number code)) ! (sprintf "XML-RPC fault response (code ~A): ~A" code msg)) ! (match (car members) ![`(member (name "faultCode") (value ,((or 'int 'i4) code))) ! (loop code msg (cdr members))] ![`(member (name "faultString") (value (string ,msg))) ! (loop code msg (cdr members))] ![r (bad r r0)])))] [r (bad r r0)] ) ] [r (bad r r0)] ) ) ] [r (bad r r0)] ) ) ) ) ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users