forked from KolibriOS/kolibrios
git-svn-id: svn://kolibrios.org@8209 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
66
contrib/sdk/sources/SDL-1.2.2_newlib/src/Makefile
Executable file
66
contrib/sdk/sources/SDL-1.2.2_newlib/src/Makefile
Executable file
@@ -0,0 +1,66 @@
|
||||
# SDL build makefile_test
|
||||
# writed by maxcodehack
|
||||
|
||||
|
||||
CC = kos32-gcc
|
||||
AR = kos32-ar
|
||||
LD = kos32-ld
|
||||
|
||||
SDK_DIR:= $(abspath ../../..)
|
||||
|
||||
endian_OBJS = endian/SDL_endian.o
|
||||
file_OBJS = file/SDL_rwops.o
|
||||
|
||||
hermes_OBJS = hermes/mmxp2_32.o hermes/mmx_main.o hermes/x86p_16.o \
|
||||
hermes/x86p_32.o hermes/x86_main.o
|
||||
|
||||
thread_OBJS = thread/SDL_syscond.o thread/SDL_sysmutex.o thread/SDL_syssem.o \
|
||||
thread/SDL_systhread.o thread/SDL_thread.o
|
||||
timer_OBJS = timer/SDL_timer.o timer/dummy/SDL_systimer.o
|
||||
event_OBJS = events/SDL_active.o events/SDL_events.o events/SDL_expose.o \
|
||||
events/SDL_keyboard.o events/SDL_mouse.o events/SDL_quit.o \
|
||||
events/SDL_resize.o
|
||||
video_OBJS = video/SDL_blit_0.o video/SDL_blit_1.o video/SDL_blit_A.o \
|
||||
video/SDL_blit.o video/SDL_blit_N.o video/SDL_bmp.o \
|
||||
video/SDL_cursor.o video/SDL_gamma.o video/SDL_pixels.o \
|
||||
video/SDL_RLEaccel.o video/SDL_stretch.o video/SDL_surface.o \
|
||||
video/SDL_video.o video/SDL_yuv.o video/SDL_yuv_mmx.o \
|
||||
video/SDL_yuv_sw.o video/menuetos/SDL_menuetevents.o \
|
||||
video/menuetos/SDL_menuetvideo.o
|
||||
audio_OBJS = audio/SDL_kolibri_audio.o
|
||||
|
||||
curr_OBJS = SDL.o SDL_error.o SDL_fatal.o SDL_getenv.o
|
||||
|
||||
OBJS = $(endian_OBJS) $(file_OBJS) $(hermes_OBJS) $(thread_OBJS) \
|
||||
$(timer_OBJS) $(event_OBJS) $(video_OBJS) $(curr_OBJS) $(audio_OBJS)
|
||||
|
||||
CFLAGS = -c -O2 -D_REENTRANT -I../include -I SYSCALL/include -I. -DPACKAGE=\"SDL\" -DVERSION=\"1.2.2\" \
|
||||
-fexpensive-optimizations -Wall -DENABLE_AUDIO -UDISABLE_AUDIO -DDISABLE_JOYSTICK \
|
||||
-DDISABLE_CDROM -DDISABLE_THREADS -DENABLE_TIMERS \
|
||||
-DUSE_ASMBLIT -Ihermes -Iaudio -Ivideo -Ievents \
|
||||
-Ijoystick -Icdrom -Ithread -Itimer -Iendian -Ifile -DENABLE_MENUETOS \
|
||||
-DNO_SIGNAL_H -DDISABLE_STDIO -DNEED_SDL_GETENV -DENABLE_FILE -UDISABLE_FILE \
|
||||
-D__MENUETOS__ -DDEBUG_VIDEO -UWIN32 -U_Win32 -U_WIN32 -U__MINGW32__ \
|
||||
-I../../newlib/libc/include/
|
||||
|
||||
|
||||
LDFLAGS = -shared -s -T../../newlib/libc/app.lds -nostdlib --image-base 0 -L /home/autobuild/tools/win32/mingw32/lib -lgcc -lz -ldll -lc.dll
|
||||
|
||||
ARFLAGS = crs
|
||||
|
||||
all: libSDL.a
|
||||
|
||||
install: libSDL.a
|
||||
mv -f libSDL.a $(SDK_DIR)/lib
|
||||
|
||||
libSDL.a: $(OBJS)
|
||||
$(AR) $(ARFLAGS) libSDL.a $(OBJS) SYSCALL/src/*.o
|
||||
|
||||
%.o : %.asm Makefile
|
||||
nasm -f coff $< $
|
||||
|
||||
%.o : %.c Makefile
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
clean:
|
||||
rm -f */*.o \ rm *.o \ rm */*/*.o
|
232
contrib/sdk/sources/SDL-1.2.2_newlib/src/SDL.c
Executable file
232
contrib/sdk/sources/SDL-1.2.2_newlib/src/SDL.c
Executable file
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
|
||||
#ifdef SAVE_RCSID
|
||||
static char rcsid =
|
||||
"@(#) $Id: SDL.c,v 1.3 2001/05/23 23:35:09 hercules Exp $";
|
||||
#endif
|
||||
|
||||
/* Initialization code for SDL */
|
||||
|
||||
#include <stdlib.h> /* For getenv() */
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_endian.h"
|
||||
#include "SDL_fatal.h"
|
||||
#ifndef DISABLE_VIDEO
|
||||
#include "SDL_leaks.h"
|
||||
#endif
|
||||
|
||||
/* Initialization/Cleanup routines */
|
||||
#ifndef DISABLE_JOYSTICK
|
||||
extern int SDL_JoystickInit(void);
|
||||
extern void SDL_JoystickQuit(void);
|
||||
#endif
|
||||
#ifndef DISABLE_CDROM
|
||||
extern int SDL_CDROMInit(void);
|
||||
extern void SDL_CDROMQuit(void);
|
||||
#endif
|
||||
#ifndef DISABLE_TIMERS
|
||||
extern void SDL_StartTicks(void);
|
||||
extern int SDL_TimerInit(void);
|
||||
extern void SDL_TimerQuit(void);
|
||||
#endif
|
||||
|
||||
/* The current SDL version */
|
||||
static SDL_version version =
|
||||
{ SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL };
|
||||
|
||||
/* The initialized subsystems */
|
||||
static Uint32 SDL_initialized = 0;
|
||||
static Uint32 ticks_started = 0;
|
||||
|
||||
#ifdef CHECK_LEAKS
|
||||
int surfaces_allocated = 0;
|
||||
#endif
|
||||
|
||||
int SDL_InitSubSystem(Uint32 flags)
|
||||
{
|
||||
#ifndef DISABLE_VIDEO
|
||||
/* Initialize the video/event subsystem */
|
||||
if ( (flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO) ) {
|
||||
if ( SDL_VideoInit(getenv("SDL_VIDEODRIVER"),
|
||||
(flags&SDL_INIT_EVENTTHREAD)) < 0 ) {
|
||||
return(-1);
|
||||
}
|
||||
SDL_initialized |= SDL_INIT_VIDEO;
|
||||
}
|
||||
#else
|
||||
if ( flags & SDL_INIT_VIDEO ) {
|
||||
SDL_SetError("SDL not built with video support");
|
||||
return(-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_AUDIO
|
||||
/* Initialize the audio subsystem */
|
||||
if ( (flags & SDL_INIT_AUDIO) && !(SDL_initialized & SDL_INIT_AUDIO) ) {
|
||||
if ( SDL_AudioInit(getenv("SDL_AUDIODRIVER")) < 0 ) {
|
||||
return(-1);
|
||||
}
|
||||
SDL_initialized |= SDL_INIT_AUDIO;
|
||||
}
|
||||
#else
|
||||
if ( flags & SDL_INIT_AUDIO ) {
|
||||
SDL_SetError("SDL not built with audio support");
|
||||
return(-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_TIMERS
|
||||
/* Initialize the timer subsystem */
|
||||
if ( ! ticks_started ) {
|
||||
SDL_StartTicks();
|
||||
ticks_started = 1;
|
||||
}
|
||||
if ( (flags & SDL_INIT_TIMER) && !(SDL_initialized & SDL_INIT_TIMER) ) {
|
||||
if ( SDL_TimerInit() < 0 ) {
|
||||
return(-1);
|
||||
}
|
||||
SDL_initialized |= SDL_INIT_TIMER;
|
||||
}
|
||||
#else
|
||||
if ( flags & SDL_INIT_TIMER ) {
|
||||
SDL_SetError("SDL not built with timer support");
|
||||
return(-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_JOYSTICK
|
||||
/* Initialize the joystick subsystem */
|
||||
if ( (flags & SDL_INIT_JOYSTICK) &&
|
||||
!(SDL_initialized & SDL_INIT_JOYSTICK) ) {
|
||||
if ( SDL_JoystickInit() < 0 ) {
|
||||
return(-1);
|
||||
}
|
||||
SDL_initialized |= SDL_INIT_JOYSTICK;
|
||||
}
|
||||
#else
|
||||
if ( flags & SDL_INIT_JOYSTICK ) {
|
||||
SDL_SetError("SDL not built with joystick support");
|
||||
return(-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_CDROM
|
||||
/* Initialize the CD-ROM subsystem */
|
||||
if ( (flags & SDL_INIT_CDROM) && !(SDL_initialized & SDL_INIT_CDROM) ) {
|
||||
if ( SDL_CDROMInit() < 0 ) {
|
||||
return(-1);
|
||||
}
|
||||
SDL_initialized |= SDL_INIT_CDROM;
|
||||
}
|
||||
#else
|
||||
if ( flags & SDL_INIT_CDROM ) {
|
||||
SDL_SetError("SDL not built with cdrom support");
|
||||
return(-1);
|
||||
}
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
|
||||
int SDL_Init(Uint32 flags)
|
||||
{
|
||||
/* Clear the error message */
|
||||
SDL_ClearError();
|
||||
|
||||
/* Initialize the desired subsystems */
|
||||
if ( SDL_InitSubSystem(flags) < 0 ) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Everything is initialized */
|
||||
if ( !(flags & SDL_INIT_NOPARACHUTE) ) {
|
||||
SDL_InstallParachute();
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
void SDL_QuitSubSystem(Uint32 flags)
|
||||
{
|
||||
/* Shut down requested initialized subsystems */
|
||||
#ifndef DISABLE_CDROM
|
||||
if ( (flags & SDL_initialized & SDL_INIT_CDROM) ) {
|
||||
SDL_CDROMQuit();
|
||||
SDL_initialized &= ~SDL_INIT_CDROM;
|
||||
}
|
||||
#endif
|
||||
#ifndef DISABLE_JOYSTICK
|
||||
if ( (flags & SDL_initialized & SDL_INIT_JOYSTICK) ) {
|
||||
SDL_JoystickQuit();
|
||||
SDL_initialized &= ~SDL_INIT_JOYSTICK;
|
||||
}
|
||||
#endif
|
||||
#ifndef DISABLE_TIMERS
|
||||
if ( (flags & SDL_initialized & SDL_INIT_TIMER) ) {
|
||||
SDL_TimerQuit();
|
||||
SDL_initialized &= ~SDL_INIT_TIMER;
|
||||
}
|
||||
#endif
|
||||
#ifndef DISABLE_AUDIO
|
||||
if ( (flags & SDL_initialized & SDL_INIT_AUDIO) ) {
|
||||
SDL_AudioQuit();
|
||||
SDL_initialized &= ~SDL_INIT_AUDIO;
|
||||
}
|
||||
#endif
|
||||
#ifndef DISABLE_VIDEO
|
||||
if ( (flags & SDL_initialized & SDL_INIT_VIDEO) ) {
|
||||
SDL_VideoQuit();
|
||||
SDL_initialized &= ~SDL_INIT_VIDEO;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Uint32 SDL_WasInit(Uint32 flags)
|
||||
{
|
||||
if ( ! flags ) {
|
||||
flags = SDL_INIT_EVERYTHING;
|
||||
}
|
||||
return (SDL_initialized&flags);
|
||||
}
|
||||
|
||||
void SDL_Quit(void)
|
||||
{
|
||||
/* Quit all subsystems */
|
||||
SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
|
||||
|
||||
#ifdef CHECK_LEAKS
|
||||
/* Print the number of surfaces not freed */
|
||||
if ( surfaces_allocated != 0 ) {
|
||||
SDL_printf("SDL Warning: %d SDL surfaces extant\n",
|
||||
surfaces_allocated);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Uninstall any parachute signal handlers */
|
||||
SDL_UninstallParachute();
|
||||
}
|
||||
|
||||
/* Return the library version number */
|
||||
const SDL_version * SDL_Linked_Version(void)
|
||||
{
|
||||
return(&version);
|
||||
}
|
352
contrib/sdk/sources/SDL-1.2.2_newlib/src/SDL_error.c
Executable file
352
contrib/sdk/sources/SDL-1.2.2_newlib/src/SDL_error.c
Executable file
@@ -0,0 +1,352 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
|
||||
#ifdef SAVE_RCSID
|
||||
static char rcsid =
|
||||
"@(#) $Id: SDL_error.c,v 1.2 2001/04/26 16:50:17 hercules Exp $";
|
||||
#endif
|
||||
|
||||
/* Simple error handling in SDL */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "SDL_types.h"
|
||||
#include "SDL_getenv.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_error_c.h"
|
||||
#ifndef DISABLE_THREADS
|
||||
#include "SDL_thread_c.h"
|
||||
#endif
|
||||
|
||||
#ifdef DISABLE_THREADS
|
||||
/* The default (non-thread-safe) global error variable */
|
||||
static SDL_error SDL_global_error;
|
||||
|
||||
#define SDL_GetErrBuf() (&SDL_global_error)
|
||||
#endif /* DISABLE_THREADS */
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
#define DISABLE_STDIO
|
||||
#endif
|
||||
|
||||
#define SDL_ERRBUFIZE 1024
|
||||
|
||||
/* Private functions */
|
||||
|
||||
static int vdprintf_help(unsigned c)
|
||||
{
|
||||
int d0;
|
||||
if(c=='\n')
|
||||
{
|
||||
c='\r';
|
||||
__asm__ __volatile__("int $0x40":"=&a"(d0):"0"(63),"b"(1),"c"(c));
|
||||
c='\n';
|
||||
__asm__ __volatile__("int $0x40":"=&a"(d0):"0"(63),"b"(1),"c"(c));
|
||||
return 0;
|
||||
}
|
||||
__asm__ __volatile__("int $0x40":"=&a"(d0):"0"(63),"b"(1),"c"(c));
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
static void xputs(char * p)
|
||||
{
|
||||
for(;*p;p++) vdprintf_help((*p)&0xff);
|
||||
}
|
||||
|
||||
static char dbg_buf[1024];
|
||||
|
||||
void SDL_printf(const char * fmt,...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap,fmt);
|
||||
vsprintf(dbg_buf,fmt,ap);
|
||||
va_end(ap);
|
||||
xputs(dbg_buf);
|
||||
}
|
||||
|
||||
static void SDL_LookupString(const Uint8 *key, Uint16 *buf, int buflen)
|
||||
{
|
||||
/* FIXME: Add code to lookup key in language string hash-table */
|
||||
|
||||
/* Key not found in language string hash-table */
|
||||
while ( *key && (--buflen > 0) ) {
|
||||
*buf++ = *key++;
|
||||
}
|
||||
*buf = 0; /* NULL terminate string */
|
||||
}
|
||||
|
||||
/* Public functions */
|
||||
|
||||
void SDL_SetError (const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
SDL_error *error;
|
||||
|
||||
/* Copy in the key, mark error as valid */
|
||||
error = SDL_GetErrBuf();
|
||||
error->error = 1;
|
||||
strncpy((char *)error->key, fmt, sizeof(error->key));
|
||||
error->key[sizeof(error->key)-1] = '\0';
|
||||
|
||||
va_start(ap, fmt);
|
||||
error->argc = 0;
|
||||
while ( *fmt ) {
|
||||
if ( *fmt++ == '%' ) {
|
||||
switch (*fmt++) {
|
||||
case 0: /* Malformed format string.. */
|
||||
--fmt;
|
||||
break;
|
||||
#if 0 /* What is a character anyway? (UNICODE issues) */
|
||||
case 'c':
|
||||
error->args[error->argc++].value_c =
|
||||
va_arg(ap, unsigned char);
|
||||
break;
|
||||
#endif
|
||||
case 'd':
|
||||
error->args[error->argc++].value_i =
|
||||
va_arg(ap, int);
|
||||
break;
|
||||
case 'f':
|
||||
error->args[error->argc++].value_f =
|
||||
va_arg(ap, double);
|
||||
break;
|
||||
case 'p':
|
||||
error->args[error->argc++].value_ptr =
|
||||
va_arg(ap, void *);
|
||||
break;
|
||||
case 's':
|
||||
{
|
||||
int index = error->argc;
|
||||
strncpy((char *)error->args[index].buf,
|
||||
va_arg(ap, char *), ERR_MAX_STRLEN);
|
||||
error->args[index].buf[ERR_MAX_STRLEN-1] = 0;
|
||||
error->argc++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ( error->argc >= ERR_MAX_ARGS ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
SDL_printf("SDL_SetError: %s\n", SDL_GetError());
|
||||
}
|
||||
|
||||
/* Print out an integer value to a UNICODE buffer */
|
||||
static int PrintInt(Uint16 *str, unsigned int maxlen, int value)
|
||||
{
|
||||
char tmp[128];
|
||||
int len, i;
|
||||
|
||||
sprintf(tmp, "%d", value);
|
||||
len = 0;
|
||||
if ( strlen(tmp) < maxlen ) {
|
||||
for ( i=0; tmp[i]; ++i ) {
|
||||
*str++ = tmp[i];
|
||||
++len;
|
||||
}
|
||||
}
|
||||
return(len);
|
||||
}
|
||||
/* Print out a double value to a UNICODE buffer */
|
||||
static int PrintDouble(Uint16 *str, unsigned int maxlen, double value)
|
||||
{
|
||||
char tmp[128];
|
||||
int len, i;
|
||||
|
||||
sprintf(tmp, "%f", value);
|
||||
len = 0;
|
||||
if ( strlen(tmp) < maxlen ) {
|
||||
for ( i=0; tmp[i]; ++i ) {
|
||||
*str++ = tmp[i];
|
||||
++len;
|
||||
}
|
||||
}
|
||||
return(len);
|
||||
}
|
||||
/* Print out a pointer value to a UNICODE buffer */
|
||||
static int PrintPointer(Uint16 *str, unsigned int maxlen, void *value)
|
||||
{
|
||||
char tmp[128];
|
||||
int len, i;
|
||||
|
||||
sprintf(tmp, "%p", value);
|
||||
len = 0;
|
||||
if ( strlen(tmp) < maxlen ) {
|
||||
for ( i=0; tmp[i]; ++i ) {
|
||||
*str++ = tmp[i];
|
||||
++len;
|
||||
}
|
||||
}
|
||||
return(len);
|
||||
}
|
||||
|
||||
/* This function has a bit more overhead than most error functions
|
||||
so that it supports internationalization and thread-safe errors.
|
||||
*/
|
||||
Uint16 *SDL_GetErrorMsgUNICODE(Uint16 *errstr, unsigned int maxlen)
|
||||
{
|
||||
SDL_error *error;
|
||||
|
||||
/* Clear the error string */
|
||||
*errstr = 0; --maxlen;
|
||||
|
||||
/* Get the thread-safe error, and print it out */
|
||||
error = SDL_GetErrBuf();
|
||||
if ( error->error ) {
|
||||
Uint16 translated[ERR_MAX_STRLEN], *fmt, *msg;
|
||||
int len;
|
||||
int argi;
|
||||
|
||||
/* Print out the UNICODE error message */
|
||||
SDL_LookupString(error->key, translated, sizeof(translated));
|
||||
msg = errstr;
|
||||
argi = 0;
|
||||
for ( fmt=translated; *fmt && (maxlen > 0); ) {
|
||||
if ( *fmt == '%' ) {
|
||||
switch (fmt[1]) {
|
||||
case 'S': /* Special SKIP operand */
|
||||
argi += (fmt[2] - '0');
|
||||
++fmt;
|
||||
break;
|
||||
case '%':
|
||||
*msg++ = '%';
|
||||
maxlen -= 1;
|
||||
break;
|
||||
#if 0 /* What is a character anyway? (UNICODE issues) */
|
||||
case 'c':
|
||||
*msg++ = (unsigned char)
|
||||
error->args[argi++].value_c;
|
||||
maxlen -= 1;
|
||||
break;
|
||||
#endif
|
||||
case 'd':
|
||||
len = PrintInt(msg, maxlen,
|
||||
error->args[argi++].value_i);
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
break;
|
||||
case 'f':
|
||||
len = PrintDouble(msg, maxlen,
|
||||
error->args[argi++].value_f);
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
break;
|
||||
case 'p':
|
||||
len = PrintPointer(msg, maxlen,
|
||||
error->args[argi++].value_ptr);
|
||||
msg += len;
|
||||
maxlen -= len;
|
||||
break;
|
||||
case 's': /* UNICODE string */
|
||||
{ Uint16 buf[ERR_MAX_STRLEN], *str;
|
||||
SDL_LookupString(error->args[argi++].buf, buf, sizeof(buf));
|
||||
str = buf;
|
||||
while ( *str && (maxlen > 0) ) {
|
||||
*msg++ = *str++;
|
||||
maxlen -= 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
fmt += 2;
|
||||
} else {
|
||||
*msg++ = *fmt++;
|
||||
maxlen -= 1;
|
||||
}
|
||||
}
|
||||
*msg = 0; /* NULL terminate the string */
|
||||
}
|
||||
return(errstr);
|
||||
}
|
||||
|
||||
Uint8 *SDL_GetErrorMsg(Uint8 *errstr, unsigned int maxlen)
|
||||
{
|
||||
Uint16 *errstr16;
|
||||
unsigned int i;
|
||||
|
||||
/* Allocate the UNICODE buffer */
|
||||
errstr16 = (Uint16 *)malloc(maxlen * (sizeof *errstr16));
|
||||
if ( ! errstr16 ) {
|
||||
strncpy((char *)errstr, "Out of memory", maxlen);
|
||||
errstr[maxlen-1] = '\0';
|
||||
return(errstr);
|
||||
}
|
||||
|
||||
/* Get the error message */
|
||||
SDL_GetErrorMsgUNICODE(errstr16, maxlen);
|
||||
|
||||
/* Convert from UNICODE to Latin1 encoding */
|
||||
for ( i=0; i<maxlen; ++i ) {
|
||||
errstr[i] = (Uint8)errstr16[i];
|
||||
}
|
||||
|
||||
/* Free UNICODE buffer (if necessary) */
|
||||
free(errstr16);
|
||||
|
||||
return(errstr);
|
||||
}
|
||||
|
||||
/* Available for backwards compatibility */
|
||||
char *SDL_GetError (void)
|
||||
{
|
||||
static char errmsg[SDL_ERRBUFIZE];
|
||||
|
||||
return((char *)SDL_GetErrorMsg((unsigned char *)errmsg, SDL_ERRBUFIZE));
|
||||
}
|
||||
|
||||
void SDL_ClearError(void)
|
||||
{
|
||||
SDL_error *error;
|
||||
|
||||
error = SDL_GetErrBuf();
|
||||
error->error = 0;
|
||||
}
|
||||
|
||||
/* Very common errors go here */
|
||||
void SDL_Error(SDL_errorcode code)
|
||||
{
|
||||
switch (code) {
|
||||
case SDL_ENOMEM:
|
||||
SDL_SetError("Out of memory");
|
||||
break;
|
||||
case SDL_EFREAD:
|
||||
SDL_SetError("Error reading from datastream");
|
||||
break;
|
||||
case SDL_EFWRITE:
|
||||
SDL_SetError("Error writing to datastream");
|
||||
break;
|
||||
case SDL_EFSEEK:
|
||||
SDL_SetError("Error seeking in datastream");
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unknown SDL error");
|
||||
break;
|
||||
}
|
||||
}
|
62
contrib/sdk/sources/SDL-1.2.2_newlib/src/SDL_error_c.h
Executable file
62
contrib/sdk/sources/SDL-1.2.2_newlib/src/SDL_error_c.h
Executable file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
|
||||
#ifdef SAVE_RCSID
|
||||
static char rcsid =
|
||||
"@(#) $Id: SDL_error_c.h,v 1.2 2001/04/26 16:50:17 hercules Exp $";
|
||||
#endif
|
||||
|
||||
/* This file defines a structure that carries language-independent
|
||||
error messages
|
||||
*/
|
||||
|
||||
#ifndef _SDL_error_c_h
|
||||
#define _SDL_error_c_h
|
||||
|
||||
#define ERR_MAX_STRLEN 128
|
||||
#define ERR_MAX_ARGS 5
|
||||
|
||||
typedef struct {
|
||||
/* This is a numeric value corresponding to the current error */
|
||||
int error;
|
||||
|
||||
/* This is a key used to index into a language hashtable containing
|
||||
internationalized versions of the SDL error messages. If the key
|
||||
is not in the hashtable, or no hashtable is available, the key is
|
||||
used directly as an error message format string.
|
||||
*/
|
||||
unsigned char key[ERR_MAX_STRLEN];
|
||||
|
||||
/* These are the arguments for the error functions */
|
||||
int argc;
|
||||
union {
|
||||
void *value_ptr;
|
||||
#if 0 /* What is a character anyway? (UNICODE issues) */
|
||||
unsigned char value_c;
|
||||
#endif
|
||||
int value_i;
|
||||
double value_f;
|
||||
unsigned char buf[ERR_MAX_STRLEN];
|
||||
} args[ERR_MAX_ARGS];
|
||||
} SDL_error;
|
||||
|
||||
#endif /* _SDL_error_c_h */
|
46
contrib/sdk/sources/SDL-1.2.2_newlib/src/SDL_fatal.c
Executable file
46
contrib/sdk/sources/SDL-1.2.2_newlib/src/SDL_fatal.c
Executable file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
void SDL_printf_error(const char * fmt,...)
|
||||
{
|
||||
int pid;
|
||||
va_list args;
|
||||
va_start(args,fmt);
|
||||
vprintf(fmt,args);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
void SDL_InstallParachute(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void SDL_UninstallParachute(void)
|
||||
{
|
||||
return;
|
||||
}
|
32
contrib/sdk/sources/SDL-1.2.2_newlib/src/SDL_fatal.h
Executable file
32
contrib/sdk/sources/SDL-1.2.2_newlib/src/SDL_fatal.h
Executable file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@devolution.com
|
||||
*/
|
||||
|
||||
#ifdef SAVE_RCSID
|
||||
static char rcsid =
|
||||
"@(#) $Id: SDL_fatal.h,v 1.2 2001/04/26 16:50:17 hercules Exp $";
|
||||
#endif
|
||||
|
||||
/* General fatal signal handling code for SDL */
|
||||
|
||||
extern void SDL_InstallParachute(void);
|
||||
extern void SDL_UninstallParachute(void);
|
||||
|
171
contrib/sdk/sources/SDL-1.2.2_newlib/src/SDL_getenv.c
Executable file
171
contrib/sdk/sources/SDL-1.2.2_newlib/src/SDL_getenv.c
Executable file
@@ -0,0 +1,171 @@
|
||||
|
||||
/* Not all environments have a working getenv()/putenv() */
|
||||
|
||||
#ifdef TEST_MAIN
|
||||
#define NEED_SDL_GETENV
|
||||
#endif
|
||||
|
||||
#include "SDL_getenv.h"
|
||||
|
||||
#ifdef NEED_SDL_GETENV
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static char **SDL_env = (char **)0;
|
||||
|
||||
/* Put a variable of the form "name=value" into the environment */
|
||||
int SDL_putenv(const char *variable)
|
||||
{
|
||||
const char *name, *value;
|
||||
int added;
|
||||
int len, i;
|
||||
char **new_env;
|
||||
char *new_variable;
|
||||
|
||||
/* A little error checking */
|
||||
if ( ! variable ) {
|
||||
return(-1);
|
||||
}
|
||||
name = variable;
|
||||
for ( value=variable; *value && (*value != '='); ++value ) {
|
||||
/* Keep looking for '=' */ ;
|
||||
}
|
||||
if ( *value ) {
|
||||
++value;
|
||||
} else {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Allocate memory for the variable */
|
||||
new_variable = (char *)malloc(strlen(variable)+1);
|
||||
if ( ! new_variable ) {
|
||||
return(-1);
|
||||
}
|
||||
strcpy(new_variable, variable);
|
||||
|
||||
/* Actually put it into the environment */
|
||||
added = 0;
|
||||
i = 0;
|
||||
if ( SDL_env ) {
|
||||
/* Check to see if it's already there... */
|
||||
len = (value - name);
|
||||
for ( ; SDL_env[i]; ++i ) {
|
||||
if ( strncmp(SDL_env[i], name, len) == 0 ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* If we found it, just replace the entry */
|
||||
if ( SDL_env[i] ) {
|
||||
free(SDL_env[i]);
|
||||
SDL_env[i] = new_variable;
|
||||
added = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Didn't find it in the environment, expand and add */
|
||||
if ( ! added ) {
|
||||
new_env = realloc(SDL_env, (i+2)*sizeof(char *));
|
||||
if ( new_env ) {
|
||||
SDL_env = new_env;
|
||||
SDL_env[i++] = new_variable;
|
||||
SDL_env[i++] = (char *)0;
|
||||
added = 1;
|
||||
} else {
|
||||
free(new_variable);
|
||||
}
|
||||
}
|
||||
return (added ? 0 : -1);
|
||||
}
|
||||
|
||||
/* Retrieve a variable named "name" from the environment */
|
||||
char *SDL_getenv(const char *name)
|
||||
{
|
||||
int len, i;
|
||||
char *value;
|
||||
|
||||
value = (char *)0;
|
||||
if ( SDL_env ) {
|
||||
len = strlen(name);
|
||||
for ( i=0; SDL_env[i] && !value; ++i ) {
|
||||
if ( (strncmp(SDL_env[i], name, len) == 0) &&
|
||||
(SDL_env[i][len] == '=') ) {
|
||||
value = &SDL_env[i][len+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
#endif /* NEED_GETENV */
|
||||
|
||||
#ifdef TEST_MAIN
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *value;
|
||||
|
||||
printf("Checking for non-existent variable... ");
|
||||
fflush(stdout);
|
||||
if ( ! getenv("EXISTS") ) {
|
||||
printf("okay\n");
|
||||
} else {
|
||||
printf("failed\n");
|
||||
}
|
||||
printf("Setting FIRST=VALUE1 in the environment... ");
|
||||
fflush(stdout);
|
||||
if ( putenv("FIRST=VALUE1") == 0 ) {
|
||||
printf("okay\n");
|
||||
} else {
|
||||
printf("failed\n");
|
||||
}
|
||||
printf("Getting FIRST from the environment... ");
|
||||
fflush(stdout);
|
||||
value = getenv("FIRST");
|
||||
if ( value && (strcmp(value, "VALUE1") == 0) ) {
|
||||
printf("okay\n");
|
||||
} else {
|
||||
printf("failed\n");
|
||||
}
|
||||
printf("Setting SECOND=VALUE2 in the environment... ");
|
||||
fflush(stdout);
|
||||
if ( putenv("SECOND=VALUE2") == 0 ) {
|
||||
printf("okay\n");
|
||||
} else {
|
||||
printf("failed\n");
|
||||
}
|
||||
printf("Getting SECOND from the environment... ");
|
||||
fflush(stdout);
|
||||
value = getenv("SECOND");
|
||||
if ( value && (strcmp(value, "VALUE2") == 0) ) {
|
||||
printf("okay\n");
|
||||
} else {
|
||||
printf("failed\n");
|
||||
}
|
||||
printf("Setting FIRST=NOVALUE in the environment... ");
|
||||
fflush(stdout);
|
||||
if ( putenv("FIRST=NOVALUE") == 0 ) {
|
||||
printf("okay\n");
|
||||
} else {
|
||||
printf("failed\n");
|
||||
}
|
||||
printf("Getting FIRST from the environment... ");
|
||||
fflush(stdout);
|
||||
value = getenv("FIRST");
|
||||
if ( value && (strcmp(value, "NOVALUE") == 0) ) {
|
||||
printf("okay\n");
|
||||
} else {
|
||||
printf("failed\n");
|
||||
}
|
||||
printf("Checking for non-existent variable... ");
|
||||
fflush(stdout);
|
||||
if ( ! getenv("EXISTS") ) {
|
||||
printf("okay\n");
|
||||
} else {
|
||||
printf("failed\n");
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
#endif /* TEST_MAIN */
|
||||
|
5
contrib/sdk/sources/SDL-1.2.2_newlib/src/compile.sh
Executable file
5
contrib/sdk/sources/SDL-1.2.2_newlib/src/compile.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
cd SYSCALL/src
|
||||
make
|
||||
cd ../..
|
||||
make install
|
||||
make clean
|
Reference in New Issue
Block a user