comp.lang.ada
 help / color / mirror / Atom feed
* System call
@ 1998-09-28  0:00 Adnan
  1998-09-30  0:00 ` Dale Stanbrough
  0 siblings, 1 reply; 9+ messages in thread
From: Adnan @ 1998-09-28  0:00 UTC (permalink / raw)


How do I use a Unix system call from an Ada program.

Thanx






^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: System call
  1998-09-28  0:00 System call Adnan
@ 1998-09-30  0:00 ` Dale Stanbrough
  0 siblings, 0 replies; 9+ messages in thread
From: Dale Stanbrough @ 1998-09-30  0:00 UTC (permalink / raw)


In article <6ulqvt$728$2@pinah.connect.com.au>, "Adnan"
<a0mohame@teaching.cs.adelaide.edu.au> wrote:

> How do I use a Unix system call from an Ada program.
> 
> Thanx

by calling the appropriate Unix routine, just as C does.
the code below does this, but is not really the best it could be.

dale


function invoke_system(name     :string) return integer is
        
        C_name  :constant interfaces.c.char_array(1..name'length+1) := 
                interfaces.c.to_C(name);

        function C_system(      name    :system.address)
                                return interfaces.c.int;
        pragma import(C, C_system, "system");
begin
        return integer(C_system(C_name(1)'address));
end;




^ permalink raw reply	[flat|nested] 9+ messages in thread

* system call
@ 2011-08-13 18:43 philippe.torgue
  2011-08-15 15:40 ` Adam Beneschan
  0 siblings, 1 reply; 9+ messages in thread
From: philippe.torgue @ 2011-08-13 18:43 UTC (permalink / raw)


Hello,

I have a program, the time of his execution, constructed images, in fact
files in PPM (P3, plain text mode)
In short, the program does not deal with the viewing of these images
(failing to find a library to do ...)

So I want to entrust this task to an external application (imview,
xview, qiv ... etc):

res = system ("imview out.ppm");

But each time this code is a new process
image viewer (here imview) that arises.

My application is waiting while I close imview to move to
the next iteration.

Well, now you have guessed the question for each passage on the line above,
I would like the external program (imview, qiv, xview ... whatever), load a new image

Regards!



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: system call
  2011-08-13 18:43 system call philippe.torgue
@ 2011-08-15 15:40 ` Adam Beneschan
  2011-08-15 15:46   ` Adam Beneschan
  2011-08-15 16:32   ` philippe.torgue
  0 siblings, 2 replies; 9+ messages in thread
From: Adam Beneschan @ 2011-08-15 15:40 UTC (permalink / raw)


On Aug 13, 11:43 am, "philippe.tor...@free.fr"
<philippe.tor...@free.fr> wrote:
> Hello,
>
> I have a program, the time of his execution, constructed images, in fact
> files in PPM (P3, plain text mode)
> In short, the program does not deal with the viewing of these images
> (failing to find a library to do ...)
>
> So I want to entrust this task to an external application (imview,
> xview, qiv ... etc):
>
> res = system ("imview out.ppm");
>
> But each time this code is a new process
> image viewer (here imview) that arises.
>
> My application is waiting while I close imview to move to
> the next iteration.
>
> Well, now you have guessed the question for each passage on the line above,
> I would like the external program (imview, qiv, xview ... whatever), load a new image
>
> Regards!

I'm not real clear on what you're trying to do.  But it sounds like
you want to run imview or some other program once, and have your
program tell that program to display a new image whenever it wants to
display something new.  In order for that to work, the image displayer
has to be set up to accept that kind of communication.

However, if by "imview" you mean the program documented at
http://hugues.zahlt.info/software_imview.html, that program appears to
have a server mode.  So you'll need to run it in server mode and then
communicate with it via a TCP/IP socket.  The documentation should
explain how to do this, but I haven't looked over it carefully.

I hope this is helpful.  I don't really know anything about this
program and just did a quick Google search to see if I could come up
with something helpful.  But it might be just what you're looking
for.  If it's not helpful at all, sorry.

                                      -- Adam




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: system call
  2011-08-15 15:40 ` Adam Beneschan
@ 2011-08-15 15:46   ` Adam Beneschan
  2011-08-15 16:48     ` philippe.torgue
  2011-08-15 16:32   ` philippe.torgue
  1 sibling, 1 reply; 9+ messages in thread
From: Adam Beneschan @ 2011-08-15 15:46 UTC (permalink / raw)


On Aug 15, 8:40 am, Adam Beneschan <a...@irvine.com> wrote:
> On Aug 13, 11:43 am, "philippe.tor...@free.fr"
>
>
>
>
>
> <philippe.tor...@free.fr> wrote:
> > Hello,
>
> > I have a program, the time of his execution, constructed images, in fact
> > files in PPM (P3, plain text mode)
> > In short, the program does not deal with the viewing of these images
> > (failing to find a library to do ...)
>
> > So I want to entrust this task to an external application (imview,
> > xview, qiv ... etc):
>
> > res = system ("imview out.ppm");
>
> > But each time this code is a new process
> > image viewer (here imview) that arises.
>
> > My application is waiting while I close imview to move to
> > the next iteration.
>
> > Well, now you have guessed the question for each passage on the line above,
> > I would like the external program (imview, qiv, xview ... whatever), load a new image
>
> > Regards!
>
> I'm not real clear on what you're trying to do.  But it sounds like
> you want to run imview or some other program once, and have your
> program tell that program to display a new image whenever it wants to
> display something new.  In order for that to work, the image displayer
> has to be set up to accept that kind of communication.
>
> However, if by "imview" you mean the program documented athttp://hugues.zahlt.info/software_imview.html, that program appears to
> have a server mode.  So you'll need to run it in server mode and then
> communicate with it via a TCP/IP socket.  The documentation should
> explain how to do this, but I haven't looked over it carefully.

Oh, yeah, one other thing: if you do this, you won't be able to use
system("...") to run imview, because "system" will wait for imview to
finish, which will never happen.  You'll need to find a way to spawn
imview without having your application wait for it to finish.  There
are ways to do this on both Unix/Linux and Windows (you don't say what
OS you're using); I think there are probably GNAT library operations
to perform that kind of spawning, but someone who's more knowledgeable
about GNAT than I am will need to help you with those, if you're using
GNAT.  There's no Ada language-defined operations for this.

                                -- Adam




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: system call
  2011-08-15 15:40 ` Adam Beneschan
  2011-08-15 15:46   ` Adam Beneschan
@ 2011-08-15 16:32   ` philippe.torgue
  1 sibling, 0 replies; 9+ messages in thread
From: philippe.torgue @ 2011-08-15 16:32 UTC (permalink / raw)


Adam Beneschan wrote:

> On Aug 13, 11:43�am, "philippe.tor...@free.fr"
> <philippe.tor...@free.fr> wrote:
>> Hello,
>>
>> I have a program, the time of his execution, constructed images, in fact
>> files in PPM (P3, plain text mode)
>> In short, the program does not deal with the viewing of these images
>> (failing to find a library to do ...)
>>
>> So I want to entrust this task to an external application (imview,
>> xview, qiv ... etc):
>>
>> res = system ("imview out.ppm");
>>
>> But each time this code is a new process
>> image viewer (here imview) that arises.
>>
>> My application is waiting while I close imview to move to
>> the next iteration.
>>
>> Well, now you have guessed the question for each passage on the line above,
>> I would like the external program (imview, qiv, xview ... whatever), load a new image
>>
>> Regards!
>
> I'm not real clear on what you're trying to do.  But it sounds like
> you want to run imview or some other program once, and have your
> program tell that program to display a new image whenever it wants to
> display something new.


 
> In order for that to work, the image displayer
> has to be set up to accept that kind of communication.
>
> However, if by "imview" you mean the program documented at
> http://hugues.zahlt.info/software_imview.html, that program appears to
> have a server mode.  So you'll need to run it in server mode and then
> communicate with it via a TCP/IP socket.  The documentation should
> explain how to do this, but I haven't looked over it carefully.
>
> I hope this is helpful.  I don't really know anything about this
> program and just did a quick Google search to see if I could come up
> with something helpful.  But it might be just what you're looking
> for.  If it's not helpful at all, sorry.
>
>                                       -- Adam


This is exactly the statement of my problem.


Meanwhile, as I had not found a solution that relieves me of the display,
I found an interesting library (opengl binding ada) 

http://www.niestu.com/software/lumen/

However, the opportunity to play a role imview server is a trail to follow!

Best regards.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: system call
  2011-08-15 15:46   ` Adam Beneschan
@ 2011-08-15 16:48     ` philippe.torgue
  2011-08-15 19:37       ` anon
  0 siblings, 1 reply; 9+ messages in thread
From: philippe.torgue @ 2011-08-15 16:48 UTC (permalink / raw)


Adam Beneschan wrote:

> On Aug 15, 8:40�am, Adam Beneschan <a...@irvine.com> wrote:
>> On Aug 13, 11:43�am, "philippe.tor...@free.fr"
>>
>>
>>
>>
>>
>> <philippe.tor...@free.fr> wrote:
>> > Hello,
>>
>> > I have a program, the time of his execution, constructed images, in fact
>> > files in PPM (P3, plain text mode)
>> > In short, the program does not deal with the viewing of these images
>> > (failing to find a library to do ...)
>>
>> > So I want to entrust this task to an external application (imview,
>> > xview, qiv ... etc):
>>
>> > res = system ("imview out.ppm");
>>
>> > But each time this code is a new process
>> > image viewer (here imview) that arises.
>>
>> > My application is waiting while I close imview to move to
>> > the next iteration.
>>
>> > Well, now you have guessed the question for each passage on the line above,
>> > I would like the external program (imview, qiv, xview ... whatever), load a new image
>>
>> > Regards!
>>
>> I'm not real clear on what you're trying to do. �But it sounds like
>> you want to run imview or some other program once, and have your
>> program tell that program to display a new image whenever it wants to
>> display something new. �In order for that to work, the image displayer
>> has to be set up to accept that kind of communication.
>>
>> However, if by "imview" you mean the program documented athttp://hugues.zahlt.info/software_imview.html, that program appears to
>> have a server mode. �So you'll need to run it in server mode and then
>> communicate with it via a TCP/IP socket. �The documentation should
>> explain how to do this, but I haven't looked over it carefully.
>
> Oh, yeah, one other thing: if you do this, you won't be able to use
> system("...") to run imview, because "system" will wait for imview to
> finish, which will never happen.  You'll need to find a way to spawn
> imview without having your application wait for it to finish.  There
> are ways to do this on both Unix/Linux and Windows (you don't say what
> OS you're using); I think there are probably GNAT library operations
> to perform that kind of spawning, but someone who's more knowledgeable
> about GNAT than I am will need to help you with those, if you're using
> GNAT.  There's no Ada language-defined operations for this.
>
>                                 -- Adam

My O.S. is ubuntu.

Damn! Here's what I read in the documentation imview ( server part)

"Instead of having a new instance of imview pop up each time one wants
to view an image, they can all appear in one, or a small number of
imview windows. This is great for monitoring progress on a long
processing run, for doing demos, for debugging an image analysis
procedure, etc.
"

Your idea sounds very good!






^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: system call
  2011-08-15 16:48     ` philippe.torgue
@ 2011-08-15 19:37       ` anon
  2011-08-16 17:18         ` philippe.torgue
  0 siblings, 1 reply; 9+ messages in thread
From: anon @ 2011-08-15 19:37 UTC (permalink / raw)


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

try something like this 

with GNAT.OS_Lib;          
use GNAT.OS_Lib;

  Prog_File : String_Access ;
  Arg_File : String_Access ;

  Args    : GNAT.OS_Lib.Argument_List ( 1 .. 1 );

  Success : Boolean ;

begin
  Arg_File := new String ( "<data file name>" ) ; 
  Args ( 1 ) := Arg_File ;
  Prog_Path := new String ( "<program name>" ) ; 

  GNAT.OS_Lib.Spawn (Prog_Path.all, Args, Success);

   if not Success then
     Exit_Program (E_Fatal);
   end if;
end ;



In <4e494de0$0$20025$426a34cc@news.free.fr>, "philippe.torgue@free.fr" <philippe.torgue@free.fr> writes:
>Adam Beneschan wrote:
>
>> On Aug 15, 8:40�am, Adam Beneschan <a...@irvine.com> wrote:
>>> On Aug 13, 11:43�am, "philippe.tor...@free.fr"
>>>
>>>
>>>
>>>
>>>
>>> <philippe.tor...@free.fr> wrote:
>>> > Hello,
>>>
>>> > I have a program, the time of his execution, constructed images, in fact
>>> > files in PPM (P3, plain text mode)
>>> > In short, the program does not deal with the viewing of these images
>>> > (failing to find a library to do ...)
>>>
>>> > So I want to entrust this task to an external application (imview,
>>> > xview, qiv ... etc):
>>>
>>> > res = system ("imview out.ppm");
>>>
>>> > But each time this code is a new process
>>> > image viewer (here imview) that arises.
>>>
>>> > My application is waiting while I close imview to move to
>>> > the next iteration.
>>>
>>> > Well, now you have guessed the question for each passage on the line above,
>>> > I would like the external program (imview, qiv, xview ... whatever), load a new image
>>>
>>> > Regards!
>>>
>>> I'm not real clear on what you're trying to do. �But it sounds like
>>> you want to run imview or some other program once, and have your
>>> program tell that program to display a new image whenever it wants to
>>> display something new. �In order for that to work, the image displayer
>>> has to be set up to accept that kind of communication.
>>>
>>> However, if by "imview" you mean the program documented athttp://hugues.zahlt.info/software_imview.html, that program appears to
>>> have a server mode. �So you'll need to run it in server mode and then
>>> communicate with it via a TCP/IP socket. �The documentation should
>>> explain how to do this, but I haven't looked over it carefully.
>>
>> Oh, yeah, one other thing: if you do this, you won't be able to use
>> system("...") to run imview, because "system" will wait for imview to
>> finish, which will never happen.  You'll need to find a way to spawn
>> imview without having your application wait for it to finish.  There
>> are ways to do this on both Unix/Linux and Windows (you don't say what
>> OS you're using); I think there are probably GNAT library operations
>> to perform that kind of spawning, but someone who's more knowledgeable
>> about GNAT than I am will need to help you with those, if you're using
>> GNAT.  There's no Ada language-defined operations for this.
>>
>>                                 -- Adam
>
>My O.S. is ubuntu.
>
>Damn! Here's what I read in the documentation imview ( server part)
>
>"Instead of having a new instance of imview pop up each time one wants
>to view an image, they can all appear in one, or a small number of
>imview windows. This is great for monitoring progress on a long
>processing run, for doing demos, for debugging an image analysis
>procedure, etc.
>"
>
>Your idea sounds very good!
>
>
>




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: system call
  2011-08-15 19:37       ` anon
@ 2011-08-16 17:18         ` philippe.torgue
  0 siblings, 0 replies; 9+ messages in thread
From: philippe.torgue @ 2011-08-16 17:18 UTC (permalink / raw)




great, I'll try your code soon.

merci beaucoup




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-08-16 17:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-13 18:43 system call philippe.torgue
2011-08-15 15:40 ` Adam Beneschan
2011-08-15 15:46   ` Adam Beneschan
2011-08-15 16:48     ` philippe.torgue
2011-08-15 19:37       ` anon
2011-08-16 17:18         ` philippe.torgue
2011-08-15 16:32   ` philippe.torgue
  -- strict thread matches above, loose matches on Subject: below --
1998-09-28  0:00 System call Adnan
1998-09-30  0:00 ` Dale Stanbrough

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