Je***********@physik.fu-berlin.de writes:
Niko Schwarz <ni**********@gmx.net> wrote: I'd like to run check from within my c program a gnupg signature. The
easiest way should be to simply call gnupg, right? But how do i get
the output of that program into a string?
Unless you are prepared to resort to non-standard, platform-specific
solutions the only way you can do that is using the system() function
and have the external program write to a file. That file you read in
from the C program to get the output into your string.
But there's no portable way to tell an external program to write its
output to a file. Many systems will support
system("gpg blah blah > output.txt");
but most such systems probably also support the (non-standard) popen()
function. As long as you're writing non-portable code anyway, you
might as well do it in a way that avoids creating a superfluous
temporary file.
If you want to be fanatical about portability, you can have some
external source (the user or a config file) specify the command string
to be passed to system(), but I wouldn't bother.
(If you have questions about popen() that aren't answered by your
system's documentation, comp.unix.programmer is the place to ask
them.)
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.