473,473 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1312
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.