comp.lang.ada
 help / color / mirror / Atom feed
From: "DuckE" <nospam_steved94@home.com>
Subject: Re: Yet another question on system calls(newbie question)
Date: Sat, 12 May 2001 01:30:54 GMT
Date: 2001-05-12T01:30:54+00:00	[thread overview]
Message-ID: <in0L6.4064$la.42892@news1.sttls1.wa.home.com> (raw)
In-Reply-To: mailman.989509930.7705.comp.lang.ada@ada.eu.org

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1808 bytes --]

While I'm not familiar with a C_System function, if is in written in C, you
most likely should be passing a C string:

    function C_System(value : Interfaces.C.Char_Array) return integer;
    pragma Import(
          C, C_System, "system");
    result : integer;
 begin
    result := C_System( Interfaces.C.To_C( "pwd " ) );
    result := C_System( Interfaces.C.To_C( "acdsee
D:\work\pictures\BP47.jpg" ) );
 end Command;

This turns the Ada string, which includes information about the extent of
the string, into a null terminated string.

Other answers to questions:
  You may import functions or procedures.
  Passing file handles from Ada to C may be tricky.  If you use the
File_Type defined in Ada's standard libraries, the definition is
implementation dependent.  You can certainly interface to C functions for
doing all I/O in Ada, but I don't know if you can mix Ada and C's native
file handling.

I hope this helps,

SteveD

"Torbj�rn Karfunkel" <toka@prover.com> wrote in message
news:mailman.989509930.7705.comp.lang.ada@ada.eu.org...
> Using the pragma Import method of calling non-Ada entities, am I only
> allowed to define functions? How about procedures? What I want to do is
> to create a text file, give this text file as a parameter to a C
> program, and then wait until the C program finishes. By then it will
> have produced another text file that I want to use.
> Can I use a dummy result variable like the 'result' in the following
> (from another mail):
>
> procedure Command is
>
>    function C_System(value : String) return integer;
>    pragma Import(
>          C, C_System, "system");
>
>    result : integer;
> begin
>    result := C_System("pwd ");
>    result := C_System(value => "acdsee D:\work\pictures\BP47.jpg ");
> end Command;
>
> /Torbj�rn Karfunkel
>
>
>





  parent reply	other threads:[~2001-05-12  1:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-10 15:44 Yet another question on system calls(newbie question) Torbjörn Karfunkel
2001-05-10 16:20 ` James Rogers
2001-05-10 21:03   ` Keith Thompson
2001-05-10 21:12     ` James Rogers
2001-05-10 21:12 ` Keith Thompson
2001-05-12  1:30 ` DuckE [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-05-10 19:40 Torbjörn Karfunkel
2001-05-11  7:18 Torbjörn Karfunkel
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox