Is busybox available in shared library form? I would like to use individual apps programmatically instead of using system()
. I've heard about libbusybox and libbb but could not find any documentation.
There exists busybox library in a shared form called libbusybox(.so)
, you just have to enable it while making menuconfig. When you have compiled, it will be avalible in 0_lib
folder. In this library you have nice little function called int lbb_main(char **argv)
.
What you need to do in your code is something like this:
extern int lbb_main(char **argv);
int main()
{
char* strarray[] = {"ifconfig",0};
lbb_main(strarray);
return 1;
}
You could import libb.h
, but that didn't work for me, because I got many errors.
After that you just have to compile using somethin like gcc -o code code.c -Lpath_to_0_lib_fodler -lbusybox
and that's it!
To intercept output you will have to redefine printf and similar calls, buts that's clearly doable by using soemthing macros like #define printf(...) code' in
libb.h'.
You could even spawn busybox's shell that doesn't use fork or system, but that doesn't work well yet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With