Re: [Chicken-users] Some pointers on easyffi and interfacing with C code
A quick thank you to everyone who responded. Those tips helped immensely. When starting out with a new system, not only does one need questions answered, you need to know what questions to ask! I'd like to *think* I'm on better ground for both of those items. Cheers, -M ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Adding (system->string) somewhere
On Jan 15, 2008, at 4:43 PM, Zbigniew wrote: On Jan 15, 2008 6:08 PM, Kon Lovett <[EMAIL PROTECTED]> wrote: [Zb wrote:] If with-input-from-pipe were to optionally take a list as first argument, and (if a list) open a pipe bypassing the shell in this manner, that might be something worth looking into. osprocess does this. Whether it is a "nice wrapper" is arguable. IIRC osprocess does what process does, just gives you more control--but both are multi-step processes. Using the 'collect?:' option it can be a "one-step' process. I was thinking a wrapper along the lines of the with-* procedures. Or modifying open-input-pipe to call ##sys#process instead of popen() when there's a list involved. It's useful enough in Perl that there's a special syntax for this, and I have used it heavily. If I ever need it in Chicken I'll make an egg. Probably cleaner. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users Best Wishes, Kon ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Adding (system->string) somewhere
On Jan 15, 2008 6:08 PM, Kon Lovett <[EMAIL PROTECTED]> wrote: > > [Zb wrote:] > > If with-input-from-pipe were to > > optionally take a list as first argument, and (if a list) open a pipe > > bypassing the shell in this manner, that might be something worth > > looking into. > osprocess does this. Whether it is a "nice wrapper" is arguable. IIRC osprocess does what process does, just gives you more control--but both are multi-step processes. I was thinking a wrapper along the lines of the with-* procedures. Or modifying open-input-pipe to call ##sys#process instead of popen() when there's a list involved. It's useful enough in Perl that there's a special syntax for this, and I have used it heavily. If I ever need it in Chicken I'll make an egg. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Adding (system->string) somewhere
On Jan 15, 2008, at 3:58 PM, Zbigniew wrote: On Jan 15, 2008 6:26 AM, Tobia <[EMAIL PROTECTED]> wrote: Elf wrote: (define (system->string . args) (string-chomp (with-input-from-pipe (string-join args " ") read-all))) if this system->string is going to be of any use, it should quote its arguments against any possible interpretation by the shell. Fortunately there is a simple way which supposedly works with every flavour of UNIX shell: replace every ' with '\'' and enclose each argument in '...' The issue with applying this to every argument is that you prevent even desired shell interpretation, such as wildcard expansion. Such interpretation is pretty much the entire reason for the system() call in the first place. It's probably better that the user quote arguments selectively with his own quoting function before invoking the command. If you truly want to bypass the shell--which is often a good idea when dealing with user input--it's best not to use system() at all. That includes using with-input-from-pipe, which uses popen(), which itself calls system(). Instead you should pipe(), fork() and exec() -- the latter, of course, taking its arguments as an array. Actually, that's exactly what 'process' in the posix unit does. But there's no nice wrapper around it. If with-input-from-pipe were to optionally take a list as first argument, and (if a list) open a pipe bypassing the shell in this manner, that might be something worth looking into. osprocess does this. Whether it is a "nice wrapper" is arguable. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users Best Wishes, Kon ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Adding (system->string) somewhere
On Jan 15, 2008 6:26 AM, Tobia <[EMAIL PROTECTED]> wrote: > Elf wrote: >> (define (system->string . args) >>(string-chomp (with-input-from-pipe (string-join args " ") read-all))) > if this system->string is going to be of any use, it should > quote its arguments against any possible interpretation by the shell. > Fortunately there is a simple way which supposedly works with every > flavour of UNIX shell: replace every ' with '\'' and enclose each > argument in '...' The issue with applying this to every argument is that you prevent even desired shell interpretation, such as wildcard expansion. Such interpretation is pretty much the entire reason for the system() call in the first place. It's probably better that the user quote arguments selectively with his own quoting function before invoking the command. If you truly want to bypass the shell--which is often a good idea when dealing with user input--it's best not to use system() at all. That includes using with-input-from-pipe, which uses popen(), which itself calls system(). Instead you should pipe(), fork() and exec() -- the latter, of course, taking its arguments as an array. Actually, that's exactly what 'process' in the posix unit does. But there's no nice wrapper around it. If with-input-from-pipe were to optionally take a list as first argument, and (if a list) open a pipe bypassing the shell in this manner, that might be something worth looking into. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] libchicken universal?
No one has actually tried it to my knowledge, but you could try building two copies (one PPC, one Intel) and then using `lipo -create` to fuse the copies of each library together. The easiest way would be to build on a native i386 and a native PPC machine, but if unavailable I think you could manually do it. For example, to build PPC on Intel, add '-arch ppc' to the gcc flags, and pass ARCH=ppc.darwin to the Makefile. Or you could just try adding the "-arch i386 -arch ppc" flag to gcc. Unfortunately the latter will undoubtedly barf on the apply hack, so you'll have to disable it. In short, you're on untrodden ground. I'm pretty sure it would be doable, but would require some elbow grease. On Jan 15, 2008 4:06 PM, Heinrich Taube <[EMAIL PROTECTED]> wrote: > hi, since chicken compiles on osx ppc and intel is it possible to > compile it as a universal lib? Im getting ready to ship chicken in an > osx app bundle and this would save some release headaches. > best,rick > > > ___ > 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
[Chicken-users] libchicken universal?
hi, since chicken compiles on osx ppc and intel is it possible to compile it as a universal lib? Im getting ready to ship chicken in an osx app bundle and this would save some release headaches. best,rick ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Two Eggs & Repo Access
Hi Ozzi, On Tue, 15 Jan 2008 09:08:26 -0600 Ozzi <[EMAIL PROTECTED]> wrote: > I've written two eggs. Comments are appreciated. Great! Thanks a lot for you contributions! > I'd like access to the SVN repo as well, to release them. Username: ozzilee. It's done. The statvfs and filesystem directories have been created on the repository root. Best wishes, Mario ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] Two Eggs & Repo Access
I've written two eggs. Comments are appreciated. I'd like access to the SVN repo as well, to release them. Username: ozzilee. statvfs --- A simple wrapper the statvfs system call, returns a vector of filesystem information. Tested on Debian and OS X. Exports: statvfs filesystem -- Wraps statvfs so for now Posix-only, but could be extended to work on other systems without statvfs. Exports: filesystem:block-size filesystem:blocks-total filesystem:blocks-free filesystem:blocks-available blocks->bytes Takes a blocksize and a multiplier, i.e. 1000 for kilobytes. blocks->kilobytes Takes a blocksize and an exponent, 1 for kilobytes, 2 for megabytes. 1000-based. blocks->kibibytes Takes a blocksize and an exponent, 1 for kibibytes, 2 for mebibytes. 1024-based. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Adding (system->string) somewhere
Elf wrote: how about (define (system->string . args) (string-chomp (with-input-from-pipe (string-join args " ") read- all))) IMHO, if this system->string is going to be of any use, it should quote its arguments against any possible interpretation by the shell. Fortunately there is a simple way which supposedly works with every flavour of UNIX shell: replace every ' with '\'' and enclose each argument in '...' (define (system+ . args) (define (shell-quote arg) (conc "'" (string-substitute "'" "'\\''" arg) "'")) (with-input-from-pipe (string-join (map shell-quote args) " ") read-lines)) #;8> (system+ "ls" "/Applications/iWork '08") ("Keynote.app" "Numbers.app" "Pages.app") The read-lines and read-all versions are both useful, as are custom loops that parse the output line-by-line or character-by-character, so maybe we should make a sort of with-input-from-system that only does the quoting? Tobia ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users