Example #1
0
int main(int argc, char **argv) {
  struct RDArgs *rdargs = NULL;
  int i;
  char pubscreen[32];

  if(argc) {
    rdargs=ReadArgs( TEMPLATE , (LONG *) &args, NULL);
    SaveIcons  = FALSE;
  }
  else {
    struct WBStartup *WBenchMsg = (struct WBStartup *)argv;
    struct WBArg *wbarg;
    BPTR olddir;
    struct DiskObject *dobj;
    STRPTR* toolarray;
    UBYTE *s;

    SaveIcons  = TRUE;

    for(i=0, wbarg=WBenchMsg->sm_ArgList;
      i < WBenchMsg->sm_NumArgs;
      i++, wbarg++) {

      olddir = (BPTR) -1;
      if((wbarg->wa_Lock)&&(*wbarg->wa_Name))
          olddir = CurrentDir(wbarg->wa_Lock);


      if((*wbarg->wa_Name) && (dobj=GetDiskObject(wbarg->wa_Name))) {
        toolarray = dobj->do_ToolTypes;

        s = FindToolType(toolarray,"CREATEICONS");

        if( s != NULL ) {
          if( MatchToolValue(s,"NO") ||
              MatchToolValue(s,"FALSE")) {
            SaveIcons = FALSE;
          }
        }

        s = (char *) FindToolType(toolarray,"PUBSCREEN");

        if( s != NULL ) {
          strncpy(pubscreen, s, sizeof pubscreen);
          args.pubscreen = pubscreen;
        }

        s = (char *) FindToolType(toolarray,"ACTION");

        if( s != NULL ) {
          if(MatchToolValue(s,"EDIT")) {
            args.edit = TRUE;
          }
          else if(MatchToolValue(s,"USE")) {
            args.use = TRUE;
          }
          else if(MatchToolValue(s,"SAVE")) {
            args.save = TRUE;
          }
        }

        FreeDiskObject(dobj);
      }

      if((i>0)&&(*wbarg->wa_Name)) {
        args.from = wbarg->wa_Name;
      }

      if(olddir != (BPTR) -1) {
        CurrentDir(olddir); /* CD back where we were */
      }
    }
  
  }

  if(args.from == NULL) {
    args.from = ENVFILE;
  }

  if(args.edit) {
    args.use  = FALSE;
    args.save = FALSE;
  }

  if((SetSignal(0L,SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) == 0) {
    if(Initialize()) {

      NewSettings(args.from);

      if((!args.use && !args.save) || args.edit) {
        if(BuildGUI(args.pubscreen)) {
          EventLoop();
        }
        CloseGUI();
      }

      if(args.use || args.save) {
        SaveSettings(ENVFILE, UnitList);
      }

      if(args.save) {
        SaveSettings(ENVARCFILE, UnitList);
      }
    }
  }

  if(rdargs) {
    FreeArgs(rdargs);
  }

  FreeVec(Units);
  FreeVec(Modes);
  FreeVec(Outputs);
  FreeVec(Inputs);
  FreeList(ModeList);
  FreeList(UnitList);

  CleanUp();

  return 0;
}
Example #2
0
int main(int argc, char **argv)
{
    LONG               rc            =       RETURN_FAIL;
    STRPTR             filename,
                       commandLine   =       NULL,
                       ixWindow      =       DEFWINDOW;
    LONG               ixWait        =       0,
                       ixStack       =       DEFSTACK;
    BOOL               ixUShell      =       DEFUSHELL;
    BPTR               oldlock       = (BPTR)-1,
                       dirlock       = (BPTR)-1,
                       window        =       NULL;
    struct DiskObject *dobj          =       NULL;

    D(bug("IconX argc %d\n", argc));

    if (argc != 0)
    {
	displayMsg(ERROR_REQUIRED_ARG_MISSING);
	goto exit;
    }

    struct WBStartup *startup = (struct WBStartup *) argv;
    if (startup->sm_NumArgs < 2)
    {
	displayMsg(ERROR_REQUIRED_ARG_MISSING);
	goto exit;
    }
    
    D(bug("[IconX] startup->sm_NumArgs: %d\n", startup->sm_NumArgs));

    dirlock  = startup->sm_ArgList[1].wa_Lock;
    filename = startup->sm_ArgList[1].wa_Name;

    oldlock = CurrentDir(dirlock);

    /* query diskobject for tooltypes */
    dobj = GetDiskObject(filename);
    if (dobj == NULL)
    {
	struct EasyStruct es = {sizeof(struct EasyStruct), 0,
	    "Error", "IconX\nGetDiskObject failed for:\n%s", "OK"};
	EasyRequest(0, &es, 0, filename);
	goto exit;
    }

    if (dobj->do_Type == WBPROJECT)
    {
	const STRPTR *toolarray = (const STRPTR *)dobj->do_ToolTypes;
	STRPTR s;
	if ((s = FindToolType(toolarray, "WINDOW")))
	{
	    ixWindow = s;
	}
	if ((s = FindToolType(toolarray, "STACK")))
	{
	    ixStack = atol(s);
	}
	if ((s = FindToolType(toolarray, "USERSHELL")))
	{
	    if (MatchToolValue(s, "NO"))
	    {
		ixUShell = FALSE;
	    }
	}
	if ((s = FindToolType(toolarray, "WAIT")))
	{
	    ixWait += atol(s) * 50;
	}
	if ((s = FindToolType(toolarray, "DELAY")))
	{
	    ixWait += atol(s);
	}
    }
    else
    {
	displayMsg(ERROR_OBJECT_WRONG_TYPE);
	goto exit;
    }
    
    if (ixWait <= 0)
	ixWait = DEFWAIT;

    if (ixStack <= 4096)
	ixStack = DEFSTACK;
    
    D(bug("wait %d stack %d usershell %d window %s\n", ixWait, ixStack, ixUShell, ixWindow));

    D(bug("Building command line\n"));
    commandLine = BuildCommandLine(startup);
    if (commandLine == NULL)
    {
	displayMsg(IoErr());
	goto exit;
    }
    D(bug("[IconX] commandLine: '%s'\n", commandLine));

    window  = Open(ixWindow, MODE_OLDFILE);
    if (window == NULL)
    {
	/* try to open default window */
	window = Open(DEFWINDOW, MODE_OLDFILE);
    }

    if (window)
    {
	D(bug("[IconX] window ok\n"));
	struct TagItem tags[] =
	{
	    { SYS_Asynch,      FALSE        },
	    { SYS_Background,  TRUE         },
	    { SYS_Input,       (IPTR)window },
	    { SYS_Output,      (IPTR)NULL   },
	    { SYS_Error,       (IPTR)NULL   },
	    { SYS_UserShell,   ixUShell     },
	    { NP_StackSize,    ixStack      },
	    { TAG_DONE,        0            }
	};

	rc = SystemTagList(commandLine, tags);
	if (rc == -1)
	{
	    displayMsg(IoErr());
	    rc = RETURN_FAIL;
	}
    }
    else
    {
	displayMsg(IoErr());
	goto exit;
    }

    Delay(ixWait);
    rc = RETURN_OK;

exit:
    Close(window);
    FreeDiskObject(dobj);

    if (oldlock != (BPTR)-1)
	CurrentDir(oldlock);

    return rc;
}
Example #3
0
/*>ProcessToolTypes(void)
   ----------------------
   Alters defaults based on icon tool types. Handles the following
   tooltypes:
   
      Size=<x> <y>                  Output dimensions
      Offset=<x> <y>                Output offset
      HPGLMargin=<x> <y>            HPGL paper margins
      Title=<Font> <Size>           Title font and size
      XTitle=<Font> <Size>          X-axis title font and size 
      YTitle=<Font> <Size>          Y-axis title font and size 
      XLabel=<Font> <Size>          X-axis label font and size 
      YLabel=<Font> <Size>          Y-axis label font and size
      Key=<Font> <Size>             Key font and size
      Extralabel=<Font> <Size>      Extra label font and size
      Hatching=ON|OFF               Use hatching or shading
      HatchControl=<thick> <space>  Thickness and spacing of hatching
      Pen0=<R> <G> <B>              Pen colours
      Pen1=<R> <G> <B>
      Pen2=<R> <G> <B>
      Pen3=<R> <G> <B>
      DIR=<directory>               Default directory
      NOSHANGHAI                    Stops editor SHANGHAI under V2.0
      AXISBOUNDS                    EPSF bounding box set to size given by paper
   
   01.07.92 Original
   02.07.92 Added pen colours. Also rebuilds windows if colours have been
            set.
   06.07.92 Added default directory.
   04.08.92 Added NOSHANGHAI
   15.09.92 Added AXISBOUNDS
*/
ProcessToolTypes(void)
{
   struct DiskObject *DiskObj = NULL;
   char   *valptr,
          string[80];
   double value,
          value2;
   int    ival1,
          ival2,
          ival3,
          redowindows = FALSE;
   
   
   if((DiskObj = (struct DiskObject *)
                 GetDiskObject(WBenchMsg->sm_ArgList->wa_Name)) != NULL)
   {
      /* Tooltype: Size=<x> <y>                       */
      if((valptr = FindToolType(DiskObj->do_ToolTypes,"Size")) != NULL)
         if(sscanf(valptr,"%lf %lf",&value,&value2) == 2)
         {
            output.xsize   = value;
            output.ysize   = value2;
         }
      
      /* Tooltype: Offset=<x> <y>                     */
      if((valptr = FindToolType(DiskObj->do_ToolTypes,"Offset")) != NULL)
         if(sscanf(valptr,"%lf %lf",&value,&value2) == 2)
         {
            output.xoffset = value;
            output.yoffset = value2;
         }
      
      /* Tooltype: HPGLMargin=<x> <y>                 */
      if((valptr = FindToolType(DiskObj->do_ToolTypes,"HPGLMargin")) != NULL)
         if(sscanf(valptr,"%lf %lf",&value,&value2) == 2)
         {
            output.xmargin = value;
            output.ymargin = value2;
         }

      /* Tooltype: Title=<font> <size>                */
      if((valptr = FindToolType(DiskObj->do_ToolTypes,"Title")) != NULL)
         if(sscanf(valptr,"%s %lf",string,&value) == 2) 
         {
            strcpy(GTitle.PSFont,string);
            GTitle.PSSize = value;
         }

      /* Tooltype: XAxTitle=<font> <size>             */
      if((valptr = FindToolType(DiskObj->do_ToolTypes,"XTitle")) != NULL)
         if(sscanf(valptr,"%s %lf",string,&value) == 2) 
         {
            strcpy(XTitle.PSFont,string);
            XTitle.PSSize = value;
         }

      /* Tooltype: YAxTitle=<font> <size>             */
      if((valptr = FindToolType(DiskObj->do_ToolTypes,"YTitle")) != NULL)
         if(sscanf(valptr,"%s %lf",string,&value) == 2) 
         {
            strcpy(YTitle.PSFont,string);
            YTitle.PSSize = value;
         }

      /* Tooltype: XLabel=<font> <size>               */
      if((valptr = FindToolType(DiskObj->do_ToolTypes,"XLabel")) != NULL)
         if(sscanf(valptr,"%s %lf",string,&value) == 2) 
         {
            strcpy(XLabel.PSFont,string);
            XLabel.PSSize = value;
         }

      /* Tooltype: YLabel=<font> <size>               */
      if((valptr = FindToolType(DiskObj->do_ToolTypes,"YLabel")) != NULL)
         if(sscanf(valptr,"%s %lf",string,&value) == 2) 
         {
            strcpy(YLabel.PSFont,string);
            YLabel.PSSize = value;
         }

      /* Tooltype: Key=<font> <size>                  */
      if((valptr = FindToolType(DiskObj->do_ToolTypes,"Key")) != NULL)
         if(sscanf(valptr,"%s %lf",string,&value) == 2) 
         {
            strcpy(Defaults.KeyPSFont,string);
            Defaults.KeyPSSize = value;
         }

      /* Tooltype: ExtraLabel=<font> <size>           */
      if((valptr = FindToolType(DiskObj->do_ToolTypes,"ExtraLabel")) != NULL)
         if(sscanf(valptr,"%s %lf",string,&value) == 2) 
         {
            strcpy(Defaults.LabelPSFont,string);
            Defaults.LabelPSSize = value;
         }

      /* Tooltype: Hatching=ON|OFF                    */
      if(MatchToolValue(FindToolType(DiskObj->do_ToolTypes,"Hatching"),"ON"))
         output.hatching = TRUE;
      if(MatchToolValue(FindToolType(DiskObj->do_ToolTypes,"Hatching"),"OFF"))
         output.hatching = FALSE;

      /* Tooltype: HatchControl=<thickness> <spacing> */
      if((valptr = FindToolType(DiskObj->do_ToolTypes,"HatchControl")) != NULL)
         if(sscanf(valptr,"%lf %lf",&value,&value2) == 2) 
         {
            output.hatchthick = value;
            output.hatchspace = value2;
         }

      /* Tooltype: Pen0=<R> <G> <B>                   */
      if((valptr = FindToolType(DiskObj->do_ToolTypes,"Pen0")) != NULL)
         if(sscanf(valptr,"%d %d %d",&ival1,&ival2,&ival3) == 3) 
         {
            ival1 = RANGECHECK(ival1,0,15);
            ival2 = RANGECHECK(ival2,0,15);
            ival3 = RANGECHECK(ival3,0,15);
            SetRGB4(&MyScreen->ViewPort,0,(UBYTE)ival1,(UBYTE)ival2,(UBYTE)ival3);
            redowindows = TRUE;
         }

      /* Tooltype: Pen1=<R> <G> <B>                   */
      if((valptr = FindToolType(DiskObj->do_ToolTypes,"Pen1")) != NULL)
         if(sscanf(valptr,"%d %d %d",&ival1,&ival2,&ival3) == 3) 
         {
            ival1 = RANGECHECK(ival1,0,15);
            ival2 = RANGECHECK(ival2,0,15);
            ival3 = RANGECHECK(ival3,0,15);
            SetRGB4(&MyScreen->ViewPort,1,(UBYTE)ival1,(UBYTE)ival2,(UBYTE)ival3);
            redowindows = TRUE;
         }

      /* Tooltype: Pen2=<R> <G> <B>                   */
      if((valptr = FindToolType(DiskObj->do_ToolTypes,"Pen2")) != NULL)
         if(sscanf(valptr,"%d %d %d",&ival1,&ival2,&ival3) == 3) 
         {
            ival1 = RANGECHECK(ival1,0,15);
            ival2 = RANGECHECK(ival2,0,15);
            ival3 = RANGECHECK(ival3,0,15);
            SetRGB4(&MyScreen->ViewPort,2,(UBYTE)ival1,(UBYTE)ival2,(UBYTE)ival3);
            redowindows = TRUE;
         }

      /* Tooltype: Pen3=<R> <G> <B>                   */
      if((valptr = FindToolType(DiskObj->do_ToolTypes,"Pen3")) != NULL)
         if(sscanf(valptr,"%d %d %d",&ival1,&ival2,&ival3) == 3) 
         {
            ival1 = RANGECHECK(ival1,0,15);
            ival2 = RANGECHECK(ival2,0,15);
            ival3 = RANGECHECK(ival3,0,15);
            SetRGB4(&MyScreen->ViewPort,3,(UBYTE)ival1,(UBYTE)ival2,(UBYTE)ival3);
            redowindows = TRUE;
         }

      /* Tooltype: DIR=<directory>                    */
      if((valptr = FindToolType(DiskObj->do_ToolTypes,"DIR")) != NULL)
         strcpy(Defaults.directory,valptr);

      /* Tooltype: NOSHANGHAI                         */
      if((valptr = FindToolType(DiskObj->do_ToolTypes,"NOSHANGHAI")) != NULL)
         display.shanghai = FALSE;

      /* Tooltype: AXISBOUNDS                         */
      if((valptr = FindToolType(DiskObj->do_ToolTypes,"AXISBOUNDS")) != NULL)
         output.fixbounds = FALSE;

      FreeDiskObject(DiskObj);

/*
//      if(redowindows)
//      {
//         FreeAllGadgets();
//         BuildAllWindows();
//      }
*/
   }
   return(0);
}