home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / POV-Ray 3.0.2 / src / MacSource / PrePost.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-07  |  4.4 KB  |  170 lines  |  [TEXT/CWIE]

  1. /*==============================================================================
  2. Project:    POV
  3.  
  4. Version:    3
  5.  
  6. File:    PrePost.c
  7.  
  8. Description:
  9.     Routines called back out from inside the engine during its processing.
  10. ------------------------------------------------------------------------------
  11. Author:
  12.     Eduard [esp] Schwan
  13. ------------------------------------------------------------------------------
  14.     from Persistence of Vision(tm) Ray Tracer
  15.     Copyright 1996 Persistence of Vision Team
  16. ------------------------------------------------------------------------------
  17.     NOTICE: This source code file is provided so that users may experiment
  18.     with enhancements to POV-Ray and to port the software to platforms other 
  19.     than those supported by the POV-Ray Team.  There are strict rules under
  20.     which you are permitted to use this file.  The rules are in the file
  21.     named POVLEGAL.DOC which should be distributed with this file. If 
  22.     POVLEGAL.DOC is not available or for more info please contact the POV-Ray
  23.     Team Coordinator by leaving a message in CompuServe's Graphics Developer's
  24.     Forum.  The latest version of POV-Ray may be found there as well.
  25.  
  26.     This program is based on the popular DKB raytracer version 2.12.
  27.     DKBTrace was originally written by David K. Buck.
  28.     DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
  29. ------------------------------------------------------------------------------
  30. Change History:
  31.     960428    [esp]    Created
  32.     960422    [esp]    Added POVRAY.INI processing
  33. ==============================================================================*/
  34.  
  35.  
  36. #define PREPOST_C
  37.  
  38. #include "PrePost.H"
  39.  
  40. /*==== POV-Ray std headers ====*/
  41. #include "config.h"
  42. #include "povray.h"        // SHELLTYPE
  43. #include "optin.h"        // parse_ini_file
  44. // #include "AppPrefs.h"    // slc added, missing type
  45.  
  46. /*==== Standard C headers ====*/
  47. #include <stdlib.h>
  48.  
  49.  
  50. // ---------------------------------------------------------------------
  51. int Mac_Shellout(int shellType)
  52. {
  53.   int rCode;
  54.  
  55.   switch(shellType) // SHELLTYPE
  56.   {
  57.     case PRE_SCENE_SHL:  // "pre-scene"
  58.     break;
  59.     case PRE_FRAME_SHL:  // "pre-frame"
  60.     break;
  61.     case POST_FRAME_SHL: // "post-frame"
  62.     break;
  63.     case POST_SCENE_SHL: // "post-scene"
  64.     break;
  65.     case USER_ABORT_SHL: // "user about"
  66.      break;
  67.     case FATAL_SHL:      // "fatal error"
  68.     break;
  69.   }
  70.  
  71. //  printf("### pov_mac_shellout called --> '%d'\n", s_type);
  72.  
  73.   rCode=Mac_SystemCall("-!-");
  74.  
  75.   return rCode;
  76. }
  77.  
  78.  
  79. // ---------------------------------------------------------------------
  80. int Mac_SystemCall(char * cmdstr)
  81. {
  82. #pragma unused(cmdstr)
  83. /*( typedef SHELLRET )
  84.   IGNORE_RET = 0,
  85.   QUIT_RET,
  86.   USER_RET,
  87.   FATAL_RET,
  88.   SKIP_ONCE_RET,
  89.   ALL_SKIP_RET
  90. */
  91. // printf("### Doing Mac shell command --> '%s'\n", cmdstr);
  92.     return IGNORE_RET;
  93. }
  94.  
  95.  
  96. // ---------------------------------------------------------------------
  97. // see if file exists in current/default folder
  98. int File_Exists(char * fileName)
  99.     {
  100.     int    retVal;
  101.     FILE    *f;
  102.  
  103.     // The simplest (but slow) way to tell if a file exists is to try to open it
  104.     f = fopen(fileName, "r");
  105.     if (f)
  106.         {
  107.         fclose(f); // didn't really want to open, sorry, never mind, bye.
  108.         retVal = true;    // exists
  109.         }
  110.     else
  111.         retVal = false;    // doesn't exist
  112.     return retVal;
  113.     }
  114.  
  115.  
  116.  
  117. // ---------------------------------------------------------------------
  118. // Get default POVRAY.INI filename from resource (not READ_ENV_VAR), and
  119. // pass it on to engine to read if it exists.
  120. void Mac_Process_Povray_Ini(void)
  121.     {
  122.     OSErr    anError    = noErr;
  123.     short    saveVRefNum;
  124.     long    saveDirID;
  125.     Str255    iniFileName;
  126.  
  127.     // read it from the STR# resource
  128.     GetIndString(iniFileName, kSTRI_FileNames, kSTRIi_POVRAY_INI);
  129.     anError = ResError();
  130.  
  131.     if (!anError)
  132.         {
  133.         // remember current folder, since we're about to change it
  134.         anError = HGetVol((StringPtr)NULL, &saveVRefNum, &saveDirID);
  135.  
  136.         // now look for "POVRAY.INI" in the application directory
  137.         SetCurrentDirToAppDir();
  138.  
  139.         if (!anError)
  140.             {
  141.             // convert it to a C string
  142.             p2cstr(iniFileName);
  143.             // now call the file parser to handle it
  144.             parse_ini_file((char*)iniFileName);
  145.             }
  146.  
  147.         // reset current folder
  148.         anError = HSetVol((StringPtr)NULL, saveVRefNum, saveDirID);
  149.         }
  150.     }
  151.  
  152.  
  153. // ---------------------------------------------------------------------
  154. void Mac_PreRender(void)
  155. {
  156. }
  157.  
  158.  
  159. // ---------------------------------------------------------------------
  160. void Mac_PreShutdown(void)
  161. {
  162. }
  163.  
  164.  
  165. // ---------------------------------------------------------------------
  166. void Mac_PostShutdown(void)
  167. {
  168. }
  169.  
  170.