Ejemplo n.º 1
0
// Run PopUp function
void popup_run_func(PopUpExt *ext,BackdropObject *object,char *filename,Lister *source)
{
	char *buffer,*ptr;
	Cfg_Function *func=0;
	PopUpExt *check;

	// Lock PopUp list
	lock_listlock(&GUI->popupext_list,FALSE);

	// Check function is still valid
	for (check=(PopUpExt *)GUI->popupext_list.list.lh_Head;
		check->pe_Node.ln_Succ && check!=ext;
		check=(PopUpExt *)check->pe_Node.ln_Succ);

	// Valid?
	if (check==ext)
	{
		// Allocate buffer
		if ((buffer=AllocVec(580,MEMF_CLEAR)))
		{
			// Copy command name to buffer
			stccpy(buffer,check->pe_Command,580);

			// Get pointer to end
			ptr=buffer+strlen(buffer);

			// Add space
			*(ptr++)=' ';
			*ptr=0;

			// Got filename?
			if (filename)
			{
				// Add filename in quotes
				lsprintf(ptr,"\"%s\"",filename);
			}

			// Got icon?
			else
			if (object)
			{
				BPTR lock;

				// Disk?
				if (object->type==BDO_DISK)
				{
					// Get device name
					if (object->device_name)
					{
						// Add device name in quotes
						lsprintf(ptr,"\"%s\"",object->device_name);
					}
				}

				// Otherwise
				else
				{
					// Add quote
					*(ptr++)='\"';

					// Get object lock
					if ((lock=backdrop_icon_lock(object)))
					{
						// Get path
						DevNameFromLockDopus(lock,ptr,512);
						UnLock(lock);
					}

					// Add name to path
					AddPart(ptr,object->name,512);

					// Add trailing quote
					strcat(ptr,"\"");
				}
			}

			// Create function
			func=new_default_function(buffer,global_memory_pool);

			// Free buffer
			FreeVec(buffer);
		}
	}

	// Unlock list
	unlock_listlock(&GUI->popupext_list);

	// No function?
	if (!func) return;

	// Set flag to free function automatically
	func->function.flags2|=FUNCF2_FREE_FUNCTION;

	// Launch function
	function_launch_quick(
		FUNCTION_RUN_FUNCTION,
		func,
		source);
}
Ejemplo n.º 2
0
static void GUINewMode(void)
{
    int Max, Sel;
    char* buffer;
    char* arg1 = getRecord();
    char* arg2 = getAuthor();
    char* arg3 = getCopyright();
    char* arg4 = getDriver();
    char* arg5 = getVersion();

    buffer = AllocVec( strlen( arg1 ) +
                       strlen( arg2 ) +
                       strlen( arg3 ) +
                       strlen( arg4 ) +
                       strlen( arg5 ) +
                       128,
                       MEMF_ANY);

    if( buffer != NULL )
    {
        sprintf( buffer,"0x%08lx\n%s\n%s\n%s\nDevs:AHI/%s.audio\n%s",
                 getAudioMode(),
                 arg1,
                 arg2,
                 arg3,
                 arg4,
                 arg5 );

        set(MUIInfos, MUIA_Text_Contents, (ULONG) buffer);

        FreeVec(buffer);
    }

    Max = max(state.Frequencies -1, 0);
    Sel = min(Max, state.FreqSelected);
    set(MUIFreq, MUIA_Disabled, Max==0);
    set(MUIFreq, MUIA_Numeric_Max, Max);
    set(MUIFreq, MUIA_Numeric_Value, Sel);
    set(MUILFreq, MUIA_Text_Contents, (ULONG) getFreq());

    Max = max(state.Channels, 0);
    Sel = min(Max, state.ChannelsSelected);
    set(MUIChannels, MUIA_Disabled, (Max == 1) || state.ChannelsDisabled);
    set(MUIChannels, MUIA_Numeric_Max, Max);
    set(MUIChannels, MUIA_Numeric_Value, Sel);
    set(MUILChannels, MUIA_Text_Contents, (ULONG) getChannels());

    Max = max(state.OutVols -1, 0);
    Sel = min(Max, state.OutVolSelected);
    set(MUIOutvol, MUIA_Disabled, Max==0);
    set(MUIOutvol, MUIA_Numeric_Max, Max);
    set(MUIOutvol, MUIA_Numeric_Value, Sel);
    set(MUILOutvol, MUIA_Text_Contents, (ULONG) getOutVol());

    Max = max(state.MonVols -1, 0);
    Sel = min(Max, state.MonVolSelected);
    set(MUIMonvol, MUIA_Disabled, Max==0);
    set(MUIMonvol, MUIA_Numeric_Max, Max);
    set(MUIMonvol, MUIA_Numeric_Value, Sel);
    set(MUILMonvol, MUIA_Text_Contents, (ULONG) getMonVol());

    Max = max(state.Gains -1, 0);
    Sel = min(Max, state.GainSelected);
    set(MUIGain, MUIA_Disabled, Max==0);
    set(MUIGain, MUIA_Numeric_Max, Max);
    set(MUIGain, MUIA_Numeric_Value, Sel);
    set(MUILGain, MUIA_Text_Contents, (ULONG) getGain());

    Max = max(state.Inputs -1, 0);
    Sel = min(Max, state.InputSelected);
    set(MUIInput, MUIA_Disabled, Max==0);
    set(MUIInput, MUIA_Numeric_Max, Max);
    set(MUIInput, MUIA_Numeric_Value, Sel);
    set(MUILInput, MUIA_Text_Contents, (ULONG) getInput());

    Max = max(state.Outputs -1, 0);
    Sel = min(Max, state.OutputSelected);
    set(MUIOutput, MUIA_Disabled, Max==0);
    set(MUIOutput, MUIA_Numeric_Max, Max);
    set(MUIOutput, MUIA_Numeric_Value, Sel);
    set(MUILOutput, MUIA_Text_Contents, (ULONG) getOutput());
}
Ejemplo n.º 3
0
// Set variable for a REXX message
long LIBFUNC L_SetRexxVarEx(
	REG(a0, struct RexxMsg *msg),
	REG(a1, char *varname),
	REG(d0, char *value),
	REG(d1, long length))
{
	struct RexxStem *var;
	struct List *list;
	short namelen;

	// Invalid varname or message?
	if (!msg || !varname) return 10;

	// Valid value?
	if (value)
	{
		// Need string length?
		if (length==-1) length=strlen(value);
	}
	else length=0;

	// Standard ARexx message?
	if (IsRexxMsg(msg))
	{
		// Pass through to amiga.lib call
		return SetRexxVar((struct RexxMsg *)msg,varname,value,length);
	}

	// Check for valid DOpus ARexx message
	if (msg->rm_Node.mn_Node.ln_Name!=RexxMsgIdentifier) return 10;

	// Get list pointer
	if (!(list=(struct List *)msg->rm_avail)) return 10;

	// See if variable already exists
	if ((var=(struct RexxStem *)L_FindNameI(list,varname)))
	{
		// Remove and free it
		Remove((struct Node *)var);
		FreeVec(var);
	}

	// Invalid value?
	if (!value) return 0;

	// Get variable name length
	namelen=strlen(varname)+1;

	// Allocate variable
	if (!(var=AllocVec(sizeof(struct RexxStem)+namelen+length,MEMF_CLEAR)))
		return 3;

	// Initialise variable
	var->rs_Node.ln_Name=(char *)(var+1)+length;

	// Copy name and value
	strcpy(var->rs_Node.ln_Name,varname);
	strcpy(var->rs_Value,value);

	// Add to list
	AddTail(list,(struct Node *)var);

	return 0;
}
Ejemplo n.º 4
0
void RecSlaveEntry(void)
{
  struct AHIAudioCtrlDrv* AudioCtrl;
  struct DriverBase*      AHIsubBase;
  struct FilesaveBase*    FilesaveBase;

  ULONG   signals;
  BPTR    lock = NULL,cd=0,file = NULL;
  Object *o = NULL;
  BYTE   *samples = NULL;
  ULONG   length = NULL;
  ULONG   count = 0,offs = 0,i;

  struct AHIRecordMessage RecordMessage = 
  {
    AHIST_S16S,
    NULL,
    RECBUFFERSIZE
  };

  AudioCtrl    = (struct AHIAudioCtrlDrv*) FindTask( NULL )->tc_UserData;
  AHIsubBase   = (struct DriverBase*) dd->fs_AHIsubBase;
  FilesaveBase = (struct FilesaveBase*) AHIsubBase;

  RecordMessage.ahirm_Buffer = dd->fs_RecBuffer;

  if(!(lock = Lock(dd->fs_RecFileReq->fr_Drawer,ACCESS_READ)))
    goto quit;
  cd = CurrentDir(lock);

  if(DataTypesBase)
  {
    struct TagItem newtags[] =
    {
      { DTA_GroupID, GID_SOUND },
      { TAG_DONE,    0         }
    };
    
    struct TagItem attrtags[] =
    {
      { SDTA_Sample,       (ULONG) &samples },
      { SDTA_SampleLength, (ULONG) &length  },
      { TAG_DONE,          0                }
    };
    
    if (!(o = NewDTObjectA (dd->fs_RecFileReq->fr_File, newtags)))
      goto quit;

    GetDTAttrsA(o, attrtags );
  }
  else // datatypes.library not open. Open the selected file as raw 8 bit signed instead.
  {
    if(!(file = Open(dd->fs_RecFileReq->fr_File,MODE_OLDFILE)))
      goto quit;
    Seek(file,0,OFFSET_END);
    length = Seek(file,0,OFFSET_BEGINNING);
    if(!(samples = AllocVec(length,MEMF_ANY)))
      goto quit;
    if(length != (ULONG) Read(file,samples,length))
      goto quit;
  }

  if(!samples || !length )
    goto quit;

  if((dd->fs_RecSlaveSignal = AllocSignal(-1)) == -1)
    goto quit;

// Everything set up. Tell Master we're alive and healthy.
    Signal((struct Task *)dd->fs_MasterTask,1L<<dd->fs_RecMasterSignal);

    for(;;)
    {
      signals = SetSignal(0L,0L);
      if(signals & (SIGBREAKF_CTRL_C | 1L<<dd->fs_RecSlaveSignal))
        break;

      for(;;)
      {
        if(count+RECBUFFERSIZE-offs < length)
        {
// End of sample will not be reached; just fill to the end of dd->fs_RecBuffer.
          for(i = RECBUFFERSIZE-offs;i>0;i--)
          {
            dd->fs_RecBuffer[(offs)<<1] = 
            dd->fs_RecBuffer[((offs++)<<1)+1] = 
            samples[count++]<<8;
          }
          offs = 0;
          break;
        }
        else
        {
// End of sample will be reached. Fill part of buffer, and iterate (== don't break).
          for(i = length-count;i>0;i--)
          {
            dd->fs_RecBuffer[(offs)<<1] = 
            dd->fs_RecBuffer[((offs++)<<1)+1] = 
            samples[count++]<<8;
          }
          count = 0;
        }

      }

      CallHookPkt(AudioCtrl->ahiac_SamplerFunc,AudioCtrl,&RecordMessage);
      Delay(50*RECBUFFERSIZE/AudioCtrl->ahiac_MixFreq);
    }

quit:
// Get rid of object
  if(DataTypesBase)
  {
    if(o)
      DisposeDTObject (o);
  }
  else // datatypes.library not open.
  {
    if(samples)
      FreeVec(samples);
    if(file)
      Close(file);
  }
  CurrentDir(cd);
  if(lock)
    UnLock(lock);

  Forbid();
  dd->fs_RecSlaveTask = NULL;
  FreeSignal(dd->fs_RecSlaveSignal);
  dd->fs_RecSlaveSignal = -1;
  // Tell the Master we're dying
  Signal((struct Task *)dd->fs_MasterTask,1L<<dd->fs_RecMasterSignal);
  // Multitaking will resume when we are dead.
}
Ejemplo n.º 5
0
LONG main(VOID)
{
  struct RDArgs  *readargs;
  LONG            rargs[5];
  UBYTE          *source;
  ULONG           buffersize = 0;
  UBYTE          *sourcedir;
  UBYTE          *textbuffer;
  struct AnchorPath *anchorpath;
  struct FileInfoBlock *fib;
  BPTR            dirlock, filelock;
  LONG            error, rc = 0;


    rargs[0] = 0L;

if	(readargs = ReadArgs("SOURCE/A", rargs, NULL))
	{

	  source = (UBYTE *) rargs[0];


	  if	(!(sourcedir = AllocVec(strlen(source) + 129, MEMF_CLEAR)))
		error = ERROR_NO_FREE_STORE;
	  else
		{
		/* 128 bytes to print informative text */
		textbuffer = sourcedir + strlen(source) + 1;

		buffersize = BUFFERSIZE;
		
		if	((error = GetPath(source, sourcedir, strlen(source) + 1) == 0))
			{
			if	(!(dirlock = Lock(sourcedir, SHARED_LOCK)))
				error = IoErr();
			else
			  	{
				UnLock(dirlock);

if	(anchorpath = AllocVec(sizeof(struct AnchorPath) + buffersize,MEMF_CLEAR))
	{
	anchorpath->ap_Strlen = buffersize;

	if	((error = MatchFirst(source, anchorpath)) == 0)
		{
		do
			{
			char *path;

			fib = &(anchorpath->ap_Info);
		
			path=anchorpath->ap_Buf;

			/*
			 * APF_DIDDIR indicates that we used returned from a
			 * directory. In that case we clear both APF_DIDDIR and
			 * APF_DODIR, so we can start afresh with the next one.
			 */
	
			printf("path %s - %lx ",anchorpath->ap_Buf,anchorpath->ap_Flags);
		
			
			if	(anchorpath->ap_Flags & APF_DIDDIR)
				{
				anchorpath->ap_Flags &= ~(APF_DODIR | APF_DIDDIR);
				//printf(" Returned --- SKIP\n");
				}
			else
				{

				if	(fib->fib_DirEntryType > 0 )
					{
					anchorpath->ap_Flags |= APF_DODIR;
					printf("=============================");
					}
				else
					{
					// Trim .info if needed
					if	(strlen(path) >= 5
						&& !stricmp( path + strlen(path) - 5, ".info" ))
						{
						printf("ICON ");
						
						}
	
					else
						printf("NOT ICON");
					}
				}
				
			printf("\n");

			} while ((error = MatchNext(anchorpath)) == 0);
		}
		
	MatchEnd(anchorpath);

	if	(error == ERROR_NO_MORE_ENTRIES)
		error = 0;
	
	FreeVec(anchorpath);
	}
				}
			}
		
		
		FreeVec(sourcedir);
		}
	FreeArgs(readargs);
	}

return (rc);
}
Ejemplo n.º 6
0
int
PlaySineEverywhere( void ) {
  int   rc = RETURN_OK;
  int   sine_length = 44100 / 100;
  BYTE* sine_m8s;
  BYTE* sine_s8s;
  WORD* sine_s16s;
  WORD* sine_m16s;
  LONG* sine_s32s;
  LONG* sine_m32s;

  sine_m8s  = AllocVec( 1 * sizeof( BYTE ) * sine_length, MEMF_ANY | MEMF_PUBLIC );
  sine_s8s  = AllocVec( 2 * sizeof( BYTE ) * sine_length, MEMF_ANY | MEMF_PUBLIC );
  sine_m16s = AllocVec( 1 * sizeof( WORD ) * sine_length, MEMF_ANY | MEMF_PUBLIC );
  sine_s16s = AllocVec( 2 * sizeof( WORD ) * sine_length, MEMF_ANY | MEMF_PUBLIC );
  sine_m32s = AllocVec( 1 * sizeof( LONG ) * sine_length, MEMF_ANY | MEMF_PUBLIC );
  sine_s32s = AllocVec( 2 * sizeof( LONG ) * sine_length, MEMF_ANY | MEMF_PUBLIC );
  
  if( sine_m8s != NULL &&
      sine_s8s != NULL &&
      sine_m16s != NULL &&
      sine_s16s != NULL &&
      sine_m32s != NULL &&
      sine_s32s != NULL ) {
    ULONG mode = AHI_INVALID_ID;
    int   i;

    for( i = 0; i < sine_length; ++i ) {
      double value = sin( i * 2 * M_PI / sine_length );

      sine_m8s[ i ] = (BYTE) ( SCHAR_MAX * value );
      sine_m16s[ i ] = (WORD) ( SHRT_MAX * value );
      sine_m32s[ i ] = (LONG) ( LONG_MAX * value );

      sine_s8s[ i * 2 + 0 ] = (BYTE) ( SCHAR_MAX * value );
      sine_s8s[ i * 2 + 1 ] = (BYTE) ( SCHAR_MAX * value );
      sine_s16s[ i * 2 + 0 ] = (WORD) ( SHRT_MAX * value );
      sine_s16s[ i * 2 + 1 ] = (WORD) ( SHRT_MAX * value );
      sine_s32s[ i * 2 + 0 ] = (LONG) ( LONG_MAX * value );
      sine_s32s[ i * 2 + 1 ] = (LONG) ( LONG_MAX * value );
    }

    while( rc == RETURN_OK &&
	   ( mode = AHI_NextAudioID( mode ) ) != AHI_INVALID_ID ) {
      struct AHIAudioCtrl* actrl;
      char                 name[ 64 ];
      struct Hook          sound_hook = {
	{ NULL, NULL },
	HookEntry,
	(HOOKFUNC) SoundFunc,
	FindTask( NULL )
      };
    
      AHI_GetAudioAttrs( mode, NULL,
			 AHIDB_Name, (ULONG) &name,
			 AHIDB_BufferLen, 64,
			 TAG_DONE );
    
      printf( "Mode 0x%08lx: %s\n", mode, name );

      actrl = AHI_AllocAudio( AHIA_AudioID,   mode,
			      AHIA_MixFreq,   44100,
			      AHIA_Channels,  1,
			      AHIA_Sounds,    6,
			      AHIA_SoundFunc, (ULONG) &sound_hook,
			      AHIA_UserData,  0,
			      TAG_DONE );

      if( actrl != NULL ) {
	struct AHISampleInfo sample_m8s  = { AHIST_M8S,  sine_m8s,  sine_length };
	struct AHISampleInfo sample_s8s  = { AHIST_S8S,  sine_s8s,  sine_length };
	struct AHISampleInfo sample_m16s = { AHIST_M16S, sine_m16s, sine_length };
	struct AHISampleInfo sample_s16s = { AHIST_S16S, sine_s16s, sine_length };
	struct AHISampleInfo sample_m32s = { AHIST_M32S, sine_m32s, sine_length };
	struct AHISampleInfo sample_s32s = { AHIST_S32S, sine_s32s, sine_length };
	
	if( AHI_LoadSound( 0, AHIST_SAMPLE, &sample_m8s,  actrl) == AHIE_OK &&
	    AHI_LoadSound( 1, AHIST_SAMPLE, &sample_s8s,  actrl) == AHIE_OK &&
	    AHI_LoadSound( 2, AHIST_SAMPLE, &sample_m16s, actrl) == AHIE_OK &&
	    AHI_LoadSound( 3, AHIST_SAMPLE, &sample_s16s, actrl) == AHIE_OK &&
	    AHI_LoadSound( 4, AHIST_SAMPLE, &sample_m32s, actrl) == AHIE_OK &&
	    AHI_LoadSound( 5, AHIST_SAMPLE, &sample_s32s, actrl) == AHIE_OK ) {

	  AHI_Play( actrl,
		    AHIP_BeginChannel, 0,
		    AHIP_Sound,        0,
		    AHIP_Freq,         44100,
		    AHIP_Vol,          0x10000,
		    AHIP_Pan,          0x00000,
		    AHIP_EndChannel,   0,
		    TAG_DONE );

	  // Now, when everything is "armed", lets start processing.

	  SetSignal( 0, SIGF_SINGLE );

	  if( AHI_ControlAudio( actrl,
				AHIC_Play, TRUE,
				TAG_DONE ) == AHIE_OK ) {
	    Wait( SIGF_SINGLE );

	    AHI_ControlAudio( actrl,
			      AHIC_Play, FALSE,
			      TAG_DONE );
	  }
	  else {
	    fprintf( stderr, "Unable start playback.\n" );
	    rc = RETURN_ERROR;
	  }

	  // AHI_FreeAudio() will unload the sounds
	}
	else {
	  fprintf( stderr, "Unable load sound.\n" );
	  rc = RETURN_ERROR;
	}
	
	AHI_FreeAudio( actrl );
      }
      else {
	fprintf( stderr, "Unable to allocate audio.\n" );
	rc = RETURN_ERROR;
      }
    }
  }
  else {
    fprintf( stderr, "Unable to allocate memory for sine\n" );
  }

  FreeVec( sine_m8s );
  FreeVec( sine_s8s );
  FreeVec( sine_s16s );
  FreeVec( sine_m16s );
  FreeVec( sine_s32s );
  FreeVec( sine_m32s );

  return rc;
}
Ejemplo n.º 7
0
static struct AHIDevUnit *
InitUnit ( ULONG unit, 
           struct AHIBase *AHIBase )
{
  struct AHIDevUnit *iounit;

  if( unit == AHI_NO_UNIT )
  {
    ReadConfig(NULL,AHIBase);
    return NULL;
  }
  else if(!AHIBase->ahib_DevUnits[unit])
  {
    if((iounit = AllocVec(sizeof(struct AHIDevUnit), MEMF_CLEAR|MEMF_PUBLIC)))
    {
      NewList(&iounit->Unit.unit_MsgPort.mp_MsgList);

      iounit->Unit.unit_MsgPort.mp_Node.ln_Type = NT_MSGPORT;
      iounit->Unit.unit_MsgPort.mp_Flags = PA_IGNORE;
      iounit->Unit.unit_MsgPort.mp_Node.ln_Name = AHINAME " Unit";
      iounit->UnitNum = unit;
      InitSemaphore(&iounit->ListLock);
      NewList((struct List *)&iounit->ReadList);
      NewList((struct List *)&iounit->PlayingList);
      NewList((struct List *)&iounit->SilentList);
      NewList((struct List *)&iounit->WaitingList);
      NewList((struct List *)&iounit->RequestQueue);

      if(ReadConfig(iounit,AHIBase))
      {
        if((iounit->Voices = AllocVec(
            sizeof(struct Voice)*iounit->Channels,MEMF_PUBLIC|MEMF_CLEAR)))
        {
          int i;
          struct Voice   *v = iounit->Voices;
          struct MsgPort *replyport;
          
          // Mark all channels as free
          for(i = 0 ; i < iounit->Channels; i++)
          {
            v->NextOffset = FREE;
            v++;
          }
          
          replyport = CreateMsgPort();

          if( replyport != NULL )
          {
            struct StartupMessage sm =
            {
              {
                { NULL, NULL, NT_UNKNOWN, 0, NULL },
                replyport, sizeof(struct StartupMessage),
              },
              iounit
            };

            iounit->Process = CreateNewProcTags( NP_Entry,    (ULONG) &DevProc,
                                                 NP_Name,     (ULONG) AHINAME " Unit Process",
                                                 NP_Priority, AHI_PRI,
                                                 TAG_DONE );

            if( iounit->Process != NULL )
            {
  
                PutMsg( &iounit->Process->pr_MsgPort,
                        &sm.Msg );

                WaitPort(replyport);
                GetMsg(replyport);
            }
            DeleteMsgPort(replyport);
          }
        }
      }

      if(!iounit->Process)
        FreeVec(iounit);
      else
        AHIBase->ahib_DevUnits[unit] = iounit;

    }
  }
  return AHIBase->ahib_DevUnits[unit];
}
Ejemplo n.º 8
0
// Remove an AppIcon
void rexx_rem_appthing(char *str,short type)
{
	RexxAppThing *app=0,*look,*next;

	// Get app handle
	if (type!=REXXAPP_ALL)
	{
		// Skip spaces
		rexx_skip_space(&str);

		// Get address
		if (!(app=(RexxAppThing *)rexx_parse_number(&str,0,0))) return;
	}

	// Lock list
	lock_listlock(&GUI->rexx_apps,TRUE);

	// Go through list
	for (look=(RexxAppThing *)GUI->rexx_apps.list.lh_Head;
		look->node.ln_Succ;
		look=next)
	{
		// Cache next pointer
		next=(RexxAppThing *)look->node.ln_Succ;

		// Match the one we're looking for?
		if (type==REXXAPP_ALL || look==app)
		{
			// Check type
			if (type==REXXAPP_ALL || look->node.ln_Type==type)
			{
				// Remove it
				Remove((struct Node *)look);

				// Icon?
				if (look->node.ln_Type==REXXAPP_ICON)
				{
					// Remove icon
					RemoveAppIcon(look->app_thing);

					// Free the remap (if local)
					if (look->flags&RATF_LOCAL)
						RemapIcon(look->icon,GUI->screen_pointer,FALSE);

					// Free icon
					FreeCachedDiskObject(look->icon);

					// If we're removing all, send goodbye
					if (type==REXXAPP_ALL)
					{
						if (look->port_name[0])
							rexx_send_appmsg(look,REXXAPPCMD_QUIT,0);
					}
				}

				// Progress?
				else
				if (look->node.ln_Type==REXXAPP_PROGRESS)
				{
					// Close window
					CloseProgressWindow(((RexxProgress *)look)->progress);
				}

				// Free data
				FreeVec(look);
			}

			// Unless we're removing all, break
			if (type!=REXXAPP_ALL) break;
		}
	}

	// Unlock list
	unlock_listlock(&GUI->rexx_apps);
}
Ejemplo n.º 9
0
// Send a message for an AppThing
BOOL rexx_send_appmsg(RexxAppThing *app,short type,struct AppMessage *msg)
{
	char buf[40];
	char *files=0,*entry=0;
	ULONG lister=0;
	BOOL ret;

	// Snapshot?
	if (type==REXXAPPCMD_SNAPSHOT)
	{
		struct AppSnapshotMsg *sm;

		// Get snapshot pointer
		sm=(struct AppSnapshotMsg *)msg;

		// Unsnapshot?
		if (sm->flags&APPSNAPF_UNSNAPSHOT) type=REXXAPPCMD_UNSNAPSHOT;

		// Snapshot
		else
		{
			// Build coordinate string
			lsprintf(buf,"%ld,%ld",sm->position_x,sm->position_y);
			entry=buf;
		}
	}

	// Menu?
	else
	if (type==REXXAPPCMD_MENU)
	{
		struct AppSnapshotMsg *sm;

		// Get message pointer
		sm=(struct AppSnapshotMsg *)msg;

		// ID string
		lsprintf(buf,"%ld",sm->id);
		entry=buf;

		// Help?
		if (sm->flags&APPSNAPF_HELP) type=REXXAPPCMD_MENUHELP;
	}

	// Something with files?
	else
	if (msg && msg->am_NumArgs>0)
	{
		// Build string of files
		if ((files=rexx_build_filestring((DOpusAppMessage *)msg,&lister,(app->flags&RATF_QUOTES)?CUSTF_WANT_QUOTES:0)))
			entry=files;
	}

	// Send message
	ret=rexx_handler_msg(
		app->port_name,
		0,
		(type!=REXXAPPCMD_QUIT)?RXMF_WARN:0,
		HA_String,0,app_commands[type],
		HA_Value,1,app->id,
		HA_String,2,entry,
		HA_Value,3,lister,
		HA_String,4,"icon",
		TAG_END);

	// Free files string
	FreeVec(files);

	return ret;
}
Ejemplo n.º 10
0
char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codeset, size_t *text_length)
{
	struct CollectionItem *ci_new = NULL, *ci_next, *ci_curr = ci;
	size_t len = 0;
	char *text = NULL, *p;

	/* Scan the collected chunks to find out the total size.
	 * If they are not in UTF-8, convert the chunks first and create a new CollectionItem list.
	 */
	do {
		switch(codeset) {
			case 106:
				len += ci_curr->ci_Size;
			break;
			
			case 0:
				if(ci_new) {
					ci_next->ci_Next = AllocVecTags(sizeof(struct CollectionItem), AVT_ClearWithValue, 0, TAG_DONE);
					ci_next = ci_next->ci_Next;
				} else {
					ci_new = AllocVecTags(sizeof(struct CollectionItem), AVT_ClearWithValue, 0, TAG_DONE);
					ci_next = ci_new;
				}
				
				utf8_from_local_encoding(ci_curr->ci_Data, ci_curr->ci_Size, (char **)&ci_next->ci_Data);
				ci_next->ci_Size = strlen(ci_next->ci_Data);
				len += ci_next->ci_Size;
			break;

			default:
				if(ci_new) {
					ci_next->ci_Next = AllocVecTags(sizeof(struct CollectionItem), AVT_ClearWithValue, 0, TAG_DONE);
					ci_next = ci_next->ci_Next;
				} else {
					ci_new = AllocVecTags(sizeof(struct CollectionItem), AVT_ClearWithValue, 0, TAG_DONE);
					ci_next = ci_new;
				}
				
				utf8_from_enc(ci_curr->ci_Data,
						(const char *)ObtainCharsetInfo(DFCS_NUMBER,
										codeset, DFCS_MIMENAME),
					      ci_curr->ci_Size, (char **)&ci_next->ci_Data, NULL);
				ci_next->ci_Size = strlen(ci_next->ci_Data);
				len += ci_next->ci_Size;
			break;
		}
	} while (ci_curr = ci_curr->ci_Next);

	text = malloc(len);

	if(text == NULL) return NULL;

	/* p points to the end of the buffer. This is because the chunks are
	 * in the list in reverse order. */
	p = text + len;

	if(ci_new) {
		ci_curr = ci_new;
	} else {
		ci_curr = ci;
	}

	do {
		p -= ci_curr->ci_Size;
		memcpy(p, ci_curr->ci_Data, ci_curr->ci_Size);
		ci_next = ci_curr->ci_Next;
		
		if(ci_new) {
			free(ci_curr->ci_Data);
			FreeVec(ci_curr);
		}
	} while (ci_curr = ci_next);

	*text_length = len;
	return text;
}
Ejemplo n.º 11
0
///ImageBackFill__MUIM_IconWindow_BackFill_ProcessBackground()
IPTR ImageBackFill__MUIM_IconWindow_BackFill_ProcessBackground
(
  Class *CLASS, Object *self, struct MUIP_IconWindow_BackFill_ProcessBackground *message
)
{

  LONG        Depth = 0;
  Object      *_IconWindows_PrefsObj    = NULL,
              *_IconWindows_WindowObj   = NULL;
  Object      *_IconWindows_IconListObj = NULL;

  BOOL        options_changed = FALSE;

  IPTR        prefs_processing        = 0;
  
  IPTR        BackGround_Attrib       = 0,
              BackGround_Base         = 0,
              BackGround_RenderMode   = 0,
              BackGround_TileMode     = 0,
              BackGround_XOffset      = 0,
              BackGround_YOffset      = 0;
  
  struct BackFillInfo   *this_BFI =(struct BackFillInfo   *) message->BackFill_Data;

  UBYTE                  *this_bgtype;
  char                  *this_ImageName;

  D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground()\n"));
  
  GET(_app(self), MUIA_Wanderer_Prefs, &_IconWindows_PrefsObj);

  D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: PrefsObj @ %x\n", _IconWindows_PrefsObj));
  
  GET(self, MUIA_IconWindow_Window, &_IconWindows_WindowObj);
  GET(self, MUIA_IconWindow_IconList, &_IconWindows_IconListObj);

  D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: MUIA_IconWindow_Window = %x\n", _IconWindows_WindowObj));

  if ((_IconWindows_PrefsObj == NULL) || (_IconWindows_WindowObj == NULL) || (_IconWindows_IconListObj == NULL)) return FALSE;

  GET(_IconWindows_PrefsObj, MUIA_WandererPrefs_Processing, &prefs_processing);

#if defined(DEBUG)
  if (prefs_processing)
  {
    D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Wanderer Prefs (re)loading detected\n"));
  }
#endif
  
  GET(_IconWindows_WindowObj, MUIA_IconWindow_BackgroundAttrib, &BackGround_Attrib);
  
  D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Background Attrib = '%s'\n", BackGround_Attrib));

  if (BackGround_Attrib == (IPTR) NULL) return FALSE;
  
  if ((BackGround_Base = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute,
                  BackGround_Attrib, MUIA_Background)) == -1)
    return FALSE;

  if ((BackGround_RenderMode = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute,
                  BackGround_Attrib, MUIA_IconWindowExt_ImageBackFill_BGRenderMode)) == -1)
    BackGround_RenderMode = IconWindowExt_ImageBackFill_RenderMode_Tiled;

  this_bgtype    = (UBYTE *)BackGround_Base;
  this_ImageName = (char *)(BackGround_Base + 2);
  
  D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: BackFillInfo @ %x\n", this_BFI));
  D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Background '%s', mode %d\n", BackGround_Base, BackGround_RenderMode));

  if ((this_bgtype[0] - 48) != 5)
  {
    D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Background is NOT an image - letting our windoclass handle it ..\n"));
    
    goto pb_cleanup_buffer;
  }
  
  GET(self, MUIA_Window_Screen, &this_BFI->bfi_Screen);
  GET(_IconWindows_IconListObj, MUIA_IconList_BufferRastport, &this_BFI->bfi_RastPort);

  D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Wanderers Screen @ %x, Using RastPort @ %x\n", this_BFI->bfi_Screen, this_BFI->bfi_RastPort));
  
  if (this_BFI->bfi_Source)
  {
    D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: BackFillInfo has existing source record @ %x\n", this_BFI->bfi_Source));
    if ((strcmp(this_BFI->bfi_Source->bfsir_SourceImage, this_ImageName) == 0) && (this_BFI->bfi_Source->bfsir_BackGroundRenderMode == BackGround_RenderMode))
    {
      D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: existing BackFillInfo Using the same background / mode\n"));
      goto check_imagebuffer;
    }
    else
    {
      if (this_BFI->bfi_Buffer)
      {
        ImageBackFill_CloseSourceBuffer(this_BFI->bfi_Source, this_BFI->bfi_Buffer);
        this_BFI->bfi_Buffer = NULL;
      }
      ImageBackFill_CloseSourceRecord(this_BFI->bfi_Source);
      this_BFI->bfi_Source = NULL;
    }
  }

  if (!(this_BFI->bfi_Source)) this_BFI->bfi_Source = ImageBackFill_FindSourceRecord(this_ImageName, BackGround_RenderMode);

  if (!(this_BFI->bfi_Source))
  {
    D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Creating NEW ImageSource Record\n"));
    if (!(this_BFI->bfi_Source = AllocMem(sizeof(struct BackFillSourceImageRecord), MEMF_CLEAR|MEMF_PUBLIC)))
    {
      D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Couldnt allocate enough mem for source record!\n"));      
      return FALSE;
    }

    if (!(this_BFI->bfi_Source->bfsir_SourceImage = AllocVec(strlen(this_ImageName) +1, MEMF_CLEAR|MEMF_PUBLIC)))
    {
      D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Couldnt allocate enough mem for source image name store\n"));     
      FreeMem(this_BFI->bfi_Source, sizeof(struct BackFillSourceImageRecord));
      return FALSE;
    }
    strcpy(this_BFI->bfi_Source->bfsir_SourceImage, this_ImageName);
    
    if ((this_BFI->bfi_Source->bfsir_DTPictureObject = NewDTObject(this_BFI->bfi_Source->bfsir_SourceImage,
                          DTA_SourceType,         DTST_FILE,
                          DTA_GroupID,            GID_PICTURE,
                          PDTA_DestMode,          PMODE_V43,
                          PDTA_Remap,             TRUE,
                          PDTA_Screen,            this_BFI->bfi_Screen,
                          PDTA_FreeSourceBitMap,  TRUE,
                          OBP_Precision,          PRECISION_IMAGE,
                          TAG_DONE)))
    {
      D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Opened Datatype Object @ %x for image '%s'\n", this_BFI->bfi_Source->bfsir_DTPictureObject, this_BFI->bfi_Source->bfsir_SourceImage));
      if (DoMethod(this_BFI->bfi_Source->bfsir_DTPictureObject, DTM_PROCLAYOUT, NULL, 1))
      {
        D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Caused Datatype Object LAYOUT\n"));

        GetDTAttrs(this_BFI->bfi_Source->bfsir_DTPictureObject, PDTA_BitMapHeader, &this_BFI->bfi_Source->bfsir_DTBitMapHeader, TAG_DONE);
        GetDTAttrs(this_BFI->bfi_Source->bfsir_DTPictureObject, PDTA_DestBitMap, &this_BFI->bfi_Source->bfsir_DTBitMap, TAG_DONE);

        if (!this_BFI->bfi_Source->bfsir_DTBitMap)
          GetDTAttrs(this_BFI->bfi_Source->bfsir_DTPictureObject, PDTA_BitMap, &this_BFI->bfi_Source->bfsir_DTBitMap, TAG_DONE);
      
        if (this_BFI->bfi_Source->bfsir_DTBitMap)
        {
          D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Datatype Object BitMap @ %x\n", this_BFI->bfi_Source->bfsir_DTBitMap));

          if ((this_BFI->bfi_Source->bfsir_DTRastPort = CreateRastPort()))
          {
            this_BFI->bfi_Source->bfsir_DTRastPort->BitMap = this_BFI->bfi_Source->bfsir_DTBitMap;
            this_BFI->bfi_Source->bfsir_BackGroundRenderMode = BackGround_RenderMode;
            this_BFI->bfi_Source->bfsir_OpenerCount = 0x01;

            NewList(&this_BFI->bfi_Source->bfsir_Buffers);

            AddTail(&image_backfill_images, &this_BFI->bfi_Source->bfsir_Node);
            goto check_imagebuffer;
          }
        }
        /* Failed to obtain datatype object's BM */
      }
      /* Failed to Layout datatype object */
    }
    /* Failed to open datatype object */
#if defined(DEBUG)
    if (!this_BFI->bfi_Source->bfsir_DTRastPort)
    {
      D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create ImageSource RastPort\n"));
    }
#endif
    
    if (this_BFI->bfi_Source->bfsir_DTBitMap)
    {
      FreeBitMap(this_BFI->bfi_Source->bfsir_DTBitMap);
      this_BFI->bfi_Source->bfsir_DTBitMap = NULL;
    }
#if defined(DEBUG)
    else
    {
      D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create ImageSource BitMap\n"));
    }
#endif

    if (this_BFI->bfi_Source->bfsir_DTPictureObject)
    {
      DisposeDTObject(this_BFI->bfi_Source->bfsir_DTPictureObject);
      this_BFI->bfi_Source->bfsir_DTPictureObject = NULL;
    }
#if defined(DEBUG)
    else
    {
      D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create ImageSource Datatype Object\n"));
    }
#endif
    D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create ImageSource Record\n"));
    if (this_BFI->bfi_Source->bfsir_SourceImage) FreeVec(this_BFI->bfi_Source->bfsir_SourceImage);
    FreeMem(this_BFI->bfi_Source, sizeof(struct BackFillSourceImageRecord));
    this_BFI->bfi_Source = NULL;
    return FALSE;
  }
  else
  {
    D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Using existing ImageSource Record\n"));
    this_BFI->bfi_Source->bfsir_OpenerCount += 1;
  }

check_imagebuffer:

  Depth = GetBitMapAttr(this_BFI->bfi_Source->bfsir_DTBitMap, BMA_DEPTH);
  this_BFI->bfi_CopyWidth = this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Width;
  this_BFI->bfi_CopyHeight = this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Height;

  switch (BackGround_RenderMode)
  {
    case IconWindowExt_ImageBackFill_RenderMode_Scale:
    {
      D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED mode\n"));

      this_BFI->bfi_Options.bfo_TileMode = IconWindowExt_ImageBackFill_TileMode_Fixed;
      
      SET(_IconWindows_IconListObj, MUIA_IconListview_FixedBackground, TRUE);
      SET(_IconWindows_IconListObj, MUIA_IconListview_ScaledBackground, TRUE);

      if ((BOOL)XGET(self, MUIA_IconWindow_IsRoot))
      {
        struct BackFillSourceImageBuffer *this_Buffer;
        D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Root Window = TRUE!\n"));
        this_BFI->bfi_CopyWidth = GetBitMapAttr(this_BFI->bfi_Screen->RastPort.BitMap, BMA_WIDTH);
        this_BFI->bfi_CopyHeight = GetBitMapAttr(this_BFI->bfi_Screen->RastPort.BitMap, BMA_HEIGHT);

        D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Base Dimensions (%d x %d)\n", this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight));

        if (!((BOOL)XGET(self, MUIA_IconWindow_IsBackdrop)))
        {
          D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Adjusting for window border Dimensions ..\n"));
          D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED -      WBorTop %d, WBorLeft %d, WBorRight %d, WBorBottom %d\n", this_BFI->bfi_Screen->WBorTop, this_BFI->bfi_Screen->WBorLeft, this_BFI->bfi_Screen->WBorRight, this_BFI->bfi_Screen->WBorBottom));
          this_BFI->bfi_CopyWidth -= (this_BFI->bfi_Screen->WBorLeft + this_BFI->bfi_Screen->WBorRight);
          this_BFI->bfi_CopyHeight -= (this_BFI->bfi_Screen->WBorTop + this_BFI->bfi_Screen->WBorBottom);;
        }

        this_BFI->bfi_CopyHeight -= (this_BFI->bfi_Screen->BarHeight + 1);

        this_Buffer = NULL;

        if (this_BFI->bfi_Buffer)
        {
          if ((this_BFI->bfi_Buffer->bfsib_BitMapWidth == this_BFI->bfi_CopyWidth) && (this_BFI->bfi_Buffer->bfsib_BitMapHeight == this_BFI->bfi_CopyHeight))
          {
            goto pb_backfillsetup_complete;
          }
          else
          {
            ImageBackFill_CloseSourceBuffer(this_BFI->bfi_Source, this_BFI->bfi_Buffer);
            this_BFI->bfi_Buffer = NULL;
          }
        }
        
        if (!(this_Buffer = ImageBackFill_FindBufferRecord(this_BFI->bfi_Source, this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight)))
        {
          this_Buffer = AllocMem(sizeof(struct BackFillSourceImageBuffer), MEMF_CLEAR|MEMF_PUBLIC);
          this_Buffer->bfsib_BitMapWidth = this_BFI->bfi_CopyWidth;
          this_Buffer->bfsib_BitMapHeight = this_BFI->bfi_CopyHeight;

          if (!(this_Buffer->bfsib_BitMapRastPort = CreateRastPort()))
          {
            D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Failed to create RastPort for BackFill BitMap\n"));
            break;
          }

          if ((this_Buffer->bfsib_BitMap = AllocBitMap(this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight, Depth, Depth == 8 ? BMF_MINPLANES : 0L, this_BFI->bfi_Screen->RastPort.BitMap)))
          {
            struct Rectangle CopyBounds;

            D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Scale Dimensions (%d x %d)\n", this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight));

            
            this_Buffer->bfsib_BitMapRastPort->BitMap = this_Buffer->bfsib_BitMap;
            this_BFI->bfi_Buffer = this_Buffer;
            
            CopyBounds.MinX = 0;
            CopyBounds.MinY = 0;
            CopyBounds.MaxX = this_BFI->bfi_CopyWidth - 1;
            CopyBounds.MaxY = this_BFI->bfi_CopyHeight - 1;

            
            ImageBackFill_CopyScaledBitMap(this_BFI->bfi_Source->bfsir_DTRastPort,
                    0, 0, 
                    this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Width,
                    this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Height,
                    this_Buffer->bfsib_BitMapRastPort,
                    &CopyBounds, &CopyBounds, blit_MODE_Blit);

            this_Buffer->bfsib_OpenerCount = 0x01;

            AddTail(&this_BFI->bfi_Source->bfsir_Buffers, &this_Buffer->bfsib_Node);
            
            goto pb_backfillsetup_complete;
          }
          break;
        }
        else
        {
          this_BFI->bfi_Buffer = this_Buffer;
          this_Buffer->bfsib_OpenerCount += 1;
          goto pb_backfillsetup_complete;
        }
      }
      // We arent the "ROOT" (desktop) window so only tile ...
      D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Drawer window scaling unsupported ...\n"));
    }
    default:
    {
      struct BackFillSourceImageBuffer *this_Buffer;
      D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: TILED mode\n"));
      if ((BackGround_TileMode = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute,
                                BackGround_Attrib, MUIA_IconWindowExt_ImageBackFill_BGTileMode)) == -1)
        BackGround_TileMode = IconWindowExt_ImageBackFill_TileMode_Float;

      if ((BackGround_XOffset = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute,
                                BackGround_Attrib, MUIA_IconWindowExt_ImageBackFill_BGXOffset)) == -1)
        BackGround_XOffset = 0;

      if ((BackGround_YOffset = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute,
                                BackGround_Attrib, MUIA_IconWindowExt_ImageBackFill_BGYOffset)) == -1)
        this_BFI->bfi_Options.bfo_OffsetY = 0;

      if (this_BFI->bfi_Options.bfo_TileMode != BackGround_TileMode)
      {
        this_BFI->bfi_Options.bfo_TileMode = BackGround_TileMode;
        options_changed = TRUE;
      }

      if (this_BFI->bfi_Options.bfo_OffsetX != BackGround_XOffset)
      {
        this_BFI->bfi_Options.bfo_OffsetX = BackGround_XOffset;
        options_changed = TRUE;
      }
      
      if (this_BFI->bfi_Options.bfo_OffsetY != BackGround_YOffset)
      {
        this_BFI->bfi_Options.bfo_OffsetY = BackGround_YOffset;
        options_changed = TRUE;
      }

      if (this_BFI->bfi_Options.bfo_TileMode == IconWindowExt_ImageBackFill_TileMode_Float)
        SET(_IconWindows_IconListObj, MUIA_IconListview_FixedBackground, FALSE);
      else
        SET(_IconWindows_IconListObj, MUIA_IconListview_FixedBackground, TRUE);

      SET(_IconWindows_IconListObj, MUIA_IconListview_ScaledBackground, FALSE);

      this_Buffer = NULL;

      if (this_BFI->bfi_Buffer)
      {
        if ((this_BFI->bfi_Buffer->bfsib_BitMapWidth == this_BFI->bfi_CopyWidth) && (this_BFI->bfi_Buffer->bfsib_BitMapHeight == this_BFI->bfi_CopyHeight))
        {
          goto pb_backfillsetup_complete;
        }
        else
        {
          ImageBackFill_CloseSourceBuffer(this_BFI->bfi_Source, this_BFI->bfi_Buffer);
          this_BFI->bfi_Buffer = NULL;
        }
      }

      D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Dimensions Width %d, Height %d\n", this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight));
      
      if (!(this_Buffer = ImageBackFill_FindBufferRecord(this_BFI->bfi_Source, this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight)))
      {
        this_Buffer = AllocMem(sizeof(struct BackFillSourceImageBuffer), MEMF_CLEAR|MEMF_PUBLIC);
        this_Buffer->bfsib_BitMapWidth = this_BFI->bfi_CopyWidth;
        this_Buffer->bfsib_BitMapHeight = this_BFI->bfi_CopyHeight;

        if ((this_Buffer->bfsib_BitMap = AllocBitMap(this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight, Depth, Depth == 8 ? BMF_MINPLANES : 0L, this_BFI->bfi_Screen->RastPort.BitMap)))
        {
          struct Rectangle CopyBounds;

          if (!(this_Buffer->bfsib_BitMapRastPort = CreateRastPort()))
          {
            D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: TILED - Failed to create RastPort for BackFill BitMap\n"));
            break;
          }

          this_Buffer->bfsib_BitMapRastPort->BitMap = this_Buffer->bfsib_BitMap;
          this_BFI->bfi_Buffer = this_Buffer;
          
          CopyBounds.MinX = 0;
          CopyBounds.MinY = 0;
          CopyBounds.MaxX = this_BFI->bfi_CopyWidth - 1;
          CopyBounds.MaxY = this_BFI->bfi_CopyHeight - 1;

          ImageBackFill_CopyTiledBitMap(this_BFI->bfi_Source->bfsir_DTRastPort,
                  0, 0, 
                  this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Width,
                  this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Height,
                  this_BFI->bfi_Buffer->bfsib_BitMapRastPort,
                  &CopyBounds, &CopyBounds, blit_MODE_Blit);

          this_Buffer->bfsib_OpenerCount = 0x01;
          
          AddTail(&this_BFI->bfi_Source->bfsir_Buffers, &this_BFI->bfi_Buffer->bfsib_Node);

          goto pb_backfillsetup_complete;
        }
        break;
      }
      else
      {
        this_BFI->bfi_Buffer = this_Buffer;
        this_Buffer->bfsib_OpenerCount += 1;
        goto pb_backfillsetup_complete;
      }
    }
  }

  D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create image datatype object\n"));  
  return FALSE;
  
pb_cleanup_buffer:
  if (this_BFI->bfi_Buffer)
  {
    ImageBackFill_CloseSourceBuffer(this_BFI->bfi_Source, this_BFI->bfi_Buffer);
    this_BFI->bfi_Buffer = NULL;
  }

pb_cleanup_source:
  if (this_BFI->bfi_Source)
  { 
    ImageBackFill_CloseSourceRecord(this_BFI->bfi_Source);
    this_BFI->bfi_Source = NULL;
  }
  
  return FALSE;
  
pb_backfillsetup_complete:
  if ((prefs_processing) && (options_changed))
    SET(self, MUIA_IconWindow_Changed, TRUE);

  return TRUE;
}
Ejemplo n.º 12
0
void osMediumFree(struct AFSBase *afsbase, struct Volume *volume, LONG all) {
	remDosVolume(afsbase, volume);
	if (all)
		FreeVec(BADDR(volume->devicelist.dl_Name));
}
Ejemplo n.º 13
0
VOID x11clipboard_handle_event(struct x11_staticdata *xsd, XEvent *event)
{
    switch(event->type)
    {
	case SelectionNotify:
	    D(bug("X11CLIPBOARD: SelectionNotify Event\n"));

	    if (xsd->hostclipboardmsg && (xsd->hostclipboard_readstate == HOSTCLIPBOARDSTATE_READ))
	    {
		Atom    	    actual_type;
		int     	    actual_format;
		unsigned long   nitems;
		unsigned long   bytes_after;
		unsigned char  *buffer, *arosbuffer;

		LOCK_X11
		XCALL(XGetWindowProperty, xsd->display,
				   xsd->dummy_window_for_creating_pixmaps,
				   xsd->clipboard_property_atom,
				   0,
				   0,
				   False,
				   AnyPropertyType,
				   &actual_type,
				   &actual_format,
				   &nitems,
				   &bytes_after,
				   &buffer);
		XCALL(XFree, buffer);
		UNLOCK_X11

		if (actual_type == xsd->clipboard_incr_atom)
		{
		    LOCK_X11
		    listen_for_xevent(xsd, PropertyChangeMask, TRUE);
		    XCALL(XDeleteProperty, xsd->display,
				    xsd->dummy_window_for_creating_pixmaps,
				    xsd->clipboard_property_atom);
    	    	    XCALL(XFlush, xsd->display);
		    UNLOCK_X11;

		    xsd->hostclipboard_readstate = HOSTCLIPBOARDSTATE_READ_INCR;

    	    	    D(bug("X11CLIPBOARD: SelectionNotify - INCR protocol\n"));
		    break;
		}       

		if (actual_format != 8)
		{
    	    	    D(bug("X11CLIPBOARD: SelectionNotify - format is <> 8, so terminating READ request with error.\n"));

    	    	    reply_async_request(xsd, NULL, FALSE);
		    break;				
		}

		LOCK_X11
		XCALL(XGetWindowProperty, xsd->display,
				   xsd->dummy_window_for_creating_pixmaps,
				   xsd->clipboard_property_atom,
				   0,
				   bytes_after,
				   False,
				   AnyPropertyType,
				   &actual_type,
				   &actual_format,
				   &nitems,
				   &bytes_after,
				   &buffer);

		XCALL(XDeleteProperty, xsd->display,
				xsd->dummy_window_for_creating_pixmaps,
				xsd->clipboard_property_atom);

		arosbuffer = AllocVec(nitems + 1, MEMF_ANY);
		if (arosbuffer)
		{
		    memcpy(arosbuffer, buffer, nitems);
		    arosbuffer[nitems] = '\0';
		}
    		XCALL(XFree, buffer);
		UNLOCK_X11;

    	    	D(bug("X11CLIPBOARD: SelectionNotify - terminating READ request with %s\n", arosbuffer ? "success" : "failure"));

    	    	reply_async_request(xsd, arosbuffer, arosbuffer ? TRUE : FALSE);
		
	    } /* if (xsd->hostclipboardmsg && (xsd->hostclipboard_readstate == HOSTCLIPBOARDSTATE_READ))*/
	    break;

	case PropertyNotify:
	    D(bug("X11CLIPBOARD: PropertyNotify Event\n"));

	    if (xsd->hostclipboardmsg && (xsd->hostclipboard_readstate == HOSTCLIPBOARDSTATE_READ_INCR))
	    {
		if ((event->xproperty.atom == xsd->clipboard_property_atom) &&
		    (event->xproperty.state == PropertyNewValue))
		{
		    Atom    	    actual_type;
		    int     	    actual_format;
		    unsigned long   nitems;
		    unsigned long   bytes_after;
		    unsigned char  *buffer, *arosbuffer;

    	    	    D(bug("X11CLIPBOARD: PropertyNotify - property event okay\n"));

		    LOCK_X11
		    XCALL(XGetWindowProperty, xsd->display,
			    	       xsd->dummy_window_for_creating_pixmaps,
				       xsd->clipboard_property_atom,
				       0,
				       0,
				       False,
				       AnyPropertyType,
				       &actual_type,
				       &actual_format,
				       &nitems,
				       &bytes_after,
				       &buffer);
		    XCALL(XFree, buffer);
		    UNLOCK_X11

		    if (actual_format == 8)
		    {
    	    	    	D(bug("X11CLIPBOARD: PropertyNotify - format(8) okay\n"));
 			if (bytes_after == 0)
			{
			    D(bug("X11CLIPBOARD: PropertyNotify - last one detected. Terminating READ request with %s\n",
			    	  xsd->hostclipboard_incrbuffer ? "success" : "failure"));

			    reply_async_request(xsd, xsd->hostclipboard_incrbuffer,
			    	    	    	xsd->hostclipboard_incrbuffer ? TRUE : FALSE);

			    xsd->hostclipboard_incrbuffer = NULL;
			    xsd->hostclipboard_incrbuffer_size = 0;
			    
			    listen_for_xevent(xsd, PropertyChangeMask, FALSE);			    
			}
			else
			{
			    LOCK_X11
			    XCALL(XGetWindowProperty, xsd->display,
			    	    	       xsd->dummy_window_for_creating_pixmaps,
					       xsd->clipboard_property_atom,
					       0,
					       bytes_after,
					       False,
					       AnyPropertyType,
					       &actual_type,
					       &actual_format,
					       &nitems,
					       &bytes_after,
					       &buffer);

			    if (!xsd->hostclipboard_incrbuffer)
			    {
				/* No buffer allocated yet. */

			    	D(bug("X11CLIPBOARD: PropertyNotify - First INCR packet of size %d\n", nitems));
				xsd->hostclipboard_incrbuffer = AllocVec(nitems + 1, MEMF_ANY);
				if (xsd->hostclipboard_incrbuffer)
				{
			    	    memcpy(xsd->hostclipboard_incrbuffer, buffer, nitems);
				    xsd->hostclipboard_incrbuffer[nitems] = '\0';
				    xsd->hostclipboard_incrbuffer_size = nitems;						
				}
				else
				{
    	    	    	    	    D(bug("X11CLIPBOARD: PropertyNotify - Allocation of incrbuffer failed! Terminating READ request with failure\n"));
				    
				    reply_async_request(xsd, NULL, FALSE);
				    
				    listen_for_xevent(xsd, PropertyChangeMask, FALSE);				    	
				}
			    }
			    else
			    {
				/* Buffer already allocated. Do a re-allocation! */

    	    	    	    	D(bug("X11CLIPBOARD: PropertyNotify - One more INCR packet of size %d. Total size now %d\n",
				      nitems, xsd->hostclipboard_incrbuffer_size + nitems));
				
				arosbuffer = AllocVec(xsd->hostclipboard_incrbuffer_size + nitems + 1, MEMF_ANY);
				if (arosbuffer)
				{
				    memcpy(arosbuffer, xsd->hostclipboard_incrbuffer, xsd->hostclipboard_incrbuffer_size);
				    FreeVec(xsd->hostclipboard_incrbuffer);
				    xsd->hostclipboard_incrbuffer = arosbuffer;

				    memcpy(xsd->hostclipboard_incrbuffer + xsd->hostclipboard_incrbuffer_size,
					   buffer,
					   nitems);

				    xsd->hostclipboard_incrbuffer_size += nitems;
				    xsd->hostclipboard_incrbuffer[xsd->hostclipboard_incrbuffer_size] = '\0';
				}
				else
				{
    	    	    	    	    D(bug("X11CLIPBOARD: PropertyNotify - Reallocation of incrbuffer failed! Terminating READ request with failure\n"));

				    FreeVec(xsd->hostclipboard_incrbuffer);
				    
				    reply_async_request(xsd, NULL, FALSE);

				    xsd->hostclipboard_incrbuffer = NULL;
				    xsd->hostclipboard_incrbuffer_size = 0;
				    
				    listen_for_xevent(xsd, PropertyChangeMask, FALSE);
				}
				
			    } /* if (!xsd->hostclipboard_incrbuffer) else ... */

			    XCALL(XFree, buffer);
			    UNLOCK_X11

			} /* if (bytes_after == 0) else ... */
			
		    } /* if (actual_format == 8) */

		    LOCK_X11
		    XCALL(XDeleteProperty, xsd->display,
				    xsd->dummy_window_for_creating_pixmaps,
				    xsd->clipboard_property_atom);
		    XCALL(XFlush, xsd->display);
		    UNLOCK_X11
		    
		} /* if it's right property and the property has new value */
Ejemplo n.º 14
0
VOID x11clipboard_handle_commands(struct x11_staticdata *xsd)
{
    struct Message *msg;
    
    if (xsd->hostclipboardmsg) return;
    
    D(bug("X11CLIPBOARD: handle_commands\n"));
    while((msg = GetMsg(xsd->hostclipboardmp)))
    {
	char cmd = REQ_CMD(msg);
	BOOL  async = FALSE;

	REQ_SUCCESS(msg) = FALSE;

	if (cmd == 'R')
	{
    	    D(bug("X11CLIPBOARD: handle_commands - READ\n"));

	    if ((xsd->hostclipboard_readstate == HOSTCLIPBOARDSTATE_IDLE))
	    {
		LOCK_X11
		XCALL(XConvertSelection, xsd->display,
		    	    	  xsd->clipboard_atom,
				  XA_STRING,
				  xsd->clipboard_property_atom,
				  xsd->dummy_window_for_creating_pixmaps,
				  CurrentTime);

		UNLOCK_X11

		xsd->hostclipboard_readstate = HOSTCLIPBOARDSTATE_READ;
    	    	async = TRUE;
	    }
	}
    	else if (cmd == 'W')
	{
	    unsigned char *srcbuffer = (unsigned char *)REQ_PARAM(msg);
	    ULONG   	   size = strlen(srcbuffer);
	    unsigned char *newbuffer;

    	    D(bug("X11CLIPBOARD: handle_commands: WRITE\n"));
	    
	    newbuffer = AllocVec(size, MEMF_ANY);
	    if (newbuffer)
	    {
	    	memcpy(newbuffer, srcbuffer, size);
		
		if (xsd->hostclipboard_writebuffer)
		{
	    	    FreeVec(xsd->hostclipboard_writebuffer);
		}
		
	    	xsd->hostclipboard_writebuffer = newbuffer;
		xsd->hostclipboard_writebuffer_size = size;
		
		LOCK_X11
		XCALL(XSetSelectionOwner, xsd->display, xsd->clipboard_atom,
		    	    	   xsd->dummy_window_for_creating_pixmaps, xsd->x_time);
		UNLOCK_X11
		
		REQ_SUCCESS(msg) = TRUE;
		REQ_RETVAL(msg) = NULL;
	    }
	    else
	    {
	    	REQ_SUCCESS(msg) = FALSE;
		REQ_RETVAL(msg) = NULL;
	    }
	}
	
	if (async)
	{
	    xsd->hostclipboardmsg = msg;
	    break;
	}

	ReplyMsg(msg);
    }    
}
Ejemplo n.º 15
0
// Drop some objects on another one
void backdrop_drop_object(BackdropInfo *info,BackdropObject *on_object)
{
	BackdropObject *object;
	char *buf,*dbuf;
	struct InfoData __aligned data;
	BPTR lock;

	if (!(buf=AllocVec(512,0)))
		return;
	dbuf=buf+256;

	// Drop on an AppIcon
	if (on_object->type==BDO_APP_ICON)
	{
		DOpusAppMessage *msg;
		struct MsgPort *port;

		// Is the icon busy?
		if (on_object->flags&BDOF_BUSY)
		{
			DisplayBeep(info->window->WScreen);
			FreeVec(buf);
			return;
		}

		// Build AppMessage
		if (!(msg=backdrop_appmessage(info,1)))
		{
			FreeVec(buf);
			return;
		}

		// Set message type
		msg->da_Msg.am_Type=MTYPE_APPICON;

		// Get AppInfo
		port=WB_AppWindowData(
			(struct AppWindow *)on_object->misc_data,
			&msg->da_Msg.am_ID,
			&msg->da_Msg.am_UserData);

		// Send the message
		PutMsg(port,(struct Message *)msg);
		FreeVec(buf);
		return;
	}

	// Only support dropping on disks at the moment
	if ((on_object->type!=BDO_DISK && on_object->type!=BDO_BAD_DISK) ||
		on_object->flags&(BDOF_ASSIGN|BDOF_CACHE))
	{
		DisplayBeep(info->window->WScreen);
		FreeVec(buf);
		return;
	}

	// Go through backdrop list
	for (object=(BackdropObject *)info->objects.list.lh_Head;
		object->node.ln_Succ;
		object=(BackdropObject *)object->node.ln_Succ)
	{
		// Selected disk?
		if (object->type==BDO_DISK && !(object->flags&(BDOF_ASSIGN|BDOF_CACHE)) && object->state)
		{
			BPTR lock;

			// Get disk lock
			if (lock=backdrop_icon_lock(object))
			{
				// This is the source
				Info(lock,&data);

				// Get device name
				DeviceFromLock(lock,buf);

				// Unlock lock
				UnLock(lock);
			}
			break;
		}
	}

	// Didn't get anything?
	if (!object->node.ln_Succ)
	{
		DisplayBeep(info->window->WScreen);
		FreeVec(buf);
		return;
	}

	// Drop on a bad disk?
	if (on_object->type==BDO_BAD_DISK)
	{
		// Get device name
		strcpy(dbuf,on_object->name);
	}

	// Real disk
	else
	{
		// Get destination disk lock
		if (!(lock=backdrop_icon_lock(on_object)))
		{
			FreeVec(buf);
			return;
		}

		// Destination is the one we dropped it on
		Info(lock,&data);

		// Get device name
		DeviceFromLock(lock,dbuf);
		UnLock(lock);
	}

	// Launch diskcopy
	function_launch(
		FUNCTION_RUN_FUNCTION,
		def_function_diskcopy,
		0,
		0,
		0,0,
		0,0,
		BuildArgArray(buf,dbuf,0),
		0,0);

	FreeVec(buf);
}
Ejemplo n.º 16
0
// Add an AppIcon from rexx
long rexx_add_appicon(char *str,struct RexxMsg *msg)
{
	char iconfile[256],menustem[80];
	RexxAppThing *app;
	struct TagItem *tags;
	short key,menu_count=0,count;
	long base=0;
	APTR memory;

	// Allocate AppNode
	if (!(app=AllocVec(sizeof(RexxAppThing),MEMF_CLEAR)))
		return 0;

	// Allocate memory handle
	if (!(memory=NewMemHandle(0,0,MEMF_CLEAR)))
	{
		FreeVec(app);
		return 0;
	}

	// Set type
	app->node.ln_Type=REXXAPP_ICON;

	// Initialise position
	app->pos_x=NO_ICON_POSITION;
	app->pos_y=NO_ICON_POSITION;

	// Get port name
	rexx_parse_word(&str,app->port_name,sizeof(app->port_name));

	// Get icon name
	rexx_parse_word(&str,app->icon_name,sizeof(app->icon_name));

	// Get ID
	rexx_skip_space(&str);
	app->id=rexx_parse_number(&str,0,0);

	// Clear buffers
	iconfile[0]=0;
	menustem[0]=0;

	// Position set?
	rexx_skip_space(&str);
	while ((key=rexx_match_keyword(&str,pos_keys,0))!=-1)
	{
		// Position?
		if (key==APPARG_POS)
		{
			// Get position
			app->pos_x=rexx_parse_number(&str,1,NO_ICON_POSITION);
			app->pos_y=rexx_parse_number(&str,0,NO_ICON_POSITION);
		}

		// Quotes?
		else
		if (key==APPARG_QUOTES) app->flags|=RATF_QUOTES;

		// Info?
		else
		if (key==APPARG_INFO) app->flags|=RATF_INFO;

		// Snapshot
		else
		if (key==APPARG_SNAP) app->flags|=RATF_SNAP;

		// Close
		else
		if (key==APPARG_CLOSE) app->flags|=RATF_CLOSE;

		// Local
		else
		if (key==APPARG_LOCAL) app->flags|=RATF_LOCAL;

		// Locked
		else
		if (key==APPARG_LOCKED) app->flags|=RATF_LOCKED;

		// Icon
		else
		if (key==APPARG_ICON)
		{
			// Get filename
			rexx_parse_word(&str,iconfile,256);
		}

		// Menu
		else
		if (key==APPARG_MENU)
		{
			// Get menu stem
			if (rexx_parse_word(&str,menustem,30))
			{
				// Check stem has a period
				if (menustem[0] && menustem[strlen(menustem)-1]!='.')
					strcat(menustem,".");
			}
		}

		// Skip spaces
		rexx_skip_space(&str);
	}

	// Try and get icon
	if (iconfile[0]) app->icon=GetCachedDiskObject(iconfile,GCDOF_NOCACHE);

	// Failed? Get default
	if (!app->icon &&
		!(app->icon=GetCachedDefDiskObject(WBTOOL|GCDOF_NOCACHE)))
	{
		// Failed completely
		FreeVec(app);
		return 0;
	}

	// Set icon position
	app->icon->do_CurrentX=app->pos_x-WBICONMAGIC_X;
	app->icon->do_CurrentY=app->pos_y-WBICONMAGIC_Y;
	SetIconFlags(app->icon,GetIconFlags(app->icon)&~ICONF_POSITION_OK);

	// Remap the icon (only if a local one)
	if (app->flags&RATF_LOCAL)
		RemapIcon(app->icon,GUI->screen_pointer,FALSE);

	// Menu items?
	if (menustem[0])
	{
		char buffer[10];

		// Get count
		rexx_get_var(msg,menustem,"COUNT",buffer,10);
		menu_count=atoi(buffer);

		// Get base
		if (rexx_get_var(msg,menustem,"BASE",buffer,10))
			base=atoi(buffer);
	}

	// Number of tags needed
	count=7+menu_count;

	// Allocate tags
	if ((tags=AllocMemH(memory,sizeof(struct TagItem)*count)))
	{
		// Initialise tags
		tags[0].ti_Tag=DAE_SnapShot;
		tags[0].ti_Data=(app->flags&RATF_SNAP)?1:0;
		tags[1].ti_Tag=DAE_Info;
		tags[1].ti_Data=(app->flags&RATF_INFO)?1:0;
		tags[2].ti_Tag=DAE_Close;
		tags[2].ti_Data=(app->flags&RATF_CLOSE)?1:0;
		tags[3].ti_Tag=(app->flags&RATF_LOCAL)?DAE_Local:TAG_IGNORE;
		tags[3].ti_Data=1;
		tags[4].ti_Tag=DAE_Locked;
		tags[4].ti_Data=(app->flags&RATF_LOCKED)?1:0;
		tags[5].ti_Tag=DAE_MenuBase;
		tags[5].ti_Data=base;

		// Go through menus
		for (count=0;count<menu_count;count++)
		{
			char buffer[80];

			// Build variable name
			lsprintf(iconfile,"%ld",count);

			// Get variable
			if (rexx_get_var(msg,menustem,iconfile,buffer,80))
			{
				// Allocate buffer
				if ((tags[count+6].ti_Data=(ULONG)AllocMemH(memory,strlen(buffer)+1)))
				{
					// Copy name
					strcpy((char *)tags[count+6].ti_Data,buffer);

					// Set tag ID
					tags[count+6].ti_Tag=DAE_Menu;
				}
				else tags[count+6].ti_Tag=TAG_IGNORE;
			}

			// Skip this tag
			else tags[count+6].ti_Tag=TAG_IGNORE;
		}
	}

	// Add AppIcon
	app->app_thing=
		AddAppIconA(
			app->id,
			(ULONG)app,
			app->icon_name,
			GUI->rexx_app_port,
			0,
			app->icon,
			tags);

	// Free memory
	FreeMemHandle(memory);

	// Failed?
	if (!app->app_thing)
	{
		// Failed
		if (app->flags&RATF_LOCAL)
			RemapIcon(app->icon,GUI->screen_pointer,FALSE);
		FreeCachedDiskObject(app->icon);
		FreeVec(app);
		return 0;
	}

	// Add to AppList
	lock_listlock(&GUI->rexx_apps,TRUE);
	AddTail(&GUI->rexx_apps.list,(struct Node *)app);
	unlock_listlock(&GUI->rexx_apps);

	return (long)app;
}
void __initcommandline(void)
{
  struct WBStartup *wbs=_WBenchMsg;

  if(wbs!=NULL)
  { if(__stdiowin[0])
    { BPTR win;

      if((window=win=Open(__stdiowin,MODE_OLDFILE))==0l)
        exit(RETURN_FAIL);
      SelectInput(win);
      SelectOutput(win);
    }
    if(wbs->sm_ArgList!=NULL) /* cd to icon */
      cd=CurrentDir(DupLock(wbs->sm_ArgList->wa_Lock));

    __argc=0;
    __argv=(char **)wbs;
  }else
  { 
    char **av,*a,*cl=__commandline;
    size_t i=__commandlen;
    int ac;

    if(!(cline=(char *)AllocVec(i+1,MEMF_ANY))) /* get buffer */
      exit(RETURN_FAIL);
  
    for(a=cline,ac=1;;) /* and parse commandline */
    {
      while(i&&(*cl==' '||*cl=='\t'||*cl=='\n'))
      { cl++;
        i--; }
      if(!i)
        break;
      if(*cl=='\"')
      {
        cl++;
        i--;
        while(i)
        {
          if(*cl=='\"')
          {
            cl++;
            i--;
            break;
          }
          if(*cl=='*')
          {
            cl++;
            i--;
            if(!i)
              break;
          }
          *a++=*cl++;
          i--;
        }
      }
      else
        while(i&&(*cl!=' '&&*cl!='\t'&&*cl!='\n'))
        { *a++=*cl++;
          i--; }
      *a++='\0';
      ac++;
    }
      /* NULL Terminated */
    if(!(__argv=av=(char **)AllocVec(((__argc=ac)+1)*sizeof(char *),MEMF_ANY|MEMF_CLEAR)))
      exit(RETURN_FAIL);

    for(a=cline,i=1;i<ac;i++)
    { 
      av[i]=a;
      while(*a++)
        ; 
    }
  
    for(i=256;;i+=256) /* try in steps of 256 bytes */
    { if(!(*av=(char *)AllocVec(i,MEMF_ANY)))
        break;
      GetProgramName(*av,i); /* Who am I ? */
      if(IoErr()!=ERROR_LINE_TOO_LONG)
        break;
      FreeVec(*av);
    }
  
    if(*av==NULL)
      exit(RETURN_FAIL);
  }
}
Ejemplo n.º 18
0
// Rename some objects
void icon_rename(IPCData *ipc,BackdropInfo *info,BackdropObject *icon)
{
	Att_List *list;
	Att_Node *node;
	BackdropObject *object;
	BOOL save_pos=0;
	BPTR lock=0,old=0;

	// Group?
	if (info->flags&BDIF_GROUP)
	{
		GroupData *group;

		// Get group pointer
		group=(GroupData *)IPCDATA(info->ipc);

		// Build directory name
		lsprintf(info->buffer,"dopus5:groups/%s",group->name);

		// Lock directory
		if (!(lock=Lock(info->buffer,ACCESS_READ)))
			return;

		// Change directory
		old=CurrentDir(lock);
	}

	// Create list
	if (!(list=Att_NewList(0)))
	{
		if (lock) UnLock(CurrentDir(old));
		return;
	}

	// Lock backdrop list
	lock_listlock(&info->objects,0);

	// Go through backdrop list (backwards, just for the hell of it)
	for (object=(BackdropObject *)info->objects.list.lh_TailPred;
		object->node.ln_Pred;
		object=(BackdropObject *)object->node.ln_Pred)
	{
		// Correct type?
		if (object->type!=BDO_APP_ICON && object->type!=BDO_BAD_DISK && !(object->flags&BDOF_CACHE))
		{
			// Selected or supplied?
			if ((!icon && object->state) || icon==object)
			{
				// Add object to list
				Att_NewNode(
					list,
					(object->flags&BDOF_CUSTOM_LABEL)?object->device_name:object->name,
					(ULONG)object,
					0);
				if (icon) break;
			}
		}
	}

	// Unlock backdrop list
	unlock_listlock(&info->objects);

	// Go through list of objects
	for (node=(Att_Node *)list->list.lh_Head;
		node->node.ln_Succ;
		node=(Att_Node *)node->node.ln_Succ)
	{
		char *name,*origname;
		BackdropObject *object;
		short ret,copy=1;
		BOOL retry,fail=0;

		if (!(name=AllocVec(512,0)))
			break;
		origname=name+256;

		// Loop on retries
		do
		{
			// Clear retry flag
			retry=0;

			// Copy name
			strcpy(name,node->node.ln_Name);

			// Build message
			lsprintf(info->buffer,GetString(&locale,MSG_RENAME_DISK),name);

			// Strip trailing colon for assigns
			if (name[(ret=(strlen(name)-1))]==':') name[ret]=0;

			// Copy original name
			strcpy(origname,name);

			// Ask for new name
			if (!(ret=super_request_args(
				info->window,
				info->buffer,
				SRF_BUFFER|SRF_IPC|SRF_PATH_FILTER|SRF_MOUSE_POS,
				name,255,
				ipc,
				GetString(&locale,MSG_OKAY),
				GetString(&locale,(node->node.ln_Succ->ln_Succ)?MSG_SKIP:MSG_CANCEL),
				(node->node.ln_Succ->ln_Succ)?GetString(&locale,MSG_CANCEL):0,0)))
			{
				// Cancel
				fail=1;
				break;
			}

			// Ok to rename?
			else
			if (ret!=2)
			{
				// Lock backdrop list
				lock_listlock(&info->objects,0);

				// Is object still valid?>
				if ((object=find_backdrop_object(info,(BackdropObject *)node->data)))
				{
					// Object in a group?
					if (info->flags&BDIF_GROUP)
					{
						// Must have custom label
						if (object->flags&BDOF_CUSTOM_LABEL)
						{
							// Try to rename object
							if (Rename(object->device_name,name))
							{
								// Store new name
								strcpy(object->device_name,name);
								ret=1;
								copy=0;
							}
						}
					}

					// Assign?
					else
					if (object->flags&BDOF_ASSIGN)
					{
						BPTR lock;

						// Lock the assign
						if ((lock=Lock(object->name,ACCESS_READ)))
						{
							// Assign the new name to it
							while (!(ret=AssignLock(name,lock)))
							{
								// Failed, display requester
								if (!(error_request(
									info->window,
									ERF_MOUSE,
									GetString(&locale,MSG_RENAMING),
									-1,
									object->name,
									":",
									0))) break;
							}

							// Success?
							if (ret)
							{
								// Delete the old assignment
								AssignLock(origname,0);
							}

							// Otherwise free the lock
							else UnLock(lock);
						}
					}

					// Disk?
					else
					if (object->type==BDO_DISK)
					{
						// Try to relabel
						while (!(ret=OriginalRelabel(object->device_name,name)))
						{
							// Failed, display requester
							if (!(error_request(
								info->window,
								ERF_MOUSE,
								GetString(&locale,MSG_RENAMING),
								-1,
								object->name,
								":",
								0))) break;
						}

						// Success?
						if (ret)
						{
							// Pass name change through to things
							notify_disk_name_change(info,object->device_name,name);
						}
					}

					// Group, desktop folder
					else
					if (object->type==BDO_GROUP ||
						(object->type==BDO_LEFT_OUT && object->flags&BDOF_DESKTOP_FOLDER))	
					{
						BPTR old=0,lock;

						// Change directory
						if ((lock=Lock(object->path,ACCESS_READ)))
							old=CurrentDir(lock);

						// Rename file
						if (!(ret=Rename(object->name,name)))
						{
							// Show error requester
							if (error_request(
									info->window,
									ERF_MOUSE,
									GetString(&locale,MSG_RENAMING),
									-1,
									object->name,
									":",
									0))
							{
								// Set flag to retry
								retry=1;
							}
						}

						// Success?
						if (ret)
						{
							GroupData *group;

							// Add .infos on
							strcpy(info->buffer,object->name);
							strcat(info->buffer,".info");
							strcpy(info->buffer+300,name);
							strcat(info->buffer+300,".info");

							// Rename icon
							Rename(info->buffer,info->buffer+300);

							// Group?
							if (object->type==BDO_GROUP)
							{
								// Lock process list
								lock_listlock(&GUI->group_list,0);

								// See if group is open
								if ((group=backdrop_find_group(object)))
								{
									char *name_copy;
		
									// Get a copy of the name
									if ((name_copy=AllocVec(strlen(name)+1,0)))
									{
										// Signal it to update its name
										strcpy(name_copy,name);
										IPC_Command(group->ipc,GROUP_NEW_NAME,0,0,name_copy,0);
									}
								}

								// Unlock process list
								unlock_listlock(&GUI->group_list);
							}
						}

						// Restore directory
						if (lock) UnLock(CurrentDir(old));
					}

					// Left-out
					else
					if (object->type==BDO_LEFT_OUT)
					{
						leftout_record *left;

						// Lock position list
						lock_listlock(&GUI->positions,0);

						// Look for entry for icon
						for (left=(leftout_record *)&GUI->positions.list.lh_Head;
							left->node.ln_Succ;
							left=(leftout_record *)left->node.ln_Succ)
						{
							// Leftout?
							if (left->node.ln_Type==PTYPE_LEFTOUT)
							{
								// Match this icon?
								if (object->misc_data==(ULONG)left)
								{
									// Store new label
									stccpy(left->icon_label,name,sizeof(left->icon_label));
									save_pos=1;
									break;
								}
							}
						}

						// Unlock position list
						unlock_listlock(&GUI->positions);

						// Store name in icon
						if (object->flags&BDOF_CUSTOM_LABEL)
						{
							strcpy(object->device_name,name);
							ret=1;
							copy=0;
						}
					}

					// Successful?
					if (ret)
					{
						// Erase object
						backdrop_erase_icon(info,object,0);

						// Store new name
						if (copy)
						{
							strcpy(object->name,name);
							if (object->flags&BDOF_ASSIGN) strcat(object->name,":");
						}

						// Show new object
						backdrop_render_object(info,object,BRENDERF_CLIP);
					}
				}

				// Unlock backdrop list
				unlock_listlock(&info->objects);
			}
		} while (retry);

		// Abort?
		FreeVec(name);
		if (fail) break;
	}

	// Free list
	Att_RemList(list,0);

	// Lock backdrop list
	lock_listlock(&info->objects,0);

	// Save any left-outs
	if (save_pos)
	{
		// Lock list
		lock_listlock(&GUI->positions,0);

		// Save list
		SavePositions(&GUI->positions.list,GUI->position_name);

		// Unlock list
		unlock_listlock(&GUI->positions);
	}

	// Unlock backdrop list
	unlock_listlock(&info->objects);

	// Restore CD
	if (lock) UnLock(CurrentDir(old));
}
Ejemplo n.º 19
0
// Save an environment
int environment_save(Cfg_Environment *env,char *name,short snapshot,CFG_ENVR *data)
{
	APTR iff;
	long success=0;
	struct OpenEnvironmentData *opendata=0;
#ifdef __AROS__
	CFG_ENVR *env_be;
#endif

	// Invalid name?
	if (!name || !*name) return 0;

	// Get data pointer if not supplied
	if (!data) data=env->env;

#ifdef __AROS__
	if (!(env_be=AllocVec(sizeof(CFG_ENVR),MEMF_CLEAR)))
		return 0;
#endif

	// Update main window position
	if (snapshot&ENVSAVE_WINDOW)
	{
		GetSemaphore(&GUI->backdrop->window_lock,SEMF_SHARED,0);
		display_store_pos();
		FreeSemaphore(&GUI->backdrop->window_lock);
	}

	// Not snapshotting listers?
	if (!(snapshot&ENVSAVE_LAYOUT))
	{
		if ((opendata=AllocMemH(env->volatile_memory,sizeof(struct OpenEnvironmentData))))
		{
			opendata->memory=env->desktop_memory;
			opendata->volatile_memory=env->volatile_memory;
			opendata->flags=OEDF_BANK|OEDF_LSTR;
			OpenEnvironment(name,opendata);
		}
	}

	// Try to open file to write
	while ((iff=IFFOpen(name,MODE_NEWFILE,ID_EPUS)))
	{
		IPCData *ipc;
		Lister *lister;
		Buttons *buttons;
		Cfg_Desktop *desk;
		struct MinNode *node;
		Cfg_SoundEntry *sound;

		// Write environment settings
#ifdef __AROS__
		CopyMem(data,env_be,sizeof(CFG_ENVR));

		{
			int i;
		
			env_be->screen_mode = AROS_LONG2BE(env_be->screen_mode);
			env_be->screen_flags = AROS_WORD2BE(env_be->screen_flags);
			env_be->screen_depth = AROS_WORD2BE(env_be->screen_depth);
			env_be->screen_width = AROS_WORD2BE(env_be->screen_width);
			env_be->screen_height = AROS_WORD2BE(env_be->screen_height);

			for (i=0; i<50; i++)
				env_be->palette[i] = AROS_LONG2BE(env_be->palette[i]);
			
			env_be->window_pos.Left = AROS_WORD2BE(env_be->window_pos.Left);
			env_be->window_pos.Top = AROS_WORD2BE(env_be->window_pos.Top);
			env_be->window_pos.Width = AROS_WORD2BE(env_be->window_pos.Width);
			env_be->window_pos.Height = AROS_WORD2BE(env_be->window_pos.Height);
			env_be->general_screen_flags = AROS_LONG2BE(env_be->general_screen_flags);
			env_be->palette_count = AROS_WORD2BE(env_be->palette_count);
			
			for (i=0; i<CUST_PENS; i++)
			{
				env_be->env_Colours[i][0][0] = AROS_LONG2BE(env_be->env_Colours[i][0][0]);
				env_be->env_Colours[i][0][1] = AROS_LONG2BE(env_be->env_Colours[i][0][1]);
				env_be->env_Colours[i][0][2] = AROS_LONG2BE(env_be->env_Colours[i][0][2]);
				env_be->env_Colours[i][1][0] = AROS_LONG2BE(env_be->env_Colours[i][1][0]);
				env_be->env_Colours[i][1][1] = AROS_LONG2BE(env_be->env_Colours[i][1][1]);
				env_be->env_Colours[i][1][2] = AROS_LONG2BE(env_be->env_Colours[i][1][2]);
			}
			
			env_be->env_ColourFlag = AROS_LONG2BE(env_be->env_ColourFlag);
			env_be->env_NewIconsFlags = AROS_LONG2BE(env_be->env_NewIconsFlags);
			env_be->display_options = AROS_WORD2BE(env_be->display_options);
			env_be->main_window_type = AROS_WORD2BE(env_be->main_window_type);
			env_be->hotkey_flags = AROS_WORD2BE(env_be->hotkey_flags);
			env_be->hotkey_code = AROS_WORD2BE(env_be->hotkey_code);
			env_be->hotkey_qual = AROS_WORD2BE(env_be->hotkey_qual);
			env_be->default_stack = AROS_LONG2BE(env_be->default_stack);
			env_be->lister_options = AROS_WORD2BE(env_be->lister_options);
			env_be->flags = AROS_LONG2BE(env_be->flags);
			env_be->lister_popup_code = AROS_WORD2BE(env_be->lister_popup_code);
			env_be->lister_popup_qual = AROS_WORD2BE(env_be->lister_popup_qual);
			env_be->env_flags = AROS_LONG2BE(env_be->env_flags);
			env_be->clock_left = AROS_WORD2BE(env_be->clock_left);
			env_be->clock_top = AROS_WORD2BE(env_be->clock_top);
			env_be->lister_width = AROS_WORD2BE(env_be->lister_width);
			env_be->lister_height = AROS_WORD2BE(env_be->lister_height);
			env_be->version = AROS_WORD2BE(env_be->version);
			env_be->desktop_flags = AROS_LONG2BE(env_be->desktop_flags);
			
			for (i=0; i<4; i++)
				env_be->env_BackgroundFlags[i] = AROS_WORD2BE(env_be->env_BackgroundFlags[i]);
		
			env_be->settings.copy_flags = AROS_LONG2BE(env_be->settings.copy_flags);
			env_be->settings.delete_flags = AROS_LONG2BE(env_be->settings.delete_flags);
			env_be->settings.error_flags = AROS_LONG2BE(env_be->settings.error_flags);
			env_be->settings.general_flags = AROS_LONG2BE(env_be->settings.general_flags);
			env_be->settings.icon_flags = AROS_LONG2BE(env_be->settings.icon_flags);
			env_be->settings.replace_method = AROS_WORD2BE(env_be->settings.replace_method);
			env_be->settings.replace_flags = AROS_WORD2BE(env_be->settings.replace_flags);
			env_be->settings.update_flags = AROS_LONG2BE(env_be->settings.update_flags);
			env_be->settings.dir_flags = AROS_LONG2BE(env_be->settings.dir_flags);
			env_be->settings.view_flags = AROS_LONG2BE(env_be->settings.view_flags);
			env_be->settings.max_buffer_count = AROS_WORD2BE(env_be->settings.max_buffer_count);
			env_be->settings.date_format = AROS_WORD2BE(env_be->settings.date_format);
			env_be->settings.date_flags = AROS_WORD2BE(env_be->settings.date_flags);
			env_be->settings.pop_code = AROS_WORD2BE(env_be->settings.pop_code);
			env_be->settings.pop_qual = AROS_WORD2BE(env_be->settings.pop_qual);
			env_be->settings.pop_qual_mask = AROS_WORD2BE(env_be->settings.pop_qual_mask);
			env_be->settings.pop_qual_same = AROS_WORD2BE(env_be->settings.pop_qual_same);
			env_be->settings.popup_delay = AROS_WORD2BE(env_be->settings.popup_delay);
			env_be->settings.max_openwith = AROS_WORD2BE(env_be->settings.max_openwith);
			env_be->settings.command_line_length = AROS_WORD2BE(env_be->settings.command_line_length);
			env_be->settings.max_filename = AROS_WORD2BE(env_be->settings.max_filename);
			env_be->settings.flags = AROS_LONG2BE(env_be->settings.flags);
			
			for (i=0; i<4; i++)
				env_be->env_BackgroundBorderColour[i] = AROS_LONG2BE(env_be->env_BackgroundBorderColour[i]);
		}

		if (!(IFFWriteChunk(iff,env_be,ID_ENVR,sizeof(CFG_ENVR))))
#else
		if (!(IFFWriteChunk(iff,data,ID_ENVR,sizeof(CFG_ENVR))))
#endif
		{
			success=IoErr();
			break;
		}

		// Write some path names
		if ((success=write_env_string(iff,env->toolbar_path,ID_TBAR)) ||
			(success=write_env_string(iff,env->menu_path,ID_LMEN)) ||
			(success=write_env_string(iff,env->user_menu_path,ID_UMEN)) ||
			(success=write_env_string(iff,env->scripts_path,ID_SCRP)) ||
			(success=write_env_string(iff,env->hotkeys_path,ID_HKEY)))
			break;

		// Not snapshotting?
		if (!(snapshot&ENVSAVE_LAYOUT) && opendata)
		{
			ButtonBankNode *button;
			OpenListerNode *lister;

			// Go through existing listers
			for (lister=(OpenListerNode *)opendata->listers.mlh_Head;
				lister->node.ln_Succ;)
			{
				OpenListerNode *next=(OpenListerNode *)lister->node.ln_Succ;

				// Write lister data
				if (!(SaveListerDef(iff,(Cfg_Lister *)lister->lister))) break;

				// Remove this node, get next
				Remove((struct Node *)lister);
				lister=next;
			}

			// Go through buttons to open
			for (button=(ButtonBankNode *)opendata->buttons.mlh_Head;
				button->node.ln_Succ;)
			{
				ButtonBankNode *next=(ButtonBankNode *)button->node.ln_Succ;
				ULONG pad[5];
#ifdef __AROS__
				struct IBox pos_be;
#endif

				// Write bank header
				if (!(IFFPushChunk(iff,ID_BANK))) break;

				// Fill out padding
				pad[0]=0;
				pad[1]=0;
				pad[2]=button->icon_pos_x;
				pad[3]=button->icon_pos_y;
				pad[4]=button->flags&BUTTONF_ICONIFIED;

#ifdef __AROS__
				CopyMem(&button->pos,&pos_be,sizeof(struct IBox));

				pos_be.Left = AROS_WORD2BE(pos_be.Left);
				pos_be.Top = AROS_WORD2BE(pos_be.Top);
				pos_be.Width = AROS_WORD2BE(pos_be.Width);
				pos_be.Height = AROS_WORD2BE(pos_be.Height);

				pad[2] = AROS_LONG2BE(pad[2]);
				pad[3] = AROS_LONG2BE(pad[3]);
				pad[4] = AROS_LONG2BE(pad[4]);
				
				if (!(IFFWriteChunkBytes(iff,pad,sizeof(pad))) ||
					!(IFFWriteChunkBytes(iff,&pos_be,sizeof(struct IBox))) ||
					!(IFFWriteChunkBytes(iff,button->node.ln_Name,strlen(button->node.ln_Name)+1)) ||
					!(IFFPopChunk(iff))) break;
#else
				// Write padding and position and path
				if (!(IFFWriteChunkBytes(iff,pad,sizeof(pad))) ||
					!(IFFWriteChunkBytes(iff,&button->pos,sizeof(struct IBox))) ||
					!(IFFWriteChunkBytes(iff,button->node.ln_Name,strlen(button->node.ln_Name)+1)) ||
					!(IFFPopChunk(iff))) break;
#endif

				// Remove this node, get next
				Remove((struct Node *)button);
				button=next;
			}

			// Go through StartMenus to open
			for (button=(ButtonBankNode *)opendata->startmenus.mlh_Head;
				button->node.ln_Succ;)
			{
				ButtonBankNode *next=(ButtonBankNode *)button->node.ln_Succ;
				ULONG pad[5];
#ifdef __AROS__
				struct IBox pos_be;
#endif

				// Write bank header
				if (!(IFFPushChunk(iff,ID_STRT))) break;

				// Fill out padding
				pad[0]=0;
				pad[1]=0;
				pad[2]=button->icon_pos_x;
				pad[3]=button->icon_pos_y;
				pad[4]=button->flags;

#ifdef __AROS__
				CopyMem(&button->pos,&pos_be,sizeof(struct IBox));

				pos_be.Left = AROS_WORD2BE(pos_be.Left);
				pos_be.Top = AROS_WORD2BE(pos_be.Top);
				pos_be.Width = AROS_WORD2BE(pos_be.Width);
				pos_be.Height = AROS_WORD2BE(pos_be.Height);

				pad[2] = AROS_LONG2BE(pad[2]);
				pad[3] = AROS_LONG2BE(pad[3]);
				pad[4] = AROS_LONG2BE(pad[4]);
				
				if (!(IFFWriteChunkBytes(iff,pad,sizeof(pad))) ||
					!(IFFWriteChunkBytes(iff,&pos_be,sizeof(struct IBox))) ||
					!(IFFWriteChunkBytes(iff,button->node.ln_Name,strlen(button->node.ln_Name)+1)) ||
					!(IFFPopChunk(iff))) break;
#else
				// Write padding and position and path
				if (!(IFFWriteChunkBytes(iff,pad,sizeof(pad))) ||
					!(IFFWriteChunkBytes(iff,&button->pos,sizeof(struct IBox))) ||
					!(IFFWriteChunkBytes(iff,button->node.ln_Name,strlen(button->node.ln_Name)+1)) ||
					!(IFFPopChunk(iff))) break;
#endif

				// Remove this node, get next
				Remove((struct Node *)button);
				button=next;
			}
		}

		// Otherwise, snapshotting current layout
		else
		{
			// Lock lister list
			lock_listlock(&GUI->lister_list,FALSE);

			// Write lister definitions
			for (ipc=(IPCData *)GUI->lister_list.list.lh_Head;
				ipc->node.mln_Succ;
				ipc=(IPCData *)ipc->node.mln_Succ)
			{
				// Get lister
				lister=IPCDATA(ipc);

				// Valid lister definition?
				if (lister->lister)
				{
					// Update lister
					lister_update(lister);

					// Write lister data
					if (!(SaveListerDef(iff,lister->lister))) break;
				}
			}

			// Unlock lister list
			unlock_listlock(&GUI->lister_list);

			// Fail?
			if (ipc->node.mln_Succ)
			{
				success=IoErr();
				break;
			}

			// Lock buttons list
			lock_listlock(&GUI->buttons_list,FALSE);

			// Write button file paths
			for (ipc=(IPCData *)GUI->buttons_list.list.lh_Head;
				ipc->node.mln_Succ;
				ipc=(IPCData *)ipc->node.mln_Succ)
			{
				// Get buttons pointer
				buttons=IPCDATA(ipc);

				// Valid button configuration?
				if (buttons->bank && buttons->bank->path[0])
				{
					ULONG pad[5];
#ifdef __AROS__
					struct IBox pos_be;
#endif

					// Update buttons
					buttons_update(buttons);

					// Write bank header
					if (!(IFFPushChunk(iff,ID_BANK))) break;

					// Fill out padding
					pad[0]=0;
					pad[1]=0;
					pad[2]=buttons->icon_pos_x;
					pad[3]=buttons->icon_pos_y;
					pad[4]=buttons->flags&BUTTONF_ICONIFIED;

#ifdef __AROS__
					CopyMem(&buttons->pos,&pos_be,sizeof(struct IBox));

					pos_be.Left = AROS_WORD2BE(pos_be.Left);
					pos_be.Top = AROS_WORD2BE(pos_be.Top);
					pos_be.Width = AROS_WORD2BE(pos_be.Width);
					pos_be.Height = AROS_WORD2BE(pos_be.Height);

					pad[2] = AROS_LONG2BE(pad[2]);
					pad[3] = AROS_LONG2BE(pad[3]);
					pad[4] = AROS_LONG2BE(pad[4]);
					
					if (!(IFFWriteChunkBytes(iff,pad,sizeof(pad))) ||
						!(IFFWriteChunkBytes(iff,&pos_be,sizeof(struct IBox))) ||
						!(IFFWriteChunkBytes(iff,buttons->bank->path,strlen(buttons->bank->path)+1)) ||
						!(IFFPopChunk(iff))) break;
#else
					// Write padding and position and path
					if (!(IFFWriteChunkBytes(iff,pad,sizeof(pad))) ||
						!(IFFWriteChunkBytes(iff,&buttons->pos,sizeof(struct IBox))) ||
						!(IFFWriteChunkBytes(iff,buttons->bank->path,strlen(buttons->bank->path)+1)) ||
						!(IFFPopChunk(iff))) break;
#endif
				}
			}

			// Unlock buttons list
			unlock_listlock(&GUI->buttons_list);

			// Fail?
			if (ipc->node.mln_Succ)
			{
				success=IoErr();
				break;
			}

			// Lock StartMenu list
			lock_listlock(&GUI->startmenu_list,FALSE);

			// Write StartMenu paths
			for (ipc=(IPCData *)GUI->startmenu_list.list.lh_Head;
				ipc->node.mln_Succ;
				ipc=(IPCData *)ipc->node.mln_Succ)
			{
				StartMenu *menu;

				// Get menu pointer
				menu=(StartMenu *)IPCDATA(ipc);

				// Lock the bank
				GetSemaphore(&menu->lock,SEMF_SHARED,0);

				// Valid configuration?
				if (menu->bank && menu->bank->path[0])
				{
					ULONG pad[5];
					struct IBox pos;

					// Get position
					pos.Left=menu->bank->window.pos.Left;
					pos.Top=menu->bank->window.pos.Top;
#ifdef __AROS__
					pos.Left = AROS_WORD2BE(pos.Left);
					pos.Top = AROS_WORD2BE(pos.Top);
#endif

					// Write menu header
					if (!(IFFPushChunk(iff,ID_STRT))) break;

					// Fill out padding
					pad[0]=0;
					pad[1]=0;
					pad[2]=0;
					pad[3]=0;
					pad[4]=0;

					// Write padding and position and path
					if (!(IFFWriteChunkBytes(iff,pad,sizeof(pad))) ||
						!(IFFWriteChunkBytes(iff,&pos,sizeof(struct IBox))) ||
						!(IFFWriteChunkBytes(iff,menu->bank->path,strlen(menu->bank->path)+1)) ||
						!(IFFPopChunk(iff))) break;
				}

				// Unlock bank
				FreeSemaphore(&menu->lock);
			}

			// Unlock startmenu list
			unlock_listlock(&GUI->startmenu_list);

			// Fail?
			if (ipc->node.mln_Succ) success=IoErr();
		}

		// Failed?
		if (success) break;

		// Go through desktop list
		for (desk=(Cfg_Desktop *)env->desktop.mlh_Head;
			desk->node.mln_Succ;
			desk=(Cfg_Desktop *)desk->node.mln_Succ)
		{
#ifdef __AROS__
			char buffer[64]; // 12 bytes CFG_DESK + 34 bytes device name + 18 bytes extra
			CFG_DESK *desk_be = (CFG_DESK *)buffer;

			CopyMem(&desk->data,desk_be,desk->data.dt_Size);

			desk_be->dt_Type = AROS_WORD2BE(desk_be->dt_Type);
			desk_be->dt_Size = AROS_WORD2BE(desk_be->dt_Size);
			desk_be->dt_Flags = AROS_LONG2BE(desk_be->dt_Flags);
			if (desk->data.dt_Type != DESKTOP_HIDE_BAD && desk->data.dt_Type != DESKTOP_HIDE)
				desk_be->dt_Data = AROS_LONG2BE(desk_be->dt_Data);

			if (!(IFFWriteChunk(iff,desk_be,ID_DESK,desk->data.dt_Size)))
#else
			// Write chunk
			if (!(IFFWriteChunk(iff,&desk->data,ID_DESK,desk->data.dt_Size)))
#endif
			{
				success=IoErr();
				break;
			}
		}

		// Go through pathlist
		for (node=env->path_list.mlh_Head;node->mln_Succ;node=node->mln_Succ)
		{
			// Write chunk
			if (!(IFFWriteChunk(iff,(char *)(node+1),ID_PATH,strlen((char *)(node+1)))))
			{
				success=IoErr();
				break;
			}
		}

		// Go through sound list
		for (sound=(Cfg_SoundEntry *)env->sound_list.mlh_Head;sound->dse_Node.ln_Succ;sound=(Cfg_SoundEntry *)sound->dse_Node.ln_Succ)
		{
#ifdef __AROS__
			Cfg_SoundEntry sound_be;

			CopyMem(&sound,&sound_be,sizeof(Cfg_SoundEntry));

			sound_be.dse_Volume = AROS_WORD2BE(sound_be.dse_Volume);
			sound_be.dse_Flags = AROS_WORD2BE(sound_be.dse_Flags);

			if (!(IFFWriteChunk(iff,sound_be.dse_Name,ID_SNDX,32+2+2+strlen(sound->dse_Sound)+1)))
#else
			// Write chunk
			if (!(IFFWriteChunk(iff,sound->dse_Name,ID_SNDX,32+2+2+strlen(sound->dse_Sound)+1)))
#endif
			{
				success=IoErr();
				break;
			}
		}
		break;
	}

	// Close file
	if (!iff) success=IoErr();
	else IFFClose(iff);

#ifdef __AROS__
	FreeVec(env_be);
#endif

	// Write icon if successful (and enabled)
	if ((!success) && (GUI->flags&GUIF_SAVE_ICONS))
	{
		WriteFileIcon("dopus5:icons/Environment",name);
	}

	// Free stuff
	FreeMemH(opendata);
	ClearMemHandle(env->volatile_memory);
	return success;
}
Ejemplo n.º 20
0
void action(void)
{
    struct AvailFontsHeader *afh;
    struct TAvailFonts *af;
    
    ULONG bufsize = 10000, shortage;
    ULONG numentries;
    ULONG i;
    
    buf = AllocVec(bufsize, MEMF_ANY);
    if (!buf) cleanup("out of memory!");
    
    do
    {
    	shortage = AvailFonts(buf, bufsize, AFF_MEMORY | AFF_DISK | AFF_BITMAP | AFF_TAGGED);
	if (shortage)
	{
	    bufsize += shortage;
	    
    	    FreeVec(buf);
	    buf = AllocVec(bufsize, MEMF_ANY);
	    if (!buf) cleanup("out of memory!");
	}
    } while (shortage);
    
    afh = (struct AvailFontsHeader *)buf;
    numentries = afh->afh_NumEntries;
    
    printf("numentries = %ld\n", numentries);
    
    af = (struct TAvailFonts *)(buf + 2);
    
    for(i = 0; i < numentries;i++)
    {
#if 1
    	printf("%s/%d [%d] flags = %x style = %x\n",
		af->taf_Attr.tta_Name,
		af->taf_Attr.tta_YSize,
		af->taf_Type,
		af->taf_Attr.tta_Flags,
		af->taf_Attr.tta_Style);
	
	printf("  tags = %p  istagged = %d\n", af->taf_Attr.tta_Tags, (af->taf_Attr.tta_Style & FSF_TAGGED));
		
{
	if ((af->taf_Attr.tta_Style & FSF_TAGGED) && (af->taf_Attr.tta_Tags))
	{
	    struct TagItem *tag, *tstate = af->taf_Attr.tta_Tags;
	   
	    printf("tags = %p\n",  af->taf_Attr.tta_Tags);
	    //Delay(1*50);
	    
	    while((tag = NextTagItem(&tstate)))
	    {
	    	printf(" {%lx,%lx}\n", tag->ti_Tag, tag->ti_Data);
	    }
	}
}
#else
    	printf("#%ld: %s/%d [%d] flags = %x style = %x\n",
	    	i,
		af->taf_Attr.tta_Name,
		af->taf_Attr.tta_YSize,
		af->taf_Type,
		af->taf_Attr.tta_Flags,
		af->taf_Attr.tta_Style);
#endif
		
//	Delay(10);
	af++;
    }
}
Ejemplo n.º 21
0
INLINE BOOL LoadTaskRegDatabase( VOID )
{
	D_S(struct FileInfoBlock,fib);
	BOOL rc = TRUE;
	STRPTR file;
	
	ENTER();
	
	if((file = FileToMem( DATABASE_FILE, fib, DOSBase )))
		transcode( file, fib->fib_Size );
	
	if(file == NULL)
	{
		LONG ioerr;
		
		if((ioerr = IoErr()) != ERROR_OBJECT_NOT_FOUND)
		{
			ShowIoErrMessage("cannot load database");
			rc = FALSE;
		}
	}
	else if(fib->fib_Size < (LONG)sizeof(ULONG) || *((ULONG *)file) != DATABASE_ID)
	{
		if((rc=CorruptDatabase()))
		{
			FreeVec( file );
			file = NULL;
		}
	}
	
	if( rc == TRUE && file != NULL )
	{
		STRPTR ptr=&file[sizeof(ULONG)];
		LONG size=(fib->fib_Size)-sizeof(ULONG), error = 0;
		
		// this is version 1, hence no more code here atm
		DBG_ASSERT(*((ULONG *)ptr)==DATABASE_VERSION);
		ptr += sizeof(ULONG);
		size -= sizeof(ULONG);
		
		/**
		 * NOTE that since memory pools are being used, I free nothing
		 * when a error happens, hence there is no problem on this code
		 */
		while(!error)
		{
			TaskReg * entry;
			
			if(size < (LONG)sizeof(ULONG)) {
				error = TRUE; break;
			}
			
			if(*((ULONG *) ptr ) == DATABASE_EOFID) break;
			
			if((entry = Malloc(sizeof(TaskReg))))
			{
				GetV( entry->TaskNameLength, UWORD );
				if(error) break;
				
				if((entry->TaskName = Malloc(entry->TaskNameLength+1)))
				{
					GetX( entry->TaskName, entry->TaskNameLength);
					if(error) break;
					
					GetV( entry->allow,    BYTE );
					GetV( entry->remember, BYTE );
					if(error) break;
					
					GetV( entry->RegTime.ds_Days,   ULONG );
					GetV( entry->RegTime.ds_Minute, ULONG );
					GetV( entry->RegTime.ds_Tick,   ULONG );
					GetV( entry->ModTime.ds_Days,   ULONG );
					GetV( entry->ModTime.ds_Minute, ULONG );
					GetV( entry->ModTime.ds_Tick,   ULONG );
					
					GetV( entry->accesses,   ULONG );
					GetV( entry->FileCRC,    ULONG );
					GetV( entry->CRCMods,    UWORD );
					GetV( entry->AlertFlags, UWORD );
					GetV( entry->ServerPort, UWORD );
					if(error) break;
					
					AddTail((struct List *) G->TaskRegList, (struct Node *) entry );
					
					#if DATABASE_RESERVED
					ptr += DATABASE_RESERVED;
					size -= DATABASE_RESERVED;
					#endif
				}
				else error = IoErr();
			}
			else error = IoErr();
		}
		
		if( error != 0 )
		{
			if(error == ERROR_NO_FREE_STORE)
			{
				OutOfMemory("loading database");
				rc = FALSE;
			}
			else if((rc = CorruptDatabase()))
			{
				TaskReg * entry;
				
				entry = (TaskReg *)((struct List *)G->TaskRegList)->lh_Head;
				while(TRUE)
				{
					struct MinNode * succ;
					
					if(entry == NULL) break;
					if(!(succ = ((struct MinNode *)entry)->mln_Succ))
						break;
					
					Remove((struct Node *)entry);
					Free(entry->TaskName);
					Free(entry);
					
					entry = (TaskReg *) succ;
				}
				
				NewList((struct List *) G->TaskRegList );
			}
		}
	}
	
	if( file != NULL )
		FreeVec( file );
	
	RETURN(rc);
	return(rc);
}
Ejemplo n.º 22
0
IPTR AboutWindow__MUIM_Window_Setup
(
    Class *CLASS, Object *self, Msg message
)
{
    struct AboutWindow_DATA *data    = INST_DATA(CLASS, self);
    struct Catalog          *catalog = data->awd_Catalog;
    STRPTR                   string  = NULL;
    
    if (!DoSuperMethodA(CLASS, self, message)) return FALSE;

    /*= Setup window title =================================================*/
    {
        STRPTR buffer = NULL;
        ULONG  length = 0;
        
        string = data->awd_Title;
        if (string == NULL)
        {
            GET(self, MUIA_AboutWindow_Title, &string);
            
            if (string != IGNORE)
            {
                if (string == NULL)
                {
                    GET(_app(self), MUIA_Application_Title, &string);
                }
                
                if (string != NULL)
                {
                    length = strlen(string) + strlen(_(MSG_ABOUT)) + 2; /* space + newline */
                    buffer = AllocVec(length, MEMF_ANY);
                    
                    if (buffer != NULL)
                    {
                        buffer[0] = '\0';
                        strlcat(buffer, _(MSG_ABOUT), length);
                        strlcat(buffer, " ", length);
                        strlcat(buffer, string, length);
                        
                        set(self, MUIA_Window_Title, buffer);
                        
                        FreeVec(buffer);
                    }
                }
            }
        }
    }
    
    /*= Setup image ========================================================*/
    if (data->awd_ImageObject == NULL)
    {
        DoMethod(data->awd_RootGroup, OM_REMMEMBER, (IPTR) data->awd_ImageGroup);
    }
    
    /*= Setup version ======================================================*/ 
    /* 
        The version string will have the format:
        MUIX_B"<title>"MUIX_N" <version> (<date>) [<extra>]" 
    */
    {
        STRPTR title         = data->awd_Title,
               versionNumber = data->awd_VersionNumber,
               versionDate   = data->awd_VersionDate,
               versionExtra  = data->awd_VersionExtra,
               buffer        = NULL;
        ULONG  length        = 0;
        
        /*- Setup default values -------------------------------------------*/
        if (title == NULL)
        {
            GET(_app(self), MUIA_Application_Title, &title);
        }
        
        if (versionNumber == NULL)
        {
            GET(_app(self), MUIA_Application_Version_Number, &versionNumber);
        }
        
        if (versionDate == NULL)
        {
            GET(_app(self), MUIA_Application_Version_Date, &versionDate);
        }
        
        if (versionExtra == NULL)
        {
            GET(_app(self), MUIA_Application_Version_Extra, &versionExtra);
        }
        
        /* Simplify later checks a little */
        if (title         == IGNORE) title         = NULL;
        if (versionNumber == IGNORE) versionNumber = NULL;
        if (versionDate   == IGNORE) versionDate   = NULL;
        if (versionExtra  == IGNORE) versionExtra  = NULL;
        
        /*- Calculate length -----------------------------------------------*/
        if (title != NULL)
        {
            length += strlen(MUIX_B) + strlen(title) + strlen(MUIX_N) + 1;
        }
        
        if (versionNumber != NULL)
        {
            length += 1 /* space */ + strlen(versionNumber);
        }
        
        if (versionDate != NULL)
        {
            length += 1 /* space */ + 1 /* ( */ + strlen(versionDate) + 1 /* ) */;
        }
        
        if (versionExtra != NULL)
        {
            length += 1 /* space */ + 1 /* [ */ + strlen(versionExtra) + 1 /* ] */;
        }
        
        /*- Setup version object -------------------------------------------*/
        if (length > 0)
        {
            /*- Allocate memory --------------------------------------------*/
            buffer = AllocVec(length, MEMF_ANY);
            
            if (buffer != NULL)
            {
                buffer[0] = '\0';
                
                /*- Generate text ------------------------------------------*/
                if (title != NULL)
                {
                    strlcat(buffer, MUIX_B, length);
                    strlcat(buffer, title, length);
                    strlcat(buffer, MUIX_N, length);
                }
                
                if (versionNumber != NULL)
                {
                    strlcat(buffer, " ", length);
                    strlcat(buffer, versionNumber, length);
                }
                
                if (versionDate != NULL)
                {
                    strlcat(buffer, " (", length);
                    strlcat(buffer, versionDate, length);
                    strlcat(buffer, ")", length);
                }
                
                if (versionExtra != NULL)
                {
                    strlcat(buffer, " [", length);
                    strlcat(buffer, versionExtra, length);
                    strlcat(buffer, "]", length);
                }
                
                set(data->awd_VersionObject, MUIA_Text_Contents, buffer);
                FreeVec(buffer); /* don't need it anymore */
            }
            else
            {
                DoMethod
                (
                    data->awd_RootGroup, OM_REMMEMBER, (IPTR) data->awd_VersionObject
                );
            }
        }
    }
        
    /*= Setup copyright ====================================================*/
    if (data->awd_Copyright == NULL)
    {
        GET(_app(self), MUIA_Application_Copyright, &data->awd_Copyright);
    }
    
    if (data->awd_Copyright != IGNORE && data->awd_Copyright != NULL)
    {
        SET(data->awd_CopyrightObject, MUIA_Text_Contents, data->awd_Copyright);
    }
    else
    {
        DoMethod(data->awd_RootGroup, OM_REMMEMBER, (IPTR) data->awd_CopyrightObject);
    }
    
    /*= Setup description ==================================================*/
    if (data->awd_Description == NULL)
    {
        GET(_app(self), MUIA_Application_Description, &data->awd_Description);
    }
    
    if (data->awd_Description != IGNORE && data->awd_Description != NULL)
    {
        SET
        (
            data->awd_DescriptionObject, 
            MUIA_Text_Contents, data->awd_Description
        );
    }
    else
    {
        DoMethod
        (
            data->awd_RootGroup, OM_REMMEMBER, (IPTR) data->awd_DescriptionGroup
        );
    }
    
    /* We no longer need to know whether to IGNORE or not */
    if (data->awd_Title == IGNORE) data->awd_Title = NULL;
    if (data->awd_VersionNumber == IGNORE) data->awd_VersionNumber = NULL;
    if (data->awd_VersionDate == IGNORE) data->awd_VersionDate = NULL;
    if (data->awd_VersionExtra == IGNORE) data->awd_VersionExtra = NULL;
    if (data->awd_Copyright == IGNORE) data->awd_Copyright = NULL;
    if (data->awd_Description == IGNORE) data->awd_Description = NULL;
    
    return TRUE;
}
Ejemplo n.º 23
0
LONG GetPath(UBYTE * path, UBYTE * buffer, LONG buffersize)
{
  UBYTE	*pathpart, *filepart;
  UBYTE	*tmp1, *tmp2;
  BPTR	lock;
  struct FileInfoBlock *fib;
  LONG	error = 0;


  /*
   * If there seems to be no path, the pathpart will point to the filepart too, so we
   * need to check for that.
   */
  filepart = FilePart(path);
  pathpart = PathPart(path);

  /*
   * This also handles cases where there is only a volume/device name, only a
   * directory name or a combo of those.
   */
  if	(pathpart == path)
  {

	/*
	 * There seems to be only one component. Copy it if it is not wild. Caller will
	 * have to check whether if it exists and if it is a file or directory.
	 */
	if	(!(ItsWild(pathpart)))
	  pathpart = NULL;
  }

  if	(pathpart != path)
  {

	/*
	 * If pathpart equals filepart (pointer wise) then there is only one component
	 * (possible preceeded by a volume name).
	 */
	if	(pathpart == filepart)
	{
	  if	(!(ItsWild(pathpart)))
		pathpart = NULL;
	}
	else
	{
	  /* Try to lock it to determine if the last component is a directory. */
	  if	(lock = Lock(path, SHARED_LOCK))
	  {
		if	(fib = AllocVec(sizeof(struct FileInfoBlock), MEMF_CLEAR))
		{
		  if	((Examine(lock, fib)) == DOSTRUE)
		  {
			/* Hey it's a directory after all */
			if	(fib->fib_DirEntryType > 0)
			  pathpart = NULL;
		  }
		  FreeVec(fib);
		}
		UnLock(lock);
	  }										  /* else treat it as a filename */
	}

	/* Copy the pathpart in the buffer */
	tmp1 = buffer;
	tmp2 = path;
	while ((*tmp1++ = *tmp2++) && (tmp2 != pathpart))
	{
	  if	(tmp1 == (buffer + buffersize))
	  {
		error = ERROR_NO_FREE_STORE;
		break;
	  }
	}
	*tmp1 = '\0';								/* NULL terminate. */
  }

  return (error);
}
Ejemplo n.º 24
0
static void
Slave( struct ExecBase* SysBase )
{
  struct AHIAudioCtrlDrv* AudioCtrl;
  struct DriverBase*      AHIsubBase;
  struct DeviceBase* DeviceBase;
  BOOL                    running;
  ULONG                   signals;

  AudioCtrl  = (struct AHIAudioCtrlDrv*) FindTask( NULL )->tc_UserData;
  AHIsubBase = (struct DriverBase*) dd->ahisubbase;
  DeviceBase = (struct DeviceBase*) AHIsubBase;

  dd->slavesignal = AllocSignal( -1 );

  if( dd->slavesignal != -1 )
  {
    struct MsgPort*    ahi_mp           = NULL;
    struct AHIRequest* ahi_iorequest    = NULL;
    APTR               ahi_iocopy       = NULL;
    BYTE               ahi_device       = -1;

    struct AHIRequest* ahi_io[ 2 ]      = { NULL,  NULL };
    BOOL               ahi_io_used[ 2 ] = { FALSE, FALSE };

    ULONG              frame_length     = 0;

    ahi_mp = CreateMsgPort();

    if( ahi_mp != NULL )
    {
      ahi_iorequest = CreateIORequest( ahi_mp, sizeof( struct AHIRequest ) );

      if( ahi_iorequest != NULL )
      {
	ahi_iorequest->ahir_Version = 4;

	ahi_device = OpenDevice( AHINAME, dd->unit,
				 (struct IORequest*) ahi_iorequest, 0 );

	if( ahi_device == 0 )
	{
	  struct Library* AHIBase = (struct Library*) ahi_iorequest->ahir_Std.io_Device;

	  ahi_iocopy = AllocVec( sizeof( *ahi_iorequest ), MEMF_ANY );

	  if( ahi_iocopy != NULL )
	  {
	    bcopy( ahi_iorequest, ahi_iocopy, sizeof( *ahi_iorequest ) );

	    ahi_io[ 0 ] = ahi_iorequest;
	    ahi_io[ 1 ] = ahi_iocopy;
    
	    // Everything set up. Tell Master we're alive and healthy.

	    Signal( (struct Task*) dd->mastertask,
		    1L << dd->mastersignal );

	    running = TRUE;

	    // The main playback loop follow

	    while( running )
	    {
	      int skip_mix;
	      APTR tmp_buff;
	      struct AHIRequest* tmp_io;
	      
	      if( ahi_io_used[ 0 ] )
	      {
		LONG  err;
		ULONG mask = ( SIGBREAKF_CTRL_C |
			       (1L << dd->slavesignal) |
			       (1L << ahi_mp->mp_SigBit) );
	      
		signals = Wait( mask );

		if( signals & ( SIGBREAKF_CTRL_C |
				(1L << dd->slavesignal) ) ) 
		{
		  running = FALSE;
		  break;
		}

		err = WaitIO( (struct IORequest*) ahi_io[ 0 ] );

		if( err != 0 )
		{
		  KPrintF( DRIVER ": AHI device error %ld\n", err );
//		  running = FALSE;
		  break;
		}
	      }

	      skip_mix = CallHookPkt( AudioCtrl->ahiac_PreTimerFunc,
				      (Object*) AudioCtrl, 0 );

	      CallHookPkt( AudioCtrl->ahiac_PlayerFunc, AudioCtrl, NULL );
		
	      if( ! skip_mix )
	      {
		CallHookPkt( AudioCtrl->ahiac_MixerFunc, AudioCtrl,
			     dd->mixbuffers[ 0 ] );
	      }
		
	      CallHookPkt( AudioCtrl->ahiac_PostTimerFunc, (Object*) AudioCtrl, 0 );

	      if( frame_length == 0 )
	      {
		frame_length = AHI_SampleFrameSize( AudioCtrl->ahiac_BuffType );
	      }
	      
	      ahi_io[ 0 ]->ahir_Std.io_Command = CMD_WRITE;
	      ahi_io[ 0 ]->ahir_Std.io_Data    = dd->mixbuffers[ 0 ];
	      ahi_io[ 0 ]->ahir_Std.io_Length  = ( AudioCtrl->ahiac_BuffSamples *
						   frame_length );
	      ahi_io[ 0 ]->ahir_Std.io_Offset  = 0;
	      ahi_io[ 0 ]->ahir_Frequency      = AudioCtrl->ahiac_MixFreq;
	      ahi_io[ 0 ]->ahir_Type           = AudioCtrl->ahiac_BuffType;
	      ahi_io[ 0 ]->ahir_Volume         = 0x10000;
	      ahi_io[ 0 ]->ahir_Position       = 0x08000;
	      ahi_io[ 0 ]->ahir_Link           = ( ahi_io_used[ 1 ] ?
						   ahi_io[ 1 ] : NULL );

	      SendIO( (struct IORequest*) ahi_io[ 0 ] );
    
	      tmp_io = ahi_io[ 0 ];
	      ahi_io[ 0 ] = ahi_io[ 1 ];
	      ahi_io[ 1 ] = tmp_io;

	      tmp_buff = dd->mixbuffers[ 0 ];
	      dd->mixbuffers[ 0 ] = dd->mixbuffers[ 1 ];
	      dd->mixbuffers[ 1 ] = tmp_buff;
	      
	      ahi_io_used[ 0 ] = ahi_io_used[ 1 ];
	      ahi_io_used[ 1 ] = TRUE;
	    }

	    
	    if( ahi_io_used[ 0 ] )
	    {
	      AbortIO( (struct IORequest*) ahi_io[ 0 ] );
	      WaitIO( (struct IORequest*) ahi_io[ 0 ] );
	    }

	    if( ahi_io_used[ 1 ] )
	    {
	      AbortIO( (struct IORequest*) ahi_io[ 1 ] );
	      WaitIO( (struct IORequest*) ahi_io[ 1 ] );
	    }
	    
	    FreeVec( ahi_iocopy );
	  }

	  CloseDevice( (struct IORequest*) ahi_iorequest );
	}

	DeleteIORequest( (struct IORequest*) ahi_iorequest );
      }

      DeleteMsgPort( ahi_mp );
    }
  }

  FreeSignal( dd->slavesignal );
  dd->slavesignal = -1;

  Forbid();

  // Tell the Master we're dying

  Signal( (struct Task*) dd->mastertask,
          1L << dd->mastersignal );

  dd->slavetask = NULL;

  // Multitaking will resume when we are dead.
}
Ejemplo n.º 25
0
void ami_drag_selection(struct selection *s)
{
    struct box *text_box;
    int x;
    int y;
    char *utf8text;
    struct ami_text_selection *sel;
    struct IFFHandle *old_iffh = iffh;
    struct gui_window_2 *gwin = ami_window_at_pointer(AMINS_WINDOW);

    if(!gwin)
    {
        DisplayBeep(scrn);
        return;
    }

    x = gwin->win->MouseX;
    y = gwin->win->MouseY;

    if(text_box = ami_text_box_at_point(gwin, (ULONG *)&x, (ULONG *)&y))
    {
        ami_utf8_clipboard = true;

        iffh = ami_clipboard_init_internal(1);

        if(gui_copy_to_clipboard(s))
        {
            browser_window_mouse_click(gwin->bw, BROWSER_MOUSE_PRESS_1, x, y);
            browser_window_key_press(gwin->bw, KEY_PASTE);
        }

        ami_clipboard_free_internal(iffh);
        iffh = old_iffh;
        ami_utf8_clipboard = false;
    }
    else
    {
        x = gwin->win->MouseX;
        y = gwin->win->MouseY;

        if(ami_gadget_hit(gwin->objects[GID_URL], x, y))
        {
            if(sel = ami_selection_to_text(gwin))
            {
                utf8text = ami_utf8_easy(sel->text);
                RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_URL],
                                      gwin->win, NULL, STRINGA_TextVal, utf8text, TAG_DONE);
                FreeVec(sel);
                ami_utf8_free(utf8text);
            }
        }
        else if(ami_gadget_hit(gwin->objects[GID_SEARCHSTRING], x, y))
        {
            if(sel = ami_selection_to_text(gwin))
            {
                utf8text = ami_utf8_easy(sel->text);
                RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_SEARCHSTRING],
                                      gwin->win, NULL, STRINGA_TextVal, utf8text, TAG_DONE);
                FreeVec(sel);
                ami_utf8_free(utf8text);
            }
        }
        else
        {
            DisplayBeep(scrn);
        }
    }
}
Ejemplo n.º 26
0
ULONG
RemoveAudioMode( ULONG           id,
                 struct AHIBase* AHIBase )
{
  struct AHI_AudioMode *node;
  struct AHI_AudioDatabase *audiodb;
  ULONG rc=FALSE;

  if(AHIBase->ahib_DebugLevel >= AHI_DEBUG_HIGH)
  {
    Debug_RemoveAudioMode(id);
  }


  /* Why ?? */

  audiodb = LockDatabaseWrite();

  if(audiodb != NULL)
  {
    UnlockDatabase(audiodb);
  }

  audiodb = LockDatabaseWrite();

  if(audiodb != NULL)
  {
    if(id != AHI_INVALID_ID)
    {
      for(node=(struct AHI_AudioMode *)audiodb->ahidb_AudioModes.mlh_Head;
          node->ahidbn_MinNode.mln_Succ;
          node=(struct AHI_AudioMode *)node->ahidbn_MinNode.mln_Succ)
      {
        if(id == GetTagData(AHIDB_AudioID, AHI_INVALID_ID, node->ahidbn_Tags))
        {
          Remove((struct Node *) node);
          FreeVec(node);
          rc = TRUE;
          break;
        }
      }

      // Remove the entire database if it's empty

      Forbid();

      if(audiodb->ahidb_AudioModes.mlh_Head->mln_Succ == NULL)
      {
        UnlockDatabase(audiodb);

        audiodb = (struct AHI_AudioDatabase *) FindSemaphore(ADB_NAME);

        if(audiodb != NULL)
        {
          RemSemaphore((struct SignalSemaphore *) audiodb);
          FreeVec(audiodb);
        }

        audiodb = NULL;

      }

      Permit();

    }
    UnlockDatabase(audiodb);
  }

  if(AHIBase->ahib_DebugLevel >= AHI_DEBUG_HIGH)
  {
    KPrintF("=>%ld\n",rc);
  }

  return rc;
}
Ejemplo n.º 27
0
void EventLoop(void)
{
    while (1)
    {
        ULONG sigs = 0UL;

        switch(DoMethod(MUIApp, MUIM_Application_NewInput, &sigs))
        {

        case MUIV_Application_ReturnID_Quit:
            return;

        case ACTID_OPEN:
        {
            struct FileRequester *request;

            request = MUI_AllocAslRequestTags(ASL_FileRequest,
                                              ASLFR_Window, xget(MUIWindow, MUIA_Window_Window),
                                              ASLFR_TitleText, msgTextProgramName,
                                              ASLFR_RejectIcons, TRUE,
                                              ASLFR_InitialDrawer, "SYS:Prefs/Presets",
                                              TAG_DONE );
            if( request != NULL )
            {
                DoMethod(MUIApp, MUIA_Application_Sleep, TRUE);
                if (MUI_AslRequest(request, NULL))
                {
                    char *file;

                    DoMethod(MUIApp, MUIA_Application_Sleep, FALSE);

                    file = AllocVec(strlen(request->fr_Drawer)+128,0);

                    if( file != NULL )
                    {
                        CopyMem(request->fr_Drawer, file, strlen(request->fr_Drawer)+1);
                        AddPart(file, request->fr_File, 128);
                        NewSettings(file);
                        GUINewSettings();
                        FreeVec(file);
                    }
                }
                else
                {
                    DoMethod(MUIApp, MUIA_Application_Sleep, FALSE);
                }
                MUI_FreeAslRequest(request);
            }
            break;
        }

        case ACTID_SAVEAS:
        {
            struct FileRequester *request;

            request = MUI_AllocAslRequestTags(ASL_FileRequest,
                                              ASLFR_Window, xget(MUIWindow, MUIA_Window_Window),
                                              ASLFR_TitleText, msgTextProgramName,
                                              ASLFR_RejectIcons, TRUE,
                                              ASLFR_DoSaveMode, TRUE,
                                              ASLFR_InitialDrawer, "SYS:Prefs/Presets",
                                              TAG_DONE);

            if(request != NULL )
            {
                DoMethod(MUIApp, MUIA_Application_Sleep, TRUE);
                FillUnit();
                if (MUI_AslRequest(request, NULL))
                {
                    char *file;

                    DoMethod(MUIApp, MUIA_Application_Sleep, FALSE);

                    file = AllocVec(strlen(request->fr_Drawer)+128,0);

                    if( file != NULL )
                    {
                        CopyMem(request->fr_Drawer, file, strlen(request->fr_Drawer)+1);
                        AddPart(file, request->fr_File, 128);
                        SaveSettings(file, UnitList);
                        if(SaveIcons)
                        {
                            WriteIcon(file);
                        }
                        FreeVec(file);
                    }
                }
                else
                {
                    DoMethod(MUIApp, MUIA_Application_Sleep, FALSE);
                }
                MUI_FreeAslRequest(request);
            }
            break;
        }

        case ACTID_ABOUT:
            MUI_Request(MUIApp, MUIWindow, 0, (char *) msgTextProgramName,
                        (char*)msgButtonOK, (char*)msgTextCopyright, "\033c",
                        (char*)msgTextProgramName, "1996-1999 Stéphane Barbaray/Martin Blom");
            break;

        case ACTID_SAVE:
            FillUnit();
            SaveSettings(ENVFILE, UnitList);
            SaveSettings(ENVARCFILE, UnitList);
            return;

        case ACTID_USE:
            FillUnit();
            SaveSettings(ENVFILE, UnitList);
            return;

        case ACTID_QUIT:
            return;

        case ACTID_DEFAULT:
            NewSettings(NULL);
            GUINewSettings();
            break;

        case ACTID_LASTSAVED:
            NewSettings(ENVARCFILE);
            GUINewSettings();
            break;

        case ACTID_RESTORE:
            NewSettings(args.from);
            GUINewSettings();
            break;

        case ACTID_ICONS:
        {
            APTR item = (APTR)DoMethod(MUIMenu,MUIM_FindUData,ACTID_ICONS);

            if(item)
            {
                if(xget(item, MUIA_Menuitem_Checked))
                {
                    SaveIcons = TRUE;
                }
                else
                {
                    SaveIcons = FALSE;
                }
            }
            break;
        }

        case ACTID_HELP:
            DoMethod(MUIApp,MUIM_Application_ShowHelp,NULL,NULL,"AHI",0);
            break;

        case ACTID_GUIDE:
            DoMethod(MUIApp,MUIM_Application_ShowHelp,NULL,NULL,"MAIN",0);
            break;

        case ACTID_HELPINDEX:
            DoMethod(MUIApp,MUIM_Application_ShowHelp,NULL,NULL,"Concept Index",0);
            break;

        case ACTID_UNIT:
            FillUnit();
            NewUnit(xget(MUIUnit,MUIA_Cycle_Active));
            GUINewUnit();
            break;

        case ACTID_MODE:
            FillUnit();
            NewMode(xget(MUIList, MUIA_List_Active));
            GUINewMode();
            break;

        case ACTID_DEBUG:
        case ACTID_SURROUND:
        case ACTID_ECHO:
        case ACTID_CPULIMIT:
        case ACTID_CLIPMV:
        case ACTID_ACTIME:
        {
            ULONG debug = AHI_DEBUG_NONE, surround = FALSE, echo = 0, cpu = 90;
            ULONG clip = FALSE, actime = 0;

            get(MUIDebug, MUIA_Cycle_Active, &debug);
            get(MUISurround, MUIA_Cycle_Active, &surround);
            get(MUIEcho, MUIA_Cycle_Active, &echo);
            get(MUIClipvol, MUIA_Cycle_Active, &clip);
            get(MUICpu, MUIA_Numeric_Value, &cpu);
            get(MUIACTime, MUIA_Numeric_Value, &actime);

            globalprefs.ahigp_DebugLevel       = debug;
            globalprefs.ahigp_DisableSurround  = surround;
            globalprefs.ahigp_DisableEcho      = (echo == 2);
            globalprefs.ahigp_FastEcho         = (echo == 1);
            globalprefs.ahigp_MaxCPU           = ((cpu << 16) + 100) / 100;
            globalprefs.ahigp_ClipMasterVolume = clip;
            globalprefs.ahigp_AntiClickTime    = ((actime << 16) + 1000) / 1000;

            break;
        }

        default:
            if (sigs)
            {
                sigs = Wait(sigs | SIGBREAKF_CTRL_C);
                if (sigs & SIGBREAKF_CTRL_C)
                    return;
            }
            break;
        }
    }
}
Ejemplo n.º 28
0
static void GUINewMode(void)
{
  int Max, Sel, Dis;
  char* buffer;
  char* arg1 = getRecord();
  char* arg2 = getAuthor();
  char* arg3 = getCopyright();
  char* arg4 = getDriver();
  char* arg5 = getVersion();
  char* arg6 = getAnnotation();

  buffer = AllocVec( strlen( arg1 ) +
                     strlen( arg2 ) +
                     strlen( arg3 ) +
                     strlen( arg4 ) +
                     strlen( arg5 ) +
                     strlen( arg6 ) +
                     128,
                     MEMF_ANY);

  if( buffer != NULL )
  {
    sprintf( buffer,"0x%08lx\n%s\n%s\n%s\nDevs:AHI/%s.audio\n%s\n%s",
      getAudioMode(),
      arg1,
      arg2,
      arg3,
      arg4,
      arg5,
      arg6 );

    set(MUIInfos, MUIA_Text_Contents, (ULONG) buffer);

    FreeVec(buffer);
  }

  Max = max(state.Frequencies -1, 0);
  Sel = min(Max, state.FreqSelected);
  Dis = Max==0;
  set(MUIFreq, MUIA_Disabled, Dis);
  if( !Dis )
  {
    set(MUIFreq, MUIA_Numeric_Max, Max);
    set(MUIFreq, MUIA_Numeric_Value, Sel);
  }
  set(MUILFreq, MUIA_Text_Contents, (ULONG) getFreq());

  Max = max(state.Channels, 0);
  Sel = min(Max, state.ChannelsSelected);
  Dis = (Max == 0 || Max == 1) || state.ChannelsDisabled;
  set(MUIChannels, MUIA_Disabled, Dis);
  if( !Dis )
  {
    set(MUIChannels, MUIA_Numeric_Max, Max);
    set(MUIChannels, MUIA_Numeric_Value, Sel);
  }
  set(MUILChannels, MUIA_Text_Contents, (ULONG) getChannels());

  if( state.ChannelsDisabled || AHIBase->lib_Version < 5)
  {
    set(MUIScalemode, MUIA_Disabled, TRUE);
    set(MUIScalemode, MUIA_Cycle_Active, AHI_SCALE_FIXED_SAFE);
  }
  else
  {
    set(MUIScalemode, MUIA_Disabled, FALSE);
    set(MUIScalemode, MUIA_Cycle_Active, state.ScaleModeSelected);
  }
  
  Max = max(state.OutVols -1, 0);
  Sel = min(Max, state.OutVolSelected);
  Dis = Max==0;
  set(MUIOutvol, MUIA_Disabled, Dis);
  if( !Dis )
  {
    set(MUIOutvol, MUIA_Numeric_Max, Max);
    set(MUIOutvol, MUIA_Numeric_Value, Sel);
  }
  set(MUILOutvol, MUIA_Text_Contents, (ULONG) getOutVol());

  Max = max(state.MonVols -1, 0);
  Sel = min(Max, state.MonVolSelected);
  Dis = Max==0;
  set(MUIMonvol, MUIA_Disabled, Dis);
  if( !Dis )
  {
    set(MUIMonvol, MUIA_Numeric_Max, Max);
    set(MUIMonvol, MUIA_Numeric_Value, Sel);
  }
  set(MUILMonvol, MUIA_Text_Contents, (ULONG) getMonVol());

  Max = max(state.Gains -1, 0);
  Sel = min(Max, state.GainSelected);
  Dis = Max==0;
  set(MUIGain, MUIA_Disabled, Dis);
  if( !Dis )
  {
    set(MUIGain, MUIA_Numeric_Max, Max);
    set(MUIGain, MUIA_Numeric_Value, Sel);
  }
  set(MUILGain, MUIA_Text_Contents, (ULONG) getGain());

  Max = max(state.Inputs -1, 0);
  Sel = min(Max, state.InputSelected);
  Dis = Max==0;
  set(MUIInput, MUIA_Disabled, Dis);
  if( !Dis )
  {
    set(MUIInput, MUIA_Numeric_Max, Max);
    set(MUIInput, MUIA_Numeric_Value, Sel);
  }
  set(MUILInput, MUIA_Text_Contents, (ULONG) getInput());

  Max = max(state.Outputs -1, 0);
  Sel = min(Max, state.OutputSelected);
  Dis = Max==0;
  set(MUIOutput, MUIA_Disabled, Dis);
  if( !Dis )
  {
    set(MUIOutput, MUIA_Numeric_Max, Max);
    set(MUIOutput, MUIA_Numeric_Value, Sel);
  }
  set(MUILOutput, MUIA_Text_Contents, (ULONG) getOutput());


  set(MUIPlay, MUIA_Disabled, getAudioMode() == AHI_INVALID_ID);
}
Ejemplo n.º 29
0
	APTR ReAllocVec (

/*  SYNOPSIS */
	APTR  oldmem,
	ULONG newsize,
	ULONG requirements)

/*  FUNCTION
	Change the size of an AllocVec:ed part of memory. The memory must
	have been allocated by AllocVec(). If you reduce the
	size, the old contents will be lost. If you enlarge the size,
	the new contents will be undefined.

    INPUTS
	oldmen - What you got from AllocVec().
	newsize - The new size.
	requirements - The (new) requirements.
		Note that if no new block of memory is allocated, the
		requirements are not considered.

    RESULT
	A pointer to the allocated memory or NULL. If you don't need the
	memory anymore, you can pass this pointer to FreeVec().

    NOTES
	If you get NULL, the memory at oldmem will not have been freed and
	can still be used.
	Note that if no new block of memory is allocated, the requirements
	are not considered.

        This function must not be used in a shared library or in a
	threaded application. (???)


    EXAMPLE

    BUGS

    SEE ALSO
	exec.library/AllocVec(), exec.library/FreeVec(), exec.library/CopyMem()

    INTERNALS

    HISTORY

******************************************************************************/
{
//    AROS_LIBFUNC_INIT
    UBYTE * mem, * newmem;
    ULONG oldsize;

    if (!oldmem)
	return AllocVec (newsize, requirements);

    mem = (UBYTE *)oldmem - AROS_ALIGN(sizeof(ULONG));
    oldsize = *((ULONG *)mem) - sizeof(ULONG);

    /* Reduce or enlarge the memory ? */
    if (newsize < oldsize)
    {
	/* Don't change anything for small changes */
	if ((oldsize - newsize) < REALLOC_MINDECREASE)
	    newmem = oldmem;
	else
	    goto copy;
    }
    else if (newsize == oldsize) /* Keep the size ? */
	newmem = oldmem;
    else
    {
	/* It is likely that if memory is ReAllocVec:ed once it will
	   be ReAllocVec:ed again, so don't be too stingy with memory */
	if ((newsize - oldsize) < REALLOC_MININCREASE)
	    newsize = oldsize + REALLOC_MININCREASE;
copy:
	newmem = AllocVec(newsize, requirements);

	if (newmem)
	{
	    CopyMem (oldmem, newmem, newsize);
	    FreeVec (oldmem);
	}
    }

    return newmem;
//    AROS_LIBFUNC_EXIT
} /* ReAllocVec */
Ejemplo n.º 30
0
// Sort a list of files
void buffer_sort_list(
	DirBuffer		*buffer,
	struct MinList	*file_list,
	long			file_count,
	long			dir_count)
{
	ListFormat *format;
	DirEntry *entry;
	BOOL sort_reverse=0;
	short sort_method;

	// Get sort format
	format=&buffer->buf_ListFormat;

	// See if reverse sorting is set for this window
	if (format->sort.sort_flags&SORT_REVERSE) sort_reverse=1;

	// Get desired sort method
	sort_method=format->sort.sort;
	if (sort_method<0 || sort_method>=DISPLAY_LAST)
		sort_method=DISPLAY_NAME;

	// Sort directories and files separately?
	if (format->sort.separation==SEPARATE_DIRSFIRST ||
		format->sort.separation==SEPARATE_FILESFIRST)
	{
		DirEntry **file_array,**dir_array;
		long file_num,dir_num,num;

		// Allocate arrays
		if (!(file_array=AllocVec(sizeof(DirEntry *)*(file_count+1),0)) ||
			!(dir_array=AllocVec(sizeof(DirEntry *)*(dir_count+1),0)))	
		{
			// Failed; fall back to insertion sort
			FreeVec(file_array);
			buffer_insert_sort_list(buffer,file_list);
			return;
		}

		// Build arrays
		for (entry=(DirEntry *)file_list->mlh_Head,file_num=0,dir_num=0;
			entry->de_Node.dn_Succ;)
		{
			DirEntry *next=(DirEntry *)entry->de_Node.dn_Succ;

			// Test for rejection
			if (buffer_test_file(entry,buffer))
			{
				// Add to reject list
				AddHead((struct List *)&buffer->reject_list,(struct Node *)entry);
				entry->de_Flags|=ENTF_REJECTED;
			}

			// Valid entry
			else
			{
				// Increment buffer entry count
				++buffer->buf_TotalEntries[0];

				// File?
				if (ENTRYTYPE(entry->de_Node.dn_Type)==ENTRY_FILE)
				{
					// Increment file count
					++buffer->buf_TotalFiles[0];
					buffer->buf_TotalBytes[0]+=entry->de_Size;
					if (entry->de_Flags&ENTF_SELECTED)
					{
						++buffer->buf_SelectedFiles[0];
						buffer->buf_SelectedBytes[0]+=entry->de_Size;
					}

					// Store in file array
					file_array[file_num++]=entry;
				}

				// Directory
				else
				if (ENTRYTYPE(entry->de_Node.dn_Type)==ENTRY_DIRECTORY)
				{
					// Increment directory count
					++buffer->buf_TotalDirs[0];
					if (entry->de_Flags&ENTF_SELECTED) ++buffer->buf_SelectedDirs[0];
					buffer->buf_TotalBytes[0]+=entry->de_Size;
					if (entry->de_Flags&ENTF_SELECTED) buffer->buf_SelectedBytes[0]+=entry->de_Size;

					// Store in dir array
					dir_array[dir_num++]=entry;
				}
			}

			// Get next
			entry=next;
		}

		// Sort the arrays
		if (dir_num>0) buffer_sort_array(dir_array,dir_num,sort_method);
		if (file_num>0) buffer_sort_array(file_array,file_num,sort_method);

		// Files first?
		if ((format->sort.separation==SEPARATE_FILESFIRST && !sort_reverse) ||
			(format->sort.separation==SEPARATE_DIRSFIRST && sort_reverse))
		{
			// Go through file array
			for (num=0;num<file_num;num++)
			{
				// Add to entry list
				if (sort_reverse)
				{
					AddHead((struct List *)&buffer->entry_list,(struct Node *)file_array[num]);
				}
				else
				{
					AddTail((struct List *)&buffer->entry_list,(struct Node *)file_array[num]);
				}
			}

			// Go through directory array
			for (num=0;num<dir_num;num++)
			{
				// Add to entry list
				if (sort_reverse)
				{
					AddHead((struct List *)&buffer->entry_list,(struct Node *)dir_array[num]);
				}
				else
				{
					AddTail((struct List *)&buffer->entry_list,(struct Node *)dir_array[num]);
				}
			}
		}

		// Directories first
		else
		{
			// Go through directory array
			for (num=0;num<dir_num;num++)
			{
				// Add to entry list
				if (sort_reverse)
				{
					AddHead((struct List *)&buffer->entry_list,(struct Node *)dir_array[num]);
				}
				else
				{
					AddTail((struct List *)&buffer->entry_list,(struct Node *)dir_array[num]);
				}
			}

			// Go through file array
			for (num=0;num<file_num;num++)
			{
				// Add to entry list
				if (sort_reverse)
				{
					AddHead((struct List *)&buffer->entry_list,(struct Node *)file_array[num]);
				}
				else
				{
					AddTail((struct List *)&buffer->entry_list,(struct Node *)file_array[num]);
				}
			}
		}

		// Get first file pointer
		if (file_num<1) buffer->first_file=0;
		else
		if (sort_reverse) buffer->first_file=file_array[file_num-1];
		else buffer->first_file=file_array[0];

		// Get first directory pointer
		if (dir_num<1) buffer->first_dir=0;
		else
		if (sort_reverse) buffer->first_dir=dir_array[dir_num-1];
		else buffer->first_dir=dir_array[0];

		// Free sort arrays
		FreeVec(file_array);
		FreeVec(dir_array);
	}

	// Sort together
	else
	{
		DirEntry **array;
		long total_num,num;

		// Allocate array
		if (!(array=AllocVec(sizeof(DirEntry *)*(file_count+dir_count+1),0)))
		{
			// Failed; fall back to insertion sort
			buffer_insert_sort_list(buffer,file_list);
			return;
		}

		// Build array
		for (entry=(DirEntry *)file_list->mlh_Head,total_num=0;
			entry->de_Node.dn_Succ;)
		{
			DirEntry *next=(DirEntry *)entry->de_Node.dn_Succ;

			// Test for rejection
			if (buffer_test_file(entry,buffer))
			{
				// Add to reject list
				AddHead((struct List *)&buffer->reject_list,(struct Node *)entry);
				entry->de_Flags|=ENTF_REJECTED;
			}

			// Valid entry
			else
			{
				// Increment buffer entry count
				++buffer->buf_TotalEntries[0];

				// File?
				if (ENTRYTYPE(entry->de_Node.dn_Type)==ENTRY_FILE)
				{
					// Increment buffer count
					++buffer->buf_TotalFiles[0];
					buffer->buf_TotalBytes[0]+=entry->de_Size;
					if (entry->de_Flags&ENTF_SELECTED)
					{
						++buffer->buf_SelectedFiles[0];
						buffer->buf_SelectedBytes[0]+=entry->de_Size;
					}
				}

				// Directory
				else
				if (ENTRYTYPE(entry->de_Node.dn_Type)==ENTRY_DIRECTORY)
				{
					++buffer->buf_TotalDirs[0];
					if (entry->de_Flags&ENTF_SELECTED) ++buffer->buf_SelectedDirs[0];
					buffer->buf_TotalBytes[0]+=entry->de_Size;
					if (entry->de_Flags&ENTF_SELECTED) buffer->buf_SelectedBytes[0]+=entry->de_Size;
				}

				// Store in array
				array[total_num++]=entry;
			}

			// Get next
			entry=next;
		}

		// Sort the array
		if (total_num>0) buffer_sort_array(array,total_num,sort_method);

		// Go through array
		for (num=0;num<total_num;num++)
		{
			// Add to entry list
			if (sort_reverse)
			{
				AddHead((struct List *)&buffer->entry_list,(struct Node *)array[num]);
			}
			else
			{
				AddTail((struct List *)&buffer->entry_list,(struct Node *)array[num]);
			}
		}

		// Clear first file/directory pointers
		buffer->first_file=0;
		buffer->first_dir=0;

		// Free sort array
		FreeVec(array);
	}
}