diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1997-12-24 02:24:59 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1997-12-24 02:24:59 +0000 |
commit | 26618a56da4122343158bd70acec552d2e6da993 (patch) | |
tree | 4ba150d7472de986d3f220242c66b8153be08144 /win32 | |
parent | 473986ffed3c1c49ad493ce37648d9ef116e65bb (diff) | |
download | perl-26618a56da4122343158bd70acec552d2e6da993.tar.gz |
[win32] add support for crypt() via user-supplied des_fcrypt() source or library.
Update README.win32.
p4raw-id: //depot/win32/perl@385
Diffstat (limited to 'win32')
-rw-r--r-- | win32/Makefile | 35 | ||||
-rw-r--r-- | win32/makedef.pl | 5 | ||||
-rw-r--r-- | win32/makefile.mk | 43 | ||||
-rw-r--r-- | win32/win32.c | 38 | ||||
-rw-r--r-- | win32/win32.h | 3 | ||||
-rw-r--r-- | win32/win32iop.h | 39 |
6 files changed, 124 insertions, 39 deletions
diff --git a/win32/Makefile b/win32/Makefile index 968b1df3ef..12410e21fb 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -25,6 +25,16 @@ BUILDOPT=-DUSE_THREADS #CFG=Debug # +# if you have the source for des_fcrypt(), uncomment this and make sure the +# file exists (see README.win32) +#CRYPT_SRC=des_fcrypt.c + +# +# if you didn't set CRYPT_SRC and if you have des_fcrypt() available in a +# library, uncomment this, and make sure the library exists (see README.win32) +#CRYPT_LIB=des_fcrypt.lib + +# # set the install locations of the compiler include/libraries #CCHOME = f:\msvc20 CCHOME = $(MSVCDIR) @@ -38,6 +48,13 @@ CCLIBDIR = $(CCHOME)\lib ##################### CHANGE THESE ONLY IF YOU MUST ##################### +!IF "$(CRYPT_SRC)$(CRYPT_LIB)" == "" +D_CRYPT=undef +!ELSE +D_CRYPT=define +CRYPT_FLAG=-DHAVE_DES_FCRYPT +!ENDIF + # # Programs to compile, build .lib files and link # @@ -53,7 +70,7 @@ RUNTIME = -MD !ENDIF INCLUDES = -I.\include -I. -I.. #PCHFLAGS = -Fp"$(INTDIR)/modules.pch" -YX -DEFINES = -DWIN32 -D_CONSOLE $(BUILDOPT) +DEFINES = -DWIN32 -D_CONSOLE $(BUILDOPT) $(CRYPT_FLAG) LOCDEFS = -DPERLDLL -DPERL_CORE SUBSYS = console @@ -82,7 +99,7 @@ LINK_DBG = -release !ENDIF # we don't add LIBC here, the compiler do it based on -MD/-MT -LIBFILES = oldnames.lib kernel32.lib user32.lib gdi32.lib \ +LIBFILES = $(CRYPT_LIB) oldnames.lib kernel32.lib user32.lib gdi32.lib \ winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib \ oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib \ version.lib odbc32.lib odbccp32.lib @@ -141,6 +158,10 @@ XCOPY=xcopy /f /r /i /d RCOPY=xcopy /f /r /i /e /d NULL= +!IF "$(CRYPT_SRC)" != "" +CRYPT_OBJ=$(CRYPT_SRC:.c=.obj) +!ENDIF + # # filenames given to xsubpp must have forward slashes (since it puts # full pathnames in #line strings) @@ -172,7 +193,8 @@ CORE_C= ..\av.c \ ..\toke.c \ ..\universal.c \ ..\util.c \ - ..\malloc.c + ..\malloc.c \ + $(CRYPT_SRC) CORE_OBJ= ..\av$(o) \ ..\deb$(o) \ @@ -200,7 +222,8 @@ CORE_OBJ= ..\av$(o) \ ..\toke$(o) \ ..\universal$(o)\ ..\util$(o) \ - ..\malloc$(o) + ..\malloc$(o) \ + $(CRYPT_OBJ) WIN32_C = perllib.c \ win32.c \ @@ -213,7 +236,8 @@ WIN32_OBJ = win32$(o) \ PERL95_OBJ = perl95$(o) \ win32mt$(o) \ - win32sckmt$(o) + win32sckmt$(o) \ + $(CRYPT_OBJ) DLL_OBJ = perllib$(o) $(DYNALOADER)$(o) @@ -324,6 +348,7 @@ config.w32 : $(CFGSH_TMPL) "cc=$(CC)" \ "ccflags=$(OPTIMIZE) $(DEFINES)" \ "cf_email=$(EMAIL)" \ + "d_crypt=$(D_CRYPT)" \ "libs=$(LIBFILES)" \ "incpath=$(CCINCDIR)" \ "libpth=$(CCLIBDIR)" \ diff --git a/win32/makedef.pl b/win32/makedef.pl index 75bd1c7bfc..766a4266f4 100644 --- a/win32/makedef.pl +++ b/win32/makedef.pl @@ -280,6 +280,11 @@ unless ($define{'DEBUGGING'}) Perl_watchok)]; } +if ($define{'HAVE_DES_FCRYPT'}) + { + emit_symbols [qw(win32_crypt)]; + } + open (GLOBAL, "<../global.sym") || die "failed to open global.sym" . $!; while (<GLOBAL>) { diff --git a/win32/makefile.mk b/win32/makefile.mk index 2ab571a91d..916d73c526 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -36,6 +36,16 @@ CCTYPE *= BORLAND #CFG *= Debug # +# if you have the source for des_fcrypt(), uncomment this and make sure the +# file exists (see README.win32) +#CRYPT_SRC *= des_fcrypt.c + +# +# if you didn't set CRYPT_SRC and if you have des_fcrypt() available in a +# library, uncomment this, and make sure the library exists (see README.win32) +#CRYPT_LIB *= des_fcrypt.lib + +# # set the install locations of the compiler include/libraries #CCHOME *= f:\msdev\vc CCHOME *= C:\bc5 @@ -55,6 +65,13 @@ CCLIBDIR *= $(CCHOME)\lib ##################### CHANGE THESE ONLY IF YOU MUST ##################### +.IF "$(CRYPT_SRC)$(CRYPT_LIB)" == "" +D_CRYPT=undef +.ELSE +D_CRYPT=define +CRYPT_FLAG=-DHAVE_DES_FCRYPT +.ENDIF + # # Programs to compile, build .lib files and link # @@ -74,11 +91,11 @@ IMPLIB = implib -c RUNTIME = -D_RTLDLL INCLUDES = -I.\include -I. -I.. -I$(CCINCDIR) #PCHFLAGS = -H -H$(INTDIR)\bcmoduls.pch -DEFINES = -DWIN32 $(BUILDOPT) +DEFINES = -DWIN32 $(BUILDOPT) $(CRYPT_FLAG) LOCDEFS = -DPERLDLL -DPERL_CORE SUBSYS = console LIBC = cw32mti.lib -LIBFILES = import32.lib $(LIBC) odbc32.lib odbccp32.lib +LIBFILES = $(CRYPT_LIB) import32.lib $(LIBC) odbc32.lib odbccp32.lib WINIOMAYBE = @@ -109,11 +126,11 @@ o = .o # RUNTIME = INCLUDES = -I.\include -I. -I.. -DEFINES = -DWIN32 $(BUILDOPT) +DEFINES = -DWIN32 $(BUILDOPT) $(CRYPT_FLAG) LOCDEFS = -DPERLDLL -DPERL_CORE SUBSYS = console LIBC = -lcrtdll -LIBFILES = -ladvapi32 -luser32 -lwsock32 -lmingw32 -lgcc -lmoldname $(LIBC) \ +LIBFILES = $(CRYPT_LIB) -ladvapi32 -luser32 -lwsock32 -lmingw32 -lgcc -lmoldname $(LIBC) \ -lkernel32 WINIOMAYBE = @@ -144,7 +161,7 @@ RUNTIME = -MD .ENDIF INCLUDES = -I.\include -I. -I.. #PCHFLAGS = -Fp$(INTDIR)\vcmoduls.pch -YX -DEFINES = -DWIN32 -D_CONSOLE $(BUILDOPT) +DEFINES = -DWIN32 -D_CONSOLE $(BUILDOPT) $(CRYPT_FLAG) LOCDEFS = -DPERLDLL -DPERL_CORE SUBSYS = console @@ -177,7 +194,7 @@ LINK_DBG = -release PROCESSOR_ARCHITECTURE *= x86 # we don't add LIBC here, the compiler do it based on -MD/-MT -LIBFILES = oldnames.lib kernel32.lib user32.lib gdi32.lib \ +LIBFILES = $(CRYPT_LIB) oldnames.lib kernel32.lib user32.lib gdi32.lib \ winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib \ oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib \ version.lib odbc32.lib odbccp32.lib @@ -261,6 +278,10 @@ XCOPY=xcopy /f /r /i /d RCOPY=xcopy /f /r /i /e /d #NULL= +.IF "$(CRYPT_SRC)" != "" +CRYPT_OBJ=$(CRYPT_SRC:db:+$(o)) +.ENDIF + # # filenames given to xsubpp must have forward slashes (since it puts # full pathnames in #line strings) @@ -292,7 +313,8 @@ CORE_C= ..\av.c \ ..\toke.c \ ..\universal.c \ ..\util.c \ - ..\malloc.c + ..\malloc.c \ + $(CRYPT_SRC) CORE_OBJ= ..\av$(o) \ ..\deb$(o) \ @@ -320,7 +342,8 @@ CORE_OBJ= ..\av$(o) \ ..\toke$(o) \ ..\universal$(o)\ ..\util$(o) \ - ..\malloc$(o) + ..\malloc$(o) \ + $(CRYPT_OBJ) WIN32_C = perllib.c \ win32.c \ @@ -333,7 +356,8 @@ WIN32_OBJ = win32$(o) \ PERL95_OBJ = perl95$(o) \ win32mt$(o) \ - win32sckmt$(o) + win32sckmt$(o) \ + $(CRYPT_OBJ) DLL_OBJ = perllib$(o) $(DYNALOADER)$(o) @@ -452,6 +476,7 @@ config.w32 : $(CFGSH_TMPL) "cc=$(CC)" \ "ccflags=$(OPTIMIZE) $(DEFINES)" \ "cf_email=$(EMAIL)" \ + "d_crypt=$(D_CRYPT)" \ "libs=$(LIBFILES:f)" \ "incpath=$(CCINCDIR)" \ "libpth=$(strip $(CCLIBDIR) $(LIBFILES:d))" \ diff --git a/win32/win32.c b/win32/win32.c index dcdda533d6..1de1bb870f 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -55,6 +55,23 @@ char szShellPath[MAX_PATH+1]; char szPerlLibRoot[MAX_PATH+1]; HANDLE PerlDllHandle = INVALID_HANDLE_VALUE; +#ifdef USE_THREADS +# ifdef USE_DECLSPEC_THREAD +__declspec(thread) char strerror_buffer[512]; +# ifdef HAVE_DES_FCRYPT +__declspec(thread) char crypt_buffer[30]; +# endif +# else +# define strerror_buffer (thr->i.Wstrerror_buffer) +# define crypt_buffer (thr->i.Wcrypt_buffer) +# endif +#else +char strerror_buffer[512]; +# ifdef HAVE_DES_FCRYPT +char crypt_buffer[30]; +# endif +#endif + static int do_spawn2(char *cmd, int exectype); int @@ -733,6 +750,17 @@ win32_alarm(unsigned int sec) return 0; } +#ifdef HAVE_DES_FCRYPT +extern char * des_fcrypt(char *cbuf, const char *txt, const char *salt); + +DllExport char * +win32_crypt(const char *txt, const char *salt) +{ + dTHR; + return des_fcrypt(crypt_buffer, txt, salt); +} +#endif + #ifdef USE_FIXED_OSFHANDLE EXTERN_C int __cdecl _alloc_osfhnd(void); @@ -936,16 +964,6 @@ win32_feof(FILE *fp) * we have to roll our own. */ -#ifdef USE_THREADS -#ifdef USE_DECLSPEC_THREAD -__declspec(thread) char strerror_buffer[512]; -#else -#define strerror_buffer (thr->i.Wstrerror_buffer) -#endif -#else -char strerror_buffer[512]; -#endif - DllExport char * win32_strerror(int e) { diff --git a/win32/win32.h b/win32/win32.h index a58e884fc8..7534ec5f31 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -212,6 +212,9 @@ struct thread_intern { char Wstrerror_buffer[512]; struct servent Wservent; +#ifdef HAVE_DES_FCRYPT + char Wcrypt_buffer[30]; +#endif }; #endif #endif diff --git a/win32/win32iop.h b/win32/win32iop.h index 78c90e1696..d565cb51e0 100644 --- a/win32/win32iop.h +++ b/win32/win32iop.h @@ -54,23 +54,23 @@ DllExport int win32_fputc(int c,FILE *pf); DllExport int win32_ungetc(int c,FILE *pf); DllExport int win32_getc(FILE *pf); DllExport int win32_fileno(FILE *pf); -DllExport void win32_clearerr(FILE *pf); +DllExport void win32_clearerr(FILE *pf); DllExport int win32_fflush(FILE *pf); -DllExport long win32_ftell(FILE *pf); +DllExport long win32_ftell(FILE *pf); DllExport int win32_fseek(FILE *pf,long offset,int origin); DllExport int win32_fgetpos(FILE *pf,fpos_t *p); DllExport int win32_fsetpos(FILE *pf,const fpos_t *p); -DllExport void win32_rewind(FILE *pf); +DllExport void win32_rewind(FILE *pf); DllExport FILE* win32_tmpfile(void); -DllExport void win32_abort(void); +DllExport void win32_abort(void); DllExport int win32_fstat(int fd,struct stat *sbufptr); DllExport int win32_stat(const char *name,struct stat *sbufptr); DllExport int win32_pipe( int *phandles, unsigned int psize, int textmode ); DllExport FILE* win32_popen( const char *command, const char *mode ); DllExport int win32_pclose( FILE *pf); DllExport int win32_setmode( int fd, int mode); -DllExport long win32_lseek( int fd, long offset, int origin); -DllExport long win32_tell( int fd); +DllExport long win32_lseek( int fd, long offset, int origin); +DllExport long win32_tell( int fd); DllExport int win32_dup( int fd); DllExport int win32_dup2(int h1, int h2); DllExport int win32_open(const char *path, int oflag,...); @@ -85,8 +85,8 @@ DllExport int win32_rmdir(const char *dir); DllExport int win32_chdir(const char *dir); DllExport int win32_flock(int fd, int oper); DllExport int win32_execvp(const char *cmdname, const char *const *argv); -DllExport void win32_perror(const char *str); -DllExport void win32_setbuf(FILE *pf, char *buf); +DllExport void win32_perror(const char *str); +DllExport void win32_setbuf(FILE *pf, char *buf); DllExport int win32_setvbuf(FILE *pf, char *buf, int type, size_t size); DllExport int win32_flushall(void); DllExport int win32_fcloseall(void); @@ -100,20 +100,24 @@ DllExport int win32_putchar(int c); DllExport void* win32_malloc(size_t size); DllExport void* win32_calloc(size_t numitems, size_t size); DllExport void* win32_realloc(void *block, size_t size); -DllExport void win32_free(void *block); +DllExport void win32_free(void *block); DllExport int win32_open_osfhandle(long handle, int flags); -DllExport long win32_get_osfhandle(int fd); +DllExport long win32_get_osfhandle(int fd); #ifndef USE_WIN32_RTL_ENV DllExport char* win32_getenv(const char *name); #endif -DllExport unsigned int win32_sleep(unsigned int); -DllExport int win32_times(struct tms *timebuf); -DllExport unsigned int win32_alarm(unsigned int sec); -DllExport int win32_flock(int fd, int oper); -DllExport int win32_stat(const char *path, struct stat *buf); +DllExport unsigned win32_sleep(unsigned int); +DllExport int win32_times(struct tms *timebuf); +DllExport unsigned win32_alarm(unsigned int sec); +DllExport int win32_flock(int fd, int oper); +DllExport int win32_stat(const char *path, struct stat *buf); + +#ifdef HAVE_DES_FCRYPT +DllExport char * win32_crypt(const char *txt, const char *salt); +#endif END_EXTERN_C @@ -233,6 +237,11 @@ END_EXTERN_C #define times win32_times #define alarm win32_alarm +#ifdef HAVE_DES_FCRYPT +#undef crypt +#define crypt win32_crypt +#endif + #ifndef USE_WIN32_RTL_ENV #undef getenv #define getenv win32_getenv |