shithub: libdvdcss

Download patch

ref: 18b755d525681ce85e14b5b953687938d1812f1a
parent: d0b6a291c24eda3727ad5c7a14956fc1fc82446d
author: Romano <me+git@fallglow.com>
date: Tue May 21 14:56:00 EDT 2024

WIP

--- /dev/null
+++ b/mkfile
@@ -1,0 +1,22 @@
+</$objtype/mkfile
+
+LIB=/$objtype/lib/libdvdcss.a
+
+OFILES=\
+	src/css.$O\
+	src/device.$O\
+	src/error.$O\
+	src/ioctl.$O\
+	src/libdvdcss.$O\
+
+HFILES=\
+	src/config.h\
+	src/libdvdcss.h\
+
+UPDATE=\
+	mkfile\
+	$HFILES\
+	${OFILES:%.$O=%.c}\
+
+</sys/src/cmd/mksyslib
+
--- a/src/common.h
+++ b/src/common.h
@@ -26,47 +26,4 @@
 #ifndef DVDCSS_COMMON_H
 #define DVDCSS_COMMON_H
 
-#if defined( _WIN32 )
-#   include <io.h>                                             /* _lseeki64 */
-
-/* several type definitions */
-#   if defined( __MINGW32__ )
-#       undef lseek
-#       define lseek _lseeki64
-#       if !defined( _OFF_T_ )
-typedef long long _off_t;
-typedef _off_t off_t;
-#           define _OFF_T_
-#       else
-#           define off_t long long
-#       endif
-#   endif /* defined( __MINGW32__ ) */
-
-#   if defined( _MSC_VER )
-#       undef lseek
-#       define lseek _lseeki64
-#       if !defined( _OFF_T_DEFINED )
-typedef __int64 off_t;
-#           define _OFF_T_DEFINED
-#       else
-#           define off_t __int64
-#       endif
-#       define ssize_t SSIZE_T
-#       define snprintf _snprintf
-#       define strdup _strdup
-#       define open _open
-#       define close _close
-#       define read _read
-#       define write _write
-#   endif /* defined( _MSC_VER ) */
-
-#endif /* defined( _WIN32 ) */
-
-#ifdef __ANDROID__
-# undef  lseek
-# define lseek lseek64
-# undef  off_t
-# define off_t off64_t
-#endif /* __ANDROID__ */
-
 #endif /* DVDCSS_COMMON_H */
--- a/src/css.c
+++ b/src/css.c
@@ -35,11 +35,16 @@
  *****************************************************************************/
 #include "config.h"
 
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
+#ifdef __PLAN9__
+#	include <u.h>
+#	include <libc.h>
+#else
+#	include <limits.h>
+#	include <stdio.h>
+#	include <stdlib.h>
+#	include <string.h>
+#	include <sys/types.h>
+#endif
 #ifdef HAVE_SYS_PARAM_H
 #   include <sys/param.h>
 #endif
@@ -46,7 +51,9 @@
 #ifdef HAVE_UNISTD_H
 #   include <unistd.h>
 #endif
-#include <fcntl.h>
+#ifndef __PLAN9__
+#    include <fcntl.h>
+#endif
 
 #include "dvdcss/dvdcss.h"
 
--- a/src/css.h
+++ b/src/css.h
@@ -29,7 +29,11 @@
 #ifndef DVDCSS_CSS_H
 #define DVDCSS_CSS_H
 
-#include <stdint.h>
+#ifdef __PLAN9__
+typedef uint uint8_t;
+#else
+#	include <stdint.h>
+#endif
 
 #include "dvdcss/dvdcss.h"
 
@@ -37,7 +41,7 @@
 
 #define DVD_KEY_SIZE 5
 
-typedef uint8_t dvd_key[DVD_KEY_SIZE];
+typedef uint dvd_key[DVD_KEY_SIZE];
 
 typedef struct dvd_title
 {
--- a/src/device.c
+++ b/src/device.c
@@ -27,19 +27,28 @@
  *****************************************************************************/
 #include "config.h"
 
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#ifdef __PLAN9__
+#	include <u.h>
+#	include <libc.h>
+#else
+#	include <limits.h>
+#	include <stdio.h>
+#	include <stdlib.h>
+#	include <string.h>
+#endif
 #ifdef HAVE_ERRNO_H
 #   include <errno.h>
 #endif
-#include <sys/types.h>
-#include <sys/stat.h>
+#ifndef __PLAN9__
+#    include <sys/types.h>
+#    include <sys/stat.h>
+#endif
 #ifdef HAVE_SYS_PARAM_H
 #   include <sys/param.h>
 #endif
-#include <fcntl.h>
+#ifndef __PLAN9__
+#    include <fcntl.h>
+#endif
 
 #ifdef HAVE_UNISTD_H
 #   include <unistd.h>
@@ -120,6 +129,8 @@
         return 1;
 
     return 0;
+#elif defined( __PLAN9__ )
+	return 0;
 #else
     struct stat fileinfo;
     int ret;
--- a/src/dvdcss/dvdcss.h
+++ b/src/dvdcss/dvdcss.h
@@ -31,10 +31,13 @@
 #define DVDCSS_DVDCSS_H 1
 #endif
 
-#include <stdint.h>
+#ifndef __PLAN9__
+#	include <stdint.h>
+#else
+typedef uvlong uint64_t;
+#	include "dvdcss/version.h"
+#endif
 
-#include "version.h"
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -73,16 +76,7 @@
 /** Macro for setting symbol storage-class or visibility.
  * Define LIBDVDCSS_IMPORTS before importing this header to get the
  * correct DLL storage-class when using \e libdvdcss from MSVC. */
-#if defined(LIBDVDCSS_EXPORTS)
-#define LIBDVDCSS_EXPORT __declspec(dllexport) extern
-#elif defined(LIBDVDCSS_IMPORTS)
-#define LIBDVDCSS_EXPORT __declspec(dllimport) extern
-#elif defined(SUPPORT_ATTRIBUTE_VISIBILITY_DEFAULT)
-#define LIBDVDCSS_EXPORT __attribute__((visibility("default"))) extern
-#else
 #define LIBDVDCSS_EXPORT extern
-#endif
-
 
 /*
  * Exported prototypes.
--- a/src/error.c
+++ b/src/error.c
@@ -20,8 +20,13 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *****************************************************************************/
 
-#include <stdarg.h>
-#include <stdio.h>
+#ifdef __PLAN9__
+#	include <u.h>
+#	include <libc.h>
+#else
+#	include <stdarg.h>
+#	include <stdio.h>
+#endif
 
 #include "libdvdcss.h"
 
--- a/src/ioctl.c
+++ b/src/ioctl.c
@@ -32,10 +32,19 @@
  *****************************************************************************/
 #include "config.h"
 
-#include <stdio.h>
+#ifdef __PLAN9__
+#	include <u.h>
+#	include <libc.h>
+#else
+#	include <stdio.h>
+#endif
 
-#include <string.h>                                    /* memcpy(), memset() */
-#include <sys/types.h>
+#ifdef __PLAN9__
+#	include <String.h>
+#else
+#	include <string.h>                                    /* memcpy(), memset() */
+#	include <sys/types.h>
+#endif
 
 #if defined( _WIN32 )
 #   include <windows.h>
--- a/src/libdvdcss.h
+++ b/src/libdvdcss.h
@@ -24,8 +24,9 @@
 #ifndef DVDCSS_LIBDVDCSS_H
 #define DVDCSS_LIBDVDCSS_H
 
+#ifndef __PLAN9__
 #include <limits.h>
-
+#endif
 #include "dvdcss/dvdcss.h"
 #include "css.h"
 #include "device.h"