From ce4f3efd78c110c015c54eab05f201d1caac5f8d Mon Sep 17 00:00:00 2001 From: Guenter Bartsch Date: Sun, 20 Apr 2003 16:42:06 +0000 Subject: importing win32 contrib sources and msvc build environment CVS patchset: 4641 CVS date: 2003/04/20 16:42:06 --- win32/include/common.h | 244 ++++++ win32/include/config.h | 496 ++++++++++++ win32/include/dirent.h | 32 + win32/include/dlfcn.h | 33 + win32/include/inttypes.h | 59 ++ win32/include/pthread.h | 1077 ++++++++++++++++++++++++++ win32/include/pwd.h | 0 win32/include/sched.h | 89 +++ win32/include/semaphore.h | 101 +++ win32/include/sys/time.h | 28 + win32/include/timer.h | 39 + win32/include/unistd.h | 58 ++ win32/include/xine/attributes.h | 44 ++ win32/include/xine/compat.h | 58 ++ win32/include/xine/xine.h | 1580 +++++++++++++++++++++++++++++++++++++++ win32/include/xine/xineutils.h | 957 ++++++++++++++++++++++++ win32/include/zconf.h | 279 +++++++ win32/include/zlib.h | 893 ++++++++++++++++++++++ 18 files changed, 6067 insertions(+) create mode 100644 win32/include/common.h create mode 100644 win32/include/config.h create mode 100644 win32/include/dirent.h create mode 100644 win32/include/dlfcn.h create mode 100644 win32/include/inttypes.h create mode 100644 win32/include/pthread.h create mode 100644 win32/include/pwd.h create mode 100644 win32/include/sched.h create mode 100644 win32/include/semaphore.h create mode 100644 win32/include/sys/time.h create mode 100644 win32/include/timer.h create mode 100644 win32/include/unistd.h create mode 100644 win32/include/xine/attributes.h create mode 100644 win32/include/xine/compat.h create mode 100644 win32/include/xine/xine.h create mode 100644 win32/include/xine/xineutils.h create mode 100644 win32/include/zconf.h create mode 100644 win32/include/zlib.h (limited to 'win32/include') diff --git a/win32/include/common.h b/win32/include/common.h new file mode 100644 index 000000000..bc9406c69 --- /dev/null +++ b/win32/include/common.h @@ -0,0 +1,244 @@ +/* + * Copyright (C) 2000-2003 the xine project + * + * This file is part of xine, a unix video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: common.h,v 1.1 2003/04/20 16:42:09 guenter Exp $ + * + */ + +#ifndef __COMMON_H__ +#define __COMMON_H__ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#if (0) +#include "Imlib-light/Imlib.h" + +#include "xitk.h" + +#include "kbindings.h" +#include "videowin.h" +#include "mediamark.h" +#include "actions.h" +#include "config_wrapper.h" +#include "control.h" +#include "errors.h" +#include "event.h" +#include "event_sender.h" +#include "i18n.h" +#include "lang.h" +#include "lirc.h" +#include "mrl_browser.h" +#include "network.h" +#include "panel.h" +#include "playlist.h" +#include "session.h" +#include "setup.h" +#include "skins.h" +#include "snapshot.h" +#include "stream_infos.h" +#include "viewlog.h" +#include "download.h" +#include "osd.h" +#include "file_browser.h" +#include "post.h" + +#include "utils.h" +#endif + +#ifdef HAVE_ORBIT +#include "../corba/xine-server.h" +#endif + +#ifdef HAVE_LIRC +#include +#endif + +/* + * config related constants + */ +#define CONFIG_LEVEL_BEG 0 /* => beginner */ +#define CONFIG_LEVEL_ADV 10 /* advanced user */ +#define CONFIG_LEVEL_EXP 20 /* expert */ +#define CONFIG_LEVEL_MAS 30 /* motku */ +#define CONFIG_LEVEL_DEB 40 /* debugger (only available in debug mode) */ + +#define CONFIG_NO_DESC NULL +#define CONFIG_NO_HELP NULL +#define CONFIG_NO_CB NULL +#define CONFIG_NO_DATA NULL + +/* + * flags for autoplay options + */ +#define PLAY_ON_START 0x00000001 +#define PLAYED_ON_START 0x00000002 +#define QUIT_ON_STOP 0x00000004 +#define FULL_ON_START 0x00000008 +#define HIDEGUI_ON_START 0x00000010 +#define PLAY_FROM_DVD 0x00000020 +#define PLAY_FROM_VCD 0x00000040 + +/* Sound mixer capabilities */ +#define MIXER_CAP_NOTHING 0x00000000 +#define MIXER_CAP_VOL 0x00000001 +#define MIXER_CAP_MUTE 0x00000002 + +/* Playlist loop modes */ +#define PLAYLIST_LOOP_NO_LOOP 0 /* no loop (default) */ +#define PLAYLIST_LOOP_LOOP 1 /* loop the whole playlist */ +#define PLAYLIST_LOOP_REPEAT 2 /* loop the current mrl */ +#define PLAYLIST_LOOP_SHUFFLE 3 /* random selection in playlist */ +#define PLAYLIST_LOOP_SHUF_PLUS 4 /* random selection in playlist, never ending */ +#define PLAYLIST_LOOP_MODES_NUM 5 + +#define SAFE_FREE(x) do { \ + if((x)) { \ + free((x)); \ + x = NULL; \ + } \ + } while(0) + +/* Our default location for skin downloads */ +#define SKIN_SERVER_URL "http://xine.sourceforge.net/skins/skins.slx" + +typedef struct { + xine_video_port_t *vo_port; + int post_video_num; + xine_post_t *post_video; + + struct { + int hue; + int brightness; + int saturation; + int contrast; + } video_settings; + + xine_audio_port_t *ao_port; + + xine_stream_t *stream; + xine_stream_t *spu_stream; + + xine_t *xine; + + xine_event_queue_t *event_queue; + + int smart_mode; + + /* Visual stuff (like animation in video window while audio only playback) */ + struct { + xine_stream_t *stream; + xine_event_queue_t *event_queue; + int running; + int current; + int enabled; /* 0, 1:vpost, 2:vanim */ + + char **mrls; + int num_mrls; + + int post_plugin_num; + xine_post_t *post_output; + int post_changed; + + } visual_anim; + + struct { + int enabled; + int timeout; + + xine_osd_t *sinfo; + int sinfo_visible; + + xine_osd_t *bar[2]; + int bar_visible; + + xine_osd_t *status; + int status_visible; + + xine_osd_t *info; + int info_visible; + + } osd; + + /* xine lib/gui configuration filename */ + char *configfile; + int experience_level; + + const char *logo_mrl; + int logo_mode; + int logo_has_changed; + + /* stuff like FULL_ON_START, QUIT_ON_STOP */ + /*action_id_t actions_on_start[16];*/ + char *autoscan_plugin; + + + uint32_t debug_level; + + int is_display_mrl; + + int mrl_overrided; + + int running; + int ignore_next; + +#ifdef HAVE_LIRC + int lirc_enable; +#endif + +#ifdef HAVE_XF86VIDMODE + int XF86VidMode_fullscreen; +#endif + + struct { + int caps; /* MIXER_CAP_x */ + int volume_level; + int mute; + } mixer; + + int layer_above; + int always_layer_above; + + int network; + + int use_root_window; + + const char *snapshot_location; + + int ssaver_timeout; + + int skip_by_chapter; + + int auto_vo_visibility; + int auto_panel_visibility; + + int eventer_sticky; + int stream_info_auto_update; + + int play_anyway; + + pthread_mutex_t download_mutex; + +} gGui_t; + +#endif diff --git a/win32/include/config.h b/win32/include/config.h new file mode 100644 index 000000000..0c4654f4f --- /dev/null +++ b/win32/include/config.h @@ -0,0 +1,496 @@ +/* config.h. Generated by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + + +#ifndef _CONFIG_H_ +#define _CONFIG_H_ + +#if defined(WIN32) +#include +#include +#include +#endif + +/* Define this if you're running PowerPC architecture */ +/* #undef ARCH_PPC */ + +/* Define this if you're running x86 architecture */ +/*define ARCH_X86*/ + +/* maximum supported data alignment */ +#define ATTRIBUTE_ALIGNED_MAX 64 + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +/* #undef CRAY_STACKSEG_END */ + +/* Define to 1 if using `alloca.c'. */ +/* #undef C_ALLOCA */ + +/* Define this if you have a Motorola 74xx CPU */ +/* #undef ENABLE_ALTIVEC */ + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +#undef ENABLE_NLS + +/* Define this if you have Sun UltraSPARC CPU */ +/* #undef ENABLE_VIS */ + +/* Define to select libmad fixed pointarithmetic implementation */ +/* #undef FPM_64BIT */ + +/* Define to select libmad fixed point arithmetic implementation */ +/* #undef FPM_ARM */ + +/* Define to select libmad fixed point arithmetic implementation */ +/* #undef FPM_DEFAULT */ + +/* Define to select libmad fixed point arithmetic implementation */ +#define FPM_INTEL 1 + +/* Define to select libmad fixed point arithmetic implementation */ +/* #undef FPM_MIPS */ + +/* Define to select libmad fixed point arithmetic implementation */ +/* #undef FPM_PPC */ + +/* Define to select libmad fixed point arithmetic implementation */ +/* #undef FPM_SPARC */ + +/* Define to 1 if you have `alloca', as a function or macro. */ +#define HAVE_ALLOCA 1 + +/* Define to 1 if you have and it should be used (not on Ultrix). + */ +#define HAVE_ALLOCA_H 1 + +/* Define this if you have Alsa (libasound) installed */ +/* #undef HAVE_ALSA */ + +/* Define this if you have alsa 0.9.x and more installed */ +/* #undef HAVE_ALSA09 */ + +/* Define this if your asoundlib.h is installed in alsa/ */ +/* #undef HAVE_ALSA_ASOUNDLIB_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ARGZ_H */ + +/* Define this if you have ARTS (libartsc) installed */ +/* #undef HAVE_ARTS */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BYTESWAP_H */ + +/* Define this if you have CDROM ioctls */ +/* #undef HAVE_CDROM_IOCTLS */ + +/* Define to 1 if you have the `dcgettext' function. */ +#define HAVE_DCGETTEXT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define this if you have a suitable version of libdvdnav */ +#define HAVE_DVDNAV 1 + +/* Define this if you have ESD (libesd) installed */ +/* #undef HAVE_ESD */ + +/* Define this if you have linux framebuffer support */ +/* #undef HAVE_FB */ + +/* Define to 1 if you have the `feof_unlocked' function. */ +/* #undef HAVE_FEOF_UNLOCKED */ + +/* Define to 1 if you have the `fgets_unlocked' function. */ +/* #undef HAVE_FGETS_UNLOCKED */ + +/* Define to 1 if you have the `getcwd' function. */ +#define HAVE_GETCWD 1 + +/* Define to 1 if you have the `getegid' function. */ +#define HAVE_GETEGID 1 + +/* Define to 1 if you have the `geteuid' function. */ +#define HAVE_GETEUID 1 + +/* Define to 1 if you have the `getgid' function. */ +#define HAVE_GETGID 1 + +/* Define to 1 if you have the `getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpwuid_r' function. */ +#define HAVE_GETPWUID_R 1 + +/* Define if the GNU gettext() function is already present or preinstalled. */ +#define HAVE_GETTEXT 1 + +/* Define to 1 if you have the `getuid' function. */ +#define HAVE_GETUID 1 + +/* Define this if you have GLU support available */ +/* #undef HAVE_GLU */ + +/* Define this if you have GLut support available */ +/* #undef HAVE_GLUT */ + +/* Define this if you have gnome-vfs installed */ +/* #undef HAVE_GNOME_VFS */ + +/* Define if you have the iconv() function. */ +/* #undef HAVE_ICONV */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_INTTYPES_H */ + +/* Define this if you have ip_mreqn in netinet/in.h */ +/* #undef HAVE_IP_MREQN */ + +/* Define this if you have a usable IRIX al interface available */ +/* #undef HAVE_IRIXAL */ + +/* Define this if you have kernel statistics available via kstat interface */ +/* #undef HAVE_KSTAT */ + +/* Define if you have and nl_langinfo(CODESET). */ +/* #undef HAVE_LANGINFO_CODESET */ + +/* Define if your file defines LC_MESSAGES. */ +#define HAVE_LC_MESSAGES 1 + +/* Define this if you have libfame mpeg encoder installed (fame.sf.net) */ +/* #undef HAVE_LIBFAME */ + +/* Define to 1 if you have the `posix4' library (-lposix4). */ +/* #undef HAVE_LIBPOSIX4 */ + +/* Define this if you have librte mpeg encoder installed (zapping.sf.net) */ +/* #undef HAVE_LIBRTE */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CDROM_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LOCALE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MALLOC_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mempcpy' function. */ +/* #undef HAVE_MEMPCPY */ + +/* Define this if you have mlib installed */ +/* #undef HAVE_MLIB */ + +/* Define to 1 if you have a working `mmap' system call. */ +/* #undef HAVE_MMAP */ + +/* Define to 1 if you have the `munmap' function. */ +#define HAVE_MUNMAP 1 + +/* Define to 1 if you have the `nanosleep' function. */ +/* #undef HAVE_NANOSLEEP */ + +/* Define this if you have libfame 0.8.10 or above */ +/* #undef HAVE_NEW_LIBFAME */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NL_TYPES_H */ + +/* Define this if you have OpenGL support available */ +/* #undef HAVE_OPENGL */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define this if you have SDL library installed */ +/* #undef HAVE_SDL */ + +/* Define to 1 if you have the `setenv' function. */ +#define HAVE_SETENV 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `sigset' function. */ +/* #undef HAVE_SIGSET */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDDEF_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STDINT_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `stpcpy' function. */ +/* #undef HAVE_STPCPY */ + +/* Define to 1 if you have the `strcasecmp' function. */ +#define HAVE_STRCASECMP 1 + +/* Define to 1 if you have the `strchr' function. */ +#define HAVE_STRCHR 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strpbrk' function. */ +#define HAVE_STRPBRK 1 + +/* Define to 1 if you have the `strsep' function. */ +#define HAVE_STRSEP 1 + +/* Define to 1 if you have the `strtoul' function. */ +#define HAVE_STRTOUL 1 + +/* Define this if your asoundlib.h is installed in sys/ */ +/* #undef HAVE_SYS_ASOUNDLIB_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_CDIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MIXER_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_MMAN_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_PARAM_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the `tsearch' function. */ +/* #undef HAVE_TSEARCH */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `vsscanf' function. */ +#define HAVE_VSSCANF 1 + +/* Define this if you have X11R6 installed */ +/* #undef HAVE_X11 */ + +/* Define this if you have libXinerama installed */ +/* #undef HAVE_XINERAMA */ + +/* Define this if you have libXv installed */ +/* #undef HAVE_XV */ + +/* Define this if you have libXv.a */ +/* #undef HAVE_XV_STATIC */ + +/* Define to 1 if you have the `__argz_count' function. */ +/* #undef HAVE___ARGZ_COUNT */ + +/* Define to 1 if you have the `__argz_next' function. */ +/* #undef HAVE___ARGZ_NEXT */ + +/* Define to 1 if you have the `__argz_stringify' function. */ +/* #undef HAVE___ARGZ_STRINGIFY */ + +/* Define as const if the declaration of iconv() needs const. */ +/* #undef ICONV_CONST */ + +/* Define this if you have mlib installed */ +/* #undef LIBA52_MLIB */ + +/* Define this if you have mlib installed */ +/* #undef LIBMPEG2_MLIB */ + +/* Name of package */ +#define PACKAGE "xine-lib" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +/* #undef STACK_DIRECTION */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "1-beta6" + +/* xine major version number */ +#define XINE_MAJOR 1 + +/* xine minor version number */ +#define XINE_MINOR 0 + +/* xine sub version number */ +#define XINE_SUB 0 + +/* Define to 1 if the X Window System is missing or not being used. */ +#define X_DISPLAY_MISSING 1 + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +/* #undef WORDS_BIGENDIAN */ + + +/* Define this if you want nvtvd tvmode support */ +/* #undef XINE_HAVE_NVTV */ + +#define HAVE_DVDCSS_DVDCSS_H 1 + +#if defined(WIN32) + +/* Ridiculous hack to return valid xine support + * directories. These should be read from + * a registry entry set at install time. + */ + +static char tmp_win32_path[ 1024 ]; +static char * exec_path_append_subdir( char * string ) +{ + char * tmpchar; + char * cmdline; + char * back_slash; + char * fore_slash; + char * last_slash; + + // get program exec command line + cmdline = GetCommandLine(); + + // check for " at beginning of string + if( *cmdline == '\"' ) + { + // copy command line, skip first quote + strcpy( tmp_win32_path, cmdline + 1 ); + + // terminate at second set of quotes + tmpchar = strchr( tmp_win32_path, '\"' ); + *tmpchar = 0; + } + else + { + // copy command line + strcpy( tmp_win32_path, cmdline ); + + // terminate at first space + tmpchar = strchr( tmp_win32_path, ' ' ); + *tmpchar = 0; + } + + // find the last occurance of a back + // slash or fore slash + back_slash = strrchr( tmp_win32_path, '\\' ); + fore_slash = strrchr( tmp_win32_path, '/' ); + + // make sure the last back slash was not + // after a drive letter + if( back_slash > tmp_win32_path ) + if( *( back_slash - 1 ) == ':' ) + back_slash = 0; + + // which slash was the latter slash + if( back_slash > fore_slash ) + last_slash = back_slash; + else + last_slash = fore_slash; + + // detect if we had a relative or + // distiguished path ( had a slash ) + if( last_slash ) + { + // we had a slash charachter in our + // command line + *( last_slash + 1 ) = 0; + + // if had a string to append to the path + if( string ) + strcat( tmp_win32_path, string ); + } + else + { + // no slash, assume local directory + strcpy( tmp_win32_path, "./" ); + + // if had a string to append to the path + if( string ) + strcat( tmp_win32_path, string ); + } + + return tmp_win32_path; +} + +#define XINE_HOMEDIR exec_path_append_subdir( 0 ) +#define XINE_PLUGINDIR exec_path_append_subdir( "plugins" ) +#define XINE_FONTDIR exec_path_append_subdir( "fonts" ) +#define XINE_LOCALEDIR exec_path_append_subdir( "locale" ) + +#else + +/* Path where catalog files will be. */ +#define XINE_LOCALEDIR "/usr/local/share/locale" + +/* Define this to plugins directory location */ +#define XINE_PLUGINDIR "/usr/local/lib/xine/plugins/1.0.0" + +/* Define this if you're running x86 architecture */ +#define __i386__ 1 + +/* Path where aclocal m4 files will be. */ +#define XINE_ACFLAGS "-I ${prefix}/share/aclocal" + +#endif + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define as `__inline' if that's what the C compiler calls it, or to nothing + if it is not supported. */ +/* #undef inline */ + +/* Define to `long' if does not define. */ +/* #undef off_t */ + +/* Define to `unsigned' if does not define. */ +/* #undef size_t */ + +#endif /* defined CONFIG_H */ diff --git a/win32/include/dirent.h b/win32/include/dirent.h new file mode 100644 index 000000000..588048c67 --- /dev/null +++ b/win32/include/dirent.h @@ -0,0 +1,32 @@ +/* + + Declaration of POSIX directory browsing functions and types for Win32. + + Kevlin Henney (mailto:kevlin@acm.org), March 1997. + + Copyright Kevlin Henney, 1997. All rights reserved. + + Permission to use, copy, modify, and distribute this software and its + documentation for any purpose is hereby granted without fee, provided + that this copyright and permissions notice appear in all copies and + derivatives, and that no charge may be made for the software and its + documentation except to cover cost of distribution. + +*/ + +#ifndef DIRENT_INCLUDED +#define DIRENT_INCLUDED + +typedef struct DIR DIR; + +struct dirent +{ + char *d_name; +}; + +DIR *opendir(const char *); +int closedir(DIR *); +struct dirent *readdir(DIR *); +void rewinddir(DIR *); + +#endif diff --git a/win32/include/dlfcn.h b/win32/include/dlfcn.h new file mode 100644 index 000000000..35074bcd1 --- /dev/null +++ b/win32/include/dlfcn.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2000-2001 the xine project + * + * This file is part of xine, a unix video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * WIN32 PORT, + * by Matthew Grooms + * + * dlfcn.h - Mimic the dl functions of a *nix system + * + */ + +#define RTLD_LAZY 0 +#define RTLD_GLOBAL 0 + +#define dlopen( A, B ) LoadLibrary( A ) +#define dlclose( A ) FreeLibrary( A ) +#define dlsym( A, B ) ( void * ) GetProcAddress( A, B ) +#define dlerror() "dlerror" diff --git a/win32/include/inttypes.h b/win32/include/inttypes.h new file mode 100644 index 000000000..90a7c81f5 --- /dev/null +++ b/win32/include/inttypes.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2000-2001 the xine project + * + * This file is part of xine, a unix video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * WIN32 PORT, + * by Matthew Grooms + * + * inttypes.h - Standard integer definitions. + * + */ + +#ifndef _SYS_INTTYPES_H_ +#define _SYS_INTTYPES_H_ + +#define int8_t signed char +#define int16_t signed short +#define int32_t signed long +#define int64_t signed hyper + +#define uint8_t unsigned char +#define uint16_t unsigned short +#define uint32_t unsigned long +#define uint64_t unsigned hyper + +#define intptr_t signed int * +#define uintptr_t unsigned int * + +#define __int8_t int8_t +#define __int16_t int16_t +#define __int32_t int32_t +#define __int64_t int64_t + +#define __uint8_t uint8_t +#define __uint16_t uint16_t +#define __uint32_t uint32_t +#define __uint64_t uint64_t + +#define __intptr_t intptr_t +#define __uintptr_t uintptr_t + +typedef __int64 ulonglong; +typedef __int64 longlong; + +#endif diff --git a/win32/include/pthread.h b/win32/include/pthread.h new file mode 100644 index 000000000..31e2cf918 --- /dev/null +++ b/win32/include/pthread.h @@ -0,0 +1,1077 @@ +/* This is the POSIX thread API (POSIX 1003). + * + * Pthreads-win32 - POSIX Threads Library for Win32 + * Copyright (C) 1998 + * + * 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 + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA + */ + +#if !defined( PTHREAD_H ) +#define PTHREAD_H + +#ifdef _UWIN +# define HAVE_STRUCT_TIMESPEC 1 +# define HAVE_SIGNAL_H 1 +# undef HAVE_CONFIG_H +# pragma comment(lib, "pthread") +#endif + +/* + * ------------------------------------------------------------- + * + * + * Module: pthread.h + * + * Purpose: + * Provides an implementation of PThreads based upon the + * standard: + * + * POSIX 1003.1c-1995 (POSIX.1c) + * + * Parts of the implementation also comply with the + * Open Group Unix 98 specification in order to enhance + * code portability between Windows, various commercial + * Unix implementations, and Linux. + * + * Authors: + * There have been many contributors to this library. + * The initial implementation was contributed by + * John Bossom, and several others have provided major + * sections or revisions of parts of the implementation. + * Often significant effort has been contributed to + * find and fix important bugs and other problems to + * improve the reliability of the library, which sometimes + * is not reflected in the amount of code which changed as + * result. + * As much as possible, the contributors are acknowledged + * in the ChangeLog file in the source code distribution + * where their changes are noted in detail. + * + * Contributors are listed in the MAINTAINERS file. + * + * As usual, all bouquets go to the contributors, and all + * brickbats go to the project maintainer. + * + * Maintainer: + * The code base for this project is coordinated and + * eventually pre-tested, packaged, and made available by + * + * Ross Johnson + * + * QA Testers: + * Ultimately, the library is tested in the real world by + * a host of competent and demanding scientists and + * engineers who report bugs and/or provide solutions + * which are then fixed or incorporated into subsequent + * versions of the library. Each time a bug is fixed, a + * test case is written to prove the fix and ensure + * that later changes to the code don't reintroduce the + * same error. The number of test cases is slowly growing + * and therefore so is the code reliability. + * + * Compliance: + * See the file ANNOUNCE for the list of implemented + * and not-implemented routines and defined options. + * Of course, these are all defined is this file as well. + * + * Web site: + * The source code and other information about this library + * are available from + * + * http://sources.redhat.com/pthreads-win32/ + * + * ------------------------------------------------------------- + */ + +/* + * ----------------- + * autoconf switches + * ----------------- + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +#include + +#ifndef NEED_FTIME +#include +#else /* NEED_FTIME */ +/* use native WIN32 time API */ +#endif /* NEED_FTIME */ + +#if HAVE_SIGNAL_H +#include +#endif /* HAVE_SIGNAL_H */ + +#include + +#ifndef HAVE_STRUCT_TIMESPEC +struct timespec { + long tv_sec; + long tv_nsec; +}; +#endif /* HAVE_STRUCT_TIMESPEC */ + +#ifndef SIG_BLOCK +#define SIG_BLOCK 0 +#endif /* SIG_BLOCK */ + +#ifndef SIG_UNBLOCK +#define SIG_UNBLOCK 1 +#endif /* SIG_UNBLOCK */ + +#ifndef SIG_SETMASK +#define SIG_SETMASK 2 +#endif /* SIG_SETMASK */ + +/* + * note: ETIMEDOUT is correctly defined in winsock.h + */ +#include + +#ifdef NEED_ERRNO +# include "need_errno.h" +#else +# include +#endif + +#include + +/* + * In case ETIMEDOUT hasn't been defined above somehow. + */ +#ifndef ETIMEDOUT +# define ETIMEDOUT 10060 /* This is the value in winsock.h. */ +#endif + +/* + * Several systems don't define ENOTSUP. If not, we use + * the same value as Solaris. + */ +#ifndef ENOTSUP +# define ENOTSUP 48 +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* + * ------------------------------------------------------------- + * + * POSIX 1003.1c-1995 Options + * =========================== + * + * _POSIX_THREADS (set) + * If set, you can use threads + * + * _POSIX_THREAD_ATTR_STACKSIZE (set) + * If set, you can control the size of a thread's + * stack + * pthread_attr_getstacksize + * pthread_attr_setstacksize + * + * _POSIX_THREAD_ATTR_STACKADDR (not set) + * If set, you can allocate and control a thread's + * stack. If not supported, the following functions + * will return ENOSYS, indicating they are not + * supported: + * pthread_attr_getstackaddr + * pthread_attr_setstackaddr + * + * _POSIX_THREAD_PRIORITY_SCHEDULING (set) + * If set, you can use realtime scheduling. + * Indicates the availability of: + * pthread_attr_getinheritsched + * pthread_attr_getschedparam + * pthread_attr_getschedpolicy + * pthread_attr_getscope + * pthread_attr_setinheritsched + * pthread_attr_setschedparam + * pthread_attr_setschedpolicy + * pthread_attr_setscope + * pthread_getschedparam + * pthread_setschedparam + * sched_get_priority_max + * sched_get_priority_min + * sched_rr_set_interval + * + * _POSIX_THREAD_PRIO_INHERIT (not set) + * If set, you can create priority inheritance + * mutexes. + * pthread_mutexattr_getprotocol + + * pthread_mutexattr_setprotocol + + * + * _POSIX_THREAD_PRIO_PROTECT (not set) + * If set, you can create priority ceiling mutexes + * Indicates the availability of: + * pthread_mutex_getprioceiling + * pthread_mutex_setprioceiling + * pthread_mutexattr_getprioceiling + * pthread_mutexattr_getprotocol + + * pthread_mutexattr_setprioceiling + * pthread_mutexattr_setprotocol + + * + * _POSIX_THREAD_PROCESS_SHARED (not set) + * If set, you can create mutexes and condition + * variables that can be shared with another + * process.If set, indicates the availability + * of: + * pthread_mutexattr_getpshared + * pthread_mutexattr_setpshared + * pthread_condattr_getpshared + * pthread_condattr_setpshared + * + * _POSIX_THREAD_SAFE_FUNCTIONS (set) + * If set you can use the special *_r library + * functions that provide thread-safe behaviour + * + * + These functions provide both 'inherit' and/or + * 'protect' protocol, based upon these macro + * settings. + * + * POSIX 1003.1c-1995 Limits + * =========================== + * + * PTHREAD_DESTRUCTOR_ITERATIONS + * Maximum number of attempts to destroy + * a thread's thread-specific data on + * termination (must be at least 4) + * + * PTHREAD_KEYS_MAX + * Maximum number of thread-specific data keys + * available per process (must be at least 128) + * + * PTHREAD_STACK_MIN + * Minimum supported stack size for a thread + * + * PTHREAD_THREADS_MAX + * Maximum number of threads supported per + * process (must be at least 64). + * + * + * POSIX 1003.1j/D10-1999 Options + * ============================== + * + * _POSIX_READER_WRITER_LOCKS (set) + * If set, you can use read/write locks + * + * _POSIX_SPIN_LOCKS (set) + * If set, you can use spin locks + * + * _POSIX_BARRIERS (set) + * If set, you can use barriers + * + * ------------------------------------------------------------- + */ + +/* + * POSIX Options + */ +#ifndef _POSIX_THREADS +#define _POSIX_THREADS +#endif + +#ifndef _POSIX_READER_WRITER_LOCKS +#define _POSIX_READER_WRITER_LOCKS +#endif + +#ifndef _POSIX_SPIN_LOCKS +#define _POSIX_SPIN_LOCKS +#endif + +#ifndef _POSIX_BARRIERS +#define _POSIX_BARRIERS +#endif + +#define _POSIX_THREAD_SAFE_FUNCTIONS +#define _POSIX_THREAD_ATTR_STACKSIZE +#define _POSIX_THREAD_PRIORITY_SCHEDULING + +#if defined( KLUDGE ) +/* + * The following are not supported + */ +#define _POSIX_THREAD_ATTR_STACKADDR +#define _POSIX_THREAD_PRIO_INHERIT +#define _POSIX_THREAD_PRIO_PROTECT +#define _POSIX_THREAD_PROCESS_SHARED + +#endif /* KLUDGE */ + +/* + * POSIX Limits + * + * PTHREAD_DESTRUCTOR_ITERATIONS + * Standard states this must be at least + * 4. + * + * PTHREAD_KEYS_MAX + * WIN32 permits only 64 TLS keys per process. + * This limitation could be worked around by + * simply simulating keys. + * + * PTHREADS_STACK_MIN + * POSIX specifies 0 which is also the value WIN32 + * interprets as allowing the system to + * set the size to that of the main thread. The + * maximum stack size in Win32 is 1Meg. WIN32 + * allocates more stack as required up to the 1Meg + * limit. + * + * PTHREAD_THREADS_MAX + * Not documented by WIN32. Wrote a test program + * that kept creating threads until it failed + * revealed this approximate number. + * + */ +#define PTHREAD_DESTRUCTOR_ITERATIONS 4 +#define PTHREAD_KEYS_MAX 64 +#define PTHREAD_STACK_MIN 0 +#define PTHREAD_THREADS_MAX 2019 + + +#ifdef _UWIN +# include +#else +typedef struct pthread_t_ *pthread_t; +typedef struct pthread_attr_t_ *pthread_attr_t; +typedef struct pthread_once_t_ pthread_once_t; +typedef struct pthread_key_t_ *pthread_key_t; +typedef struct pthread_mutex_t_ *pthread_mutex_t; +typedef struct pthread_mutexattr_t_ *pthread_mutexattr_t; +typedef struct pthread_cond_t_ *pthread_cond_t; +typedef struct pthread_condattr_t_ *pthread_condattr_t; +#endif +typedef struct pthread_rwlock_t_ *pthread_rwlock_t; +typedef struct pthread_rwlockattr_t_ *pthread_rwlockattr_t; +typedef struct pthread_spinlock_t_ *pthread_spinlock_t; +typedef struct pthread_barrier_t_ *pthread_barrier_t; +typedef struct pthread_barrierattr_t_ *pthread_barrierattr_t; + +/* + * ==================== + * ==================== + * POSIX Threads + * ==================== + * ==================== + */ + +enum { +/* + * pthread_attr_{get,set}detachstate + */ + PTHREAD_CREATE_JOINABLE = 0, /* Default */ + PTHREAD_CREATE_DETACHED = 1, + +/* + * pthread_attr_{get,set}inheritsched + */ + PTHREAD_INHERIT_SCHED = 0, + PTHREAD_EXPLICIT_SCHED = 1, /* Default */ + +/* + * pthread_{get,set}scope + */ + PTHREAD_SCOPE_PROCESS = 0, + PTHREAD_SCOPE_SYSTEM = 1, /* Default */ + +/* + * pthread_setcancelstate paramters + */ + PTHREAD_CANCEL_ENABLE = 0, /* Default */ + PTHREAD_CANCEL_DISABLE = 1, + +/* + * pthread_setcanceltype parameters + */ + PTHREAD_CANCEL_ASYNCHRONOUS = 0, + PTHREAD_CANCEL_DEFERRED = 1, /* Default */ + +/* + * pthread_mutexattr_{get,set}pshared + * pthread_condattr_{get,set}pshared + */ + PTHREAD_PROCESS_PRIVATE = 0, + PTHREAD_PROCESS_SHARED = 1, + +/* + * pthread_barrier_wait + */ + PTHREAD_BARRIER_SERIAL_THREAD = -1 +}; + +/* + * ==================== + * ==================== + * Cancelation + * ==================== + * ==================== + */ +#define PTHREAD_CANCELED ((void *) -1) + + +/* + * ==================== + * ==================== + * Once Key + * ==================== + * ==================== + */ +#define PTHREAD_ONCE_INIT { FALSE, -1 } + +struct pthread_once_t_ +{ + int done; /* indicates if user function executed */ + long started; /* First thread to increment this value */ + /* to zero executes the user function */ +}; + + +/* + * ==================== + * ==================== + * Object initialisers + * ==================== + * ==================== + */ +#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) -1) + +#define PTHREAD_COND_INITIALIZER ((pthread_cond_t) -1) + +#define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t) -1) + +#define PTHREAD_SPINLOCK_INITIALIZER ((pthread_spinlock_t) -1) + +enum +{ + PTHREAD_MUTEX_FAST_NP, + PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_FAST_NP, + PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL +}; + + +/* There are three implementations of cancel cleanup. + * Note that pthread.h is included in both application + * compilation units and also internally for the library. + * The code here and within the library aims to work + * for all reasonable combinations of environments. + * + * The three implementations are: + * + * WIN32 SEH + * C + * C++ + * + * Please note that exiting a push/pop block via + * "return", "exit", "break", or "continue" will + * lead to different behaviour amongst applications + * depending upon whether the library was built + * using SEH, C++, or C. For example, a library built + * with SEH will call the cleanup routine, while both + * C++ and C built versions will not. + */ + +/* + * define defaults for cleanup code + */ +#if !defined( __CLEANUP_SEH ) && !defined( __CLEANUP_CXX ) && !defined( __CLEANUP_C ) + +#if defined(_MSC_VER) +#define __CLEANUP_SEH +#elif defined(__cplusplus) +#define __CLEANUP_CXX +#else +#define __CLEANUP_C +#endif + +#endif + +#if defined( __CLEANUP_SEH ) && defined(__GNUC__) +#error ERROR [__FILE__, line __LINE__]: GNUC does not support SEH. +#endif + +typedef struct ptw32_cleanup_t ptw32_cleanup_t; +typedef void (__cdecl *ptw32_cleanup_callback_t)(void *); + +struct ptw32_cleanup_t +{ + ptw32_cleanup_callback_t routine; + void *arg; + struct ptw32_cleanup_t *prev; +}; + +#ifdef __CLEANUP_SEH + /* + * WIN32 SEH version of cancel cleanup. + */ + +#define pthread_cleanup_push( _rout, _arg ) \ + { \ + ptw32_cleanup_t _cleanup; \ + \ + _cleanup.routine = (ptw32_cleanup_callback_t)(_rout); \ + _cleanup.arg = (_arg); \ + __try \ + { \ + +#define pthread_cleanup_pop( _execute ) \ + } \ + __finally \ + { \ + if( _execute || AbnormalTermination()) \ + { \ + (*(_cleanup.routine))( _cleanup.arg ); \ + } \ + } \ + } + +#else /* __CLEANUP_SEH */ + +#ifdef __CLEANUP_C + + /* + * C implementation of PThreads cancel cleanup + */ + +#define pthread_cleanup_push( _rout, _arg ) \ + { \ + ptw32_cleanup_t _cleanup; \ + \ + ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t) (_rout), (_arg) ); \ + +#define pthread_cleanup_pop( _execute ) \ + (void) ptw32_pop_cleanup( _execute ); \ + } + +#else /* __CLEANUP_C */ + +#ifdef __CLEANUP_CXX + + /* + * C++ version of cancel cleanup. + * - John E. Bossom. + */ + + class PThreadCleanup { + /* + * PThreadCleanup + * + * Purpose + * This class is a C++ helper class that is + * used to implement pthread_cleanup_push/ + * pthread_cleanup_pop. + * The destructor of this class automatically + * pops the pushed cleanup routine regardless + * of how the code exits the scope + * (i.e. such as by an exception) + */ + ptw32_cleanup_callback_t cleanUpRout; + void * obj; + int executeIt; + + public: + PThreadCleanup() : + cleanUpRout( NULL ), + obj( NULL ), + executeIt( 0 ) + /* + * No cleanup performed + */ + { + } + + PThreadCleanup( + ptw32_cleanup_callback_t routine, + void * arg ) : + cleanUpRout( routine ), + obj( arg ), + executeIt( 1 ) + /* + * Registers a cleanup routine for 'arg' + */ + { + } + + ~PThreadCleanup() + { + if ( executeIt && ((void *) cleanUpRout != NULL) ) + { + (void) (*cleanUpRout)( obj ); + } + } + + void execute( int exec ) + { + executeIt = exec; + } + }; + + /* + * C++ implementation of PThreads cancel cleanup; + * This implementation takes advantage of a helper + * class who's destructor automatically calls the + * cleanup routine if we exit our scope weirdly + */ +#define pthread_cleanup_push( _rout, _arg ) \ + { \ + PThreadCleanup cleanup((ptw32_cleanup_callback_t)(_rout), \ + (void *) (_arg) ); + +#define pthread_cleanup_pop( _execute ) \ + cleanup.execute( _execute ); \ + } + +#else + +#error ERROR [__FILE__, line __LINE__]: Cleanup type undefined. + +#endif /* __CLEANUP_CXX */ + +#endif /* __CLEANUP_C */ + +#endif /* __CLEANUP_SEH */ + +/* + * =============== + * =============== + * Methods + * =============== + * =============== + */ + +/* + * PThread Attribute Functions + */ +int pthread_attr_init (pthread_attr_t * attr); + +int pthread_attr_destroy (pthread_attr_t * attr); + +int pthread_attr_getdetachstate (const pthread_attr_t * attr, + int *detachstate); + +int pthread_attr_getstackaddr (const pthread_attr_t * attr, + void **stackaddr); + +int pthread_attr_getstacksize (const pthread_attr_t * attr, + size_t * stacksize); + +int pthread_attr_setdetachstate (pthread_attr_t * attr, + int detachstate); + +int pthread_attr_setstackaddr (pthread_attr_t * attr, + void *stackaddr); + +int pthread_attr_setstacksize (pthread_attr_t * attr, + size_t stacksize); + +int pthread_attr_getschedparam (const pthread_attr_t *attr, + struct sched_param *param); + +int pthread_attr_setschedparam (pthread_attr_t *attr, + const struct sched_param *param); + +int pthread_attr_setschedpolicy (pthread_attr_t *, + int); + +int pthread_attr_getschedpolicy (pthread_attr_t *, + int *); + +int pthread_attr_setinheritsched(pthread_attr_t * attr, + int inheritsched); + +int pthread_attr_getinheritsched(pthread_attr_t * attr, + int * inheritsched); + +int pthread_attr_setscope (pthread_attr_t *, + int); + +int pthread_attr_getscope (const pthread_attr_t *, + int *); + +/* + * PThread Functions + */ +int pthread_create (pthread_t * tid, + const pthread_attr_t * attr, + void *(*start) (void *), + void *arg); + +int pthread_detach (pthread_t tid); + +int pthread_equal (pthread_t t1, + pthread_t t2); + +void pthread_exit (void *value_ptr); + +int pthread_join (pthread_t thread, + void **value_ptr); + +pthread_t pthread_self (void); + +int pthread_cancel (pthread_t thread); + +int pthread_setcancelstate (int state, + int *oldstate); + +int pthread_setcanceltype (int type, + int *oldtype); + +void pthread_testcancel (void); + +int pthread_once (pthread_once_t * once_control, + void (*init_routine) (void)); + +ptw32_cleanup_t *ptw32_pop_cleanup (int execute); + +void ptw32_push_cleanup (ptw32_cleanup_t * cleanup, + void (*routine) (void *), + void *arg); + +/* + * Thread Specific Data Functions + */ +int pthread_key_create (pthread_key_t * key, + void (*destructor) (void *)); + +int pthread_key_delete (pthread_key_t key); + +int pthread_setspecific (pthread_key_t key, + const void *value); + +void *pthread_getspecific (pthread_key_t key); + + +/* + * Mutex Attribute Functions + */ +int pthread_mutexattr_init (pthread_mutexattr_t * attr); + +int pthread_mutexattr_destroy (pthread_mutexattr_t * attr); + +int pthread_mutexattr_getpshared (const pthread_mutexattr_t + * attr, + int *pshared); + +int pthread_mutexattr_setpshared (pthread_mutexattr_t * attr, + int pshared); + +int pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind); +int pthread_mutexattr_gettype (pthread_mutexattr_t * attr, int *kind); + +/* + * Barrier Attribute Functions + */ +int pthread_barrierattr_init (pthread_barrierattr_t * attr); + +int pthread_barrierattr_destroy (pthread_barrierattr_t * attr); + +int pthread_barrierattr_getpshared (const pthread_barrierattr_t + * attr, + int *pshared); + +int pthread_barrierattr_setpshared (pthread_barrierattr_t * attr, + int pshared); + +/* + * Mutex Functions + */ +int pthread_mutex_init (pthread_mutex_t * mutex, + const pthread_mutexattr_t * attr); + +int pthread_mutex_destroy (pthread_mutex_t * mutex); + +int pthread_mutex_lock (pthread_mutex_t * mutex); + +int pthread_mutex_trylock (pthread_mutex_t * mutex); + +int pthread_mutex_unlock (pthread_mutex_t * mutex); + +/* + * Spinlock Functions + */ +int pthread_spin_init (pthread_spinlock_t * lock, int pshared); + +int pthread_spin_destroy (pthread_spinlock_t * lock); + +int pthread_spin_lock (pthread_spinlock_t * lock); + +int pthread_spin_trylock (pthread_spinlock_t * lock); + +int pthread_spin_unlock (pthread_spinlock_t * lock); + +/* + * Barrier Functions + */ +int pthread_barrier_init (pthread_barrier_t * barrier, + const pthread_barrierattr_t * attr, + unsigned int count); + +int pthread_barrier_destroy (pthread_barrier_t * barrier); + +int pthread_barrier_wait (pthread_barrier_t * barrier); + +/* + * Condition Variable Attribute Functions + */ +int pthread_condattr_init (pthread_condattr_t * attr); + +int pthread_condattr_destroy (pthread_condattr_t * attr); + +int pthread_condattr_getpshared (const pthread_condattr_t * attr, + int *pshared); + +int pthread_condattr_setpshared (pthread_condattr_t * attr, + int pshared); + +/* + * Condition Variable Functions + */ +int pthread_cond_init (pthread_cond_t * cond, + const pthread_condattr_t * attr); + +int pthread_cond_destroy (pthread_cond_t * cond); + +int pthread_cond_wait (pthread_cond_t * cond, + pthread_mutex_t * mutex); + +int pthread_cond_timedwait (pthread_cond_t * cond, + pthread_mutex_t * mutex, + const struct timespec *abstime); + +int pthread_cond_signal (pthread_cond_t * cond); + +int pthread_cond_broadcast (pthread_cond_t * cond); + +/* + * Scheduling + */ +int pthread_setschedparam (pthread_t thread, + int policy, + const struct sched_param *param); + +int pthread_getschedparam (pthread_t thread, + int *policy, + struct sched_param *param); + +int pthread_setconcurrency (int); + +int pthread_getconcurrency (void); + +/* + * Read-Write Lock Functions + */ +int pthread_rwlock_init(pthread_rwlock_t *lock, + const pthread_rwlockattr_t *attr); + +int pthread_rwlock_destroy(pthread_rwlock_t *lock); + +int pthread_rwlock_tryrdlock(pthread_rwlock_t *); + +int pthread_rwlock_trywrlock(pthread_rwlock_t *); + +int pthread_rwlock_rdlock(pthread_rwlock_t *lock); + +int pthread_rwlock_wrlock(pthread_rwlock_t *lock); + +int pthread_rwlock_unlock(pthread_rwlock_t *lock); + + +/* + * Non-portable functions + */ + +/* + * Compatibility with Linux. + */ +int pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr, int kind); +int pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr, int *kind); + +/* + * Possibly supported by other POSIX threads implementations + */ +int pthread_delay_np (struct timespec * interval); + +/* + * Returns the Win32 HANDLE for the POSIX thread. + */ +HANDLE pthread_getw32threadhandle_np(pthread_t thread); + +/* + * Returns the number of CPUs available to the process. + */ +int pthread_getprocessors_np(int * count); + +/* + * Useful if an application wants to statically link + * the lib rather than load the DLL at run-time. + */ +int pthread_win32_process_attach_np(void); +int pthread_win32_process_detach_np(void); +int pthread_win32_thread_attach_np(void); +int pthread_win32_thread_detach_np(void); + + +/* + * Protected Methods + * + * This function blocks until the given WIN32 handle + * is signaled or pthread_cancel had been called. + * This function allows the caller to hook into the + * PThreads cancel mechanism. It is implemented using + * + * WaitForMultipleObjects + * + * on 'waitHandle' and a manually reset WIN32 Event + * used to implement pthread_cancel. The 'timeout' + * argument to TimedWait is simply passed to + * WaitForMultipleObjects. + */ +int pthreadCancelableWait (HANDLE waitHandle); +int pthreadCancelableTimedWait (HANDLE waitHandle, DWORD timeout); + +/* + * Thread-Safe C Runtime Library Mappings. + */ +#ifndef _UWIN +#if 1 +#if (! defined(HAVE_ERRNO)) && (! defined(_REENTRANT)) && (! defined(_MT)) +int * _errno( void ); +#endif +#else +#if (! defined(NEED_ERRNO)) || (! defined( _REENTRANT ) && (! defined( _MT ) || ! defined( _MD ))) +#if defined(PTW32_BUILD) +__declspec( dllexport ) int * _errno( void ); +#else +int * _errno( void ); +#endif +#endif +#endif +#endif + +/* + * WIN32 C runtime library had been made thread-safe + * without affecting the user interface. Provide + * mappings from the UNIX thread-safe versions to + * the standard C runtime library calls. + * Only provide function mappings for functions that + * actually exist on WIN32. + */ + +#if !defined(__MINGW32__) +#define strtok_r( _s, _sep, _lasts ) \ + ( *(_lasts) = strtok( (_s), (_sep) ) ) +#endif /* !__MINGW32__ */ + +#define asctime_r( _tm, _buf ) \ + ( strcpy( (_buf), asctime( (_tm) ) ), \ + (_buf) ) + +#define ctime_r( _clock, _buf ) \ + ( strcpy( (_buf), ctime( (_clock) ) ), \ + (_buf) ) + +#define gmtime_r( _clock, _result ) \ + ( *(_result) = *gmtime( (_clock) ), \ + (_result) ) + +#define localtime_r( _clock, _result ) \ + ( *(_result) = *localtime( (_clock) ), \ + (_result) ) + +#define rand_r( _seed ) \ + ( _seed == _seed? rand() : rand() ) + + +#ifdef __cplusplus + +/* + * Internal exceptions + */ +class ptw32_exception {}; +class ptw32_exception_cancel : public ptw32_exception {}; +class ptw32_exception_exit : public ptw32_exception {}; + +#endif + +/* FIXME: This is only required if the library was built using SEH */ +/* + * Get internal SEH tag + */ +DWORD ptw32_get_exception_services_code(void); + +#ifndef PTW32_BUILD + +#ifdef __CLEANUP_SEH + +/* + * Redefine the SEH __except keyword to ensure that applications + * propagate our internal exceptions up to the library's internal handlers. + */ +#define __except( E ) \ + __except( ( GetExceptionCode() == ptw32_get_exception_services_code() ) \ + ? EXCEPTION_CONTINUE_SEARCH : ( E ) ) + +#endif /* __CLEANUP_SEH */ + +#ifdef __cplusplus + +/* + * Redefine the C++ catch keyword to ensure that applications + * propagate our internal exceptions up to the library's internal handlers. + */ +#ifdef _MSC_VER + /* + * WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll' + * if you want Pthread-Win32 cancelation and pthread_exit to work. + */ + +#ifndef PtW32NoCatchWarn + +#pragma message("When compiling applications with MSVC++ and C++ exception handling:") +#pragma message(" Replace any 'catch( ... )' with 'PtW32CatchAll' in POSIX threads") +#pragma message(" if you want POSIX thread cancelation and pthread_exit to work.") + +#endif + +#define PtW32CatchAll \ + catch( ptw32_exception & ) { throw; } \ + catch( ... ) + +#else /* _MSC_VER */ + +#define catch( E ) \ + catch( ptw32_exception & ) { throw; } \ + catch( E ) + +#endif /* _MSC_VER */ + +#endif /* __cplusplus */ + +#endif /* ! PTW32_BUILD */ + +#ifdef __cplusplus +} /* End of extern "C" */ +#endif /* __cplusplus */ + +#endif /* PTHREAD_H */ diff --git a/win32/include/pwd.h b/win32/include/pwd.h new file mode 100644 index 000000000..e69de29bb diff --git a/win32/include/sched.h b/win32/include/sched.h new file mode 100644 index 000000000..c9aaeb8a4 --- /dev/null +++ b/win32/include/sched.h @@ -0,0 +1,89 @@ +/* + * Module: sched.h + * + * Purpose: + * Provides an implementation of POSIX realtime extensions + * as defined in + * + * POSIX 1003.1b-1993 (POSIX.1b) + * + * Pthreads-win32 - POSIX Threads Library for Win32 + * Copyright (C) 1998 + * + * 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 + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA + */ +#ifndef _SCHED_H +#define _SCHED_H + +#if defined(__MINGW32__) || defined(_UWIN) +/* For pid_t */ +# include +/* Required by Unix 98 */ +# include +#else +typedef int pid_t; +#endif + +/* Thread scheduling policies */ + +enum { + SCHED_OTHER = 0, + SCHED_FIFO, + SCHED_RR, + SCHED_MIN = SCHED_OTHER, + SCHED_MAX = SCHED_RR +}; + +struct sched_param { + int sched_priority; +}; + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +int sched_yield (void); + +int sched_get_priority_min (int policy); + +int sched_get_priority_max (int policy); + +int sched_setscheduler (pid_t pid, int policy); + +int sched_getscheduler (pid_t pid); + +/* + * Note that this macro returns ENOTSUP rather than + * ENOSYS as might be expected. However, returning ENOSYS + * should mean that sched_get_priority_{min,max} are + * not implemented as well as sched_rr_get_interval. + * This is not the case, since we just don't support + * round-robin scheduling. Therefore I have chosen to + * return the same value as sched_setscheduler when + * SCHED_RR is passed to it. + */ +#define sched_rr_get_interval(_pid, _interval) \ + ( errno = ENOTSUP, (int) -1 ) + + +#ifdef __cplusplus +} /* End of extern "C" */ +#endif /* __cplusplus */ + + +#endif /* !_SCHED_H */ + diff --git a/win32/include/semaphore.h b/win32/include/semaphore.h new file mode 100644 index 000000000..a0255cf6f --- /dev/null +++ b/win32/include/semaphore.h @@ -0,0 +1,101 @@ +/* + * Module: semaphore.h + * + * Purpose: + * Semaphores aren't actually part of the PThreads standard. + * They are defined by the POSIX Standard: + * + * POSIX 1003.1b-1993 (POSIX.1b) + * + * Pthreads-win32 - POSIX Threads Library for Win32 + * Copyright (C) 1998 + * + * 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 + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA + */ +#if !defined( SEMAPHORE_H ) +#define SEMAPHORE_H + +/* + * This is a duplicate of what is in the autoconf config.h, + * which is only used when building the pthread-win32 libraries. + */ + +#ifndef PTW32_CONFIG_H +# if defined(WINCE) +# define NEED_ERRNO +# define NEED_SEM +# endif +# if defined(_UWIN) || defined(__MINGW32__) +# define HAVE_MODE_T +# endif +#endif + +/* + * + */ + +#ifdef NEED_SEM +#include "need_errno.h" +#else +#include +#endif + +#define _POSIX_SEMAPHORES + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifndef HAVE_MODE_T +typedef unsigned int mode_t; +#endif + + +typedef struct sem_t_ * sem_t; + +int sem_init (sem_t * sem, + int pshared, + unsigned int value); + +int sem_destroy (sem_t * sem); + +int sem_trywait (sem_t * sem); + +int sem_wait (sem_t * sem); + +int sem_post (sem_t * sem); + +int sem_post_multiple (sem_t * sem, + int count); + +int sem_open (const char * name, + int oflag, + mode_t mode, + unsigned int value); + +int sem_close (sem_t * sem); + +int sem_unlink (const char * name); + +int sem_getvalue (sem_t * sem, + int * sval); + +#ifdef __cplusplus +} /* End of extern "C" */ +#endif /* __cplusplus */ + +#endif /* !SEMAPHORE_H */ diff --git a/win32/include/sys/time.h b/win32/include/sys/time.h new file mode 100644 index 000000000..074a8a1e6 --- /dev/null +++ b/win32/include/sys/time.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2000-2001 the xine project + * + * This file is part of xine, a unix video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * WIN32 PORT, + * by Matthew Grooms + * + * sys/time.h - There is no seperate sys/time.h for win32 so we simply + * include the standard time header as well as our xine + * timer functions. + */ + +#include diff --git a/win32/include/timer.h b/win32/include/timer.h new file mode 100644 index 000000000..9be9d0557 --- /dev/null +++ b/win32/include/timer.h @@ -0,0 +1,39 @@ +#include +#include +#include "pthread.h" + +#ifndef _ITIMER_ +#define _ITIMER_ + +#define ITIMER_REAL 0 +#define ITIMER_VIRTUAL 1 + +// time reference +// ---------------------------------- +// +// 1,000 milliseconds / sec +// 1,000,000 microseconds / sec +// 1,000,000,000 nanoseconds / sec +// +// timeval.time_sec = seconds +// timeval.time_usec = microseconds + +struct itimerval +{ + struct timeval it_interval; /* timer interval */ + struct timeval it_value; /* current value */ +}; + +struct timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +int gettimeofday( struct timeval *tp, struct timezone *tzp ); +int setitimer( int which, struct itimerval * value, struct itimerval *ovalue ); +int pause( void ); + +unsigned int sleep( unsigned int seconds ); +int nanosleep( const struct timespec *rqtp, struct timespec *rmtp ); + +#endif \ No newline at end of file diff --git a/win32/include/unistd.h b/win32/include/unistd.h new file mode 100644 index 000000000..22287d239 --- /dev/null +++ b/win32/include/unistd.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2000-2001 the xine project + * + * This file is part of xine, a unix video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * WIN32 PORT, + * by Matthew Grooms + * + * unistd.h - This is mostly a catch all header that maps standard unix + * libc calls to the equivelent win32 functions. + * + */ + +#include +#include +#include +#include + +#include "timer.h" + +#ifndef _SYS_UNISTD_H_ +#define _SYS_UNISTD_H_ + +#define inline __inline + +#define mkdir( A, B ) _mkdir( A ) +#define lstat stat +#define S_ISDIR(A) ( S_IFDIR & A ) +#define S_IXUSR S_IEXEC +#define S_IXGRP S_IEXEC +#define S_IXOTH S_IEXEC + +#define M_PI 3.14159265358979323846 /* pi */ + +#define bzero( A, B ) memset( A, 0, B ) +#define strcasecmp _stricmp +#define strncasecmp _strnicmp +#define snprintf _snprintf +#define vsnprintf _vsnprintf + +// FIXME : I dont remember why this is here +#define readlink + +#endif diff --git a/win32/include/xine/attributes.h b/win32/include/xine/attributes.h new file mode 100644 index 000000000..eac90ea9e --- /dev/null +++ b/win32/include/xine/attributes.h @@ -0,0 +1,44 @@ +/* + * attributes.h + * Copyright (C) 1999-2000 Aaron Holtzman + * + * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. + * + * mpeg2dec is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * mpeg2dec 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* use gcc attribs to align critical data structures */ + +#ifndef ATTRIBUTE_H_ +#define ATTRIBUTE_H_ + +#ifdef ATTRIBUTE_ALIGNED_MAX +#define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align))) +#else +#define ATTR_ALIGN(align) +#endif + +/* disable GNU __attribute__ extension, when not compiling with GNU C */ +#if defined(__GNUC__) +#ifndef ATTRIBUTE_PACKED +#define ATTRIBUTE_PACKED 1 +#endif +#else +#undef ATTRIBUTE_PACKED +#define __attribute__(x) /**/ +#endif + +#endif /* ATTRIBUTE_H_ */ + diff --git a/win32/include/xine/compat.h b/win32/include/xine/compat.h new file mode 100644 index 000000000..6c2906f14 --- /dev/null +++ b/win32/include/xine/compat.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2000-2001 the xine project + * + * This file is part of xine, a unix video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: compat.h,v 1.1 2003/04/20 16:42:10 guenter Exp $ + * + */ + +#ifndef XINE_COMPAT_H +#define XINE_COMPAT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined _MSC_VER +#define __XINE_FUNCTION__ __FILE__ +#elif defined __GNUC__ +#define __XINE_FUNCTION__ __FUNCTION__ +#else +#define __XINE_FUNCTION__ __func__ +#endif + +#ifndef NAME_MAX +#define XINE_NAME_MAX 256 +#else +#define XINE_NAME_MAX NAME_MAX +#endif + +#ifndef PATH_MAX +#define XINE_PATH_MAX 768 +#else +#define XINE_PATH_MAX PATH_MAX +#endif + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/win32/include/xine/xine.h b/win32/include/xine/xine.h new file mode 100644 index 000000000..193d7b7a9 --- /dev/null +++ b/win32/include/xine/xine.h @@ -0,0 +1,1580 @@ +/* + * Copyright (C) 2000-2002 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: xine.h,v 1.1 2003/04/20 16:42:10 guenter Exp $ + * + * public xine-lib (libxine) interface and documentation + * + * + * some programming guidelines about this api: + * ------------------------------------------- + * + * (1) libxine has (per stream instance) a fairly static memory + * model + * (2) as a rule of thumb, never free() or realloc() any pointers + * returned by the xine engine (unless stated otherwise) + * or, in other words: + * do not free() stuff you have not malloc()ed + * (3) xine is multi-threaded, make sure your programming environment + * can handle this. + * for x11-related stuff this means that you either have to properly + * use xlockdisplay() or use two seperate connections to the x-server + * + */ + +#ifndef HAVE_XINE_H +#define HAVE_XINE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include + + +/********************************************************************* + * xine opaque data types * + *********************************************************************/ + +typedef struct xine_s xine_t; +typedef struct xine_stream_s xine_stream_t; +typedef struct xine_audio_port_s xine_audio_port_t; +typedef struct xine_video_port_s xine_video_port_t; + +/* convenience types: simple player UIs might want to call ports drivers */ +typedef xine_audio_port_t xine_ao_driver_t; +typedef xine_video_port_t xine_vo_driver_t; + + +/********************************************************************* + * global engine handling * + *********************************************************************/ + +/* + * version information + */ + +/* dynamic info from actually linked libxine */ +const char *xine_get_version_string (void); +void xine_get_version (int *major, int *minor, int *sub); + +/* compare given version to libxine version, + return 1 if compatible, 0 otherwise */ +int xine_check_version (int major, int minor, int sub) ; + +/* static info - which libxine release this header came from */ +#define XINE_MAJOR_VERSION 1 +#define XINE_MINOR_VERSION 0 +#define XINE_SUB_VERSION 0 +#define XINE_VERSION "1-beta10" + +/* + * pre-init the xine engine + * + * will first malloc and init a xine_t, create an empty config + * system, then scan through all installed plugins and add them + * to an internal list for later use. + * + * to fully init the xine engine, you have to load config values + * (either using your own storage method and calling + * xine_config_register_entry, or by using the xine_load_config + * utility function - see below) and then call xine_init + * + * the only proper way to shut down the xine engine is to + * call xine_exit() - do not try to free() the xine pointer + * yourself and do not try to access any internal data structures + */ +xine_t *xine_new (void); + +/* + * post_init the xine engine + */ +void xine_init (xine_t *self); + +/* + * helper functions to find and init audio/video drivers + * from xine's plugin collection + * + * id : identifier of the driver, may be NULL for auto-detection + * data : special data struct for ui/driver communications, depends + * on driver + * visual: video driver flavor selector, constants see below + * + * both functions may return NULL if driver failed to load, was not + * found ... + * + * use xine_close_audio/video_driver() to close loaded drivers + * and free resources allocated by them + */ +xine_audio_port_t *xine_open_audio_driver (xine_t *self, const char *id, + void *data); +xine_video_port_t *xine_open_video_driver (xine_t *self, const char *id, + int visual, void *data); + +void xine_close_audio_driver (xine_t *self, xine_audio_port_t *driver); +void xine_close_video_driver (xine_t *self, xine_video_port_t *driver); + +/* valid visual types */ +#define XINE_VISUAL_TYPE_NONE 0 +#define XINE_VISUAL_TYPE_X11 1 +#define XINE_VISUAL_TYPE_AA 2 +#define XINE_VISUAL_TYPE_FB 3 +#define XINE_VISUAL_TYPE_GTK 4 +#define XINE_VISUAL_TYPE_DFB 5 +#define XINE_VISUAL_TYPE_PM 6 /* used by the OS/2 port */ +#define XINE_VISUAL_TYPE_WIN32 7 /* used by the WIN32/_MSC_VER port */ + +/* + * free all resources, close all plugins, close engine. + * self pointer is no longer valid after this call. + */ +void xine_exit (xine_t *self); + + +/********************************************************************* + * stream handling * + *********************************************************************/ + +/* + * create a new stream for media playback/access + * + * returns xine_stream_t* if OK, + * NULL on error (use xine_get_error for details) + * + * the only proper way to free the stream pointer returned by this + * function is to call xine_dispose() on it. do not try to access any + * fields in xine_stream_t, they're all private and subject to change + * without further notice. + */ +xine_stream_t *xine_stream_new (xine_t *self, + xine_audio_port_t *ao, xine_video_port_t *vo); + +/* + * Make one stream the slave of another. + * This establishes a binary master slave relation on streams, where + * certain operations (specified by parameter "affection") on the master + * stream are also applied to the slave stream. + * If you want more than one stream to react to one master, you have to + * apply the calls in a top down way: + * xine_stream_master_slave(stream1, stream2, 3); + * xine_stream_master_slave(stream2, stream3, 3); + * This will make stream1 affect stream2 and stream2 affect stream3, so + * effectively, operations on stream1 propagate to stream2 and 3. + * + * Please note that subsequent master_slave calls on the same streams + * will overwrite their previous master/slave setting. + * Be sure to not mess around. + * + * returns 1 on success, 0 on failure + */ +int xine_stream_master_slave(xine_stream_t *master, xine_stream_t *slave, + int affection); + +/* affection is some of the following ORed together: */ +/* playing the master plays the slave */ +#define XINE_MASTER_SLAVE_PLAY (1<<0) +/* slave stops on master stop */ +#define XINE_MASTER_SLAVE_STOP (1<<1) + +/* + * open a stream + * + * look for input / demux / decoder plugins, find out about the format + * see if it is supported, set up internal buffers and threads + * + * returns 1 if OK, 0 on error (use xine_get_error for details) + */ +int xine_open (xine_stream_t *stream, const char *mrl); + +/* + * play a stream from a given position + * + * start_pos: 0..65535 + * start_time: milliseconds + * if both start position parameters are != 0 start_pos will be used + * for non-seekable streams both values will be ignored + * + * returns 1 if OK, 0 on error (use xine_get_error for details) + */ +int xine_play (xine_stream_t *stream, int start_pos, int start_time); + +/* + * set xine to a trick mode for fast forward, backwards playback, + * low latency seeking. Please note that this works only with some + * input plugins. mode constants see below. + * + * returns 1 if OK, 0 on error (use xine_get_error for details) + */ +int xine_trick_mode (xine_stream_t *stream, int mode, int value); + +/* trick modes */ +#define XINE_TRICK_MODE_OFF 0 +#define XINE_TRICK_MODE_SEEK_TO_POSITION 1 +#define XINE_TRICK_MODE_SEEK_TO_TIME 2 +#define XINE_TRICK_MODE_FAST_FORWARD 3 +#define XINE_TRICK_MODE_FAST_REWIND 4 + +/* + * stop stream playback + * xine_stream_t stays valid for new xine_open or xine_play + */ +void xine_stop (xine_stream_t *stream); + +/* + * stop stream playback, free all stream-related resources + * xine_stream_t stays valid for new xine_open + */ +void xine_close (xine_stream_t *stream); + +/* + * ask current/recent input plugin to eject media - may or may not work, + * depending on input plugin capabilities + */ +int xine_eject (xine_stream_t *stream); + +/* + * stop playback, dispose all stream-related resources + * xine_stream_t no longer valid when after this + */ +void xine_dispose (xine_stream_t *stream); + +/* + * set/get engine parameters. + */ +void xine_engine_set_param(xine_t *self, int param, int value); +int xine_engine_get_param(xine_t *self, int param); + +#define XINE_ENGINE_PARAM_VERBOSITY 1 + +/* + * set/get xine stream parameters + * e.g. playback speed, constants see below + */ +void xine_set_param (xine_stream_t *stream, int param, int value); +int xine_get_param (xine_stream_t *stream, int param); + +/* + * xine engine parameters + */ +#define XINE_PARAM_SPEED 1 /* see below */ +#define XINE_PARAM_AV_OFFSET 2 /* unit: 1/90000 sec */ +#define XINE_PARAM_AUDIO_CHANNEL_LOGICAL 3 /* -1 => auto, -2 => off */ +#define XINE_PARAM_SPU_CHANNEL 4 +#define XINE_PARAM_VIDEO_CHANNEL 5 +#define XINE_PARAM_AUDIO_VOLUME 6 /* 0..100 */ +#define XINE_PARAM_AUDIO_MUTE 7 /* 1=>mute, 0=>unmute */ +#define XINE_PARAM_AUDIO_COMPR_LEVEL 8 /* <100=>off, % compress otherw*/ +#define XINE_PARAM_AUDIO_AMP_LEVEL 9 /* 0..200, 100=>100% (default) */ +#define XINE_PARAM_AUDIO_REPORT_LEVEL 10 /* 1=>send events, 0=> don't */ +#define XINE_PARAM_VERBOSITY 11 /* control console output */ +#define XINE_PARAM_SPU_OFFSET 12 /* unit: 1/90000 sec */ +#define XINE_PARAM_IGNORE_VIDEO 13 /* disable video decoding */ +#define XINE_PARAM_IGNORE_AUDIO 14 /* disable audio decoding */ +#define XINE_PARAM_IGNORE_SPU 15 /* disable spu decoding */ +#define XINE_PARAM_ENABLE_BROADCAST 16 /* (not implemented yet) */ +#define XINE_PARAM_METRONOM_PREBUFFER 17 /* unit: 1/90000 sec */ + + +/* speed values */ +#define XINE_SPEED_PAUSE 0 +#define XINE_SPEED_SLOW_4 1 +#define XINE_SPEED_SLOW_2 2 +#define XINE_SPEED_NORMAL 4 +#define XINE_SPEED_FAST_2 8 +#define XINE_SPEED_FAST_4 16 + +/* video parameters */ +#define XINE_PARAM_VO_DEINTERLACE 0x01000000 /* bool */ +#define XINE_PARAM_VO_ASPECT_RATIO 0x01000001 /* see below */ +#define XINE_PARAM_VO_HUE 0x01000002 /* 0..65535 */ +#define XINE_PARAM_VO_SATURATION 0x01000003 /* 0..65535 */ +#define XINE_PARAM_VO_CONTRAST 0x01000004 /* 0..65535 */ +#define XINE_PARAM_VO_BRIGHTNESS 0x01000005 /* 0..65535 */ +#define XINE_PARAM_VO_ZOOM_X 0x01000008 /* percent */ +#define XINE_PARAM_VO_ZOOM_Y 0x0100000d /* percent */ +#define XINE_PARAM_VO_PAN_SCAN 0x01000009 /* bool */ +#define XINE_PARAM_VO_TVMODE 0x0100000a /* ??? */ + +#define XINE_VO_ZOOM_STEP 100 +#define XINE_VO_ZOOM_MAX 400 +#define XINE_VO_ZOOM_MIN -85 + +/* possible ratios for XINE_PARAM_VO_ASPECT_RATIO */ +#define XINE_VO_ASPECT_AUTO 0 +#define XINE_VO_ASPECT_SQUARE 1 /* 1:1 */ +#define XINE_VO_ASPECT_4_3 2 /* 4:3 */ +#define XINE_VO_ASPECT_ANAMORPHIC 3 /* 16:9 */ +#define XINE_VO_ASPECT_DVB 4 /* 1:2 */ +#define XINE_VO_ASPECT_NUM_RATIOS 5 +#define XINE_VO_ASPECT_PAN_SCAN 41 +#define XINE_VO_ASPECT_DONT_TOUCH 42 + +/* stream format detection strategies */ + +/* recognize stream type first by content then by extension. */ +#define XINE_DEMUX_DEFAULT_STRATEGY 0 +/* recognize stream type first by extension then by content. */ +#define XINE_DEMUX_REVERT_STRATEGY 1 +/* recognize stream type by content only. */ +#define XINE_DEMUX_CONTENT_STRATEGY 2 +/* recognize stream type by extension only. */ +#define XINE_DEMUX_EXTENSION_STRATEGY 3 + +/* verbosity settings */ +#define XINE_VERBOSITY_NONE 0 +#define XINE_VERBOSITY_LOG 1 +#define XINE_VERBOSITY_DEBUG 2 + +/* + * snapshot function + * + * image format can be YUV 4:2:0 or 4:2:2 + * will copy the image data into memory that points to + * (interleaved for yuv 4:2:2 or planary for 4:2:0) + * + * returns 1 on success, 0 failure. + */ +int xine_get_current_frame (xine_stream_t *stream, + int *width, int *height, + int *ratio_code, int *format, + uint8_t *img); + +/* xine image formats */ +#define XINE_IMGFMT_YV12 (('2'<<24)|('1'<<16)|('V'<<8)|'Y') +#define XINE_IMGFMT_YUY2 (('2'<<24)|('Y'<<16)|('U'<<8)|'Y') + + +/********************************************************************* + * media processing * + *********************************************************************/ + +#ifdef XINE_ENABLE_EXPERIMENTAL_FEATURES + +/* + * access to decoded audio and video frames from a stream + * these functions are intended to provide the basis for + * re-encoding and other video processing applications + * + * warning: highly experimental + * + */ + +xine_video_port_t *xine_new_framegrab_video_port (xine_t *self); + +typedef struct { + + int64_t vpts; /* timestamp 1/90000 sec for a/v sync */ + int64_t duration; + int width, height; + int colorspace; /* XINE_IMGFMT_* */ + double aspect_ratio; + + int pos_stream; /* bytes from stream start */ + int pos_time; /* milliseconds */ + + uint8_t *data; + void *xine_frame; /* used internally by xine engine */ +} xine_video_frame_t; + +int xine_get_next_video_frame (xine_video_port_t *port, + xine_video_frame_t *frame); + +void xine_free_video_frame (xine_video_port_t *port, xine_video_frame_t *frame); + +xine_audio_port_t *xine_new_framegrab_audio_port (xine_t *self); + +typedef struct { + + int64_t vpts; /* timestamp 1/90000 sec for a/v sync */ + int num_samples; + int sample_rate; + int num_channels; + int bits_per_sample; /* per channel */ + + off_t pos_stream; /* bytes from stream start */ + int pos_time; /* milliseconds */ + + uint8_t *data; + void *xine_frame; /* used internally by xine engine */ +} xine_audio_frame_t; + +int xine_get_next_audio_frame (xine_audio_port_t *port, + xine_audio_frame_t *frame); + +void xine_free_audio_frame (xine_audio_port_t *port, xine_audio_frame_t *frame); + + /* + * maybe future aproach: + */ + +int xine_get_video_frame (xine_stream_t *stream, + int timestamp, /* msec */ + int *width, int *height, + int *ratio_code, + int *duration, /* msec */ + int *format, + uint8_t *img); + +/* TODO: xine_get_audio_frame */ + +#endif + + +/********************************************************************* + * post plugin handling * + *********************************************************************/ + +/* + * post effect plugin functions + * + * after the data leaves the decoder it can pass an arbitrary tree + * of post plugins allowing for effects to be applied to the video + * frames/audio buffers before they reach the output stage + */ + +typedef struct xine_post_s xine_post_t; + +struct xine_post_s { + + /* a NULL-terminated array of audio input ports this post plugin + * provides; you can hand these to other post plugin's outputs or + * pass them to the initialization of streams + */ + xine_audio_port_t **audio_input; + + /* a NULL-terminated array of video input ports this post plugin + * provides; you can hand these to other post plugin's outputs or + * pass them to the initialization of streams + */ + xine_video_port_t **video_input; + + /* the type of the post plugin + * one of XINE_POST_TYPE_* can be used here + */ + int type; + +}; + +/* + * initialize a post plugin + * + * returns xine_post_t* on success, NULL on failure + * + * Initializes the post plugin with the given name and connects its + * outputs to the NULL-terminated arrays of audio and video ports. + * Some plugins also care about the number of inputs you request + * (e.g. mixer plugins), others simply ignore this number. + */ +xine_post_t *xine_post_init(xine_t *xine, const char *name, + int inputs, + xine_audio_port_t **audio_target, + xine_video_port_t **video_target); + +/* get a list of all available post plugins */ +const char *const *xine_list_post_plugins(xine_t *xine); + +/* get a list of all post plugins of one type */ +const char *const *xine_list_post_plugins_typed(xine_t *xine, int type); + +/* + * post plugin input/output + * + * These structures encapsulate inputs/outputs for post plugins + * to transfer arbitrary data. Frontends can also provide inputs + * and outputs and connect them to post plugins to exchange data + * with them. + */ + +typedef struct xine_post_in_s xine_post_in_t; +typedef struct xine_post_out_s xine_post_out_t; + +struct xine_post_in_s { + + /* the name identifying this input */ + const char *name; + + /* the datatype of this input, use one of XINE_POST_DATA_* here */ + int type; + + /* the data pointer; input is directed to this memory location, + * so you simply access the pointer to access the input data */ + void *data; + +}; + +struct xine_post_out_s { + + /* the name identifying this output */ + const char *name; + + /* the datatype of this output, use one of XINE_POST_DATA_* here */ + int type; + + /* the data pointer; output should be directed to this memory location, + * so in the easy case you simply write through the pointer */ + void *data; + + /* this function is called, when the output should be redirected + * to another input, you sould set the data pointer to direct + * any output to this new input; + * a special situation is, when this function is called with a NULL + * argument: in this case you should disconnect the data pointer + * from any output and if necessary to avoid writing to some stray + * memory you should make it point to some dummy location, + * returns 1 on success, 0 on failure; + * if you do not implement rewiring, set this to NULL */ + int (*rewire) (xine_post_out_t *self, void *data); + +}; + +/* get a list of all inputs of a post plugin */ +const char *const *xine_post_list_inputs(xine_post_t *self); + +/* get a list of all outputs of a post plugin */ +const char *const *xine_post_list_outputs(xine_post_t *self); + +/* retrieve one specific input of a post plugin */ +const xine_post_in_t *xine_post_input(xine_post_t *self, char *name); + +/* retrieve one specific output of a post plugin */ +const xine_post_out_t *xine_post_output(xine_post_t *self, char *name); + +/* + * wire an input to an output + * returns 1 on success, 0 on failure + */ +int xine_post_wire(xine_post_out_t *source, xine_post_in_t *target); + +/* + * wire a video port to a video output + * This can be used to rewire different post plugins to the video output + * plugin layer. The ports you hand in at xine_post_init() will already + * be wired with the post plugin, so you need this function for + * _re_connecting only. + * + * returns 1 on success, 0 on failure + */ +int xine_post_wire_video_port(xine_post_out_t *source, xine_video_port_t *vo); + +/* + * wire an audio port to an audio output + * This can be used to rewire different post plugins to the audio output + * plugin layer. The ports you hand in at xine_post_init() will already + * be wired with the post plugin, so you need this function for + * _re_connecting only. + * + * returns 1 on success, 0 on failure + */ +int xine_post_wire_audio_port(xine_post_out_t *source, xine_audio_port_t *vo); + +/* + * Extracts an output for a stream. Use this to rewire the outputs of streams. + */ +xine_post_out_t * xine_get_video_source(xine_stream_t *stream); +xine_post_out_t * xine_get_audio_source(xine_stream_t *stream); + +/* + * disposes the post plugin + * please make sure that no other post plugin and no stream is + * connected to any of this plugin's inputs + */ +void xine_post_dispose(xine_t *xine, xine_post_t *self); + + +/* post plugin types */ +#define XINE_POST_TYPE_VIDEO_FILTER 0x010000 +#define XINE_POST_TYPE_VIDEO_VISUALIZATION 0x010001 +#define XINE_POST_TYPE_VIDEO_COMPOSE 0x010002 +#define XINE_POST_TYPE_AUDIO_FILTER 0x020000 +#define XINE_POST_TYPE_AUDIO_VISUALIZATION 0x020001 + + +/* post plugin data types */ + +/* video port data + * input->data is a xine_video_port_t* + * output->data usually is a xine_video_port_t** + */ +#define XINE_POST_DATA_VIDEO 0 + +/* audio port data + * input->data is a xine_audio_port_t* + * output->data usually is a xine_audio_port_t** + */ +#define XINE_POST_DATA_AUDIO 1 + +/* integer data + * input->data is a int* + * output->data usually is a int* + */ +#define XINE_POST_DATA_INT 3 + +/* double precision floating point data + * input->data is a double* + * output->data usually is a double* + */ +#define XINE_POST_DATA_DOUBLE 4 + + +/********************************************************************* + * information retrieval * + *********************************************************************/ + +/* + * xine log functions + * + * frontends can display xine log output using these functions + */ +int xine_get_log_section_count(xine_t *self); + +/* return a NULL terminated array of log sections names */ +const char *const *xine_get_log_names(xine_t *self); + +/* print some log information to section */ +void xine_log (xine_t *self, int buf, + const char *format, ...); + +/* get log messages of specified section */ +const char *const *xine_get_log (xine_t *self, int buf); + +/* log callback will be called whenever something is logged */ +typedef void (*xine_log_cb_t) (void *user_data, int section); +void xine_register_log_cb (xine_t *self, xine_log_cb_t cb, + void *user_data); + +/* + * error handling / engine status + */ + +/* return last error */ +int xine_get_error (xine_stream_t *stream); + +/* get current xine engine status (constants see below) */ +int xine_get_status (xine_stream_t *stream); + +/* + * engine status codes + */ +#define XINE_STATUS_IDLE 0 /* no mrl assigned */ +#define XINE_STATUS_STOP 1 +#define XINE_STATUS_PLAY 2 +#define XINE_STATUS_QUIT 3 + +/* + * xine error codes + */ +#define XINE_ERROR_NONE 0 +#define XINE_ERROR_NO_INPUT_PLUGIN 1 +#define XINE_ERROR_NO_DEMUX_PLUGIN 2 +#define XINE_ERROR_DEMUX_FAILED 3 +#define XINE_ERROR_MALFORMED_MRL 4 + +/* + * try to find out audio/spu language of given channel + * (use -1 for current channel) + * + * returns 1 on success, 0 on failure + */ +int xine_get_audio_lang (xine_stream_t *stream, int channel, + char *lang); +int xine_get_spu_lang (xine_stream_t *stream, int channel, + char *lang); + +/* + * get position / length information + * + * depending of the nature and system layer of the stream, + * some or all of this information may be unavailable or incorrect + * (e.g. live network streams may not have a valid length) + * + * returns 1 on success, 0 on failure (data was not updated, + * probably because it's not known yet... try again later) + */ +int xine_get_pos_length (xine_stream_t *stream, + int *pos_stream, /* 0..65535 */ + int *pos_time, /* milliseconds */ + int *length_time);/* milliseconds */ + +/* + * get information about the stream such as + * video width/height, codecs, audio format, title, author... + * + * constants see below + */ +uint32_t xine_get_stream_info (xine_stream_t *stream, int info); +const char *xine_get_meta_info (xine_stream_t *stream, int info); + +/* xine_get_stream_info */ +#define XINE_STREAM_INFO_BITRATE 0 +#define XINE_STREAM_INFO_SEEKABLE 1 +#define XINE_STREAM_INFO_VIDEO_WIDTH 2 +#define XINE_STREAM_INFO_VIDEO_HEIGHT 3 +#define XINE_STREAM_INFO_VIDEO_RATIO 4 /* *10000 */ +#define XINE_STREAM_INFO_VIDEO_CHANNELS 5 +#define XINE_STREAM_INFO_VIDEO_STREAMS 6 +#define XINE_STREAM_INFO_VIDEO_BITRATE 7 +#define XINE_STREAM_INFO_VIDEO_FOURCC 8 +#define XINE_STREAM_INFO_VIDEO_HANDLED 9 /* codec available? */ +#define XINE_STREAM_INFO_FRAME_DURATION 10 /* 1/90000 sec */ +#define XINE_STREAM_INFO_AUDIO_CHANNELS 11 +#define XINE_STREAM_INFO_AUDIO_BITS 12 +#define XINE_STREAM_INFO_AUDIO_SAMPLERATE 13 +#define XINE_STREAM_INFO_AUDIO_BITRATE 14 +#define XINE_STREAM_INFO_AUDIO_FOURCC 15 +#define XINE_STREAM_INFO_AUDIO_HANDLED 16 /* codec available? */ +#define XINE_STREAM_INFO_HAS_CHAPTERS 17 +#define XINE_STREAM_INFO_HAS_VIDEO 18 +#define XINE_STREAM_INFO_HAS_AUDIO 19 +#define XINE_STREAM_INFO_IGNORE_VIDEO 20 +#define XINE_STREAM_INFO_IGNORE_AUDIO 21 +#define XINE_STREAM_INFO_IGNORE_SPU 22 +#define XINE_STREAM_INFO_VIDEO_HAS_STILL 23 +#define XINE_STREAM_INFO_MAX_AUDIO_CHANNEL 24 +#define XINE_STREAM_INFO_MAX_SPU_CHANNEL 25 +#define XINE_STREAM_INFO_AUDIO_MODE 26 + +/* xine_get_meta_info */ +#define XINE_META_INFO_TITLE 0 +#define XINE_META_INFO_COMMENT 1 +#define XINE_META_INFO_ARTIST 2 +#define XINE_META_INFO_GENRE 3 +#define XINE_META_INFO_ALBUM 4 +#define XINE_META_INFO_YEAR 5 +#define XINE_META_INFO_VIDEOCODEC 6 +#define XINE_META_INFO_AUDIOCODEC 7 +#define XINE_META_INFO_SYSTEMLAYER 8 +#define XINE_META_INFO_INPUT_PLUGIN 9 + + +/********************************************************************* + * plugin management / autoplay / mrl browsing * + *********************************************************************/ + +/* + * note: the pointers to strings or string arrays returned + * by some of these functions are pointers to statically + * alloced internal xine memory chunks. + * they're only valid between xine function calls + * and should never be free()d. + */ + +typedef struct { + char *origin; /* file plugin: path */ + char *mrl; /* :// */ + char *link; + uint32_t type; /* see below */ + off_t size; /* size of this source, may be 0 */ +} xine_mrl_t; + +/* mrl types */ +#define XINE_MRL_TYPE_unknown (0 << 0) +#define XINE_MRL_TYPE_dvd (1 << 0) +#define XINE_MRL_TYPE_vcd (1 << 1) +#define XINE_MRL_TYPE_net (1 << 2) +#define XINE_MRL_TYPE_rtp (1 << 3) +#define XINE_MRL_TYPE_stdin (1 << 4) +#define XINE_MRL_TYPE_cda (1 << 5) +#define XINE_MRL_TYPE_file (1 << 6) +#define XINE_MRL_TYPE_file_fifo (1 << 7) +#define XINE_MRL_TYPE_file_chardev (1 << 8) +#define XINE_MRL_TYPE_file_directory (1 << 9) +#define XINE_MRL_TYPE_file_blockdev (1 << 10) +#define XINE_MRL_TYPE_file_normal (1 << 11) +#define XINE_MRL_TYPE_file_symlink (1 << 12) +#define XINE_MRL_TYPE_file_sock (1 << 13) +#define XINE_MRL_TYPE_file_exec (1 << 14) +#define XINE_MRL_TYPE_file_backup (1 << 15) +#define XINE_MRL_TYPE_file_hidden (1 << 16) + +/* get a list of browsable input plugin ids */ +const char *const *xine_get_browsable_input_plugin_ids (xine_t *self) ; + +/* + * ask input plugin named to return + * a list of available MRLs in domain/directory . + * + * may be NULL indicating the toplevel domain/dir + * returns if is a valid MRL, not a directory + * returns NULL if is an invalid MRL, not even a directory. + */ +xine_mrl_t **xine_get_browse_mrls (xine_t *self, + const char *plugin_id, + const char *start_mrl, + int *num_mrls); + +/* get a list of plugins that support the autoplay feature */ +const char *const *xine_get_autoplay_input_plugin_ids (xine_t *self); + +/* get autoplay MRL list from input plugin named */ +char **xine_get_autoplay_mrls (xine_t *self, + const char *plugin_id, + int *num_mrls); + +/* get a list of file extensions for file types supported by xine + * the list is separated by spaces + * + * the pointer returned can be free()ed when no longer used */ +char *xine_get_file_extensions (xine_t *self); + +/* get a list of mime types supported by xine + * + * the pointer returned can be free()ed when no longer used */ +char *xine_get_mime_types (xine_t *self); + +/* get the demuxer identifier that handles a given mime type + * + * the pointer returned can be free()ed when no longer used + * returns NULL if no demuxer is available to handle this. */ +char *xine_get_demux_for_mime_type (xine_t *self, const char *mime_type); + +/* get a description string for an input plugin */ +const char *xine_get_input_plugin_description (xine_t *self, + const char *plugin_id); + +/* get lists of available audio and video output plugins */ +const char *const *xine_list_audio_output_plugins (xine_t *self) ; +const char *const *xine_list_video_output_plugins (xine_t *self) ; + + +/********************************************************************* + * visual specific gui <-> xine engine communication * + *********************************************************************/ + +/* talk to video output driver - old method */ +int xine_gui_send_vo_data (xine_stream_t *self, + int type, void *data); + +/* new (preferred) method to talk to video driver. */ +int xine_port_send_gui_data (xine_video_port_t *vo, + int type, void *data); + +typedef struct { + + /* area of that drawable to be used by video */ + int x,y,w,h; + +} x11_rectangle_t; + +/* + * this is the visual data struct any x11 gui + * must supply to the xine_open_video_driver call + * ("data" parameter) + */ +typedef struct { + + /* some information about the display */ + void *display; /* Display* */ + int screen; + + /* drawable to display the video in/on */ + unsigned long d; /* Drawable */ + + void *user_data; + + /* + * dest size callback + * + * this will be called by the video driver to find out + * how big the video output area size will be for a + * given video size. The ui should _not_ adjust it's + * video out area, just do some calculations and return + * the size. This will be called for every frame, ui + * implementation should be fast. + * dest_pixel_aspect should be set to the used display pixel aspect. + * NOTE: Semantics has changed: video_width and video_height + * are no longer pixel aspect corrected. Get the old semantics + * in the UI with + * *dest_pixel_aspect = display_pixel_aspect; + * if (video_pixel_aspect >= display_pixel_aspect) + * video_width = video_width * video_pixel_aspect / display_pixel_aspect + .5; + * else + * video_height = video_height * display_pixel_aspect / video_pixel_aspect + .5; + */ + void (*dest_size_cb) (void *user_data, + int video_width, int video_height, + double video_pixel_aspect, + int *dest_width, int *dest_height, + double *dest_pixel_aspect); + + /* + * frame output callback + * + * this will be called by the video driver for every frame + * it's about to draw. ui can adapt it's size if necessary + * here. + * note: the ui doesn't have to adjust itself to this + * size, this is just to be taken as a hint. + * ui must return the actual size of the video output + * area and the video output driver will do it's best + * to adjust the video frames to that size (while + * preserving aspect ratio and stuff). + * dest_x, dest_y: offset inside window + * dest_width, dest_height: available drawing space + * dest_pixel_aspect: display pixel aspect + * win_x, win_y: window absolute screen position + * NOTE: Semantics has changed: video_width and video_height + * are no longer pixel aspect corrected. Get the old semantics + * in the UI with + * *dest_pixel_aspect = display_pixel_aspect; + * if (video_pixel_aspect >= display_pixel_aspect) + * video_width = video_width * video_pixel_aspect / display_pixel_aspect + .5; + * else + * video_height = video_height * display_pixel_aspect / video_pixel_aspect + .5; + */ + void (*frame_output_cb) (void *user_data, + int video_width, int video_height, + double video_pixel_aspect, + int *dest_x, int *dest_y, + int *dest_width, int *dest_height, + double *dest_pixel_aspect, + int *win_x, int *win_y); + +} x11_visual_t; + +/* + * this is the visual data struct any fb gui + * may supply to the xine_open_video_driver call + * ("data" parameter) to get frame_output_cd calls + */ + +typedef struct { + + void (*frame_output_cb) (void *user_data, + int video_width, int video_height, + double video_pixel_aspect, + int *dest_x, int *dest_y, + int *dest_width, int *dest_height, + double *dest_pixel_aspect, + int *win_x, int *win_y); + + void *user_data; + +} fb_visual_t; + +/* + * "type" constants for xine_gui_send_vo_data (...) + */ + +/* xevent *data */ +#define XINE_GUI_SEND_COMPLETION_EVENT 1 + +/* Drawable data */ +#define XINE_GUI_SEND_DRAWABLE_CHANGED 2 + +/* xevent *data */ +#define XINE_GUI_SEND_EXPOSE_EVENT 3 + +/* x11_rectangle_t *data */ +#define XINE_GUI_SEND_TRANSLATE_GUI_TO_VIDEO 4 + +/* int data */ +#define XINE_GUI_SEND_VIDEOWIN_VISIBLE 5 + +/* *data contains chosen visual, select a new one or change it to NULL + * to indicate the visual to use or that no visual will work */ +/* XVisualInfo **data */ +#define XINE_GUI_SEND_SELECT_VISUAL 8 + + +/********************************************************************* + * xine health check stuff * + *********************************************************************/ + +#define XINE_HEALTH_CHECK_OK 0 +#define XINE_HEALTH_CHECK_FAIL 1 +#define XINE_HEALTH_CHECK_UNSUPPORTED 2 +#define XINE_HEALTH_CHECK_NO_SUCH_CHECK 3 + +#define CHECK_KERNEL 0 +#define CHECK_MTRR 1 +#define CHECK_CDROM 2 +#define CHECK_DVDROM 3 +#define CHECK_DMA 4 +#define CHECK_X 5 +#define CHECK_XV 6 + +struct xine_health_check_s { + int status; + const char* cdrom_dev; + const char* dvd_dev; + char* msg; + char* title; + char* explanation; +}; + +typedef struct xine_health_check_s xine_health_check_t; +xine_health_check_t* xine_health_check(xine_health_check_t*, int check_num); + + +/********************************************************************* + * configuration system * + *********************************************************************/ + +/* + * config entry data types + */ + +#define XINE_CONFIG_TYPE_UNKNOWN 0 +#define XINE_CONFIG_TYPE_RANGE 1 +#define XINE_CONFIG_TYPE_STRING 2 +#define XINE_CONFIG_TYPE_ENUM 3 +#define XINE_CONFIG_TYPE_NUM 4 +#define XINE_CONFIG_TYPE_BOOL 5 + +typedef struct xine_cfg_entry_s xine_cfg_entry_t; + +typedef void (*xine_config_cb_t) (void *user_data, + xine_cfg_entry_t *entry); +struct xine_cfg_entry_s { + const char *key; /* unique id (example: gui.logo_mrl) */ + + int type; + + /* type unknown */ + char *unknown_value; + + /* type string */ + char *str_value; + char *str_default; + char *str_sticky; + + /* common to range, enum, num, bool: */ + int num_value; + int num_default; + + /* type range specific: */ + int range_min; + int range_max; + + /* type enum specific: */ + char **enum_values; + + /* help info for the user */ + const char *description; + const char *help; + + /* user experience level */ + int exp_level; /* 0 => beginner, + 10 => advanced user, + 20 => expert */ + + /* callback function and data for live changeable values */ + xine_config_cb_t callback; + void *callback_data; + +}; + +const char *xine_config_register_string (xine_t *self, + const char *key, + const char *def_value, + const char *description, + const char *help, + int exp_level, + xine_config_cb_t changed_cb, + void *cb_data); + +int xine_config_register_range (xine_t *self, + const char *key, + int def_value, + int min, int max, + const char *description, + const char *help, + int exp_level, + xine_config_cb_t changed_cb, + void *cb_data); + +int xine_config_register_enum (xine_t *self, + const char *key, + int def_value, + char **values, + const char *description, + const char *help, + int exp_level, + xine_config_cb_t changed_cb, + void *cb_data); + +int xine_config_register_num (xine_t *self, + const char *key, + int def_value, + const char *description, + const char *help, + int exp_level, + xine_config_cb_t changed_cb, + void *cb_data); + +int xine_config_register_bool (xine_t *self, + const char *key, + int def_value, + const char *description, + const char *help, + int exp_level, + xine_config_cb_t changed_cb, + void *cb_data); + +/* + * the following functions will copy data from the internal xine_config + * data database to the xine_cfg_entry_t *entry you provide + * + * they return 1 on success, 0 on failure + */ + +/* get first config item */ +int xine_config_get_first_entry (xine_t *self, xine_cfg_entry_t *entry); + +/* get next config item (iterate through the items) */ +int xine_config_get_next_entry (xine_t *self, xine_cfg_entry_t *entry); + +/* search for a config entry by key */ +int xine_config_lookup_entry (xine_t *self, const char *key, + xine_cfg_entry_t *entry); + +/* + * update a config entry (which was returned from lookup_entry() ) + * + * xine will make a deep copy of the data in the entry into it's internal + * config database. + */ +void xine_config_update_entry (xine_t *self, + const xine_cfg_entry_t *entry); + +/* + * load/save config data from/to afile (e.g. $HOME/.xine/config) + */ +void xine_config_load (xine_t *self, const char *cfg_filename); +void xine_config_save (xine_t *self, const char *cfg_filename); +void xine_config_reset (xine_t *self); + + +/********************************************************************* + * asynchroneous xine event mechanism * + *********************************************************************/ + +/* + * to receive events you have to register an event queue with + * the xine engine (xine_event_new_queue, see below). + * + * then you can either + * 1) check for incoming events regularly (xine_event_get/wait), + * process them and free them using xine_event_free + * 2) use xine_event_create_listener_thread and specify a callback + * which will then be called for each event + * + * to send events to every module listening you don't need + * to register an event queue but simply call xine_event_send. + */ + +/* event types */ +#define XINE_EVENT_UI_PLAYBACK_FINISHED 1 /* frontend can e.g. move on to next playlist entry */ +#define XINE_EVENT_UI_CHANNELS_CHANGED 2 /* inform ui that new channel info is available */ +#define XINE_EVENT_UI_SET_TITLE 3 /* request title display change in ui */ +#define XINE_EVENT_UI_MESSAGE 4 /* message (dialog) for the ui to display */ +#define XINE_EVENT_FRAME_FORMAT_CHANGE 5 /* e.g. aspect ratio change during dvd playback */ +#define XINE_EVENT_AUDIO_LEVEL 6 /* report current audio level (l/r) */ +#define XINE_EVENT_QUIT 7 /* last event sent when stream is disposed */ +#define XINE_EVENT_PROGRESS 8 /* index creation/network connections */ +#define XINE_EVENT_MRL_REFERENCE 9 /* demuxer->frontend: MRL reference(s) for the real stream */ +#define XINE_EVENT_UI_NUM_BUTTONS 10 /* number of buttons for interactive menus */ + +/* input events coming from frontend */ +#define XINE_EVENT_INPUT_MOUSE_BUTTON 101 +#define XINE_EVENT_INPUT_MOUSE_MOVE 102 +#define XINE_EVENT_INPUT_MENU1 103 +#define XINE_EVENT_INPUT_MENU2 104 +#define XINE_EVENT_INPUT_MENU3 105 +#define XINE_EVENT_INPUT_MENU4 106 +#define XINE_EVENT_INPUT_MENU5 107 +#define XINE_EVENT_INPUT_MENU6 108 +#define XINE_EVENT_INPUT_MENU7 109 +#define XINE_EVENT_INPUT_UP 110 +#define XINE_EVENT_INPUT_DOWN 111 +#define XINE_EVENT_INPUT_LEFT 112 +#define XINE_EVENT_INPUT_RIGHT 113 +#define XINE_EVENT_INPUT_SELECT 114 +#define XINE_EVENT_INPUT_NEXT 115 +#define XINE_EVENT_INPUT_PREVIOUS 116 +#define XINE_EVENT_INPUT_ANGLE_NEXT 117 +#define XINE_EVENT_INPUT_ANGLE_PREVIOUS 118 +#define XINE_EVENT_INPUT_BUTTON_FORCE 119 +#define XINE_EVENT_INPUT_NUMBER_0 120 +#define XINE_EVENT_INPUT_NUMBER_1 121 +#define XINE_EVENT_INPUT_NUMBER_2 122 +#define XINE_EVENT_INPUT_NUMBER_3 123 +#define XINE_EVENT_INPUT_NUMBER_4 124 +#define XINE_EVENT_INPUT_NUMBER_5 125 +#define XINE_EVENT_INPUT_NUMBER_6 126 +#define XINE_EVENT_INPUT_NUMBER_7 127 +#define XINE_EVENT_INPUT_NUMBER_8 128 +#define XINE_EVENT_INPUT_NUMBER_9 129 +#define XINE_EVENT_INPUT_NUMBER_10_ADD 130 + +/* specific event types */ +#define XINE_EVENT_SET_V4L2 200 +#define XINE_EVENT_PVR_SAVE 201 +#define XINE_EVENT_PVR_REPORT_NAME 202 +#define XINE_EVENT_PVR_REALTIME 203 + +/* + * xine event struct + */ +typedef struct { + int type; /* event type (constants see above) */ + xine_stream_t *stream; /* stream this event belongs to */ + + void *data; /* contents depending on type */ + int data_length; + + /* you do not have to provide this, it will be filled in by xine_event_send() */ + struct timeval tv; /* timestamp of event creation */ +} xine_event_t; + +/* + * input event dynamic data + */ +typedef struct { + xine_event_t event; + uint8_t button; /* Generally 1 = left, 2 = mid, 3 = right */ + uint16_t x,y; /* In Image space */ +} xine_input_data_t; + +/* + * UI event dynamic data - send information to/from UI. + */ +typedef struct { + int num_buttons; + int str_len; + char str[256]; /* might be longer */ +} xine_ui_data_t; + +/* + * Send messages to UI. used mostly to report errors. + */ +typedef struct { + /* + * old xine-ui versions expect xine_ui_data_t type. + * this struct is added for compatibility. + */ + xine_ui_data_t compatibility; + + /* See XINE_MSG_xxx for defined types. */ + int type; + + /* defined types are provided with a standard explanation. + * note: zero means no explanation. + */ + int explanation; /* add to struct address to get a valid (char *) */ + + /* parameters are zero terminated strings */ + int num_parameters; + int parameters; /* add to struct address to get a valid (char *) */ + + /* where messages are stored, will be longer + * + * this field begins with the message text itself (\0-terminated), + * followed by (optional) \0-terminated parameter strings + * the end marker is \0 \0 + */ + char messages[1]; +} xine_ui_message_data_t; + + +/* + * notify frame format change + */ +typedef struct { + int width; + int height; + int aspect; +} xine_format_change_data_t; + +/* + * audio level for left/right channel + */ +typedef struct { + int left; + int right; /* 0..255 */ +} xine_audio_level_data_t; + +/* + * index generation / buffering + */ +typedef struct { + const char *description; /* e.g. "connecting..." */ + int percent; +} xine_progress_data_t; + +/* + * mrl reference data is sent by demuxers when a reference stream is found. + * this stream just contains pointers (urls) to the real data, which are + * passed to frontend using this event type. (examples: .asx, .mov and .ram) + * + * ideally, frontends should add these mrls to a "hierarchical playlist". + * that is, instead of the original file, the ones provided here should be + * played instead. on pratice, just using a simple playlist should work. + * + * mrl references should be played in the same order they are received, just + * after the current stream finishes. + * alternative playlists may be provided and should be used in case of + * failure of the primary playlist. + */ +typedef struct { + int alternative; /* alternative playlist number, usually 0 */ + char mrl[1]; /* might (will) be longer */ +} xine_mrl_reference_data_t; + + +#ifdef XINE_ENABLE_EXPERIMENTAL_FEATURES + +/* + * configuration options for video4linux-like input plugins + */ +typedef struct { + /* input selection */ + int input; /* select active input from card */ + int channel; /* channel number */ + int radio; /* ask for a radio channel */ + uint32_t frequency; /* frequency divided by 62.5KHz or 62.5 Hz */ + uint32_t transmission; /* The transmission standard. */ + + /* video parameters */ + uint32_t framerate_numerator; /* framerate as numerator/denominator */ + uint32_t framerate_denominator; + uint32_t framelines; /* Total lines per frame including blanking */ + uint32_t colorstandard; /* One of the V4L2_COLOR_STD_* values */ + uint32_t colorsubcarrier; /* The color subcarrier frequency */ + int frame_width; /* scaled frame width */ + int frame_height; /* scaled frame height */ + + /* used by pvr plugin */ + int32_t session_id; /* -1 stops pvr recording */ +} xine_set_v4l2_data_t; + +/* + * ask pvr to save (ie. do not discard) the current session + * see comments on input_pvr.c to understand how it works. + */ +typedef struct { + /* mode values: + * -1 = do nothing, just set the name + * 0 = truncate current session and save from now on + * 1 = save from last sync point + * 2 = save everything on current session + */ + int mode; + int id; + char name[256]; /* name for saving, might be longer */ +} xine_pvr_save_data_t; + +typedef struct { + /* mode values: + * 0 = non realtime + * 1 = realtime + */ + int mode; +} xine_pvr_realtime_t; + +#endif + +/* + * Defined message types for XINE_EVENT_UI_MESSAGE + * This is the mechanism to report async errors from engine. + * + * If frontend knows about the XINE_MSG_xxx type it may safely + * ignore the 'explanation' field and provide it's own custom + * dialog to the 'parameters'. + * + * right column specifies the usual parameters. + */ + +#define XINE_MSG_NO_ERROR 0 /* (messages to UI) */ +#define XINE_MSG_GENERAL_WARNING 1 /* (warning message) */ +#define XINE_MSG_UNKNOWN_HOST 2 /* (host name) */ +#define XINE_MSG_UNKNOWN_DEVICE 3 /* (device name) */ +#define XINE_MSG_NETWORK_UNREACHABLE 4 /* none */ +#define XINE_MSG_CONNECTION_REFUSED 5 /* (host name) */ +#define XINE_MSG_FILE_NOT_FOUND 6 /* (file name or mrl) */ +#define XINE_MSG_READ_ERROR 7 /* (device/file/mrl) */ +#define XINE_MSG_LIBRARY_LOAD_ERROR 8 /* (library/decoder) */ +#define XINE_MSG_ENCRYPTED_SOURCE 9 /* none */ + +/* opaque xine_event_queue_t */ +typedef struct xine_event_queue_s xine_event_queue_t; + +/* + * register a new event queue + * + * you have to receive messages from this queue regularly + * + * use xine_event_dispose_queue to unregister and free the queue + */ +xine_event_queue_t *xine_event_new_queue (xine_stream_t *stream); +void xine_event_dispose_queue (xine_event_queue_t *queue); + +/* + * receive events (poll) + * + * use xine_event_free on the events received from these calls + * when they're no longer needed + */ +xine_event_t *xine_event_get (xine_event_queue_t *queue); +xine_event_t *xine_event_wait (xine_event_queue_t *queue); +void xine_event_free (xine_event_t *event); + +/* + * receive events (callback) + * + * a thread is created which will receive all events from + * the specified queue, call your callback on each of them + * and will then free the event when your callback returns + * + */ +typedef void (*xine_event_listener_cb_t) (void *user_data, + const xine_event_t *event); +void xine_event_create_listener_thread (xine_event_queue_t *queue, + xine_event_listener_cb_t callback, + void *user_data); + +/* + * send an event to all queues + * + * the event will be copied so you can free or reuse + * *event as soon as xine_event_send returns. + */ +void xine_event_send (xine_stream_t *stream, const xine_event_t *event); + + +/********************************************************************* + * OSD (on screen display) * + *********************************************************************/ + +#define XINE_TEXT_PALETTE_SIZE 11 + +#define XINE_OSD_TEXT1 (0 * XINE_TEXT_PALETTE_SIZE) +#define XINE_OSD_TEXT2 (1 * XINE_TEXT_PALETTE_SIZE) +#define XINE_OSD_TEXT3 (2 * XINE_TEXT_PALETTE_SIZE) +#define XINE_OSD_TEXT4 (3 * XINE_TEXT_PALETTE_SIZE) +#define XINE_OSD_TEXT5 (4 * XINE_TEXT_PALETTE_SIZE) +#define XINE_OSD_TEXT6 (5 * XINE_TEXT_PALETTE_SIZE) +#define XINE_OSD_TEXT7 (6 * XINE_TEXT_PALETTE_SIZE) +#define XINE_OSD_TEXT8 (7 * XINE_TEXT_PALETTE_SIZE) +#define XINE_OSD_TEXT9 (8 * XINE_TEXT_PALETTE_SIZE) +#define XINE_OSD_TEXT10 (9 * XINE_TEXT_PALETTE_SIZE) + +/* white text, black border, transparent background */ +#define XINE_TEXTPALETTE_WHITE_BLACK_TRANSPARENT 0 +/* white text, noborder, transparent background */ +#define XINE_TEXTPALETTE_WHITE_NONE_TRANSPARENT 1 +/* white text, no border, translucid background */ +#define XINE_TEXTPALETTE_WHITE_NONE_TRANSLUCID 2 +/* yellow text, black border, transparent background */ +#define XINE_TEXTPALETTE_YELLOW_BLACK_TRANSPARENT 3 + +typedef struct xine_osd_s xine_osd_t; + +xine_osd_t *xine_osd_new (xine_stream_t *self, int x, int y, + int width, int height); +void xine_osd_draw_point (xine_osd_t *self, int x, int y, int color); + +void xine_osd_draw_line (xine_osd_t *self, int x1, int y1, + int x2, int y2, int color); +void xine_osd_draw_rect (xine_osd_t *self, int x1, int y1, + int x2, int y2, + int color, int filled ); +/* for freetype2 fonts x1 and y1 specifies the beginning of the baseline, + for xine fonts x1 and y1 specifies the upper left corner of the text + to be rendered */ +void xine_osd_draw_text (xine_osd_t *self, int x1, int y1, + const char *text, int color_base); +void xine_osd_draw_bitmap (xine_osd_t *self, uint8_t *bitmap, + int x1, int y1, int width, int height, + uint8_t *palette_map); +/* for freetype2 fonts the height is taken from _baseline_ to top */ +void xine_osd_get_text_size (xine_osd_t *self, const char *text, + int *width, int *height); +/* with freetype2 support compiled in, you can also specify a font file + as 'fontname' here */ +void xine_osd_set_font (xine_osd_t *self, const char *fontname, + int size); +/* set position were overlay will be blended */ +void xine_osd_set_position (xine_osd_t *self, int x, int y); +void xine_osd_show (xine_osd_t *self, int64_t vpts); +void xine_osd_hide (xine_osd_t *self, int64_t vpts); +/* empty drawing area */ +void xine_osd_clear (xine_osd_t *self); +/* + * close osd rendering engine + * loaded fonts are unloaded + * osd objects are closed + */ +void xine_osd_free (xine_osd_t *self); +void xine_osd_set_palette (xine_osd_t *self, + const uint32_t *const color, + const uint8_t *const trans ); +/* + * set on existing text palette + * (-1 to set used specified palette) + * + * color_base specifies the first color index to use for this text + * palette. The OSD palette is then modified starting at this + * color index, up to the size of the text palette. + * + * Use OSD_TEXT1, OSD_TEXT2, ... for some preassigned color indices. + */ +void xine_osd_set_text_palette (xine_osd_t *self, + int palette_number, + int color_base ); +/* get palette (color and transparency) */ +void xine_osd_get_palette (xine_osd_t *self, uint32_t *color, + uint8_t *trans); + + +/********************************************************************* + * TV-mode API, to make it possible to use nvtvd to view movies * + *********************************************************************/ + +/* connect to nvtvd server and save current TV and X settings */ +void xine_tvmode_init (xine_t *self); + +/* try to change TV state if enabled + * type select 'regular' (0) or 'TV' (1) state + * width frame width the mode should match best or 0 if unknown + * height frame height the mode should match best or 0 if unknown + * fps frame rate the mode should match best or 0 if unknown + * returns: finally selected state + */ +int xine_tvmode_switch (xine_t *self, int type, int width, int height, double fps); + +/* adapt (maximum) output size to visible area if necessary and return pixel + * aspect and real frame rate if available + */ +void xine_tvmode_size (xine_t *self, int *width, int *height, + double *pixelratio, double *fps); + +/* restore old TV and X settings and close nvtvd connection */ +void xine_tvmode_exit (xine_t *self); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/win32/include/xine/xineutils.h b/win32/include/xine/xineutils.h new file mode 100644 index 000000000..33696e718 --- /dev/null +++ b/win32/include/xine/xineutils.h @@ -0,0 +1,957 @@ +/* + * Copyright (C) 2000-2002 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: xineutils.h,v 1.1 2003/04/20 16:42:10 guenter Exp $ + * + */ +#ifndef XINEUTILS_H +#define XINEUTILS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include "attributes.h" +#include "compat.h" +#include "xmlparser.h" +#include "xine_buffer.h" +#include "configfile.h" + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#if defined(__SUNPRO_C) || !defined(XINE_COMPILE) +#define inline +#endif + + /* + * debugable mutexes + */ + + typedef struct { + pthread_mutex_t mutex; + char id[80]; + char *locked_by; + } xine_mutex_t; + + int xine_mutex_init (xine_mutex_t *mutex, const pthread_mutexattr_t *mutexattr, + char *id); + + int xine_mutex_lock (xine_mutex_t *mutex, char *who); + int xine_mutex_unlock (xine_mutex_t *mutex, char *who); + int xine_mutex_destroy (xine_mutex_t *mutex); + + + + /* CPU Acceleration */ + +/* + * The type of an value that fits in an MMX register (note that long + * long constant values MUST be suffixed by LL and unsigned long long + * values by ULL, lest they be truncated by the compiler) + */ + +/* generic accelerations */ +#define MM_ACCEL_MLIB 0x00000001 + +/* x86 accelerations */ +#define MM_ACCEL_X86_MMX 0x80000000 +#define MM_ACCEL_X86_3DNOW 0x40000000 +#define MM_ACCEL_X86_MMXEXT 0x20000000 +#define MM_ACCEL_X86_SSE 0x10000000 +#define MM_ACCEL_X86_SSE2 0x08000000 +/* powerpc accelerations */ +#define MM_ACCEL_PPC_ALTIVEC 0x04000000 +/* x86 compat defines */ +#define MM_MMX MM_ACCEL_X86_MMX +#define MM_3DNOW MM_ACCEL_X86_3DNOW +#define MM_MMXEXT MM_ACCEL_X86_MMXEXT +#define MM_SSE MM_ACCEL_X86_SSE +#define MM_SSE2 MM_ACCEL_X86_SSE2 + +uint32_t xine_mm_accel (void); +/* uint32_t xine_mm_support (void) ; */ + +#ifdef ARCH_X86 + +typedef union { +#ifdef _MSC_VER + int64_t q; /* Quadword (64-bit) value */ + uint64_t uq; /* Unsigned Quadword */ +#else + long long q; /* Quadword (64-bit) value */ + unsigned long long uq; /* Unsigned Quadword */ +#endif + int d[2]; /* 2 Doubleword (32-bit) values */ + unsigned int ud[2]; /* 2 Unsigned Doubleword */ + short w[4]; /* 4 Word (16-bit) values */ + unsigned short uw[4]; /* 4 Unsigned Word */ + char b[8]; /* 8 Byte (8-bit) values */ + unsigned char ub[8]; /* 8 Unsigned Byte */ + float s[2]; /* Single-precision (32-bit) value */ +} ATTR_ALIGN(8) mmx_t; /* On an 8-byte (64-bit) boundary */ + + + +#define mmx_i2r(op,imm,reg) \ + __asm__ __volatile__ (#op " %0, %%" #reg \ + : /* nothing */ \ + : "i" (imm) ) + +#define mmx_m2r(op,mem,reg) \ + __asm__ __volatile__ (#op " %0, %%" #reg \ + : /* nothing */ \ + : "m" (mem)) + +#define mmx_r2m(op,reg,mem) \ + __asm__ __volatile__ (#op " %%" #reg ", %0" \ + : "=m" (mem) \ + : /* nothing */ ) + +#define mmx_r2r(op,regs,regd) \ + __asm__ __volatile__ (#op " %" #regs ", %" #regd) + + +#define emms() __asm__ __volatile__ ("emms") + +#define movd_m2r(var,reg) mmx_m2r (movd, var, reg) +#define movd_r2m(reg,var) mmx_r2m (movd, reg, var) +#define movd_r2r(regs,regd) mmx_r2r (movd, regs, regd) + +#define movq_m2r(var,reg) mmx_m2r (movq, var, reg) +#define movq_r2m(reg,var) mmx_r2m (movq, reg, var) +#define movq_r2r(regs,regd) mmx_r2r (movq, regs, regd) + +#define packssdw_m2r(var,reg) mmx_m2r (packssdw, var, reg) +#define packssdw_r2r(regs,regd) mmx_r2r (packssdw, regs, regd) +#define packsswb_m2r(var,reg) mmx_m2r (packsswb, var, reg) +#define packsswb_r2r(regs,regd) mmx_r2r (packsswb, regs, regd) + +#define packuswb_m2r(var,reg) mmx_m2r (packuswb, var, reg) +#define packuswb_r2r(regs,regd) mmx_r2r (packuswb, regs, regd) + +#define paddb_m2r(var,reg) mmx_m2r (paddb, var, reg) +#define paddb_r2r(regs,regd) mmx_r2r (paddb, regs, regd) +#define paddd_m2r(var,reg) mmx_m2r (paddd, var, reg) +#define paddd_r2r(regs,regd) mmx_r2r (paddd, regs, regd) +#define paddw_m2r(var,reg) mmx_m2r (paddw, var, reg) +#define paddw_r2r(regs,regd) mmx_r2r (paddw, regs, regd) + +#define paddsb_m2r(var,reg) mmx_m2r (paddsb, var, reg) +#define paddsb_r2r(regs,regd) mmx_r2r (paddsb, regs, regd) +#define paddsw_m2r(var,reg) mmx_m2r (paddsw, var, reg) +#define paddsw_r2r(regs,regd) mmx_r2r (paddsw, regs, regd) + +#define paddusb_m2r(var,reg) mmx_m2r (paddusb, var, reg) +#define paddusb_r2r(regs,regd) mmx_r2r (paddusb, regs, regd) +#define paddusw_m2r(var,reg) mmx_m2r (paddusw, var, reg) +#define paddusw_r2r(regs,regd) mmx_r2r (paddusw, regs, regd) + +#define pand_m2r(var,reg) mmx_m2r (pand, var, reg) +#define pand_r2r(regs,regd) mmx_r2r (pand, regs, regd) + +#define pandn_m2r(var,reg) mmx_m2r (pandn, var, reg) +#define pandn_r2r(regs,regd) mmx_r2r (pandn, regs, regd) + +#define pcmpeqb_m2r(var,reg) mmx_m2r (pcmpeqb, var, reg) +#define pcmpeqb_r2r(regs,regd) mmx_r2r (pcmpeqb, regs, regd) +#define pcmpeqd_m2r(var,reg) mmx_m2r (pcmpeqd, var, reg) +#define pcmpeqd_r2r(regs,regd) mmx_r2r (pcmpeqd, regs, regd) +#define pcmpeqw_m2r(var,reg) mmx_m2r (pcmpeqw, var, reg) +#define pcmpeqw_r2r(regs,regd) mmx_r2r (pcmpeqw, regs, regd) + +#define pcmpgtb_m2r(var,reg) mmx_m2r (pcmpgtb, var, reg) +#define pcmpgtb_r2r(regs,regd) mmx_r2r (pcmpgtb, regs, regd) +#define pcmpgtd_m2r(var,reg) mmx_m2r (pcmpgtd, var, reg) +#define pcmpgtd_r2r(regs,regd) mmx_r2r (pcmpgtd, regs, regd) +#define pcmpgtw_m2r(var,reg) mmx_m2r (pcmpgtw, var, reg) +#define pcmpgtw_r2r(regs,regd) mmx_r2r (pcmpgtw, regs, regd) + +#define pmaddwd_m2r(var,reg) mmx_m2r (pmaddwd, var, reg) +#define pmaddwd_r2r(regs,regd) mmx_r2r (pmaddwd, regs, regd) + +#define pmulhw_m2r(var,reg) mmx_m2r (pmulhw, var, reg) +#define pmulhw_r2r(regs,regd) mmx_r2r (pmulhw, regs, regd) + +#define pmullw_m2r(var,reg) mmx_m2r (pmullw, var, reg) +#define pmullw_r2r(regs,regd) mmx_r2r (pmullw, regs, regd) + +#define por_m2r(var,reg) mmx_m2r (por, var, reg) +#define por_r2r(regs,regd) mmx_r2r (por, regs, regd) + +#define pslld_i2r(imm,reg) mmx_i2r (pslld, imm, reg) +#define pslld_m2r(var,reg) mmx_m2r (pslld, var, reg) +#define pslld_r2r(regs,regd) mmx_r2r (pslld, regs, regd) +#define psllq_i2r(imm,reg) mmx_i2r (psllq, imm, reg) +#define psllq_m2r(var,reg) mmx_m2r (psllq, var, reg) +#define psllq_r2r(regs,regd) mmx_r2r (psllq, regs, regd) +#define psllw_i2r(imm,reg) mmx_i2r (psllw, imm, reg) +#define psllw_m2r(var,reg) mmx_m2r (psllw, var, reg) +#define psllw_r2r(regs,regd) mmx_r2r (psllw, regs, regd) + +#define psrad_i2r(imm,reg) mmx_i2r (psrad, imm, reg) +#define psrad_m2r(var,reg) mmx_m2r (psrad, var, reg) +#define psrad_r2r(regs,regd) mmx_r2r (psrad, regs, regd) +#define psraw_i2r(imm,reg) mmx_i2r (psraw, imm, reg) +#define psraw_m2r(var,reg) mmx_m2r (psraw, var, reg) +#define psraw_r2r(regs,regd) mmx_r2r (psraw, regs, regd) + +#define psrld_i2r(imm,reg) mmx_i2r (psrld, imm, reg) +#define psrld_m2r(var,reg) mmx_m2r (psrld, var, reg) +#define psrld_r2r(regs,regd) mmx_r2r (psrld, regs, regd) +#define psrlq_i2r(imm,reg) mmx_i2r (psrlq, imm, reg) +#define psrlq_m2r(var,reg) mmx_m2r (psrlq, var, reg) +#define psrlq_r2r(regs,regd) mmx_r2r (psrlq, regs, regd) +#define psrlw_i2r(imm,reg) mmx_i2r (psrlw, imm, reg) +#define psrlw_m2r(var,reg) mmx_m2r (psrlw, var, reg) +#define psrlw_r2r(regs,regd) mmx_r2r (psrlw, regs, regd) + +#define psubb_m2r(var,reg) mmx_m2r (psubb, var, reg) +#define psubb_r2r(regs,regd) mmx_r2r (psubb, regs, regd) +#define psubd_m2r(var,reg) mmx_m2r (psubd, var, reg) +#define psubd_r2r(regs,regd) mmx_r2r (psubd, regs, regd) +#define psubw_m2r(var,reg) mmx_m2r (psubw, var, reg) +#define psubw_r2r(regs,regd) mmx_r2r (psubw, regs, regd) + +#define psubsb_m2r(var,reg) mmx_m2r (psubsb, var, reg) +#define psubsb_r2r(regs,regd) mmx_r2r (psubsb, regs, regd) +#define psubsw_m2r(var,reg) mmx_m2r (psubsw, var, reg) +#define psubsw_r2r(regs,regd) mmx_r2r (psubsw, regs, regd) + +#define psubusb_m2r(var,reg) mmx_m2r (psubusb, var, reg) +#define psubusb_r2r(regs,regd) mmx_r2r (psubusb, regs, regd) +#define psubusw_m2r(var,reg) mmx_m2r (psubusw, var, reg) +#define psubusw_r2r(regs,regd) mmx_r2r (psubusw, regs, regd) + +#define punpckhbw_m2r(var,reg) mmx_m2r (punpckhbw, var, reg) +#define punpckhbw_r2r(regs,regd) mmx_r2r (punpckhbw, regs, regd) +#define punpckhdq_m2r(var,reg) mmx_m2r (punpckhdq, var, reg) +#define punpckhdq_r2r(regs,regd) mmx_r2r (punpckhdq, regs, regd) +#define punpckhwd_m2r(var,reg) mmx_m2r (punpckhwd, var, reg) +#define punpckhwd_r2r(regs,regd) mmx_r2r (punpckhwd, regs, regd) + +#define punpcklbw_m2r(var,reg) mmx_m2r (punpcklbw, var, reg) +#define punpcklbw_r2r(regs,regd) mmx_r2r (punpcklbw, regs, regd) +#define punpckldq_m2r(var,reg) mmx_m2r (punpckldq, var, reg) +#define punpckldq_r2r(regs,regd) mmx_r2r (punpckldq, regs, regd) +#define punpcklwd_m2r(var,reg) mmx_m2r (punpcklwd, var, reg) +#define punpcklwd_r2r(regs,regd) mmx_r2r (punpcklwd, regs, regd) + +#define pxor_m2r(var,reg) mmx_m2r (pxor, var, reg) +#define pxor_r2r(regs,regd) mmx_r2r (pxor, regs, regd) + + +/* 3DNOW extensions */ + +#define pavgusb_m2r(var,reg) mmx_m2r (pavgusb, var, reg) +#define pavgusb_r2r(regs,regd) mmx_r2r (pavgusb, regs, regd) + + +/* AMD MMX extensions - also available in intel SSE */ + + +#define mmx_m2ri(op,mem,reg,imm) \ + __asm__ __volatile__ (#op " %1, %0, %%" #reg \ + : /* nothing */ \ + : "X" (mem), "X" (imm)) +#define mmx_r2ri(op,regs,regd,imm) \ + __asm__ __volatile__ (#op " %0, %%" #regs ", %%" #regd \ + : /* nothing */ \ + : "X" (imm) ) + +#define mmx_fetch(mem,hint) \ + __asm__ __volatile__ ("prefetch" #hint " %0" \ + : /* nothing */ \ + : "X" (mem)) + + +#define maskmovq(regs,maskreg) mmx_r2ri (maskmovq, regs, maskreg) + +#define movntq_r2m(mmreg,var) mmx_r2m (movntq, mmreg, var) + +#define pavgb_m2r(var,reg) mmx_m2r (pavgb, var, reg) +#define pavgb_r2r(regs,regd) mmx_r2r (pavgb, regs, regd) +#define pavgw_m2r(var,reg) mmx_m2r (pavgw, var, reg) +#define pavgw_r2r(regs,regd) mmx_r2r (pavgw, regs, regd) + +#define pextrw_r2r(mmreg,reg,imm) mmx_r2ri (pextrw, mmreg, reg, imm) + +#define pinsrw_r2r(reg,mmreg,imm) mmx_r2ri (pinsrw, reg, mmreg, imm) + +#define pmaxsw_m2r(var,reg) mmx_m2r (pmaxsw, var, reg) +#define pmaxsw_r2r(regs,regd) mmx_r2r (pmaxsw, regs, regd) + +#define pmaxub_m2r(var,reg) mmx_m2r (pmaxub, var, reg) +#define pmaxub_r2r(regs,regd) mmx_r2r (pmaxub, regs, regd) + +#define pminsw_m2r(var,reg) mmx_m2r (pminsw, var, reg) +#define pminsw_r2r(regs,regd) mmx_r2r (pminsw, regs, regd) + +#define pminub_m2r(var,reg) mmx_m2r (pminub, var, reg) +#define pminub_r2r(regs,regd) mmx_r2r (pminub, regs, regd) + +#define pmovmskb(mmreg,reg) \ + __asm__ __volatile__ ("movmskps %" #mmreg ", %" #reg) + +#define pmulhuw_m2r(var,reg) mmx_m2r (pmulhuw, var, reg) +#define pmulhuw_r2r(regs,regd) mmx_r2r (pmulhuw, regs, regd) + +#define prefetcht0(mem) mmx_fetch (mem, t0) +#define prefetcht1(mem) mmx_fetch (mem, t1) +#define prefetcht2(mem) mmx_fetch (mem, t2) +#define prefetchnta(mem) mmx_fetch (mem, nta) + +#define psadbw_m2r(var,reg) mmx_m2r (psadbw, var, reg) +#define psadbw_r2r(regs,regd) mmx_r2r (psadbw, regs, regd) + +#define pshufw_m2r(var,reg,imm) mmx_m2ri(pshufw, var, reg, imm) +#define pshufw_r2r(regs,regd,imm) mmx_r2ri(pshufw, regs, regd, imm) + +#define sfence() __asm__ __volatile__ ("sfence\n\t") + +typedef union { + float sf[4]; /* Single-precision (32-bit) value */ +} ATTR_ALIGN(16) sse_t; /* On a 16 byte (128-bit) boundary */ + + +#define sse_i2r(op, imm, reg) \ + __asm__ __volatile__ (#op " %0, %%" #reg \ + : /* nothing */ \ + : "X" (imm) ) + +#define sse_m2r(op, mem, reg) \ + __asm__ __volatile__ (#op " %0, %%" #reg \ + : /* nothing */ \ + : "X" (mem)) + +#define sse_r2m(op, reg, mem) \ + __asm__ __volatile__ (#op " %%" #reg ", %0" \ + : "=X" (mem) \ + : /* nothing */ ) + +#define sse_r2r(op, regs, regd) \ + __asm__ __volatile__ (#op " %" #regs ", %" #regd) + +#define sse_r2ri(op, regs, regd, imm) \ + __asm__ __volatile__ (#op " %0, %%" #regs ", %%" #regd \ + : /* nothing */ \ + : "X" (imm) ) + +#define sse_m2ri(op, mem, reg, subop) \ + __asm__ __volatile__ (#op " %0, %%" #reg ", " #subop \ + : /* nothing */ \ + : "X" (mem)) + + +#define movaps_m2r(var, reg) sse_m2r(movaps, var, reg) +#define movaps_r2m(reg, var) sse_r2m(movaps, reg, var) +#define movaps_r2r(regs, regd) sse_r2r(movaps, regs, regd) + +#define movntps_r2m(xmmreg, var) sse_r2m(movntps, xmmreg, var) + +#define movups_m2r(var, reg) sse_m2r(movups, var, reg) +#define movups_r2m(reg, var) sse_r2m(movups, reg, var) +#define movups_r2r(regs, regd) sse_r2r(movups, regs, regd) + +#define movhlps_r2r(regs, regd) sse_r2r(movhlps, regs, regd) + +#define movlhps_r2r(regs, regd) sse_r2r(movlhps, regs, regd) + +#define movhps_m2r(var, reg) sse_m2r(movhps, var, reg) +#define movhps_r2m(reg, var) sse_r2m(movhps, reg, var) + +#define movlps_m2r(var, reg) sse_m2r(movlps, var, reg) +#define movlps_r2m(reg, var) sse_r2m(movlps, reg, var) + +#define movss_m2r(var, reg) sse_m2r(movss, var, reg) +#define movss_r2m(reg, var) sse_r2m(movss, reg, var) +#define movss_r2r(regs, regd) sse_r2r(movss, regs, regd) + +#define shufps_m2r(var, reg, index) sse_m2ri(shufps, var, reg, index) +#define shufps_r2r(regs, regd, index) sse_r2ri(shufps, regs, regd, index) + +#define cvtpi2ps_m2r(var, xmmreg) sse_m2r(cvtpi2ps, var, xmmreg) +#define cvtpi2ps_r2r(mmreg, xmmreg) sse_r2r(cvtpi2ps, mmreg, xmmreg) + +#define cvtps2pi_m2r(var, mmreg) sse_m2r(cvtps2pi, var, mmreg) +#define cvtps2pi_r2r(xmmreg, mmreg) sse_r2r(cvtps2pi, mmreg, xmmreg) + +#define cvttps2pi_m2r(var, mmreg) sse_m2r(cvttps2pi, var, mmreg) +#define cvttps2pi_r2r(xmmreg, mmreg) sse_r2r(cvttps2pi, mmreg, xmmreg) + +#define cvtsi2ss_m2r(var, xmmreg) sse_m2r(cvtsi2ss, var, xmmreg) +#define cvtsi2ss_r2r(reg, xmmreg) sse_r2r(cvtsi2ss, reg, xmmreg) + +#define cvtss2si_m2r(var, reg) sse_m2r(cvtss2si, var, reg) +#define cvtss2si_r2r(xmmreg, reg) sse_r2r(cvtss2si, xmmreg, reg) + +#define cvttss2si_m2r(var, reg) sse_m2r(cvtss2si, var, reg) +#define cvttss2si_r2r(xmmreg, reg) sse_r2r(cvtss2si, xmmreg, reg) + +#define movmskps(xmmreg, reg) \ + __asm__ __volatile__ ("movmskps %" #xmmreg ", %" #reg) + +#define addps_m2r(var, reg) sse_m2r(addps, var, reg) +#define addps_r2r(regs, regd) sse_r2r(addps, regs, regd) + +#define addss_m2r(var, reg) sse_m2r(addss, var, reg) +#define addss_r2r(regs, regd) sse_r2r(addss, regs, regd) + +#define subps_m2r(var, reg) sse_m2r(subps, var, reg) +#define subps_r2r(regs, regd) sse_r2r(subps, regs, regd) + +#define subss_m2r(var, reg) sse_m2r(subss, var, reg) +#define subss_r2r(regs, regd) sse_r2r(subss, regs, regd) + +#define mulps_m2r(var, reg) sse_m2r(mulps, var, reg) +#define mulps_r2r(regs, regd) sse_r2r(mulps, regs, regd) + +#define mulss_m2r(var, reg) sse_m2r(mulss, var, reg) +#define mulss_r2r(regs, regd) sse_r2r(mulss, regs, regd) + +#define divps_m2r(var, reg) sse_m2r(divps, var, reg) +#define divps_r2r(regs, regd) sse_r2r(divps, regs, regd) + +#define divss_m2r(var, reg) sse_m2r(divss, var, reg) +#define divss_r2r(regs, regd) sse_r2r(divss, regs, regd) + +#define rcpps_m2r(var, reg) sse_m2r(rcpps, var, reg) +#define rcpps_r2r(regs, regd) sse_r2r(rcpps, regs, regd) + +#define rcpss_m2r(var, reg) sse_m2r(rcpss, var, reg) +#define rcpss_r2r(regs, regd) sse_r2r(rcpss, regs, regd) + +#define rsqrtps_m2r(var, reg) sse_m2r(rsqrtps, var, reg) +#define rsqrtps_r2r(regs, regd) sse_r2r(rsqrtps, regs, regd) + +#define rsqrtss_m2r(var, reg) sse_m2r(rsqrtss, var, reg) +#define rsqrtss_r2r(regs, regd) sse_r2r(rsqrtss, regs, regd) + +#define sqrtps_m2r(var, reg) sse_m2r(sqrtps, var, reg) +#define sqrtps_r2r(regs, regd) sse_r2r(sqrtps, regs, regd) + +#define sqrtss_m2r(var, reg) sse_m2r(sqrtss, var, reg) +#define sqrtss_r2r(regs, regd) sse_r2r(sqrtss, regs, regd) + +#define andps_m2r(var, reg) sse_m2r(andps, var, reg) +#define andps_r2r(regs, regd) sse_r2r(andps, regs, regd) + +#define andnps_m2r(var, reg) sse_m2r(andnps, var, reg) +#define andnps_r2r(regs, regd) sse_r2r(andnps, regs, regd) + +#define orps_m2r(var, reg) sse_m2r(orps, var, reg) +#define orps_r2r(regs, regd) sse_r2r(orps, regs, regd) + +#define xorps_m2r(var, reg) sse_m2r(xorps, var, reg) +#define xorps_r2r(regs, regd) sse_r2r(xorps, regs, regd) + +#define maxps_m2r(var, reg) sse_m2r(maxps, var, reg) +#define maxps_r2r(regs, regd) sse_r2r(maxps, regs, regd) + +#define maxss_m2r(var, reg) sse_m2r(maxss, var, reg) +#define maxss_r2r(regs, regd) sse_r2r(maxss, regs, regd) + +#define minps_m2r(var, reg) sse_m2r(minps, var, reg) +#define minps_r2r(regs, regd) sse_r2r(minps, regs, regd) + +#define minss_m2r(var, reg) sse_m2r(minss, var, reg) +#define minss_r2r(regs, regd) sse_r2r(minss, regs, regd) + +#define cmpps_m2r(var, reg, op) sse_m2ri(cmpps, var, reg, op) +#define cmpps_r2r(regs, regd, op) sse_r2ri(cmpps, regs, regd, op) + +#define cmpeqps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 0) +#define cmpeqps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 0) + +#define cmpltps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 1) +#define cmpltps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 1) + +#define cmpleps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 2) +#define cmpleps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 2) + +#define cmpunordps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 3) +#define cmpunordps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 3) + +#define cmpneqps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 4) +#define cmpneqps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 4) + +#define cmpnltps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 5) +#define cmpnltps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 5) + +#define cmpnleps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 6) +#define cmpnleps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 6) + +#define cmpordps_m2r(var, reg) sse_m2ri(cmpps, var, reg, 7) +#define cmpordps_r2r(regs, regd) sse_r2ri(cmpps, regs, regd, 7) + +#define cmpss_m2r(var, reg, op) sse_m2ri(cmpss, var, reg, op) +#define cmpss_r2r(regs, regd, op) sse_r2ri(cmpss, regs, regd, op) + +#define cmpeqss_m2r(var, reg) sse_m2ri(cmpss, var, reg, 0) +#define cmpeqss_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 0) + +#define cmpltss_m2r(var, reg) sse_m2ri(cmpss, var, reg, 1) +#define cmpltss_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 1) + +#define cmpless_m2r(var, reg) sse_m2ri(cmpss, var, reg, 2) +#define cmpless_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 2) + +#define cmpunordss_m2r(var, reg) sse_m2ri(cmpss, var, reg, 3) +#define cmpunordss_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 3) + +#define cmpneqss_m2r(var, reg) sse_m2ri(cmpss, var, reg, 4) +#define cmpneqss_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 4) + +#define cmpnltss_m2r(var, reg) sse_m2ri(cmpss, var, reg, 5) +#define cmpnltss_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 5) + +#define cmpnless_m2r(var, reg) sse_m2ri(cmpss, var, reg, 6) +#define cmpnless_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 6) + +#define cmpordss_m2r(var, reg) sse_m2ri(cmpss, var, reg, 7) +#define cmpordss_r2r(regs, regd) sse_r2ri(cmpss, regs, regd, 7) + +#define comiss_m2r(var, reg) sse_m2r(comiss, var, reg) +#define comiss_r2r(regs, regd) sse_r2r(comiss, regs, regd) + +#define ucomiss_m2r(var, reg) sse_m2r(ucomiss, var, reg) +#define ucomiss_r2r(regs, regd) sse_r2r(ucomiss, regs, regd) + +#define unpcklps_m2r(var, reg) sse_m2r(unpcklps, var, reg) +#define unpcklps_r2r(regs, regd) sse_r2r(unpcklps, regs, regd) + +#define unpckhps_m2r(var, reg) sse_m2r(unpckhps, var, reg) +#define unpckhps_r2r(regs, regd) sse_r2r(unpckhps, regs, regd) + +#define fxrstor(mem) \ + __asm__ __volatile__ ("fxrstor %0" \ + : /* nothing */ \ + : "X" (mem)) + +#define fxsave(mem) \ + __asm__ __volatile__ ("fxsave %0" \ + : /* nothing */ \ + : "X" (mem)) + +#define stmxcsr(mem) \ + __asm__ __volatile__ ("stmxcsr %0" \ + : /* nothing */ \ + : "X" (mem)) + +#define ldmxcsr(mem) \ + __asm__ __volatile__ ("ldmxcsr %0" \ + : /* nothing */ \ + : "X" (mem)) +#endif /*ARCH_X86 */ + + + + /* Optimized/fast memcpy */ + +/* + TODO : fix dll linkage problem for xine_fast_memcpy on win32 + + xine_fast_memcpy dll linkage is screwy here. + declairing as dllinport seems to fix the problem + but causes compiler warning with libxineutils +*/ +#ifdef _MSC_VER +void __declspec( dllimport ) *(* xine_fast_memcpy)(void *to, const void *from, size_t len); +#else +extern void *(* xine_fast_memcpy)(void *to, const void *from, size_t len); +#endif + +#ifdef HAVE_XINE_INTERNAL_H +/* Benchmark available memcpy methods */ +void xine_probe_fast_memcpy(config_values_t *config); +#endif + + +/* + * Debug stuff + */ +/* + * profiling (unworkable in non DEBUG isn't defined) + */ +void xine_profiler_init (void); +int xine_profiler_allocate_slot (char *label); +void xine_profiler_start_count (int id); +void xine_profiler_stop_count (int id); +void xine_profiler_print_results (void); + +/* + * Allocate and clean memory size_t 'size', then return the pointer + * to the allocated memory. + */ +void *xine_xmalloc(size_t size); + +/* + * Same as above, but memory is aligned to 'alignement'. + * **base is used to return pointer to un-aligned memory, use + * this to free the mem chunk + */ +void *xine_xmalloc_aligned(size_t alignment, size_t size, void **base); + +/* + * Get user home directory. + */ +const char *xine_get_homedir(void); + +/* + * Clean a string (remove spaces and '=' at the begin, + * and '\n', '\r' and spaces at the end. + */ +char *xine_chomp (char *str); + +/* + * A thread-safe usecond sleep + */ +void xine_usec_sleep(unsigned usec); + + + /* + * Some string functions + */ + + +void xine_strdupa(char *dest, char *src); +#define xine_strdupa(d, s) do { \ + (d) = NULL; \ + if((s) != NULL) { \ + (d) = (char *) alloca(strlen((s)) + 1); \ + strcpy((d), (s)); \ + } \ + } while(0) + +/* Shamefully copied from glibc 2.2.3 */ +#ifdef HAVE_STRPBRK +#define xine_strpbrk strpbrk +#else +static inline char *_x_strpbrk(const char *s, const char *accept) { + + while(*s != '\0') { + const char *a = accept; + while(*a != '\0') + if(*a++ == *s) + return(char *) s; + ++s; + } + + return NULL; +} +#define xine_strpbrk _x_strpbrk +#endif + +#ifdef HAVE_STRSEP +#define xine_strsep strsep +#else +static inline char *_x_strsep(char **stringp, const char *delim) { + char *begin, *end; + + begin = *stringp; + if(begin == NULL) + return NULL; + + if(delim[0] == '\0' || delim[1] == '\0') { + char ch = delim[0]; + + if(ch == '\0') + end = NULL; + else { + if(*begin == ch) + end = begin; + else if(*begin == '\0') + end = NULL; + else + end = strchr(begin + 1, ch); + } + } + else + end = xine_strpbrk(begin, delim); + + if(end) { + *end++ = '\0'; + *stringp = end; + } + else + *stringp = NULL; + + return begin; +} +#define xine_strsep _x_strsep +#endif + + +#ifdef HAVE_SETENV +#define xine_setenv setenv +#else +static inline void _x_setenv(const char *name, const char *val, int _xx) +{ + int len = strlen(name) + strlen(val) + 2; + char *env; + + env = (char*)malloc(len); + + if (env != NULL) { + strcpy(env, name); + strcat(env, "="); + strcat(env, val); + putenv(env); + } +} +#define xine_setenv _x_setenv +#endif + +/* + * Color Conversion Utility Functions + * The following data structures and functions facilitate the conversion + * of RGB images to packed YUV (YUY2) images. There are also functions to + * convert from YUV9 -> YV12. All of the meaty details are written in + * color.c. + */ + +typedef struct yuv_planes_s { + + unsigned char *y; + unsigned char *u; + unsigned char *v; + unsigned int row_width; /* frame width */ + unsigned int row_count; /* frame height */ + +} yuv_planes_t; + +void init_yuv_conversion(void); +void init_yuv_planes(yuv_planes_t *yuv_planes, int width, int height); +void free_yuv_planes(yuv_planes_t *yuv_planes); + +extern void (*yuv444_to_yuy2) + (yuv_planes_t *yuv_planes, unsigned char *yuy2_map, int pitch); +extern void (*yuv9_to_yv12) + (unsigned char *y_src, int y_src_pitch, unsigned char *y_dest, int y_dest_pitch, + unsigned char *u_src, int u_src_pitch, unsigned char *u_dest, int u_dest_pitch, + unsigned char *v_src, int v_src_pitch, unsigned char *v_dest, int v_dest_pitch, + int width, int height); +extern void (*yuv411_to_yv12) + (unsigned char *y_src, int y_src_pitch, unsigned char *y_dest, int y_dest_pitch, + unsigned char *u_src, int u_src_pitch, unsigned char *u_dest, int u_dest_pitch, + unsigned char *v_src, int v_src_pitch, unsigned char *v_dest, int v_dest_pitch, + int width, int height); + +#define SCALEFACTOR 65536 +#define CENTERSAMPLE 128 + +#define COMPUTE_Y(r, g, b) \ + (unsigned char) \ + ((y_r_table[r] + y_g_table[g] + y_b_table[b]) / SCALEFACTOR) +#define COMPUTE_U(r, g, b) \ + (unsigned char) \ + ((u_r_table[r] + u_g_table[g] + u_b_table[b]) / SCALEFACTOR + CENTERSAMPLE) +#define COMPUTE_V(r, g, b) \ + (unsigned char) \ + ((v_r_table[r] + v_g_table[g] + v_b_table[b]) / SCALEFACTOR + CENTERSAMPLE) + +#define UNPACK_BGR15(packed_pixel, r, g, b) \ + b = (packed_pixel & 0x7C00) >> 7; \ + g = (packed_pixel & 0x03E0) >> 2; \ + r = (packed_pixel & 0x001F) << 3; + +#define UNPACK_BGR16(packed_pixel, r, g, b) \ + b = (packed_pixel & 0xF800) >> 8; \ + g = (packed_pixel & 0x07E0) >> 3; \ + r = (packed_pixel & 0x001F) << 3; + +#define UNPACK_RGB15(packed_pixel, r, g, b) \ + r = (packed_pixel & 0x7C00) >> 7; \ + g = (packed_pixel & 0x03E0) >> 2; \ + b = (packed_pixel & 0x001F) << 3; + +#define UNPACK_RGB16(packed_pixel, r, g, b) \ + r = (packed_pixel & 0xF800) >> 8; \ + g = (packed_pixel & 0x07E0) >> 3; \ + b = (packed_pixel & 0x001F) << 3; + +extern int y_r_table[256]; +extern int y_g_table[256]; +extern int y_b_table[256]; + +extern int u_r_table[256]; +extern int u_g_table[256]; +extern int u_b_table[256]; + +extern int v_r_table[256]; +extern int v_g_table[256]; +extern int v_b_table[256]; + + +/* backtrace printout funtion for use in XINE_ASSERT() macro */ +void xine_print_trace(void); + + +#ifdef DEBUG +# define XINE_ABORT() \ + abort(); +#else +# define XINE_ABORT() + /* don't abort */ +#endif + +/** + * Provide assert like feature with better description of failure + * Thanks to Mark Thomas + */ +#if __GNUC__ +# define XINE_ASSERT(exp, desc, args...) \ + do { \ + if (!(exp)) { \ + printf("%s:%s:%d: assertion `%s' failed. " desc "\n\n", \ + __FILE__, __XINE_FUNCTION__, __LINE__, #exp, ##args); \ + xine_print_trace(); \ + XINE_ABORT(); \ + } \ + } while(0) +#else /* not GNU C, assume we have a C99 compiler */ + +#ifdef _MSC_VER +/* + #define XINE_ASSERT(exp, desc) ((void)((exp) || \ + (printf desc, _assert(#exp, __FILE__, __LINE__), 0))) + +*/ +# define XINE_ASSERT(exp, desc) \ + do { \ + if (!(exp)) { \ + printf("%s:%s:%d: assertion `%s' failed. ", \ + __FILE__, __XINE_FUNCTION__, __LINE__, #exp); \ + printf(desc); \ + printf("\n\n"); \ + xine_print_trace(); \ + XINE_ABORT(); \ + } \ + } while(0) +#else +# define XINE_ASSERT(exp, ...) \ + do { \ + if (!(exp)) { \ + printf("%s:%s:%d: assertion `%s' failed. ", \ + __FILE__, __XINE_FUNCTION__, __LINE__, #exp); \ + printf(__VA_ARGS__); \ + printf("\n\n"); \ + xine_print_trace(); \ + XINE_ABORT(); \ + } \ + } while(0) +#endif /* _MSC_VER */ + +#endif + + +/******** double chained lists with builtin iterator *******/ + +typedef struct xine_node_s { + + struct xine_node_s *next, *prev; + + void *content; + + int priority; + +} xine_node_t; + + +typedef struct { + + xine_node_t *first, *last, *cur; + +} xine_list_t; + + + +xine_list_t *xine_list_new (void); + + +/** + * dispose the whole list. + * note: disposes _only_ the list structure, content must be free()d elsewhere + */ +void xine_list_free(xine_list_t *l); + + +/** + * returns: Boolean + */ +int xine_list_is_empty (xine_list_t *l); + +/** + * return content of first entry in list. + */ +void *xine_list_first_content (xine_list_t *l); + +/** + * return next content in list. + */ +void *xine_list_next_content (xine_list_t *l); + +/** + * Return last content of list. + */ +void *xine_list_last_content (xine_list_t *l); + +/** + * Return previous content of list. + */ +void *xine_list_prev_content (xine_list_t *l); + +/** + * Append content to list, sorted by decreasing priority. + */ +void xine_list_append_priority_content (xine_list_t *l, void *content, int priority); + +/** + * Append content to list. + */ +void xine_list_append_content (xine_list_t *l, void *content); + +/** + * Insert content in list. + */ +void xine_list_insert_content (xine_list_t *l, void *content); + +/** + * Remove current content in list. + * note: removes only the list entry; content must be free()d elsewhere. + */ +void xine_list_delete_current (xine_list_t *l); + + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/win32/include/zconf.h b/win32/include/zconf.h new file mode 100644 index 000000000..90d1a107a --- /dev/null +++ b/win32/include/zconf.h @@ -0,0 +1,279 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-1998 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id: zconf.h,v 1.1 2003/04/20 16:42:09 guenter Exp $ */ + +#ifndef _ZCONF_H +#define _ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + */ +#ifdef Z_PREFIX +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateSetDictionary z_deflateSetDictionary +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define inflateInit2_ z_inflateInit2_ +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateReset z_inflateReset +# define compress z_compress +# define compress2 z_compress2 +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 +# define get_crc_table z_get_crc_table + +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp +#endif + +#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) +# define WIN32 +#endif +#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) +# ifndef __32BIT__ +# define __32BIT__ +# endif +#endif +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#if defined(MSDOS) && !defined(__32BIT__) +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC) +# define STDC +#endif +#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__) +# ifndef STDC +# define STDC +# endif +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Old Borland C incorrectly complains about missing returns: */ +#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) +# define NEED_DUMMY_RETURN +#endif + + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +#endif +#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) +# ifndef __32BIT__ +# define SMALL_MEDIUM +# define FAR _far +# endif +#endif + +/* Compile with -DZLIB_DLL for Windows DLL support */ +#if defined(ZLIB_DLL) +# if defined(_WINDOWS) || defined(WINDOWS) +# ifdef FAR +# undef FAR +# endif +# include +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR _cdecl _export +# endif +# endif +# if defined (__BORLANDC__) +# if (__BORLANDC__ >= 0x0500) && defined (WIN32) +# include +# define ZEXPORT __declspec(dllexport) WINAPI +# define ZEXPORTRVA __declspec(dllexport) WINAPIV +# else +# if defined (_Windows) && defined (__DLL__) +# define ZEXPORT _export +# define ZEXPORTVA _export +# endif +# endif +# endif +#endif + +#if defined (__BEOS__) +# if defined (ZLIB_DLL) +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +#endif + +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif +#ifndef ZEXTERN +# define ZEXTERN extern +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(MACOS) && !defined(TARGET_OS_MAC) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#ifdef HAVE_UNISTD_H +# include /* for off_t */ +# include /* for SEEK_* and off_t */ +# define z_off_t off_t +#endif +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) +# pragma map(deflateInit_,"DEIN") +# pragma map(deflateInit2_,"DEIN2") +# pragma map(deflateEnd,"DEEND") +# pragma map(inflateInit_,"ININ") +# pragma map(inflateInit2_,"ININ2") +# pragma map(inflateEnd,"INEND") +# pragma map(inflateSync,"INSY") +# pragma map(inflateSetDictionary,"INSEDI") +# pragma map(inflate_blocks,"INBL") +# pragma map(inflate_blocks_new,"INBLNE") +# pragma map(inflate_blocks_free,"INBLFR") +# pragma map(inflate_blocks_reset,"INBLRE") +# pragma map(inflate_codes_free,"INCOFR") +# pragma map(inflate_codes,"INCO") +# pragma map(inflate_fast,"INFA") +# pragma map(inflate_flush,"INFLU") +# pragma map(inflate_mask,"INMA") +# pragma map(inflate_set_dictionary,"INSEDI2") +# pragma map(inflate_copyright,"INCOPY") +# pragma map(inflate_trees_bits,"INTRBI") +# pragma map(inflate_trees_dynamic,"INTRDY") +# pragma map(inflate_trees_fixed,"INTRFI") +# pragma map(inflate_trees_free,"INTRFR") +#endif + +#endif /* _ZCONF_H */ diff --git a/win32/include/zlib.h b/win32/include/zlib.h new file mode 100644 index 000000000..34fe85f41 --- /dev/null +++ b/win32/include/zlib.h @@ -0,0 +1,893 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.1.3, July 9th, 1998 + + Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef _ZLIB_H +#define _ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.1.3" + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: ascii or binary */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +/* Allowed flush values; see deflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_ASCII 1 +#define Z_UNKNOWN 2 +/* Possible values of the data_type field */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + the compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + 0.1% larger than avail_in plus 12 bytes. If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update data_type if it can make a good guess about + the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may some + introduce some output latency (reading input without producing any output) + except when forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much + output as possible to the output buffer. The flushing behavior of inflate is + not specified for values of the flush parameter other than Z_SYNC_FLUSH + and Z_FINISH, but the current implementation actually flushes as much output + as possible anyway. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster routine + may be used for the single inflate() call. + + If a preset dictionary is needed at this point (see inflateSetDictionary + below), inflate sets strm-adler to the adler32 checksum of the + dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise + it sets strm->adler to the adler32 checksum of all output produced + so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or + an error code as described below. At the end of the stream, inflate() + checks that its computed adler32 checksum is equal to that saved by the + compressor and returns Z_STREAM_END only if the checksum is correct. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect + adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent + (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if no progress is possible or if there was not + enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR + case, the application may then call inflateSync to look for a good + compression block. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match). Filtered data consists mostly of small values with a + somewhat random distribution. In this case, the compression algorithm is + tuned to compress them better. The effect of Z_FILTERED is to force more + Huffman coding and less string matching; it is somewhat intermediate + between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects + the compression ratio but not the correctness of the compressed output even + if it is not set appropriately. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. + + Upon return of this function, strm->adler is set to the Adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The Adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. If a compressed stream with a larger window size is given as + input, inflate() will return with the error code Z_DATA_ERROR instead of + trying to allocate a larger window. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative + memLevel). msg is set to null if there is no error message. inflateInit2 + does not perform any decompression apart from reading the zlib header if + present: this will be done by inflate(). (So next_in and avail_in may be + modified, but next_out and avail_out are unchanged.) +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate + if this call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the Adler32 value returned by this call of + inflate. The compressor and decompressor must use exactly the same + dictionary (see deflateSetDictionary). + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect Adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least 0.1% larger than + sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. +*/ + + +typedef voidp gzFile; + +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h". (See the description + of deflateInit2 for more information about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + const voidp buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. + gzgets returns buf, or Z_NULL in case of error. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. +*/ + +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); +/* + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); + +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running crc with the bytes buf[0..len-1] and return the updated + crc. If buf is NULL, this function returns the required initial value + for the crc. Pre- and post-conditioning (one's complement) is performed + within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) + + +#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; /* hack for buggy compilers */ +#endif + +ZEXTERN const char * ZEXPORT zError OF((int err)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); + +#ifdef __cplusplus +} +#endif + +#endif /* _ZLIB_H */ -- cgit v1.2.3