Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tcpiptan/412916 to your computer and use it in GitHub Desktop.
Save tcpiptan/412916 to your computer and use it in GitHub Desktop.
From 97aa799574932871f66bc3eb11e0f7ea47afadba Mon Sep 17 00:00:00 2001
From: tcpiptan <tcpipdoom@gmail.com>
Date: Tue, 25 May 2010 15:54:04 +0900
Subject: [PATCH] fix to make for ActivePerl + nmake
---
win32_unicode.h | 15 +++--
xs/Console.xs | 59 +++++++++---------
xs/Error.xs | 77 ++++++++++++------------
xs/File.xs | 177 ++++++++++++++++++++++++++++---------------------------
xs/Process.xs | 4 +-
xs/XS.xs | 35 +++++------
6 files changed, 184 insertions(+), 183 deletions(-)
diff --git a/win32_unicode.h b/win32_unicode.h
index 2f03b09..09b30a8 100644
--- a/win32_unicode.h
+++ b/win32_unicode.h
@@ -1,7 +1,8 @@
-/* win32_unicode.h */
-
-#define WIN32_UNICODE_CALL_BOOT(name) STMT_START { \
- EXTERN_C XS(CAT2(boot_, name)); \
- PUSHMARK(SP); \
- CALL_FPTR(CAT2(boot_, name))(aTHX_ cv); \
- } STMT_END
+#include "ppport.h"
+/* win32_unicode.h */
+
+#define WIN32_UNICODE_CALL_BOOT(name) STMT_START { \
+ EXTERN_C XS(CAT2(boot_, name)); \
+ PUSHMARK(SP); \
+ CALL_FPTR(CAT2(boot_, name))(aTHX_ cv); \
+ } STMT_END
diff --git a/xs/Console.xs b/xs/Console.xs
index 248ac34..dd23e5e 100644
--- a/xs/Console.xs
+++ b/xs/Console.xs
@@ -1,29 +1,30 @@
-#define PERL_NO_GET_CONTEXT
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-
-#include "ppport.h"
-
-#include <windows.h>
-
-MODULE = Win32::Unicode::Console PACKAGE = Win32::Unicode::Console
-
-PROTOTYPES: DISABLE
-
-long
-get_std_handle(long handle)
- CODE:
- RETVAL = GetStdHandle(handle);
- OUTPUT:
- RETVAL
-
-void
-write_console(long handle, SV* str)
- PPCODE:
- STRLEN len;
- const WCHAR* buff = SvPV_const(str, len);
- DWORD write_size;
-
- WriteConsoleW(handle, buff, wcslen(buff), &write_size, NULL);
-
+#define PERL_NO_GET_CONTEXT
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#define NEED_sv_2pv_flags_GLOBAL
+#include "ppport.h"
+
+#include <windows.h>
+
+MODULE = Win32::Unicode::Console PACKAGE = Win32::Unicode::Console
+
+PROTOTYPES: DISABLE
+
+long
+get_std_handle(long handle)
+ CODE:
+ RETVAL = GetStdHandle(handle);
+ OUTPUT:
+ RETVAL
+
+void
+write_console(long handle, SV* str)
+ PPCODE:
+ STRLEN len;
+ const WCHAR* buff = SvPV_const(str, len);
+ DWORD write_size;
+
+ WriteConsoleW(handle, buff, wcslen(buff), &write_size, NULL);
+
diff --git a/xs/Error.xs b/xs/Error.xs
index 697799a..15d9408 100644
--- a/xs/Error.xs
+++ b/xs/Error.xs
@@ -1,39 +1,38 @@
-#define PERL_NO_GET_CONTEXT
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-
-#include "ppport.h"
-
-#include <windows.h>
-#define BUFF_SIZE 520
-
-MODULE = Win32::Unicode::Error PACKAGE = Win32::Unicode::Error
-
-PROTOTYPES: DISABLE
-
-long
-get_last_error()
- CODE:
- RETVAL = GetLastError();
- OUTPUT:
- RETVAL
-
-SV*
-foramt_message()
- CODE:
- WCHAR* buff[BUFF_SIZE];
-
- FormatMessageW(
- FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- GetLastError(),
- LANG_USER_DEFAULT,
- buff,
- BUFF_SIZE,
- NULL
- );
-
- RETVAL = newSVpv(buff, wcslen(buff) * 2);
- OUTPUT:
- RETVAL
+#define PERL_NO_GET_CONTEXT
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+
+#include <windows.h>
+#define BUFF_SIZE 520
+
+MODULE = Win32::Unicode::Error PACKAGE = Win32::Unicode::Error
+
+PROTOTYPES: DISABLE
+
+long
+get_last_error()
+ CODE:
+ RETVAL = GetLastError();
+ OUTPUT:
+ RETVAL
+
+SV*
+foramt_message()
+ CODE:
+ WCHAR* buff[BUFF_SIZE];
+
+ FormatMessageW(
+ FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ LANG_USER_DEFAULT,
+ buff,
+ BUFF_SIZE,
+ NULL
+ );
+
+ RETVAL = newSVpv(buff, wcslen(buff) * 2);
+ OUTPUT:
+ RETVAL
diff --git a/xs/File.xs b/xs/File.xs
index b2ffbf3..5fcde6f 100644
--- a/xs/File.xs
+++ b/xs/File.xs
@@ -1,88 +1,89 @@
-#define PERL_NO_GET_CONTEXT
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-
-#include "ppport.h"
-
-#include <windows.h>
-
-WINBASEAPI BOOL WINAPI GetFileSizeEx(HANDLE,PLARGE_INTEGER);
-
-
-MODULE = Win32::Unicode::File PACKAGE = Win32::Unicode::File
-
-PROTOTYPES: DISABLE
-
-long
-get_file_attributes(SV* file)
- CODE:
- STRLEN len;
- const WCHAR* file_name = SvPV_const(file, len);
- RETVAL = GetFileAttributesW(file_name);
- OUTPUT:
- RETVAL
-
-SV*
-get_file_size(long handle)
- CODE:
- LARGE_INTEGER st;
-
- if (GetFileSizeEx(handle, &st) == 0) {
- XSRETURN_EMPTY;
- }
-
- SV* sv = newSV(0);
- HV* hv = newHV();
- sv_setsv(sv, sv_2mortal(newRV_noinc((SV*)hv)));
- hv_store(hv, "high", strlen("high"), newSVnv(st.HighPart), 0);
- hv_store(hv, "low", strlen("low"), newSVnv(st.LowPart), 0);
-
- RETVAL = sv;
- OUTPUT:
- RETVAL
-
-int
-copy_file(SV* from, SV* to, int over)
- CODE:
- STRLEN len;
- const WCHAR* from_name = SvPV_const(from, len);
- const WCHAR* to_name = SvPV_const(to , len);
-
- RETVAL = CopyFileW(from_name, to_name, over);
- OUTPUT:
- RETVAL
-
-int
-move_file(SV* from, SV* to)
- CODE:
- STRLEN len;
- const WCHAR* from_name = SvPV_const(from, len);
- const WCHAR* to_name = SvPV_const(to , len);
-
- RETVAL = MoveFileW(from_name, to_name);
- OUTPUT:
- RETVAL
-
-SV*
-set_file_pointer(long handle, long lpos, long hpos, int whence)
- CODE:
- LARGE_INTEGER mv;
- LARGE_INTEGER st;
-
- mv.LowPart = lpos;
- mv.HighPart = hpos;
-
- if (SetFilePointerEx(handle, mv, &st, whence) == 0) {
- XSRETURN_EMPTY;
- }
-
- SV* sv = newSV(0);
- HV* hv = newHV();
- sv_setsv(sv, sv_2mortal(newRV_noinc((SV*)hv)));
- hv_store(hv, "high", strlen("high"), newSVnv(st.HighPart), 0);
- hv_store(hv, "low", strlen("low"), newSVnv(st.LowPart), 0);
-
- RETVAL = sv;
- OUTPUT:
- RETVAL
+#define PERL_NO_GET_CONTEXT
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#define NEED_newRV_noinc_GLOBAL
+#include "ppport.h"
+
+#include <windows.h>
+
+WINBASEAPI BOOL WINAPI GetFileSizeEx(HANDLE,PLARGE_INTEGER);
+
+
+MODULE = Win32::Unicode::File PACKAGE = Win32::Unicode::File
+
+PROTOTYPES: DISABLE
+
+long
+get_file_attributes(SV* file)
+ CODE:
+ STRLEN len;
+ const WCHAR* file_name = SvPV_const(file, len);
+ RETVAL = GetFileAttributesW(file_name);
+ OUTPUT:
+ RETVAL
+
+SV*
+get_file_size(long handle)
+ CODE:
+ LARGE_INTEGER st;
+ SV* sv = newSV(0);
+ HV* hv = newHV();
+
+ if (GetFileSizeEx(handle, &st) == 0) {
+ XSRETURN_EMPTY;
+ }
+
+ sv_setsv(sv, sv_2mortal(newRV_noinc((SV*)hv)));
+ hv_store(hv, "high", strlen("high"), newSVnv(st.HighPart), 0);
+ hv_store(hv, "low", strlen("low"), newSVnv(st.LowPart), 0);
+
+ RETVAL = sv;
+ OUTPUT:
+ RETVAL
+
+int
+copy_file(SV* from, SV* to, int over)
+ CODE:
+ STRLEN len;
+ const WCHAR* from_name = SvPV_const(from, len);
+ const WCHAR* to_name = SvPV_const(to , len);
+
+ RETVAL = CopyFileW(from_name, to_name, over);
+ OUTPUT:
+ RETVAL
+
+int
+move_file(SV* from, SV* to)
+ CODE:
+ STRLEN len;
+ const WCHAR* from_name = SvPV_const(from, len);
+ const WCHAR* to_name = SvPV_const(to , len);
+
+ RETVAL = MoveFileW(from_name, to_name);
+ OUTPUT:
+ RETVAL
+
+SV*
+set_file_pointer(long handle, long lpos, long hpos, int whence)
+ CODE:
+ LARGE_INTEGER mv;
+ LARGE_INTEGER st;
+ SV* sv = newSV(0);
+ HV* hv = newHV();
+
+ mv.LowPart = lpos;
+ mv.HighPart = hpos;
+
+ if (SetFilePointerEx(handle, mv, &st, whence) == 0) {
+ XSRETURN_EMPTY;
+ }
+
+ sv_setsv(sv, sv_2mortal(newRV_noinc((SV*)hv)));
+ hv_store(hv, "high", strlen("high"), newSVnv(st.HighPart), 0);
+ hv_store(hv, "low", strlen("low"), newSVnv(st.LowPart), 0);
+
+ RETVAL = sv;
+ OUTPUT:
+ RETVAL
diff --git a/xs/Process.xs b/xs/Process.xs
index 07f243a..7914fae 100644
--- a/xs/Process.xs
+++ b/xs/Process.xs
@@ -33,6 +33,8 @@ create_process(SV* shell, SV* cmd)
WCHAR* ccmd = SvPV(cmd, len);
STARTUPINFOW si;
PROCESS_INFORMATION pi;
+ SV* sv = newSV(0);
+ HV* hv = newHV();
ZeroMemory(&si,sizeof(si));
si.cb=sizeof(si);
@@ -52,8 +54,6 @@ create_process(SV* shell, SV* cmd)
XSRETURN_EMPTY;
}
- SV* sv = newSV(0);
- HV* hv = newHV();
sv_setsv(sv, sv_2mortal(newRV_noinc((SV*)hv)));
hv_store(hv, "thread_handle", strlen("thread_handle"), newSViv(pi.hThread), 0);
hv_store(hv, "process_handle", strlen("process_handle"), newSViv(pi.hProcess), 0);
diff --git a/xs/XS.xs b/xs/XS.xs
index 235dee3..f03042f 100644
--- a/xs/XS.xs
+++ b/xs/XS.xs
@@ -1,18 +1,17 @@
-#define PERL_NO_GET_CONTEXT
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-
-#include "ppport.h"
-#include "win32_unicode.h"
-
-MODULE = Win32::Unicode
-
-BOOT:
- WIN32_UNICODE_CALL_BOOT(Win32__Unicode__Dir);
- WIN32_UNICODE_CALL_BOOT(Win32__Unicode__File);
- WIN32_UNICODE_CALL_BOOT(Win32__Unicode__Error);
- WIN32_UNICODE_CALL_BOOT(Win32__Unicode__Console);
- WIN32_UNICODE_CALL_BOOT(Win32__Unicode__Process);
- WIN32_UNICODE_CALL_BOOT(Win32__Unicode__Native);
-
+#define PERL_NO_GET_CONTEXT
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#include "win32_unicode.h"
+
+MODULE = Win32::Unicode
+
+BOOT:
+ WIN32_UNICODE_CALL_BOOT(Win32__Unicode__Dir);
+ WIN32_UNICODE_CALL_BOOT(Win32__Unicode__File);
+ WIN32_UNICODE_CALL_BOOT(Win32__Unicode__Error);
+ WIN32_UNICODE_CALL_BOOT(Win32__Unicode__Console);
+ WIN32_UNICODE_CALL_BOOT(Win32__Unicode__Process);
+ WIN32_UNICODE_CALL_BOOT(Win32__Unicode__Native);
+
--
1.7.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment