471,334 Members | 1,398 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,334 software developers and data experts.

How to browse a C Library with Python

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
4 1252
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
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
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
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.

Similar topics

1 post views Thread by Chris Lasher | last post: by
5 posts views Thread by Fred | last post: by
1 post views Thread by tim.stoop | last post: by
5 posts views Thread by Dan | last post: by
3 posts views Thread by William Foster | last post: by
7 posts views Thread by Rory Becker | last post: by
reply views Thread by William Gill | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.