POV-Ray : Newsgroups : povray.binaries.programming : #system patch Server Time
22 Dec 2024 00:50:56 EST (-0500)
  #system patch (Message 1 to 4 of 4)  
From: Dan Connelly
Subject: #system patch
Date: 23 Aug 1998 14:15:10
Message: <35E04E1D.3E61D477@flash.net>
This is perhaps the simplest patch ever written,
but is nevertheless of considerable power.  It is
an implementation of a "#system" directive -- similar
in syntax to the "#render" directive.  However,
instead of writing the associated string to an
output stream, it uses it as an argument to the
C "system()" function.

The power is that code and/or image generators can be
called from within POV scripts.  Even POV itself could
be recursively called -- those "recursive art" images
which are so popular can thus be fully specified within
a single .pov file.

Other options include the calling of such external codes
as torpatch or gforge from within POV.

Basically, it's a poor man's #macro, but with considerably
extended capabilities.

A very simple UNIX example follows:

-------------------------------------------------

#system "echo parsing about to begin :"
#system "date"


global_settings {
  max_trace_level 12
}

camera {
  location <0, 0, -10>
  look_at <0, 0, 0>
}

light_source {
  <2, 5, -15>
  color rgb 1
}

#system "echo \"sphere {0,1 pigment{color rgb 1}}\" > system_test.inc"
#include "system_test.inc"
#system "echo \"plane {-z,-3 pigment{color rgb <0,1,0>}}\" > system_test.inc"
#include "system_test.inc"

#system "echo parsing done :"
#system "date"

-------------------------------------------------------
A context diff for the patch relative to the tmpov
version of the 3.02 source follows.  It should be
completely trivial to convert it to other 3.02 codes,
and hopefully similarly so for 3.1 codes.

Note there are three changes:

1. In parse.h, add a line assigning a number to the token,
   calling it SYSTEM_TOKEN.
   Increment following tokens (in this case, only LAST_TOKEN)
   to make room for it.

2. in tokenize.c, assign the keyword "system" to SYSTEM_TOKEN.

3. in tokenize.c, repeat the code for DEBUG_TOKEN, changing
   references to DEBUG_TOKEN to SYSTEM_TOKEN, and calling
   system() with the parsed string.


There is no status checking and no capability for piping stdout
into the current POV process, so intermediate files must be
used. 

Dan



*** parse.h     Sun Aug 23 10:57:37 1998
--- parse.h.tmpov       Sun Aug 23 10:54:57 1998
***************
*** 515,525 ****
  #define FUNC_ID_TOKEN                   ( COLOUR_ID_TOKEN + 364 )
  #define JULIA_TEXTURE_TOKEN             ( COLOUR_ID_TOKEN + 365 )
  /* -hdf- Apr 98 */
! #define SLOPE_TOKEN                   ( COLOUR_ID_TOKEN + 366 )
!  /* djconnel 23Aug1998 */
! #define SYSTEM_TOKEN                    ( COLOUR_ID_TOKEN + 367 )
  /* the last token */
! #define LAST_TOKEN                      ( COLOUR_ID_TOKEN + 368 )



--- 515,523 ----
  #define FUNC_ID_TOKEN                   ( COLOUR_ID_TOKEN + 364 )
  #define JULIA_TEXTURE_TOKEN             ( COLOUR_ID_TOKEN + 365 )
  /* -hdf- Apr 98 */
! #define SLOPE_TOKEN                                   ( COLOUR_ID_TOKEN +
366
)
  /* the last token */
! #define LAST_TOKEN                      ( COLOUR_ID_TOKEN + 367 )



*** tokenize.c  Sun Aug 23 11:04:07 1998
--- tokenize.c.tmpov    Sun Aug 23 10:54:08 1998
***************
*** 520,526 ****
    {SUPERELLIPSOID_TOKEN, "superellipsoid"},
    {SWITCH_TOKEN, "switch"},
    {SYS_TOKEN, "sys"},
-   {SYSTEM_TOKEN, "system"},       /* added djconnel 23Aug1998 */
    {T_TOKEN, "t"},
    {TAN_TOKEN, "tan"},
    {TANH_TOKEN,"tanh"},
--- 520,525 ----
***************
*** 2561,2583 ****
        }
        EXIT
      END_CASE
-
-     /* begin added djconnel : 23 Aug 1998 */
-     CASE(SYSTEM_TOKEN)
-       if (Skipping)
-       {
-         UNGET
-         EXIT
-       }
-       else
-       {
-         ts=Parse_Formatted_String();
-         system(ts);
-         POV_FREE(ts);
-       }
-       EXIT
-     END_CASE
-     /* end added djconnel : 23 Aug 1998 */

      OTHERWISE
        UNGET
--- 2560,2565 ----



Dan Connelly
http://www.flash.net/~djconnel


Post a reply to this message

From: Le Forgeron
Subject: Re: #system patch
Date: 27 Nov 2003 09:26:34
Message: <3fc6099a@news.povray.org>


> This is perhaps the simplest patch ever written,
> but is nevertheless of considerable power.  It is
> an implementation of a "#system" directive -- similar
> in syntax to the "#render" directive.  However,
> instead of writing the associated string to an
> output stream, it uses it as an argument to the
> C "system()" function.
> 
> The power is that code and/or image generators can be
> called from within POV scripts.  Even POV itself could
> be recursively called -- those "recursive art" images
> which are so popular can thus be fully specified within
> a single .pov file.
> 
> Other options include the calling of such external codes
> as torpatch or gforge from within POV.
> 
> Basically, it's a poor man's #macro, but with considerably
> extended capabilities.

It's also a can of worms for viral infection...
I guess your next step will be to have an 'emacs'-like command 
extension in the pov code, just to read the newsgroup in 
pov-script...

IMNSHO, "#system" is dangerous and unwanted.


Post a reply to this message

From: ABX
Subject: Re: #system patch
Date: 27 Nov 2003 09:45:38
Message: <kb3csvc25io4tm404178hlihga61ehmkau@4ax.com>
On Thu, 27 Nov 2003 15:26:33 +0100, Le Forgeron <jgr### [at] freefr> wrote:
> It's also a can of worms for viral infection...
> I guess your next step will be to have an 'emacs'-like command 
> extension in the pov code, just to read the newsgroup in 
> pov-script...
>
> IMNSHO, "#system" is dangerous and unwanted.

Jerome, please look into settings of your news reader. You have answered to
five years old message.

ABX


Post a reply to this message

From: Peter Popov
Subject: Re: #system patch
Date: 29 Nov 2003 05:40:40
Message: <sqtgsv02jqnj9k5fbbi2dhhc34asfssnt9@4ax.com>
On Thu, 27 Nov 2003 15:44:04 +0100, ABX <abx### [at] abxartpl> wrote:

>Jerome, please look into settings of your news reader. You have answered to
>five years old message.

Oh drats, and I thought Dan was back :-/


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.