473,662 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to call foreign programs from c?

Hello,

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?

best regards,

niko
Nov 14 '05 #1
3 3383
Niko Schwarz <ni**********@g mx.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.

<OT>
If you don't mind using a platform-specific solution and you're using
UNIX it might be worthwhile to have a look at the popen() function. I
guess that it's also available on Windows.
</OT>
Regards, Jens
--
\ Jens Thoms Toerring ___ Je***********@p hysik.fu-berlin.de
\______________ ____________ http://www.toerring.de
Nov 14 '05 #2
Je***********@p hysik.fu-berlin.de writes:
Niko Schwarz <ni**********@g mx.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.progr ammer is the place to ask
them.)

--
Keith Thompson (The_Other_Keit h) 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.
Nov 14 '05 #3
Keith Thompson <ks***@mib.or g> wrote:
Je***********@p hysik.fu-berlin.de writes:
Niko Schwarz <ni**********@g mx.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");


I was assuming that either that is possible or that the external
program has some options to tell it to write its output to a file.
If neither of these assumptions is true the OP draws a blank;-)

Regards, Jens
--
\ Jens Thoms Toerring ___ Je***********@p hysik.fu-berlin.de
\______________ ____________ http://www.toerring.de
Nov 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2625
by: Jeremiah Jacks | last post by:
I just upgraded to MySQL 4.0.14-standard for RedHat Linux and am using = the pre-compiled binaries. I have a database with INNODB tables. When I insert a row into one of the child tables, I get the following = MySQL error: INSERT INTO product_access_level (product_id,access_level_id) VALUES
2
3912
by: geoff | last post by:
The table creation script(at the end of this post) works fine on 4.0.1-alpha-win, but the foreign key constraints fail on 4.0.15-win. I am starting the server with the same command for both versions: mysqld-max-nt --console --transaction-isolation=SERIALIZABLE In 4.0.15-win I can extract the following error after I run the table creation script: ERROR 1005: Can't create table '.\ibdata\#sql-a14_3.frm'
31
3367
by: Robert Brown | last post by:
Let's say I have a type hierarchy: (just an example) the general entity customer: CREATE TABLE customer(customer_id int, customer_name varchar(250), customer_type int) three specific customer subtypes: 1 - business, 2 - home, 3 - university
0
1418
by: Scott Ribe | last post by:
I've got a problem which I think may be a bug in Postgres, but I wonder if I'm missing something. Two tables, A & B have foreign key relations to each other. A 3rd table C, inherits from A. A stored procedure updates a row in C, adds a row each in B & C. I get an integrity violation. All the foreign keys are deferrable, and the stored procedure is called from within a transaction with constraints deferred. (And the foreign keys do refer to...
0
1356
by: robert | last post by:
i use AQT mostly, and it uses ODBC and this call to show foreign key info. what it gets back is the PK of the referenced table, not the target column(s) of the foreign key. is this a shortcoming of ODBC, or the DB2 driver? reading the SYSIBM columns i can get the true picture, but i'm not sure whether the AQT folks are up to that; i suspect that normal user priviledges would prevent even reading those tables (i guess i'm special). ...
5
2800
by: Seong-Kook Shin | last post by:
Hi, I'm reading Steve's "C Programming FAQs" in book version, and have two question regarding to Q11.16 ... Also, a `return' from `main' cannot be expected to work if data local to main might be needed during cleanup. (Finally the two forms are obviously not equivalent in a recursive call to `main'). My questions are
10
2077
by: Shawn Chisholm | last post by:
Hi, I am trying to deal with a deadlock situation caused by foreign key references on insert and I was wondering if anyone knows what order the foreign keys are locked (or evaluated) in for a particular table? Deferring the locks is unfortunately not a good option for me... Thanks, Shawn ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ?
3
1775
by: Steven | last post by:
Hello All, I am relatively new to database design and wanted to ask a few questions to see if I am on the right track regarding design and normalization. I am creating a user entity which is made up of 4 tables: User(UserID(PK), EmpID, CountryID, PostCodeID) Employee(EmployeeID(PK), EmployeeType)
24
6572
by: John | last post by:
I know this is a very fundamental question. I am still quite confused if the program call stack stack should always grows upwards from the bottom, or the opposite, or doesn't matter?? That means the stack pointer should go upwards when there are "push" operations, and stack pointer should go downards when there are "pop" operations?? If this is the case, the address should go upwards (increasing) or downards (decreasing) then? i.e....
0
8432
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8344
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8857
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8764
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7367
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5654
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.