void POVMS_List::Append(POVMS_Object& item)
{
	int err;

	err = POVMSAttrList_Append(&data, &item.data);
	if(err != kNoErr)
		throw err;

	item.DetachData();
}
Example #2
0
void POVMS_List::Append(POVMS_Object& item)
{
    int err;

    err = POVMSAttrList_Append(&data, &item.data);
    if(err != pov_base::kNoErr)
        throw POV_EXCEPTION_CODE(err);

    item.DetachData();
}
Example #3
0
int AddOIStatistic(POVMSAttributeListPtr list, int index, COUNTER *pstats)
{
   POVMSObject obj;
   int err;

   err = POVMSObject_New(&obj, kPOVObjectClass_OIStat);
   if(err == kNoErr)
      err = POVMSUtil_SetString(&obj, kPOVAttrib_ObjectName, intersection_stats[index].infotext);
   if(err == kNoErr)
      err = POVMSUtil_SetInt(&obj, kPOVAttrib_ObjectID, intersection_stats[index].povms_id);
   if(err == kNoErr)
      err = POVMSUtil_SetLong(&obj, kPOVAttrib_ISectsTests, pstats[intersection_stats[index].stat_test_id]);
   if(err == kNoErr)
      err = POVMSUtil_SetLong(&obj, kPOVAttrib_ISectsSucceeded, pstats[intersection_stats[index].stat_suc_id]);
   if(err == kNoErr)
      err = POVMSAttrList_Append(list, &obj);

   return err;
}
Example #4
0
void Send_InitInfo()
{
   POVMSAttributeList attrlist;
   POVMSAttribute attr;
   POVMSObject msg;
   int err = kNoErr;

   if(err == kNoErr)
      err = POVMSObject_New(&msg, kPOVMSType_WildCard);

   if(err == kNoErr)
      err = POVMSUtil_SetString(&msg, kPOVAttrib_PlatformName, POVRAY_PLATFORM_NAME);
   if(err == kNoErr)
      err = POVMSUtil_SetFormatString(&msg, kPOVAttrib_CoreVersion,
                                      "Persistence of Vision(tm) Ray Tracer Version %s%s", POV_RAY_VERSION, COMPILER_VER);
   if(err == kNoErr)
      err = POVMSUtil_SetString(&msg, kPOVAttrib_EnglishText,
                                DISTRIBUTION_MESSAGE_1 "\n" DISTRIBUTION_MESSAGE_2 "\n" DISTRIBUTION_MESSAGE_3
                                "\nPOV-Ray is based on DKBTrace 2.12 by David K. Buck & Aaron A. Collins\n" POV_RAY_COPYRIGHT);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(&msg, kPOVAttrib_Official, POV_RAY_IS_OFFICIAL);

   if(err == kNoErr)
      err = POVMSAttrList_New(&attrlist);
   if(err == kNoErr)
   {
      for(int i = 0; Primary_Developers[i] != NULL; i++)
      {
         err = POVMSAttr_New(&attr);
         if(err == kNoErr)
         {
            err = POVMSAttr_Set(&attr, kPOVMSType_CString, Primary_Developers[i], strlen(Primary_Developers[i]) + 1);
            if(err == kNoErr)
               err = POVMSAttrList_Append(&attrlist, &attr);
            else
               err = POVMSAttr_Delete(&attr);
         }
      }
   }
   if(err == kNoErr)
      err = POVMSObject_Set(&msg, &attrlist, kPOVAttrib_PrimaryDevs);

   if(err == kNoErr)
      err = POVMSAttrList_New(&attrlist);
   if(err == kNoErr)
   {
      for(int i = 0; Contributing_Authors[i] != NULL; i++)
      {
         err = POVMSAttr_New(&attr);
         if(err == kNoErr)
         {
            err = POVMSAttr_Set(&attr, kPOVMSType_CString, Contributing_Authors[i], strlen(Contributing_Authors[i]) + 1);
            if(err == kNoErr)
               err = POVMSAttrList_Append(&attrlist, &attr);
            else
               err = POVMSAttr_Delete(&attr);
         }
      }
   }
   if(err == kNoErr)
      err = POVMSObject_Set(&msg, &attrlist, kPOVAttrib_ContributingDevs);

   if(err == kNoErr)
      err = POVMSAttrList_New(&attrlist);
#ifndef DONT_SHOW_IMAGE_LIB_VERSIONS
   // ZLib library version and copyright notice
   if(err == kNoErr)
   {
      err = POVMSAttr_New(&attr);
      if(err == kNoErr)
      {
         const char *tempstr = pov_tsprintf("ZLib %s, Copyright 1995-1998 Jean-loup Gailly and Mark Adler", Extract_Version(zlibVersion()));
         err = POVMSAttr_Set(&attr, kPOVMSType_CString, (void *)tempstr, strlen(tempstr) + 1);
         if(err == kNoErr)
            err = POVMSAttrList_Append(&attrlist, &attr);
         else
            err = POVMSAttr_Delete(&attr);
      }
   }
   // LibPNG library version and copyright notice
   if(err == kNoErr)
   {
      err = POVMSAttr_New(&attr);
      if(err == kNoErr)
      {
         const char *tempstr = pov_tsprintf("LibPNG %s, Copyright 1998-2002 Glenn Randers-Pehrson", Extract_Version(png_get_libpng_ver(NULL)));
         err = POVMSAttr_Set(&attr, kPOVMSType_CString, (void *)tempstr, strlen(tempstr) + 1);
         if(err == kNoErr)
            err = POVMSAttrList_Append(&attrlist, &attr);
         else
            err = POVMSAttr_Delete(&attr);
      }
   }
   // LibJPEG library version and copyright notice
   if(err == kNoErr)
   {
      err = POVMSAttr_New(&attr);
      if(err == kNoErr)
      {
         const char *tempstr = pov_tsprintf("LibJPEG %s, Copyright 1998 Thomas G. Lane", Extract_Version(JVERSION));
         err = POVMSAttr_Set(&attr, kPOVMSType_CString, (void *)tempstr, strlen(tempstr) + 1);
         if(err == kNoErr)
            err = POVMSAttrList_Append(&attrlist, &attr);
         else
            err = POVMSAttr_Delete(&attr);
      }
   }
   // LibTIFF library version and copyright notice
   if(err == kNoErr)
   {
      err = POVMSAttr_New(&attr);
      if(err == kNoErr)
      {
         const char *tempstr = pov_tsprintf("LibTIFF %s, Copyright 1988-1997 Sam Leffler, 1991-1997 SGI", Extract_Version(TIFFGetVersion()));
         err = POVMSAttr_Set(&attr, kPOVMSType_CString, (void *)tempstr, strlen(tempstr) + 1);
         if(err == kNoErr)
            err = POVMSAttrList_Append(&attrlist, &attr);
         else
            err = POVMSAttr_Delete(&attr);
      }
   }
#endif
   if(err == kNoErr)
      err = POVMSObject_Set(&msg, &attrlist, kPOVAttrib_ImageLibVersions);

   if(err == kNoErr)
      err = POVMSMsg_SetupMessage(&msg, kPOVMsgClass_Miscellaneous, kPOVMsgIdent_InitInfo);
   if(err == kNoErr)
      err = POVMSMsg_SetDestinationAddress(&msg, FRONTEND_ADDRESS);

   if(err == kNoErr)
      err = POVMS_Send(POVMS_Render_Context, &msg, NULL, kPOVMSSendMode_NoReply);

   if(err != 0)
      (void)POVMS_ASSERT_OUTPUT("Sending InitInfo failed!", "povmsend.cpp", 0);
}
Example #5
0
int BuildRenderOptions(POVMSObjectPtr msg)
{
   POVMSAttribute attr;
   int err = kNoErr;

   if(msg == NULL)
      return kParamErr;

   if(err == kNoErr)
      err = POVMSAttr_New(&attr);
   if(err == kNoErr)
   {
      err = POVMSAttr_Set(&attr, kPOVMSType_WildCard, (void *)(&opts.Preview_RefCon), sizeof(unsigned long));
      if(err == kNoErr)
         err = POVMSObject_Set(msg, &attr, kPOVAttrib_PreviewRefCon);
   }
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_Height, Frame.Screen_Height);
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_Width, Frame.Screen_Width);
   if(err == kNoErr)
   {
      if (opts.First_Column == -1)
         err = POVMSUtil_SetFloat(msg, kPOVAttrib_StartColumn, opts.First_Column_Percent);
      else
         err = POVMSUtil_SetFloat(msg, kPOVAttrib_StartColumn, opts.First_Column);
   }
   if(err == kNoErr)
   {
      if (opts.Last_Column == -1)
         err = POVMSUtil_SetFloat(msg, kPOVAttrib_EndColumn, opts.Last_Column_Percent);
      else
         err = POVMSUtil_SetFloat(msg, kPOVAttrib_EndColumn, opts.Last_Column);
   }
   if(err == kNoErr)
   {
      if (opts.First_Line == -1)
         err = POVMSUtil_SetFloat(msg, kPOVAttrib_StartRow, opts.First_Line_Percent);
      else
         err = POVMSUtil_SetFloat(msg, kPOVAttrib_StartRow, opts.First_Line);
   }
   if(err == kNoErr)
   {
      if (opts.Last_Line == -1)
         err = POVMSUtil_SetFloat(msg, kPOVAttrib_EndRow, opts.Last_Line_Percent);
      else
         err = POVMSUtil_SetFloat(msg, kPOVAttrib_EndRow, opts.Last_Line);
   }
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_TestAbort, (opts.Options & EXITENABLE) != 0);
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_TestAbortCount, opts.Abort_Test_Counter);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_ContinueTrace, (opts.Options & CONTINUE_TRACE) != 0);
   if(err == kNoErr)
      err = POVMSUtil_SetString(msg, kPOVAttrib_CreateIni, opts.Ini_Output_File_Name);
   if(err == kNoErr)
      err = POVMSUtil_SetFloat(msg, kPOVAttrib_Clock, opts.FrameSeq.Clock_Value);
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_InitialFrame, max(opts.FrameSeq.InitialFrame, 1));
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_FinalFrame, max(opts.FrameSeq.FinalFrame, 1));
   if(err == kNoErr)
      err = POVMSUtil_SetFloat(msg, kPOVAttrib_InitialClock, opts.FrameSeq.InitialClock);
   if(err == kNoErr)
   {
      if(opts.FrameSeq.FinalFrame <= 1)
         err = POVMSUtil_SetFloat(msg, kPOVAttrib_FinalClock, 1.0);
      else
         err = POVMSUtil_SetFloat(msg, kPOVAttrib_FinalClock, opts.FrameSeq.FinalClock);
   }
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_SubsetStartFrame, max(opts.FrameSeq.SubsetStartFrame, 1));
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_SubsetEndFrame, max(opts.FrameSeq.SubsetEndFrame, 1));
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_CyclicAnimation, (opts.Options & CYCLIC_ANIMATION) != 0);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_FieldRender, opts.FrameSeq.Field_Render_Flag);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_OddField, opts.FrameSeq.Odd_Field_Flag);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_PauseWhenDone, (opts.Options & PROMPTEXIT) != 0);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_Verbose, (opts.Options & VERBOSE) != 0);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_DrawVistas, (opts.Options & USE_VISTA_DRAW) != 0);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_Display, (opts.Options & DISPLAY) != 0);
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_VideoMode, opts.DisplayFormat);
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_Palette, opts.PaletteOption);
   if(err == kNoErr)
      err = POVMSUtil_SetFloat(msg, kPOVAttrib_DisplayGamma, opts.DisplayGamma);
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_PreviewStartSize, opts.PreviewGridSize_Start);
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_PreviewEndSize, opts.PreviewGridSize_End);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_OutputToFile, (opts.Options & DISKWRITE) != 0);
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_OutputFileType, opts.OutputFormat);
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_Compression, opts.OutputQuality);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_OutputAlpha, (opts.Options & OUTPUT_ALPHA) != 0);
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_BitsPerColor, opts.OutputQuality);
   if(err == kNoErr)
      err = POVMSUtil_SetString(msg, kPOVAttrib_OutputFile, opts.Output_File_Name);
   if(err == kNoErr)
      err = POVMSUtil_SetString(msg, kPOVAttrib_OutputPath, opts.Output_Path);
#if PRECISION_TIMER_AVAILABLE
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_CreateHistogram, opts.histogram_on != 0);
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_HistogramFileType, opts.histogram_type);
   if(err == kNoErr)
      err = POVMSUtil_SetString(msg, kPOVAttrib_HistogramFile, opts.Histogram_File_Name);
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_HistogramGridSizeX, opts.histogram_x);
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_HistogramGridSizeY, opts.histogram_y);
#endif /* PRECISION_TIMER_AVAILABLE */
   if(err == kNoErr)
      err = BuildCommand(msg, kPOVAttrib_PreSceneCommand, &opts.Shellouts[PRE_SCENE_SHL]);
   if(err == kNoErr)
      err = BuildCommand(msg, kPOVAttrib_PreFrameCommand, &opts.Shellouts[PRE_FRAME_SHL]);
   if(err == kNoErr)
      err = BuildCommand(msg, kPOVAttrib_PostSceneCommand, &opts.Shellouts[POST_SCENE_SHL]);
   if(err == kNoErr)
      err = BuildCommand(msg, kPOVAttrib_PostFrameCommand, &opts.Shellouts[POST_FRAME_SHL]);
   if(err == kNoErr)
      err = BuildCommand(msg, kPOVAttrib_UserAbortCommand, &opts.Shellouts[USER_ABORT_SHL]);
   if(err == kNoErr)
      err = BuildCommand(msg, kPOVAttrib_FatalErrorCommand, &opts.Shellouts[FATAL_SHL]);
   if(err == kNoErr)
      err = POVMSUtil_SetString(msg, kPOVAttrib_InputFile, opts.Input_File_Name);
   if(err == kNoErr)
   {
      POVMSAttributeList list;

      err = POVMSAttrList_New(&list);
      if(err == kNoErr)
      {
         int ii;

         for(ii = 0; ii < opts.Library_Path_Index; ii++)
         {
            err = POVMSAttr_New(&attr);
            if(err == kNoErr)
            {
               err = POVMSAttr_Set(&attr, kPOVMSType_CString, opts.Library_Paths[ii], strlen(opts.Library_Paths[ii]) + 1);
               if(err == kNoErr)
                  err = POVMSAttrList_Append(&list, &attr);
               else
                  err = POVMSAttr_Delete(&attr);
            }
         }
         if(err == kNoErr)
            err = POVMSObject_Set(msg, &list, kPOVAttrib_LibraryPath);
      }
   }
   if(err == kNoErr)
   {
      POVMSFloat f = opts.Language_Version / 100.0;
      err = POVMSUtil_SetFloat(msg, kPOVAttrib_Version, f);
   }
/* FIXME
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_DebugConsole, Stream_Info[DEBUG_STREAM]->console != NULL);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_FatalConsole, Stream_Info[FATAL_STREAM]->console != NULL);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_RenderConsole, Stream_Info[RENDER_STREAM]->console != NULL);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_StatisticsConsole, Stream_Info[STATISTIC_STREAM]->console != NULL);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_WarningConsole, Stream_Info[WARNING_STREAM]->console != NULL);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_AllConsole, Stream_Info[ALL_STREAM]->console != NULL);
   if((err == kNoErr) && (Stream_Info[DEBUG_STREAM]->name != NULL))
      err = POVMSUtil_SetString(msg, kPOVAttrib_DebugFile, Stream_Info[DEBUG_STREAM]->name);
   if((err == kNoErr) && (Stream_Info[FATAL_STREAM]->name != NULL))
      err = POVMSUtil_SetString(msg, kPOVAttrib_FatalFile, Stream_Info[FATAL_STREAM]->name);
   if((err == kNoErr) && (Stream_Info[RENDER_STREAM]->name != NULL))
      err = POVMSUtil_SetString(msg, kPOVAttrib_RenderFile, Stream_Info[RENDER_STREAM]->name);
   if((err == kNoErr) && (Stream_Info[STATISTIC_STREAM]->name != NULL))
      err = POVMSUtil_SetString(msg, kPOVAttrib_StatisticsFile, Stream_Info[STATISTIC_STREAM]->name);
   if((err == kNoErr) && (Stream_Info[WARNING_STREAM]->name != NULL))
      err = POVMSUtil_SetString(msg, kPOVAttrib_WarningFile, Stream_Info[WARNING_STREAM]->name);
   if((err == kNoErr) && (Stream_Info[ALL_STREAM]->name != NULL))
      err = POVMSUtil_SetString(msg, kPOVAttrib_AllFile, Stream_Info[ALL_STREAM]->name);
*/   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_Quality, opts.Quality);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_Bounding, opts.Use_Slabs);
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_BoundingThreshold, opts.BBox_Threshold);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_LightBuffer, (opts.Options & USE_LIGHT_BUFFER) != 0);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_VistaBuffer, (opts.Options & USE_VISTA_BUFFER) != 0);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_RemoveBounds, (opts.Options & REMOVE_BOUNDS) != 0);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_SplitUnions, (opts.Options & SPLIT_UNION) != 0);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_Antialias, (opts.Options & ANTIALIAS) != 0);
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_SamplingMethod, opts.Tracing_Method);
   if(err == kNoErr)
      err = POVMSUtil_SetFloat(msg, kPOVAttrib_AntialiasThreshold, opts.Antialias_Threshold);
   if(err == kNoErr)
      err = POVMSUtil_SetInt(msg, kPOVAttrib_AntialiasDepth, opts.AntialiasDepth);
   if(err == kNoErr)
      err = POVMSUtil_SetBool(msg, kPOVAttrib_Jitter, (opts.Options & JITTER) != 0);
   if(err == kNoErr)
      err = POVMSUtil_SetFloat(msg, kPOVAttrib_JitterAmount, opts.JitterScale);
   if(err == kNoErr)
      err = POVMSUtil_SetString(msg, kPOVAttrib_IncludeHeader, opts.Header_File_Name);

   return err;
}
Example #6
0
int ProcessRenderOptions::ProcessUnknownString(char *str, POVMSObjectPtr obj)
{
    POVMSAttributeList list;
    POVMSAttribute attr;
    int state = 0; // INI file
    int err = kNoErr;

    if(str == NULL)
    {
        ParseError("Expected filename, nothing was found.");
        return kParseErr;
    }

    // add filename or path

    // see if it is a POV file
    if(state == 0)
    {
        char *ptr = strrchr(str, '.');
        if(ptr != NULL)
        {
            if(pov_stricmp(ptr, ".pov") == 0)
                state = 1; // POV file
        }
    }

    // see if it is a path
    if(state == 0)
    {
        if(strlen(str) > 0)
        {
            if(str[strlen(str) - 1] == FILENAME_SEPARATOR)
                state = 2; // library path
        }
    }

    switch(state)
    {
    // INI file
    case 0:
        // parse INI file (recursive)
        err = ParseFile(str, obj);
        if(err == kNoErr)
        {
            // create list if it isn't there
            if(POVMSObject_Exist(obj, kPOVAttrib_IncludeIni) == kFalseErr)
                err = POVMSAttrList_New(&list);
            else if(POVMSObject_Exist(obj, kPOVAttrib_IncludeIni) != kNoErr)
                err = kObjectAccessErr;
            else
                err = POVMSObject_Get(obj, &list, kPOVAttrib_IncludeIni);
        }

        // add INI file to list
        if(err == kNoErr)
            err = POVMSAttr_New(&attr);
        if(err == kNoErr)
        {
            err = POVMSAttr_Set(&attr, kPOVMSType_CString, str, strlen(str) + 1);
            if(err == kNoErr)
                err = POVMSAttrList_Append(&list, &attr);
            else
                err = POVMSAttr_Delete(&attr);
        }
        if(err == kNoErr)
            err = POVMSObject_Set(obj, &list, kPOVAttrib_IncludeIni);
        break;
    // POV file
    case 1:
        // set POV file
        err = POVMSUtil_SetString(obj, kPOVAttrib_InputFile, str);
        break;
    // library path
    case 2:
        // create list if it isn't there
        if(POVMSObject_Exist(obj, kPOVAttrib_LibraryPath) == kFalseErr)
            err = POVMSAttrList_New(&list);
        else if(POVMSObject_Exist(obj, kPOVAttrib_LibraryPath) != kNoErr)
            err = kObjectAccessErr;
        else
            err = POVMSObject_Get(obj, &list, kPOVAttrib_LibraryPath);

        // add librarypath to list
        if(err == kNoErr)
            err = POVMSAttr_New(&attr);
        if(err == kNoErr)
        {
            err = POVMSAttr_Set(&attr, kPOVMSType_CString, str, strlen(str) + 1);
            if(err == kNoErr)
                err = POVMSAttrList_Append(&list, &attr);
            else
                err = POVMSAttr_Delete(&attr);
        }
        if(err == kNoErr)
            err = POVMSObject_Set(obj, &list, kPOVAttrib_LibraryPath);
        break;
    }

    return err;
}
Example #7
0
int ProcessRenderOptions::ReadSpecialSwitchHandler(Cmd_Parser_Table *option, char *param, POVMSObjectPtr obj, bool)
{
    int intval = 0;
    int intval2 = 0;
    int err = 0;
    char chr = 0;

    switch(option->key)
    {
    case kPOVAttrib_Display:
        if(param[0] != '\0')
        {
            err = POVMSUtil_SetInt(obj, kPOVAttrib_VideoMode, (int)toupper(param[0]));
            if((param[1] != '\0') && (err == 0))
                err = POVMSUtil_SetInt(obj, kPOVAttrib_Palette, (int)toupper(param[1]));
        }
        break;
    case kPOVAttrib_HistogramGridSizeX:
        if(sscanf(param, "%d.%d", &intval, &intval2) == 2)
        {
            err = POVMSUtil_SetInt(obj, kPOVAttrib_HistogramGridSizeX, intval);
            if(err == kNoErr)
                err = POVMSUtil_SetInt(obj, kPOVAttrib_HistogramGridSizeY, intval2);
        }
        else
        {
            ParseError("Invalid histogram grid size '%s'.", param);
            err = kParseErr;
        }
        break;
    case kPOVAttrib_OutputFileType:
        if(strchr(Output_File_Types, *param) == NULL)
            ParseError("Unrecognized output file format %c.", *param);
        err = POVMSUtil_SetInt(obj, option->key, tolower(*param));
        param++;
        if((err == kNoErr) && (*param > ' '))
        {
            if(isdigit(*param) != 0)
            {
                if(sscanf(param, "%d", &intval) == 1)
                    err = POVMSUtil_SetInt(obj, kPOVAttrib_BitsPerColor, intval);
                else
                {
                    ParseError("Invalid bits per color '%s'.", param);
                    err = kParseErr;
                }
            }
            else
            {
                ParseError("Missing bits per color, '%s' found instead.", param);
                err = kParseErr;
            }
        }
        break;
    case kPOVAttrib_HistogramFileType:
        if(strchr(Output_File_Types, *param) == NULL)
        {
            ParseError("Unrecognized output file format %c.", *param);
            err = kParseErr;
        }
        else
        {
            chr = tolower(*param);
            err = POVMSUtil_SetInt(obj, option->key, chr);
        }
        break;
    case kPOVAttrib_LibraryPath:
        POVMSAttributeList list;
        POVMSAttribute attr;

        if(err == kNoErr)
        {
            // create list if it isn't there
            if(POVMSObject_Exist(obj, option->key) == kFalseErr)
                err = POVMSAttrList_New(&list);
            else if(POVMSObject_Exist(obj, option->key) != kNoErr)
                err = kObjectAccessErr;
            else
                err = POVMSObject_Get(obj, &list, option->key);
        }
        else
        {
            ParseError("File name or path parameter expected for switch '%s', found '%s'.", option->command, param);
            err = kParseErr;
        }

        // add path or file to list
        if(err == kNoErr)
            err = POVMSAttr_New(&attr);
        if(err == kNoErr)
        {
            err = POVMSAttr_Set(&attr, kPOVMSType_CString, (void *)param, strlen(param) + 1);
            if(err == kNoErr)
                err = POVMSAttrList_Append(&list, &attr);
            else
                err = POVMSAttr_Delete(&attr);
        }
        if(err == kNoErr)
            err = POVMSObject_Set(obj, &list, option->key);
        break;
    case kPOVAttrib_TestAbortCount:
        if((*param) == 0)
            break;
        if(sscanf(param, "%d", &intval) == 1)
            err = POVMSUtil_SetInt(obj, option->key, intval);
        else
        {
            ParseError("No or integer parameter expected for switch '%s', found '%s'.", option->command, param);
            err = kParseErr;
        }
        break;
    }

    return err;
}
Example #8
0
int ProcessRenderOptions::ReadSpecialOptionHandler(INI_Parser_Table *option, char *param, POVMSObjectPtr obj)
{
    POVMSAttributeList list;
    double floatval = 0.0;
    int intval = 0;
    int intval2 = 0;
    int err = kNoErr;

    switch(option->key)
    {
    case kPOVAttrib_HistogramGridSizeX:
        if(sscanf(param, "%d.%d", &intval, &intval2) == 2)
        {
            err = POVMSUtil_SetInt(obj, kPOVAttrib_HistogramGridSizeX, intval);
            if(err == kNoErr)
                err = POVMSUtil_SetInt(obj, kPOVAttrib_HistogramGridSizeY, intval2);
        }
        else
        {
            ParseError("Invalid histogram grid size '%s'.", param);
            err = kParseErr;
        }
        break;
    case kPOVAttrib_Palette:
    case kPOVAttrib_VideoMode:
        while(isspace(*param))
            param++;
        err = POVMSUtil_SetInt(obj, option->key, tolower(*param));
        break;
    case kPOVAttrib_HistogramFileType:
    case kPOVAttrib_OutputFileType:
        while(isspace(*param))
            param++;
        if(strchr(Output_File_Types, *param) == NULL)
            ParseError("Unrecognized output file format %c.", *param);
        err = POVMSUtil_SetInt(obj, option->key, tolower(*param));
        break;
    case kPOVAttrib_IncludeIni:
    case kPOVAttrib_LibraryPath:
        POVMSAttribute attr;

        if(err == kNoErr)
        {
            // parse INI file (recursive)
            if(option->key == kPOVAttrib_IncludeIni)
                err = ParseFile(param, obj);

            // create list if it isn't there
            if(err == kNoErr)
            {
                if(POVMSObject_Exist(obj, option->key) == kFalseErr)
                    err = POVMSAttrList_New(&list);
                else if(POVMSObject_Exist(obj, option->key) != kNoErr)
                    err = kObjectAccessErr;
                else
                    err = POVMSObject_Get(obj, &list, option->key);
            }
        }
        else
        {
            ParseError("File name or path parameter expected for option '%s', found '%s'.", option->keyword, param);
            err = kParseErr;
        }

        // add path or file to list
        if(err == kNoErr)
            err = POVMSAttr_New(&attr);
        if(err == kNoErr)
        {
            err = POVMSAttr_Set(&attr, kPOVMSType_CString, (void *)param, strlen(param) + 1);
            if(err == kNoErr)
                err = POVMSAttrList_Append(&list, &attr);
            else
                err = POVMSAttr_Delete(&attr);
        }
        if(err == kNoErr)
            err = POVMSObject_Set(obj, &list, option->key);
        break;
    case kPOVAttrib_Declare:
        POVMSObject decobj;

        // create list if it isn't there
        if(POVMSObject_Exist(obj, option->key) == kFalseErr)
            err = POVMSAttrList_New(&list);
        else if(POVMSObject_Exist(obj, option->key) != kNoErr)
            err = kObjectAccessErr;
        else
            err = POVMSObject_Get(obj, &list, option->key);

        // add value to list
        if(err == kNoErr)
            err = POVMSObject_New(&decobj, kPOVMSType_WildCard);
        if(err == kNoErr)
        {
            char *ptr = NULL;

            err = POVMSUtil_SetString(&decobj, kPOVAttrib_Identifier, strtok(param, "="));
            if(err == kNoErr)
            {
                ptr = strtok(NULL, "");
                if(ptr == NULL)
                    err = kParseErr;
            }
            if(err == kNoErr)
            {
                if(strchr(ptr, '"') != NULL)
                {
                    ptr = strchr(ptr, '"') + 1;
                    strtok(ptr, "\"");
                    err = POVMSUtil_SetString(&decobj, kPOVAttrib_Value, ptr);
                }
                else
                    err = POVMSUtil_SetFloat(&decobj, kPOVAttrib_Value, atof(ptr));
            }
            if(err == kNoErr)
                err = POVMSAttrList_Append(&list, &decobj);
            else
                err = POVMSObject_Delete(&decobj);
        }
        if(err == kNoErr)
            err = POVMSObject_Set(obj, &list, option->key);
        break;
    case kPOVAttrib_FatalErrorCommand:
    case kPOVAttrib_PostFrameCommand:
    case kPOVAttrib_PostSceneCommand:
    case kPOVAttrib_PreFrameCommand:
    case kPOVAttrib_PreSceneCommand:
    case kPOVAttrib_UserAbortCommand:
        POVMSObject cmdobj;

        if(POVMSObject_Exist(obj, option->key) == kNoErr)
            err = POVMSObject_Get(obj, &cmdobj, option->key);
        else
            err = POVMSObject_New(&cmdobj, kPOVMSType_WildCard);
        if(toupper(*(option->keyword + strlen(option->keyword) - 1)) == 'D')
        {
            if(err == kNoErr)
                err = POVMSUtil_SetString(&cmdobj, kPOVAttrib_CommandString, param);
        }
        else
        {
            if(err == kNoErr)
            {
                int i = 0;

                if((*param == '-') || (*param == '!'))
                    i = tolower(*(param + 1));
                else
                    i = tolower(*param);
                err = POVMSUtil_SetInt(&cmdobj, kPOVAttrib_ReturnAction, i);
            }
        }
        if(err == kNoErr)
            err = POVMSObject_Set(obj, &cmdobj, option->key);
        break;
    }

    return err;
}