By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,402 Members | 1,047 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,402 IT Pros & Developers. It's quick & easy.

How to browse a C Library with Python

P: n/a
Hello,
with Python it is simple to call direct functions from c-librarys.
Is there a way to browse over a library i.e. '/lib/libc.so' with
python, to see all possible functions in a library?

#!/python
import dl, time
i = 1
line = "Python ist geil, weil ich direkt auf C librarys zugreifen kann!
\n"
print line
a = dl.open('/lib/libc.so')
print 'call c-function direct from /lib/libc.so'
i = a.call('time')
print i
print 'call function from python'
i = time.time()
print i
################################################## #######
Regards
Georg
Dec 5 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
En Wed, 05 Dec 2007 12:32:31 -0300, georg.heiss <ge*********@gmx.de>
escribi�:
with Python it is simple to call direct functions from c-librarys.
Is there a way to browse over a library i.e. '/lib/libc.so' with
python, to see all possible functions in a library?
You could use the subprocess module to execute 'nm /lib/libc.so' and look
at lines with type T.

--
Gabriel Genellina

Dec 5 '07 #2

P: n/a
with Python it is simple to call direct functions from c-librarys.
Is there a way to browse over a library i.e. '/lib/libc.so' with
python, to see all possible functions in a library?

You could use the subprocess module to execute 'nm /lib/libc.so' and look
at lines with type T.
To do this on a dynamic library you have to use nm -D /lib/libc.so
--
Rafael Sachetto Oliveira

Sir - Simple Image Resizer
http://rsachetto.googlepages.com
Dec 5 '07 #3

P: n/a
This could be a solution

import commands

callables = commands.getoutput("nm -D /lib/libc.so.6 | egrep ' T '
").split("\n")
callables = [c.split()[2] for c in callables]

print callables

On Dec 5, 2007 5:26 PM, Rafael Sachetto <rs*******@gmail.comwrote:
with Python it is simple to call direct functions from c-librarys.
Is there a way to browse over a library i.e. '/lib/libc.so' with
python, to see all possible functions in a library?
You could use the subprocess module to execute 'nm /lib/libc.so' and look
at lines with type T.

To do this on a dynamic library you have to use nm -D /lib/libc.so
--
Rafael Sachetto Oliveira

Sir - Simple Image Resizer
http://rsachetto.googlepages.com


--
Rafael Sachetto Oliveira

Sir - Simple Image Resizer
http://rsachetto.googlepages.com
Dec 5 '07 #4

P: n/a
On 5 Dez., 21:03, "Rafael Sachetto" <rsache...@gmail.comwrote:
This could be a solution

import commands

callables = commands.getoutput("nm -D /lib/libc.so.6 | egrep ' T '
").split("\n")
callables = [c.split()[2] for c in callables]

print callables

On Dec 5, 2007 5:26 PM, Rafael Sachetto <rsache...@gmail.comwrote:


with Python it is simple to call direct functions from c-librarys.
Is there a way to browse over alibraryi.e. '/lib/libc.so' with
python, to see all possible functions in alibrary?
You could use the subprocess module to execute 'nm /lib/libc.so' and look
at lines with type T.
To do this on a dynamiclibraryyou have to use nm -D /lib/libc.so
--
Rafael Sachetto Oliveira
Sir - Simple Image Resizer
http://rsachetto.googlepages.com

--
Rafael Sachetto Oliveira

Sir - Simple Image Resizerhttp://rsachetto.googlepages.com- Zitierten Text ausblenden -

- Zitierten Text anzeigen -
works fine ..., thanks a lot georg
Dec 7 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.