You are not logged in.
Hi all, I hope to find someone that can help me.
I'm struggling in using the command base64, which encodes a file to another one
more in details, the following command works
echo VGhlIExpbnV4IEpvdXJuYWwK | base64 -d
and gives the proper result (The Linux Journal)
Is there a way to get the result into a C variable (i.e char*)?
PS i know that the method "system("type here the shell command") executes the command, but output is not recoverable...i mean, i don't know how.
Thanks
Last edited by virusso80 (2010-05-25 18:13:37)
Offline
man 3 exec
man fork
man pipe
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
I think popen is what you are looking for.
aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies
Offline
i second popen.
Last edited by n0dix (2010-05-25 18:56:37)
Offline
But, you probably dont what to use it (popen), I think this can really slow down you program, I recommend that you implement a base64 dec/enc in C for example http://base64.sourceforge.net/b64.c
Offline
Yes, don't use popen if you can avoid it. For one thing it is slower, and for another it is less portable. Write your own conversion algorithm (it's relatively short), or use someone else's. Googling "base64 C library" brings up libb64 and a smattering of others.
Offline
You should try to use a native library where possible
[git] | [AURpkgs] | [arch-games]
Offline
And probably some library already provide base64, in my mind come openssl (its is a core package). For example google give me this http://www.ioncannon.net/programming/34 … d-openssl/ and http://www.mail-archive.com/openssl-use … 58722.html
Offline