コード例 #1
0
ファイル: cookie.c プロジェクト: daemqn/Atari_ST_Sources
short Getcookie(long cookie, long *value)
{
	/* Check for Ssystem if not done yet */
	if (has_ssystem < 0)
		has_ssystem = Ssystem(-1, 0, 0) == 0;

	/* Use Ssystem if available... */
	if (has_ssystem > 0)
	{
		long r, val=-42;

		r = Ssystem(S_GETCOOKIE, cookie, (long)&val);
		/*
		 * Backward compatibility for MiNT 1.14.7:
		 * Ssystems() returns cookie value and ignores arg2!!
		 */
		if (r != -1 && val == -42)				
			val = r;
		if (!r)
		{
			if (value)
				*value = val;
			return C_FOUND;
		}
		else
		{
			if (value)
				*value = 0L;
			return C_NOTFOUND;
		}
	}
	else
	{
		/* Check get address of cookie jar */
		long *jar = (long *)Supexec(__init_cookie);
		
		if(jar == NULL)
			return C_JARNOTINSTALLED;
		
		do
		{
			if (jar[0] == cookie)			/* check if cookie already exists */
			{
				if (value)
					*value = jar[1];		/* extract value */

				return C_FOUND;				/* Return success */
			}
			else
				jar = &(jar[2]);			/* continue search... */
		}while(jar[-2]);					/* ... up to end of cookie list */

		return C_NOTFOUND;					/* Inform user about failure */
	}
}
コード例 #2
0
ファイル: cookie.c プロジェクト: daemqn/Atari_ST_Sources
short Setcookie(long cookie, long value)
{
	/* Check for Ssystem if not done yet */
	if (has_ssystem < 0)
		has_ssystem = Ssystem(-1, 0, 0) == 0;
	
	/* Use Ssystem if available... */
	if (has_ssystem > 0)
	{
		long r;
		r = Ssystem(S_SETCOOKIE, cookie, value);
		if (!r)
			return C_OK;
		else
			return C_NOTFOUND;
	}
	else
	{
		short count = 0;
		
		/* Check get address of cookie jar */
		long *jar = (long *)Supexec(__init_cookie);
		
		if(jar == NULL)
			return C_JARNOTINSTALLED;
		
		do
		{
			count++;						/* count number of cookies */
			if(jar[0] == cookie)			/* check if cookie already exists */
			{
				jar[1] = value;
				return C_OK;
			}
			else
				jar = &(jar[2]);			/* continue search... */
		}while(jar[-2]);					/* ... up to end of cookie list */

		if(jar[-1]>count)					/* check if there is enought space */
		{
			jar[0] = 0;						/* Move empty cookie,,,*/
			jar[1] = jar[-1];				/* ... including value */
			jar[-2] = cookie;				/* Set our own cookie... */
			jar[-1] = value;				/* ... and value */
			return C_OK;					/* Return successful addition */
		}
		else
			return C_JARFULL;				/* Inform user about missing space */
	}
}
コード例 #3
0
ファイル: cookie.c プロジェクト: daemqn/Atari_ST_Sources
short Removecookie(long cookie)
{
	/* Check for Ssystem if not done yet */
	if (has_ssystem < 0)
		has_ssystem = Ssystem(-1, 0, 0) == 0;
	
	/* Use Ssystem if available... */
	if (has_ssystem > 0)
	{
		long r;
		r = Ssystem(S_DELCOOKIE, cookie, (long)NULL);
		if (!r)
			return C_OK;
		else
			return C_NOTFOUND;
	}
	else
	{
		/* Check get address of cookie jar */
		long *jar = (long *)Supexec(__init_cookie);
		
		if(jar == NULL)
			return C_JARNOTINSTALLED;
		
		do
		{
			if (jar[0] == cookie)			/* Check if it's our cookie */
			{
				do
				{
					jar[0] = jar[2];		/* Move all cookies 1 entry up... */
					jar[1] = jar[3];
					jar = &(jar[2]);		/* Next cookie */
				}while(jar[-2]);			/* Up to the end of the list */
				return C_OK;				/* Return successful remove */
			}
			else
				jar = &(jar[2]);			/* continue search... */
		}while(jar[-2]);					/* Up to the end of the list */

		return C_NOTFOUND;					/* Inform user about failure */
	}
}
コード例 #4
0
ファイル: XA_CHEAT.C プロジェクト: daemqn/Atari_ST_Sources
short main(void)
{
	/* Check that MiNT is actually installed */
	/* Tried to use mintlibs Getcookie, but failed */
	if (Ssystem(-1, 0, 0) == 0)
	{
		N_AESINFO *cook;
		
		if (Ssystem(S_GETCOOKIE, 'nAES', 0) == -1)
		{
			cook = Mxalloc(sizeof(*cook), MX_GLOBAL | MX_PREFTTRAM);
			if (!cook)
				Cconws("Not enough memory\r\n");
			else
			{
				memset(cook, 0, sizeof(*cook));
				Ssystem(S_SETCOOKIE, 'nAES', (long)cook);	
				Cconws("\r\n\r\nXA_CHEAT: fake 'nAES' cookie.\r\n");
				Cconws("The use of this program is completely\r\n");
				Cconws("at your own risc.\r\n");
				Cconws("Any program accessing the pointer in this\r\n");
				Cconws("cookie will crash hopelessly.\r\n");
				Cconws("So do not use any N.Aes utilities!!!\r\n");
				Cconws("\r\n");
				Cconws("\r\n'nAES' cookie now faked.\r\n\r\n");
				Ptermres(2048, 0);
			}
		}
		else
			Cconws("nAES cookie already exists\r\n");
	}
	else
	{
		Cconws("XaCHEAT requires MiNT\r\n");
		bios(2,2);
	}
	return 0;
}
コード例 #5
0
ファイル: ffi.c プロジェクト: Boereck/jna
ffi_status
ffi_prep_closure_loc (ffi_closure* closure,
                      ffi_cif* cif,
                      void (*fun)(ffi_cif*,void*,void**,void*),
                      void *user_data,
                      void *codeloc)
{
    if (cif->abi != FFI_SYSV)
        return FFI_BAD_ABI;

    *(unsigned short *)closure->tramp = 0x207c;
    *(void **)(closure->tramp + 2) = codeloc;
    *(unsigned short *)(closure->tramp + 6) = 0x4ef9;

    if (
#ifdef __MINT__
        (cif->rtype->type == FFI_TYPE_LONGDOUBLE) ||
#endif
        (((cif->rtype->type == FFI_TYPE_STRUCT)
          && !cif->flags)))
        *(void **)(closure->tramp + 8) = ffi_closure_struct_SYSV;
    else
        *(void **)(closure->tramp + 8) = ffi_closure_SYSV;

#ifdef __rtems__
    rtems_cache_flush_multiple_data_lines( codeloc, FFI_TRAMPOLINE_SIZE );
#elif defined(__MINT__)
    Ssystem(S_FLUSHCACHE, codeloc, FFI_TRAMPOLINE_SIZE);
#else
    syscall(SYS_cacheflush, codeloc, FLUSH_SCOPE_LINE,
            FLUSH_CACHE_BOTH, FFI_TRAMPOLINE_SIZE);
#endif

    closure->cif  = cif;
    closure->user_data = user_data;
    closure->fun  = fun;

    return FFI_OK;
}
コード例 #6
0
ファイル: MAIN.C プロジェクト: daemqn/Atari_ST_Sources
int main(void)
{
	int error;

#if _MINT_				/* HR 151102 */
	have_ssystem = Ssystem(-1, 0, 0) == 0;		/* HR 151102: use Ssystem where possible */

	mint   = (find_cookie('MiNT') == -1) ? FALSE : TRUE;
	magx   = (find_cookie('MagX') == -1) ? FALSE : TRUE;	/* HR 151102 */
	geneva = (find_cookie('Gnva') == -1) ? FALSE : TRUE;    /* DjV 035 080203 */
	mint  |= magx;			/* Quick & dirty */

	if (mint)
	{
		Psigsetmask(0x7FFFE14EL);
		Pdomain(1);
	}
#endif

	x_init();

	if ((ap_id = appl_init()) < 0)
		return -1;

	if  (_GemParBlk.glob.version >= 0x400)
	{
		shel_write(9, 1, 0, NULL, NULL);
		menu_register(ap_id, "  Tera Desktop");
	}

	if (rsrc_load(RSRCNAME) == 0)
		form_alert(1, msg_resnfnd);
	else
	{
		if ((error = init_xdialog(&vdi_handle, malloc, free,
								  "Tera Desktop", 1, &nfonts)) < 0)
			xform_error(error);
		else
		{
			init_vdi();
			rsc_init();

			if (((max_w / screen_info.fnt_w) < 40) || ((max_h / screen_info.fnt_h) < 25))
				alert_printf(1, MRESTLOW);
			else
			{
				if ((error = alloc_global_memory()) == 0)
				{
					if (exec_deskbat() == FALSE)
					{
						if (load_icons() == FALSE)
						{
							if (init() == FALSE)
							{
								graf_mouse(ARROW, NULL);
								evntloop();

								wd_del_all();
								menu_bar(menu, 0);
								xw_close_desk();
							}

							free_icons();		/* HR 151102 */

							wind_set(0, WF_NEWDESK, NULL, 0);
							dsk_draw();
						}
					}

					Mfree(global_memory);
				}
				else
					xform_error(error);
			}

			if (vq_gdos() != 0)
				vst_unload_fonts(vdi_handle, 0);
			exit_xdialog();
		}

		rsrc_free();
	}

	/* DjV 013 030103 100203 ---vvv--- */
	/*
	 * The following section handles system shutdown and resolution change
	 * If a resolution change is required, shutdown is performed first
	 * If only shutdown s required, system will reset at the end.
	 */ 

	/* appl_exit(); */

	if ( chrez || shutdown ) /* If change resolution or shutdown ... */
	{

		/* Tell all applications which would understand it to end */

		quit = shel_write ( 4, 2, 0, NULL, NULL ); 	/* complete shutdown */
		evnt_timer( 3000, 0 );						/* Wait a bit? */

		/*

		/* 
		 * In Mint, must tell all proceseses to terminate nicely ?
		 * but this is only in this group ? What to do?
		 */

		Pkill(0, SIGTERM); 
		evnt_timer(3000, 0); /* Wait a bit? */
		*/

		/* 
		 * After all applications have hopefully been closed,
		 * change the screen resolution if needed;
		 * else- reset the computer
		 */
		if ( chrez )
			get_set_video(2);

#if 1
		else
	#if _MINT_
		if (!mint)			/* HR 230203: Dont reset under MiNT or MagiC !!!!! */
	#endif
		{
			/* Perform a reset here */

	#if 0		/* with warnings */
			long *m;					/* to memory locations */
			long rv;					/* reset vector */

			Super ( 0L );				/* Supervisor; old stack won't be needed again */
			*(m = 0x420L) = 0L;			/* memctrl  */
			*(m = 0x43aL) = 0L;			/* memval2  */
			*(m = 0x426L) = 0L;			/* resvalid */	
			m = *( m = 0x4f2 );			/* to start of OS */
			rv = *(m + 4);				/* to routine that  handles the reset */
			Supexec(rv);				/* execute it */
	#else			/* HR: without warnings */
			long (*rv)();					/* reset vector */

			Super ( 0L );				/* Supervisor; old stack won't be needed again */
			memctrl = 0L;
			memval2 = 0L;
			resvalid = 0L;
			(long)rv = *((long *)os_start + 4);	/* routine that handles the reset */
			Supexec(rv);				/* execute it */
	#endif
		}
#endif
	}