Exemple #1
0
LONG SendRexxCommand(CONST_STRPTR port, CONST_STRPTR Cmd, STRPTR Result, LONG ResultSize)
{
	struct MsgPort *RexxPort;
	struct MsgPort *ReplyPort = &((struct Process *)FindTask(NULL))->pr_MsgPort;
	struct Library *RexxSysBase;
#ifdef __AMIGAOS4__
	struct RexxSysIFace *IRexxSys;
#else
	void *IRexxSys;
#endif
	int rc;

	*Result = '\0';

	if ((RexxSysBase = OpenLibraryInterface("rexxsyslib.library", 36L, &IRexxSys)))
	{
		Forbid();

		if ((RexxPort = FindPort(port)))
		{
			struct RexxMsg *rexxMsg, *Answer;

			if ((rexxMsg = CreateRexxMsg(ReplyPort, NULL, NULL)))
			{
				if ((rexxMsg->rm_Args[0] = (STRPTR)CreateArgstring(Cmd, strlen(Cmd))))
				{
					rexxMsg->rm_Action = RXCOMM | RXFF_RESULT;

					PutMsg(RexxPort, &rexxMsg->rm_Node);
					Permit();

					do
					{
						WaitPort(ReplyPort);
						Answer = (struct RexxMsg *)GetMsg(ReplyPort);
					} while (Answer == NULL);

					if ((rc = (Answer->rm_Result1 == RETURN_OK)))
					{
						if (Answer->rm_Result2)
						{
							strncpy(Result, (STRPTR)Answer->rm_Result2, ResultSize);
							DeleteArgstring((STRPTR)Answer->rm_Result2);
						}
					}

					DeleteArgstring((STRPTR)ARG0(Answer));
					DeleteRexxMsg(Answer);

					CloseLibraryInterface(RexxSysBase,IRexxSys);
					return rc;
				} else
				{
					DeleteRexxMsg(rexxMsg);
				}
			}
		}

		Permit();

		CloseLibraryInterface(RexxSysBase,IRexxSys);
	}

	return 0;
}
Exemple #2
0
static void handle_startup_msg (void)
{
    struct Process *self = (struct Process*) FindTask (NULL);
    WaitPort (&self->pr_MsgPort);
    ReplyMsg (GetMsg (&self->pr_MsgPort));
}
Exemple #3
0
void amiga_init (char *dir)
{
  if ((DefaultPubScreen = LockPubScreen (0)) == 0)
    exit (1);
  screen_ratio (DefaultPubScreen);

  char prog_name[256];
  static char font_name[MAXFONTPATH];
  char *font_desc, *name_ptr;
  static WORD pens[] =
  {-1};
  static struct TextAttr font =
  {NULL, 0, FS_NORMAL, 0};
  int window = 0;

  if (Icon == NULL)
  {
    if (GetProgramName (prog_name, 256))
      Icon = GetDiskObject (prog_name);
  }

  if (Icon)
  {
    if (FindToolType (Icon->do_ToolTypes, "WINDOW"))
      window = 1;
    if (font_desc = FindToolType (Icon->do_ToolTypes, "FONT"))
    {
      strcpy (font_name, font_desc);
      if (name_ptr = strrchr (font_name, '/'))
      {
	font.ta_Name = font_name;
	font.ta_YSize = atoi (name_ptr + 1);
	strcpy (name_ptr, ".font");
      }
    }
    if (font.ta_Name)
      Font = OpenDiskFont (&font);
  }
  if (Font == NULL)
  {
    font.ta_Name = "topaz.font";
    font.ta_YSize = 8;
    Font = OpenFont (&font);
  }

  if (window == 0)
  {
    if ((Screen = OpenScreenTags (0,
				  SA_Pens, pens,
				  SA_DisplayID, GetVPModeID (&DefaultPubScreen->ViewPort),
				  SA_Overscan, OSCAN_TEXT,
				  SA_Depth, 2,
				  SA_Type, CUSTOMSCREEN | AUTOSCROLL,
				  SA_Font, &font,
				  SA_Title, TitleBar, TAG_DONE)) == 0)
      exit (1);
  }

  if ((Window = OpenWindowTags (0,
				WA_Left, 0,
				WA_Top, Screen ? 2 : DefaultPubScreen->BarHeight + 1,
				WA_Width, Screen ? Screen->Width : ScreenWidth,
				WA_Height, Screen ? Screen->Height - 2 : ScreenHeight - DefaultPubScreen->BarHeight - 1,
				WA_SmartRefresh, 1,
				WA_NewLookMenus, 1,
				WA_AutoAdjust, 1,
				WA_Borderless, Screen ? 1 : 0,
				WA_Backdrop, Screen ? 1 : 0,
				WA_Activate, 1,
				WA_CloseGadget, Screen ? 0 : 1,
				WA_DragBar, Screen ? 0 : 1,
				WA_DepthGadget, Screen ? 0 : 1,
				WA_SizeGadget, Screen ? 0 : 1,
				WA_SizeBBottom, Screen ? 0 : 1,
				WA_Title, TitleBar,
				WA_ScreenTitle, TitleBar,
				WA_IDCMP, IDCMP_RAWKEY | IDCMP_VANILLAKEY | IDCMP_MENUPICK | IDCMP_CLOSEWINDOW | IDCMP_CHANGEWINDOW,
				Screen ? WA_CustomScreen : WA_PubScreen, Screen ? Screen : DefaultPubScreen,
				TAG_DONE)) == 0)
    exit (1);

  ThisProcess = (struct Process *)FindTask(0);
  OldWindowPtr = ThisProcess->pr_WindowPtr;
  ThisProcess->pr_WindowPtr = Window;

  if ((Visual = GetVisualInfo (Window->WScreen, TAG_DONE)) == 0)
    exit (1);
  if ((Menus = CreateMenus (NewMenus, GTMN_NewLookMenus, TRUE, TAG_DONE)) == 0)
    exit (1);
  LayoutMenus (Menus, Visual, GTMN_NewLookMenus, TRUE, TAG_DONE);
  SetMenuStrip (Window, Menus);

  if ((GameReq = alloc_freq (dir)) == 0)
    exit (1);
  if ((SaveReq = alloc_freq (dir)) == 0)
    exit (1);
  if ((ScriptReq = alloc_freq (dir)) == 0)
    exit (1);

  RastPort = Window->RPort;
  SetDrMd (RastPort, JAM2);
  SetAPen (RastPort, 1);
  SetBPen (RastPort, 0);
  SetFont (RastPort, Font);
  DisplayHeight = ((Window->Height - Window->BorderTop - Window->BorderBottom) / RastPort->TxHeight) - 1;
  PreviousHeight = DisplayHeight;

  reset_cursor ();
}
Exemple #4
0
int main(void)
{
    if (IntuitionBase->LibNode.lib_Version == VERSION_NUMBER)
    {
        struct MsgPort *port = CreateMsgPort();
        if (port)
        {
            struct IOStdReq *req = CreateIORequest(port, sizeof(*req));
            if (req)
            {
                if (OpenDevice("input.device", 0, req, 0) == 0)
                {
                    BYTE old_pri;

                    req->io_Command = IND_ADDHANDLER;
                    req->io_Data = &interrupt;
                    DoIO(req);

                    /* Make sure we have a higher priority than the
                     * input.device, in case it gets trapped in an
                     * endless loop.
                     */
                    old_pri = SetTaskPri(FindTask(NULL), 50);

                    /* Also dump if intuition's input handler has been
                     * frozen for more than 2s.
                     */
                    do
                    {
                        ULONG old_secs = IntuitionBase->Seconds;
                        ULONG old_micros = IntuitionBase->Micros;

                        Delay(200);

                        if (old_secs == IntuitionBase->Seconds &&
                                old_micros == IntuitionBase->Micros)
                        {
                            REG_A6 = (ULONG)IntuitionBase;
                            MyEmulHandle->EmulCallDirectOS(-152 * 6);

                            do
                            {
                                Delay(50);
                            }
                            while (old_secs == IntuitionBase->Seconds &&
                                    old_micros == IntuitionBase->Micros);

                        }
                    }
                    while ((SetSignal(0,0) & 0x1000) == 0);

                    SetTaskPri(FindTask(NULL), old_pri);

                    req->io_Command = IND_REMHANDLER;
                    req->io_Data = &interrupt;
                    DoIO(req);

                    CloseDevice(req);
                }

                DeleteIORequest(req);
            }

            DeleteMsgPort(port);
        }
    }

    return 0;
}
Exemple #5
0
static int X11_Init(LIBBASETYPEPTR LIBBASE)
{
    struct x11_staticdata *xsd = &LIBBASE->xsd;

    D(bug("Entering X11_Init\n"));
    if (LIBBASE->library.lib_OpenCnt) {
	D(bug("[X11GFX] Already initialized\n"));
	return TRUE;
    }
    
    InitSemaphore( &xsd->sema );
    InitSemaphore( &xsd->x11sema );
		
    /* Do not need to singlethead this
     * since no other tasks are using X currently
     */

    xsd->display = XCALL(XOpenDisplay, NULL);
    if (xsd->display)
    {
	struct x11task_params 	 xtp;
	struct Task 	    	*x11task;

	XCALL(XSetErrorHandler, MyErrorHandler);
	XCALL(XSetIOErrorHandler, MySysErrorHandler);

        /*
         * XXX on my system, getenv() is declared:
         *
         * extern char *getenv (__const char *__name) __THROW __nonnull ((1)) * __wur;
         *
         * the attributes appear to change the calling convention, so a naive
         * prototype like char *getenv(char *) causes carshes as the returned
         * address is not a valid pointer.
         *
         * ideally this configration variable would be brought in via a
         * bootloader.resource, which hosted doesn't have yet
         */
        /*
	if (getenv, "AROS_X11_FULLSCREEN")
	{
	    xsd->fullscreen = x11_fullscreen_supported(xsd->display);
	}
        */
	
	xsd->delete_win_atom         = XCALL(XInternAtom, xsd->display, "WM_DELETE_WINDOW", FALSE);
	xsd->clipboard_atom          = XCALL(XInternAtom, xsd->display, "CLIPBOARD", FALSE);
	xsd->clipboard_property_atom = XCALL(XInternAtom, xsd->display, "AROS_HOSTCLIP", FALSE);
	xsd->clipboard_incr_atom     = XCALL(XInternAtom, xsd->display, "INCR", FALSE);
	xsd->clipboard_targets_atom  = XCALL(XInternAtom, xsd->display, "TARGETS", FALSE);
	
	xtp.parent = FindTask(NULL);
	xtp.ok_signal	= SIGBREAKF_CTRL_E;
	xtp.fail_signal	= SIGBREAKF_CTRL_F;
	xtp.kill_signal	= SIGBREAKF_CTRL_C;
	xtp.xsd		= xsd;

	if ((x11task = create_x11task(&xtp)))
	{			
	    if (initclasses(xsd))
	    {
		D(bug("X11_Init succeeded\n"));
		return TRUE;
	    }
	    
	    Signal(x11task, xtp.kill_signal);
	}

	XCALL(XCloseDisplay, xsd->display);

    }
    
    D(bug("X11_Init failed\n"));
    
    return FALSE;
}
Exemple #6
0
    /* xoper hunks Shell Process */

    num=0;
    for (data = (ULONG *)BADDR(myseglist); data != NULL;
            data = (ULONG *)BADDR(data[0])) {
        if (((ULONG) GC_register_data_segments < (ULONG) &data[1]) ||
                ((ULONG) GC_register_data_segments > (ULONG) &data[1] + data[-1])) {
#             ifdef __GNUC__
            if (dataSegSize == data[-1]) {
                found_segment = TRUE;
            }
# 	      endif
            GC_add_roots_inner((char *)&data[1],
                               ((char *)&data[1]) + data[-1], FALSE);
        }
        ++num;
    } /* for */
# 	ifdef __GNUC__
    if (!found_segment) {
        ABORT("Can`t find correct Segments.\nSolution: Use an newer version of ixemul.library");
    }
# 	endif
}

#if 0 /* old version */
void GC_register_data_segments()
{
    extern struct WBStartup *_WBenchMsg;
    struct Process	*proc;
    struct CommandLineInterface *cli;
    BPTR myseglist;
    ULONG *data;

    if ( _WBenchMsg != 0 ) {
        if ((myseglist = _WBenchMsg->sm_Segment) == 0) {
            GC_err_puts("No seglist from workbench\n");
            return;
        }
    } else {
        if ((proc = (struct Process *)FindTask(0)) == 0) {
            GC_err_puts("Cannot find process structure\n");
            return;
        }
        if ((cli = BADDR(proc->pr_CLI)) == 0) {
            GC_err_puts("No CLI\n");
            return;
        }
        if ((myseglist = cli->cli_Module) == 0) {
            GC_err_puts("No seglist from CLI\n");
            return;
        }
    }

    for (data = (ULONG *)BADDR(myseglist); data != 0;
            data = (ULONG *)BADDR(data[0])) {
#        ifdef AMIGA_SKIP_SEG
        if (((ULONG) GC_register_data_segments < (ULONG) &data[1]) ||
                ((ULONG) GC_register_data_segments > (ULONG) &data[1] + data[-1])) {
#	 else
        {
#	 endif /* AMIGA_SKIP_SEG */
            GC_add_roots_inner((char *)&data[1],
            ((char *)&data[1]) + data[-1], FALSE);
        }
    }
}
#endif /* old version */


#endif



#ifdef GC_AMIGA_AM

#ifndef GC_AMIGA_FASTALLOC

void *GC_amiga_allocwrapper(size_t size,void *(*AllocFunction)(size_t size2)) {
    return (*AllocFunction)(size);
}

void *(*GC_amiga_allocwrapper_do)(size_t size,void *(*AllocFunction)(size_t size2))
    =GC_amiga_allocwrapper;

#else




void *GC_amiga_allocwrapper_firsttime(size_t size,void *(*AllocFunction)(size_t size2));

void *(*GC_amiga_allocwrapper_do)(size_t size,void *(*AllocFunction)(size_t size2))
    =GC_amiga_allocwrapper_firsttime;


/******************************************************************
   Amiga-spesific routines to obtain memory, and force GC to give
   back fast-mem whenever possible.
	These hacks makes gc-programs go many times faster when
   the amiga is low on memory, and are therefore strictly necesarry.

   -Kjetil S. Matheussen, 2000.
******************************************************************/



/* List-header for all allocated memory. */

struct GC_Amiga_AllocedMemoryHeader {
    ULONG size;
    struct GC_Amiga_AllocedMemoryHeader *next;
};
struct GC_Amiga_AllocedMemoryHeader *GC_AMIGAMEM=(struct GC_Amiga_AllocedMemoryHeader *)(int)~(NULL);



/* Type of memory. Once in the execution of a program, this might change to MEMF_ANY|MEMF_CLEAR */

ULONG GC_AMIGA_MEMF = MEMF_FAST | MEMF_CLEAR;


/* Prevents GC_amiga_get_mem from allocating memory if this one is TRUE. */
#ifndef GC_AMIGA_ONLYFAST
BOOL GC_amiga_dontalloc=FALSE;
#endif

#ifdef GC_AMIGA_PRINTSTATS
int succ=0,succ2=0;
int nsucc=0,nsucc2=0;
int nullretries=0;
int numcollects=0;
int chipa=0;
int allochip=0;
int allocfast=0;
int cur0=0;
int cur1=0;
int cur10=0;
int cur50=0;
int cur150=0;
int cur151=0;
int ncur0=0;
int ncur1=0;
int ncur10=0;
int ncur50=0;
int ncur150=0;
int ncur151=0;
#endif

/* Free everything at program-end. */

void GC_amiga_free_all_mem(void) {
    struct GC_Amiga_AllocedMemoryHeader *gc_am=(struct GC_Amiga_AllocedMemoryHeader *)(~(int)(GC_AMIGAMEM));
    struct GC_Amiga_AllocedMemoryHeader *temp;

#ifdef GC_AMIGA_PRINTSTATS
    printf("\n\n"
           "%d bytes of chip-mem, and %d bytes of fast-mem where allocated from the OS.\n",
           allochip,allocfast
          );
    printf(
        "%d bytes of chip-mem were returned from the GC_AMIGA_FASTALLOC supported allocating functions.\n",
        chipa
    );
    printf("\n");
    printf("GC_gcollect was called %d times to avoid returning NULL or start allocating with the MEMF_ANY flag.\n",numcollects);
    printf("%d of them was a success. (the others had to use allocation from the OS.)\n",nullretries);
    printf("\n");
    printf("Succeded forcing %d gc-allocations (%d bytes) of chip-mem to be fast-mem.\n",succ,succ2);
    printf("Failed forcing %d gc-allocations (%d bytes) of chip-mem to be fast-mem.\n",nsucc,nsucc2);
    printf("\n");
    printf(
        "Number of retries before succeding a chip->fast force:\n"
        "0: %d, 1: %d, 2-9: %d, 10-49: %d, 50-149: %d, >150: %d\n",
        cur0,cur1,cur10,cur50,cur150,cur151
    );
    printf(
        "Number of retries before giving up a chip->fast force:\n"
        "0: %d, 1: %d, 2-9: %d, 10-49: %d, 50-149: %d, >150: %d\n",
        ncur0,ncur1,ncur10,ncur50,ncur150,ncur151
    );
#endif

    while(gc_am!=NULL) {
        temp=gc_am->next;
        FreeMem(gc_am,gc_am->size);
        gc_am=(struct GC_Amiga_AllocedMemoryHeader *)(~(int)(temp));
    }
}

#ifndef GC_AMIGA_ONLYFAST

/* All memory with address lower than this one is chip-mem. */

char *chipmax;


/*
 * Allways set to the last size of memory tried to be allocated.
 * Needed to ensure allocation when the size is bigger than 100000.
 *
 */
size_t latestsize;

#endif


/*
 * The actual function that is called with the GET_MEM macro.
 *
 */

void *GC_amiga_get_mem(size_t size) {
    struct GC_Amiga_AllocedMemoryHeader *gc_am;

#ifndef GC_AMIGA_ONLYFAST
    if(GC_amiga_dontalloc==TRUE) {
//		printf("rejected, size: %d, latestsize: %d\n",size,latestsize);
        return NULL;
    }

    // We really don't want to use chip-mem, but if we must, then as little as possible.
    if(GC_AMIGA_MEMF==(MEMF_ANY|MEMF_CLEAR) && size>100000 && latestsize<50000) return NULL;
#endif

    gc_am=AllocMem((ULONG)(size + sizeof(struct GC_Amiga_AllocedMemoryHeader)),GC_AMIGA_MEMF);
    if(gc_am==NULL) return NULL;

    gc_am->next=GC_AMIGAMEM;
    gc_am->size=size + sizeof(struct GC_Amiga_AllocedMemoryHeader);
    GC_AMIGAMEM=(struct GC_Amiga_AllocedMemoryHeader *)(~(int)(gc_am));

//	printf("Allocated %d (%d) bytes at address: %x. Latest: %d\n",size,tot,gc_am,latestsize);

#ifdef GC_AMIGA_PRINTSTATS
    if((char *)gc_am<chipmax) {
        allochip+=size;
    } else {
        allocfast+=size;
    }
#endif

    return gc_am+1;

}




#ifndef GC_AMIGA_ONLYFAST

/* Tries very hard to force GC to find fast-mem to return. Done recursively
 * to hold the rejected memory-pointers reachable from the collector in an
 * easy way.
 *
 */
#ifdef GC_AMIGA_RETRY
void *GC_amiga_rec_alloc(size_t size,void *(*AllocFunction)(size_t size2),const int rec) {
    void *ret;

    ret=(*AllocFunction)(size);

#ifdef GC_AMIGA_PRINTSTATS
    if((char *)ret>chipmax || ret==NULL) {
        if(ret==NULL) {
            nsucc++;
            nsucc2+=size;
            if(rec==0) ncur0++;
            if(rec==1) ncur1++;
            if(rec>1 && rec<10) ncur10++;
            if(rec>=10 && rec<50) ncur50++;
            if(rec>=50 && rec<150) ncur150++;
            if(rec>=150) ncur151++;
        } else {
            succ++;
            succ2+=size;
            if(rec==0) cur0++;
            if(rec==1) cur1++;
            if(rec>1 && rec<10) cur10++;
            if(rec>=10 && rec<50) cur50++;
            if(rec>=50 && rec<150) cur150++;
            if(rec>=150) cur151++;
        }
    }
#endif

    if (((char *)ret)<=chipmax && ret!=NULL && (rec<(size>500000?9:size/5000))) {
        ret=GC_amiga_rec_alloc(size,AllocFunction,rec+1);
//		GC_free(ret2);
    }

    return ret;
}
Exemple #7
0
int open_ssl_lib(void)
{
#ifdef NO_SSL
	return 0;
#else
	struct thread_s *thread;

	SM_ENTER;

	if (!(thread = (struct thread_s*)FindTask(NULL)->tc_UserData))
		goto out;
	if (!open_socket_lib())
		goto out;
#ifndef USE_OPENSSL
	if (!thread->amissllib)
	{

#ifdef USE_AMISSL3
		if (open_amissl3(thread))
		{
#else
		SM_DEBUGF(10,("Open amissl.library\n"));
		if ((thread->amissllib = OpenLibraryInterface("amissl.library",1,&thread->iamissl)))
		{
			if (!InitAmiSSL(AmiSSL_Version,
					AmiSSL_CurrentVersion,
					AmiSSL_Revision, AmiSSL_CurrentRevision,
					AmiSSL_SocketBase, (ULONG)SocketBase,
					/*	AmiSSL_VersionOverride, TRUE,*/ /* If you insist */
					TAG_DONE))
			{
#endif
#endif
				if ((thread->ssl_ctx = ssl_create_context()))
				{
					/* Everything is ok */
					thread->ssllib_opencnt = 1;
					SM_DEBUGF(10,("AmiSSL opened %ld times\n",thread->ssllib_opencnt));
					SM_RETURN(1,"%ld");
					return 1;
				}
#ifndef USE_OPENSSL
#ifdef USE_AMISSL3
			close_amissl3(thread);
		}
#else
				CleanupAmiSSL(TAG_DONE);
			}
			CloseLibraryInterface(thread->amissllib,thread->iamissl);
			thread->iamissl = NULL;
			thread->amissllib = NULL;
		}
#endif

	} else
	{
		thread->ssllib_opencnt++;
		SM_DEBUGF(10,("AmiSSL opened %ld times\n",thread->ssllib_opencnt));
		SM_RETURN(1,"%ld");
		return 1;
	}
#else /* USE_OPENSSL */
	return 1;
#endif
out:
	close_socket_lib();
	SM_RETURN(0,"%ld");
	return 0;
#endif
}
Exemple #8
0
STATIC VOID ProgressWindow_SubTask( STRPTR message )
{
	struct Library * MUIMasterBase;
	
	ENTER();
	DBG_STRING(message);
	
	if((MUIMasterBase = OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN)))
	{
		Object * app, * window;
		
		app = ApplicationObject,
			MUIA_Application_Title      , "AmiNZB.WNDP",
			MUIA_Application_Base       , "AmiNZB.WNDP",
			MUIA_Application_Version    , ProgramVersionTag(),
			MUIA_Application_Description, ProgramDescription(),
			
			SubWindow, window = WindowObject,
				MUIA_Window_Borderless , TRUE,
				MUIA_Window_CloseGadget, FALSE,
				MUIA_Window_SizeGadget , FALSE,
				MUIA_Window_DepthGadget, FALSE,
				MUIA_Window_DragBar    , FALSE,
				MUIA_Window_ScreenTitle, ProgramDescription(),
				WindowContents, VGroup,  GroupFrameT(NULL),
					InnerSpacing(2,4),
					Child, TextObject,
						MUIA_Text_Contents, (ULONG)message,
						MUIA_Text_PreParse, "\033b\033c",
						MUIA_Font, MUIV_Font_Big,
					End,
					Child, BusyObject, End,
				End,
			End,
		End;
		
		if( app )
		{
			DoMethod(window,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,
				app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
			
			set(window,MUIA_Window_Open,TRUE);
			
			if(xget( window, MUIA_Window_Open))
			{
				ULONG sigs = 0;
				BOOL running = TRUE;
				struct Window * iWindow;
				
				if((iWindow = (struct Window *) xget( window, MUIA_Window_Window)))
				{
					((struct Process *)FindTask(0))->pr_WindowPtr = iWindow;
					
					//SetWindowTitles( iWindow, NULL, ProgramDescription());
				}
				
				do {
					switch(DoMethod(app,MUIM_Application_NewInput,&sigs))
					{
						case MUIV_Application_ReturnID_Quit:
							//running = FALSE;
							DisplayBeep(NULL);
							break;
						
						default:
							break;
					}
					if(running && sigs)
					{
						sigs = Wait(sigs | SIGBREAKF_CTRL_C);
						if (sigs & SIGBREAKF_CTRL_C) break;
					}
				} while(running);
				
				set(window,MUIA_Window_Open,FALSE);
			}
			
			MUI_DisposeObject(app);
		}
		
		CloseLibrary(MUIMasterBase);
	}
	
	LEAVE();
}
Exemple #9
0
void fn00001000(int32 d0, byte * a0)
{
	struct Eq_4 * a6_8 = *(struct Eq_4 **) 0x04;
	int32 d2_166 = d0;
	byte * a2_249 = a0;
	if (a6_8->w0014 < 0x24)
	{
		word32 * a0_505 = &globals->ptr2B88;
		word32 d0_508 = 0x0C;
		do
		{
			*a0_505 = 0x00;
			a0_505 = a0_505 + 0x01;
			d0_508 = d0_508 - 0x01;
		} while (d0_508 != 0x00);
	}
	*&globals->ptr2B88 = fp;
	*&globals->ptr2B8C = (struct Eq_4 **) a6_8;
	struct Eq_25 * d0_19 = FindTask(0x00);
	struct Eq_31 * d0_112 = OpenLibrary(0x12BC, 0x00);
	if (d0_112 != null)
	{
		int32 d4_460;
		*&globals->ptr2B90 = (struct Eq_31 **) d0_112;
		if (d0_19->ptr00AC == null)
		{
			d4_460 = 0x02;
			d2_166 = 0x08;
		}
		else
		{
			byte * a0_463 = a0;
			d4_460 = 0x03;
			do
			{
				if (*a0_517 == 0x20)
					d4_460 = DPB(d4_460, (word16) d4_460 + 0x01, 0);
				a0_463 = a0_517 + 0x01;
				byte * a0_517 = a0_463;
			} while (*a0_517 != 0x00);
		}
		int32 d0_105 = d4_460 << 0x02;
		int32 d0_107 = d0_105 + d2_166;
		int32 d3_110 = d0_107 + 0x11;
		int32 d1_111 = 0x00010001;
		d0_112 = AllocMem(d0_107 + 0x11, 0x00010001);
		if (d0_112 != null)
		{
			Eq_119 a6_162;
			struct Eq_67 * dwLoc14_159;
			word32 a0_164;
			d0_112->dw0000 = (word32) (d0_107 + 0x11);
			Eq_126 d4_123 = d4_460 - 0x01;
			d0_112[0x03] = (struct Eq_31) d4_123;
			d0_112[0x02] = (struct Eq_31) (d0_112 + 0x04 + d0_105 / 0x04);
			Mem131[0x00:word32] = 0x00;
			struct Eq_67 * d0_132 = d0_19->ptr00AC;
			d0_132->ptr0000 = d0_107 + 0x11;
			d0_132->dw000C = d4_123 - 0x01;
			d0_132->ptr0008 = (byte *) (&d0_132->ptr0010 + d0_105 / 0x0028);
			Mem150[0x00:word32] = 0x00;
			struct Eq_67 * d0_151 = d0_19->ptr00AC;
			if (d0_151 == null)
			{
				fn00001214(d0_19);
				*&globals->ptr2B94 = (struct Eq_67 **) d0_151;
				*&globals->ptr2B98 = (struct Eq_67 **) d0_151;
				Mem403[0x00:word32] = 0x00;
				dwLoc14_159 = d0_151;
				ui32 d0_406 = d0_151->dw0024;
				if (d0_406 != 0x00)
					Enable();
				Supervisor(d0_132);
				d0_132->dw0004 = d0_406;
				d2_166 = 1005;
				if (d0_406 == 0x00)
				{
					fn0000127C(0x0014);
					return;
				}
				*&globals->dw2B9C = d0_406;
				*&globals->dw2BA0 = d0_406;
				*&globals->dw2BA4 = d0_406;
				d0_19->dw009C = d0_406;
				d0_19->dw00A0 = d0_406;
				word32 d0_432 = ((word32[]) 0x08)[d0_406];
				if (d0_432 != 0x00)
					d0_19->dw00A4 = d0_432;
				a6_162 = *&globals->ptr2B8C;
l000011F8:
				a0_164 = d0_19->dw003A;
				goto l00001202;
			}
Exemple #10
0
    SEE ALSO
        OpenWindow(), UnlockPubScreen(), GetScreenData()

    INTERNALS

*****************************************************************************/
{
    AROS_LIBFUNC_INIT

    struct Screen *screen = NULL;
    struct List   *list;

    DEBUG_LOCKPUBSCREEN(dprintf("LockPubScreen: name <%s>\n",
                                name ? name : (CONST_STRPTR)"NULL"));
    DEBUG_LOCKPUBSCREEN({struct Task *t = FindTask(NULL);
                        dprintf("LockPubScreen: task %p <%s>\n",
                        t,
                        t->tc_Node.ln_Name ? t->tc_Node.ln_Name : "NULL");});

    list = LockPubScreenList();

    if( !name )
    {

        screen = GetPrivIBase(IntuitionBase)->DefaultPubScreen;

        /* If IntuitionBase->DefaultPubScreen is NULL, then Workbench screen
           is default public screen. But note that, Workbench screen might
           here not be open either. */
Exemple #11
0
ULONG __asm __saveds intAHIsub_AllocAudio(
    register __a1 struct TagItem *tagList,
    register __a2 struct AHIAudioCtrlDrv *AudioCtrl )
{
  char *ext = "";

  if(AslBase == NULL)
  {
    return AHISF_ERROR;
  }

  if(AudioCtrl->ahiac_DriverData = AllocVec(sizeof(struct filesave),MEMF_CLEAR))
  {
    dd->fs_AHIsubBase       = AHIsubBase;
    dd->fs_DisableSignal    = -1;
    dd->fs_EnableSignal     = -1;
    dd->fs_SlaveSignal      = -1;
    dd->fs_MasterSignal     = AllocSignal(-1);
    dd->fs_MasterTask       = (struct Process *) FindTask(NULL);
    dd->fs_RecSlaveSignal   = -1;
    dd->fs_RecMasterSignal  = AllocSignal(-1);
  }
  else
  {
    return AHISF_ERROR;
  }

  if((dd->fs_MasterSignal == -1) || (dd->fs_RecMasterSignal == -1))
  {
    return AHISF_ERROR;
  }

  dd->fs_Format = GetTagData(AHIDB_FileSaveFormat, FORMAT_8SVX, tagList);

  switch(dd->fs_Format)
  {
    case FORMAT_8SVX:
      ext = ".8SVX";
      break;

    case FORMAT_AIFF:
      ext = ".AIFF";
      break;

    case FORMAT_AIFC:
      ext = ".AIFC";
      break;

    case FORMAT_S16:
      break;

    default:
      break;
  }

  if(!(dd->fs_FileReq = AllocAslRequestTags(ASL_FileRequest,
      ASLFR_InitialFile,  ext,
      ASLFR_DoSaveMode,   TRUE,
      ASLFR_RejectIcons,  TRUE,
      ASLFR_TitleText,    _LibID,
      TAG_DONE)))
  {
    return AHISF_ERROR;
  }

  if(!(dd->fs_RecFileReq = AllocAslRequestTags(ASL_FileRequest,
      ASLFR_RejectIcons,  TRUE,
      ASLFR_TitleText,    "Select a sound sample",
      TAG_DONE)))
  {
    return AHISF_ERROR;
  }

  return AHISF_KNOWHIFI|AHISF_KNOWSTEREO|AHISF_CANRECORD|AHISF_MIXING|AHISF_TIMING;
}
Exemple #12
0
 
    NOTES
 
    The list's nodes are PubScreenNodes as defined in <intuition/screens.h>.
 
    EXAMPLE
 
    BUGS
 
    SEE ALSO
 
    UnlockPubScreenList()
 
    INTERNALS
 
*****************************************************************************/
#define GPB(x) GetPrivIBase(x)

{
    AROS_LIBFUNC_INIT

    DEBUG_LOCKPUBSCREENLIST(dprintf("LockPubScreenList: <%s>\n",
                                    FindTask(NULL)->tc_Node.ln_Name));
    ObtainSemaphore(&GPB(IntuitionBase)->PubScrListLock);
    DEBUG_LOCKPUBSCREENLIST(dprintf("LockPubScreenList: done\n"));
    
    return (struct List *)&(GPB(IntuitionBase)->PubScreenList);

    AROS_LIBFUNC_EXIT
} /* LockPubScreenList */
Exemple #13
0
char *uno_step(Tcl_Interp *interp)
{
  char msg[MAX_LONG_MESSAGE];
  MsgData msgData;
  int from=0, to=0, dt=0;
  static int prev_time;
  static int first_run=1;
  char source[128];
  char dest[128];
  int from_resourcep=0;
  Task task;
  int valid_message=1;

  /* (1) Read in a line from the log file and parse it (This is all done
         by the CV_OneStepFromFile procedure.
     (2) Check what type of message the line is.  */

  if (CV_OneStepFromFile(global_log_file, msg, &msgData, interp))
      {
	if (COMVIEW_DEBUG) {
	  fprintf(stderr, "%s\n",msg);
	}

	/* For Success or Failure messages the source (from) the module
	   which is sending the message is not logged by central. This
	   information is maintained by the task-tree however, so a call to
	   FindTask will wean this information. */

	if ((msgData->type==FAILURE) || 
	    (msgData->type==SUCCESS)) {

	  task = FindTask(msgData->name, msgData->id, task_ACTIVE);
	  if (!task) {
	    fprintf(stderr, 
		    "Comview error line %d %s : could not FindTask %s\n",
		    __LINE__, __FILE__, msgData->name);
	  }
	  from=(int)task->additional;
	  from_resourcep = 0;
	  to = 0;
	  strcpy(source, "0");
	  strcpy(dest, "0");
	  if (COMVIEW_DEBUG) {
	    fprintf(stderr, "TASK: %s ", task->creator->name);
	    fprintf(stderr, "%d ", task->creation_time);
	    fprintf(stderr, "%d\n",  (int)task->additional);
	  }
	} else if (msgData->type == MODULE_CONNECT) {

	  /* The Tcl code expects the module name in the source element */
	  strcpy(source, msgData->name);
	  /* Read and Parse and additional line: the HOSTNAME */
	  CV_OneStepFromFile(global_log_file, msg, &msgData, interp);
	  strcpy(dest, msgData->name);
	  from=module_lookup(source, dest, interp);

	} else if (msgData->type == MODULE_DISCONNECT) {
	  
	  /* the destination string will hold the hostname (eventually) */
	  strcpy(dest, "0");
	  /* The Tcl code expects the module name in the source element */
	  strcpy(source, msgData->name);
	  from=module_lookup(source, dest, interp);

	} else if (logged_message_type(msgData->type)) {
	  
	  /* check if the message is coming from a resource... */
	  from_resourcep = resource_msg(msgData->source);
	  if (from_resourcep)
	      resource_loc(source, msgData->source);
	  else strcpy(source, msgData->source);
	  
	  /* check if the message is going to a resource... */
	  if (resource_msg (msgData->dest))
	      resource_loc(dest, msgData->dest);
	  else strcpy(dest, msgData->dest);
	  
	  from = module_lookup(source, "", interp);
	  to = module_lookup(dest, "", interp);
	} else {
	  fprintf(stderr, "COMVIEW WARNING: message type not handled %d\n",
		  msgData->type);
	  valid_message = 0;
	}
	
	if ((logged_message_type(msgData->type)) &&
	    (msgData->type != MODULE_CONNECT) && 
	    (msgData->type != MODULE_DISCONNECT) &&
	    (msgData->type != HOSTNAME)) {
	  
	  dt=msgData->time - prev_time;
	  
	  if (first_run) {
	    /* the first time through the prev_time is not going to be set */
	    first_run=0;
	    dt=10;
	    /* we also need to tell Tcl what time the first message */
	    /* occurred at (as a point of reference) */
	    set_time_vars(interp, msgData->hours, msgData->minutes,
			  msgData->seconds, msgData->m_seconds);
	  }

	  prev_time = msgData->time;
	} 

	if (valid_message) {
	  g_mod = to;
	  
	  if (COMVIEW_DEBUG) 
	      log_debug(msgData, from, to, dt, prev_time, from_resourcep); 
	  
	  sprintf(result, "list %d \"%s\" %d \"%s\" %d %d \"%s\" %d %d",
		  from, source, to, dest, msgData->type,
		  msgData->status, msgData->name, dt, from_resourcep);
	  
	  /* if the message was valid, then add it to the task tree */
	  if (msgData->type != TYPE_NULL)
	      TaskTreeProcessNewMessage(msgData);
	} else {
	  sprintf(result, "perror");
	}

      }
  else
      {
	/* This point is reached if there was a parse error, or if the file
	   pointer is currently at the EOF (this is more often the case). */
	sprintf(result, "perror");
	if (COMVIEW_DEBUG)
	    fprintf(stderr, "C Could not parse message: %s\n", msg);
      }
  
  /*  free(&msgData); */
  
  return result;
}
Exemple #14
0
static void DoDebug(xadUINT32 mode, const xadSTRING *fmt, xadTAGPTR tags,
va_list data)
{
  xadUINT32 i;
  xadUINT32 Flags = 0;

  if(!function && (deb_flags & DEBUGFLAG_STATIC))
    return;

#ifdef AMIGA
  Forbid();
#endif

  if((deb_flags & DEBUGFLAG_STATIC)
  || (mode & (DEBUGFLAG_CONTINUE|DEBUGFLAG_CONTINUEEND)))
    Flags = deb_flags;
  else
  {
    xadSTRING Mode[17] = "";
#ifdef AMIGA
    GetVar("XADDEBUG", (xadSTRPTR) &Mode, sizeof(Mode)-1, GVF_GLOBAL_ONLY);
#else
    const xadSTRING *modePtr = getenv("XADDEBUG");
    if (modePtr)
      strncpy(Mode, modePtr, sizeof(Mode)-1);
#endif
    function = 0;

    for(i=0; Mode[i] && i < 15; ++i)
    {
      switch(Mode[i])
      {
      case 'A': Flags |= DEBUGFLAG_TAGLIST|DEBUGFLAG_RUNTIME|DEBUGFLAG_HOOK
                        |DEBUGFLAG_ERROR|DEBUGFLAG_OTHER|DEBUGFLAG_MEM
                        |DEBUGFLAG_FLAGS|DEBUGFLAG_RESOURCE|DEBUGFLAG_CLIENT
                        |DEBUGFLAG_SEARCHED; break;
      case 'M': Flags |= DEBUGFLAG_MEM; break;
      case 'O': Flags |= DEBUGFLAG_OTHER; break;
      case 'E': Flags |= DEBUGFLAG_ERROR; break;
      case 'C': Flags |= DEBUGFLAG_RESOURCE; break;
      case 'D': Flags |= DEBUGFLAG_CLIENT|DEBUGFLAG_SEARCHED; break;
      case 'F': Flags |= DEBUGFLAG_FLAGS; break;
      case 'H': Flags |= DEBUGFLAG_HOOK; break;
      case 'R': Flags |= DEBUGFLAG_RUNTIME; break;
      case 'T': Flags |= DEBUGFLAG_TAGLIST; break;
      case 'S': Flags |= DEBUGFLAG_STATIC; break;

#ifdef __MORPHOS__
      case 's': function = RAWFMTFUNC_SERIAL; break;
#elif defined(AMIGA)
      case 's': function = serfunc; break;
      case 'p': function = parfunc; break;
#endif
      case 'f': function = normfunc; break;
      case 'e': function = errfunc; break;
      case 'o': function = outfunc; break;
      case 'n': function = 0; break;
      }
    }
    deb_flags = Flags;
  }

  mode &= Flags|DEBUGFLAG_CONTINUE|DEBUGFLAG_CONTINUEEND
  |DEBUGFLAG_CONTINUESTART;

  if(mode & (~(DEBUGFLAG_TAGLIST|DEBUGFLAG_STATIC|DEBUGFLAG_CONTINUE
  |DEBUGFLAG_CONTINUEEND|DEBUGFLAG_CONTINUESTART)))
  {
#ifdef AMIGA
    xadPTR fh = 0;

    if(function==normfunc)
    {
      if((fh = (xadPTR) Open("T:xadMasterOut", MODE_READWRITE)))
      {
        Seek((BPTR)fh, 0, OFFSET_END);
      }
      else
        function = 0;
    }
#else
    FILE *fh = NULL;

    switch(function)
    {
    case normfunc: fh = fopen(".libxad-debug", "a"); break;
    case outfunc: default: fh = stdout; break;
    case errfunc: fh = stderr; break;
    }
#endif

    if(function)
    {
#ifdef AMIGA
      if(!(mode & (DEBUGFLAG_CONTINUE|DEBUGFLAG_CONTINUEEND)))
      {
        i = (xadUINT32) FindTask(0);
        OutputDebugArgs("XadM(%08lx):", (putchtype) function, fh, i);
      }
#endif

      OutputDebugVA(fmt, (putchtype) function, fh, data);
      if(!(mode & (DEBUGFLAG_CONTINUESTART|DEBUGFLAG_CONTINUE))
      || (mode & DEBUGFLAG_CONTINUEEND))
        OutputDebug("\n", (putchtype) function, fh);

#ifdef DEBUG
      if(mode & DEBUGFLAG_TAGLIST)
      {
        xadTAGPTR ti;
        while((ti = NextTagItem(&tags)))
        {
          xadUINT32 i[2], dmode = 0;
          const xadSTRING *s;

          /* dmode == 1 - BOOL data, dmode == 2 - unknown, dmode == 3 - error text */
          switch(ti->ti_Tag)
          {
          case XAD_INSIZE:             s = "XAD_INSIZE, %lu"; break;
          case XAD_INFILENAME:         s = "XAD_INFILENAME, \"%s\" ($%08lx)"; break;
          case XAD_INFILEHANDLE:       s = "XAD_INFILEHANDLE, $%08lx"; break;
          case XAD_INMEMORY:           s = "XAD_INMEMORY, $%08lx"; break;
          case XAD_INHOOK:             s = "XAD_INHOOK, $%08lx"; break;
          case XAD_INSPLITTED:         s = "XAD_INSPLITTED, $%08lx"; break;
          case XAD_INDISKARCHIVE:      s = "XAD_INDISKARCHIVE, $%08lx"; break;
          case XAD_INXADSTREAM:        s = "XAD_INXADSTREAM, $%08lx"; break;
#ifdef AMIGA
          case XAD_INDEVICE:           s = "XAD_INDEVICE, $%08lx"; break;
#endif
          case XAD_OUTSIZE:            s = "XAD_OUTSIZE, %lu"; break;
          case XAD_OUTFILENAME:        s = "XAD_OUTFILENAME, \"%s\" ($%08lx)"; break;
          case XAD_OUTFILEHANDLE:      s = "XAD_OUTFILEHANDLE, $%08lx"; break;
          case XAD_OUTMEMORY:          s = "XAD_OUTMEMORY, $%08lx"; break;
          case XAD_OUTHOOK:            s = "XAD_OUTHOOK, $%08lx"; break;
#ifdef AMIGA
          case XAD_OUTDEVICE:          s = "XAD_OUTDEVICE, $%08lx"; break;
#endif
          case XAD_OUTXADSTREAM:       s = "XAD_OUTXADSTREAM, $%08lx"; break;
          case XAD_OBJNAMESIZE:        s = "XAD_OBJNAMESIZE, %lu"; break;
          case XAD_OBJCOMMENTSIZE:     s = "XAD_OBJCOMMENTSIZE, %lu"; break;
          case XAD_OBJBLOCKENTRIES:    s = "XAD_OBJBLOCKENTRIES, %lu"; break;
          case XAD_OBJPRIVINFOSIZE:    s = "XAD_OBJPRIVINFOSIZE, %lu"; break;
          case XAD_NOEXTERN:           s = "XAD_NOEXTERN, %s"; dmode = 1; break;
          case XAD_PASSWORD:           s = "XAD_PASSWORD, \"%s\" ($%08lx)"; break;
          case XAD_ENTRYNUMBER:        s = "XAD_ENTRYNUMBER, %lu"; break;
          case XAD_PROGRESSHOOK:       s = "XAD_PROGRESSHOOK, $%08lx"; break;
          case XAD_OVERWRITE:          s = "XAD_OVERWRITE, %s"; dmode = 1; break;
#ifdef AMIGA
          case XAD_IGNOREGEOMETRY:     s = "XAD_IGNOREGEOMETRY, %s"; dmode = 1; break;
          case XAD_USESECTORLABELS:    s = "XAD_USESECTORLABELS, %s"; dmode = 1; break;
#endif
          case XAD_LOWCYLINDER:        s = "XAD_LOWCYLINDER, %lu"; break;
          case XAD_HIGHCYLINDER:       s = "XAD_HIGHCYLINDER, %lu"; break;
#ifdef AMIGA
          case XAD_VERIFY:             s = "XAD_VERIFY, %s"; dmode = 1; break;
#endif
          case XAD_NOKILLPARTIAL:      s = "XAD_NOKILLPARTIAL, %s"; dmode = 1; break;
#ifdef AMIGA
          case XAD_FORMAT:             s = "XAD_FORMAT, %s"; dmode = 1; break;
#endif
          case XAD_MAKEDIRECTORY:      s = "XAD_MAKEDIRECTORY, %s"; dmode = 1; break;
          case XAD_DATEUNIX:           s = "XAD_DATEUNIX, %ld"; break;
          case XAD_DATEAMIGA:          s = "XAD_DATEAMIGA, %ld"; break;
          case XAD_DATECURRENTTIME:    s = "XAD_DATECURRENTTIME"; break;
          case XAD_DATEDATESTAMP:      s = "XAD_DATEDATESTAMP, $%08lx"; break;
          case XAD_DATEXADDATE:        s = "XAD_DATEXADDATE, $%08lx"; break;
          case XAD_DATECLOCKDATA:      s = "XAD_DATECLOCKDATA, $%08lx"; break;
          case XAD_DATEMSDOS:          s = "XAD_DATEMSDOS, $%08lx"; break;
          case XAD_DATEMAC:            s = "XAD_DATEMAC, $%08lx"; break;
          case XAD_DATECPM:            s = "XAD_DATECPM, $%08lx"; break;
          case XAD_DATECPM2:           s = "XAD_DATECPM2, $%08lx"; break;
          case XAD_GETDATEUNIX:        s = "XAD_GETDATEUNIX, $%08lx"; break;
          case XAD_GETDATEAMIGA:       s = "XAD_GETDATEAMIGA, $%08lx"; break;
#ifdef AMIGA
          case XAD_GETDATEDATESTAMP:   s = "XAD_GETDATEDATESTAMP, $%08lx"; break;
#endif
          case XAD_GETDATEXADDATE:     s = "XAD_GETDATEXADDATE, $%08lx"; break;
#ifdef AMIGA
          case XAD_GETDATECLOCKDATA:   s = "XAD_GETDATECLOCKDATA, $%08lx"; break;
#endif
          case XAD_GETDATEMSDOS:       s = "XAD_GETDATEMSDOS, $%08lx"; break;
          case XAD_GETDATEMAC:         s = "XAD_GETDATEMAC, $%08lx"; break;
          case XAD_GETDATECPM:         s = "XAD_GETDATECPM, $%08lx"; break;
          case XAD_GETDATECPM2:        s = "XAD_GETDATECPM2, $%08lx"; break;
          case XAD_PROTAMIGA:          s = "XAD_PROTAMIGA, $%08lx"; break;
          case XAD_PROTUNIX:           s = "XAD_PROTUNIX, $%08lx"; break;
          case XAD_PROTMSDOS:          s = "XAD_PROTMSDOS, $%08lx"; break;
          case XAD_PROTFILEINFO:       s = "XAD_PROTFILEINFO, $%08lx"; break;
          case XAD_GETPROTAMIGA:       s = "XAD_GETPROTAMIGA, $%08lx"; break;
          case XAD_GETPROTUNIX:        s = "XAD_GETPROTUNIX, $%08lx"; break;
          case XAD_GETPROTMSDOS:       s = "XAD_GETPROTMSDOS, $%08lx"; break;
          case XAD_GETPROTFILEINFO:    s = "XAD_GETPROTFILEINFO, $%08lx"; break;
          case XAD_MAKEGMTDATE:        s = "XAD_MAKEGMTDATE, %s", dmode = 1; break;
          case XAD_MAKELOCALDATE:      s = "XAD_MAKELOCALDATE, %s", dmode = 1; break;
          case XAD_STARTCLIENT:        s = "XAD_STARTCLIENT, $%08lx"; break;
          case XAD_NOEMPTYERROR:       s = "XAD_NOEMPTYERROR, %s"; dmode = 1; break;
          case XAD_ARCHIVEINFO:        s = "XAD_ARCHIVEINFO, $%08lx"; break;
          case XAD_WASERROR:           s = "XAD_WASERROR, \"%s\" (%ld)"; dmode = 3; break;
          case XAD_SECTORLABELS:       s = "XAD_SECTORLABELS, $%08lx"; break;
          case XAD_INSERTDIRSFIRST:    s = "XAD_INSERTDIRSFIRST, %s"; dmode = 1; break;
          case XAD_SETINPOS:           s = "XAD_SETINPOS, %ld"; break;
          case XAD_IGNOREFLAGS:        s = "XAD_IGNOREFLAGS, $%08lx"; dmode = 100; break;
          case XAD_ONLYFLAGS:          s = "XAD_ONLYFLAGS, $%08lx"; dmode=100; break;
          case XAD_ERRORCODE:          s = "XAD_ERRORCODE, $%08lx"; break;
          case XAD_PATHSEPERATOR:      s = "XAD_PATHSEPERATOR, $%08lx"; break;
          case XAD_CHARACTERSET:       s = "XAD_CHARACTERSET, %ld (%s)"; dmode = 4; break;
          case XAD_STRINGSIZE:         s = "XAD_STRINGSIZE, %ld"; break;
          case XAD_CSTRING:            s = "XAD_CSTRING, $%08lx"; break;
          case XAD_PSTRING:            s = "XAD_PSTRING, $%08lx"; break;
          case XAD_XADSTRING:          s = "XAD_XADSTRING, $%08lx"; break;
          case XAD_ADDPATHSEPERATOR:   s = "XAD_ADDPATHSEPERATOR, %s"; dmode = 1; break;
          case XAD_NOLEADINGPATH:      s = "XAD_NOLEADINGPATH, %s"; dmode = 1; break;
          case XAD_NOTRAILINGPATH:     s = "XAD_NOTRAILINGPATH, %s"; dmode = 1; break;
          case XAD_MASKCHARACTERS:     s = "XAD_MASKCHARACTERS, $%08lx"; break;
          case XAD_MASKINGCHAR:        s = "XAD_MASKINGCHAR, '%lc'"; break;
          case XAD_REQUIREDBUFFERSIZE: s = "XAD_REQUIREDBUFFERSIZE, $%08lx"; break;
          case XAD_USESKIPINFO:        s = "XAD_USESKIPINFO, %s"; dmode = 1; break;
          case XAD_EXTENSION:          s = "XAD_EXTENSION, \"%s\" ($%08lx)"; break;
          default:                     s = "$%08lx, $%08lx"; dmode = 2; break;
          }
          switch(dmode)
          {
          case 1: i[0] = ti->ti_Data ? (xadUINT32) "TRUE" : (xadUINT32) "FALSE"; break;
          case 2: i[0] = ti->ti_Tag; i[1] = ti->ti_Data; break;
          #ifdef AMIGA
          case 3: i[0] = (xadUINT32) xadGetErrorText(XADM ti->ti_Data); i[1] = ti->ti_Data; break;
          #else
          /* Special case: We pass a NULL to xadGetErrorText() since we don't have XMB as a global
             variable in Unix. xadGetErrorText() will make an exception for this. */
          case 3: i[0] = (xadUINT32) xadGetErrorText(NULL, ti->ti_Data); i[1] = ti->ti_Data; break;
          #endif
          case 4: i[0] = ti->ti_Data;
            switch(i[0])
            {
            case CHARSET_HOST: i[1] = (xadUINT32) "CHARSET_HOST"; break;
            case CHARSET_UNICODE_UCS2_HOST: i[1] = (xadUINT32) "CHARSET_UNICODE_UCS2_HOST"; break;
            case CHARSET_UNICODE_UCS2_BIGENDIAN: i[1] = (xadUINT32) "CHARSET_UNICODE_UCS2BIGENDIAN"; break;
            case CHARSET_UNICODE_UCS2_LITTLEENDIAN: i[1] = (xadUINT32) "CHARSET_UNICODE_UCS2_LITTLEENDIAN"; break;
            case CHARSET_UNICODE_UTF8: i[1] = (xadUINT32) "CHARSET_UNICODE_UTF8"; break;
            case CHARSET_AMIGA: i[1] = (xadUINT32) "CHARSET_AMIGA"; break;
            case CHARSET_MSDOS: i[1] = (xadUINT32) "CHARSET_MSDOS"; break;
            case CHARSET_MACOS: i[1] = (xadUINT32) "CHARSET_MACOS"; break;
            case CHARSET_C64: i[1] = (xadUINT32) "CHARSET_C64"; break;
            case CHARSET_ATARI_ST: i[1] = (xadUINT32) "CHARSET_ATARI_ST"; break;
            case CHARSET_WINDOWS: i[1] = (xadUINT32) "CHARSET_WINDOWS"; break;
            case CHARSET_ASCII: i[1] = (xadUINT32) "CHARSET_ASCII"; break;
            case CHARSET_ISO_8859_1: i[1] = (xadUINT32) "CHARSET_ISO_8859_1"; break;
            case CHARSET_ISO_8859_15: i[1] = (xadUINT32) "CHARSET_ISO_8859_15"; break;
            case CHARSET_ATARI_ST_US: i[1] = (xadUINT32) "CHARSET_ATARI_ST_US"; break;
            case CHARSET_PETSCII_C64_LC: i[1] = (xadUINT32) "CHARSET_PETSCII_C64_LC"; break;
            case CHARSET_CODEPAGE_437: i[1] = (xadUINT32) "CHARSET_CODEPAGE_437"; break;
            case CHARSET_CODEPAGE_1252: i[1] = (xadUINT32) "CHARSET_CODEPAGE_1252"; break;
            default: i[1] = (xadUINT32) "unknown"; break;
            }
            break;
          default: i[0] = i[1] = ti->ti_Data;
          }

          OutputDebug("   ", (putchtype) function, fh);
          OutputDebugArgs(s, (putchtype) function, fh, i[0], i[1]);
          if(dmode >= 100 && (Flags & DEBUGFLAG_FLAGS))
          {
            OutputDebug(" ("/*)*/, (putchtype) function, fh);
            switch(dmode)
            {
            case 100:
              i[1] = PrintFlag(XADCF_FILEARCHIVER, i[1]);
              i[1] = PrintFlag(XADCF_DISKARCHIVER, i[1]);
              i[1] = PrintFlag(XADCF_EXTERN, i[1]);
              i[1] = PrintFlag(XADCF_FILESYSTEM, i[1]);
              i[1] = PrintFlag(XADCF_NOCHECKSIZE, i[1]);
              i[1] = PrintFlag(XADCF_DATACRUNCHER, i[1]);
              i[1] = PrintFlag(XADCF_EXECRUNCHER, i[1]);
              i[1] = PrintFlag(XADCF_ADDRESSCRUNCHER, i[1]);
              i[1] = PrintFlag(XADCF_LINKER, i[1]);
              i[1] = PrintFlag(XADCF_FREESPECIALINFO, i[1]);
              i[1] = PrintFlag(XADCF_FREESKIPINFO, i[1]);
              i[1] = PrintFlag(XADCF_FREETEXTINFO, i[1]);
              i[1] = PrintFlag(XADCF_FREETEXTINFOTEXT, i[1]);
              i[1] = PrintFlag(XADCF_FREEFILEINFO, i[1]);
              i[1] = PrintFlag(XADCF_FREEDISKINFO, i[1]);
            }
            if(i[1])
            {
              OutputDebugArgs("$%lx", (putchtype) function, fh, i[1]);
            }
            OutputDebug(/*(*/")", (putchtype) function, fh);
          }
          OutputDebug("\n", (putchtype) function, fh);
        }
        OutputDebug("   TAG_DONE\n", (putchtype) function, fh);
      }
#endif
    }

#ifdef AMIGA
    if(fh)
      Close((BPTR)fh);
#else
    if(fh && function == normfunc)
      fclose(fh);
#endif
  }
#ifdef AMIGA
  Permit();
#endif
}
Exemple #15
0
/*  FUNCTION
	Returns the current output stream or 0 if there is no current
	output stream.

    INPUTS

    RESULT
	Output stream handle.

    NOTES

    EXAMPLE

    BUGS

    SEE ALSO

    INTERNALS

*****************************************************************************/
{
    AROS_LIBFUNC_INIT

    /* Get pointer to process structure */
    struct Process *me=(struct Process *)FindTask(NULL);

    /* Nothing spectacular */
    return me->pr_COS;
    AROS_LIBFUNC_EXIT
} /* Output */
Exemple #16
0
	"Sanity check on memory list failed",

	"IO attempted on closed IORequest",
	"Stack appears to extend out of range",
	"Memory header not located. (Usually an invalid address passed to FreeMem())",
	"An attempt was made to use the old message semaphores",

    };

    struct Task * task;

#   define GetSubSysId(a)       (((a) >> 24) & 0x7F)
#   define GetGenError(a)       (((a) >> 16) & 0xFF)
#   define GetSpecError(a)      ((a) & 0xFFFF)

    task = FindTask (NULL);

    /* since this is an emulation, we just show the bug in the console */
    kprintf ( "[exec] GURU Meditation %04lx %04lx\n[exec] "
	, alertNum >> 16
	, alertNum & 0xFFFF
    );

    if (alertNum & 0x80000000)
	kprintf ( "Deadend/" );
    else
	kprintf( "Recoverable/" );

    switch (GetSubSysId (alertNum))
    {
    case 0: /* CPU/OS/App */
Exemple #17
0
	Signal(), SetSignal(), AllocSignal(), FreeSignal()

    INTERNALS

    HISTORY

******************************************************************************/
{
    AROS_LIBFUNC_INIT

    ULONG rcvd;
    struct Task *me;
    void *KernelBase = priv_KernelBase;

    /* Get pointer to current task - I'll need it very often */
    me = FindTask (NULL);

    /* Protect the task lists against access by other tasks. */
    Disable();

//    if (SysBase->Elapsed == SysBase->Quantum)
//    {
//    	if (me->tc_Node.ln_Pri < (GetIntETask(me)->iet_OrigPri) + 10)
//    		me->tc_Node.ln_Pri++;
//    }
//    else
//    {
//    	if (me->tc_Node.ln_Pri > (GetIntETask(me)->iet_OrigPri) - 10)
//    		me->tc_Node.ln_Pri--;
//    }
Exemple #18
0
int main (int argc, char **argv)
{
    struct timerequest *timereq = 0;
    struct MsgPort *timeport;
    struct timeval *tz_offset;
    struct Device *TimerBase;
    int quit = 0;
    int result = calltrap (0, 0);

    if (result == 1)
        fputs ("timehack already running.\n", stderr);
    else if (result == 2)
        fputs ("timehack not supported with this version of UAE.\n", stderr);
    if (result != 0)
        exit (5);

    timeport = (struct MsgPort *) CreatePort (0, 0);
    if (timeport)
        timereq = (struct timerequest *) CreateStdIO(timeport);

    if (timereq == 0)
        goto fail;

    if (OpenDevice ("timer.device", UNIT_VBLANK, (struct IORequest *) timereq, 0) != 0)
        goto fail;
    TimerBase = timereq->tr_node.io_Device;

    SetTaskPri (FindTask (NULL), 20); /* same as input.device */

    tz_offset = get_tz_offset();

    while (!quit) {
        struct timeval cur_sys_time;

        timereq->tr_node.io_Command = TR_GETSYSTIME;
        DoIO ((struct IORequest *)timereq);
        cur_sys_time = timereq->tr_time;
        calltrap (1, &timereq->tr_time);
        if (timereq->tr_time.tv_secs != cur_sys_time.tv_secs
                || (timereq->tr_time.tv_secs == cur_sys_time.tv_secs
                    && ABS(timereq->tr_time.tv_micro - cur_sys_time.tv_micro) > 1000))
        {
            AddTime (&timereq->tr_time, tz_offset);
            timereq->tr_node.io_Command = TR_SETSYSTIME;
            DoIO ((struct IORequest *)timereq);
        }

        timereq->tr_time.tv_secs = 1;
        timereq->tr_time.tv_micro = 0;
        timereq->tr_node.io_Command = TR_ADDREQUEST;
        DoIO ((struct IORequest *)timereq);

        if (SetSignal(0L,SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C)
            quit = TRUE;
    }
    /* Exit and error handling badly needs tidying up - Rich */
    CloseDevice ((struct IORequest *)timereq);
    DeleteStdIO ((struct IOStdReq *)timereq);
    DeletePort (timeport);
    exit (0);

fail:
    fputs ("Couldn't start timehack (that's bad!)\n", stderr);
    exit (5);
}
Exemple #19
0
BOOPSI_DISPATCHER_END

int main(void) {

    SetTaskPri(FindTask(NULL), 15);

    struct MUI_CustomClass *mcc;

    if((ps = OpenLibrary("poseidon.library", 4))) {

        if((mcc = MUI_CreateCustomClass(NULL, "Area.mui", NULL, sizeof(struct InstData), classdispatcher))) {
            mybug(-1,("mui custon class at %p\n", mcc));

            Object *app, *window, *tick1, *custom;

            app = ApplicationObject,
            SubWindow, window = WindowObject,
                MUIA_Window_Title, "PS3Eye",
                    MUIA_Window_Activate, TRUE,
                        WindowContents, HGroup,
		    		        Child, HGroup,
		    			        MUIA_Weight, 100,
		    			        Child, custom = NewObject(mcc->mcc_Class, NULL, TAG_DONE),
		    		        End,

                            Child, VGroup,
                                MUIA_Weight, 1,
                                MUIA_Group_SameWidth, TRUE,
                                GroupFrameT("Configuration"),
                                    Child, HGroup,
                                        Child, tick1 = MUI_MakeObject(MUIO_Checkmark, NULL),
                                        Child, MUI_MakeObject(MUIO_Label,"640x480", 0),
                                    End,
                                Child, (IPTR) VSpace(0),
                            End,
                        End,
                    End,
                End;

            if(app) {
                ULONG sigs = 0;

                DoMethod(tick1, MUIM_Notify, MUIA_Selected, TRUE,  (IPTR)custom, 3, MUIM_Set, MUIA_Resolution, TRUE);
                DoMethod(tick1, MUIM_Notify, MUIA_Selected, FALSE, (IPTR)custom, 3, MUIM_Set, MUIA_Resolution, FALSE);

                DoMethod(window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

                set(window, MUIA_Window_Open, TRUE);

                while((LONG)DoMethod(app, MUIM_Application_NewInput, &sigs) != (LONG)MUIV_Application_ReturnID_Quit) {
                    if(sigs) {
                        sigs = Wait(sigs | SIGBREAKF_CTRL_C);
                        if(sigs & SIGBREAKF_CTRL_C)
                            break;
                    }
                }

                MUI_DisposeObject(app);
            }

            MUI_DeleteCustomClass(mcc);
        }
        CloseLibrary(ps);
    }

    mybug(-1,("Exiting\n"));
    return 0;
}
Exemple #20
0
static void do_file_dialog (unsigned int type)
{
    struct FileRequester *FileRequest;
    struct Window *win;

    char buf[80];
    char path[512];

    const char *req_prompt;
    const char *req_pattern = 0;
    const char *req_lastdir;
    int         req_do_save = FALSE;

#ifdef __amigaos4__
    int release_asl = 0;
#endif

    if (type >= FILEDIALOG_MAX)
        return;

    if (!AslBase) {
        AslBase = OpenLibrary ("asl.library", 36);
        if (!AslBase) {
            write_log ("Can't open asl.library v36.\n");
            return;
        } else {
#ifdef __amigaos4__
            IAsl = (struct AslIFace *) GetInterface ((struct Library *)AslBase, "main", 1, NULL);
            if (!IAsl) {
                CloseLibrary (AslBase);
                AslBase = 0;
                write_log ("Can't get asl.library interface\n");
            }
#endif
        }
#ifdef __amigaos4__
    } else {
        IAsl->Obtain ();
        release_asl = 1;
#endif
    }

    FileRequest = AllocAslRequest (ASL_FileRequest, NULL);
    if (!FileRequest) {
        write_log ("Unable to allocate file requester.\n");
        return;
    }

    /* Find this task's default window */
    win = ((struct Process *) FindTask (NULL))->pr_WindowPtr;
    if (win == (struct Window *)-1)
        win = 0;

    /*
     * Prepare requester.
     */
    switch (type) {

    default: /* to stop GCC complaining */
    case FILEDIALOG_INSERT_DF0:
    case FILEDIALOG_INSERT_DF1:
    case FILEDIALOG_INSERT_DF2:
    case FILEDIALOG_INSERT_DF3:
        sprintf (buf, "Select image to insert in drive DF%d:", FILEDIALOG_DRIVE(type));
        req_prompt = buf;
        req_pattern = "(#?.(ad(f|z)|dms|ipf|zip)#?|df?|?)";
        req_lastdir = get_last_floppy_dir ();
        break;

    case FILEDIALOG_SAVE_STATE:
        req_prompt = "Select file to save emulator state to";
        req_pattern = "#?.uss";
        req_lastdir = get_last_savestate_dir ();
        req_do_save = TRUE;
        break;

    case FILEDIALOG_LOAD_STATE:
        req_prompt = "Select saved state file to load";
        req_pattern = "#?.uss";
        req_lastdir = get_last_savestate_dir ();
        break;
    }

    /*
     * Do the file request.
     */
    if (AslRequestTags (FileRequest,
                        ASLFR_TitleText,      req_prompt,
                        ASLFR_InitialDrawer,  req_lastdir,
                        ASLFR_InitialPattern, req_pattern,
                        ASLFR_DoPatterns,     req_pattern != 0,
                        ASLFR_DoSaveMode,     req_do_save,
                        ASLFR_RejectIcons,    TRUE,
                        ASLFR_Window,         win,
                        TAG_DONE)) {

        /*
         * User selected a file.
         *
         * Construct file path to selected image.
         */
        strcpy (path, FileRequest->fr_Drawer);
        if (strlen (path) && !(path[strlen (path) - 1] == ':' || path[strlen (path) - 1] == '/'))
            strcat (path, "/");
        strcat (path, FileRequest->fr_File);

        /*
         * Process selected file.
         */
        switch (type) {

        default: /* to stop GCC complaining */
        case FILEDIALOG_INSERT_DF0:
        case FILEDIALOG_INSERT_DF1:
        case FILEDIALOG_INSERT_DF2:
        case FILEDIALOG_INSERT_DF3:
            set_last_savestate_dir (FileRequest->fr_Drawer);
            strcpy (changed_prefs.df[FILEDIALOG_DRIVE(type)], path);
            break;

        case FILEDIALOG_SAVE_STATE:
            set_last_savestate_dir (FileRequest->fr_Drawer);
            savestate_initsave (path, 1, 0);
            save_state (path, "Description");
            break;

        case FILEDIALOG_LOAD_STATE:
            set_last_savestate_dir (FileRequest->fr_Drawer);
            savestate_initsave (path, 1, 0);
            savestate_state = STATE_DORESTORE;
            write_log ("Restoring state from '%s'...\n", path);
            break;
        }
    }

    FreeAslRequest (FileRequest);

#ifdef __amigaos4__
    if (release_asl)
        IAsl->Release ();
#endif

    return;
}
Exemple #21
0
int par_init(UBYTE useCRC)
{
    int result = PAR_INIT_OK;
    
    /* allocate signal for interrupt */
    intSig = AllocSignal(-1);
    if(intSig == -1) {
        return PAR_INIT_NO_SIGNAL;
    }
    alloc_flags |= 8;
    
    /* setup state structure */
    state.s_Flags = 0;
    state.s_IntSigMask = 1UL << intSig;
    state.s_SysBase = SysBase;
    state.s_ServerTask = FindTask(NULL);
    state.s_UseCRC = useCRC;
    
    /* register our time out flag */
    timer_timeout_set_flag_ptr(&state.s_TimeOut);
    
    if (MiscBase = OpenResource("misc.resource")) {
        if (cia_base = OpenResource("ciaa.resource")) {

            /* obtain exclusive access to the parallel hardware */
            if (!AllocMiscResource(MR_PARALLELPORT, name))
            {
                alloc_flags |= 1;
                if (!AllocMiscResource(MR_PARALLELBITS, name))
                {
                    BOOL ok = FALSE;
                    
                    alloc_flags |= 2;
                    
                    /* allocate irq */
                    irq.is_Node.ln_Type = NT_INTERRUPT;
                    irq.is_Node.ln_Pri  = 127;
                    irq.is_Node.ln_Name = name;
                    irq.is_Data         = (APTR)&state;
                    irq.is_Code         = (VOID (*)())&interrupt;

                    Disable();
                    /* add an interrupt handler for FLAG = ACK */
                    if (!AddICRVector(cia_base, CIAICRB_FLG, &irq))
                    {
                        DISABLEINT;
                        ok = TRUE;
                    }
                    Enable();

                    /* finish setting up interrupt handler */
                    if (ok) {
                        alloc_flags |= 4;
                        
                        /* setup line */
                        PARINIT;
                        CLEARREQUEST;
                        
                        /* irq setup */
                        CLEARINT;
                        ENABLEINT;
                    } else {
                        result = PAR_INIT_NO_CIA_IRQ;
                    }
                } else {
                    result = PAR_INIT_NO_PARBITS_RES;
                }  
            } else {
                result = PAR_INIT_NO_PARPORT_RES;
            }
        }
    }
    return result;
}
/* /// "nGUITask()" */
AROS_UFH0(void, nGUITask)
{
    AROS_USERFUNC_INIT

    struct Task *thistask;
    struct AROSXClassBase *arosxb;
    struct AROSXClassController *arosxc;

    struct Library *MUIBase;
    struct Library *PsdBase;
    struct Library *AROSXBase;

    struct AROSXClassConfigGUI *gui;

    thistask = FindTask(NULL);
    arosxc = thistask->tc_UserData;
    arosxb = arosxc->arosxb;

    struct AROSX_GAMEPAD *arosx_gamepad;
    arosx_gamepad = &arosxc->arosx_gamepad;

    /*
        TODO: Make use of OpenLibrary/CloseLibrary to keep track of lib open count...
    */
    ++arosxb->Library.lib_OpenCnt;

    struct AROSX_EventHook *arosx_eventhook;
    struct MsgPort         *arosx_eventport;

    if(gui = AllocVec(sizeof(struct AROSXClassConfigGUI), MEMF_CLEAR|MEMF_ANY)) {

        if(AROSXBase = OpenLibrary("arosx.library", 0)) {
            mybug(-1,("[AROSXClass GUI] arosx.library openened\n"));

            arosx_eventport = CreateMsgPort();
            arosx_eventhook = AROSX_AddEventHandler(arosx_eventport, (((1<<arosxc->id))<<28));
            /*
                Set to listen every controller
            */
            //arosx_eventhook = AROSX_AddEventHandler(arosx_eventport, (0xf<<28));

        if((MUIMasterBase = OpenLibrary(MUIMASTER_NAME, MUIMASTER_VMIN)))
        {
            if((ps = OpenLibrary("poseidon.library", 4)))
            {

                gui->App = ApplicationObject,
                MUIA_Application_Title      , (IPTR)libname,
                MUIA_Application_Version    , (IPTR)VERSION_STRING,
                MUIA_Application_Copyright  , (IPTR)"©2018-2019 The AROS Development Team",
                MUIA_Application_Author     , (IPTR)"The AROS Development Team",
                MUIA_Application_Description, (IPTR)"Settings for the arosx.class",
                MUIA_Application_Base       , (IPTR)"AROSX",
                MUIA_Application_HelpFile   , (IPTR)"HELP:Poseidon.guide",
                MUIA_Application_Menustrip  , (IPTR)MenustripObject,
                    Child, (IPTR)MenuObjectT((IPTR)"Project"),
                        Child, (IPTR)(gui->AboutMI = MenuitemObject,
                            MUIA_Menuitem_Title, (IPTR)"About...",
                            MUIA_Menuitem_Shortcut, (IPTR)"?",
                            End),
                        End,
                    Child, (IPTR)MenuObjectT((IPTR)"Settings"),
                        Child, (IPTR)(gui->UseMI = MenuitemObject,
                            MUIA_Menuitem_Title, (IPTR)"Save",
                            MUIA_Menuitem_Shortcut, (IPTR)"S",
                            End),
                        Child, (IPTR)MenuitemObject,
                            MUIA_Menuitem_Title, (IPTR)NM_BARLABEL,
                            End,
                        Child, (IPTR)(gui->MUIPrefsMI = MenuitemObject,
                            MUIA_Menuitem_Title, (IPTR)"MUI Settings",
                            MUIA_Menuitem_Shortcut, (IPTR)"M",
                            End),
                        End,
                    End,

                SubWindow, (IPTR)(gui->MainWindow = WindowObject,
                    MUIA_Window_ID   , MAKE_ID('M','A','I','N'),
                    MUIA_Window_Title, (IPTR)arosxc->name,
                    MUIA_HelpNode, (IPTR)libname,

                    WindowContents, (IPTR)VGroup,
                        Child, (IPTR)(gui->GamepadGroupObject = ColGroup(2),
                            GroupFrameT("Gamepad"),
                            MUIA_Disabled, TRUE,

                            Child, (IPTR)HGroup,
                            Child, (IPTR)(gui->GamepadObject_button_a = ImageObject,
                                MUIA_Image_FontMatch, TRUE,
                                MUIA_Selected, FALSE,
                                MUIA_ShowSelState, FALSE,
                                MUIA_Image_Spec, MUII_RadioButton,
                                MUIA_Frame, MUIV_Frame_None,
                                End),

                            Child, (IPTR)(gui->GamepadObject_button_b = ImageObject,
                                MUIA_Image_FontMatch, TRUE,
                                MUIA_Selected, FALSE,
                                MUIA_ShowSelState, FALSE,
                                MUIA_Image_Spec, MUII_RadioButton,
                                MUIA_Frame, MUIV_Frame_None,
                                End),

                            Child, (IPTR)(gui->GamepadObject_button_x = ImageObject,
                                MUIA_Image_FontMatch, TRUE,
                                MUIA_Selected, FALSE,
                                MUIA_ShowSelState, FALSE,
                                MUIA_Image_Spec, MUII_RadioButton,
                                MUIA_Frame, MUIV_Frame_None,
                                End),

                            Child, (IPTR)(gui->GamepadObject_button_y = ImageObject,
                                MUIA_Image_FontMatch, TRUE,
                                MUIA_Selected, FALSE,
                                MUIA_ShowSelState, FALSE,
                                MUIA_Image_Spec, MUII_RadioButton,
                                MUIA_Frame, MUIV_Frame_None,
                                End),

                            Child, (IPTR)(gui->GamepadObject_button_ls = ImageObject,
                                MUIA_Image_FontMatch, TRUE,
                                MUIA_Selected, FALSE,
                                MUIA_ShowSelState, FALSE,
                                MUIA_Image_Spec, MUII_RadioButton,
                                MUIA_Frame, MUIV_Frame_None,
                                End),

                            Child, (IPTR)(gui->GamepadObject_button_rs = ImageObject,
                                MUIA_Image_FontMatch, TRUE,
                                MUIA_Selected, FALSE,
                                MUIA_ShowSelState, FALSE,
                                MUIA_Image_Spec, MUII_RadioButton,
                                MUIA_Frame, MUIV_Frame_None,
                                End),

                            Child, (IPTR)(gui->GamepadObject_left_thumb = ImageObject,
                                MUIA_Image_FontMatch, TRUE,
                                MUIA_Selected, FALSE,
                                MUIA_ShowSelState, FALSE,
                                MUIA_Image_Spec, MUII_RadioButton,
                                MUIA_Frame, MUIV_Frame_None,
                                End),

                            Child, (IPTR)(gui->GamepadObject_right_thumb = ImageObject,
                                MUIA_Image_FontMatch, TRUE,
                                MUIA_Selected, FALSE,
                                MUIA_ShowSelState, FALSE,
                                MUIA_Image_Spec, MUII_RadioButton,
                                MUIA_Frame, MUIV_Frame_None,
                                End),

                            Child, (IPTR)(gui->GamepadObject_dpad_left = ImageObject,
                                MUIA_Image_FontMatch, TRUE,
                                MUIA_Selected, FALSE,
                                MUIA_ShowSelState, FALSE,
                                MUIA_Image_Spec, MUII_RadioButton,
                                MUIA_Frame, MUIV_Frame_None,
                                End),

                            Child, (IPTR)(gui->GamepadObject_dpad_right = ImageObject,
                                MUIA_Image_FontMatch, TRUE,
                                MUIA_Selected, FALSE,
                                MUIA_ShowSelState, FALSE,
                                MUIA_Image_Spec, MUII_RadioButton,
                                MUIA_Frame, MUIV_Frame_None,
                                End),

                            Child, (IPTR)(gui->GamepadObject_dpad_up = ImageObject,
                                MUIA_Image_FontMatch, TRUE,
                                MUIA_Selected, FALSE,
                                MUIA_ShowSelState, FALSE,
                                MUIA_Image_Spec, MUII_RadioButton,
                                MUIA_Frame, MUIV_Frame_None,
                                End),

                            Child, (IPTR)(gui->GamepadObject_dpad_down = ImageObject,
                                MUIA_Image_FontMatch, TRUE,
                                MUIA_Selected, FALSE,
                                MUIA_ShowSelState, FALSE,
                                MUIA_Image_Spec, MUII_RadioButton,
                                MUIA_Frame, MUIV_Frame_None,
                                End),

                            Child, (IPTR)(gui->GamepadObject_button_back = ImageObject,
                                MUIA_Image_FontMatch, TRUE,
                                MUIA_Selected, FALSE,
                                MUIA_ShowSelState, FALSE,
                                MUIA_Image_Spec, MUII_RadioButton,
                                MUIA_Frame, MUIV_Frame_None,
                                End),

                            Child, (IPTR)(gui->GamepadObject_button_start = ImageObject,
                                MUIA_Image_FontMatch, TRUE,
                                MUIA_Selected, FALSE,
                                MUIA_ShowSelState, FALSE,
                                MUIA_Image_Spec, MUII_RadioButton,
                                MUIA_Frame, MUIV_Frame_None,
                                End),
                            End,

                            Child, (IPTR)(gui->GamepadObject_left_trigger = GaugeObject,
                                GaugeFrame,
                                MUIA_Gauge_Max, 0xff,
                                MUIA_Gauge_InfoText, (IPTR)"%lx",
                                MUIA_Gauge_Horiz, TRUE,
                                MUIA_Gauge_Current, 0,
                                End),

                            Child, (IPTR)(gui->GamepadObject_right_trigger = GaugeObject,
                                GaugeFrame,
                                MUIA_Gauge_Max, 0xff,
                                MUIA_Gauge_InfoText, (IPTR)"%lx",
                                MUIA_Gauge_Horiz, TRUE,
                                MUIA_Gauge_Current, 0,
                                End),

                            Child, (IPTR)(gui->GamepadObject_left_stick_x = GaugeObject,
                                GaugeFrame,
                                MUIA_Gauge_Max, 0xffff,
                                MUIA_Gauge_InfoText, (IPTR)"%lx",
                                MUIA_Gauge_Horiz, TRUE,
                                MUIA_Gauge_Current, 0,
                                End),

                            Child, (IPTR)(gui->GamepadObject_left_stick_y = GaugeObject,
                                GaugeFrame,
                                MUIA_Gauge_Max, 0xffff,
                                MUIA_Gauge_InfoText, (IPTR)"%lx",
                                MUIA_Gauge_Horiz, TRUE,
                                MUIA_Gauge_Current, 0,
                                End),

                            Child, (IPTR)(gui->GamepadObject_right_stick_x = GaugeObject,
                                GaugeFrame,
                                MUIA_Gauge_Max, 0xffff,
                                MUIA_Gauge_InfoText, (IPTR)"%lx",
                                MUIA_Gauge_Horiz, TRUE,
                                MUIA_Gauge_Current, 0,
                                End),

                            Child, (IPTR)(gui->GamepadObject_right_stick_y = GaugeObject,
                                GaugeFrame,
                                MUIA_Gauge_Max, 0xffff,
                                MUIA_Gauge_InfoText, (IPTR)"%lx",
                                MUIA_Gauge_Horiz, TRUE,
                                MUIA_Gauge_Current, 0,
                                End),

                            End),

                        Child, (IPTR)VSpace(0),
                        Child, (IPTR)HGroup,
                            MUIA_Group_SameWidth, TRUE,
                            Child, (IPTR)(gui->UseObj = TextObject, ButtonFrame,
                                MUIA_Background, MUII_ButtonBack,
                                MUIA_CycleChain, 1,
                                MUIA_InputMode, MUIV_InputMode_RelVerify,
                                MUIA_Text_Contents, (IPTR)"\33c Save ",
                                End),
                            Child, (IPTR)(gui->CloseObj = TextObject, ButtonFrame,
                                MUIA_Background, MUII_ButtonBack,
                                MUIA_CycleChain, 1,
                                MUIA_InputMode, MUIV_InputMode_RelVerify,
                                MUIA_Text_Contents, (IPTR)"\33c Use ",
                                End),
                            End,
                        End,
                    End),
                End;

                if(gui->App) 
                {
                    DoMethod(gui->MainWindow, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
                             gui->App, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
                    DoMethod(gui->UseObj, MUIM_Notify, MUIA_Pressed, FALSE,
                             gui->App, 2, MUIM_Application_ReturnID, ID_STORE_CONFIG);
                    DoMethod(gui->CloseObj, MUIM_Notify, MUIA_Pressed, FALSE,
                             gui->App, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

                    DoMethod(gui->AboutMI, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
                             gui->App, 2, MUIM_Application_ReturnID, ID_ABOUT);
                    DoMethod(gui->UseMI, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
                             gui->App, 2, MUIM_Application_ReturnID, ID_STORE_CONFIG);
                    DoMethod(gui->MUIPrefsMI, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
                             gui->App, 2, MUIM_Application_OpenConfigWindow, 0);

                    IPTR  isopen = 0;
                    IPTR  iconify = 0;
                    ULONG sigs;
                    ULONG sigmask;
                    LONG retid;

                    get(gui->App, MUIA_Application_Iconified, &iconify);
                    set(gui->MainWindow, MUIA_Window_Open, TRUE);
                    get(gui->MainWindow, MUIA_Window_Open, &isopen);

                    if((isopen || (!iconify)))
                    {
                        sigmask = (1UL<<arosx_eventport->mp_SigBit);
                        do
                        {
                            retid = DoMethod(gui->App, MUIM_Application_NewInput, &sigs);
                            switch(retid)
                            {
                                case ID_ABOUT:
                                    MUI_RequestA(gui->App, gui->MainWindow, 0, NULL, "Fabulous!", VERSION_STRING, NULL);
                                    break;
                            }
                            if(retid == MUIV_Application_ReturnID_Quit)
                            {
                                break;
                            }
                            if(sigs)
                            {
                                sigs = Wait(sigs | sigmask | SIGBREAKF_CTRL_C);
                                if(sigs & SIGBREAKF_CTRL_C)
                                {
                                    break;
                                }

                                if(sigs & (1UL<<arosx_eventport->mp_SigBit)) {
                                    mybug(-1,("(%d) I may have received an event...\n", arosxc->id));
                                    struct AROSX_EventNote *en;
                                    while((en = (struct AROSX_EventNote *)GetMsg(arosx_eventport))) {
 
                                        mybug(-1,("    event %08lx\n", en->en_Event));

                                        /* TODO: GUI is disabled until we get the first message even on wired controllers... */
                                        if((arosxc->status.wireless)&&(arosxc->status.signallost)) {
                                            set(gui->GamepadGroupObject, MUIA_Disabled, TRUE);
                                        } else {
                                            set(gui->GamepadGroupObject, MUIA_Disabled, FALSE);

                                            set(gui->GamepadObject_button_a, MUIA_Selected, (arosx_gamepad->Buttons & AROSX_GAMEPAD_A));
                                            set(gui->GamepadObject_button_b, MUIA_Selected, (arosx_gamepad->Buttons & AROSX_GAMEPAD_B));
                                            set(gui->GamepadObject_button_x, MUIA_Selected, (arosx_gamepad->Buttons & AROSX_GAMEPAD_X));
                                            set(gui->GamepadObject_button_y, MUIA_Selected, (arosx_gamepad->Buttons & AROSX_GAMEPAD_Y));
                                            set(gui->GamepadObject_button_ls, MUIA_Selected, (arosx_gamepad->Buttons & AROSX_GAMEPAD_LEFT_SHOULDER));
                                            set(gui->GamepadObject_button_rs, MUIA_Selected, (arosx_gamepad->Buttons & AROSX_GAMEPAD_RIGHT_SHOULDER));
                                            set(gui->GamepadObject_left_thumb, MUIA_Selected, (arosx_gamepad->Buttons & AROSX_GAMEPAD_LEFT_THUMB));
                                            set(gui->GamepadObject_right_thumb, MUIA_Selected, (arosx_gamepad->Buttons & AROSX_GAMEPAD_RIGHT_THUMB));
                                            set(gui->GamepadObject_dpad_left, MUIA_Selected, (arosx_gamepad->Buttons & AROSX_GAMEPAD_DPAD_LEFT));
                                            set(gui->GamepadObject_dpad_right, MUIA_Selected, (arosx_gamepad->Buttons & AROSX_GAMEPAD_DPAD_RIGHT));
                                            set(gui->GamepadObject_dpad_up, MUIA_Selected, (arosx_gamepad->Buttons & AROSX_GAMEPAD_DPAD_UP));
                                            set(gui->GamepadObject_dpad_down, MUIA_Selected, (arosx_gamepad->Buttons & AROSX_GAMEPAD_DPAD_DOWN));
                                            set(gui->GamepadObject_button_back, MUIA_Selected, (arosx_gamepad->Buttons & AROSX_GAMEPAD_BACK));
                                            set(gui->GamepadObject_button_start, MUIA_Selected, (arosx_gamepad->Buttons & AROSX_GAMEPAD_START));

                                            set(gui->GamepadObject_left_trigger, MUIA_Gauge_Current, (arosx_gamepad->LeftTrigger));
                                            set(gui->GamepadObject_right_trigger, MUIA_Gauge_Current, (arosx_gamepad->RightTrigger));

                                            if(arosx_gamepad->ThumbLX>=0x8000) {
                                                set(gui->GamepadObject_left_stick_x, MUIA_Gauge_Current, (arosx_gamepad->ThumbLX-0x8000));
                                            } else {
                                                set(gui->GamepadObject_left_stick_x, MUIA_Gauge_Current, (0x8000+arosx_gamepad->ThumbLX));
                                            }

                                            if(arosx_gamepad->ThumbLY>=0x8000) {
                                                set(gui->GamepadObject_left_stick_y, MUIA_Gauge_Current, (arosx_gamepad->ThumbLY-0x8000));
                                            } else {
                                                set(gui->GamepadObject_left_stick_y, MUIA_Gauge_Current, (0x8000+arosx_gamepad->ThumbLY));
                                            }

                                            if(arosx_gamepad->ThumbRX>=0x8000) {
                                                set(gui->GamepadObject_right_stick_x, MUIA_Gauge_Current, (arosx_gamepad->ThumbRX-0x8000));
                                            } else {
                                                set(gui->GamepadObject_right_stick_x, MUIA_Gauge_Current, (0x8000+arosx_gamepad->ThumbRX));
                                            }

                                            if(arosx_gamepad->ThumbRY>=0x8000) {
                                                set(gui->GamepadObject_right_stick_y, MUIA_Gauge_Current, (arosx_gamepad->ThumbRY-0x8000));
                                            } else {
                                                set(gui->GamepadObject_right_stick_y, MUIA_Gauge_Current, (0x8000+arosx_gamepad->ThumbRY));
                                            }
                                        }

                                        ReplyMsg((struct Message *)en);
                                    }
                                }
                            }
                        } while(TRUE);
                        set(gui->MainWindow, MUIA_Window_Open, FALSE);
                    }

                    if(gui->App)
                    {
                        MUI_DisposeObject(gui->App);
                        gui->App = NULL;
                    }

                    if(MUIMasterBase)
                    {
                        CloseLibrary(MUIMasterBase);
                        MUIMasterBase = NULL;
                    }

                    if(ps)
                    {
                        CloseLibrary(ps);
                        ps = NULL;
                    }
                }
            }
        }
        }

        AROSX_RemEventHandler(arosx_eventhook);
        CloseLibrary(AROSXBase);

        FreeVec(gui);

        Forbid();

        arosxc->GUITask = NULL;
        --arosxb->Library.lib_OpenCnt;

    }

    AROS_USERFUNC_EXIT
}
Exemple #23
0
/* /// "usbForceDeviceBinding()" */
struct NepClassSerial * usbForceDeviceBinding(struct NepSerialBase *nh, struct PsdDevice *pd)
{
    struct Library *ps;
    struct NepClassSerial *ncp;
    STRPTR devname;
    IPTR prodid;
    IPTR vendid;
    ULONG unitno;
    BOOL  unitfound;
    UBYTE buf[64];
    struct Task *tmptask;

    KPRINTF(1, ("nepSerialForceDeviceBinding(%08lx)\n", pd));
    if((ps = OpenLibrary("poseidon.library", 4)))
    {
        psdGetAttrs(PGA_DEVICE, pd,
                    DA_ProductID, &prodid,
                    DA_VendorID, &vendid,
                    DA_ProductName, &devname,
                    TAG_END);

        nLoadClassConfig(nh);
        Forbid();
        /* Find next free unit number */
        unitno = 0;
        ncp = (struct NepClassSerial *) nh->nh_Units.lh_Head;
        while(ncp->ncp_Unit.unit_MsgPort.mp_Node.ln_Succ)
        {
            if(ncp->ncp_UnitNo == unitno)
            {
                unitno++;
                ncp = (struct NepClassSerial *) nh->nh_Units.lh_Head;
            } else {
                ncp = (struct NepClassSerial *) ncp->ncp_Unit.unit_MsgPort.mp_Node.ln_Succ;
            }
        }
        unitfound = FALSE;
        ncp = (struct NepClassSerial *) nh->nh_Units.lh_Head;
        while(ncp->ncp_Unit.unit_MsgPort.mp_Node.ln_Succ)
        {
            if((ncp->ncp_UnitProdID == prodid) && (ncp->ncp_UnitVendorID == vendid))
            {
                unitno = ncp->ncp_UnitNo;
                unitfound = TRUE;
                break;
            }
            ncp = (struct NepClassSerial *) ncp->ncp_Unit.unit_MsgPort.mp_Node.ln_Succ;
        }
        if(!unitfound)
        {
            /* as units are freed in the expunge-vector, the memory is
               outside the scope of the poseidon library */
            if(!(ncp = AllocVec(sizeof(struct NepClassSerial), MEMF_PUBLIC|MEMF_CLEAR)))
            {
                Permit();
                CloseLibrary(ps);
                return(NULL);
            }
            /* IORequests may be queued even if the task is gone. */
            NewList(&ncp->ncp_Unit.unit_MsgPort.mp_MsgList);
            NewList(&ncp->ncp_ReadQueue);
            NewList(&ncp->ncp_WriteQueue);
            AddTail(&nh->nh_Units, &ncp->ncp_Unit.unit_MsgPort.mp_Node);
            ncp->ncp_DenyRequests = TRUE;
        }
        ncp->ncp_DevBase = nh->nh_DevBase;
        ncp->ncp_UnitNo = unitno;
        ncp->ncp_Device = pd;
        ncp->ncp_UnitProdID = prodid;
        ncp->ncp_UnitVendorID = vendid;
        Permit();

        psdSafeRawDoFmt(buf, 64, "palmpda.class<%08lx>", ncp);
        ncp->ncp_ReadySignal = SIGB_SINGLE;
        ncp->ncp_ReadySigTask = FindTask(NULL);
        SetSignal(0, SIGF_SINGLE);
        if((tmptask = psdSpawnSubTask(buf, nSerialTask, ncp)))
        {
            psdBorrowLocksWait(tmptask, 1UL<<ncp->ncp_ReadySignal);
            if(ncp->ncp_Task)
            {
                ncp->ncp_ReadySigTask = NULL;
                //FreeSignal(ncp->ncp_ReadySignal);
                psdAddErrorMsg(RETURN_OK, (STRPTR) libname,
                               "This '%s' PDA is hot at %s unit %ld!",
                               devname, nh->nh_DevBase->np_Library.lib_Node.ln_Name,
                               ncp->ncp_UnitNo);

                CloseLibrary(ps);
                return(ncp);
            }
        }
        ncp->ncp_ReadySigTask = NULL;
        //FreeSignal(ncp->ncp_ReadySignal);
        /* Get rid of unit structure */
        /*Forbid();
        Remove((struct Node *) ncp);
        FreeVec(ncp);
        Permit();*/
        CloseLibrary(ps);
    }
    return(NULL);
}
Exemple #24
0
    EXAMPLE

    BUGS

    SEE ALSO
        LockTaskList(), NextTaskEntry()

    INTERNALS

*****************************************************************************/
{
    AROS_LIBFUNC_INIT

#ifdef TASKRES_ENABLE
    struct TaskListPrivate *taskList, *tltmp;
    struct Task *thisTask = FindTask(NULL);
#endif /* TASKRES_ENABLE */

    D(bug("[TaskRes] UnLockTaskList: flags = $%lx\n", flags));

#ifdef TASKRES_ENABLE
    ReleaseSemaphore(&TaskResBase->trb_Sem);

    ForeachNodeSafe(&TaskResBase->trb_LockedLists, taskList, tltmp)
    {
        if (((struct Task *)taskList->tlp_Node.ln_Name == thisTask) &&
            (taskList->tlp_Flags == flags))
        {
            D(bug("[TaskRes] UnLockTaskList: Releasing TaskList @ 0x%p\n", taskList));
            Remove(&taskList->tlp_Node);
            FreeMem(taskList, sizeof(struct TaskListPrivate));
Exemple #25
0
int __asm __saveds L_Module_Entry(
	register __a0 struct List *files,
	register __a1 struct Screen *callback1,
	register __a2 IPCData *callback2,
	register __a3 IPCData *main_ipc,
	register __d0 ULONG mod_id,
	register __d1 ULONG mod_data)
{
	NewConfigWindow newwin;
	struct Window *window;
	ObjectList *objlist;
	Att_List *list;
	TimerHandle *timer;
	short count=0;
	struct Task *task;
	rego_data test={0};

	// Call back to main program
	((void __asm (*)
		(register __a0 struct List *,
		register __a1 rego_data *,
		register __a2 rego_data *,
		register __a3 void **,
		register __d0 ULONG))callback2)(files,&test,&rego,&newwin.parent,global_checksum);

	// Won't work with DOpus library > 55
	if (DOpusBase->lib_Version>55)
		return 0;

	// Fix IPC
	main_ipc->proc=(struct Process *)FindTask(0);
	main_ipc->proc->pr_Task.tc_UserData=main_ipc;
	main_ipc->list=0;
	if (!main_ipc->command_port)
		main_ipc->command_port=CreateMsgPort();

	// Fill out new window
	newwin.parent=0;
	newwin.dims=&serial_window;
	newwin.title=GetString(locale,MSG_TITLE);
	newwin.locale=locale;
	newwin.port=0;
	newwin.flags=WINDOW_VISITOR|WINDOW_NO_CLOSE|WINDOW_REQ_FILL|WINDOW_AUTO_KEYS;
	newwin.font=0;

	// Initialise timer
	if (!(timer=AllocTimer(UNIT_VBLANK,0)))
		return 0;

	// Open window
	if (!(window=OpenConfigWindow(&newwin)) ||
		!(objlist=AddObjectList(window,serial_objects)))
	{
		CloseConfigWindow(window);
		FreeTimer(timer);
		return 0;
	}

	// Set ok flag
	*((ULONG *)mod_data)|=(1<<28);

	// Display text
	list=build_text_display(window,objlist,message0);

	// Start timer
	StartTimer(timer,DELAY,0);

	// Event loop
	FOREVER
	{
		struct IntuiMessage *msg;
		BOOL break_flag=0;

		// Timer returned?
		if (CheckTimer(timer))
		{
			// Exit
			break_flag=1;
		}

		// Any Intuition messages?
		while (msg=GetWindowMsg(window->UserPort))
		{
			struct IntuiMessage copy_msg;

			// Copy message and reply
			copy_msg=*msg;
			ReplyWindowMsg(msg);

			// Gadget?
			if (copy_msg.Class==IDCMP_GADGETUP)
			{
				struct Gadget *gadget;

				// Get gadget
				gadget=(struct Gadget *)copy_msg.IAddress;

				// Look at gadget ID
				switch (gadget->GadgetID)
				{
					// Ok
					case GAD_SERIAL_OKAY:

						break_flag=1;
						break;
				}
			}
		}

		if (break_flag) break;

		Wait(1<<window->UserPort->mp_SigBit|1<<timer->port->mp_SigBit);
	}

	// Close window
	CloseConfigWindow(window);

	// Free list and timer
	Att_RemList(list,0);
	FreeTimer(timer);

	// Success
	return 1;
}
int
main( void )
{
  struct RDArgs *rdargs;
  int            rc = RETURN_OK;

  GfxBase       = (struct GfxBase *) OpenLibrary( GRAPHICSNAME, 37 );
  IntuitionBase = (struct IntuitionBase *) OpenLibrary( "intuition.library", 37 );
  
  if( GfxBase == NULL )
  {
    Printf( "Unable to open %s version %ld\n", (ULONG) GRAPHICSNAME, 37 );
    cleanup();
    return RETURN_FAIL;
  }

  if( IntuitionBase == NULL )
  {
    Printf( "Unable to open %s version %ld\n", (ULONG) "intuition.library", 37 );
    cleanup();
    return RETURN_FAIL;
  }

  rdargs = ReadArgs( TEMPLATE , (LONG *) &args, NULL );

  if( rdargs != NULL )
  {
    /* Refresh database */

    if( args.refresh && !args.remove )
    {
      ULONG id;

      OpenAHI();

      /* First, empty the database */
      
      for( id = AHI_NextAudioID( AHI_INVALID_ID );
           id != (ULONG) AHI_INVALID_ID;
           id = AHI_NextAudioID( AHI_INVALID_ID ) )
      {
        AHI_RemoveAudioMode( id );
      }

      /* Now add all modes */

      if( !AHI_LoadModeFile( "DEVS:AudioModes" ) )
      {
        if( IS_MORPHOS )
        {
          ULONG res;

          /* Be quiet here. - Piru */
          APTR *windowptr = &((struct Process *) FindTask(NULL))->pr_WindowPtr;
          APTR oldwindowptr = *windowptr;
          *windowptr = (APTR) -1;
          res = AHI_LoadModeFile( "MOSSYS:DEVS/AudioModes" );
          *windowptr = oldwindowptr;

          if( !res )
          {
            if( !args.quiet )
            {
              PrintFault( IoErr(), "AudioModes" );
            }

            rc = RETURN_ERROR;
          }
        }
        else
        {
          if ( !args.quiet )
          {
            PrintFault( IoErr(), "DEVS:AudioModes" );
          }

          rc = RETURN_ERROR;
        }
      }
    }

    /* Load mode files */

    if( args.files != NULL && !args.remove )
    {
      int i = 0;

      OpenAHI();

      while( args.files[i] )
      {
        if( !AHI_LoadModeFile( args.files[i] ) && !args.quiet )
        {
          PrintFault( IoErr(), args.files[i] );
          rc = RETURN_ERROR;
        }
        i++;
      }
    }

    /* Remove database */

    if( args.remove )
    {
      if( args.files || args.refresh )
      {
        PutStr( "The REMOVE switch cannot be used together with FILES or REFRESH.\n" );
        rc = RETURN_FAIL;
      }
      else
      {
        ULONG id;

        OpenAHI();

        for( id = AHI_NextAudioID( AHI_INVALID_ID );
             id != (ULONG) AHI_INVALID_ID;
             id = AHI_NextAudioID( AHI_INVALID_ID ) )
        {
          AHI_RemoveAudioMode( id );
        }
      }
    }

    /* Make display mode doublescan (allowing > 28 kHz sample rates) */

    if( args.dblscan )
    {
      ULONG          id;
      ULONG          bestid = INVALID_ID;
      int            minper = INT_MAX;
      struct Screen *screen = NULL;

      static const struct ColorSpec colorspecs[] =
      {
        { 0, 0, 0, 0 },
        { 1, 0, 0, 0 },
        {-1, 0, 0, 0 }
      };
      
      union {
        struct MonitorInfo mon;
        struct DisplayInfo dis;
      } buffer;

      for( id = NextDisplayInfo( INVALID_ID );
           id != (ULONG) INVALID_ID;
           id = NextDisplayInfo( id ) )
      {
        int period;

        if( GetDisplayInfoData( NULL, 
                                (UBYTE*) &buffer.dis, sizeof(buffer.dis),
                                DTAG_DISP, id ) )
        {
          if( !(buffer.dis.PropertyFlags & (DIPF_IS_ECS | DIPF_IS_AA ) ) )
          {
            continue;
          }
        }

        if( GetDisplayInfoData( NULL,
                                (UBYTE*) &buffer.mon, sizeof(buffer.mon),
                                DTAG_MNTR, id ) )
        {
          period = buffer.mon.TotalColorClocks * buffer.mon.TotalRows
                   / ( 2 * ( buffer.mon.TotalRows - buffer.mon.MinRow + 1 ) );

          if( period < minper )
          {
            minper = period;
            bestid = id;
          }
        }

      }

      if( bestid != (ULONG) INVALID_ID && minper < 100 )
      {
        screen = OpenScreenTags( NULL,
                                 SA_DisplayID,  bestid,
                                 SA_Colors,    (ULONG) &colorspecs,
                                 TAG_DONE );
      }
      else if( ( GfxBase->ChipRevBits0 & (GFXF_HR_DENISE | GFXF_AA_LISA ) ) != 0 )
      {
        /* No suitable screen mode found, let's bang the hardware...
           Using code from Sebastiano Vigna <[email protected]>. */

        struct Custom *custom = (struct Custom *) 0xdff000;

        custom->bplcon0  = 0x8211;
        custom->ddfstrt  = 0x0018;
        custom->ddfstop  = 0x0058;
        custom->hbstrt   = 0x0009;
        custom->hsstop   = 0x0017;
        custom->hbstop   = 0x0021;
        custom->htotal   = 0x0071;
        custom->vbstrt   = 0x0000;
        custom->vsstrt   = 0x0003;
        custom->vsstop   = 0x0005;
        custom->vbstop   = 0x001D;
        custom->vtotal   = 0x020E;
        custom->beamcon0 = 0x0B88;
        custom->bplcon1  = 0x0000;
        custom->bplcon2  = 0x027F;
        custom->bplcon3  = 0x00A3;
        custom->bplcon4  = 0x0011;
      }

      if( screen != NULL )
      {
        CloseScreen( screen );
      }
    }

    FreeArgs( rdargs );
  }

  cleanup();
  return rc;
}
Exemple #27
0
extern void uae_set_thread_priority (int pri)
{
    SetTaskPri (FindTask (NULL), pri);
}
Exemple #28
0
BOOL BuildGUI(char *screenname) {
	Object **ar = Window_Objs;
  struct Screen *screen;
  BOOL OptionFrame = FALSE;
  LONG indicatorwidth = 100;

  UpdateStrings();

  // Kludge for Piccaso 96/BGUI.
  if(FindTask("Picasso96"))
  {
    PopUpMenus = FALSE;
  }

  BGUIBase = (void *)OpenLibrary("bgui.library", 41);
  if(BGUIBase == NULL) {
    Printf((char *) msgTextNoOpen, (ULONG) "bgui.library", 41);
    Printf("\n");
    return FALSE;
  }

  screen = LockPubScreen(screenname);

  indicatorwidth = max(indicatorwidth, 16 * screen->RastPort.Font->tf_XSize);
  if(screen->Height > 240) {
    OptionFrame = TRUE;
  }

  WO_Window = WindowObject,
    WINDOW_PubScreen,       screen,
    WINDOW_Title,           (char *) msgTextProgramName,
    WINDOW_CloseGadget,     FALSE,
    WINDOW_MenuStrip,       Menus,
    WINDOW_AutoAspect,      TRUE,
    WINDOW_AutoKeyLabel,    TRUE,
    WINDOW_ScaleWidth,      60,
    WINDOW_ScaleHeight,     20,
    WINDOW_HelpFile,        HELPFILE,
    WINDOW_HelpNode,        "AHI",
    WINDOW_IDCMPHook,      &IDCMPhook,
    WINDOW_IDCMPHookBits,   IDCMP_RAWKEY,

    WINDOW_MasterGroup, VGroupObject, NormalOffset,

/* TABS */

      StartMember, ar[ACTID_TABS] = MxObject,
        MX_Labels, PageNames,
        MX_TabsObject, TRUE,
        GA_ID, ACTID_TABS,
      EndObject, FixMinHeight, EndMember,

      StartMember, ar[ACTID_PAGE] = PageObject, NormalSpacing, 
        PAGE_NoBufferRP, TRUE,

/* PAGE 1 */

        PageMember, HGroupObject, NormalOffset, NormalSpacing, TabAboveFrame,

          StartMember, vgroup = VGroupObject, NormalSpacing,

            StartMember, ar[ACTID_UNIT] = CycleObject,
              CYC_Labels,    Units,
              CYC_Active,    state.UnitSelected,
              CYC_PopActive, PopUpMenus,
              CYC_Popup,     PopUpMenus,
              GA_ID,         ACTID_UNIT,
            EndObject, FixMinHeight, EndMember,

            StartMember, ar[ACTID_MODE] = ListviewObject,
//              LISTV_EntryArray,  Modes,
//              LISTV_Select,      state.ModeSelected,
              PGA_NewLook, TRUE,
              GA_ID, ACTID_MODE,
            EndObject, EndMember,

            StartMember, HGroupObject,
              ButtonFrame, FRM_Flags, FRF_RECESSED,
          
              StartMember, InfoObject,
                INFO_TextFormat,  (char *) msgProperties,
                INFO_FixTextWidth,TRUE,
                INFO_MinLines,    6,
              EndObject, FixMinWidth, EndMember,

              StartMember, ar[SHOWID_MODE] = InfoObject,
                INFO_MinLines,   6,
              EndObject,  EndMember,
            EndObject, FixMinHeight, EndMember,

          EndObject /* vgroup */, EndMember,

          StartMember, VGroupObject, NormalSpacing, 

            VarSpace(1),

            StartMember, VGroupObject,
              (OptionFrame ? GROUP_HorizOffset : TAG_IGNORE), GRSPACE_NORMAL,
              (OptionFrame ? GROUP_VertOffset  : TAG_IGNORE), GRSPACE_NORMAL,
              (OptionFrame ? GROUP_Spacing     : TAG_IGNORE), GRSPACE_NORMAL,
              (OptionFrame ? FRM_Type          : TAG_IGNORE), FRTYPE_RIDGE,
              (OptionFrame ? FRM_Flags         : TAG_IGNORE), FRF_RECESSED,
              (OptionFrame ? FRM_Title         : TAG_IGNORE), (char *) msgOptions,

              StartMember, HGroupObject,
                StartMember, ar[ACTID_FREQ] = SliderObject,
                  LAB_Label,    (char *) msgOptFrequency,
                  SLIDER_Min,   0,
                  SLIDER_Max,   state.Frequencies -1 ,
                  SLIDER_Level, state.FreqSelected,
                  PGA_NewLook, TRUE,
                  GA_ID, ACTID_FREQ,
                EndObject, EndMember,

                StartMember, ar[SHOWID_FREQ] = InfoObject,
                  INFO_TextFormat,    getFreq(),
                  INFO_VertOffset,    0,
                EndObject, FixWidth(indicatorwidth), EndMember,
              EndObject, FixMinHeight, EndMember,

              StartMember, HGroupObject,
                StartMember, ar[ACTID_CHANNELS] = SliderObject,
                  LAB_Label,    (char *) msgOptChannels,
                  SLIDER_Min,   1,
                  SLIDER_Max,   state.Channels,
                  SLIDER_Level, state.ChannelsSelected,
                  PGA_NewLook, TRUE,
                  GA_ID, ACTID_CHANNELS,
                EndObject, EndMember,

                StartMember, ar[SHOWID_CHANNELS] = InfoObject,
                  INFO_TextFormat,    getChannels(),
                  INFO_VertOffset,    0,
                EndObject, FixWidth(indicatorwidth), EndMember,
              EndObject, FixMinHeight, EndMember,

              StartMember, HGroupObject,
                StartMember, ar[ACTID_OUTVOL] = SliderObject,
                  LAB_Label,    (char *) msgOptVolume,
                  SLIDER_Min,   0,
                  SLIDER_Max,   state.OutVols-1 ,
                  SLIDER_Level, state.OutVolSelected,
                  PGA_NewLook, TRUE,
                  GA_ID, ACTID_OUTVOL,
                EndObject, EndMember,

                StartMember, ar[SHOWID_OUTVOL] = InfoObject,
                  INFO_TextFormat,    getOutVol(),
                  INFO_VertOffset,    0,
                EndObject, FixWidth(indicatorwidth), EndMember,
              EndObject, FixMinHeight, EndMember,

              StartMember, HGroupObject,
                StartMember, ar[ACTID_MONVOL] = SliderObject,
                  LAB_Label,    (char *) msgOptMonitor,
                  SLIDER_Min,   0,
                  SLIDER_Max,   state.MonVols-1 ,
                  SLIDER_Level, state.MonVolSelected,
                  PGA_NewLook, TRUE,
                  GA_ID, ACTID_MONVOL,
                EndObject, EndMember,

                StartMember, ar[SHOWID_MONVOL] = InfoObject,
                  INFO_TextFormat,    getMonVol(),
                  INFO_VertOffset,    0,
                EndObject, FixWidth(indicatorwidth), EndMember,
              EndObject, FixMinHeight, EndMember,

              StartMember, HGroupObject,
                StartMember, ar[ACTID_GAIN] = SliderObject,
                  LAB_Label,    (char *) msgOptGain,
                  SLIDER_Min,   0,
                  SLIDER_Max,   state.Gains-1 ,
                  SLIDER_Level, state.GainSelected,
                  PGA_NewLook, TRUE,
                  GA_ID, ACTID_GAIN,
                EndObject, EndMember,

                StartMember, ar[SHOWID_GAIN] = InfoObject,
                  INFO_TextFormat,    getGain(),
                  INFO_VertOffset,    0,
                EndObject, FixWidth(indicatorwidth), EndMember,
              EndObject, FixMinHeight, EndMember,

              StartMember, HGroupObject,
                StartMember, ar[ACTID_INPUT] = SliderObject,
                  LAB_Label,    (char *) msgOptInput,
                  SLIDER_Min,   0,
                  SLIDER_Max,   state.Inputs-1 ,
                  SLIDER_Level, state.InputSelected,
                  PGA_NewLook, TRUE,
                  GA_ID, ACTID_INPUT,
                EndObject, EndMember,

                StartMember, ar[SHOWID_INPUT] = InfoObject,
                  INFO_TextFormat,    getInput(),
                  INFO_VertOffset,    0,
                EndObject, FixWidth(indicatorwidth), EndMember,
              EndObject, FixMinHeight, EndMember,

              StartMember, HGroupObject,
                StartMember, ar[ACTID_OUTPUT] = SliderObject,
                  LAB_Label,    (char *) msgOptOutput,
                  SLIDER_Min,   0,
                  SLIDER_Max,   state.Outputs-1 ,
                  SLIDER_Level, state.OutputSelected,
                  PGA_NewLook, TRUE,
                  GA_ID, ACTID_OUTPUT,
                EndObject, EndMember,

                StartMember, ar[SHOWID_OUTPUT] = InfoObject,
                  INFO_TextFormat,    getOutput(),
                  INFO_VertOffset,    0,
                EndObject, FixWidth(indicatorwidth), EndMember,
              EndObject, FixMinHeight, EndMember,

            EndObject /* vgroup "Options" */, FixMinHeight, EndMember,

          VarSpace(1),

          EndObject /* vgroup */, EndMember,

        EndObject, /* (EndMember) page */

/* PAGE 2 */

        PageMember, HGroupObject, NormalSpacing, TabAboveFrame,

          VarSpace(1),

          StartMember, VGroupObject, NormalSpacing,

            VarSpace(1), 

            StartMember, VGroupObject, NormalOffset, NormalSpacing,
              RidgeFrame, FRM_Flags, FRF_RECESSED, FrameTitle((char *) msgGlobalOptions),

              StartMember, HGroupObject, NormalSpacing,
              StartMember, VGroupObject, NormalSpacing,

              StartMember, ar[ACTID_DEBUG] = CycleObject,
                LAB_Label,      (char *) msgGlobOptDebugLevel,
                LAB_Place,      PLACE_LEFT,
                CYC_Labels,     DebugLabels,
                CYC_Active,     globalprefs.ahigp_DebugLevel,
                CYC_PopActive,  PopUpMenus,
                CYC_Popup,      PopUpMenus,
                GA_ID,          ACTID_DEBUG,
              EndObject, FixMinHeight, EndMember,

              StartMember, ar[ACTID_ECHO] = CycleObject,
                LAB_Label,      (char *) msgGlobOptEcho,
                LAB_Place,      PLACE_LEFT,
                CYC_Labels,     EchoLabels,
                CYC_Active,     (globalprefs.ahigp_DisableEcho ? 2 : 0) |
                                (globalprefs.ahigp_FastEcho    ? 1 : 0),
                CYC_PopActive,  PopUpMenus,
                CYC_Popup,      PopUpMenus,
                GA_ID,          ACTID_ECHO,
              EndObject, FixMinHeight, EndMember,

              StartMember, ar[ACTID_SURROUND] = CycleObject,
                LAB_Label,      (char *) msgGlobOptSurround,
                LAB_Place,      PLACE_LEFT,
                CYC_Labels,     SurroundLabels,
                CYC_Active,     globalprefs.ahigp_DisableSurround,
                GA_ID,          ACTID_SURROUND,
              EndObject, FixMinHeight, EndMember,

              StartMember, ar[ACTID_CLIPMV] = CycleObject,
                LAB_Label,      (char *) msgGlobOptMasterVol,
                LAB_Place,      PLACE_LEFT,
                CYC_Labels,     ClipMVLabels,
                CYC_Active,     globalprefs.ahigp_ClipMasterVolume,
                GA_ID,          ACTID_CLIPMV,
              EndObject, FixMinHeight, EndMember,

              StartMember, ar[ACTID_CPULIMIT] = SliderObject,
                LAB_Label,    (char *) msgGlobOptCPULimit,
                SLIDER_Min,   0,
                SLIDER_Max,   100,
                SLIDER_Level, (globalprefs.ahigp_MaxCPU * 100 + 32768) >> 16,
                PGA_NewLook, TRUE,
                GA_ID, ACTID_CPULIMIT,
              EndObject, EndMember,

              EndObject /* vgroup */, EndMember,

              StartMember, VGroupObject, NormalSpacing,

                VarSpace(1),

                StartMember, ar[SHOWID_CPULIMIT] = IndicatorObject,\
                  INDIC_Min,              0,
                  INDIC_Max,              100,
                  INDIC_Level,            (globalprefs.ahigp_MaxCPU * 100 + 32768) / 65536,
                  INDIC_Justification,    IDJ_LEFT,
                  INDIC_FormatString,     "%ld%%",
                EndObject, FixMinWidth, FixMinHeight, EndMember,

              EndObject /* vgroup */, EndMember,
              EndObject /* hgroup */, EndMember,

            EndObject, FixMinWidth, FixMinHeight, EndMember,

            VarSpace(1),

          EndObject /* vgroup */ , FixMinWidth, EndMember,

          VarSpace(1),

        EndObject, /* (EndMember) page */

      EndObject /* page */, EndMember,


/* BUTTONS */
      StartMember, HGroupObject, NormalSpacing, NormalVOffset,

        StartMember, ar[ACTID_SAVE] = ButtonObject,
          ButtonFrame,
          LAB_Label, (char *) msgButtonSave,
          GA_ID,     ACTID_SAVE,
        EndObject, EndMember,

        StartMember, ar[ACTID_USE] = ButtonObject,
          ButtonFrame,
          LAB_Label, (char *) msgButtonUse,
          GA_ID,     ACTID_USE,
        EndObject, EndMember,

        StartMember, ar[ACTID_QUIT] = ButtonObject,
          ButtonFrame,
          LAB_Label, (char *) msgButtonCancel,
          GA_ID,     ACTID_QUIT,
        EndObject, EndMember,
      EndObject, FixMinHeight, EndMember,
    EndObject,
  EndObject;

  if(WO_Window) {
    AddMap( ar[ACTID_TABS], ar[ACTID_PAGE], pagemap );

    DoMethod( ar[ACTID_FREQ],     BASE_ADDHOOK, &GadgetHook );
    DoMethod( ar[ACTID_CHANNELS], BASE_ADDHOOK, &GadgetHook );
    DoMethod( ar[ACTID_OUTVOL],   BASE_ADDHOOK, &GadgetHook );
    DoMethod( ar[ACTID_MONVOL],   BASE_ADDHOOK, &GadgetHook );
    DoMethod( ar[ACTID_GAIN],     BASE_ADDHOOK, &GadgetHook );
    DoMethod( ar[ACTID_INPUT],    BASE_ADDHOOK, &GadgetHook );
    DoMethod( ar[ACTID_OUTPUT],   BASE_ADDHOOK, &GadgetHook );

    AddMap( ar[ACTID_CPULIMIT], ar[SHOWID_CPULIMIT], cpumap);

    window = WindowOpen(WO_Window);
  }

  if(screen) {
    UnlockPubScreen(NULL, screen);
  }

  if(window == NULL) {
    Printf((char *) msgTextNoWindow);
    Printf("\n");
    return FALSE;
  }

  openreq = FileReqObject,
    ASLFR_Window,        window,
    ASLFR_SleepWindow,   TRUE,
    ASLFR_RejectIcons,   TRUE,
    ASLFR_InitialDrawer, "SYS:Prefs/Presets",
  EndObject;

  savereq = FileReqObject,
    ASLFR_Window,        window,
    ASLFR_SleepWindow,   TRUE,
    ASLFR_RejectIcons,   TRUE,
    ASLFR_InitialDrawer, "SYS:Prefs/Presets",
    ASLFR_DoSaveMode,    TRUE,
  EndObject;

  if((openreq == NULL) || (savereq == NULL)) {
    Printf((char *) msgTextNoFileRequester);
    Printf("\n");
    return FALSE;
  }

  // Update the checkmark for "Create Icons?"
  {
    struct Menu     *menu = NULL;
    struct MenuItem *item;

    GetAttr( WINDOW_MenuStrip, WO_Window, (ULONG *) &menu);
    ClearMenuStrip(window);

    item = FindMenuItem(ACTID_ICONS);

    if(item) {
      if(SaveIcons)
        item->Flags |= CHECKED;
      else
        item->Flags &= ~CHECKED;
    }
    ResetMenuStrip(window, menu);
  }

  GUINewUnit();
  return TRUE;
}
Exemple #29
0
INLINE VOID zat_properties( ZoneAlarmTask * zat )
{
	D_S(struct FileInfoBlock,fib);
	GLOBAL struct Library * DOSBase;
	STRPTR data;
	ZoneAlarmTask * x;
	
	zat->execrc = (~0);
	zat->exever = NULL;
	zat->virus  = NULL;
	
	ENTER();
	DBG_ASSERT(G->mTask == FindTask(NULL));
	
	if((x = ZoneAlarmRecord( zat )))
	{
		DBG("Found record for \"%s\"\n", zat->executable );
		
		zat->execrc = x->execrc;
		
		if( x->exever && *x->exever )
			zat->exever = StrDup(x->exever);
		
		zat->xvs = x->xvs;
		if( x->virus && *x->virus )
			zat->virus = StrDup(x->virus);
		
		DBG_ASSERT(x->xvs != XVS_VIRUSDETECTED);
	}
	else if((data = FileToMem( zat->executable, fib, DOSBase )))
	{
		// Get the CRC32 checksum of the file
		zat->execrc = CRC32( data, fib->fib_Size, zat->execrc );
		
		// Get the $VER: string
		zat->exever = GetProgVersion( data, fib->fib_Size );
		
		// Check if it has some virus..
		zat->xvs = xvs_analyzer( data, fib->fib_Size, &zat->virus );
		
		FreeVec(data);
	}
	else if(IoErr() == ERROR_NO_FREE_STORE)
	{
		BPTR fd;
		
		DBG(" -+-+-+-+-+-+-+-+-+-+- have to load the file by chunks!\n");
		
		if((fd = Open( zat->executable, MODE_OLDFILE)))
		{
			LONG size = 262144;
			
			while(!(data = AllocVec( size+1, MEMF_FAST )))
			{
				size >>= 1;
				
				if(size < 1024) break;
			}
			
			if( data != NULL )
			{
				LONG r;
				
				while((r=Read( fd, data, size )) > 0)
				{
					zat->execrc = CRC32( data, r, zat->execrc );
				}
				
				FreeVec(data);
			}
			
			Close(fd);
		}
Exemple #30
0
int main(void)
{
    struct TrackedResources *crs = NULL;
    struct TrackedResources *start_rs = NULL;
    BOOL quitme = FALSE;
    int numlines = 30;
    struct Task *this;
    ULONG  portsig;
    struct MsgPort *port;

    this = FindTask(NULL);

    port = CreateMsgPort();
    if (!port)
	return 2;
    port->mp_Node.ln_Name = "LeakWatch";
    port->mp_Node.ln_Pri  = 0;
    AddPort(port);

    portsig = 1L << port->mp_SigBit;

    open_libs();

    FPuts(Output(), "LeakWatch running, CTRL-C to exit, CTRL-E to watch for leaks since beginning, CTRL-F to watch for leaks since last CTRL-F, CTRL-D for an usage snapshot\n");

    crs = NewResourcesState();
    if (NULL == crs)
	quitme = TRUE;
    else
	start_rs = CopyResourcesState(crs);

    while(!quitme)
    {
	ULONG signals;

	signals = Wait(portsig | SIGBREAKF_CTRL_F | SIGBREAKF_CTRL_E | SIGBREAKF_CTRL_D | SIGBREAKF_CTRL_C);

	if (signals & SIGBREAKF_CTRL_D)
	{
	    struct TrackedResources *tr;

	    tr = NewResourcesState();
	    if (NULL == tr)
	    {
		quitme = TRUE;
		break;
	    }
	    DisplayResourcesState(tr, numlines);
	    DeleteResourcesState(tr);
	}
	if (signals & SIGBREAKF_CTRL_E)
	{
	    struct ResourceDiff *rd = NULL;

	    DeleteResourcesState(crs);
	    crs = NewResourcesState();
	    if (NULL == crs)
	    {
		quitme = TRUE;
		break;
	    }
	    /*  DisplayResourcesState(crs); */ /* only for debug */
	    rd = NewStateDiff(start_rs, crs);
	    DisplayStateDiff(rd, numlines);
	    DeleteStateDiff(rd);
	}
	if (signals & SIGBREAKF_CTRL_F)
	{
	    struct TrackedResources *ors = crs;
	    struct ResourceDiff *rd = NULL;

	    crs = NewResourcesState();
	    if (NULL == crs)
	    {
		quitme = TRUE;
		break;
	    }
	    rd = NewStateDiff(ors, crs);
	    DisplayStateDiff(rd, numlines);
	    DeleteStateDiff(rd);
	    DeleteResourcesState(ors);
	}
	if (signals & SIGBREAKF_CTRL_C)
	{
	    quitme = TRUE;
	}
	if (signals & portsig)
	{
	    struct Message *msg;

	    while((msg = (struct Message *)GetMsg(port)))
	    {
		D(bug("Received watch message.\n"));

		ReplyMsg(msg);
	    }

	}
    } /* while(!quitme) */

    DeleteResourcesState(crs);
    DeleteResourcesState(start_rs);

    close_libs();

    if (port)
    {
	RemPort(port);
    	DeleteMsgPort(port);
    }
    return 0;
}