IRC channel logs

2018-02-07.log

back to list of logs

<lloda>e^x: It seems so. Please send a message to bug-guile@gnu.org.
<Labu>Hello !
<roelj>Is it possible to get a FILE* from a Guile port, so that it can be passed to a foreign function?
<amz3>roelj: if you are looking for the file descriptor associated with a port, there is 'fileno' procedure
<amz3>or 'port->fdes'
<roelj>And that returns a number, not a pointer. How do I go from file descriptor to a FILE*?
<amz3>I think FILE is a number actually
<amz3>I need to check
<roelj>So (scm->pointer ...) should do the trick?
<amz3>oops sorry
<amz3>loooking at 'man fdopen' it seems like fd and FILE are different things
<roelj>Yeah, I just realized this too. So, I can pass the file descriptor, and then I'll have to do fdopen on it to get a FILE*
<amz3>maybe you can 'fdopen' the fd returned by guile, idk, maybe some else knows better
<amz3>yes maybe
<roelj>Well, thanks. I'm going to give this a try.
<amz3>roelj: btw, you don't need 'scm->pointer' an integer, if the C function expect an int, you can pass the scheme number directly to ffi procedure it will be handled correctly
<roelj>Well, it expects a FILE*, not an int :-)
<roelj>Uhh.. how do I use the 'fdopen' C-function? Can I just dynamic-link glibc?
<amz3>yes
<civodul>roelj: there's an 'fdopen' procedure in Guile
<roelj>civodul: But it returns a port, not a FILE*, right?
<civodul>right, FILE* are libc-only things
<civodul>yeah i guess i misunderstood what you were looking for :-)
<roelj>That's alright :). So I wrote a C function that takes a file descriptor, then does: FILE* file = fdopen (fd, "rw"); return file;
<roelj>Then I loaded it with dynamic-func, but when calling it, it doesn't actually write to the file.
<roelj>And the C function calling fprintf (file, ...) returns -1 --> So something went wrong.
<roelj>Any ideas what might go wrong?
<roelj>Because I am out of clues
<amz3>strace might give more clues
<roelj>Ha! good idea
<civodul>roelj: do you really need FILE*?
<civodul>because then you have to use exclusively FILE* functions
<civodul>and FILE* does caching, so writing to a FILE* doesn't take effect immediately
<roelj>civodul: Yes, I'm trying to write an interface to a C library. And there's this one function that takes a FILE* to do all of the printing..
<roelj>Too bad. Even when using fopen from glibc, the fprintf eventually fails. :(
<roelj>Well, it was a fun experiment.
<bavier`>amz3, OrangeShark: is it possible to do a shallow clone with guile-git?
<bavier`>amz3, OrangeShark: nvm, I couldn't find anything in the texi documentation, but found the procedures in the modules
<OrangeShark>bavier`: I don't believe libgit2 supports shallow clones
<bavier`>OrangeShark: ah, indeed. there are a few open bugs/issues/feature requests
<bavier`>hmm, this makes things more difficult