How to browse a C Library with Python

Discussion in 'Python' started by georg.heiss, Dec 5, 2007.

  1. georg.heiss

    georg.heiss Guest

    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
     
    georg.heiss, Dec 5, 2007
    #1
    1. Advertising

  2. En Wed, 05 Dec 2007 12:32:31 -0300, georg.heiss <>
    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
     
    Gabriel Genellina, Dec 5, 2007
    #2
    1. Advertising

  3. > > 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, Dec 5, 2007
    #3
  4. 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 <> wrote:
    > > > 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
     
    Rafael Sachetto, Dec 5, 2007
    #4
  5. georg.heiss

    georg.heiss Guest

    On 5 Dez., 21:03, "Rafael Sachetto" <> wrote:
    > 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 <> wrote:
    >
    >
    >
    >
    >
    > > > > 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
     
    georg.heiss, Dec 7, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mathew George
    Replies:
    1
    Views:
    675
    Randy Charles Morin
    Sep 15, 2003
  2. John

    Where's Build and Browse

    John, Apr 16, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    377
    Gerry O'Brien [MVP]
    Apr 17, 2004
  3. =?Utf-8?B?U2FuamVldiBCaGF0aWE=?=

    Regarding Browse information(ALT-F12) feature same as VS 6.0

    =?Utf-8?B?U2FuamVldiBCaGF0aWE=?=, Apr 6, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    882
    =?Utf-8?B?U2FuamVldiBCaGF0aWE=?=
    Apr 8, 2005
  4. VB Programmer

    HELP: Build and Browse - Missing

    VB Programmer, Jun 24, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    797
    VB Programmer
    Jun 24, 2003
  5. Replies:
    0
    Views:
    216
Loading...

Share This Page