469,271 Members | 1,743 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

Re: ctypes shared object FILE*

On 11/8/08, Dog Walker <th*****@gmail.comwrote:
I need to call a function in a shared object with this signature:
init_dialog(FILE *input, FILE *output)
The FILE*'s are to stdin and stdout.

The call from python is libdialog.init_dialog( x, y)
I need to define x and y so that they will have the structure of
sys.stdin and sys.stdout; the called function (init_dialog) is using a
(std?) function fileno to extract the fileno from the FILE* describing
stdin and stdout.
How can I do this?
I should have said "stderr" rather than "stdout".

And the answer is:

from ctypes import *
from ctypes.util import find_library
libc = CDLL(find_library("c"))
libdialog = CDLL(find_library("dialog"))
class FILE(Structure): pass

libdialog.init_dialog(POINTER(FILE).in_dll(libc, "stdin"),
POINTER(FILE).in_dll(libc, "stderr"))
--
I have seen the future and I'm not in it!

--
http://mail.python.org/mailman/listinfo/python-list
Nov 13 '08 #1
0 1013

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Thomas Heller | last post: by
19 posts views Thread by Thomas Heller | last post: by
1 post views Thread by Srijit Kumar Bhadra | last post: by
reply views Thread by Srijit Kumar Bhadra | last post: by
3 posts views Thread by Paddy | last post: by
2 posts views Thread by Sells, Fred | last post: by
1 post views Thread by Dog Walker | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.