472,951 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,951 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 1305
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chris Lasher | last post by:
Hello, I'm trying to write a tool to scrape through some of the Ribosomal Database Project II's (http://rdp.cme.msu.edu/) pages, specifically, through the Hierarchy Browser....
5
by: Fred | last post by:
Hi I am searching for a module, that would allow me to call files by using a 'browse' button. Is there any uniform module for browsing files, or is there a special module for *.txt files? Thanks...
1
by: tim.stoop | last post by:
Hi people, I'm trying my first little app to create a small, simple application in Python (just to see how PyQt works and all) and I seem to get stuck. I want to make a front-end for...
21
by: strutsng | last post by:
<input type="file"> only allows the user to browse for files. How about "browse for folder" dialog? Can html/javascript do that? I couldn't find any syntax for that. If not, please advise what...
5
by: RK | last post by:
I need to compile a library of C code with pre-ANSI C functions using MS ..NET 2003. The functions are declared something like this: int myFunction(p) double p; { int x; code here... return...
5
by: Dan | last post by:
I am working on a C# ASP.NET project where I need to allow the user to browse to a folder. The only way I see how to do this is use <input type=file>. But this makes the user select a file and...
3
by: William Foster | last post by:
Good evening all, Microsoft is really starting to annoy me as a new user. I am trying to convert my code from VBA (A very user friendly laguage with generally good help files) to Visual Studio...
7
by: Rory Becker | last post by:
Having installed SP1 with no Issues... I have ....created a Web app... ....Added a LINQ to SQL dbml (MyAstoriaDataContext) for some tables in my database ....Created "MyAstoriaService.svc" and...
0
by: William Gill | last post by:
I am trying to convert a Python App I wrote that generates html docs from a template. It comes in handy when doing things like photo galleries where dozens of pages are identical except the...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.