List all available Functions in C

131 Views Asked by At

I want to create Bindings for another programming language, and since there are hundreds of functions I am wondering how I can make things more efficient by automating or so.

That means I want a list of all functions from a Header File with data types and return types like this:

void myfunction1(int)
void myfubction2()
void myfunction3(string, string)
....

I've imported the "glad.h" (header only lib) into my Main.

Unfortunately this library only binds system functions which means I can't extract them from the header file. Now I want to know if there is a C function which I can call in the Main which gives me exactly what I want, a list of all currently imported functions like described.

Is there a way to do so for example with relection or something.

I tried to find out a solution + I tried to give chatgpt a html list from the Docs, to extract the func names, but the list has no Definition () and return type, that means I would have to click hundreds of functions manually Copy them look what types and params they take ... and so on.

1

There are 1 best solutions below

0
Misha T On

If you've got Doxygen generated doumentation URL, you could use script:

mkdir tmp;
cd tmp;
wget -r <Documentation URL Root> -L <Documentation URL Root>;
for F in $(find . -name \*.html); do  cat $F | grep '<tr class="memitem:' | sed -e 's/<tr[^>]*>//g' | sed -e 's/&nbsp;/ /g' | sed -e 's/&#160;/ /g' | sed -e 's/<td[^>]*>//g' | sed -e 's/<a[^>]*>//g' | sed -e 's/<\/tr>//g' | sed -e 's/<\/td>//g' | sed -e 's/<\/a>//g' | sed -e 's/$/;/' | egrep  '\(.*\)' >> library_functions.h; done

You doesn't obtain type definitions by this script, and there would be some garbage

Tested for libnl, url: http://www.infradead.org/~tgr/libnl/doc/api/