From: Richard Basch Date: Thu, 6 Feb 1997 02:31:41 +0000 (+0000) Subject: Windows/NT integration (V1_0_WIN32_BRANCH merge) X-Git-Tag: krb5-1.1-beta1~1382 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a0b9ce4bee60136363cfff7a93c4e42eab972c02;p=krb5.git Windows/NT integration (V1_0_WIN32_BRANCH merge) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9788 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/include/krb5/ChangeLog b/src/include/krb5/ChangeLog index 01201ba03..d3c889ae7 100644 --- a/src/include/krb5/ChangeLog +++ b/src/include/krb5/ChangeLog @@ -1,3 +1,9 @@ +Thu Nov 21 11:55:16 EST 1996 Richard Basch + + * Makefile.in: + all-windows needed :: not : + clean up various generated files on all platforms, not just unix + Wed Oct 30 18:55:21 1996 Sam Hartman * Makefile.in (LOCALSTATEDIR): Add localstatedir a and sysconfidr diff --git a/src/include/krb5/Makefile.in b/src/include/krb5/Makefile.in index d60ac1ae8..b3500dd4b 100644 --- a/src/include/krb5/Makefile.in +++ b/src/include/krb5/Makefile.in @@ -11,9 +11,10 @@ BUILT_HEADERS = osconf.h all-unix:: autoconf.h $(BUILT_HEADERS) all-mac:: $(BUILT_HEADERS) -all-windows: +all-windows:: + $(RM) osconf.h autoconf.h autoconf.stamp copy stock\osconf.h osconf.h - echo /* not used in windows */ > autoconf.h + echo #include "win-mac.h" > autoconf.h # Should only rebuild autoconf.h here (use CONFIG_FILES=), but the weird krb5 # makefile post-processing is unconditional and would trash the makefile. @@ -46,4 +47,6 @@ clean:: clean-unix:: $(RM) $(ET_HEADERS) autoconf.h autoconf.stamp clean-mac:: + $(RM) osconf.h autoconf.h autoconf.stamp clean-windows:: + $(RM) osconf.h autoconf.h autoconf.stamp diff --git a/src/lib/ChangeLog b/src/lib/ChangeLog index 38f08ba6c..f1d2d706a 100644 --- a/src/lib/ChangeLog +++ b/src/lib/ChangeLog @@ -1,3 +1,25 @@ +Tue Feb 4 15:52:34 1997 Richard Basch + + * gssapi16.def: Declare the library name (win16) + + * krb5_16.def krb5_32.def: New ComErr interface definitions + + * krb5_32.def: Remove unsupported statements (EXETYPE, RESIDENTNAME) + +Sun Feb 2 11:22:24 1997 Richard Basch + + * krb5_16.def: Need to declare the library name + +Thu Jan 30 21:27:07 1997 Richard Basch + + * krb5_16.def krb5_32.def: + Export krb5_decrypt, krb5_encrypt, + krb5_string_to_key, krb5_process_key, krb5_finish_key, + krb5_init_random_key, krb5_finish_random_key, + krb5_random_key, krb5_eblock_enctype + * Makefile.in + Win32 - Link against MSVCRT.LIB (runtime library) + Sat Dec 21 01:23:48 1996 Theodore Y. Ts'o * win_glue.c: Change the timebomb to be June 1, 1997. Make the diff --git a/src/lib/Makefile.in b/src/lib/Makefile.in index b8cd3980a..43662d93c 100644 --- a/src/lib/Makefile.in +++ b/src/lib/Makefile.in @@ -19,38 +19,51 @@ clean-unix:: $(RM) $(CLEANLIBS) clean-windows:: - $(RM) krb5_16.dll krb5_16.lib krb5_16.bak krb5_16.map winsock.lib - $(RM) gssapi.dll gssapi.lib gssapi.bak gssapi.map + $(RM) *.dll *.lib *.exp *.map *.bak + # -# Windows stuff to make krb5_16.dll and krb5_16.lib. Currently it +# Windows stuff to make krb5.dll and krb5.lib. Currently it # combines crypto, krb5, kadm and the util/et directories. # -ALIB = kadm\kadm.lib -CLIB = crypto\crypto.lib -KLIB = krb5\krb5.lib -GLIB = gssapi\gssapi.lib -ETLIB = $(BUILDTOP)\util\et\comerr.lib -PLIB = $(BUILDTOP)\util\profile\profile.lib -WLIB = .\winsock.lib -LIBS = $(ALIB) $(CLIB) $(KLIB) $(GLIB) $(ETLIB) $(PLIB) $(WLIB) - -lib-windows: winsock.lib krb5_16.lib gssapi.lib - -gssapi.lib:: gssapi.dll - implib /nologo gssapi.lib gssapi.dll +GLIBS = gssapi\gssapi.lib +KLIBS = krb5\krb5.lib crypto\crypto.lib \ + $(BUILDTOP)\util\profile\profile.lib \ + $(BUILDTOP)\util\et\comerr.lib \ + kadm\kadm.lib des425\des425.lib + +##WIN16##KDEF = krb5_16.def +##WIN32##KDEF = krb5_32.def +##WIN16##GDEF = gssapi16.def +##WIN32##GDEF = gssapi32.def + +##WIN16##WLIB = .\winsock.lib +##WIN16##WINLIBS = $(WLIB) ldllcew libw oldnames +##WIN32##WINLIBS = msvcrt.lib kernel32.lib wsock32.lib \ +##WIN32## user32.lib shell32.lib oldnames.lib +##WIN32##WINDLLFLAGS = /nodefaultlib /incremental:no /pdb:none /release \ +##WIN32## /nologo /align:0x1000 /base:0x1c000000 /dll /debug + + + +$(KLIB): $(KLIBS) $(WLIB) $(KDEF) win_glue.obj +##WIN16## link /co /seg:400 /noe /nod /nol \ +##WIN16## win_glue, $*.dll, $*.map, \ +##WIN16## $(KLIBS) $(WINLIBS), $(KDEF) +##WIN16## rc /nologo /p /k $*.dll +##WIN16## implib /nologo $@ $*.dll +##WIN32## link $(WINDLLFLAGS) /def:$(KDEF) /out:$*.dll \ +##WIN32## win_glue.obj $(KLIBS) $(WINLIBS) + +$(GLIB): $(GLIBS) $(KLIB) $(GDEF) win_glue.obj +##WIN16## link /co /seg:400 /noe /nod /nol \ +##WIN16## win_glue, $*.dll, $*.map, \ +##WIN16## $(GLIBS) $(KLIB) $(WINLIBS), $(GDEF) +##WIN16## rc /nologo /p /k $*.dll +##WIN16## implib /nologo $@ $*.dll +##WIN32## link $(WINDLLFLAGS) /def:$(GDEF) /out:$*.dll \ +##WIN32## win_glue.obj $(GLIBS) $(KLIB) $(WINLIBS) -gssapi.dll:: $(GLIB) $(LIBS) gssapi.def win_glue.obj - link /co /seg:400 /noe /nod /nol win_glue, gssapi.dll, gssapi.map, \ - $(LIBS) ldllcew libw oldnames, gssapi.def - rc /nologo /p /k gssapi.dll -krb5_16.lib:: krb5_16.dll - implib /nologo krb5_16.lib krb5_16.dll - -krb5_16.dll:: $(LIBS) krb5_16.def win_glue.obj - link /co /seg:400 /noe /nod /nol win_glue, krb5_16.dll, krb5_16.map, \ - $(LIBS) ldllcew libw oldnames, krb5_16.def - rc /nologo /p /k krb5_16.dll sap_glue.obj: win_glue.c $(CC) $(CFLAGS) -DSAP_TIMEBOMB -I$(VERS_DIR) /c \ @@ -59,42 +72,59 @@ sap_glue.obj: win_glue.c win_glue.obj: win_glue.c $(CC) $(CFLAGS) /c win_glue.c -sapkrb5.dll:: $(GLIB) $(LIBS) gssapi.def sap_glue.obj - link /co /seg:400 /noe /nod /nol sap_glue, sapkrb5.dll, sapkrb5.map, \ - $(LIBS) $(VERS_DIR)\vswin.lib ldllcew libw oldnames, sapkrb5.def - rc /nologo /p /k sapkrb5.dll -winsock.lib: winsock.def - implib /nologo winsock.lib winsock.def + +##WIN16##sapkrb5.dll: $(GLIB) $(LIBS) gssapi.def sap_glue.obj +##WIN16## link /co /seg:400 /noe /nod /nol sap_glue, sapkrb5.dll, sapkrb5.map, \ +##WIN16## $(LIBS) $(VERS_DIR)\vswin.lib ldllcew libw oldnames, sapkrb5.def +##WIN16## rc /nologo /p /k sapkrb5.dll + +##WIN16##winsock.lib: winsock.def +##WIN16## implib /nologo winsock.lib winsock.def + + all-windows:: @echo Making in lib\crypto cd crypto -$(MAKE) -$(MFLAGS) + @echo Making in lib\krb5 + cd ..\krb5 + -$(MAKE) -$(MFLAGS) @echo Making in lib\kadm cd ..\kadm -$(MAKE) -$(MFLAGS) - @echo Making in lib\krb5 - cd ..\krb5 + @echo Making in lib\des425 + cd ..\des425 -$(MAKE) -$(MFLAGS) +# @echo Making in lib\krb4 +# cd ..\krb4 +# -$(MAKE) -$(MFLAGS) @echo Making in lib\gssapi cd ..\gssapi -$(MAKE) -$(MFLAGS) @echo Making in lib cd .. -all-windows:: krb5_16.lib gssapi.lib +all-windows:: lib-windows +lib-windows: $(KLIB) $(GLIB) clean-windows:: @echo Making clean in lib\crypto cd crypto -$(MAKE) -$(MFLAGS) clean + @echo Making clean in lib\krb5 + cd ..\krb5 + -$(MAKE) -$(MFLAGS) clean @echo Making clean in lib\kadm cd ..\kadm -$(MAKE) -$(MFLAGS) clean - @echo Making clean in lib\krb5 - cd ..\krb5 + @echo Making clean in lib\des425 + cd ..\des425 -$(MAKE) -$(MFLAGS) clean +# @echo Making clean in lib\krb4 +# cd ..\krb4 +# -$(MAKE) -$(MFLAGS) clean @echo Making clean in lib\gssapi cd ..\gssapi -$(MAKE) -$(MFLAGS) clean diff --git a/src/lib/crypto/crc32/ChangeLog b/src/lib/crypto/crc32/ChangeLog index b9e7d9e12..eaf0e8591 100644 --- a/src/lib/crypto/crc32/ChangeLog +++ b/src/lib/crypto/crc32/ChangeLog @@ -1,3 +1,11 @@ +Thu Jan 30 21:30:32 1997 Richard Basch + + * crc.c: Declare the functions to take const pointers, where possible. + +Thu Nov 21 00:58:04 EST 1996 Richard Basch + + * Makefile.in: Win32 build + Tue May 14 19:33:27 1996 Richard Basch * crc.c: ensure the cksum content length is sufficient diff --git a/src/lib/crypto/crc32/Makefile.in b/src/lib/crypto/crc32/Makefile.in index aa3cf8730..34255defb 100644 --- a/src/lib/crypto/crc32/Makefile.in +++ b/src/lib/crypto/crc32/Makefile.in @@ -1,7 +1,9 @@ CFLAGS = $(CCOPTS) $(DEFS) ##DOSBUILDTOP = ..\..\.. -##DOSLIBNAME=..\crypto.lib +##DOSMYNAME=crc32 +##DOSOBJFILE=..\crc32.lst +##WIN16##LIBNAME=..\crypto.lib .c.o: $(CC) $(CFLAGS) -c $(srcdir)/$*.c @@ -13,7 +15,12 @@ SRCS= $(srcdir)/crc.c all-unix:: shared $(OBJS) all-mac:: shared $(OBJS) -all-windows:: $(OBJS) +all-windows:: $(OBJFILE) + +##DOS$(OBJFILE): $(OBJS) +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) -p $(MYNAME)\ *.obj > $(OBJFILE) shared: mkdir shared @@ -36,3 +43,4 @@ clean-unix:: clean-mac:: $(RM) shared/* clean-windows:: + $(RM) $(OBJFILE) diff --git a/src/lib/crypto/crc32/crc.c b/src/lib/crypto/crc32/crc.c index 9f055200a..60afb3f4a 100644 --- a/src/lib/crypto/crc32/crc.c +++ b/src/lib/crypto/crc32/crc.c @@ -146,20 +146,28 @@ static u_long const crc_table[256] = { /* Windows needs to these prototypes for crc32_cksumtable_entry below */ static krb5_error_code -crc32_sum_func PROTOTYPE((krb5_pointer in, size_t in_length, - krb5_pointer seed, size_t seed_length, krb5_checksum *outcksum)); +crc32_sum_func PROTOTYPE(( + krb5_const krb5_pointer in, + krb5_const size_t in_length, + krb5_const krb5_pointer seed, + krb5_const size_t seed_length, + krb5_checksum FAR *outcksum)); static krb5_error_code -crc32_verify_func PROTOTYPE((krb5_checksum FAR *cksum, krb5_pointer in, - size_t in_length, krb5_pointer seed, size_t seed_length)); +crc32_verify_func PROTOTYPE(( + krb5_const krb5_checksum FAR *cksum, + krb5_const krb5_pointer in, + krb5_const size_t in_length, + krb5_const krb5_pointer seed, + krb5_const size_t seed_length)); static krb5_error_code crc32_sum_func(in, in_length, seed, seed_length, outcksum) -krb5_pointer in; -size_t in_length; -krb5_pointer seed; -size_t seed_length; -krb5_checksum FAR *outcksum; + krb5_const krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer seed; + krb5_const size_t seed_length; + krb5_checksum FAR *outcksum; { register u_char *data; register u_long c = 0; @@ -188,11 +196,11 @@ krb5_checksum FAR *outcksum; static krb5_error_code crc32_verify_func(cksum, in, in_length, seed, seed_length) -krb5_checksum FAR *cksum; -krb5_pointer in; -size_t in_length; -krb5_pointer seed; -size_t seed_length; + krb5_const krb5_checksum FAR *cksum; + krb5_const krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer seed; + krb5_const size_t seed_length; { register u_char *data; register u_long c = 0; diff --git a/src/lib/crypto/des/ChangeLog b/src/lib/crypto/des/ChangeLog index 6edc924c9..76ea95156 100644 --- a/src/lib/crypto/des/ChangeLog +++ b/src/lib/crypto/des/ChangeLog @@ -1,3 +1,12 @@ +Thu Jan 30 21:43:19 1997 Richard Basch + + * cbc_cksum.c + Change functions to take const args where possible + +Thu Nov 21 00:58:04 EST 1996 Richard Basch + + * Makefile.in: Win32 build + Sat Jun 15 03:51:19 1996 Ezra Peisach * Makefile.in (clean): Add space before \ diff --git a/src/lib/crypto/des/Makefile.in b/src/lib/crypto/des/Makefile.in index ad665617f..403cca650 100644 --- a/src/lib/crypto/des/Makefile.in +++ b/src/lib/crypto/des/Makefile.in @@ -1,7 +1,9 @@ CFLAGS = $(CCOPTS) $(DEFS) ##DOSBUILDTOP = ..\..\.. -##DOSLIBNAME=..\crypto.lib +##DOSMYNAME=des +##DOSOBJFILE=..\des.lst +##WIN16##LIBNAME=..\crypto.lib COMERRLIB=$(BUILDTOP)/util/et/libcom_err.$(LIBEXT) @@ -62,11 +64,14 @@ SRCS= $(srcdir)/afsstring2key.c \ $(srcdir)/u_rn_key.c -all:: $(OBJS) +all-unix:: $(OBJS) shared +all-mac:: $(OBJS) shared +all-windows:: $(OBJFILE) -all-unix:: shared -all-mac:: shared -all-windows:: +##DOS$(OBJFILE): $(OBJS) +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) -p $(MYNAME)\ *.obj > $(OBJFILE) shared: mkdir shared @@ -109,3 +114,4 @@ clean-unix:: clean-mac:: $(RM) shared/* clean-windows:: + $(RM) $(OBJFILE) diff --git a/src/lib/crypto/des/cbc_cksum.c b/src/lib/crypto/des/cbc_cksum.c index c4fb8c086..29a38a0a5 100644 --- a/src/lib/crypto/des/cbc_cksum.c +++ b/src/lib/crypto/des/cbc_cksum.c @@ -44,18 +44,25 @@ */ static krb5_error_code mit_des_cbc_checksum - PROTOTYPE((krb5_pointer, size_t,krb5_pointer,size_t, krb5_checksum FAR * )); + PROTOTYPE((krb5_const krb5_pointer, + krb5_const size_t, + krb5_const krb5_pointer, + krb5_const size_t, + krb5_checksum FAR * )); static krb5_error_code mit_des_cbc_verf_cksum - PROTOTYPE ((krb5_checksum FAR *, krb5_pointer, size_t, krb5_pointer, - size_t )); + PROTOTYPE ((krb5_const krb5_checksum FAR *, + krb5_const krb5_pointer, + krb5_const size_t, + krb5_const krb5_pointer, + krb5_const size_t )); static krb5_error_code mit_des_cbc_checksum(in, in_length, key, key_size, cksum) - krb5_pointer in; - size_t in_length; - krb5_pointer key; - size_t key_size; + krb5_const krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer key; + krb5_const size_t key_size; krb5_checksum FAR * cksum; { struct mit_des_ks_struct *schedule; /* pointer to key schedules */ @@ -95,11 +102,11 @@ mit_des_cbc_checksum(in, in_length, key, key_size, cksum) static krb5_error_code mit_des_cbc_verf_cksum(cksum, in, in_length, key, key_size) - krb5_checksum FAR * cksum; - krb5_pointer in; - size_t in_length; - krb5_pointer key; - size_t key_size; + krb5_const krb5_checksum FAR * cksum; + krb5_const krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer key; + krb5_const size_t key_size; { struct mit_des_ks_struct *schedule; /* pointer to key schedules */ mit_des_cblock contents; diff --git a/src/lib/crypto/md4/ChangeLog b/src/lib/crypto/md4/ChangeLog index 531fd8af7..b275f9823 100644 --- a/src/lib/crypto/md4/ChangeLog +++ b/src/lib/crypto/md4/ChangeLog @@ -1,3 +1,12 @@ +Thu Jan 30 21:42:03 1997 Richard Basch + + * md4crypto.c md4glue.c: + Change functions to take const args where possible + +Thu Nov 21 00:58:04 EST 1996 Richard Basch + + * Makefile.in: Win32 build + Wed Jun 12 00:10:42 1996 Theodore Ts'o * md4.c diff --git a/src/lib/crypto/md4/Makefile.in b/src/lib/crypto/md4/Makefile.in index c7af3d1b0..e4c54f030 100644 --- a/src/lib/crypto/md4/Makefile.in +++ b/src/lib/crypto/md4/Makefile.in @@ -2,7 +2,10 @@ CFLAGS = $(CCOPTS) $(DEFS) -I$(srcdir)/../des -I"$(srcdir)" ##DOSBUILDTOP = ..\..\.. -##DOSLIBNAME=..\crypto.lib +##DOSMYNAME=md4 +##DOSOBJFILE=..\md4.lst +##WIN16##LIBNAME=..\crypto.lib + RUN_SETUP=@KRB5_RUN_ENV@ .c.o: @@ -15,7 +18,12 @@ SRCS= $(srcdir)/md4.c $(srcdir)/md4glue.c $(srcdir)/md4crypto.c all-unix:: shared $(OBJS) all-mac:: shared $(OBJS) -all-windows:: $(OBJS) +all-windows:: $(OBJFILE) + +##DOS$(OBJFILE): $(OBJS) +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) -p $(MYNAME)\ *.obj > $(OBJFILE) shared: mkdir shared @@ -59,3 +67,4 @@ clean-unix:: clean-mac:: $(RM) shared/* clean-windows:: + $(RM) $(OBJFILE) diff --git a/src/lib/crypto/md4/md4crypto.c b/src/lib/crypto/md4/md4crypto.c index 43d644366..eac9647f2 100644 --- a/src/lib/crypto/md4/md4crypto.c +++ b/src/lib/crypto/md4/md4crypto.c @@ -28,18 +28,6 @@ #include "rsa-md4.h" #include "des_int.h" /* we cheat a bit and call it directly... */ -/* Windows needs to these prototypes for the assignment below */ - -krb5_error_code -krb5_md4_crypto_sum_func PROTOTYPE((krb5_pointer in, size_t in_length, - krb5_pointer seed, size_t seed_length, krb5_checksum *outcksum)); - -krb5_error_code -krb5_md4_crypto_verify_func PROTOTYPE((krb5_checksum FAR *cksum, krb5_pointer in, - size_t in_length, krb5_pointer seed, size_t seed_length)); - -static mit_des_cblock zero_ivec = { 0 }; - /* * In Kerberos V5 Beta 5 and previous releases the RSA-MD4-DES implementation * did not follow RFC1510. The folowing definitions control the compatibility @@ -56,6 +44,37 @@ static mit_des_cblock zero_ivec = { 0 }; #define MD4_K5BETA_COMPAT #define MD4_K5BETA_COMPAT_DEF + +/* Windows needs to these prototypes for the assignment below */ + +#ifdef MD4_K5BETA_COMPAT +krb5_error_code +krb5_md4_crypto_compat_sum_func PROTOTYPE(( + krb5_const krb5_pointer in, + krb5_const size_t in_length, + krb5_const krb5_pointer seed, + krb5_const size_t seed_length, + krb5_checksum *outcksum)); +#endif + +krb5_error_code +krb5_md4_crypto_sum_func PROTOTYPE(( + krb5_const krb5_pointer in, + krb5_const size_t in_length, + krb5_const krb5_pointer seed, + krb5_const size_t seed_length, + krb5_checksum *outcksum)); + +krb5_error_code +krb5_md4_crypto_verify_func PROTOTYPE(( + krb5_const krb5_checksum FAR *cksum, + krb5_const krb5_pointer in, + krb5_const size_t in_length, + krb5_const krb5_pointer seed, + krb5_const size_t seed_length)); + +static mit_des_cblock zero_ivec = { 0 }; + static void krb5_md4_calculate_cksum(md4ctx, confound, confound_length, in, in_length) krb5_MD4_CTX *md4ctx; @@ -78,11 +97,11 @@ krb5_md4_calculate_cksum(md4ctx, confound, confound_length, in, in_length) */ krb5_error_code krb5_md4_crypto_compat_sum_func(in, in_length, seed, seed_length, outcksum) -krb5_pointer in; -size_t in_length; -krb5_pointer seed; -size_t seed_length; -krb5_checksum FAR *outcksum; + krb5_const krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer seed; + krb5_const size_t seed_length; + krb5_checksum FAR *outcksum; { krb5_octet outtmp[OLD_RSA_MD4_DES_CKSUM_LENGTH]; krb5_octet *input = (krb5_octet *)in; @@ -131,11 +150,11 @@ krb5_checksum FAR *outcksum; */ krb5_error_code krb5_md4_crypto_sum_func(in, in_length, seed, seed_length, outcksum) -krb5_pointer in; -size_t in_length; -krb5_pointer seed; -size_t seed_length; -krb5_checksum FAR *outcksum; + krb5_const krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer seed; + krb5_const size_t seed_length; + krb5_checksum FAR *outcksum; { krb5_octet outtmp[NEW_RSA_MD4_DES_CKSUM_LENGTH]; mit_des_cblock tmpkey; @@ -195,11 +214,11 @@ krb5_checksum FAR *outcksum; krb5_error_code krb5_md4_crypto_verify_func(cksum, in, in_length, seed, seed_length) -krb5_checksum FAR *cksum; -krb5_pointer in; -size_t in_length; -krb5_pointer seed; -size_t seed_length; + krb5_const krb5_checksum FAR *cksum; + krb5_const krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer seed; + krb5_const size_t seed_length; { krb5_octet outtmp[NEW_RSA_MD4_DES_CKSUM_LENGTH]; mit_des_cblock tmpkey; diff --git a/src/lib/crypto/md4/md4glue.c b/src/lib/crypto/md4/md4glue.c index df33c8a23..f7e566e9b 100644 --- a/src/lib/crypto/md4/md4glue.c +++ b/src/lib/crypto/md4/md4glue.c @@ -29,20 +29,28 @@ /* Windows needs to these prototypes for the assignment below */ krb5_error_code -krb5_md4_sum_func PROTOTYPE((krb5_pointer in, size_t in_length, - krb5_pointer seed, size_t seed_length, krb5_checksum *outcksum)); +krb5_md4_sum_func PROTOTYPE(( + krb5_const krb5_pointer in, + krb5_const size_t in_length, + krb5_const krb5_pointer seed, + krb5_const size_t seed_length, + krb5_checksum FAR *outcksum)); krb5_error_code -krb5_md4_verify_func PROTOTYPE((krb5_checksum FAR *cksum, krb5_pointer in, - size_t in_length, krb5_pointer seed, size_t seed_length)); +krb5_md4_verify_func PROTOTYPE(( + krb5_const krb5_checksum FAR *cksum, + krb5_const krb5_pointer in, + krb5_const size_t in_length, + krb5_const krb5_pointer seed, + krb5_const size_t seed_length)); krb5_error_code krb5_md4_sum_func(in, in_length, seed, seed_length, outcksum) -krb5_pointer in; -size_t in_length; -krb5_pointer seed; -size_t seed_length; -krb5_checksum FAR *outcksum; + krb5_const krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer seed; + krb5_const size_t seed_length; + krb5_checksum FAR *outcksum; { krb5_octet *input = (krb5_octet *)in; krb5_MD4_CTX working; @@ -66,11 +74,11 @@ krb5_checksum FAR *outcksum; krb5_error_code krb5_md4_verify_func(cksum, in, in_length, seed, seed_length) -krb5_checksum FAR *cksum; -krb5_pointer in; -size_t in_length; -krb5_pointer seed; -size_t seed_length; + krb5_const krb5_checksum FAR *cksum; + krb5_const krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer seed; + krb5_const size_t seed_length; { krb5_octet *input = (krb5_octet *)in; krb5_MD4_CTX working; diff --git a/src/lib/crypto/md5/ChangeLog b/src/lib/crypto/md5/ChangeLog index 9e73726bc..b771bedd2 100644 --- a/src/lib/crypto/md5/ChangeLog +++ b/src/lib/crypto/md5/ChangeLog @@ -1,3 +1,12 @@ +Thu Jan 30 21:42:50 1997 Richard Basch + + * md5crypto.c md5glue.c: + Change functions to take const args where possible + +Thu Nov 21 00:58:04 EST 1996 Richard Basch + + * Makefile.in: Win32 build + Wed Jun 12 00:11:34 1996 Theodore Ts'o * rsa-md5.h: diff --git a/src/lib/crypto/md5/Makefile.in b/src/lib/crypto/md5/Makefile.in index f7d3292ad..8c009cd83 100644 --- a/src/lib/crypto/md5/Makefile.in +++ b/src/lib/crypto/md5/Makefile.in @@ -1,7 +1,10 @@ CFLAGS = $(CCOPTS) $(DEFS) -I$(srcdir)/../des ##DOSBUILDTOP = ..\..\.. -##DOSLIBNAME=..\crypto.lib +##DOSMYNAME=md5 +##DOSOBJFILE=..\md5.lst +##WIN16##LIBNAME=..\crypto.lib + RUN_SETUP = @KRB5_RUN_ENV@ .c.o: $(CC) $(CFLAGS) -c $(srcdir)/$*.c @@ -13,7 +16,12 @@ SRCS= $(srcdir)/md5.c $(srcdir)/md5glue.c $(srcdir)/md5crypto.c all-unix:: shared $(OBJS) all-mac:: shared $(OBJS) -all-windows:: $(OBJS) +all-windows:: $(OBJFILE) + +##DOS$(OBJFILE): $(OBJS) +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) -p $(MYNAME)\ *.obj > $(OBJFILE) shared: mkdir shared @@ -43,3 +51,4 @@ clean-unix:: clean-mac:: $(RM) shared/* clean-windows:: + $(RM) $(OBJFILE) diff --git a/src/lib/crypto/md5/md5crypto.c b/src/lib/crypto/md5/md5crypto.c index 1982a56e2..b83e50e77 100644 --- a/src/lib/crypto/md5/md5crypto.c +++ b/src/lib/crypto/md5/md5crypto.c @@ -2,18 +2,6 @@ #include "rsa-md5.h" #include "des_int.h" /* we cheat a bit and call it directly... */ -/* Windows needs to these prototypes for the assignment below */ - -krb5_error_code -krb5_md5_crypto_sum_func PROTOTYPE((krb5_pointer in, size_t in_length, - krb5_pointer seed, size_t seed_length, krb5_checksum FAR *outcksum)); - -krb5_error_code -krb5_md5_crypto_verify_func PROTOTYPE((krb5_checksum FAR *cksum, krb5_pointer in, - size_t in_length, krb5_pointer seed, size_t seed_length)); - -static mit_des_cblock zero_ivec = { 0 }; - /* * In Kerberos V5 Beta 5 and previous releases the RSA-MD5-DES implementation * did not follow RFC1510. The folowing definitions control the compatibility @@ -30,6 +18,37 @@ static mit_des_cblock zero_ivec = { 0 }; #define MD5_K5BETA_COMPAT #define MD5_K5BETA_COMPAT_DEF + +/* Windows needs to these prototypes for the assignment below */ + +#ifdef MD5_K5BETA_COMPAT +krb5_error_code +krb5_md5_crypto_compat_sum_func PROTOTYPE(( + krb5_const krb5_pointer in, + krb5_const size_t in_length, + krb5_const krb5_pointer seed, + krb5_const size_t seed_length, + krb5_checksum FAR *outcksum)); +#endif + +krb5_error_code +krb5_md5_crypto_sum_func PROTOTYPE(( + krb5_const krb5_pointer in, + krb5_const size_t in_length, + krb5_const krb5_pointer seed, + krb5_const size_t seed_length, + krb5_checksum FAR *outcksum)); + +krb5_error_code +krb5_md5_crypto_verify_func PROTOTYPE(( + krb5_const krb5_checksum FAR *cksum, + krb5_const krb5_pointer in, + krb5_const size_t in_length, + krb5_const krb5_pointer seed, + krb5_const size_t seed_length)); + +static mit_des_cblock zero_ivec = { 0 }; + static void krb5_md5_calculate_cksum(md5ctx, confound, confound_length, in, in_length) krb5_MD5_CTX *md5ctx; @@ -48,11 +67,11 @@ krb5_md5_calculate_cksum(md5ctx, confound, confound_length, in, in_length) #ifdef MD5_K5BETA_COMPAT krb5_error_code krb5_md5_crypto_compat_sum_func(in, in_length, seed, seed_length, outcksum) -krb5_pointer in; -size_t in_length; -krb5_pointer seed; -size_t seed_length; -krb5_checksum FAR *outcksum; + krb5_const krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer seed; + krb5_const size_t seed_length; + krb5_checksum FAR *outcksum; { krb5_octet outtmp[OLD_RSA_MD5_DES_CKSUM_LENGTH]; krb5_octet *input = (krb5_octet *)in; @@ -96,11 +115,11 @@ krb5_checksum FAR *outcksum; krb5_error_code krb5_md5_crypto_sum_func(in, in_length, seed, seed_length, outcksum) -krb5_pointer in; -size_t in_length; -krb5_pointer seed; -size_t seed_length; -krb5_checksum FAR *outcksum; + krb5_const krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer seed; + krb5_const size_t seed_length; + krb5_checksum FAR *outcksum; { krb5_octet outtmp[NEW_RSA_MD5_DES_CKSUM_LENGTH]; mit_des_cblock tmpkey; @@ -162,11 +181,11 @@ krb5_checksum FAR *outcksum; krb5_error_code krb5_md5_crypto_verify_func(cksum, in, in_length, seed, seed_length) -krb5_checksum FAR *cksum; -krb5_pointer in; -size_t in_length; -krb5_pointer seed; -size_t seed_length; + krb5_const krb5_checksum FAR *cksum; + krb5_const krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer seed; + krb5_const size_t seed_length; { krb5_octet outtmp[NEW_RSA_MD5_DES_CKSUM_LENGTH]; mit_des_cblock tmpkey; diff --git a/src/lib/crypto/md5/md5glue.c b/src/lib/crypto/md5/md5glue.c index 77aca3686..66d5aa791 100644 --- a/src/lib/crypto/md5/md5glue.c +++ b/src/lib/crypto/md5/md5glue.c @@ -4,20 +4,28 @@ /* Windows needs to these prototypes for the assignment below */ krb5_error_code -krb5_md5_sum_func PROTOTYPE((krb5_pointer in, size_t in_length, - krb5_pointer seed, size_t seed_length, krb5_checksum *outcksum)); +krb5_md5_sum_func PROTOTYPE(( + krb5_const krb5_pointer in, + krb5_const size_t in_length, + krb5_const krb5_pointer seed, + krb5_const size_t seed_length, + krb5_checksum FAR *outcksum)); krb5_error_code -krb5_md5_verify_func PROTOTYPE((krb5_checksum FAR *cksum, krb5_pointer in, - size_t in_length, krb5_pointer seed, size_t seed_length)); +krb5_md5_verify_func PROTOTYPE(( + krb5_const krb5_checksum FAR *cksum, + krb5_const krb5_pointer in, + krb5_const size_t in_length, + krb5_const krb5_pointer seed, + krb5_const size_t seed_length)); krb5_error_code krb5_md5_sum_func(in, in_length, seed, seed_length, outcksum) -krb5_pointer in; -size_t in_length; -krb5_pointer seed; -size_t seed_length; -krb5_checksum FAR *outcksum; + krb5_const krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer seed; + krb5_const size_t seed_length; + krb5_checksum FAR *outcksum; { krb5_octet *input = (krb5_octet *)in; krb5_MD5_CTX working; @@ -40,11 +48,11 @@ krb5_checksum FAR *outcksum; krb5_error_code krb5_md5_verify_func(cksum, in, in_length, seed, seed_length) -krb5_checksum FAR *cksum; -krb5_pointer in; -size_t in_length; -krb5_pointer seed; -size_t seed_length; + krb5_const krb5_checksum FAR *cksum; + krb5_const krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer seed; + krb5_const size_t seed_length; { krb5_octet *input = (krb5_octet *)in; krb5_MD5_CTX working; diff --git a/src/lib/crypto/os/ChangeLog b/src/lib/crypto/os/ChangeLog index 3671f1349..97f79106d 100644 --- a/src/lib/crypto/os/ChangeLog +++ b/src/lib/crypto/os/ChangeLog @@ -1,3 +1,13 @@ +Thu Nov 21 00:58:04 EST 1996 Richard Basch + + * Makefile.in: Win32 build + + * c_ustime.c: The Win32 time calculation is different from DOS' + so the DOS version shouldn't be trying to use the same + part of the ifdef. + + * rnd_confoun.c: Fix function declaration (win32) + Wed Jun 12 00:12:52 1996 Theodore Ts'o * c_ustime.c: Fix WIN32 to be _WIN32 diff --git a/src/lib/crypto/os/Makefile.in b/src/lib/crypto/os/Makefile.in index 46e734d11..134e5c918 100644 --- a/src/lib/crypto/os/Makefile.in +++ b/src/lib/crypto/os/Makefile.in @@ -1,7 +1,9 @@ CFLAGS = $(CCOPTS) $(DEFS) ##DOSBUILDTOP = ..\..\.. -##DOSLIBNAME=..\crypto.lib +##DOSMYNAME=os +##DOSOBJFILE=..\os.lst +##WIN16##LIBNAME=..\crypto.lib LIBOBJS = @LIBOBJS@ @@ -15,10 +17,13 @@ OBJS= $(COBJS) $(LIBOBJS) SRCS= rnd_confoun.c c_localaddr.c c_ustime.c all-unix:: shared $(OBJS) - all-mac:: $(OBJS) +all-windows:: $(OBJFILE) -all-windows: $(COBJS) +##DOS$(OBJFILE): $(COBJS) +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) -p $(MYNAME)\ *.obj > $(OBJFILE) shared: mkdir shared @@ -39,3 +44,4 @@ clean-unix:: clean-mac:: $(RM) shared/* clean-windows:: + $(RM) $(OBJFILE) diff --git a/src/lib/crypto/os/c_ustime.c b/src/lib/crypto/os/c_ustime.c index 8b539463f..57606de10 100644 --- a/src/lib/crypto/os/c_ustime.c +++ b/src/lib/crypto/os/c_ustime.c @@ -121,7 +121,7 @@ krb5_crypto_us_timeofday(seconds, microseconds) } -#elif defined(_WIN32) || defined(_MSDOS) +#elif defined(_WIN32) /* Microsoft Windows NT and 95 (32bit) */ /* This one works for WOW (Windows on Windows, ntvdm on Win-NT) */ diff --git a/src/lib/crypto/os/rnd_confoun.c b/src/lib/crypto/os/rnd_confoun.c index 8db32d156..e904cb5c7 100644 --- a/src/lib/crypto/os/rnd_confoun.c +++ b/src/lib/crypto/os/rnd_confoun.c @@ -60,9 +60,9 @@ You need a random number generator! /* * Generate a random confounder */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_random_confounder(size, fillin) -int size; +size_t size; krb5_pointer fillin; { static int seeded = 0; diff --git a/src/lib/crypto/sha/ChangeLog b/src/lib/crypto/sha/ChangeLog index 8a312d7fb..fbb5f0ba8 100644 --- a/src/lib/crypto/sha/ChangeLog +++ b/src/lib/crypto/sha/ChangeLog @@ -1,3 +1,15 @@ +Thu Jan 30 21:31:39 1997 Richard Basch + + * sha_crypto.c sha_glue.c: + Declare the functions to take const args where possible + Remove extra includes + + * sha_crypto.c: Function prototypes did not match function names. + +Thu Nov 21 00:58:04 EST 1996 Richard Basch + + * Makefile.in: Win32 build fixed + Wed Aug 28 17:40:53 1996 Theodore Ts'o * shs.c: Only include sys/types.h if present. diff --git a/src/lib/crypto/sha/Makefile.in b/src/lib/crypto/sha/Makefile.in index 4f529fdfa..e45646aed 100644 --- a/src/lib/crypto/sha/Makefile.in +++ b/src/lib/crypto/sha/Makefile.in @@ -1,7 +1,9 @@ CFLAGS = $(CCOPTS) $(DEFS) -I$(srcdir)/../des ##DOSBUILDTOP = ..\..\.. -##DOSLIBNAME=..\crypto.lib +##DOSMYDIR=sha +##DOSOBJFILE=..\sha.lst +##WIN16##LIBNAME=..\crypto.lib .c.o: $(CC) $(CFLAGS) -c $(srcdir)/$*.c @@ -20,7 +22,12 @@ SRCS= $(srcdir)/shs.c \ all-unix:: shared $(OBJS) all-mac:: shared $(OBJS) -all-windows:: $(OBJS) +all-windows:: $(OBJFILE) + +##DOS$(OBJFILE): $(OBJS) +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) -p $(MYDIR)\ *.obj > $(OBJFILE) shared: mkdir shared @@ -45,3 +52,4 @@ clean-unix:: clean-mac:: $(RM) shared/* clean-windows:: + $(RM) $(OBJFILE) diff --git a/src/lib/crypto/sha/sha_crypto.c b/src/lib/crypto/sha/sha_crypto.c index af1aee225..b539b1199 100644 --- a/src/lib/crypto/sha/sha_crypto.c +++ b/src/lib/crypto/sha/sha_crypto.c @@ -1,31 +1,29 @@ -#include "k5-int.h" #include "shs.h" -#include "des_int.h" /* we cheat a bit and call it directly... */ /* Windows needs to these prototypes for the assignment below */ static krb5_error_code krb5_sha_crypto_sum_func - PROTOTYPE((krb5_pointer in, - size_t in_length, - krb5_pointer seed, - size_t seed_length, + PROTOTYPE((krb5_const krb5_pointer in, + krb5_const size_t in_length, + krb5_const krb5_pointer seed, + krb5_const size_t seed_length, krb5_checksum FAR *outcksum)); static krb5_error_code krb5_sha_crypto_verify_func - PROTOTYPE((krb5_checksum FAR *cksum, - krb5_pointer in, - size_t in_length, - krb5_pointer seed, - size_t seed_length)); + PROTOTYPE((krb5_const krb5_checksum FAR *cksum, + krb5_const krb5_pointer in, + krb5_const size_t in_length, + krb5_const krb5_pointer seed, + krb5_const size_t seed_length)); static krb5_error_code -shs_crypto_sum_func(in, in_length, seed, seed_length, outcksum) - krb5_pointer in; - size_t in_length; - krb5_pointer seed; - size_t seed_length; +krb5_sha_crypto_sum_func(in, in_length, seed, seed_length, outcksum) + krb5_const krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer seed; + krb5_const size_t seed_length; krb5_checksum FAR *outcksum; { krb5_error_code retval; @@ -41,12 +39,12 @@ shs_crypto_sum_func(in, in_length, seed, seed_length, outcksum) } static krb5_error_code -shs_crypto_verify_func(cksum, in, in_length, seed, seed_length) - krb5_checksum FAR *cksum; - krb5_pointer in; - size_t in_length; - krb5_pointer seed; - size_t seed_length; +krb5_sha_crypto_verify_func(cksum, in, in_length, seed, seed_length) + krb5_const krb5_checksum FAR *cksum; + krb5_const krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer seed; + krb5_const size_t seed_length; { krb5_octet digest[HMAC_SHA_CKSUM_LENGTH]; krb5_error_code retval; @@ -70,8 +68,8 @@ cleanup: krb5_checksum_entry hmac_sha_cksumtable_entry = { 0, - shs_crypto_sum_func, - shs_crypto_verify_func, + krb5_sha_crypto_sum_func, + krb5_sha_crypto_verify_func, HMAC_SHA_CKSUM_LENGTH, 1, /* is collision proof */ 1, /* uses key */ diff --git a/src/lib/crypto/sha/sha_glue.c b/src/lib/crypto/sha/sha_glue.c index 28416fc08..3a57e0182 100644 --- a/src/lib/crypto/sha/sha_glue.c +++ b/src/lib/crypto/sha/sha_glue.c @@ -1,29 +1,28 @@ -#include "k5-int.h" #include "shs.h" krb5_error_code krb5_sha_sum_func - PROTOTYPE((krb5_pointer in, - size_t in_length, - krb5_pointer seed, - size_t seed_length, - krb5_checksum *outcksum)); + PROTOTYPE((krb5_const krb5_pointer in, + krb5_const size_t in_length, + krb5_const krb5_pointer seed, + krb5_const size_t seed_length, + krb5_checksum FAR *outcksum)); krb5_error_code krb5_sha_verify_func - PROTOTYPE((krb5_checksum FAR *cksum, - krb5_pointer in, - size_t in_length, - krb5_pointer seed, - size_t seed_length)); + PROTOTYPE((krb5_const krb5_checksum FAR *cksum, + krb5_const krb5_pointer in, + krb5_const size_t in_length, + krb5_const krb5_pointer seed, + krb5_const size_t seed_length)); krb5_error_code krb5_sha_sum_func(in, in_length, seed, seed_length, outcksum) - krb5_pointer in; - size_t in_length; - krb5_pointer seed; - size_t seed_length; - krb5_checksum *outcksum; + krb5_const krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer seed; + krb5_const size_t seed_length; + krb5_checksum FAR *outcksum; { krb5_octet *input = (krb5_octet *)in; SHS_INFO working; @@ -47,11 +46,11 @@ krb5_sha_sum_func(in, in_length, seed, seed_length, outcksum) krb5_error_code krb5_sha_verify_func(cksum, in, in_length, seed, seed_length) - krb5_checksum FAR *cksum; - krb5_pointer in; - size_t in_length; - krb5_pointer seed; - size_t seed_length; + krb5_const krb5_checksum FAR *cksum; + krb5_const krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer seed; + krb5_const size_t seed_length; { krb5_octet *input = (krb5_octet *)in; SHS_INFO working; diff --git a/src/lib/crypto/sha/shs.h b/src/lib/crypto/sha/shs.h index 77b4ff250..01acddb82 100644 --- a/src/lib/crypto/sha/shs.h +++ b/src/lib/crypto/sha/shs.h @@ -1,21 +1,20 @@ #ifndef _SHS_DEFINED -#include +#include #define _SHS_DEFINED /* Some useful types */ typedef krb5_octet BYTE; -typedef krb5_ui_4 LONG; -/* Exit status of functions. */ +/* Old DOS/Windows compilers are case-insensitive */ +#if !defined(_MSDOS) && !defined(_WIN32) +typedef krb5_ui_4 LONG; +#endif -#define OK 0 -#define ERROR -1 /* Define the following to use the updated SHS implementation */ - #define NEW_SHS /**/ /* The SHS block size and message digest sizes, in bytes */ diff --git a/src/lib/crypto/sha/t_shs.c b/src/lib/crypto/sha/t_shs.c index de30603e2..87d8a0f9d 100644 --- a/src/lib/crypto/sha/t_shs.c +++ b/src/lib/crypto/sha/t_shs.c @@ -37,8 +37,8 @@ int shsTestLevel; /* Compare the returned digest and required values */ for( i = 0; i < 5; i++ ) if( shsInfo->digest[ i ] != shsTestResults[ shsTestLevel ][ i ] ) - return( ERROR ); - return( OK ); + return( -1 ); + return( 0 ); } main() @@ -59,11 +59,11 @@ main() shsInit( &shsInfo ); shsUpdate( &shsInfo, ( BYTE * ) "abc", 3 ); shsFinal( &shsInfo ); - if( compareSHSresults( &shsInfo, 0 ) == ERROR ) + if( compareSHSresults( &shsInfo, 0 ) == -1 ) { putchar( '\n' ); puts( "SHS test 1 failed" ); - exit( ERROR ); + exit( -1 ); } #ifdef NEW_SHS puts( "passed, result= A9993E364706816ABA3E25717850C26C9CD0D89D" ); @@ -75,11 +75,11 @@ main() shsInit( &shsInfo ); shsUpdate( &shsInfo, ( BYTE * ) "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 56 ); shsFinal( &shsInfo ); - if( compareSHSresults( &shsInfo, 1 ) == ERROR ) + if( compareSHSresults( &shsInfo, 1 ) == -1 ) { putchar( '\n' ); puts( "SHS test 2 failed" ); - exit( ERROR ); + exit( -1 ); } #ifdef NEW_SHS puts( "passed, result= 84983E441C3BD26EBAAE4AA1F95129E5E54670F1" ); @@ -92,11 +92,11 @@ main() for( i = 0; i < 15625; i++ ) shsUpdate( &shsInfo, ( BYTE * ) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 64 ); shsFinal( &shsInfo ); - if( compareSHSresults( &shsInfo, 2 ) == ERROR ) + if( compareSHSresults( &shsInfo, 2 ) == -1 ) { putchar( '\n' ); puts( "SHS test 3 failed" ); - exit( ERROR ); + exit( -1 ); } #ifdef NEW_SHS puts( "passed, result= 34AA973CD4C4DAA4F61EEB2BDBAD27316534016F" ); @@ -116,5 +116,5 @@ main() #endif puts( "\nAll SHS tests passed" ); - exit( OK ); + exit( 0 ); } diff --git a/src/lib/des425/ChangeLog b/src/lib/des425/ChangeLog index 8b1457e07..2acf19bac 100644 --- a/src/lib/des425/ChangeLog +++ b/src/lib/des425/ChangeLog @@ -1,3 +1,11 @@ +Thu Nov 21 11:55:16 EST 1996 Richard Basch + + * Makefile.in: win32 build + + * des.c, des.h, key_sched.c, new_rnd_key.c, pcbc_encrypt.c, + read_passwd.c, unix_time.c: + DLL export various functions (mostly for wintel) + Mon Nov 18 20:39:02 1996 Ezra Peisach * configure.in: Set shared library version to 1.0. [krb5-libs/201] diff --git a/src/lib/des425/Makefile.in b/src/lib/des425/Makefile.in index 4c1f14ab5..c8e513996 100644 --- a/src/lib/des425/Makefile.in +++ b/src/lib/des425/Makefile.in @@ -1,7 +1,11 @@ CFLAGS = $(CCOPTS) $(DEFS) -I$(srcdir)/../crypto/des -I$(srcdir)/../../include/kerberosIV ##DOSBUILDTOP = ..\.. -##DOSLIBNAME=libdes425.lib +##DOSLIBNAME=des425.lib +##DOSOBJFILE=des425.lst +##DOSOBJFILEDEP=des425.lst +##DOSOBJFILELIST=@des425.lst + RUN_SETUP=@KRB5_RUN_ENV@ .c.o: @@ -17,7 +21,7 @@ OBJS= cksum.$(OBJEXT) \ pcbc_encrypt.$(OBJEXT) \ quad_cksum.$(OBJEXT) \ random_key.$(OBJEXT) \ - read_passwd.$(OBJEXT) \ + read_passwd.$(OBJEXT) \ str_to_key.$(OBJEXT) \ unix_time.$(OBJEXT) \ util.$(OBJEXT) \ @@ -34,7 +38,7 @@ SRCS= $(srcdir)/cksum.c \ $(srcdir)/quad_cksum.c \ $(srcdir)/random_key.c \ $(srcdir)/read_passwd.c \ - $(srcdir)/str_to_key.c \ + $(srcdir)/str_to_key.c \ $(srcdir)/unix_time.c \ $(srcdir)/util.c \ $(srcdir)/weak_key.c \ @@ -57,7 +61,12 @@ DEPKLIB= $(TOPLIBD)/libcrypto.a all-unix:: shared $(OBJS) all-mac:: $(OBJS) -all-windows:: $(OBJS) +all-windows:: $(OBJFILE) + +##DOS$(OBJFILE): $(OBJS) +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) *.obj > $(OBJFILE) shared: mkdir shared @@ -80,6 +89,7 @@ clean-unix:: clean-mac:: clean-windows:: + $(RM) des425.lib des425.bak $(OBJFILE) libdes425.$(STEXT): $(OBJS) $(RM) $@ diff --git a/src/lib/des425/des.c b/src/lib/des425/des.c index 12e8c3ea7..6b08899b7 100644 --- a/src/lib/des425/des.c +++ b/src/lib/des425/des.c @@ -51,7 +51,7 @@ #include "des.h" -int +KRB5_DLLIMP int KRB5_CALLCONV des_ecb_encrypt(clear, cipher, schedule, encrypt) unsigned long *clear; unsigned long *cipher; diff --git a/src/lib/des425/des.h b/src/lib/des425/des.h index 9ec87ddc3..2aed529bb 100644 --- a/src/lib/des425/des.h +++ b/src/lib/des425/des.h @@ -67,14 +67,14 @@ typedef struct des_ks_struct bit_64; * Windows needs everything prototyped because we're exporting all the fuctions. */ void des_cbc_cksum(); -int des_ecb_encrypt(); +KRB5_DLLIMP int KRB5_CALLCONV des_ecb_encrypt(); int des_cbc_encrypt(); void des_fixup_key_parity(); int des_check_key_parity(); -int des_key_sched(); -int des_new_random_key(); +KRB5_DLLIMP int KRB5_CALLCONV des_key_sched(); +KRB5_DLLIMP int KRB5_CALLCONV des_new_random_key(); void des_init_random_number_generator(); -void des_set_random_generator_seed(); +KRB5_DLLIMP void KRB5_CALLCONV des_set_random_generator_seed(); void des_set_sequence_number(); void des_generate_random_block(); int des_pcbc_encrypt(); diff --git a/src/lib/des425/key_sched.c b/src/lib/des425/key_sched.c index d96ef6fe0..cb4ecee96 100644 --- a/src/lib/des425/key_sched.c +++ b/src/lib/des425/key_sched.c @@ -48,7 +48,7 @@ #include #include "des.h" -int +KRB5_DLLIMP int KRB5_CALLCONV des_key_sched(k,schedule) register mit_des_cblock k; /* r11 */ mit_des_key_schedule schedule; diff --git a/src/lib/des425/new_rnd_key.c b/src/lib/des425/new_rnd_key.c index b5a367b5a..943b9e03b 100644 --- a/src/lib/des425/new_rnd_key.c +++ b/src/lib/des425/new_rnd_key.c @@ -38,7 +38,7 @@ krb5_pointer des425_random_state = 0; * to be a weak des key. Des_generate_random_block is used to * provide the random bits. */ -int +KRB5_DLLIMP int KRB5_CALLCONV des_new_random_key(key) mit_des_cblock key; { @@ -102,7 +102,7 @@ des_init_random_number_generator(key) * Requires: key is a valid des key. I.e., has correct parity and is not a * weak des key. */ -void +KRB5_DLLIMP void KRB5_CALLCONV des_set_random_generator_seed(key) mit_des_cblock key; { diff --git a/src/lib/des425/pcbc_encrypt.c b/src/lib/des425/pcbc_encrypt.c index 7c7517b23..92bc789a7 100644 --- a/src/lib/des425/pcbc_encrypt.c +++ b/src/lib/des425/pcbc_encrypt.c @@ -18,7 +18,7 @@ /* * copy of include/des.h to avoid collision with local one */ -#include "autoconf.h" +#include "krb5.h" #ifndef KRB_INT32 #if (SIZEOF_LONG == 4) diff --git a/src/lib/des425/read_passwd.c b/src/lib/des425/read_passwd.c index d9f29d72e..968c98600 100644 --- a/src/lib/des425/read_passwd.c +++ b/src/lib/des425/read_passwd.c @@ -27,6 +27,8 @@ * echoing. */ +#if defined(unix) + #include "des.h" #include #include @@ -178,3 +180,8 @@ des_read_password/*_v4_compat_crock*/(k,prompt,verify) return ok; } +#else /* !unix */ +/* + * These are all just dummy functions to make the rest of the library happy... + */ +#endif /* unix */ diff --git a/src/lib/des425/unix_time.c b/src/lib/des425/unix_time.c index ed1110007..ae7aee4c4 100644 --- a/src/lib/des425/unix_time.c +++ b/src/lib/des425/unix_time.c @@ -12,7 +12,7 @@ #include "k5-int.h" -#ifndef _MSDOS +#if !defined(_MSDOS) && !defined(_WIN32) #include krb5_ui_4 @@ -27,8 +27,25 @@ unix_time_gmt_unixsec (usecptr) return now.tv_sec; } -#else /* _MSDOS */ +#endif /* !_MSDOS && !_WIN32 */ +#ifdef _WIN32 +#include + +krb5_ui_4 +unix_time_gmt_unixsec (usecptr) + krb5_ui_4 *usecptr; +{ + time_t gmt; + + time(&gmt); + if (usecptr) + *usecptr = gmt; + return gmt; +} +#endif /* _WIN32 */ + +#ifdef MSDOS /* * Originally written by John Gilmore, Cygnus Support, May '94. * Public Domain. diff --git a/src/lib/gssapi.def b/src/lib/gssapi.def deleted file mode 100644 index dd7794750..000000000 --- a/src/lib/gssapi.def +++ /dev/null @@ -1,72 +0,0 @@ -;---------------------------------------------------- -; GSSAPI.DEF - GSSAPI.DLL module definition file -;---------------------------------------------------- - -LIBRARY GSSAPI -DESCRIPTION 'Base Generic Security Service API' -EXETYPE WINDOWS -CODE PRELOAD MOVEABLE DISCARDABLE -DATA PRELOAD MOVEABLE SINGLE -HEAPSIZE 8192 - -EXPORTS - WEP @1001 RESIDENTNAME - LIBMAIN @1002 - GSS_ACQUIRE_CRED @1 - GSS_RELEASE_CRED @2 - GSS_INIT_SEC_CONTEXT @3 - GSS_ACCEPT_SEC_CONTEXT @4 - GSS_PROCESS_CONTEXT_TOKEN @5 - GSS_DELETE_SEC_CONTEXT @6 - GSS_CONTEXT_TIME @7 - GSS_SIGN @8 - GSS_VERIFY @9 - GSS_SEAL @10 - GSS_UNSEAL @11 - GSS_DISPLAY_STATUS @12 - GSS_INDICATE_MECHS @13 - GSS_COMPARE_NAME @14 - GSS_DISPLAY_NAME @15 - GSS_IMPORT_NAME @16 - GSS_RELEASE_NAME @17 - GSS_RELEASE_BUFFER @18 - GSS_RELEASE_OID_SET @19 - GSS_INQUIRE_CRED @20 - -; GSS-API v2 additional credential calls -; -; XXX we need to add the numbers to this! -; - GSS_ADD_CRED - GSS_INQUIRE_CRED_BY_MECH - -; GSS-API v2 additional context-level calls -; - GSS_INQUIRE_CONTEXT - GSS_WRAP_SIZE_LIMIT - GSS_EXPORT_SEC_CONTEXT - GSS_IMPORT_SEC_CONTEXT - -; GSS-API v2 additional calls for OID and OID_set operations -; - GSS_RELEASE_OID - GSS_CREATE_EMPTY_OID_SET - GSS_ADD_OID_SET_MEMBER - GSS_TEST_OID_SET_MEMBER - GSS_OID_TO_STR - GSS_STR_TO_OID - -; GSS-API v2 renamed message protection calls -; - GSS_WRAP - GSS_UNWRAP - GSS_GET_MIC - GSS_VERIFY_MIC - -; GSS-API v2 future extensions -; - GSS_INQUIRE_NAMES_FOR_MECH -; GSS_INQUIRE_MECHS_FOR_NAME -; GSS_CANONICALIZE_NAME -; GSS_EXPORT_NAME - diff --git a/src/lib/gssapi/ChangeLog b/src/lib/gssapi/ChangeLog index b29cc371b..e8c524b88 100644 --- a/src/lib/gssapi/ChangeLog +++ b/src/lib/gssapi/ChangeLog @@ -1,3 +1,7 @@ +Thu Nov 21 11:55:16 EST 1996 Richard Basch + + * Makefile.in: win32 build + Mon Nov 18 20:39:41 1996 Ezra Peisach * configure.in: Set shared library version to 1.0. [krb5-libs/201] diff --git a/src/lib/gssapi/Makefile.in b/src/lib/gssapi/Makefile.in index bd7eac736..b2410633c 100644 --- a/src/lib/gssapi/Makefile.in +++ b/src/lib/gssapi/Makefile.in @@ -1,6 +1,9 @@ TST=if test -n "`cat DONE`" ; then ##DOSBUILDTOP = ..\.. +##DOSLIBNAME=gssapi.lib +##DOSOBJFILELIST=@generic.lst @krb5.lst +##DOSOBJFILEDEP=generic.lst krb5.lst MAC_SUBDIRS = generic krb5 @@ -19,7 +22,6 @@ SHLIB_LDFLAGS= $(LDFLAGS) @SHLIB_RPATH_DIRS@ SHLIB_LIBDIRS= @SHLIB_LIBDIRS@ all-unix:: - all-mac:: libgssapi_krb5.$(STEXT): $(LIBDONE) diff --git a/src/lib/gssapi/generic/ChangeLog b/src/lib/gssapi/generic/ChangeLog index 30fd1c3c2..1456356a1 100644 --- a/src/lib/gssapi/generic/ChangeLog +++ b/src/lib/gssapi/generic/ChangeLog @@ -1,3 +1,16 @@ +Tue Feb 4 15:55:11 1997 Richard Basch + + * Makefile.in: Only override the object build of the error table + under Unix + +Thu Nov 21 11:55:16 EST 1996 Richard Basch + + * Makefile.in: win32 build + + * gssapi.hin, gssapi_generic.c, gssapi_generic.h: + DLL export all public gssapi functions; move windows/mac stuff to + win-mac.h + Wed Nov 20 13:59:58 1996 Ezra Peisach * Makefile.in (install): Install gssapi.h from the build tree. diff --git a/src/lib/gssapi/generic/Makefile.in b/src/lib/gssapi/generic/Makefile.in index 87b414f47..4b652734e 100644 --- a/src/lib/gssapi/generic/Makefile.in +++ b/src/lib/gssapi/generic/Makefile.in @@ -1,7 +1,9 @@ CFLAGS = $(CCOPTS) $(DEFS) -I. -I$(srcdir) ##DOSBUILDTOP = ..\..\.. -##DOSLIBNAME=..\gssapi.$(LIBEXT) +##DOSMYNAME=generic +##DOSOBJFILE=..\generic.lst +##WIN16##LIBNAME=..\gssapi.lib .c.o: $(CC) $(CFLAGS) -c $(srcdir)/$*.c @@ -18,17 +20,21 @@ ETHDRS= gssapi_err_generic.h EHDRDIR= $(BUILDTOP)$(S)include$(S)gssapi -HDRS= $(EHDRDIR)/gssapi.h \ - $(EHDRDIR)/gssapi_generic.h +HDRS= $(EHDRDIR)$(S)gssapi.h \ + $(EHDRDIR)$(S)gssapi_generic.h -gssapi_err_generic.$(OBJEXT): gssapi_err_generic.c +$(EHDRDIR)$(S)gssapi.h: gssapi.h + $(CP) gssapi.h $@ +$(EHDRDIR)$(S)gssapi_generic.h: $(srcdir)$(S)gssapi_generic.h + $(CP) $(srcdir)$(S)gssapi_generic.h $@ + +gssapi_err_generic.o: gssapi_err_generic.c $(CC) $(CFLAGS) -c $*.c + @SHARED_RULE_LOCAL@ -##WIN16## $(LIBCMD) $(PAGESIZE) /nologo $(LIBNAME) -+$@; -##WIN32## $(LIBCMD) /out:$(LIBNAME) /nologo $@ +gssapi_err_generic.$(OBJEXT): gssapi_err_generic.c gssapi_err_generic.h: gssapi_err_generic.et - gssapi_err_generic.c: gssapi_err_generic.et gssapi.h: gssapi.hin @@ -83,22 +89,22 @@ OBJS = \ util_validate.$(OBJEXT) \ gssapi_err_generic.$(OBJEXT) -$(OBJS): $(HDRS) $(ETHDRS) - EXPORTED_HEADERS= gssapi_generic.h EXPORTED_BUILT_HEADERS= gssapi.h -all-unix:: shared $(SRCS) $(ETHDRS) $(OBJS) +$(OBJS): $(EXPORTED_HEADERS) $(ETHDRS) +all-unix:: shared $(SRCS) $(HDRS) $(ETHDRS) $(OBJS) all-mac:: $(SRCS) $(HDRS) $(ETHDRS) $(OBJS) +all-windows:: win-include $(HDRS) $(OBJFILE) -all-windows:: $(SRCS) $(ETHDRS) win-include -all-windows:: $(OBJS) +##DOS$(OBJFILE): $(OBJS) +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) -p $(MYNAME)\ *.obj > $(OBJFILE) win-include:: if not exist $(EHDRDIR)\nul mkdir $(EHDRDIR) - copy gssapi.h $(EHDRDIR) - copy gssapi_generic.h $(EHDRDIR) unixmac: $(SRCS) $(ETHDRS) @@ -109,7 +115,7 @@ clean-mac:: $(RM) $(ETHDRS) $(ETSRCS) $(HDRS) shared/* clean-windows:: - $(RM) $(EHDRDIR)\gssapi.h $(EHDRDIR)\gssapi_generic.h + $(RM) $(HDRS) $(OBJFILE) if exist $(EHDRDIR)\nul rmdir $(EHDRDIR) # Krb5InstallHeaders($(EXPORTED_HEADERS), $(KRB5_INCDIR)/krb5) diff --git a/src/lib/gssapi/generic/gssapi.hin b/src/lib/gssapi/generic/gssapi.hin index 4d2e14d00..685b8aa7b 100644 --- a/src/lib/gssapi/generic/gssapi.hin +++ b/src/lib/gssapi/generic/gssapi.hin @@ -26,82 +26,25 @@ /* * Determine platform-dependent configuration. */ -#if defined(_MSDOS) || defined(_WIN32) - -#ifdef _MSDOS - /* Windows 16 definition */ - -#define GSS_SIZEOF_INT 2 -#define GSS_SIZEOF_SHORT 2 -#define GSS_SIZEOF_LONG 4 - -#ifndef FAR -#define FAR _far -#define NEAR _near -#endif - -#ifndef KRB5_CALLCONV -#define KRB5_CALLCONV __far __export __pascal -#define KRB5_CALLCONV_C __far __export __cdecl -#define KRB5_DLLIMP -#define INTERFACE KRB5_CALLCONV -#define INTERFACE_C KRB5_CALLCONV_C -#endif /* !KRB5_CALLCONV */ - -#else - /* Windows 32 specific definitions */ -#define GSS_SIZEOF_INT 4 -#define GSS_SIZEOF_SHORT 2 -#define GSS_SIZEOF_LONG 4 -#ifndef KRB5_CALLCONV -#ifdef KRB5_DLL_FILE -#define KRB5_DECLSPEC dllexport -#else -#define KRB5_DECLSPEC dllimport -#endif -#define KRB5_DLLIMP __declspec(KRB5_DECLSPEC) -#define KRB5_CALLCONV __stdcall -#define KRB5_CALLCONV_C __cdecl -#define INTERFACE KRB5_DLLIMP KRB5_CALLCONV -#define INTERFACE_C KRB5_DLLIMP KRB5_CALLCONV_C -#endif /* !KRB5_CALLCONV */ - -#include -#endif - -#ifndef _SIZE_T_DEFINED -typedef unsigned int size_t; -#define _SIZE_T_DEFINED -#endif /* _SIZE_T_DEFINED */ - -#ifndef _UID_T_DEFINED -typedef unsigned int uid_t; -#define _UID_T_DEFINED +#if defined(_MSDOS) || defined(_WIN32) +#include #endif -#else /* _MSDOS_ */ #ifndef KRB5_CALLCONV #define KRB5_CALLCONV #define KRB5_CALLCONV_C #define KRB5_DLLIMP -#define INTERFACE -#define INTERFACE_C +#endif + +#ifndef FAR #define FAR #define NEAR -#endif /* !KRB5_CALLCONV */ +#endif #define GSS_SIZEOF_INT SIZEOF_INT #define GSS_SIZEOF_LONG SIZEOF_LONG #define GSS_SIZEOF_SHORT SIZEOF_SHORT -#endif /* _MSDOS */ - -#ifndef FAR -#define FAR -#endif -#ifndef NEAR -#define NEAR -#endif /* * Make sure we have a definition for PROTOTYPE. diff --git a/src/lib/gssapi/generic/gssapi_generic.c b/src/lib/gssapi/generic/gssapi_generic.c index 7072329b7..b078104d2 100644 --- a/src/lib/gssapi/generic/gssapi_generic.c +++ b/src/lib/gssapi/generic/gssapi_generic.c @@ -53,7 +53,7 @@ static gss_OID_desc oids[] = { {10, "\052\206\110\206\367\022\001\002\001\004"}, }; -gss_OID gss_nt_user_name = oids+0; -gss_OID gss_nt_machine_uid_name = oids+1; -gss_OID gss_nt_string_uid_name = oids+2; -gss_OID gss_nt_service_name = oids+3; +KRB5_DLLIMP gss_OID gss_nt_user_name = oids+0; +KRB5_DLLIMP gss_OID gss_nt_machine_uid_name = oids+1; +KRB5_DLLIMP gss_OID gss_nt_string_uid_name = oids+2; +KRB5_DLLIMP gss_OID gss_nt_service_name = oids+3; diff --git a/src/lib/gssapi/generic/gssapi_generic.h b/src/lib/gssapi/generic/gssapi_generic.h index 09a9810b0..7b48d396f 100644 --- a/src/lib/gssapi/generic/gssapi_generic.h +++ b/src/lib/gssapi/generic/gssapi_generic.h @@ -33,9 +33,9 @@ #include #endif -extern gss_OID gss_nt_user_name; -extern gss_OID gss_nt_machine_uid_name; -extern gss_OID gss_nt_string_uid_name; -extern gss_OID gss_nt_service_name; +KRB5_DLLIMP extern gss_OID gss_nt_user_name; +KRB5_DLLIMP extern gss_OID gss_nt_machine_uid_name; +KRB5_DLLIMP extern gss_OID gss_nt_string_uid_name; +KRB5_DLLIMP extern gss_OID gss_nt_service_name; #endif /* _GSSAPI_GENERIC_H_ */ diff --git a/src/lib/gssapi/krb5/ChangeLog b/src/lib/gssapi/krb5/ChangeLog index 8f9ac2c0d..67bf46319 100644 --- a/src/lib/gssapi/krb5/ChangeLog +++ b/src/lib/gssapi/krb5/ChangeLog @@ -1,9 +1,26 @@ +Wed Feb 5 20:27:50 1997 Richard Basch + + * acquire_cred.c (acquire_accept_cred): Removed unused local variable + +Tue Feb 4 15:56:01 1997 Richard Basch + + * Makefile.in: Only override the object build of the error table + under Unix + Wed Dec 4 13:06:13 1996 Barry Jaspan * acquire_cred.c (acquire_accept_cred): use krb5_kt_get_entry instead of scanning through keytab to find matching principal [krb5-libs/210] +Thu Nov 21 11:55:16 EST 1996 Richard Basch + + * Makefile.in: win32 build + + * gssapiP_krb5.h krb5_gss_glue.c: + DLL export all public GSSAPI interfaces; adjusted some other + declarations accordingly (KRB5_CALLCONV, FAR keywords added) + Wed Nov 20 19:55:29 1996 Marc Horowitz * init_sec_context.c (make_ap_rep, krb5_gss_init_sec_context), diff --git a/src/lib/gssapi/krb5/Makefile.in b/src/lib/gssapi/krb5/Makefile.in index d48db0291..45db67345 100644 --- a/src/lib/gssapi/krb5/Makefile.in +++ b/src/lib/gssapi/krb5/Makefile.in @@ -1,18 +1,14 @@ -CFLAGS = $(CCOPTS) $(DEFS) -I. -I$(srcdir) -I../generic -I$(srcdir)/../generic -DUSE_AUTOCONF_H +CFLAGS = $(CCOPTS) $(DEFS) -I. -I$(srcdir) -I../generic -I$(srcdir)/../generic ##DOSBUILDTOP = ..\..\.. -##DOSLIBNAME=..\gssapi.$(LIBEXT) +##DOSMYNAME=krb5 +##DOSOBJFILE = ..\krb5.lst +##WIN16##LIBNAME=..\gssapi.lib .c.o: $(CC) $(CFLAGS) -c $(srcdir)/$*.c @SHARED_RULE@ -all-unix:: shared $(OBJS) - -all-mac:: shared $(OBJS) - -all-windows:: $(OBJS) - shared: mkdir shared @@ -20,14 +16,13 @@ ETSRCS= gssapi_err_krb5.c ETOBJS= gssapi_err_krb5.$(OBJEXT) ETHDRS= gssapi_err_krb5.h -gssapi_err_krb5.$(OBJEXT): gssapi_err_krb5.c +gssapi_err_krb5.o: gssapi_err_krb5.c $(CC) $(CFLAGS) -c $*.c + @SHARED_RULE_LOCAL@ -##WIN16## $(LIBCMD) $(PAGESIZE) /nologo $(LIBNAME) -+$@; -##WIN32## $(LIBCMD) /out:$(LIBNAME) /nologo $@ +gssapi_err_krb5.$(OBJEXT): gssapi_err_krb5.c gssapi_err_krb5.h: gssapi_err_krb5.et - gssapi_err_krb5.c: gssapi_err_krb5.et SRCS = \ @@ -115,9 +110,14 @@ HDRS= $(ETHDRS) EHDRDIR=$(BUILDTOP)$(S)include$(S)gssapi EXPORTED_HEADERS= gssapi_krb5.h -all-unix:: $(SRCS) $(HDRS) includes $(OBJS) -all-mac:: $(SRCS) $(HDRS) includes $(OBJS) -all-windows:: win-include $(SRCS) $(HDRS) $(OBJS) +##DOS$(OBJFILE): $(OBJS) +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) -p $(MYNAME)\ *.obj >$(OBJFILE) + +all-unix:: shared $(SRCS) $(HDRS) includes $(OBJS) +all-mac:: shared $(SRCS) $(HDRS) includes $(OBJS) +all-windows:: win-include $(SRCS) $(HDRS) $(OBJS) $(OBJFILE) win-include:: if not exist $(EHDRDIR)\nul mkdir $(EHDRDIR) @@ -130,7 +130,7 @@ clean-mac:: $(RM) $(ETHDRS) $(ETSRCS) shared/* clean-windows:: - $(RM) $(EHDRDIR)\gssapi_krb5.h + $(RM) $(EHDRDIR)\gssapi_krb5.h $(OBJFILE) if exist $(EHDRDIR)\nul rmdir $(EHDRDIR) install:: diff --git a/src/lib/gssapi/krb5/acquire_cred.c b/src/lib/gssapi/krb5/acquire_cred.c index a99177758..8f1935038 100644 --- a/src/lib/gssapi/krb5/acquire_cred.c +++ b/src/lib/gssapi/krb5/acquire_cred.c @@ -50,7 +50,6 @@ acquire_accept_cred(context, minor_status, desired_name, output_princ, cred) krb5_principal princ; krb5_keytab kt; krb5_keytab_entry entry; - krb5_kt_cursor cur; *output_princ = NULL; cred->keytab = NULL; diff --git a/src/lib/gssapi/krb5/gssapiP_krb5.h b/src/lib/gssapi/krb5/gssapiP_krb5.h index 97f2d51d5..d7b01e021 100644 --- a/src/lib/gssapi/krb5/gssapiP_krb5.h +++ b/src/lib/gssapi/krb5/gssapiP_krb5.h @@ -27,11 +27,7 @@ * $Id$ */ -#if (defined(_MSDOS) || defined(_WIN32) || defined(_MACINTOSH)) -#include -#else #include -#endif #include /* work around sunos braindamage */ diff --git a/src/lib/gssapi/krb5/krb5_gss_glue.c b/src/lib/gssapi/krb5/krb5_gss_glue.c index fe3b0208f..8155d8577 100644 --- a/src/lib/gssapi/krb5/krb5_gss_glue.c +++ b/src/lib/gssapi/krb5/krb5_gss_glue.c @@ -26,21 +26,21 @@ #include "gssapiP_krb5.h" -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_accept_sec_context(minor_status, context_handle, verifier_cred_handle, input_token, input_chan_bindings, src_name, mech_type, output_token, ret_flags, time_rec, delegated_cred_handle) - OM_uint32 *minor_status; - gss_ctx_id_t *context_handle; + OM_uint32 FAR *minor_status; + gss_ctx_id_t FAR *context_handle; gss_cred_id_t verifier_cred_handle; gss_buffer_t input_token; gss_channel_bindings_t input_chan_bindings; - gss_name_t *src_name; - gss_OID *mech_type; + gss_name_t FAR *src_name; + gss_OID FAR *mech_type; gss_buffer_t output_token; - OM_uint32 *ret_flags; - OM_uint32 *time_rec; - gss_cred_id_t *delegated_cred_handle; + OM_uint32 FAR *ret_flags; + OM_uint32 FAR *time_rec; + gss_cred_id_t FAR *delegated_cred_handle; { return(krb5_gss_accept_sec_context(minor_status, context_handle, @@ -55,17 +55,17 @@ gss_accept_sec_context(minor_status, context_handle, verifier_cred_handle, delegated_cred_handle)); } -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_acquire_cred(minor_status, desired_name, time_req, desired_mechs, cred_usage, output_cred_handle, actual_mechs, time_rec) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_name_t desired_name; OM_uint32 time_req; gss_OID_set desired_mechs; gss_cred_usage_t cred_usage; - gss_cred_id_t *output_cred_handle; - gss_OID_set *actual_mechs; - OM_uint32 *time_rec; + gss_cred_id_t FAR *output_cred_handle; + gss_OID_set FAR *actual_mechs; + OM_uint32 FAR *time_rec; { return(krb5_gss_acquire_cred(minor_status, desired_name, @@ -78,22 +78,22 @@ gss_acquire_cred(minor_status, desired_name, time_req, desired_mechs, } /* V2 */ -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_add_cred(minor_status, input_cred_handle, desired_name, desired_mech, cred_usage, initiator_time_req, acceptor_time_req, output_cred_handle, actual_mechs, initiator_time_rec, acceptor_time_rec) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_cred_id_t input_cred_handle; gss_name_t desired_name; gss_OID desired_mech; gss_cred_usage_t cred_usage; OM_uint32 initiator_time_req; OM_uint32 acceptor_time_req; - gss_cred_id_t *output_cred_handle; - gss_OID_set *actual_mechs; - OM_uint32 *initiator_time_rec; - OM_uint32 *acceptor_time_rec; + gss_cred_id_t FAR *output_cred_handle; + gss_OID_set FAR *actual_mechs; + OM_uint32 FAR *initiator_time_rec; + OM_uint32 FAR *acceptor_time_rec; { return(krb5_gss_add_cred(minor_status, input_cred_handle, desired_name, desired_mech, cred_usage, initiator_time_req, @@ -103,74 +103,74 @@ gss_add_cred(minor_status, input_cred_handle, desired_name, desired_mech, } /* V2 */ -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_add_oid_set_member(minor_status, member_oid, oid_set) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_OID member_oid; - gss_OID_set *oid_set; + gss_OID_set FAR *oid_set; { return(generic_gss_add_oid_set_member(minor_status, member_oid, oid_set)); } -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_compare_name(minor_status, name1, name2, name_equal) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_name_t name1; gss_name_t name2; - int *name_equal; + int FAR *name_equal; { return(krb5_gss_compare_name(minor_status, name1, name2, name_equal)); } -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_context_time(minor_status, context_handle, time_rec) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_ctx_id_t context_handle; - OM_uint32 *time_rec; + OM_uint32 FAR *time_rec; { return(krb5_gss_context_time(minor_status, context_handle, time_rec)); } /* V2 */ -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_create_empty_oid_set(minor_status, oid_set) - OM_uint32 *minor_status; - gss_OID_set *oid_set; + OM_uint32 FAR *minor_status; + gss_OID_set FAR *oid_set; { return(generic_gss_create_empty_oid_set(minor_status, oid_set)); } -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_delete_sec_context(minor_status, context_handle, output_token) - OM_uint32 *minor_status; - gss_ctx_id_t *context_handle; + OM_uint32 FAR *minor_status; + gss_ctx_id_t FAR *context_handle; gss_buffer_t output_token; { return(krb5_gss_delete_sec_context(minor_status, context_handle, output_token)); } -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_display_name(minor_status, input_name, output_name_buffer, output_name_type) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_name_t input_name; gss_buffer_t output_name_buffer; - gss_OID *output_name_type; + gss_OID FAR *output_name_type; { return(krb5_gss_display_name(minor_status, input_name, output_name_buffer, output_name_type)); } -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_display_status(minor_status, status_value, status_type, mech_type, message_context, status_string) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; OM_uint32 status_value; int status_type; gss_OID mech_type; - OM_uint32 *message_context; + OM_uint32 FAR *message_context; gss_buffer_t status_string; { return(krb5_gss_display_status(minor_status, status_value, @@ -179,10 +179,10 @@ gss_display_status(minor_status, status_value, status_type, } /* V2 */ -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_export_sec_context(minor_status, context_handle, interprocess_token) - OM_uint32 *minor_status; - gss_ctx_id_t *context_handle; + OM_uint32 FAR *minor_status; + gss_ctx_id_t FAR *context_handle; gss_buffer_t interprocess_token; { return(krb5_gss_export_sec_context(minor_status, @@ -191,10 +191,10 @@ gss_export_sec_context(minor_status, context_handle, interprocess_token) } /* V2 */ -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_get_mic(minor_status, context_handle, qop_req, message_buffer, message_token) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_ctx_id_t context_handle; gss_qop_t qop_req; gss_buffer_t message_buffer; @@ -204,55 +204,55 @@ gss_get_mic(minor_status, context_handle, qop_req, qop_req, message_buffer, message_token)); } -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_import_name(minor_status, input_name_buffer, input_name_type, output_name) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_buffer_t input_name_buffer; gss_OID input_name_type; - gss_name_t *output_name; + gss_name_t FAR *output_name; { return(krb5_gss_import_name(minor_status, input_name_buffer, input_name_type, output_name)); } /* V2 */ -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_import_sec_context(minor_status, interprocess_token, context_handle) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_buffer_t interprocess_token; - gss_ctx_id_t *context_handle; + gss_ctx_id_t FAR *context_handle; { return(krb5_gss_import_sec_context(minor_status, interprocess_token, context_handle)); } -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_indicate_mechs(minor_status, mech_set) - OM_uint32 *minor_status; - gss_OID_set *mech_set; + OM_uint32 FAR *minor_status; + gss_OID_set FAR *mech_set; { return(krb5_gss_indicate_mechs(minor_status, mech_set)); } -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_init_sec_context(minor_status, claimant_cred_handle, context_handle, target_name, mech_type, req_flags, time_req, input_chan_bindings, input_token, actual_mech_type, output_token, ret_flags, time_rec) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_cred_id_t claimant_cred_handle; - gss_ctx_id_t *context_handle; + gss_ctx_id_t FAR *context_handle; gss_name_t target_name; gss_OID mech_type; OM_uint32 req_flags; OM_uint32 time_req; gss_channel_bindings_t input_chan_bindings; gss_buffer_t input_token; - gss_OID *actual_mech_type; + gss_OID FAR *actual_mech_type; gss_buffer_t output_token; - OM_uint32 *ret_flags; - OM_uint32 *time_rec; + OM_uint32 FAR *ret_flags; + OM_uint32 FAR *time_rec; { return(krb5_gss_init_sec_context(minor_status, claimant_cred_handle, context_handle, @@ -262,19 +262,19 @@ gss_init_sec_context(minor_status, claimant_cred_handle, context_handle, time_rec)); } -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_inquire_context(minor_status, context_handle, initiator_name, acceptor_name, lifetime_rec, mech_type, ret_flags, locally_initiated, open) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_ctx_id_t context_handle; - gss_name_t *initiator_name; - gss_name_t *acceptor_name; - OM_uint32 *lifetime_rec; - gss_OID *mech_type; - OM_uint32 *ret_flags; - int *locally_initiated; - int *open; + gss_name_t FAR *initiator_name; + gss_name_t FAR *acceptor_name; + OM_uint32 FAR *lifetime_rec; + gss_OID FAR *mech_type; + OM_uint32 FAR *ret_flags; + int FAR *locally_initiated; + int FAR *open; { return(krb5_gss_inquire_context(minor_status, context_handle, initiator_name, acceptor_name, lifetime_rec, @@ -282,31 +282,31 @@ gss_inquire_context(minor_status, context_handle, initiator_name, acceptor_name, open)); } -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_inquire_cred(minor_status, cred_handle, name, lifetime_ret, cred_usage, mechanisms) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_cred_id_t cred_handle; - gss_name_t *name; - OM_uint32 *lifetime_ret; - gss_cred_usage_t *cred_usage; - gss_OID_set *mechanisms; + gss_name_t FAR *name; + OM_uint32 FAR *lifetime_ret; + gss_cred_usage_t FAR *cred_usage; + gss_OID_set FAR *mechanisms; { return(krb5_gss_inquire_cred(minor_status, cred_handle, name, lifetime_ret, cred_usage, mechanisms)); } /* V2 */ -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_inquire_cred_by_mech(minor_status, cred_handle, mech_type, name, initiator_lifetime, acceptor_lifetime, cred_usage) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_cred_id_t cred_handle; gss_OID mech_type; - gss_name_t *name; - OM_uint32 *initiator_lifetime; - OM_uint32 *acceptor_lifetime; - gss_cred_usage_t *cred_usage; + gss_name_t FAR *name; + OM_uint32 FAR *initiator_lifetime; + OM_uint32 FAR *acceptor_lifetime; + gss_cred_usage_t FAR *cred_usage; { return(krb5_gss_inquire_cred_by_mech(minor_status, cred_handle, mech_type, name, initiator_lifetime, @@ -314,11 +314,11 @@ gss_inquire_cred_by_mech(minor_status, cred_handle, mech_type, name, } /* V2 */ -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_inquire_names_for_mech(minor_status, mechanism, name_types) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_OID mechanism; - gss_OID_set *name_types; + gss_OID_set FAR *name_types; { return(krb5_gss_inquire_names_for_mech(minor_status, mechanism, @@ -326,18 +326,18 @@ gss_inquire_names_for_mech(minor_status, mechanism, name_types) } /* V2 */ -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_oid_to_str(minor_status, oid, oid_str) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_OID oid; gss_buffer_t oid_str; { return(generic_gss_oid_to_str(minor_status, oid, oid_str)); } -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_process_context_token(minor_status, context_handle, token_buffer) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_ctx_id_t context_handle; gss_buffer_t token_buffer; { @@ -345,25 +345,25 @@ gss_process_context_token(minor_status, context_handle, token_buffer) context_handle, token_buffer)); } -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_release_cred(minor_status, cred_handle) - OM_uint32 *minor_status; - gss_cred_id_t *cred_handle; + OM_uint32 FAR *minor_status; + gss_cred_id_t FAR *cred_handle; { return(krb5_gss_release_cred(minor_status, cred_handle)); } -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_release_name(minor_status, input_name) - OM_uint32 *minor_status; - gss_name_t *input_name; + OM_uint32 FAR *minor_status; + gss_name_t FAR *input_name; { return(krb5_gss_release_name(minor_status, input_name)); } -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_release_buffer(minor_status, buffer) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_buffer_t buffer; { return(generic_gss_release_buffer(minor_status, @@ -371,32 +371,32 @@ gss_release_buffer(minor_status, buffer) } /* V2 */ -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_release_oid(minor_status, oid) - OM_uint32 *minor_status; - gss_OID *oid; + OM_uint32 FAR *minor_status; + gss_OID FAR *oid; { return(krb5_gss_release_oid(minor_status, oid)); } -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_release_oid_set(minor_status, set) - OM_uint32* minor_status; - gss_OID_set *set; + OM_uint32 FAR * minor_status; + gss_OID_set FAR *set; { return(generic_gss_release_oid_set(minor_status, set)); } /* V1 only */ -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_seal(minor_status, context_handle, conf_req_flag, qop_req, input_message_buffer, conf_state, output_message_buffer) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_ctx_id_t context_handle; int conf_req_flag; int qop_req; gss_buffer_t input_message_buffer; - int *conf_state; + int FAR *conf_state; gss_buffer_t output_message_buffer; { return(krb5_gss_seal(minor_status, context_handle, @@ -404,11 +404,11 @@ gss_seal(minor_status, context_handle, conf_req_flag, qop_req, conf_state, output_message_buffer)); } -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_sign(minor_status, context_handle, qop_req, message_buffer, message_token) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_ctx_id_t context_handle; int qop_req; gss_buffer_t message_buffer; @@ -419,29 +419,29 @@ gss_sign(minor_status, context_handle, } /* V2 */ -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_verify_mic(minor_status, context_handle, message_buffer, token_buffer, qop_state) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_ctx_id_t context_handle; gss_buffer_t message_buffer; gss_buffer_t token_buffer; - gss_qop_t *qop_state; + gss_qop_t FAR *qop_state; { return(krb5_gss_verify_mic(minor_status, context_handle, message_buffer, token_buffer, qop_state)); } /* V2 */ -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_wrap(minor_status, context_handle, conf_req_flag, qop_req, input_message_buffer, conf_state, output_message_buffer) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_ctx_id_t context_handle; int conf_req_flag; gss_qop_t qop_req; gss_buffer_t input_message_buffer; - int *conf_state; + int FAR *conf_state; gss_buffer_t output_message_buffer; { return(krb5_gss_wrap(minor_status, context_handle, conf_req_flag, qop_req, @@ -450,37 +450,37 @@ gss_wrap(minor_status, context_handle, conf_req_flag, qop_req, } /* V2 */ -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_str_to_oid(minor_status, oid_str, oid) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_buffer_t oid_str; - gss_OID *oid; + gss_OID FAR *oid; { return(generic_gss_str_to_oid(minor_status, oid_str, oid)); } /* V2 */ -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_test_oid_set_member(minor_status, member, set, present) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_OID member; gss_OID_set set; - int *present; + int FAR *present; { return(generic_gss_test_oid_set_member(minor_status, member, set, present)); } /* V1 only */ -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_unseal(minor_status, context_handle, input_message_buffer, output_message_buffer, conf_state, qop_state) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_ctx_id_t context_handle; gss_buffer_t input_message_buffer; gss_buffer_t output_message_buffer; - int *conf_state; - int *qop_state; + int FAR *conf_state; + int FAR *qop_state; { return(krb5_gss_unseal(minor_status, context_handle, input_message_buffer, output_message_buffer, @@ -488,29 +488,29 @@ gss_unseal(minor_status, context_handle, input_message_buffer, } /* V2 */ -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_unwrap(minor_status, context_handle, input_message_buffer, output_message_buffer, conf_state, qop_state) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_ctx_id_t context_handle; gss_buffer_t input_message_buffer; gss_buffer_t output_message_buffer; - int *conf_state; - gss_qop_t *qop_state; + int FAR *conf_state; + gss_qop_t FAR *qop_state; { return(krb5_gss_unwrap(minor_status, context_handle, input_message_buffer, output_message_buffer, conf_state, qop_state)); } /* V1 only */ -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_verify(minor_status, context_handle, message_buffer, token_buffer, qop_state) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_ctx_id_t context_handle; gss_buffer_t message_buffer; gss_buffer_t token_buffer; - int *qop_state; + int FAR *qop_state; { return(krb5_gss_verify(minor_status, context_handle, @@ -520,15 +520,15 @@ gss_verify(minor_status, context_handle, message_buffer, } /* V2 interface */ -OM_uint32 INTERFACE +KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_wrap_size_limit(minor_status, context_handle, conf_req_flag, qop_req, req_output_size, max_input_size) - OM_uint32 *minor_status; + OM_uint32 FAR *minor_status; gss_ctx_id_t context_handle; int conf_req_flag; gss_qop_t qop_req; OM_uint32 req_output_size; - OM_uint32 *max_input_size; + OM_uint32 FAR *max_input_size; { return(krb5_gss_wrap_size_limit(minor_status, context_handle, conf_req_flag, qop_req, diff --git a/src/lib/gssapi/krb5/ser_sctx.c b/src/lib/gssapi/krb5/ser_sctx.c index 22b5c367c..36e70d742 100644 --- a/src/lib/gssapi/krb5/ser_sctx.c +++ b/src/lib/gssapi/krb5/ser_sctx.c @@ -25,6 +25,7 @@ /* * ser_sctx.c - Handle [de]serialization of GSSAPI security context. */ +#include "k5-int.h" #include "gssapiP_krb5.h" /* diff --git a/src/lib/gssapi/mechglue/ChangeLog b/src/lib/gssapi/mechglue/ChangeLog index 9f8fb1bc4..35c48afca 100644 --- a/src/lib/gssapi/mechglue/ChangeLog +++ b/src/lib/gssapi/mechglue/ChangeLog @@ -1,3 +1,14 @@ +Wed Feb 5 10:37:00 1996 Richard Basch + + * g_accept_sec_context.c g_acquire_cred.c g_compare_name.c + g_context_time.c g_delete_sec_context.c g_dsp_name.c + g_dsp_status.c g_exp_sec_context.c g_imp_name.c + g_imp_sec_context.c g_indicate_mechs.c g_init_sec_context.c + g_inq_context.c g_inq_cred.c g_inq_names.c g_process_context.c + g_rel_buffer.c g_rel_cred.c g_rel_name.c g_rel_oid_set.c + g_seal.c g_sign.c g_unseal.c g_verify.c + Changed INTERFACE keyword to KRB5_CALLCONV + Mon Nov 18 20:43:54 1996 Ezra Peisach * configure.in: Shared library version number to 1.0. [krb5-libs/201] diff --git a/src/lib/gssapi/mechglue/g_accept_sec_context.c b/src/lib/gssapi/mechglue/g_accept_sec_context.c index 286dc2432..8cc752fe7 100644 --- a/src/lib/gssapi/mechglue/g_accept_sec_context.c +++ b/src/lib/gssapi/mechglue/g_accept_sec_context.c @@ -33,7 +33,7 @@ #include #include -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_accept_sec_context (minor_status, context_handle, verifier_cred_handle, diff --git a/src/lib/gssapi/mechglue/g_acquire_cred.c b/src/lib/gssapi/mechglue/g_acquire_cred.c index 97bc8e0f5..d6ff8897a 100644 --- a/src/lib/gssapi/mechglue/g_acquire_cred.c +++ b/src/lib/gssapi/mechglue/g_acquire_cred.c @@ -378,7 +378,7 @@ error_out: return(status); } -/* V2 INTERFACE */ +/* V2 KRB5_CALLCONV */ KRB5_DLLIMP OM_uint32 KRB5_CALLCONV gss_add_cred(minor_status, input_cred_handle, desired_name, desired_mech, cred_usage, diff --git a/src/lib/gssapi/mechglue/g_compare_name.c b/src/lib/gssapi/mechglue/g_compare_name.c index 97e08d0f0..851be4a85 100644 --- a/src/lib/gssapi/mechglue/g_compare_name.c +++ b/src/lib/gssapi/mechglue/g_compare_name.c @@ -37,7 +37,7 @@ (((o1)->length == (o2)->length) && \ (memcmp((o1)->elements,(o2)->elements,(int) (o1)->length) == 0)) -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_compare_name (minor_status, name1, name2, diff --git a/src/lib/gssapi/mechglue/g_context_time.c b/src/lib/gssapi/mechglue/g_context_time.c index 7351564f5..6f08c9224 100644 --- a/src/lib/gssapi/mechglue/g_context_time.c +++ b/src/lib/gssapi/mechglue/g_context_time.c @@ -28,7 +28,7 @@ #include "mglueP.h" -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_context_time (minor_status, context_handle, time_rec) diff --git a/src/lib/gssapi/mechglue/g_delete_sec_context.c b/src/lib/gssapi/mechglue/g_delete_sec_context.c index 5138569e2..fae0b0ac3 100644 --- a/src/lib/gssapi/mechglue/g_delete_sec_context.c +++ b/src/lib/gssapi/mechglue/g_delete_sec_context.c @@ -32,7 +32,7 @@ #include #endif -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_delete_sec_context (minor_status, context_handle, output_token) diff --git a/src/lib/gssapi/mechglue/g_dsp_name.c b/src/lib/gssapi/mechglue/g_dsp_name.c index c7abaf9b1..8bd0426c3 100644 --- a/src/lib/gssapi/mechglue/g_dsp_name.c +++ b/src/lib/gssapi/mechglue/g_dsp_name.c @@ -34,7 +34,7 @@ #endif #include -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_display_name (minor_status, input_name, output_name_buffer, diff --git a/src/lib/gssapi/mechglue/g_dsp_status.c b/src/lib/gssapi/mechglue/g_dsp_status.c index 3c6e5785b..4b58c38f7 100644 --- a/src/lib/gssapi/mechglue/g_dsp_status.c +++ b/src/lib/gssapi/mechglue/g_dsp_status.c @@ -33,7 +33,7 @@ #include #endif -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_display_status (minor_status, status_value, status_type, diff --git a/src/lib/gssapi/mechglue/g_exp_sec_context.c b/src/lib/gssapi/mechglue/g_exp_sec_context.c index 61488c70b..958553b49 100644 --- a/src/lib/gssapi/mechglue/g_exp_sec_context.c +++ b/src/lib/gssapi/mechglue/g_exp_sec_context.c @@ -34,7 +34,7 @@ #endif #include -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_export_sec_context(minor_status, context_handle, interprocess_token) diff --git a/src/lib/gssapi/mechglue/g_imp_name.c b/src/lib/gssapi/mechglue/g_imp_name.c index 3e90d36e4..e93b4c9ac 100644 --- a/src/lib/gssapi/mechglue/g_imp_name.c +++ b/src/lib/gssapi/mechglue/g_imp_name.c @@ -35,7 +35,7 @@ #include #include -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_import_name(minor_status, input_name_buffer, input_name_type, diff --git a/src/lib/gssapi/mechglue/g_imp_sec_context.c b/src/lib/gssapi/mechglue/g_imp_sec_context.c index c7ed23d6b..eed9bbeda 100644 --- a/src/lib/gssapi/mechglue/g_imp_sec_context.c +++ b/src/lib/gssapi/mechglue/g_imp_sec_context.c @@ -34,7 +34,7 @@ #endif #include -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_import_sec_context(minor_status, interprocess_token, context_handle) diff --git a/src/lib/gssapi/mechglue/g_indicate_mechs.c b/src/lib/gssapi/mechglue/g_indicate_mechs.c index 4bf7eed73..334f7c1b9 100644 --- a/src/lib/gssapi/mechglue/g_indicate_mechs.c +++ b/src/lib/gssapi/mechglue/g_indicate_mechs.c @@ -38,7 +38,7 @@ extern gss_mechanism *__gss_mechs_array; static gss_OID_set_desc supported_mechs_desc; static gss_OID_set supported_mechs = NULL; -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_indicate_mechs (minor_status, mech_set) diff --git a/src/lib/gssapi/mechglue/g_init_sec_context.c b/src/lib/gssapi/mechglue/g_init_sec_context.c index 96d678332..1e19c57e4 100644 --- a/src/lib/gssapi/mechglue/g_init_sec_context.c +++ b/src/lib/gssapi/mechglue/g_init_sec_context.c @@ -37,7 +37,7 @@ (((o1)->length == (o2)->length) && \ (memcmp((o1)->elements,(o2)->elements,(int) (o1)->length) == 0)) -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_init_sec_context (minor_status, claimant_cred_handle, context_handle, diff --git a/src/lib/gssapi/mechglue/g_inq_context.c b/src/lib/gssapi/mechglue/g_inq_context.c index 105d203f8..3f28c484f 100644 --- a/src/lib/gssapi/mechglue/g_inq_context.c +++ b/src/lib/gssapi/mechglue/g_inq_context.c @@ -32,7 +32,7 @@ #endif /* Last argument new for V2 */ -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_inquire_context( minor_status, context_handle, diff --git a/src/lib/gssapi/mechglue/g_inq_cred.c b/src/lib/gssapi/mechglue/g_inq_cred.c index 27412df02..e0a2bc4a8 100644 --- a/src/lib/gssapi/mechglue/g_inq_cred.c +++ b/src/lib/gssapi/mechglue/g_inq_cred.c @@ -34,7 +34,7 @@ #include #include -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_inquire_cred(minor_status, cred_handle, name, @@ -159,7 +159,7 @@ gss_OID_set * mechanisms; return(GSS_S_COMPLETE); } -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_inquire_cred_by_mech(minor_status, cred_handle, mech_type, name, initiator_lifetime, acceptor_lifetime, cred_usage) OM_uint32 *minor_status; diff --git a/src/lib/gssapi/mechglue/g_inq_names.c b/src/lib/gssapi/mechglue/g_inq_names.c index 971595191..7c07f44ed 100644 --- a/src/lib/gssapi/mechglue/g_inq_names.c +++ b/src/lib/gssapi/mechglue/g_inq_names.c @@ -29,7 +29,7 @@ #include "mglueP.h" /* Last argument new for V2 */ -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_inquire_names_for_mech(minor_status, mechanism, name_types) OM_uint32 * minor_status; diff --git a/src/lib/gssapi/mechglue/g_process_context.c b/src/lib/gssapi/mechglue/g_process_context.c index b09b2a6f5..dcb4716bc 100644 --- a/src/lib/gssapi/mechglue/g_process_context.c +++ b/src/lib/gssapi/mechglue/g_process_context.c @@ -28,7 +28,7 @@ #include "mglueP.h" -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_process_context_token (minor_status, context_handle, token_buffer) diff --git a/src/lib/gssapi/mechglue/g_rel_buffer.c b/src/lib/gssapi/mechglue/g_rel_buffer.c index b39f3057e..6f8367a1d 100644 --- a/src/lib/gssapi/mechglue/g_rel_buffer.c +++ b/src/lib/gssapi/mechglue/g_rel_buffer.c @@ -32,7 +32,7 @@ #include #endif -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_release_buffer (minor_status, buffer) diff --git a/src/lib/gssapi/mechglue/g_rel_cred.c b/src/lib/gssapi/mechglue/g_rel_cred.c index 092492e7f..44d82709e 100644 --- a/src/lib/gssapi/mechglue/g_rel_cred.c +++ b/src/lib/gssapi/mechglue/g_rel_cred.c @@ -32,7 +32,7 @@ #include #endif -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_release_cred(minor_status, cred_handle) diff --git a/src/lib/gssapi/mechglue/g_rel_name.c b/src/lib/gssapi/mechglue/g_rel_name.c index 101b73009..29c3f9819 100644 --- a/src/lib/gssapi/mechglue/g_rel_name.c +++ b/src/lib/gssapi/mechglue/g_rel_name.c @@ -33,7 +33,7 @@ #endif #include -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_release_name (minor_status, input_name) diff --git a/src/lib/gssapi/mechglue/g_rel_oid_set.c b/src/lib/gssapi/mechglue/g_rel_oid_set.c index e52057f22..357c00e67 100644 --- a/src/lib/gssapi/mechglue/g_rel_oid_set.c +++ b/src/lib/gssapi/mechglue/g_rel_oid_set.c @@ -32,7 +32,7 @@ #include #endif -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_release_oid_set (minor_status, set) diff --git a/src/lib/gssapi/mechglue/g_seal.c b/src/lib/gssapi/mechglue/g_seal.c index 412202dee..7d66e469a 100644 --- a/src/lib/gssapi/mechglue/g_seal.c +++ b/src/lib/gssapi/mechglue/g_seal.c @@ -28,7 +28,7 @@ #include "mglueP.h" -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_seal (minor_status, context_handle, conf_req_flag, @@ -83,7 +83,7 @@ gss_buffer_t output_message_buffer; return(GSS_S_NO_CONTEXT); } -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_wrap (minor_status, context_handle, conf_req_flag, @@ -109,7 +109,7 @@ gss_buffer_t output_message_buffer; /* * New for V2 */ -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_wrap_size_limit(minor_status, context_handle, conf_req_flag, qop_req, req_output_size, max_input_size) OM_uint32 *minor_status; diff --git a/src/lib/gssapi/mechglue/g_sign.c b/src/lib/gssapi/mechglue/g_sign.c index 78eee681d..4dfd3ec71 100644 --- a/src/lib/gssapi/mechglue/g_sign.c +++ b/src/lib/gssapi/mechglue/g_sign.c @@ -28,7 +28,7 @@ #include "mglueP.h" -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_sign (minor_status, context_handle, qop_req, @@ -77,7 +77,7 @@ gss_buffer_t msg_token; return(GSS_S_NO_CONTEXT); } -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_get_mic (minor_status, context_handle, qop_req, diff --git a/src/lib/gssapi/mechglue/g_unseal.c b/src/lib/gssapi/mechglue/g_unseal.c index 35cab05e2..9ca1c1512 100644 --- a/src/lib/gssapi/mechglue/g_unseal.c +++ b/src/lib/gssapi/mechglue/g_unseal.c @@ -28,7 +28,7 @@ #include "mglueP.h" -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_unseal (minor_status, context_handle, input_message_buffer, @@ -80,7 +80,7 @@ int * qop_state; return(GSS_S_NO_CONTEXT); } -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_unwrap (minor_status, context_handle, input_message_buffer, diff --git a/src/lib/gssapi/mechglue/g_verify.c b/src/lib/gssapi/mechglue/g_verify.c index 53ed26268..7fc86b448 100644 --- a/src/lib/gssapi/mechglue/g_verify.c +++ b/src/lib/gssapi/mechglue/g_verify.c @@ -28,7 +28,7 @@ #include "mglueP.h" -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_verify (minor_status, context_handle, message_buffer, @@ -77,7 +77,7 @@ int * qop_state; return(GSS_S_NO_CONTEXT); } -OM_uint32 INTERFACE +OM_uint32 KRB5_CALLCONV gss_verify_mic (minor_status, context_handle, message_buffer, diff --git a/src/lib/gssapi16.def b/src/lib/gssapi16.def new file mode 100644 index 000000000..c2cbe93f7 --- /dev/null +++ b/src/lib/gssapi16.def @@ -0,0 +1,77 @@ +;---------------------------------------------------- +; GSSAPI.DEF - GSSAPI.DLL module definition file +;---------------------------------------------------- + +LIBRARY GSSAPI +DESCRIPTION 'Base Generic Security Service API' +EXETYPE WINDOWS +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE SINGLE +HEAPSIZE 8192 + +EXPORTS + WEP @1001 RESIDENTNAME + LibMain @1002 +; + gss_acquire_cred + gss_release_cred + gss_init_sec_context + gss_accept_sec_context + gss_process_context_token + gss_delete_sec_context + gss_context_time + gss_sign + gss_verify + gss_seal + gss_unseal + gss_display_status + gss_indicate_mechs + gss_compare_name + gss_display_name + gss_import_name + gss_release_name + gss_release_buffer + gss_release_oid_set + gss_inquire_cred +; +; GSS-API v2 additional credential calls +; + gss_add_cred + gss_inquire_cred_by_mech +; +; GSS-API v2 additional context-level calls +; + gss_inquire_context + gss_wrap_size_limit + gss_export_sec_context + gss_import_sec_context +; +; GSS-API v2 additional calls for OID and OID_set operations +; + gss_release_oid + gss_create_empty_oid_set + gss_add_oid_set_member + gss_test_oid_set_member + gss_oid_to_str + gss_str_to_oid +; +; GSS-API v2 renamed message protection calls +; + gss_wrap + gss_unwrap + gss_get_mic + gss_verify_mic +; +; GSS-API v2 future extensions +; + gss_inquire_names_for_mech +; gss_inquire_mechs_for_name +; gss_canonicalize_name +; gss_export_name +; +; GSS-API variables +; + _gss_nt_user_name + _gss_nt_machine_uid_name + _gss_nt_string_uid_name + _gss_nt_service_name diff --git a/src/lib/gssapi32.def b/src/lib/gssapi32.def new file mode 100644 index 000000000..959e0f8d0 --- /dev/null +++ b/src/lib/gssapi32.def @@ -0,0 +1,77 @@ +;---------------------------------------------------- +; GSSAPI.DEF - GSSAPI.DLL module definition file +;---------------------------------------------------- + +;LIBRARY GSSAPI +DESCRIPTION 'Base Generic Security Service API' +EXETYPE WINDOWS +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE SINGLE +HEAPSIZE 8192 + +EXPORTS + WEP @1001 RESIDENTNAME + LibMain @1002 +; + gss_acquire_cred + gss_release_cred + gss_init_sec_context + gss_accept_sec_context + gss_process_context_token + gss_delete_sec_context + gss_context_time + gss_sign + gss_verify + gss_seal + gss_unseal + gss_display_status + gss_indicate_mechs + gss_compare_name + gss_display_name + gss_import_name + gss_release_name + gss_release_buffer + gss_release_oid_set + gss_inquire_cred +; +; GSS-API v2 additional credential calls +; + gss_add_cred + gss_inquire_cred_by_mech +; +; GSS-API v2 additional context-level calls +; + gss_inquire_context + gss_wrap_size_limit + gss_export_sec_context + gss_import_sec_context +; +; GSS-API v2 additional calls for OID and OID_set operations +; + gss_release_oid + gss_create_empty_oid_set + gss_add_oid_set_member + gss_test_oid_set_member + gss_oid_to_str + gss_str_to_oid +; +; GSS-API v2 renamed message protection calls +; + gss_wrap + gss_unwrap + gss_get_mic + gss_verify_mic +; +; GSS-API v2 future extensions +; + gss_inquire_names_for_mech +; gss_inquire_mechs_for_name +; gss_canonicalize_name +; gss_export_name +; +; GSS-API variables +; + gss_nt_user_name + gss_nt_machine_uid_name + gss_nt_string_uid_name + gss_nt_service_name diff --git a/src/lib/kadm/ChangeLog b/src/lib/kadm/ChangeLog index 33c7dbb32..62570f32b 100644 --- a/src/lib/kadm/ChangeLog +++ b/src/lib/kadm/ChangeLog @@ -1,3 +1,10 @@ +Thu Nov 21 00:58:04 EST 1996 Richard Basch + + * Makefile.in: Win32 build + * adm_conn.c, adm_rw.c: + DLL export krb5_adm_connect, krb5_adm_disconnect, + krb5_free_adm_data, krb5_send_adm_cmd, krb5_read_adm_reply + Tue Sep 24 13:25:50 1996 Theodore Ts'o * Makefile.in: Eliminate extra files not needed for Macintosh and diff --git a/src/lib/kadm/Makefile.in b/src/lib/kadm/Makefile.in index 9cd60e717..f76a58abc 100644 --- a/src/lib/kadm/Makefile.in +++ b/src/lib/kadm/Makefile.in @@ -2,6 +2,8 @@ CFLAGS = $(CCOPTS) $(DEFS) ##DOSBUILDTOP = ..\.. ##DOSLIBNAME=kadm.lib +##DOSOBJFILE=kadm.lst + RUN_SETUP=@KRB5_RUN_ENV@ BASE_OBJS= adm_conn.$(OBJEXT) \ adm_kt_dec.$(OBJEXT) \ @@ -35,12 +37,15 @@ SRCS= $(srcdir)/adm_conn.c \ # $(srcdir)/adm_kw_enc.c -all:: $(BASE_OBJS) - -all-unix:: $(DB_OBJS) $(UNIX_OBJS) +all-unix:: $(BASE_OBJS) $(DB_OBJS) $(UNIX_OBJS) all-unix:: libkadm.a -all-mac:: $(DB_OBJS) -all-windows:: +all-mac:: $(BASE_OBJS) $(DB_OBJS) +all-windows:: $(OBJFILE) + +##DOS$(OBJFILE): $(BASE_OBJS) +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) *.obj > $(OBJFILE) libkadm.a: $(OBJS) $(UNIX_OBJS) $(RM) $@ @@ -56,7 +61,7 @@ clean-unix:: clean-mac:: $(RM) libkadm.$(LIBEXT) clean-windows:: - $(RM) kadm.lib kadm.bak + $(RM) kadm.lib kadm.bak $(OBJFILE) # # t_dbentry diff --git a/src/lib/kadm/adm_conn.c b/src/lib/kadm/adm_conn.c index 1534b4b02..d341b8301 100644 --- a/src/lib/kadm/adm_conn.c +++ b/src/lib/kadm/adm_conn.c @@ -602,17 +602,17 @@ kadm_get_auth(kcontext, ctxp, local, remote) * free auth_context * close socket. */ -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_adm_connect(kcontext, user, prompt, opassword, sockp, ctxp, ccachep, ccname, tlife) krb5_context kcontext; /* Context handle (In ) */ - char *user; /* User specified (In ) */ - char *prompt; /* Old password prompt (In ) */ - char *opassword; /* Old Password (I/O) */ - int *sockp; /* Socket for conn. (Out) */ - krb5_auth_context *ctxp; /* Auth context (Out) */ - krb5_ccache *ccachep; /* Credentials cache (I/O) */ - char *ccname; /* Cred cache name (In ) */ + char FAR *user; /* User specified (In ) */ + char FAR *prompt; /* Old password prompt (In ) */ + char FAR *opassword; /* Old Password (I/O) */ + int FAR *sockp; /* Socket for conn. (Out) */ + krb5_auth_context FAR *ctxp; /* Auth context (Out) */ + krb5_ccache FAR *ccachep; /* Credentials cache (I/O) */ + char FAR *ccname; /* Cred cache name (In ) */ krb5_timestamp tlife; /* Ticket lifetime (In ) */ { krb5_error_code kret; @@ -745,10 +745,10 @@ krb5_adm_connect(kcontext, user, prompt, opassword, sockp, ctxp, * If ccache is supplied, then it is destroyed. Otherwise, the ccache is * the caller's responsibility to close. */ -void INTERFACE +KRB5_DLLIMP void KRB5_CALLCONV krb5_adm_disconnect(kcontext, socketp, auth_context, ccache) krb5_context kcontext; - int *socketp; + int FAR *socketp; krb5_auth_context auth_context; krb5_ccache ccache; { diff --git a/src/lib/kadm/adm_rw.c b/src/lib/kadm/adm_rw.c index bed4e4bb1..0d823304d 100644 --- a/src/lib/kadm/adm_rw.c +++ b/src/lib/kadm/adm_rw.c @@ -68,11 +68,11 @@ kadm_copyout_int32(outint, cp) /* * krb5_free_adm_data() - Free data blocks allocated by read_adm... routines. */ -void INTERFACE +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_adm_data(kcontext, ncomp, datap) krb5_context kcontext; krb5_int32 ncomp; - krb5_data *datap; + krb5_data FAR *datap; { int i; @@ -96,13 +96,13 @@ krb5_free_adm_data(kcontext, ncomp, datap) * . * . */ -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_send_adm_cmd(kcontext, sock, ctx, nargs, arglist) krb5_context kcontext; /* Context handle (In ) */ krb5_pointer sock; /* Socket to write to (In ) */ krb5_auth_context ctx; /* Auth context (In ) */ - krb5_int32 nargs; /* Number of arguments (In ) */ - krb5_data *arglist; /* Components to write (In ) */ + krb5_int32 nargs; /* Number of arguments (In ) */ + krb5_data FAR *arglist; /* Components to write (In ) */ { int writebufsize; int i; @@ -412,14 +412,14 @@ krb5_read_adm_cmd(kcontext, sock, ctx, nargs, arglist) * It is the caller's responsibility to free the memory allocated for * the read in component list. */ -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_read_adm_reply(kcontext, sock, ctx, cmd_stat, ncomps, complist) krb5_context kcontext; /* Context handle (In ) */ krb5_pointer sock; /* Socket to read from (In ) */ krb5_auth_context ctx; /* Auth context (In ) */ - krb5_int32 *cmd_stat; /* Command status (Out) */ - krb5_int32 *ncomps; /* # of reply components(Out) */ - krb5_data **complist; /* List of components (Out) */ + krb5_int32 FAR *cmd_stat; /* Command status (Out) */ + krb5_int32 FAR *ncomps; /* # of reply components(Out) */ + krb5_data FAR * FAR *complist; /* List of components (Out) */ { krb5_data read_data; krb5_error_code ret; diff --git a/src/lib/krb5/ChangeLog b/src/lib/krb5/ChangeLog index e77f6b970..e2e717c35 100644 --- a/src/lib/krb5/ChangeLog +++ b/src/lib/krb5/ChangeLog @@ -1,3 +1,7 @@ +Thu Nov 21 11:55:16 EST 1996 Richard Basch + + * Makefile.in: win32 build + Mon Nov 18 20:42:39 1996 Ezra Peisach * configure.in: Set shared library version to 1.0. [krb5-libs/201] diff --git a/src/lib/krb5/Makefile.in b/src/lib/krb5/Makefile.in index 7387c76a5..f9227fa4f 100644 --- a/src/lib/krb5/Makefile.in +++ b/src/lib/krb5/Makefile.in @@ -1,4 +1,7 @@ ##DOSBUILDTOP = ..\.. +##DOSLIBNAME=krb5.lib +##DOSOBJFILEDEP=asn1.lst ccache.lst err_tbls.lst free.lst keytab.lst krb.lst os.lst posix.lst rcache.lst +##DOSOBJFILELIST=@asn1.lst @ccache.lst @err_tbls.lst @free.lst @keytab.lst @krb.lst @os.lst @posix.lst @rcache.lst ANAME_DBDEP=@ANAME_DBDEP@ ANAME_DBLIB=@ANAME_DBLIB@ @@ -28,7 +31,6 @@ SHLIB_LDFLAGS= $(LDFLAGS) @SHLIB_RPATH_DIRS@ SHLIB_LIBDIRS= @SHLIB_LIBDIRS@ all-unix:: - all-windows:: libkrb5.$(STEXT): $(LIBDONE) @@ -47,62 +49,62 @@ clean-windows:: $(RM) krb5.lib krb5.bak all-windows:: - cd ASN.1 - @echo Making in lib\asn.1 + cd asn.1 + @echo Making in krb5\asn.1 -$(MAKE) -$(MFLAGS) - cd ..\CCACHE - @echo Making in lib\ccache + cd ..\ccache + @echo Making in krb5\ccache -$(MAKE) -$(MFLAGS) cd ..\error_tables - @echo Making in lib\error_tables + @echo Making in krb5\error_tables -$(MAKE) -$(MFLAGS) - cd ..\FREE - @echo Making in lib\free + cd ..\free + @echo Making in krb5\free -$(MAKE) -$(MFLAGS) - cd ..\KEYTAB - @echo Making in lib\keytab + cd ..\keytab + @echo Making in krb5\keytab -$(MAKE) -$(MFLAGS) - cd ..\KRB - @echo Making in lib\krb + cd ..\krb + @echo Making in krb5\krb -$(MAKE) -$(MFLAGS) - cd ..\OS - @echo Making in lib\os + cd ..\os + @echo Making in krb5\os -$(MAKE) -$(MFLAGS) - cd ..\POSIX - @echo Making in lib\posix + cd ..\posix + @echo Making in krb5\posix -$(MAKE) -$(MFLAGS) - cd ..\RCACHE - @echo Making in lib\rcache + cd ..\rcache + @echo Making in krb5\rcache -$(MAKE) -$(MFLAGS) cd .. clean-windows:: cd ASN.1 - @echo Making clean in lib\asn.1 + @echo Making clean in krb5\asn.1 -$(MAKE) -$(MFLAGS) clean cd ..\CCACHE - @echo Making clean in lib\ccache + @echo Making clean in krb5\ccache -$(MAKE) -$(MFLAGS) clean cd ..\error_tables - @echo Making clean in lib\error_tables + @echo Making clean in krb5\error_tables -$(MAKE) -$(MFLAGS) clean cd ..\FREE - @echo Making clean in lib\free + @echo Making clean in krb5\free -$(MAKE) -$(MFLAGS) clean cd ..\KEYTAB - @echo Making clean in lib\keytab + @echo Making clean in krb5\keytab -$(MAKE) -$(MFLAGS) clean cd ..\KRB - @echo Making clean in lib\krb + @echo Making clean in krb5\krb -$(MAKE) -$(MFLAGS) clean cd ..\OS - @echo Making clean in lib\os + @echo Making clean in krb5\os -$(MAKE) -$(MFLAGS) clean cd ..\POSIX - @echo Making clean in lib\posix + @echo Making clean in krb5\posix -$(MAKE) -$(MFLAGS) clean cd ..\RCACHE - @echo Making clean in lib\rcache + @echo Making clean in krb5\rcache -$(MAKE) -$(MFLAGS) clean cd .. @echo Making clean locally diff --git a/src/lib/krb5/asn.1/ChangeLog b/src/lib/krb5/asn.1/ChangeLog index 8aa3684e2..64ce1a4a2 100644 --- a/src/lib/krb5/asn.1/ChangeLog +++ b/src/lib/krb5/asn.1/ChangeLog @@ -1,3 +1,7 @@ +Thu Nov 21 11:55:16 EST 1996 Richard Basch + + * Makefile.in: win32 build + Thu Nov 14 20:57:55 1996 Theodore Y. Ts'o * asn1_k_encode.c (asn1_encode_principal_name): Be liberal about diff --git a/src/lib/krb5/asn.1/Makefile.in b/src/lib/krb5/asn.1/Makefile.in index 034566e70..91afd6fd6 100644 --- a/src/lib/krb5/asn.1/Makefile.in +++ b/src/lib/krb5/asn.1/Makefile.in @@ -1,7 +1,9 @@ CFLAGS=$(CCOPTS) $(DEFS) ##DOSBUILDTOP = ..\..\.. -##DOSLIBNAME=..\krb5.lib +##DOSMYDIR=asn.1 +##DOSOBJFILE=..\asn1.lst +##WIN16##LIBNAME=..\krb5.lib EHDRDIR=$(BUILDTOP)/include/krb5/asn.1 @@ -35,7 +37,12 @@ OBJS= \ all-unix:: shared $(OBJS) all-mac:: $(OBJS) -all-windows:: $(OBJS) +all-windows:: $(OBJFILE) + +##DOS$(OBJFILE): $(OBJS) +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) -p $(MYDIR)\ *.obj > $(OBJFILE) shared: mkdir shared @@ -47,4 +54,4 @@ clean-mac:: $(RM) $(OBJS) clean-windows:: - $(RM) *.obj + $(RM) $(OBJFILE) diff --git a/src/lib/krb5/ccache/ChangeLog b/src/lib/krb5/ccache/ChangeLog index 56cea9297..f2b4d65d9 100644 --- a/src/lib/krb5/ccache/ChangeLog +++ b/src/lib/krb5/ccache/ChangeLog @@ -1,7 +1,15 @@ +Thu Nov 21 11:55:16 EST 1996 Richard Basch + + * Makefile.in: win32 build + + * ccbase.c, ccdefault.c: + DLL export basic ccache functions + Thu Jun 6 00:04:38 1996 Theodore Y. Ts'o * Makefile.in (all-windows): Don't pass $(LIBCMD) on the command - line. It's set in the windows.in prologue for all Makefiles anyway. + line. It's set in the windows.in prologue for all + Makefiles anyway. Wed Feb 7 00:23:18 1996 Theodore Y. Ts'o diff --git a/src/lib/krb5/ccache/Makefile.in b/src/lib/krb5/ccache/Makefile.in index c95b6f7a9..5661182c5 100644 --- a/src/lib/krb5/ccache/Makefile.in +++ b/src/lib/krb5/ccache/Makefile.in @@ -1,7 +1,9 @@ CFLAGS = $(CCOPTS) $(DEFS) -I$(srcdir)$(S)file -I$(srcdir)$(S)stdio ##DOSBUILDTOP = ..\..\.. -##DOSLIBNAME=..\krb5.lib +##DOSMYNAME=ccache +##DOSOBJFILE=..\$(MYNAME).lst +##WIN16##LIBNAME=..\krb5.lib MAC_SUBDIRS = file stdio @@ -22,11 +24,19 @@ SRCS= $(srcdir)/ccbase.c \ all-unix:: shared $(OBJS) all-mac:: $(OBJS) -all-windows:: $(OBJS) - cd FILE - @echo Making in ccache\file - -$(MAKE) -$(MFLAGS) - cd .. +all-windows:: subdirs $(OBJFILE) + +##DOSsubdirs:: file\file.lst +##DOSfile\file.lst:: +##DOS cd file +##DOS @echo Making in krb5\ccache\file +##DOS -$(MAKE) -$(MFLAGS) +##DOS cd .. + +##DOS$(OBJFILE): $(OBJS) file\file.lst +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) -p $(MYNAME)\ *.obj file\*.obj > $(OBJFILE) shared: mkdir shared @@ -36,8 +46,9 @@ clean-unix:: clean-mac: clean-windows:: - cd FILE - @echo Making clean in ccache\file + cd file + @echo Making clean in krb5\ccache\file -$(MAKE) -$(MFLAGS) clean cd .. - @echo Making clean locally + @echo Making clean in krb5\ccache + $(RM) $(OBJFILE) diff --git a/src/lib/krb5/ccache/ccbase.c b/src/lib/krb5/ccache/ccbase.c index 05a18d0df..e8bff024d 100644 --- a/src/lib/krb5/ccache/ccbase.c +++ b/src/lib/krb5/ccache/ccbase.c @@ -26,7 +26,6 @@ #include "k5-int.h" -extern krb5_cc_ops *krb5_cc_dfl_ops; struct krb5_cc_typelist { krb5_cc_ops *ops; @@ -39,10 +38,10 @@ static struct krb5_cc_typelist *cc_typehead = 0; * If override is set, replace any existing ccache with that type tag */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_cc_register(context, ops, override) krb5_context context; - krb5_cc_ops *ops; + krb5_cc_ops FAR *ops; krb5_boolean override; { struct krb5_cc_typelist *t; @@ -73,7 +72,7 @@ krb5_cc_register(context, ops, override) * particular cache type. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_cc_resolve (context, name, cache) krb5_context context; char *name; diff --git a/src/lib/krb5/ccache/ccdefault.c b/src/lib/krb5/ccache/ccdefault.c index c5b8f4c73..5e3cd53a9 100644 --- a/src/lib/krb5/ccache/ccdefault.c +++ b/src/lib/krb5/ccache/ccdefault.c @@ -26,10 +26,10 @@ #include "k5-int.h" -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_cc_default(context, ccache) krb5_context context; - krb5_ccache *ccache; + krb5_ccache FAR *ccache; { return krb5_cc_resolve(context, krb5_cc_default_name(context), ccache); } diff --git a/src/lib/krb5/ccache/file/ChangeLog b/src/lib/krb5/ccache/file/ChangeLog index 8b568c178..43f4a7038 100644 --- a/src/lib/krb5/ccache/file/ChangeLog +++ b/src/lib/krb5/ccache/file/ChangeLog @@ -1,3 +1,16 @@ +Thu Nov 21 11:55:16 EST 1996 Richard Basch + + * Makefile.in: win32 build + + * configure.in: Test for chmod and fchmod (not on Windows) + + * fcc-proto.h, fcc_close.c, fcc_destry.c, fcc_eseq.c, fcc_gennew.c, + fcc_getnam.c, fcc_gprin.c, fcc_init.c, fcc_nseq.c, fcc_ops.c, + fcc_reslv.c, fcc_retrv.c, fcc_sflags.c, fcc_sseq.c, fcc_store.c: + Changed the calling conventions of the internal ccache + functions to comply with the new function calling + conventions of the ccache dispatch functions (win16/win32) + Thu Aug 15 16:46:00 1996 Tom Yu * fcc_retrv.c (flags_match): Add parens to def'n of flags_match to diff --git a/src/lib/krb5/ccache/file/Makefile.in b/src/lib/krb5/ccache/file/Makefile.in index 48805c3c1..1c1c24677 100644 --- a/src/lib/krb5/ccache/file/Makefile.in +++ b/src/lib/krb5/ccache/file/Makefile.in @@ -1,7 +1,9 @@ CFLAGS = $(CCOPTS) $(DEFS) ##DOSBUILDTOP = ..\..\..\.. -##DOSLIBNAME=..\..\krb5.lib +##DOSMYNAME = ccache\file +##DOSOBJFILE = file.lst +##WIN16##LIBNAME=..\..\krb5.lib .c.o: $(CC) $(CFLAGS) -c $(srcdir)/$*.c @@ -25,7 +27,12 @@ SRCS = $(srcdir)/fcc_close.c $(srcdir)/fcc_destry.c $(srcdir)/fcc_eseq.c \ all-unix:: shared $(OBJS) all-mac:: $(OBJS) -all-windows:: $(OBJS) +all-windows:: $(OBJFILE) + +##DOS$(OBJFILE): $(OBJS) +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) -p $(MYNAME)\ *.obj > $(OBJFILE) shared: mkdir shared @@ -35,3 +42,4 @@ clean-unix:: clean-mac:: clean-windows:: + $(RM) $(OBJFILE) diff --git a/src/lib/krb5/ccache/file/configure.in b/src/lib/krb5/ccache/file/configure.in index ee042a115..72b51d7a1 100644 --- a/src/lib/krb5/ccache/file/configure.in +++ b/src/lib/krb5/ccache/file/configure.in @@ -2,6 +2,7 @@ AC_INIT(configure.in) CONFIG_RULES AC_HAVE_HEADERS(unistd.h) AC_FUNC_CHECK(flock,AC_DEFINE(HAVE_FLOCK)) +AC_HAVE_FUNCS(fchmod chmod) V5_SHARED_LIB_OBJS SubdirLibraryRule([${OBJS}]) V5_AC_OUTPUT_MAKEFILE diff --git a/src/lib/krb5/ccache/file/fcc-proto.h b/src/lib/krb5/ccache/file/fcc-proto.h index 7e8f7c158..61b5cf3c1 100644 --- a/src/lib/krb5/ccache/file/fcc-proto.h +++ b/src/lib/krb5/ccache/file/fcc-proto.h @@ -127,7 +127,7 @@ KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_fcc_set_flags KRB5_PROTOTYPE((krb5_context, krb5_ccache id , krb5_flags flags )); /* fcc_ops.c */ -extern krb5_cc_ops krb5_cc_file_ops; +KRB5_DLLIMP extern krb5_cc_ops krb5_cc_file_ops; krb5_error_code krb5_change_cache KRB5_PROTOTYPE((void)); diff --git a/src/lib/krb5/ccache/file/fcc_close.c b/src/lib/krb5/ccache/file/fcc_close.c index 71e52f549..6e7997afd 100644 --- a/src/lib/krb5/ccache/file/fcc_close.c +++ b/src/lib/krb5/ccache/file/fcc_close.c @@ -35,7 +35,7 @@ * Closes the file cache, invalidates the id, and frees any resources * associated with the cache. */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_fcc_close(context, id) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/file/fcc_destry.c b/src/lib/krb5/ccache/file/fcc_destry.c index 02deb7293..37914e1f9 100644 --- a/src/lib/krb5/ccache/file/fcc_destry.c +++ b/src/lib/krb5/ccache/file/fcc_destry.c @@ -34,7 +34,7 @@ * Errors: * system errors */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_fcc_destroy(context, id) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/file/fcc_eseq.c b/src/lib/krb5/ccache/file/fcc_eseq.c index 369d667a6..d6ce34e2d 100644 --- a/src/lib/krb5/ccache/file/fcc_eseq.c +++ b/src/lib/krb5/ccache/file/fcc_eseq.c @@ -40,7 +40,7 @@ * and invalidates the cursor (it must never be used after this call). */ /* ARGSUSED */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_fcc_end_seq_get(context, id, cursor) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/file/fcc_gennew.c b/src/lib/krb5/ccache/file/fcc_gennew.c index 177e0e960..a76a19277 100644 --- a/src/lib/krb5/ccache/file/fcc_gennew.c +++ b/src/lib/krb5/ccache/file/fcc_gennew.c @@ -53,7 +53,7 @@ extern krb5_cc_ops krb5_fcc_ops; * krb5_ccache. id is undefined. * system errors (from open) */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_fcc_generate_new (context, id) krb5_context context; krb5_ccache *id; @@ -111,8 +111,8 @@ krb5_fcc_generate_new (context, id) int errsave, cnt; /* Ignore user's umask, set mode = 0600 */ -#ifdef NOFCHMOD -#ifndef NOCHMOD +#ifndef HAVE_FCHMOD +#ifdef HAVE_CHMOD chmod(((krb5_fcc_data *) lid->data)->filename, S_IRUSR | S_IWUSR); #endif #else diff --git a/src/lib/krb5/ccache/file/fcc_getnam.c b/src/lib/krb5/ccache/file/fcc_getnam.c index 514535957..6a7b9557c 100644 --- a/src/lib/krb5/ccache/file/fcc_getnam.c +++ b/src/lib/krb5/ccache/file/fcc_getnam.c @@ -35,7 +35,7 @@ * Returns: * The name of the file cred cache id. */ -KRB5_DLLIMP char * KRB5_CALLCONV +char * KRB5_CALLCONV krb5_fcc_get_name (context, id) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/file/fcc_gprin.c b/src/lib/krb5/ccache/file/fcc_gprin.c index 97369db01..72d6c7780 100644 --- a/src/lib/krb5/ccache/file/fcc_gprin.c +++ b/src/lib/krb5/ccache/file/fcc_gprin.c @@ -40,7 +40,7 @@ * system errors * KRB5_CC_NOMEM */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_fcc_get_principal(context, id, princ) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/file/fcc_init.c b/src/lib/krb5/ccache/file/fcc_init.c index 8f661bab3..b3bf74de1 100644 --- a/src/lib/krb5/ccache/file/fcc_init.c +++ b/src/lib/krb5/ccache/file/fcc_init.c @@ -40,7 +40,7 @@ * system errors * permission errors */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_fcc_initialize(context, id, princ) krb5_context context; krb5_ccache id; @@ -51,8 +51,8 @@ krb5_fcc_initialize(context, id, princ) MAYBE_OPEN(context, id, FCC_OPEN_AND_ERASE); -#ifdef NOFCHMOD -#ifndef NOCHMOD +#ifndef HAVE_FCHMOD +#ifdef HAVE_CHMOD reti = chmod(((krb5_fcc_data *) id->data)->filename, S_IREAD | S_IWRITE); #endif #else diff --git a/src/lib/krb5/ccache/file/fcc_nseq.c b/src/lib/krb5/ccache/file/fcc_nseq.c index 96650ac45..92df32927 100644 --- a/src/lib/krb5/ccache/file/fcc_nseq.c +++ b/src/lib/krb5/ccache/file/fcc_nseq.c @@ -48,7 +48,7 @@ * Errors: * system errors */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_fcc_next_cred(context, id, cursor, creds) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/file/fcc_ops.c b/src/lib/krb5/ccache/file/fcc_ops.c index c9ff93978..e873bed0b 100644 --- a/src/lib/krb5/ccache/file/fcc_ops.c +++ b/src/lib/krb5/ccache/file/fcc_ops.c @@ -64,7 +64,7 @@ krb5_change_cache (void) { return 0; } -unsigned int INTERFACE +KRB5_DLLIMP unsigned int KRB5_CALLCONV krb5_get_notification_message (void) { static unsigned int message = 0; @@ -80,7 +80,7 @@ krb5_change_cache () { return 0; } -unsigned int INTERFACE +unsigned int krb5_get_notification_message () { return 0; diff --git a/src/lib/krb5/ccache/file/fcc_reslv.c b/src/lib/krb5/ccache/file/fcc_reslv.c index 4b6d381c9..8ba7d78b0 100644 --- a/src/lib/krb5/ccache/file/fcc_reslv.c +++ b/src/lib/krb5/ccache/file/fcc_reslv.c @@ -49,7 +49,7 @@ extern krb5_cc_ops krb5_fcc_ops; * krb5_ccache. id is undefined. * permission errors */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_fcc_resolve (context, id, residual) krb5_context context; krb5_ccache *id; diff --git a/src/lib/krb5/ccache/file/fcc_retrv.c b/src/lib/krb5/ccache/file/fcc_retrv.c index ab0db7c8e..e12d06e58 100644 --- a/src/lib/krb5/ccache/file/fcc_retrv.c +++ b/src/lib/krb5/ccache/file/fcc_retrv.c @@ -90,7 +90,7 @@ register const krb5_data *data1, *data2; * permission errors * KRB5_CC_NOMEM */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_fcc_retrieve(context, id, whichfields, mcreds, creds) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/file/fcc_sflags.c b/src/lib/krb5/ccache/file/fcc_sflags.c index d74f2b0e8..9f9b60140 100644 --- a/src/lib/krb5/ccache/file/fcc_sflags.c +++ b/src/lib/krb5/ccache/file/fcc_sflags.c @@ -39,7 +39,7 @@ * Effects: * Sets the operational flags of id to flags. */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_fcc_set_flags(context, id, flags) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/file/fcc_sseq.c b/src/lib/krb5/ccache/file/fcc_sseq.c index dac38941c..8e215becd 100644 --- a/src/lib/krb5/ccache/file/fcc_sseq.c +++ b/src/lib/krb5/ccache/file/fcc_sseq.c @@ -40,7 +40,7 @@ * KRB5_CC_NOMEM * system errors */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_fcc_start_seq_get(context, id, cursor) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/file/fcc_store.c b/src/lib/krb5/ccache/file/fcc_store.c index fec27aeb6..4915e4e39 100644 --- a/src/lib/krb5/ccache/file/fcc_store.c +++ b/src/lib/krb5/ccache/file/fcc_store.c @@ -41,7 +41,7 @@ * system errors * storage failure errors */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_fcc_store(context, id, creds) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/memory/mcc-proto.h b/src/lib/krb5/ccache/memory/mcc-proto.h index 6cc83f9af..d41ad4952 100644 --- a/src/lib/krb5/ccache/memory/mcc-proto.h +++ b/src/lib/krb5/ccache/memory/mcc-proto.h @@ -29,46 +29,46 @@ #define KRB5_MCC_PROTO__ /* mcc_close.c */ -krb5_error_code INTERFACE krb5_mcc_close +krb5_error_code KRB5_CALLCONV krb5_mcc_close PROTOTYPE((krb5_context, krb5_ccache id )); /* mcc_destry.c */ -krb5_error_code INTERFACE krb5_mcc_destroy +krb5_error_code KRB5_CALLCONV krb5_mcc_destroy PROTOTYPE((krb5_context, krb5_ccache id )); /* mcc_eseq.c */ -krb5_error_code INTERFACE krb5_mcc_end_seq_get +krb5_error_code KRB5_CALLCONV krb5_mcc_end_seq_get PROTOTYPE((krb5_context, krb5_ccache id , krb5_cc_cursor *cursor )); /* mcc_gennew.c */ -krb5_error_code INTERFACE krb5_mcc_generate_new +krb5_error_code KRB5_CALLCONV krb5_mcc_generate_new PROTOTYPE((krb5_context, krb5_ccache *id )); /* mcc_getnam.c */ -char * INTERFACE krb5_mcc_get_name +char * KRB5_CALLCONV krb5_mcc_get_name PROTOTYPE((krb5_context, krb5_ccache id )); /* mcc_gprin.c */ -krb5_error_code INTERFACE krb5_mcc_get_principal +krb5_error_code KRB5_CALLCONV krb5_mcc_get_principal PROTOTYPE((krb5_context, krb5_ccache id , krb5_principal *princ )); /* mcc_init.c */ -krb5_error_code INTERFACE krb5_mcc_initialize +krb5_error_code KRB5_CALLCONV krb5_mcc_initialize PROTOTYPE((krb5_context, krb5_ccache id , krb5_principal princ )); /* mcc_nseq.c */ -krb5_error_code INTERFACE krb5_mcc_next_cred +krb5_error_code KRB5_CALLCONV krb5_mcc_next_cred PROTOTYPE((krb5_context, krb5_ccache id , krb5_cc_cursor *cursor , krb5_creds *creds )); /* mcc_reslv.c */ -krb5_error_code INTERFACE krb5_mcc_resolve +krb5_error_code KRB5_CALLCONV krb5_mcc_resolve PROTOTYPE((krb5_context, krb5_ccache *id , char *residual )); /* mcc_retrv.c */ -krb5_error_code INTERFACE krb5_mcc_retrieve +krb5_error_code KRB5_CALLCONV krb5_mcc_retrieve PROTOTYPE((krb5_context, krb5_ccache id , krb5_flags whichfields , @@ -76,15 +76,15 @@ krb5_error_code INTERFACE krb5_mcc_retrieve krb5_creds *creds )); /* mcc_sseq.c */ -krb5_error_code INTERFACE krb5_mcc_start_seq_get +krb5_error_code KRB5_CALLCONV krb5_mcc_start_seq_get PROTOTYPE((krb5_context, krb5_ccache id , krb5_cc_cursor *cursor )); /* mcc_store.c */ -krb5_error_code INTERFACE krb5_mcc_store +krb5_error_code KRB5_CALLCONV krb5_mcc_store PROTOTYPE((krb5_context, krb5_ccache id , krb5_creds *creds )); /* mcc_sflags.c */ -krb5_error_code INTERFACE krb5_mcc_set_flags +krb5_error_code KRB5_CALLCONV krb5_mcc_set_flags PROTOTYPE((krb5_context, krb5_ccache id , krb5_flags flags )); /* mcc_ops.c */ diff --git a/src/lib/krb5/ccache/memory/mcc_close.c b/src/lib/krb5/ccache/memory/mcc_close.c index b40a9b360..514a4adfa 100644 --- a/src/lib/krb5/ccache/memory/mcc_close.c +++ b/src/lib/krb5/ccache/memory/mcc_close.c @@ -35,7 +35,7 @@ * Closes the file cache, invalidates the id, and frees any resources * associated with the cache. */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_mcc_close(context, id) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/memory/mcc_destry.c b/src/lib/krb5/ccache/memory/mcc_destry.c index 0c050523d..e6946789d 100644 --- a/src/lib/krb5/ccache/memory/mcc_destry.c +++ b/src/lib/krb5/ccache/memory/mcc_destry.c @@ -52,7 +52,7 @@ krb5_mcc_free(context, id) * Errors: * none */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_mcc_destroy(context, id) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/memory/mcc_eseq.c b/src/lib/krb5/ccache/memory/mcc_eseq.c index 907951b85..c3d264cdd 100644 --- a/src/lib/krb5/ccache/memory/mcc_eseq.c +++ b/src/lib/krb5/ccache/memory/mcc_eseq.c @@ -40,7 +40,7 @@ * and invalidates the cursor (it must never be used after this call). */ /* ARGSUSED */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_mcc_end_seq_get(context, id, cursor) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/memory/mcc_gennew.c b/src/lib/krb5/ccache/memory/mcc_gennew.c index 0e7dfa56f..76249610a 100644 --- a/src/lib/krb5/ccache/memory/mcc_gennew.c +++ b/src/lib/krb5/ccache/memory/mcc_gennew.c @@ -43,7 +43,7 @@ extern krb5_cc_ops krb5_mcc_ops; * krb5_ccache. id is undefined. * system errors (from open) */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_mcc_generate_new (context, id) krb5_context context; krb5_ccache *id; diff --git a/src/lib/krb5/ccache/memory/mcc_getnam.c b/src/lib/krb5/ccache/memory/mcc_getnam.c index fdfcaa84c..e86b0836e 100644 --- a/src/lib/krb5/ccache/memory/mcc_getnam.c +++ b/src/lib/krb5/ccache/memory/mcc_getnam.c @@ -35,7 +35,7 @@ * Returns: * The name of the file cred cache id. */ -char * INTERFACE +char * KRB5_CALLCONV krb5_mcc_get_name (context, id) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/memory/mcc_gprin.c b/src/lib/krb5/ccache/memory/mcc_gprin.c index 2cc55d32d..81624d73a 100644 --- a/src/lib/krb5/ccache/memory/mcc_gprin.c +++ b/src/lib/krb5/ccache/memory/mcc_gprin.c @@ -40,7 +40,7 @@ * system errors * KRB5_CC_NOMEM */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_mcc_get_principal(context, id, princ) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/memory/mcc_init.c b/src/lib/krb5/ccache/memory/mcc_init.c index 8aac3f16a..5f4a40ae7 100644 --- a/src/lib/krb5/ccache/memory/mcc_init.c +++ b/src/lib/krb5/ccache/memory/mcc_init.c @@ -40,7 +40,7 @@ */ void krb5_mcc_free KRB5_PROTOTYPE((krb5_context context, krb5_ccache id)); -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_mcc_initialize(context, id, princ) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/memory/mcc_nseq.c b/src/lib/krb5/ccache/memory/mcc_nseq.c index 30ecdba7e..a68b9f95a 100644 --- a/src/lib/krb5/ccache/memory/mcc_nseq.c +++ b/src/lib/krb5/ccache/memory/mcc_nseq.c @@ -46,7 +46,7 @@ * Errors: * system errors */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_mcc_next_cred(context, id, cursor, creds) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/memory/mcc_reslv.c b/src/lib/krb5/ccache/memory/mcc_reslv.c index 6146c6c2b..a2468d8d0 100644 --- a/src/lib/krb5/ccache/memory/mcc_reslv.c +++ b/src/lib/krb5/ccache/memory/mcc_reslv.c @@ -49,7 +49,7 @@ extern krb5_cc_ops krb5_mcc_ops; * krb5_ccache. id is undefined. * permission errors */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_mcc_resolve (context, id, residual) krb5_context context; krb5_ccache *id; diff --git a/src/lib/krb5/ccache/memory/mcc_retrv.c b/src/lib/krb5/ccache/memory/mcc_retrv.c index bb07171b4..ae3510129 100644 --- a/src/lib/krb5/ccache/memory/mcc_retrv.c +++ b/src/lib/krb5/ccache/memory/mcc_retrv.c @@ -86,7 +86,7 @@ register const krb5_data *data1, *data2; * permission errors * KRB5_CC_NOMEM */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_mcc_retrieve(context, id, whichfields, mcreds, creds) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/memory/mcc_sflags.c b/src/lib/krb5/ccache/memory/mcc_sflags.c index 1484ab8b1..a12c696f9 100644 --- a/src/lib/krb5/ccache/memory/mcc_sflags.c +++ b/src/lib/krb5/ccache/memory/mcc_sflags.c @@ -39,7 +39,7 @@ * Effects: * Sets the operational flags of id to flags. */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_mcc_set_flags(context, id, flags) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/memory/mcc_sseq.c b/src/lib/krb5/ccache/memory/mcc_sseq.c index 5954de3d6..bb87e47df 100644 --- a/src/lib/krb5/ccache/memory/mcc_sseq.c +++ b/src/lib/krb5/ccache/memory/mcc_sseq.c @@ -40,7 +40,7 @@ * KRB5_CC_NOMEM * system errors */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_mcc_start_seq_get(context, id, cursor) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/memory/mcc_store.c b/src/lib/krb5/ccache/memory/mcc_store.c index 8b2e22dfa..91a433f60 100644 --- a/src/lib/krb5/ccache/memory/mcc_store.c +++ b/src/lib/krb5/ccache/memory/mcc_store.c @@ -23,7 +23,7 @@ * system errors * storage failure errors */ -krb5_error_code INTERFACE +krb5_error_code KRB5_CALLCONV krb5_mcc_store(context, id, creds) krb5_context context; krb5_ccache id; diff --git a/src/lib/krb5/ccache/ser_cc.c b/src/lib/krb5/ccache/ser_cc.c index 384e8ebb2..c834769eb 100644 --- a/src/lib/krb5/ccache/ser_cc.c +++ b/src/lib/krb5/ccache/ser_cc.c @@ -203,7 +203,7 @@ krb5_ccache_internalize(kcontext, argp, buffer, lenremain) /* * Register the ccache serializer. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_ser_ccache_init(kcontext) krb5_context kcontext; { diff --git a/src/lib/krb5/error_tables/ChangeLog b/src/lib/krb5/error_tables/ChangeLog index ce88cc63d..863749bbd 100644 --- a/src/lib/krb5/error_tables/ChangeLog +++ b/src/lib/krb5/error_tables/ChangeLog @@ -1,3 +1,9 @@ +Thu Nov 21 11:55:16 EST 1996 Richard Basch + + * Makefile.in: win32 build + + * init_ets.c: dll export krb5_init_ets() + Fri Dec 13 14:55:43 1996 Theodore Y. Ts'o * krb5_err.et: Added the error codes KRB5_APPL_EXPIRED and diff --git a/src/lib/krb5/error_tables/Makefile.in b/src/lib/krb5/error_tables/Makefile.in index 10ddf764c..84fb64bd9 100644 --- a/src/lib/krb5/error_tables/Makefile.in +++ b/src/lib/krb5/error_tables/Makefile.in @@ -1,7 +1,9 @@ CFLAGS = $(CCOPTS) $(DEFS) ##DOSBUILDTOP = ..\..\.. -##DOSLIBNAME=..\krb5.lib +##DOSMYNAME=error_tables +##DOSOBJFILE=..\err_tbls.lst +##WIN16##LIBNAME=..\krb5.lib EHDRDIR=$(BUILDTOP)$(S)include$(S)krb5 @@ -30,8 +32,12 @@ SRCS= asn1_err.c kdb5_err.c krb5_err.c kv5m_err.c adm_err.c \ all-unix:: $(HDRS) shared $(OBJS) all-mac:: $(OBJS) +all-windows:: $(OBJFILE) -all-windows:: $(OBJS) +##DOS$(OBJFILE): $(OBJS) +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) -p $(MYNAME)\ *.obj > $(OBJFILE) shared: mkdir shared diff --git a/src/lib/krb5/error_tables/init_ets.c b/src/lib/krb5/error_tables/init_ets.c index 7a4e32ffc..9de65c5d3 100644 --- a/src/lib/krb5/error_tables/init_ets.c +++ b/src/lib/krb5/error_tables/init_ets.c @@ -26,7 +26,7 @@ #include "k5-int.h" -void INTERFACE +KRB5_DLLIMP void KRB5_CALLCONV krb5_init_ets (context) krb5_context context; { diff --git a/src/lib/krb5/free/ChangeLog b/src/lib/krb5/free/ChangeLog index 6ad05dcbe..327124b52 100644 --- a/src/lib/krb5/free/ChangeLog +++ b/src/lib/krb5/free/ChangeLog @@ -1,3 +1,15 @@ +Thu Nov 21 11:55:16 EST 1996 Richard Basch + + * Makefile.in: win32 build + + * f_addr.c f_address.c f_ap_rep.c f_ap_req.c f_arep_enc.c + f_auth_cnt.c f_authdata.c f_authent.c f_chksum.c f_cred.c + f_cred_cnt.c f_cred_enc.c f_creds.c f_enc_kdc.c f_enc_tkt.c + f_error.c f_kdc_rp.c f_kdc_rq.c f_keyblock.c f_last_req.c + f_padata.c f_princ.c f_priv.c f_priv_enc.c f_pwd_data.c + f_pwd_seq.c f_safe.c f_tckt.c f_tckts.c f_tkt_auth.c + DLL export free routines in krb5.h + Fri Aug 2 14:03:44 1996 Barry Jaspan * f_keyblock.c (krb5_free_keyblock_contents): added diff --git a/src/lib/krb5/free/Makefile.in b/src/lib/krb5/free/Makefile.in index 60b93b005..0384d53e0 100644 --- a/src/lib/krb5/free/Makefile.in +++ b/src/lib/krb5/free/Makefile.in @@ -1,7 +1,9 @@ CFLAGS = $(CCOPTS) $(DEFS) ##DOSBUILDTOP = ..\..\.. -##DOSLIBNAME=..\krb5.lib +##DOSMYNAME=free +##DOSOBJFILE=..\$(MYNAME).lst +##WIN16##LIBNAME=..\krb5.lib .c.o: $(CC) $(CFLAGS) -c $(srcdir)/$*.c @@ -77,7 +79,12 @@ SRCS= \ all-unix:: shared $(OBJS) all-mac:: $(OBJS) -all-windows:: $(OBJS) +all-windows:: $(OBJFILE) + +##DOS$(OBJFILE): $(OBJS) +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) -p $(MYNAME)\ *.obj > $(OBJFILE) shared: mkdir shared @@ -87,5 +94,5 @@ clean-unix:: clean-mac:: clean-windows:: - + $(RM) $(OBJFILE) diff --git a/src/lib/krb5/free/f_addr.c b/src/lib/krb5/free/f_addr.c index d8f58b767..9faea10be 100644 --- a/src/lib/krb5/free/f_addr.c +++ b/src/lib/krb5/free/f_addr.c @@ -25,10 +25,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_address(context, val) krb5_context context; - krb5_address *val; + krb5_address FAR *val; { if (val->contents) krb5_xfree(val->contents); diff --git a/src/lib/krb5/free/f_address.c b/src/lib/krb5/free/f_address.c index 7f3bfa662..7387eba68 100644 --- a/src/lib/krb5/free/f_address.c +++ b/src/lib/krb5/free/f_address.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void INTERFACE +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_addresses(context, val) krb5_context context; - krb5_address **val; + krb5_address FAR * FAR *val; { register krb5_address **temp; diff --git a/src/lib/krb5/free/f_ap_rep.c b/src/lib/krb5/free/f_ap_rep.c index 0301af162..50e67109c 100644 --- a/src/lib/krb5/free/f_ap_rep.c +++ b/src/lib/krb5/free/f_ap_rep.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_ap_rep(context, val) krb5_context context; - register krb5_ap_rep *val; + register krb5_ap_rep FAR *val; { if (val->enc_part.ciphertext.data) krb5_xfree(val->enc_part.ciphertext.data); diff --git a/src/lib/krb5/free/f_ap_req.c b/src/lib/krb5/free/f_ap_req.c index 1b9a93a7e..8e63a6ed7 100644 --- a/src/lib/krb5/free/f_ap_req.c +++ b/src/lib/krb5/free/f_ap_req.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_ap_req(context, val) krb5_context context; - register krb5_ap_req *val; + register krb5_ap_req FAR *val; { if (val->ticket) krb5_free_ticket(context, val->ticket); diff --git a/src/lib/krb5/free/f_arep_enc.c b/src/lib/krb5/free/f_arep_enc.c index ec1d5ef90..99eff9a0f 100644 --- a/src/lib/krb5/free/f_arep_enc.c +++ b/src/lib/krb5/free/f_arep_enc.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void INTERFACE +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_ap_rep_enc_part(context, val) krb5_context context; - krb5_ap_rep_enc_part *val; + krb5_ap_rep_enc_part FAR *val; { if (val->subkey) krb5_free_keyblock(context, val->subkey); diff --git a/src/lib/krb5/free/f_auth_cnt.c b/src/lib/krb5/free/f_auth_cnt.c index d061f26f9..8b7a11a9d 100644 --- a/src/lib/krb5/free/f_auth_cnt.c +++ b/src/lib/krb5/free/f_auth_cnt.c @@ -27,10 +27,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_authenticator_contents(context, val) krb5_context context; - krb5_authenticator *val; + krb5_authenticator FAR *val; { if (val->checksum) krb5_free_checksum(context, val->checksum); diff --git a/src/lib/krb5/free/f_authdata.c b/src/lib/krb5/free/f_authdata.c index fba8dd319..f91a26ba2 100644 --- a/src/lib/krb5/free/f_authdata.c +++ b/src/lib/krb5/free/f_authdata.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_authdata(context, val) krb5_context context; -krb5_authdata **val; + krb5_authdata FAR * FAR *val; { register krb5_authdata **temp; diff --git a/src/lib/krb5/free/f_authent.c b/src/lib/krb5/free/f_authent.c index f4d1c0659..898da745c 100644 --- a/src/lib/krb5/free/f_authent.c +++ b/src/lib/krb5/free/f_authent.c @@ -27,10 +27,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_authenticator(context, val) krb5_context context; - krb5_authenticator *val; + krb5_authenticator FAR *val; { if (val->checksum) krb5_free_checksum(context, val->checksum); diff --git a/src/lib/krb5/free/f_chksum.c b/src/lib/krb5/free/f_chksum.c index beab7450b..ac2fd7674 100644 --- a/src/lib/krb5/free/f_chksum.c +++ b/src/lib/krb5/free/f_chksum.c @@ -26,7 +26,7 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_checksum(context, val) krb5_context context; register krb5_checksum *val; diff --git a/src/lib/krb5/free/f_cred.c b/src/lib/krb5/free/f_cred.c index 7cc2a9a97..b572aeb8e 100644 --- a/src/lib/krb5/free/f_cred.c +++ b/src/lib/krb5/free/f_cred.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_cred(context, val) krb5_context context; - register krb5_cred *val; + register krb5_cred FAR *val; { if (val->tickets) krb5_free_tickets(context, val->tickets); diff --git a/src/lib/krb5/free/f_cred_cnt.c b/src/lib/krb5/free/f_cred_cnt.c index 575b07555..6f40499b4 100644 --- a/src/lib/krb5/free/f_cred_cnt.c +++ b/src/lib/krb5/free/f_cred_cnt.c @@ -31,10 +31,10 @@ * the credentials structures */ -void INTERFACE +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_cred_contents(context, val) krb5_context context; - krb5_creds *val; + krb5_creds FAR *val; { if (val->client) krb5_free_principal(context, val->client); diff --git a/src/lib/krb5/free/f_cred_enc.c b/src/lib/krb5/free/f_cred_enc.c index d14b3d861..24c06eae1 100644 --- a/src/lib/krb5/free/f_cred_enc.c +++ b/src/lib/krb5/free/f_cred_enc.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_cred_enc_part(context, val) krb5_context context; - register krb5_cred_enc_part *val; + register krb5_cred_enc_part FAR *val; { register krb5_cred_info **temp; diff --git a/src/lib/krb5/free/f_creds.c b/src/lib/krb5/free/f_creds.c index 7d00afe30..b47b4fdfd 100644 --- a/src/lib/krb5/free/f_creds.c +++ b/src/lib/krb5/free/f_creds.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void INTERFACE +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_creds(context, val) krb5_context context; - krb5_creds *val; + krb5_creds FAR *val; { krb5_free_cred_contents(context, val); krb5_xfree(val); diff --git a/src/lib/krb5/free/f_enc_kdc.c b/src/lib/krb5/free/f_enc_kdc.c index 102237674..b45d28a62 100644 --- a/src/lib/krb5/free/f_enc_kdc.c +++ b/src/lib/krb5/free/f_enc_kdc.c @@ -26,7 +26,7 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_enc_kdc_rep_part(context, val) krb5_context context; register krb5_enc_kdc_rep_part *val; diff --git a/src/lib/krb5/free/f_enc_tkt.c b/src/lib/krb5/free/f_enc_tkt.c index 3c2aa3ae4..409ed5ac0 100644 --- a/src/lib/krb5/free/f_enc_tkt.c +++ b/src/lib/krb5/free/f_enc_tkt.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_enc_tkt_part(context, val) krb5_context context; - krb5_enc_tkt_part *val; + krb5_enc_tkt_part FAR *val; { if (val->session) krb5_free_keyblock(context, val->session); diff --git a/src/lib/krb5/free/f_error.c b/src/lib/krb5/free/f_error.c index a24a6c409..16b5c52a7 100644 --- a/src/lib/krb5/free/f_error.c +++ b/src/lib/krb5/free/f_error.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_error(context, val) krb5_context context; - register krb5_error *val; + register krb5_error FAR *val; { if (val->client) krb5_free_principal(context, val->client); diff --git a/src/lib/krb5/free/f_kdc_rp.c b/src/lib/krb5/free/f_kdc_rp.c index aba2fff31..b424f368e 100644 --- a/src/lib/krb5/free/f_kdc_rp.c +++ b/src/lib/krb5/free/f_kdc_rp.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_kdc_rep(context, val) krb5_context context; -krb5_kdc_rep *val; + krb5_kdc_rep FAR *val; { if (val->padata) krb5_free_pa_data(context, val->padata); diff --git a/src/lib/krb5/free/f_kdc_rq.c b/src/lib/krb5/free/f_kdc_rq.c index 2b1ad9082..9116850a3 100644 --- a/src/lib/krb5/free/f_kdc_rq.c +++ b/src/lib/krb5/free/f_kdc_rq.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_kdc_req(context, val) krb5_context context; - krb5_kdc_req *val; + krb5_kdc_req FAR *val; { if (val->padata) krb5_free_pa_data(context, val->padata); diff --git a/src/lib/krb5/free/f_keyblock.c b/src/lib/krb5/free/f_keyblock.c index f3e13cfef..8d6950eeb 100644 --- a/src/lib/krb5/free/f_keyblock.c +++ b/src/lib/krb5/free/f_keyblock.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_keyblock_contents(context, key) krb5_context context; - register krb5_keyblock *key; + register krb5_keyblock FAR *key; { if (key->contents) { memset(key->contents, 0, key->length); @@ -38,10 +38,10 @@ krb5_free_keyblock_contents(context, key) return; } -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_keyblock(context, val) krb5_context context; - register krb5_keyblock *val; + register krb5_keyblock FAR *val; { krb5_free_keyblock_contents(context, val); krb5_xfree(val); diff --git a/src/lib/krb5/free/f_last_req.c b/src/lib/krb5/free/f_last_req.c index 278b6f4b7..cb0959f28 100644 --- a/src/lib/krb5/free/f_last_req.c +++ b/src/lib/krb5/free/f_last_req.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_last_req(context, val) krb5_context context; - krb5_last_req_entry **val; + krb5_last_req_entry FAR * FAR *val; { register krb5_last_req_entry **temp; diff --git a/src/lib/krb5/free/f_padata.c b/src/lib/krb5/free/f_padata.c index 954001451..332bf02e3 100644 --- a/src/lib/krb5/free/f_padata.c +++ b/src/lib/krb5/free/f_padata.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_pa_data(context, val) krb5_context context; - krb5_pa_data **val; + krb5_pa_data FAR * FAR *val; { register krb5_pa_data **temp; diff --git a/src/lib/krb5/free/f_princ.c b/src/lib/krb5/free/f_princ.c index 4ccf7393d..af1c07e79 100644 --- a/src/lib/krb5/free/f_princ.c +++ b/src/lib/krb5/free/f_princ.c @@ -26,7 +26,7 @@ #include "k5-int.h" -void INTERFACE +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_principal(context, val) krb5_context context; krb5_principal val; diff --git a/src/lib/krb5/free/f_priv.c b/src/lib/krb5/free/f_priv.c index 06861421a..f781ce6b1 100644 --- a/src/lib/krb5/free/f_priv.c +++ b/src/lib/krb5/free/f_priv.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_priv(context, val) krb5_context context; -register krb5_priv *val; + register krb5_priv FAR *val; { if (val->enc_part.ciphertext.data) krb5_xfree(val->enc_part.ciphertext.data); diff --git a/src/lib/krb5/free/f_priv_enc.c b/src/lib/krb5/free/f_priv_enc.c index 8e25602bb..cc48e08ba 100644 --- a/src/lib/krb5/free/f_priv_enc.c +++ b/src/lib/krb5/free/f_priv_enc.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_priv_enc_part(context, val) krb5_context context; - register krb5_priv_enc_part *val; + register krb5_priv_enc_part FAR *val; { if (val->user_data.data) krb5_xfree(val->user_data.data); diff --git a/src/lib/krb5/free/f_pwd_data.c b/src/lib/krb5/free/f_pwd_data.c index 2a92336b3..386e00474 100644 --- a/src/lib/krb5/free/f_pwd_data.c +++ b/src/lib/krb5/free/f_pwd_data.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_pwd_data(context, val) krb5_context context; -krb5_pwd_data *val; + krb5_pwd_data FAR *val; { if (val->element) krb5_free_pwd_sequences(context, val->element); diff --git a/src/lib/krb5/free/f_pwd_seq.c b/src/lib/krb5/free/f_pwd_seq.c index 436fb6830..af1a969f0 100644 --- a/src/lib/krb5/free/f_pwd_seq.c +++ b/src/lib/krb5/free/f_pwd_seq.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_pwd_sequences(context, val) krb5_context context; - passwd_phrase_element **val; + passwd_phrase_element FAR * FAR *val; { if ((*val)->passwd) krb5_xfree((*val)->passwd); diff --git a/src/lib/krb5/free/f_safe.c b/src/lib/krb5/free/f_safe.c index 11a3159f4..30a8650ce 100644 --- a/src/lib/krb5/free/f_safe.c +++ b/src/lib/krb5/free/f_safe.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_safe(context, val) krb5_context context; - register krb5_safe *val; + register krb5_safe FAR *val; { if (val->user_data.data) krb5_xfree(val->user_data.data); diff --git a/src/lib/krb5/free/f_tckt.c b/src/lib/krb5/free/f_tckt.c index 8344345eb..bfc8fbf77 100644 --- a/src/lib/krb5/free/f_tckt.c +++ b/src/lib/krb5/free/f_tckt.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_ticket(context, val) krb5_context context; - krb5_ticket *val; + krb5_ticket FAR *val; { if (val->server) krb5_free_principal(context, val->server); diff --git a/src/lib/krb5/free/f_tckts.c b/src/lib/krb5/free/f_tckts.c index 1a1af1e18..f211eff6f 100644 --- a/src/lib/krb5/free/f_tckts.c +++ b/src/lib/krb5/free/f_tckts.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_tickets(context, val) krb5_context context; - krb5_ticket **val; + krb5_ticket FAR * FAR *val; { register krb5_ticket **temp; diff --git a/src/lib/krb5/free/f_tgt_cred.c b/src/lib/krb5/free/f_tgt_cred.c index ddf726826..93fd3c17d 100644 --- a/src/lib/krb5/free/f_tgt_cred.c +++ b/src/lib/krb5/free/f_tgt_cred.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_tgt_creds(context, tgts) krb5_context context; - krb5_creds **tgts; + krb5_creds FAR * FAR *tgts; { register krb5_creds **tgtpp; for (tgtpp = tgts; *tgtpp; tgtpp++) diff --git a/src/lib/krb5/free/f_tkt_auth.c b/src/lib/krb5/free/f_tkt_auth.c index 2ef99f482..8bfc9b9e4 100644 --- a/src/lib/krb5/free/f_tkt_auth.c +++ b/src/lib/krb5/free/f_tkt_auth.c @@ -26,10 +26,10 @@ #include "k5-int.h" -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_tkt_authent(context, val) krb5_context context; - krb5_tkt_authent *val; + krb5_tkt_authent FAR *val; { if (val->ticket) krb5_free_ticket(context, val->ticket); diff --git a/src/lib/krb5/keytab/ChangeLog b/src/lib/krb5/keytab/ChangeLog index e860ba5cd..85fbb79df 100644 --- a/src/lib/krb5/keytab/ChangeLog +++ b/src/lib/krb5/keytab/ChangeLog @@ -1,3 +1,10 @@ +Thu Nov 21 11:55:16 EST 1996 Richard Basch + + * Makefile.in: win32 build + + * ktadd.c,ktbase.c,ktdefault.c,ktfr_entry.c,ktremove.c,read_servi.c: + DLL export the keytab dispatch functions + Thu Jun 6 00:04:38 1996 Theodore Y. Ts'o * Makefile.in (all-windows): Don't pass $(LIBCMD) on the command diff --git a/src/lib/krb5/keytab/Makefile.in b/src/lib/krb5/keytab/Makefile.in index 760fc4e97..fa7acc83a 100644 --- a/src/lib/krb5/keytab/Makefile.in +++ b/src/lib/krb5/keytab/Makefile.in @@ -1,7 +1,9 @@ CFLAGS = $(CCOPTS) $(DEFS) ##DOSBUILDTOP = ..\..\.. -##DOSLIBNAME=..\krb5.lib +##DOSMYNAME=keytab +##DOSOBJFILE=..\$(MYNAME).lst +##WIN16##LIBNAME=..\krb5.lib MAC_SUBDIRS = file @@ -30,11 +32,19 @@ shared: all-unix:: shared $(OBJS) all-mac:: $(OBJS) -all-windows:: $(OBJS) - cd file - @echo Making in keytab\file - -$(MAKE) -$(MFLAGS) - cd .. +all-windows:: subdirs $(OBJFILE) + +##DOSsubdirs:: file\file.lst +##DOSfile\file.lst:: +##DOS cd file +##DOS @echo Making in krb5\keytab\file +##DOS -$(MAKE) -$(MFLAGS) +##DOS cd .. + +##DOS$(OBJFILE): $(OBJS) file\file.lst +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) -p $(MYNAME)\ *.obj file\*.obj > $(OBJFILE) clean-unix:: $(RM) shared/* @@ -42,8 +52,9 @@ clean-unix:: clean-mac:: clean-windows:: cd file - @echo Making clean in keytab\file + @echo Making clean in krb5\keytab\file -$(MAKE) -$(MFLAGS) clean cd .. - @echo Making clean locally + @echo Making clean in krb5\keytab + $(RM) $(OBJFILE) diff --git a/src/lib/krb5/keytab/file/ChangeLog b/src/lib/krb5/keytab/file/ChangeLog index f14e2a030..7109cf7c1 100644 --- a/src/lib/krb5/keytab/file/ChangeLog +++ b/src/lib/krb5/keytab/file/ChangeLog @@ -1,3 +1,12 @@ +Thu Nov 21 11:55:16 EST 1996 Richard Basch + + * Makefile.in: win32 build + + * ktf_add.c, ktf_close.c, ktf_g_ent.c, ktf_g_name.c, ktf_next.c, + ktf_remove.c, ktf_resolv.c, ktf_ssget.c, ktf_wreslv.c, ktfile.h + Change the functions declarations to include FAR pointers + and KRB5_CALLCONV so that they can be utilized by a DLL. + Tue Nov 19 17:06:59 1996 Barry Jaspan * ktf_g_ent.c (krb5_ktfile_get_entry): return KRB5_KT_KVNONOTFOUND diff --git a/src/lib/krb5/keytab/file/Makefile.in b/src/lib/krb5/keytab/file/Makefile.in index 36291e9f0..4b27d33cf 100644 --- a/src/lib/krb5/keytab/file/Makefile.in +++ b/src/lib/krb5/keytab/file/Makefile.in @@ -1,7 +1,9 @@ CFLAGS = $(CCOPTS) $(DEFS) ##DOSBUILDTOP = ..\..\..\.. -##DOSLIBNAME=..\..\krb5.lib +##DOSMYNAME=keytab\file +##DOSOBJFILE= file.lst +##WIN16##LIBNAME=..\..\krb5.lib .c.o: $(CC) $(CFLAGS) -c $(srcdir)/$*.c @@ -43,7 +45,12 @@ OBJS = \ all-unix:: shared $(OBJS) all-mac:: $(OBJS) -all-windows:: $(OBJS) +all-windows:: $(OBJFILE) + +##DOS$(OBJFILE): $(OBJS) +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) -p $(MYNAME)\ *.obj > $(OBJFILE) shared: mkdir shared @@ -53,3 +60,4 @@ clean-unix:: clean-mac:: clean-windows:: + $(RM) $(OBJFILE) diff --git a/src/lib/krb5/keytab/file/ktf_add.c b/src/lib/krb5/keytab/file/ktf_add.c index aac429c04..8979ad8c9 100644 --- a/src/lib/krb5/keytab/file/ktf_add.c +++ b/src/lib/krb5/keytab/file/ktf_add.c @@ -27,7 +27,7 @@ #include "k5-int.h" #include "ktfile.h" -krb5_error_code +krb5_error_code KRB5_CALLCONV krb5_ktfile_add(context, id, entry) krb5_context context; krb5_keytab id; diff --git a/src/lib/krb5/keytab/file/ktf_close.c b/src/lib/krb5/keytab/file/ktf_close.c index 93ee92e68..a538aa719 100644 --- a/src/lib/krb5/keytab/file/ktf_close.c +++ b/src/lib/krb5/keytab/file/ktf_close.c @@ -28,7 +28,7 @@ #include "k5-int.h" #include "ktfile.h" -krb5_error_code +krb5_error_code KRB5_CALLCONV krb5_ktfile_close(context, id) krb5_context context; krb5_keytab id; diff --git a/src/lib/krb5/keytab/file/ktf_endget.c b/src/lib/krb5/keytab/file/ktf_endget.c index 25ef4de7e..66f862e18 100644 --- a/src/lib/krb5/keytab/file/ktf_endget.c +++ b/src/lib/krb5/keytab/file/ktf_endget.c @@ -27,7 +27,7 @@ #include "k5-int.h" #include "ktfile.h" -krb5_error_code +krb5_error_code KRB5_CALLCONV krb5_ktfile_end_get(context, id, cursor) krb5_context context; krb5_keytab id; diff --git a/src/lib/krb5/keytab/file/ktf_g_ent.c b/src/lib/krb5/keytab/file/ktf_g_ent.c index e42dcdbd4..67050a838 100644 --- a/src/lib/krb5/keytab/file/ktf_g_ent.c +++ b/src/lib/krb5/keytab/file/ktf_g_ent.c @@ -29,7 +29,7 @@ #include "k5-int.h" #include "ktfile.h" -krb5_error_code +krb5_error_code KRB5_CALLCONV krb5_ktfile_get_entry(context, id, principal, kvno, enctype, entry) krb5_context context; krb5_keytab id; diff --git a/src/lib/krb5/keytab/file/ktf_g_name.c b/src/lib/krb5/keytab/file/ktf_g_name.c index fadb9bc94..b0cd4d8e6 100644 --- a/src/lib/krb5/keytab/file/ktf_g_name.c +++ b/src/lib/krb5/keytab/file/ktf_g_name.c @@ -27,7 +27,7 @@ #include "k5-int.h" #include "ktfile.h" -krb5_error_code +krb5_error_code KRB5_CALLCONV krb5_ktfile_get_name(context, id, name, len) krb5_context context; krb5_keytab id; diff --git a/src/lib/krb5/keytab/file/ktf_next.c b/src/lib/krb5/keytab/file/ktf_next.c index 7b13ede5a..acabb7c35 100644 --- a/src/lib/krb5/keytab/file/ktf_next.c +++ b/src/lib/krb5/keytab/file/ktf_next.c @@ -27,7 +27,7 @@ #include "k5-int.h" #include "ktfile.h" -krb5_error_code +krb5_error_code KRB5_CALLCONV krb5_ktfile_get_next(context, id, entry, cursor) krb5_context context; krb5_keytab id; diff --git a/src/lib/krb5/keytab/file/ktf_remove.c b/src/lib/krb5/keytab/file/ktf_remove.c index 644209f7a..3d9e627b5 100644 --- a/src/lib/krb5/keytab/file/ktf_remove.c +++ b/src/lib/krb5/keytab/file/ktf_remove.c @@ -27,7 +27,7 @@ #include "k5-int.h" #include "ktfile.h" -krb5_error_code +krb5_error_code KRB5_CALLCONV krb5_ktfile_remove(context, id, entry) krb5_context context; krb5_keytab id; diff --git a/src/lib/krb5/keytab/file/ktf_resolv.c b/src/lib/krb5/keytab/file/ktf_resolv.c index 415f3c5f3..93c06d022 100644 --- a/src/lib/krb5/keytab/file/ktf_resolv.c +++ b/src/lib/krb5/keytab/file/ktf_resolv.c @@ -28,7 +28,7 @@ #include "k5-int.h" #include "ktfile.h" -krb5_error_code +krb5_error_code KRB5_CALLCONV krb5_ktfile_resolve(context, name, id) krb5_context context; const char *name; diff --git a/src/lib/krb5/keytab/file/ktf_ssget.c b/src/lib/krb5/keytab/file/ktf_ssget.c index 1001b2ee7..b66c4caba 100644 --- a/src/lib/krb5/keytab/file/ktf_ssget.c +++ b/src/lib/krb5/keytab/file/ktf_ssget.c @@ -27,7 +27,7 @@ #include "k5-int.h" #include "ktfile.h" -krb5_error_code +krb5_error_code KRB5_CALLCONV krb5_ktfile_start_seq_get(context, id, cursorp) krb5_context context; krb5_keytab id; diff --git a/src/lib/krb5/keytab/file/ktf_wreslv.c b/src/lib/krb5/keytab/file/ktf_wreslv.c index 9df5922a9..e132293a0 100644 --- a/src/lib/krb5/keytab/file/ktf_wreslv.c +++ b/src/lib/krb5/keytab/file/ktf_wreslv.c @@ -28,7 +28,7 @@ #include "k5-int.h" #include "ktfile.h" -krb5_error_code +krb5_error_code KRB5_CALLCONV krb5_ktfile_wresolve(context, name, id) krb5_context context; const char *name; diff --git a/src/lib/krb5/keytab/file/ktfile.h b/src/lib/krb5/keytab/file/ktfile.h index 0b2542ceb..155f24603 100644 --- a/src/lib/krb5/keytab/file/ktfile.h +++ b/src/lib/krb5/keytab/file/ktfile.h @@ -62,27 +62,27 @@ typedef struct _krb5_ktfile_data { extern struct _krb5_kt_ops krb5_ktf_ops; extern struct _krb5_kt_ops krb5_ktf_writable_ops; -krb5_error_code krb5_ktfile_resolve +krb5_error_code KRB5_CALLCONV krb5_ktfile_resolve PROTOTYPE((krb5_context, const char *, krb5_keytab *)); -krb5_error_code krb5_ktfile_wresolve +krb5_error_code KRB5_CALLCONV krb5_ktfile_wresolve PROTOTYPE((krb5_context, const char *, krb5_keytab *)); -krb5_error_code krb5_ktfile_get_name +krb5_error_code KRB5_CALLCONV krb5_ktfile_get_name PROTOTYPE((krb5_context, krb5_keytab, char *, int)); -krb5_error_code krb5_ktfile_close +krb5_error_code KRB5_CALLCONV krb5_ktfile_close PROTOTYPE((krb5_context, krb5_keytab)); -krb5_error_code krb5_ktfile_get_entry +krb5_error_code KRB5_CALLCONV krb5_ktfile_get_entry PROTOTYPE((krb5_context, krb5_keytab, krb5_principal, @@ -90,29 +90,29 @@ krb5_error_code krb5_ktfile_get_entry krb5_enctype, krb5_keytab_entry *)); -krb5_error_code krb5_ktfile_start_seq_get +krb5_error_code KRB5_CALLCONV krb5_ktfile_start_seq_get PROTOTYPE((krb5_context, krb5_keytab, krb5_kt_cursor *)); -krb5_error_code krb5_ktfile_get_next +krb5_error_code KRB5_CALLCONV krb5_ktfile_get_next PROTOTYPE((krb5_context, krb5_keytab, krb5_keytab_entry *, krb5_kt_cursor *)); -krb5_error_code krb5_ktfile_end_get +krb5_error_code KRB5_CALLCONV krb5_ktfile_end_get PROTOTYPE((krb5_context, krb5_keytab, krb5_kt_cursor *)); /* routines to be included on extended version (write routines) */ -krb5_error_code krb5_ktfile_add +krb5_error_code KRB5_CALLCONV krb5_ktfile_add PROTOTYPE((krb5_context, krb5_keytab, krb5_keytab_entry *)); -krb5_error_code krb5_ktfile_remove +krb5_error_code KRB5_CALLCONV krb5_ktfile_remove PROTOTYPE((krb5_context, krb5_keytab, krb5_keytab_entry *)); diff --git a/src/lib/krb5/keytab/ktadd.c b/src/lib/krb5/keytab/ktadd.c index 56d31028c..ab805c94d 100644 --- a/src/lib/krb5/keytab/ktadd.c +++ b/src/lib/krb5/keytab/ktadd.c @@ -26,11 +26,11 @@ #include "k5-int.h" -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_kt_add_entry (context, id, entry) krb5_context context; krb5_keytab id; - krb5_keytab_entry *entry; + krb5_keytab_entry FAR *entry; { if (id->ops->add) return (*id->ops->add)(context, id, entry); diff --git a/src/lib/krb5/keytab/ktbase.c b/src/lib/krb5/keytab/ktbase.c index e78c3dc71..3e821edc7 100644 --- a/src/lib/krb5/keytab/ktbase.c +++ b/src/lib/krb5/keytab/ktbase.c @@ -39,10 +39,10 @@ static struct krb5_kt_typelist *kt_typehead = &krb5_kt_typelist_dfl; * don't replace if it already exists; return an error instead. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_kt_register(context, ops) krb5_context context; - krb5_kt_ops *ops; + krb5_kt_ops FAR *ops; { struct krb5_kt_typelist *t; for (t = kt_typehead;t && strcmp(t->ops->prefix,ops->prefix);t = t->next) @@ -68,11 +68,11 @@ krb5_kt_register(context, ops) * particular keytab type. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_kt_resolve (context, name, ktid) krb5_context context; - const char *name; - krb5_keytab *ktid; + const char FAR *name; + krb5_keytab FAR *ktid; { struct krb5_kt_typelist *tlist; char *pfx, *resid, *cp; @@ -184,7 +184,7 @@ krb5_keytab_internalize(kcontext, argp, buffer, lenremain) return(kret); } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_ser_keytab_init(kcontext) krb5_context kcontext; { diff --git a/src/lib/krb5/keytab/ktdefault.c b/src/lib/krb5/keytab/ktdefault.c index 1e34b76ce..6178d43dd 100644 --- a/src/lib/krb5/keytab/ktdefault.c +++ b/src/lib/krb5/keytab/ktdefault.c @@ -27,10 +27,10 @@ #include "k5-int.h" #include -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_kt_default(context, id) krb5_context context; - krb5_keytab *id; + krb5_keytab FAR *id; { char defname[BUFSIZ]; krb5_error_code retval; diff --git a/src/lib/krb5/keytab/ktfr_entry.c b/src/lib/krb5/keytab/ktfr_entry.c index 5aaa77512..92c3235e4 100644 --- a/src/lib/krb5/keytab/ktfr_entry.c +++ b/src/lib/krb5/keytab/ktfr_entry.c @@ -26,10 +26,10 @@ #include "k5-int.h" -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_kt_free_entry (context, entry) krb5_context context; - krb5_keytab_entry *entry; + krb5_keytab_entry FAR *entry; { if (!entry) return 0; diff --git a/src/lib/krb5/keytab/ktremove.c b/src/lib/krb5/keytab/ktremove.c index 377c4a0a7..6fc9dd3cf 100644 --- a/src/lib/krb5/keytab/ktremove.c +++ b/src/lib/krb5/keytab/ktremove.c @@ -26,11 +26,11 @@ #include "k5-int.h" -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_kt_remove_entry (context, id, entry) krb5_context context; krb5_keytab id; - krb5_keytab_entry *entry; + krb5_keytab_entry FAR *entry; { if (id->ops->remove) return (*id->ops->remove)(context, id, entry); diff --git a/src/lib/krb5/keytab/read_servi.c b/src/lib/krb5/keytab/read_servi.c index a17443461..b6f058e49 100644 --- a/src/lib/krb5/keytab/read_servi.c +++ b/src/lib/krb5/keytab/read_servi.c @@ -40,14 +40,14 @@ * returns: Either KSUCCESS or error code. * errors: error code if not found or keyprocarg is invalid. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_kt_read_service_key(context, keyprocarg, principal, vno, enctype, key) krb5_context context; krb5_pointer keyprocarg; krb5_principal principal; krb5_kvno vno; krb5_enctype enctype; - krb5_keyblock ** key; + krb5_keyblock FAR * FAR * key; { krb5_error_code kerror = KSUCCESS; char keytabname[MAX_KEYTAB_NAME_LEN + 1]; /* + 1 for NULL termination */ diff --git a/src/lib/krb5/krb/ChangeLog b/src/lib/krb5/krb/ChangeLog index 025691fcf..1d6f06b85 100644 --- a/src/lib/krb5/krb/ChangeLog +++ b/src/lib/krb5/krb/ChangeLog @@ -1,3 +1,16 @@ +Sun Feb 2 20:57:15 1997 Richard Basch + + * serialize.c: Added FAR declarations to pointer arguments for + all functions declared as KRB5_DLLIMP. + +Thu Jan 30 21:44:37 1997 Richard Basch + + * crypto_glue.c: + Export more crypto-layer functions: + krb5_encrypt, krb5_decrypt, krb5_eblock_enctype, + krb5_process_key, krb5_finish_key, krb5_string_to_key, + krb5_init_random_key, krb5_finish_random_key, krb5_random_key + Mon Dec 23 17:20:03 1996 Theodore Y. Ts'o * Makefile.in (SRCS): Add brand.c to the SRCS line so that the @@ -16,6 +29,20 @@ Sat Dec 21 01:26:11 1996 Theodore Y. Ts'o code, which is returned to the user if the timebomb should be activated. +Thu Nov 21 14:55:16 EST 1996 Richard Basch + + * Makefile.in: win32 build + + * auth_con.c bld_pr_ext.c conv_princ.c copy_addrs.c copy_athctr.c + copy_auth.c copy_cksum.c copy_creds.c copy_data.c copy_key.c + copy_princ.c copy_tick.c cp_key_cnt.c decrypt_tk.c fwd_tgt.c + gc_via_tkt.c get_creds.c get_in_tkt.c in_tkt_ktb.c in_tkt_pwd.c + in_tkt_sky.c init_ctx.c mk_cred.c mk_error.c mk_priv.c mk_rep.c + mk_req.c mk_req_ext.c mk_safe.c parse.c princ_comp.c rd_cred.c + rd_error.c rd_priv.c rd_rep.c rd_req.c rd_safe.c recvauth.c + sendauth.c str_conv.c unparse.c valid_times.c + DLL export various functions (see lib/krb5.def for full list) + Thu Nov 21 13:54:01 1996 Ezra Peisach * recvauth.c (krb5_recvauth): If there is an error, and the server diff --git a/src/lib/krb5/krb/Makefile.in b/src/lib/krb5/krb/Makefile.in index 2ec9e933b..8ee61e8f3 100644 --- a/src/lib/krb5/krb/Makefile.in +++ b/src/lib/krb5/krb/Makefile.in @@ -2,7 +2,9 @@ CFLAGS = $(CCOPTS) $(DEFS) RUN_SETUP = @KRB5_RUN_ENV@ ##DOSBUILDTOP = ..\..\.. -##DOSLIBNAME=..\krb5.lib +##DOSMYNAME=krb +##DOSOBJFILE=..\$(MYNAME).lst +##WIN16##LIBNAME=..\krb5.lib .c.o: $(CC) $(CFLAGS) -c $(srcdir)/$*.c @@ -26,6 +28,7 @@ OBJS= addr_comp.$(OBJEXT) \ copy_princ.$(OBJEXT) \ copy_tick.$(OBJEXT) \ cp_key_cnt.$(OBJEXT) \ + crypto_glue.$(OBJEXT) \ decode_kdc.$(OBJEXT) \ decrypt_tk.$(OBJEXT) \ encode_kdc.$(OBJEXT) \ @@ -100,6 +103,7 @@ SRCS= $(srcdir)/addr_comp.c \ $(srcdir)/copy_princ.c \ $(srcdir)/copy_tick.c \ $(srcdir)/cp_key_cnt.c \ + $(srcdir)/crypto_glue.c \ $(srcdir)/decode_kdc.c \ $(srcdir)/decrypt_tk.c \ $(srcdir)/encode_kdc.c \ @@ -157,7 +161,12 @@ SRCS= $(srcdir)/addr_comp.c \ all-unix:: shared $(OBJS) all-mac:: shared $(OBJS) -all-windows:: $(OBJS) +all-windows:: $(OBJFILE) + +##DOS$(OBJFILE): $(OBJS) +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) -p $(MYNAME)\ *.obj > $(OBJFILE) shared: mkdir shared @@ -222,3 +231,4 @@ clean-unix:: clean-mac:: $(RM) shared/* clean-windows:: + $(RM) $(OBJFILE) diff --git a/src/lib/krb5/krb/auth_con.c b/src/lib/krb5/krb/auth_con.c index ec8918208..b258b0dd2 100644 --- a/src/lib/krb5/krb/auth_con.c +++ b/src/lib/krb5/krb/auth_con.c @@ -26,10 +26,10 @@ actx_copy_addr(context, inad, outad) return 0; } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_auth_con_init(context, auth_context) krb5_context context; - krb5_auth_context * auth_context; + krb5_auth_context FAR * auth_context; { *auth_context = (krb5_auth_context)malloc(sizeof(struct _krb5_auth_context)); @@ -48,7 +48,7 @@ krb5_auth_con_init(context, auth_context) return 0; } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_auth_con_free(context, auth_context) krb5_context context; krb5_auth_context auth_context; @@ -172,18 +172,18 @@ krb5_auth_con_setports(context, auth_context, local_port, remote_port) * Once decrypted this key is no longer necessary and is then overwritten * with the session key sent by the client. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_auth_con_setuseruserkey(context, auth_context, keyblock) krb5_context context; krb5_auth_context auth_context; - krb5_keyblock * keyblock; + krb5_keyblock FAR * keyblock; { if (auth_context->keyblock) krb5_free_keyblock(context, auth_context->keyblock); return(krb5_copy_keyblock(context, keyblock, &(auth_context->keyblock))); } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_auth_con_getkey(context, auth_context, keyblock) krb5_context context; krb5_auth_context auth_context; @@ -195,11 +195,11 @@ krb5_auth_con_getkey(context, auth_context, keyblock) return 0; } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_auth_con_getlocalsubkey(context, auth_context, keyblock) krb5_context context; krb5_auth_context auth_context; - krb5_keyblock ** keyblock; + krb5_keyblock FAR * FAR * keyblock; { if (auth_context->local_subkey) return krb5_copy_keyblock(context,auth_context->local_subkey,keyblock); @@ -207,11 +207,11 @@ krb5_auth_con_getlocalsubkey(context, auth_context, keyblock) return 0; } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_auth_con_getremotesubkey(context, auth_context, keyblock) krb5_context context; krb5_auth_context auth_context; - krb5_keyblock ** keyblock; + krb5_keyblock FAR * FAR * keyblock; { if (auth_context->remote_subkey) return krb5_copy_keyblock(context,auth_context->remote_subkey,keyblock); @@ -219,7 +219,7 @@ krb5_auth_con_getremotesubkey(context, auth_context, keyblock) return 0; } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_auth_con_set_req_cksumtype(context, auth_context, cksumtype) krb5_context context; krb5_auth_context auth_context; @@ -239,7 +239,7 @@ krb5_auth_con_set_safe_cksumtype(context, auth_context, cksumtype) return 0; } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_auth_con_getlocalseqnumber(context, auth_context, seqnumber) krb5_context context; krb5_auth_context auth_context; @@ -249,21 +249,21 @@ krb5_auth_con_getlocalseqnumber(context, auth_context, seqnumber) return 0; } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_auth_con_getauthenticator(context, auth_context, authenticator) krb5_context context; krb5_auth_context auth_context; - krb5_authenticator ** authenticator; + krb5_authenticator FAR * FAR * authenticator; { return (krb5_copy_authenticator(context, auth_context->authentp, authenticator)); } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_auth_con_getremoteseqnumber(context, auth_context, seqnumber) krb5_context context; krb5_auth_context auth_context; - krb5_int32 * seqnumber; + krb5_int32 FAR * seqnumber; { *seqnumber = auth_context->remote_seq_number; return 0; @@ -307,7 +307,7 @@ krb5_auth_con_getivector(context, auth_context, ivector) return 0; } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_auth_con_setflags(context, auth_context, flags) krb5_context context; krb5_auth_context auth_context; @@ -317,11 +317,11 @@ krb5_auth_con_setflags(context, auth_context, flags) return 0; } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_auth_con_getflags(context, auth_context, flags) krb5_context context; krb5_auth_context auth_context; - krb5_int32 * flags; + krb5_int32 FAR * flags; { *flags = auth_context->auth_context_flags; return 0; diff --git a/src/lib/krb5/krb/bld_pr_ext.c b/src/lib/krb5/krb/bld_pr_ext.c index 85c62c509..8b201759f 100644 --- a/src/lib/krb5/krb/bld_pr_ext.c +++ b/src/lib/krb5/krb/bld_pr_ext.c @@ -32,15 +32,15 @@ #include #endif -krb5_error_code INTERFACE_C +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV_C #ifdef HAVE_STDARG_H -krb5_build_principal_ext(krb5_context context, krb5_principal * princ, int rlen, const char * realm, ...) +krb5_build_principal_ext(krb5_context context, krb5_principal FAR * princ, int rlen, const char FAR * realm, ...) #else krb5_build_principal_ext(context, princ, rlen, realm, va_alist) krb5_context context; - krb5_principal *princ; + krb5_principal FAR *princ; int rlen; - const char *realm; + const char FAR *realm; va_dcl #endif { diff --git a/src/lib/krb5/krb/bld_princ.c b/src/lib/krb5/krb/bld_princ.c index d78fea5f5..364c234ca 100644 --- a/src/lib/krb5/krb/bld_princ.c +++ b/src/lib/krb5/krb/bld_princ.c @@ -96,7 +96,7 @@ krb5_build_principal_va(context, princ, rlen, realm, ap) return 0; } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV_C #ifdef HAVE_STDARG_H krb5_build_principal(krb5_context context, krb5_principal * princ, int rlen, const char * realm, ...) diff --git a/src/lib/krb5/krb/conv_princ.c b/src/lib/krb5/krb/conv_princ.c index d11fac337..6a72abc72 100644 --- a/src/lib/krb5/krb/conv_princ.c +++ b/src/lib/krb5/krb/conv_princ.c @@ -102,13 +102,13 @@ static char *strnchr(s, c, n) /* XXX This calls for a new error code */ #define KRB5_INVALID_PRINCIPAL KRB5_LNAME_BADFORMAT -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_524_conv_principal(context, princ, name, inst, realm) krb5_context context; const krb5_principal princ; - char *name; - char *inst; - char *realm; + char FAR *name; + char FAR *inst; + char FAR *realm; { const struct krb_convert *p; krb5_data *compo; @@ -170,13 +170,13 @@ krb5_524_conv_principal(context, princ, name, inst, realm) return 0; } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_425_conv_principal(context, name, instance, realm, princ) krb5_context context; - const char *name; - const char *instance; - const char *realm; - krb5_principal *princ; + const char FAR *name; + const char FAR *instance; + const char FAR *realm; + krb5_principal FAR *princ; { const struct krb_convert *p; char buf[256]; /* V4 instances are limited to 40 characters */ diff --git a/src/lib/krb5/krb/copy_addrs.c b/src/lib/krb5/krb/copy_addrs.c index 4d93ebf98..596a1267e 100644 --- a/src/lib/krb5/krb/copy_addrs.c +++ b/src/lib/krb5/krb/copy_addrs.c @@ -26,11 +26,11 @@ #include "k5-int.h" -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_copy_addr(context, inad, outad) krb5_context context; -const krb5_address *inad; -krb5_address **outad; + const krb5_address FAR *inad; + krb5_address FAR * FAR *outad; { krb5_address *tmpad; @@ -53,11 +53,11 @@ krb5_address **outad; /* * Copy an address array, with fresh allocation. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_copy_addresses(context, inaddr, outaddr) krb5_context context; - krb5_address * const * inaddr; - krb5_address ***outaddr; + krb5_address FAR * const FAR * inaddr; + krb5_address FAR * FAR * FAR *outaddr; { krb5_error_code retval; krb5_address ** tempaddr; diff --git a/src/lib/krb5/krb/copy_athctr.c b/src/lib/krb5/krb/copy_athctr.c index d162fb215..e2bec676c 100644 --- a/src/lib/krb5/krb/copy_athctr.c +++ b/src/lib/krb5/krb/copy_athctr.c @@ -26,11 +26,11 @@ #include "k5-int.h" -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_copy_authenticator(context, authfrom, authto) krb5_context context; -const krb5_authenticator *authfrom; -krb5_authenticator **authto; + const krb5_authenticator FAR *authfrom; + krb5_authenticator FAR *FAR *authto; { krb5_error_code retval; krb5_authenticator *tempto; diff --git a/src/lib/krb5/krb/copy_auth.c b/src/lib/krb5/krb/copy_auth.c index 759608ca5..7594b9136 100644 --- a/src/lib/krb5/krb/copy_auth.c +++ b/src/lib/krb5/krb/copy_auth.c @@ -53,11 +53,11 @@ krb5_authdata **outad; /* * Copy an authdata array, with fresh allocation. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_copy_authdata(context, inauthdat, outauthdat) krb5_context context; -krb5_authdata * const * inauthdat; -krb5_authdata ***outauthdat; + krb5_authdata FAR * const FAR * inauthdat; + krb5_authdata FAR * FAR * FAR *outauthdat; { krb5_error_code retval; krb5_authdata ** tempauthdat; diff --git a/src/lib/krb5/krb/copy_cksum.c b/src/lib/krb5/krb/copy_cksum.c index c0bf8a24a..8adc82a90 100644 --- a/src/lib/krb5/krb/copy_cksum.c +++ b/src/lib/krb5/krb/copy_cksum.c @@ -26,11 +26,11 @@ #include "k5-int.h" -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_copy_checksum(context, ckfrom, ckto) krb5_context context; - const krb5_checksum *ckfrom; - krb5_checksum **ckto; + const krb5_checksum FAR *ckfrom; + krb5_checksum FAR * FAR *ckto; { krb5_checksum *tempto; diff --git a/src/lib/krb5/krb/copy_creds.c b/src/lib/krb5/krb/copy_creds.c index 712ca3833..a8fea1166 100644 --- a/src/lib/krb5/krb/copy_creds.c +++ b/src/lib/krb5/krb/copy_creds.c @@ -30,7 +30,7 @@ * Copy credentials, allocating fresh storage where needed. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_copy_creds(context, incred, outcred) krb5_context context; const krb5_creds *incred; diff --git a/src/lib/krb5/krb/copy_data.c b/src/lib/krb5/krb/copy_data.c index fb2e8708d..df4f7831e 100644 --- a/src/lib/krb5/krb/copy_data.c +++ b/src/lib/krb5/krb/copy_data.c @@ -29,11 +29,11 @@ /* * Copy a data structure, with fresh allocation. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_copy_data(context, indata, outdata) krb5_context context; - const krb5_data *indata; - krb5_data **outdata; + const krb5_data FAR *indata; + krb5_data FAR * FAR *outdata; { krb5_data *tempdata; diff --git a/src/lib/krb5/krb/copy_key.c b/src/lib/krb5/krb/copy_key.c index e71f39961..39fcb7df8 100644 --- a/src/lib/krb5/krb/copy_key.c +++ b/src/lib/krb5/krb/copy_key.c @@ -29,11 +29,11 @@ /* * Copy a keyblock, including alloc'ed storage. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_copy_keyblock(context, from, to) krb5_context context; - const krb5_keyblock *from; - krb5_keyblock **to; + const krb5_keyblock FAR *from; + krb5_keyblock FAR * FAR *to; { krb5_keyblock *new_key; diff --git a/src/lib/krb5/krb/copy_princ.c b/src/lib/krb5/krb/copy_princ.c index 4dbf44e7e..2a4025e8d 100644 --- a/src/lib/krb5/krb/copy_princ.c +++ b/src/lib/krb5/krb/copy_princ.c @@ -29,11 +29,11 @@ /* * Copy a principal structure, with fresh allocation. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_copy_principal(context, inprinc, outprinc) krb5_context context; krb5_const_principal inprinc; - krb5_principal *outprinc; + krb5_principal FAR *outprinc; { register krb5_principal tempprinc; register int i, nelems; diff --git a/src/lib/krb5/krb/copy_tick.c b/src/lib/krb5/krb/copy_tick.c index a4dbed4df..9235db111 100644 --- a/src/lib/krb5/krb/copy_tick.c +++ b/src/lib/krb5/krb/copy_tick.c @@ -95,7 +95,7 @@ krb5_copy_enc_tkt_part(context, partfrom, partto) return 0; } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_copy_ticket(context, from, pto) krb5_context context; const krb5_ticket *from; diff --git a/src/lib/krb5/krb/cp_key_cnt.c b/src/lib/krb5/krb/cp_key_cnt.c index fd32cae15..6cc6ef843 100644 --- a/src/lib/krb5/krb/cp_key_cnt.c +++ b/src/lib/krb5/krb/cp_key_cnt.c @@ -29,11 +29,11 @@ /* * Copy a keyblock, including alloc'ed storage. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_copy_keyblock_contents(context, from, to) krb5_context context; - const krb5_keyblock *from; - krb5_keyblock *to; + const krb5_keyblock FAR *from; + krb5_keyblock FAR *to; { *to = *from; to->contents = (krb5_octet *)malloc(to->length); diff --git a/src/lib/krb5/krb/crypto_glue.c b/src/lib/krb5/krb/crypto_glue.c new file mode 100644 index 000000000..615adc653 --- /dev/null +++ b/src/lib/krb5/krb/crypto_glue.c @@ -0,0 +1,233 @@ +/* + * lib/krb5/krb/crypto_glue.c + * + * Copyright 1996 by the Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + * + * Exported routines: + * krb5_use_enctype() + * krb5_checksum_size() + * krb5_encrypt_size() + * krb5_calculate_checksum() + * krb5_verify_checksum() + * krb5_encrypt() + * krb5_decrypt() + * krb5_process_key() + * krb5_finish_key() + * krb5_string_to_key() + * krb5_init_random_key() + * krb5_finish_random_key() + * krb5_random_key() + * krb5_eblock_enctype() + * + * Internal library routines: + * is_coll_proof_cksum() + * is_keyed_cksum() + * valid_cksumtype() + * valid_enctype() + */ + +#include "k5-int.h" + + +KRB5_DLLIMP size_t KRB5_CALLCONV +krb5_encrypt_size(length, crypto) + krb5_const size_t length; + krb5_const krb5_cryptosystem_entry FAR * crypto; +{ + return krb5_roundup(length + crypto->pad_minimum, crypto->block_length); +} + +krb5_boolean KRB5_CALLCONV +valid_enctype(ktype) + krb5_const krb5_enctype ktype; +{ + return ((ktype<=krb5_max_enctype) && (ktype>0) && krb5_enctype_array[ktype]); +} + +krb5_boolean KRB5_CALLCONV +valid_cksumtype(cktype) + krb5_const krb5_cksumtype cktype; +{ + return ((cktype<=krb5_max_cksum) && (cktype>0) && krb5_cksumarray[cktype]); +} + +krb5_boolean KRB5_CALLCONV +is_coll_proof_cksum(cktype) + krb5_const krb5_cksumtype cktype; +{ + return(krb5_cksumarray[cktype]->is_collision_proof); +} + +krb5_boolean KRB5_CALLCONV +is_keyed_cksum(cktype) + krb5_const krb5_cksumtype cktype; +{ + return (krb5_cksumarray[cktype]->uses_key); +} + +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV +krb5_use_enctype(context, eblock, enctype) + krb5_context context; + krb5_encrypt_block FAR * eblock; + krb5_const krb5_enctype enctype; +{ + eblock->crypto_entry = krb5_enctype_array[(enctype)]->system; + return 0; +} + +KRB5_DLLIMP size_t KRB5_CALLCONV +krb5_checksum_size(context, cktype) + krb5_context context; + krb5_const krb5_cksumtype cktype; +{ + return krb5_cksumarray[cktype]->checksum_length; +} + +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV +krb5_calculate_checksum(context, cktype, in, in_length, seed, seed_length, outcksum) + krb5_context context; + krb5_const krb5_cksumtype cktype; + krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer seed; + krb5_const size_t seed_length; + krb5_checksum FAR *outcksum; +{ + return krb5_x(((*krb5_cksumarray[cktype]->sum_func)), + (in, in_length, seed, seed_length, outcksum)); +} + +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV +krb5_verify_checksum(context, cktype, cksum, in, in_length, seed, seed_length) + krb5_context context; + krb5_const krb5_cksumtype cktype; + krb5_const krb5_checksum FAR *cksum; + krb5_const krb5_pointer in; + krb5_const size_t in_length; + krb5_const krb5_pointer seed; + krb5_const size_t seed_length; +{ + return krb5_x((*krb5_cksumarray[cktype]->sum_verf_func), + (cksum, in, in_length, seed, seed_length)); +} + +KRB5_DLLIMP krb5_enctype KRB5_CALLCONV +krb5_eblock_enctype(context, eblock) + krb5_context context; + krb5_const krb5_encrypt_block FAR * eblock; +{ + return eblock->crypto_entry->proto_enctype; +} + +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV +krb5_encrypt(context, inptr, outptr, size, eblock, ivec) + krb5_context context; + krb5_const krb5_pointer inptr; + krb5_pointer outptr; + krb5_const size_t size; + krb5_encrypt_block FAR * eblock; + krb5_pointer ivec; +{ + return krb5_x(eblock->crypto_entry->encrypt_func, + (inptr, outptr, size, eblock, ivec)); +} + + +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV +krb5_decrypt(context, inptr, outptr, size, eblock, ivec) + krb5_context context; + krb5_const krb5_pointer inptr; + krb5_pointer outptr; + krb5_const size_t size; + krb5_encrypt_block FAR * eblock; + krb5_pointer ivec; +{ + return krb5_x(eblock->crypto_entry->decrypt_func, + (inptr, outptr, size, eblock, ivec)); +} + + +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV +krb5_process_key(context, eblock, key) + krb5_context context; + krb5_encrypt_block FAR * eblock; + krb5_const krb5_keyblock FAR * key; +{ + return krb5_x(eblock->crypto_entry->process_key, + (eblock, key)); +} + +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV +krb5_finish_key(context, eblock) + krb5_context context; + krb5_encrypt_block FAR * eblock; +{ + return krb5_x(eblock->crypto_entry->finish_key,(eblock)); +} + + +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV +krb5_string_to_key(context, eblock, keyblock, data, princ) + krb5_context context; + krb5_const krb5_encrypt_block FAR * eblock; + krb5_keyblock FAR * keyblock; + krb5_const krb5_data FAR * data; + krb5_const krb5_data FAR * princ; +{ + return krb5_x(eblock->crypto_entry->string_to_key, + (eblock, keyblock, data, princ)); +} + + +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV +krb5_init_random_key(context, eblock, keyblock, ptr) + krb5_context context; + krb5_const krb5_encrypt_block FAR * eblock; + krb5_const krb5_keyblock FAR * keyblock; + krb5_pointer FAR * ptr; +{ + return krb5_x(eblock->crypto_entry->init_random_key, + (eblock, keyblock, ptr)); +} + + +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV +krb5_finish_random_key(context, eblock, ptr) + krb5_context context; + krb5_const krb5_encrypt_block FAR * eblock; + krb5_pointer FAR * ptr; +{ + return krb5_x(eblock->crypto_entry->finish_random_key, + (eblock, ptr)); +} + + +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV +krb5_random_key(context, eblock, ptr, keyblock) + krb5_context context; + krb5_const krb5_encrypt_block FAR * eblock; + krb5_pointer ptr; + krb5_keyblock FAR * FAR * keyblock; +{ + return krb5_x(eblock->crypto_entry->random_key, + (eblock, ptr, keyblock)); +} + + diff --git a/src/lib/krb5/krb/decrypt_tk.c b/src/lib/krb5/krb/decrypt_tk.c index f8850b178..354a3f2a0 100644 --- a/src/lib/krb5/krb/decrypt_tk.c +++ b/src/lib/krb5/krb/decrypt_tk.c @@ -35,11 +35,11 @@ */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_decrypt_tkt_part(context, srv_key, ticket) krb5_context context; - const krb5_keyblock *srv_key; - register krb5_ticket *ticket; + const krb5_keyblock FAR *srv_key; + register krb5_ticket FAR *ticket; { krb5_enc_tkt_part *dec_tkt_part; krb5_encrypt_block eblock; diff --git a/src/lib/krb5/krb/encrypt_tk.c b/src/lib/krb5/krb/encrypt_tk.c index 6203b7836..cb1fb28b9 100644 --- a/src/lib/krb5/krb/encrypt_tk.c +++ b/src/lib/krb5/krb/encrypt_tk.c @@ -57,7 +57,7 @@ krb5_encrypt_tkt_part(context, srv_key, dec_ticket) #define cleanup_scratch() { (void) memset(scratch->data, 0, scratch->length); \ krb5_free_data(context, scratch); } - krb5_use_enctype(kdc_context, &eblock, srv_key->enctype); + krb5_use_enctype(context, &eblock, srv_key->enctype); dec_ticket->enc_part.ciphertext.length = krb5_encrypt_size(scratch->length, eblock.crypto_entry); diff --git a/src/lib/krb5/krb/fwd_tgt.c b/src/lib/krb5/krb/fwd_tgt.c index 6e10ad2ee..ed95b75fd 100644 --- a/src/lib/krb5/krb/fwd_tgt.c +++ b/src/lib/krb5/krb/fwd_tgt.c @@ -29,17 +29,17 @@ #define flags2options(flags) (flags & KDC_TKT_COMMON_MASK) /* Get a TGT for use at the remote host */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_fwd_tgt_creds(context, auth_context, rhost, client, server, cc, forwardable, outbuf) krb5_context context; krb5_auth_context auth_context; - char *rhost; + char FAR *rhost; krb5_principal client; krb5_principal server; krb5_ccache cc; int forwardable; /* Should forwarded TGT also be forwardable? */ - krb5_data *outbuf; + krb5_data FAR *outbuf; { krb5_replay_data replaydata; krb5_data * scratch = 0; @@ -143,6 +143,3 @@ errout: krb5_free_cred_contents(context, &tgt); return retval; } - - - diff --git a/src/lib/krb5/krb/gc_via_tkt.c b/src/lib/krb5/krb/gc_via_tkt.c index 0ee919770..2ea4fc815 100644 --- a/src/lib/krb5/krb/gc_via_tkt.c +++ b/src/lib/krb5/krb/gc_via_tkt.c @@ -98,7 +98,7 @@ cleanup: return retval; } -krb5_error_code INTERFACE +krb5_error_code krb5_get_cred_via_tkt (context, tkt, kdcoptions, address, in_cred, out_cred) krb5_context context; krb5_creds * tkt; diff --git a/src/lib/krb5/krb/get_creds.c b/src/lib/krb5/krb/get_creds.c index 4ff62f174..3e2885d66 100644 --- a/src/lib/krb5/krb/get_creds.c +++ b/src/lib/krb5/krb/get_creds.c @@ -87,13 +87,13 @@ krb5_get_credentials_core(context, options, ccache, in_creds, out_creds, return 0; } -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_get_credentials(context, options, ccache, in_creds, out_creds) krb5_context context; const krb5_flags options; krb5_ccache ccache; - krb5_creds *in_creds; - krb5_creds **out_creds; + krb5_creds FAR *in_creds; + krb5_creds FAR * FAR *out_creds; { krb5_error_code retval; krb5_creds mcreds; @@ -195,7 +195,7 @@ krb5_get_credentials_val_renew_core(context, options, ccache, return retval; } -krb5_error_code INTERFACE +krb5_error_code krb5_get_credentials_validate(context, options, ccache, in_creds, out_creds) krb5_context context; const krb5_flags options; @@ -208,7 +208,7 @@ krb5_get_credentials_validate(context, options, ccache, in_creds, out_creds) INT_GC_VALIDATE)); } -krb5_error_code INTERFACE +krb5_error_code krb5_get_credentials_renew(context, options, ccache, in_creds, out_creds) krb5_context context; const krb5_flags options; diff --git a/src/lib/krb5/krb/get_in_tkt.c b/src/lib/krb5/krb/get_in_tkt.c index 048a56ca8..8d42b2de8 100644 --- a/src/lib/krb5/krb/get_in_tkt.c +++ b/src/lib/krb5/krb/get_in_tkt.c @@ -361,21 +361,21 @@ make_preauth_list(context, ptypes, ret_list) #define MAX_IN_TKT_LOOPS 16 -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_get_in_tkt(context, options, addrs, ktypes, ptypes, key_proc, keyseed, decrypt_proc, decryptarg, creds, ccache, ret_as_reply) krb5_context context; const krb5_flags options; - krb5_address * const * addrs; - krb5_enctype * ktypes; - krb5_preauthtype * ptypes; + krb5_address FAR * const FAR * addrs; + krb5_enctype FAR * ktypes; + krb5_preauthtype FAR * ptypes; git_key_proc key_proc; krb5_const_pointer keyseed; git_decrypt_proc decrypt_proc; krb5_const_pointer decryptarg; - krb5_creds * creds; + krb5_creds FAR * creds; krb5_ccache ccache; - krb5_kdc_rep ** ret_as_reply; + krb5_kdc_rep FAR * FAR * ret_as_reply; { krb5_error_code retval; krb5_timestamp time_now; diff --git a/src/lib/krb5/krb/in_tkt_ktb.c b/src/lib/krb5/krb/in_tkt_ktb.c index 257ecce0f..0c901c1b9 100644 --- a/src/lib/krb5/krb/in_tkt_ktb.c +++ b/src/lib/krb5/krb/in_tkt_ktb.c @@ -105,18 +105,18 @@ cleanup: returns system errors, encryption errors */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_get_in_tkt_with_keytab(context, options, addrs, ktypes, pre_auth_types, keytab, ccache, creds, ret_as_reply) krb5_context context; const krb5_flags options; - krb5_address * const * addrs; - krb5_enctype * ktypes; - krb5_preauthtype * pre_auth_types; + krb5_address FAR * const FAR * addrs; + krb5_enctype FAR * ktypes; + krb5_preauthtype FAR * pre_auth_types; const krb5_keytab keytab; krb5_ccache ccache; - krb5_creds * creds; - krb5_kdc_rep ** ret_as_reply; + krb5_creds FAR * creds; + krb5_kdc_rep FAR *FAR * ret_as_reply; { struct keytab_keyproc_arg arg; diff --git a/src/lib/krb5/krb/in_tkt_pwd.c b/src/lib/krb5/krb/in_tkt_pwd.c index 52ef240b9..7373f62f1 100644 --- a/src/lib/krb5/krb/in_tkt_pwd.c +++ b/src/lib/krb5/krb/in_tkt_pwd.c @@ -97,18 +97,18 @@ pwd_keyproc(context, type, salt, keyseed, key) returns system errors, encryption errors */ -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_get_in_tkt_with_password(context, options, addrs, ktypes, pre_auth_types, password, ccache, creds, ret_as_reply) krb5_context context; const krb5_flags options; - krb5_address * const * addrs; - krb5_enctype * ktypes; - krb5_preauthtype * pre_auth_types; - const char * password; + krb5_address FAR * const FAR * addrs; + krb5_enctype FAR * ktypes; + krb5_preauthtype FAR * pre_auth_types; + const char FAR * password; krb5_ccache ccache; - krb5_creds * creds; - krb5_kdc_rep ** ret_as_reply; + krb5_creds FAR * creds; + krb5_kdc_rep FAR * FAR * ret_as_reply; { krb5_error_code retval; krb5_data data; diff --git a/src/lib/krb5/krb/in_tkt_sky.c b/src/lib/krb5/krb/in_tkt_sky.c index 9e4bea0dc..3c7a0cd32 100644 --- a/src/lib/krb5/krb/in_tkt_sky.c +++ b/src/lib/krb5/krb/in_tkt_sky.c @@ -94,18 +94,18 @@ skey_keyproc(context, type, salt, keyseed, key) returns system errors, encryption errors */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_get_in_tkt_with_skey(context, options, addrs, ktypes, pre_auth_types, key, ccache, creds, ret_as_reply) krb5_context context; const krb5_flags options; - krb5_address * const * addrs; - krb5_enctype * ktypes; - krb5_preauthtype * pre_auth_types; - const krb5_keyblock * key; + krb5_address FAR * const FAR * addrs; + krb5_enctype FAR * ktypes; + krb5_preauthtype FAR * pre_auth_types; + const krb5_keyblock FAR * key; krb5_ccache ccache; - krb5_creds * creds; - krb5_kdc_rep ** ret_as_reply; + krb5_creds FAR * creds; + krb5_kdc_rep FAR * FAR * ret_as_reply; { if (key) diff --git a/src/lib/krb5/krb/init_ctx.c b/src/lib/krb5/krb/init_ctx.c index 9daa7f8d1..fe725af54 100644 --- a/src/lib/krb5/krb/init_ctx.c +++ b/src/lib/krb5/krb/init_ctx.c @@ -31,7 +31,7 @@ extern krb5_error_code krb5_vercheck(); #endif -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_init_context(context) krb5_context *context; { @@ -139,7 +139,7 @@ cleanup: return retval; } -void +KRB5_DLLIMP void KRB5_CALLCONV krb5_free_context(ctx) krb5_context ctx; { diff --git a/src/lib/krb5/krb/mk_cred.c b/src/lib/krb5/krb/mk_cred.c index 11c6a1d3e..7640e7a28 100644 --- a/src/lib/krb5/krb/mk_cred.c +++ b/src/lib/krb5/krb/mk_cred.c @@ -198,14 +198,14 @@ cleanup: * This functions takes as input an array of krb5_credentials, and * outputs an encoded KRB_CRED message suitable for krb5_rd_cred */ -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_mk_ncred(context, auth_context, ppcreds, ppdata, outdata) krb5_context context; krb5_auth_context auth_context; - krb5_creds ** ppcreds; - krb5_data ** ppdata; - krb5_replay_data * outdata; + krb5_creds FAR * FAR * ppcreds; + krb5_data FAR * FAR * ppdata; + krb5_replay_data FAR * outdata; { krb5_address * premote_fulladdr = NULL; krb5_address * plocal_fulladdr = NULL; @@ -346,13 +346,13 @@ error: /* * A convenience function that calls krb5_mk_ncred. */ -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_mk_1cred(context, auth_context, pcreds, ppdata, outdata) krb5_context context; krb5_auth_context auth_context; - krb5_creds * pcreds; - krb5_data ** ppdata; - krb5_replay_data * outdata; + krb5_creds FAR * pcreds; + krb5_data FAR * FAR * ppdata; + krb5_replay_data FAR * outdata; { krb5_error_code retval; krb5_creds **ppcreds; diff --git a/src/lib/krb5/krb/mk_error.c b/src/lib/krb5/krb/mk_error.c index 292ffeaeb..77e502fde 100644 --- a/src/lib/krb5/krb/mk_error.c +++ b/src/lib/krb5/krb/mk_error.c @@ -34,11 +34,11 @@ returns system errors */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_mk_error(context, dec_err, enc_err) krb5_context context; - const krb5_error *dec_err; - krb5_data *enc_err; + const krb5_error FAR *dec_err; + krb5_data FAR *enc_err; { krb5_error_code retval; krb5_data *new_enc_err; diff --git a/src/lib/krb5/krb/mk_priv.c b/src/lib/krb5/krb/mk_priv.c index dabfd8dc9..7986e1856 100644 --- a/src/lib/krb5/krb/mk_priv.c +++ b/src/lib/krb5/krb/mk_priv.c @@ -133,13 +133,13 @@ clean_scratch: } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_mk_priv(context, auth_context, userdata, outbuf, outdata) krb5_context context; krb5_auth_context auth_context; - const krb5_data * userdata; - krb5_data * outbuf; - krb5_replay_data * outdata; + const krb5_data FAR * userdata; + krb5_data FAR * outbuf; + krb5_replay_data FAR * outdata; { krb5_error_code retval; krb5_keyblock * keyblock; diff --git a/src/lib/krb5/krb/mk_rep.c b/src/lib/krb5/krb/mk_rep.c index b1c17b6b9..45784284c 100644 --- a/src/lib/krb5/krb/mk_rep.c +++ b/src/lib/krb5/krb/mk_rep.c @@ -36,11 +36,11 @@ returns system errors */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_mk_rep(context, auth_context, outbuf) krb5_context context; krb5_auth_context auth_context; - krb5_data * outbuf; + krb5_data FAR * outbuf; { krb5_error_code retval; krb5_enctype enctype; diff --git a/src/lib/krb5/krb/mk_req.c b/src/lib/krb5/krb/mk_req.c index e793b9592..a454a5759 100644 --- a/src/lib/krb5/krb/mk_req.c +++ b/src/lib/krb5/krb/mk_req.c @@ -46,17 +46,17 @@ returns system errors */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_mk_req(context, auth_context, ap_req_options, service, hostname, in_data, ccache, outbuf) krb5_context context; - krb5_auth_context * auth_context; + krb5_auth_context FAR * auth_context; const krb5_flags ap_req_options; - char * service; - char * hostname; - krb5_data * in_data; + char FAR * service; + char FAR * hostname; + krb5_data FAR * in_data; krb5_ccache ccache; - krb5_data * outbuf; + krb5_data FAR * outbuf; { krb5_error_code retval; krb5_principal server; diff --git a/src/lib/krb5/krb/mk_req_ext.c b/src/lib/krb5/krb/mk_req_ext.c index 733dd319c..3bec52e51 100644 --- a/src/lib/krb5/krb/mk_req_ext.c +++ b/src/lib/krb5/krb/mk_req_ext.c @@ -67,15 +67,15 @@ krb5_generate_authenticator PROTOTYPE((krb5_context, const krb5_checksum *, krb5_keyblock *, krb5_int32, krb5_authdata ** )); -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_mk_req_extended(context, auth_context, ap_req_options, in_data, in_creds, outbuf) krb5_context context; - krb5_auth_context * auth_context; + krb5_auth_context FAR * auth_context; const krb5_flags ap_req_options; - krb5_data * in_data; - krb5_creds * in_creds; - krb5_data * outbuf; + krb5_data FAR * in_data; + krb5_creds FAR * in_creds; + krb5_data FAR * outbuf; { krb5_error_code retval; krb5_checksum checksum; diff --git a/src/lib/krb5/krb/mk_safe.c b/src/lib/krb5/krb/mk_safe.c index dfa253a4e..1a44a75e5 100644 --- a/src/lib/krb5/krb/mk_safe.c +++ b/src/lib/krb5/krb/mk_safe.c @@ -119,13 +119,13 @@ cleanup_scratch: return retval; } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_mk_safe(context, auth_context, userdata, outbuf, outdata) krb5_context context; krb5_auth_context auth_context; - const krb5_data * userdata; - krb5_data * outbuf; - krb5_replay_data * outdata; + const krb5_data FAR * userdata; + krb5_data FAR * outbuf; + krb5_replay_data FAR * outdata; { krb5_error_code retval; krb5_keyblock * keyblock; diff --git a/src/lib/krb5/krb/parse.c b/src/lib/krb5/krb/parse.c index 0b41a201a..3b2305f19 100644 --- a/src/lib/krb5/krb/parse.c +++ b/src/lib/krb5/krb/parse.c @@ -60,11 +60,11 @@ * May the fleas of a thousand camels infest the ISO, they who think * that arbitrarily large multi-component names are a Good Thing..... */ -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_parse_name(context, name, nprincipal) krb5_context context; - const char *name; - krb5_principal *nprincipal; + const char FAR *name; + krb5_principal FAR *nprincipal; { register const char *cp; register char *q; diff --git a/src/lib/krb5/krb/princ_comp.c b/src/lib/krb5/krb/princ_comp.c index 35c5847c6..635d22cc3 100644 --- a/src/lib/krb5/krb/princ_comp.c +++ b/src/lib/krb5/krb/princ_comp.c @@ -43,7 +43,7 @@ krb5_realm_compare(context, princ1, princ2) return TRUE; } -krb5_boolean +KRB5_DLLIMP krb5_boolean KRB5_CALLCONV krb5_principal_compare(context, princ1, princ2) krb5_context context; krb5_const_principal princ1; diff --git a/src/lib/krb5/krb/rd_cred.c b/src/lib/krb5/krb/rd_cred.c index 874960bf5..05eb7d746 100644 --- a/src/lib/krb5/krb/rd_cred.c +++ b/src/lib/krb5/krb/rd_cred.c @@ -225,13 +225,13 @@ cleanup_cred: * This functions takes as input an KRB_CRED message, validates it, and * outputs the nonce and an array of the forwarded credentials. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_rd_cred(context, auth_context, pcreddata, pppcreds, outdata) krb5_context context; krb5_auth_context auth_context; - krb5_data * pcreddata; - krb5_creds *** pppcreds; - krb5_replay_data * outdata; + krb5_data FAR * pcreddata; + krb5_creds FAR * FAR * FAR * pppcreds; + krb5_replay_data FAR * outdata; { krb5_error_code retval; krb5_keyblock * keyblock; diff --git a/src/lib/krb5/krb/rd_error.c b/src/lib/krb5/krb/rd_error.c index bf0753927..7f8e4226e 100644 --- a/src/lib/krb5/krb/rd_error.c +++ b/src/lib/krb5/krb/rd_error.c @@ -36,11 +36,11 @@ * returns system errors */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_rd_error(context, enc_errbuf, dec_error) krb5_context context; - const krb5_data *enc_errbuf; - krb5_error **dec_error; + const krb5_data FAR *enc_errbuf; + krb5_error FAR * FAR *dec_error; { if (!krb5_is_krb_error(enc_errbuf)) return KRB5KRB_AP_ERR_MSG_TYPE; diff --git a/src/lib/krb5/krb/rd_priv.c b/src/lib/krb5/krb/rd_priv.c index 7acb6f3f8..e6c0fe361 100644 --- a/src/lib/krb5/krb/rd_priv.c +++ b/src/lib/krb5/krb/rd_priv.c @@ -170,13 +170,13 @@ cleanup_privmsg:; return retval; } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_rd_priv(context, auth_context, inbuf, outbuf, outdata) krb5_context context; krb5_auth_context auth_context; - const krb5_data * inbuf; - krb5_data * outbuf; - krb5_replay_data * outdata; + const krb5_data FAR * inbuf; + krb5_data FAR * outbuf; + krb5_replay_data FAR * outdata; { krb5_error_code retval; krb5_keyblock * keyblock; diff --git a/src/lib/krb5/krb/rd_rep.c b/src/lib/krb5/krb/rd_rep.c index 13e8363ee..d4d559d14 100644 --- a/src/lib/krb5/krb/rd_rep.c +++ b/src/lib/krb5/krb/rd_rep.c @@ -38,12 +38,12 @@ * returns system errors, encryption errors, replay errors */ -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_rd_rep(context, auth_context, inbuf, repl) krb5_context context; krb5_auth_context auth_context; - const krb5_data * inbuf; - krb5_ap_rep_enc_part **repl; + const krb5_data FAR * inbuf; + krb5_ap_rep_enc_part FAR * FAR *repl; { krb5_error_code retval; krb5_ap_rep * reply; diff --git a/src/lib/krb5/krb/rd_req.c b/src/lib/krb5/krb/rd_req.c index e46b3bd91..7fbe1727c 100644 --- a/src/lib/krb5/krb/rd_req.c +++ b/src/lib/krb5/krb/rd_req.c @@ -42,16 +42,16 @@ * returns system errors, encryption errors, replay errors */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_rd_req(context, auth_context, inbuf, server, keytab, ap_req_options, ticket) krb5_context context; - krb5_auth_context * auth_context; - const krb5_data * inbuf; + krb5_auth_context FAR * auth_context; + const krb5_data FAR * inbuf; krb5_const_principal server; /* XXX do we really need this */ krb5_keytab keytab; - krb5_flags * ap_req_options; - krb5_ticket ** ticket; + krb5_flags FAR * ap_req_options; + krb5_ticket FAR *FAR * ticket; { krb5_error_code retval; krb5_ap_req * request; diff --git a/src/lib/krb5/krb/rd_safe.c b/src/lib/krb5/krb/rd_safe.c index 7298605c0..9f23ff383 100644 --- a/src/lib/krb5/krb/rd_safe.c +++ b/src/lib/krb5/krb/rd_safe.c @@ -147,13 +147,13 @@ cleanup: return retval; } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_rd_safe(context, auth_context, inbuf, outbuf, outdata) krb5_context context; krb5_auth_context auth_context; - const krb5_data * inbuf; - krb5_data * outbuf; - krb5_replay_data * outdata; + const krb5_data FAR * inbuf; + krb5_data FAR * outbuf; + krb5_replay_data FAR * outdata; { krb5_error_code retval; krb5_keyblock * keyblock; diff --git a/src/lib/krb5/krb/recvauth.c b/src/lib/krb5/krb/recvauth.c index d5e7b5fc5..5bde73aa4 100644 --- a/src/lib/krb5/krb/recvauth.c +++ b/src/lib/krb5/krb/recvauth.c @@ -34,20 +34,20 @@ static char *sendauth_version = "KRB5_SENDAUTH_V1.0"; -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_recvauth(context, auth_context, /* IN */ fd, appl_version, server, flags, keytab, /* OUT */ ticket) krb5_context context; - krb5_auth_context * auth_context; + krb5_auth_context FAR * auth_context; krb5_pointer fd; - char * appl_version; + char FAR * appl_version; krb5_principal server; krb5_int32 flags; krb5_keytab keytab; - krb5_ticket ** ticket; + krb5_ticket FAR * FAR * ticket; { krb5_auth_context new_auth_context; krb5_flags ap_option; diff --git a/src/lib/krb5/krb/sendauth.c b/src/lib/krb5/krb/sendauth.c index d77afdc9b..54a9ac000 100644 --- a/src/lib/krb5/krb/sendauth.c +++ b/src/lib/krb5/krb/sendauth.c @@ -35,7 +35,7 @@ static char *sendauth_version = "KRB5_SENDAUTH_V1.0"; -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_sendauth(context, auth_context, /* IN */ fd, appl_version, client, server, ap_req_options, in_data, @@ -45,18 +45,18 @@ krb5_sendauth(context, auth_context, /* OUT */ error, rep_result, out_creds) krb5_context context; - krb5_auth_context * auth_context; + krb5_auth_context FAR * auth_context; krb5_pointer fd; - char * appl_version; + char FAR * appl_version; krb5_principal client; krb5_principal server; krb5_flags ap_req_options; - krb5_data * in_data; - krb5_creds * in_creds; + krb5_data FAR * in_data; + krb5_creds FAR * in_creds; krb5_ccache ccache; - krb5_error ** error; - krb5_ap_rep_enc_part ** rep_result; - krb5_creds ** out_creds; + krb5_error FAR * FAR * error; + krb5_ap_rep_enc_part FAR * FAR * rep_result; + krb5_creds FAR * FAR * out_creds; { krb5_octet result; krb5_creds creds; diff --git a/src/lib/krb5/krb/ser_actx.c b/src/lib/krb5/krb/ser_actx.c index 8be618a89..5705b711f 100644 --- a/src/lib/krb5/krb/ser_actx.c +++ b/src/lib/krb5/krb/ser_actx.c @@ -541,7 +541,7 @@ krb5_auth_context_internalize(kcontext, argp, buffer, lenremain) /* * Register the auth_context serializer. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_ser_auth_context_init(kcontext) krb5_context kcontext; { diff --git a/src/lib/krb5/krb/ser_ctx.c b/src/lib/krb5/krb/ser_ctx.c index 2bdb1ad71..13392a738 100644 --- a/src/lib/krb5/krb/ser_ctx.c +++ b/src/lib/krb5/krb/ser_ctx.c @@ -633,7 +633,7 @@ krb5_oscontext_internalize(kcontext, argp, buffer, lenremain) /* * Register the context serializers. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_ser_context_init(kcontext) krb5_context kcontext; { diff --git a/src/lib/krb5/krb/serialize.c b/src/lib/krb5/krb/serialize.c index 392caf4da..084ecb677 100644 --- a/src/lib/krb5/krb/serialize.c +++ b/src/lib/krb5/krb/serialize.c @@ -91,7 +91,7 @@ krb5_register_serializer(kcontext, entry) * krb5_size_opaque() - Determine the size necessary to serialize a given * piece of opaque data. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_size_opaque(kcontext, odtype, arg, sizep) krb5_context kcontext; krb5_magic odtype; @@ -111,13 +111,13 @@ krb5_size_opaque(kcontext, odtype, arg, sizep) /* * krb5_externalize_opaque() - Externalize a piece of opaque data. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_externalize_opaque(kcontext, odtype, arg, bufpp, sizep) krb5_context kcontext; krb5_magic odtype; krb5_pointer arg; - krb5_octet **bufpp; - size_t *sizep; + krb5_octet FAR * FAR *bufpp; + size_t FAR *sizep; { krb5_error_code kret; krb5_ser_handle shandle; @@ -172,13 +172,13 @@ krb5_externalize_data(kcontext, arg, bufpp, sizep) * krb5_internalize_opaque() - Convert external representation into a data * structure. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_internalize_opaque(kcontext, odtype, argp, bufpp, sizep) krb5_context kcontext; krb5_magic odtype; - krb5_pointer *argp; - krb5_octet **bufpp; - size_t *sizep; + krb5_pointer FAR *argp; + krb5_octet FAR * FAR *bufpp; + size_t FAR *sizep; { krb5_error_code kret; krb5_ser_handle shandle; @@ -195,11 +195,11 @@ krb5_internalize_opaque(kcontext, odtype, argp, bufpp, sizep) * krb5_ser_pack_int32() - Pack a 4-byte integer if space is availble. * Update buffer pointer and remaining space. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_ser_pack_int32(iarg, bufp, remainp) krb5_int32 iarg; - krb5_octet **bufp; - size_t *remainp; + krb5_octet FAR * FAR *bufp; + size_t FAR *remainp; { if (*remainp >= sizeof(krb5_int32)) { (*bufp)[0] = (krb5_octet) ((iarg >> 24) & 0xff); @@ -217,12 +217,12 @@ krb5_ser_pack_int32(iarg, bufp, remainp) /* * krb5_ser_pack_bytes() - Pack a string of bytes. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_ser_pack_bytes(ostring, osize, bufp, remainp) - krb5_octet *ostring; + krb5_octet FAR *ostring; size_t osize; - krb5_octet **bufp; - size_t *remainp; + krb5_octet FAR * FAR *bufp; + size_t FAR *remainp; { if (*remainp >= osize) { memcpy(*bufp, ostring, osize); @@ -237,11 +237,11 @@ krb5_ser_pack_bytes(ostring, osize, bufp, remainp) /* * krb5_ser_unpack_int32() - Unpack a 4-byte integer if it's there. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_ser_unpack_int32(intp, bufp, remainp) - krb5_int32 *intp; - krb5_octet **bufp; - size_t *remainp; + krb5_int32 FAR *intp; + krb5_octet FAR * FAR *bufp; + size_t FAR *remainp; { if (*remainp >= sizeof(krb5_int32)) { *intp = (((krb5_int32) ((unsigned char) (*bufp)[0]) << 24) | @@ -259,12 +259,12 @@ krb5_ser_unpack_int32(intp, bufp, remainp) /* * krb5_ser_unpack_bytes() - Unpack a byte string if it's there. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_ser_unpack_bytes(istring, isize, bufp, remainp) - krb5_octet *istring; + krb5_octet FAR *istring; size_t isize; - krb5_octet **bufp; - size_t *remainp; + krb5_octet FAR * FAR *bufp; + size_t FAR *remainp; { if (*remainp >= isize) { memcpy(istring, *bufp, isize); diff --git a/src/lib/krb5/krb/str_conv.c b/src/lib/krb5/krb/str_conv.c index 76a79a86b..d8b2e6d94 100644 --- a/src/lib/krb5/krb/str_conv.c +++ b/src/lib/krb5/krb/str_conv.c @@ -367,10 +367,10 @@ strptime(buf, format, tm) * * These routines return 0 for success, EINVAL for invalid entry. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_string_to_enctype(string, enctypep) - char * string; - krb5_enctype * enctypep; + char FAR * string; + krb5_enctype FAR * enctypep; { int i; int found; @@ -386,10 +386,10 @@ krb5_string_to_enctype(string, enctypep) return((found) ? 0 : EINVAL); } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_string_to_salttype(string, salttypep) - char * string; - krb5_int32 * salttypep; + char FAR * string; + krb5_int32 FAR * salttypep; { int i; int found; @@ -405,10 +405,10 @@ krb5_string_to_salttype(string, salttypep) return((found) ? 0 : EINVAL); } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_string_to_cksumtype(string, cksumtypep) - char * string; - krb5_cksumtype * cksumtypep; + char FAR * string; + krb5_cksumtype FAR * cksumtypep; { int i; int found; @@ -424,10 +424,10 @@ krb5_string_to_cksumtype(string, cksumtypep) return((found) ? 0 : EINVAL); } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_string_to_timestamp(string, timestampp) - char * string; - krb5_timestamp * timestampp; + char FAR * string; + krb5_timestamp FAR * timestampp; { int i; int found; @@ -454,10 +454,10 @@ krb5_string_to_timestamp(string, timestampp) return((found) ? 0 : EINVAL); } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_string_to_deltat(string, deltatp) - char * string; - krb5_deltat * deltatp; + char FAR * string; + krb5_deltat FAR * deltatp; { int i; int found; @@ -502,10 +502,10 @@ krb5_string_to_deltat(string, deltatp) * These routines return 0 for success, EINVAL for invalid parameter, ENOMEM * if the supplied buffer/length will not contain the output. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_enctype_to_string(enctype, buffer, buflen) krb5_enctype enctype; - char * buffer; + char FAR * buffer; size_t buflen; { int i; @@ -529,10 +529,10 @@ krb5_enctype_to_string(enctype, buffer, buflen) return(EINVAL); } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_salttype_to_string(salttype, buffer, buflen) krb5_int32 salttype; - char * buffer; + char FAR * buffer; size_t buflen; { int i; @@ -556,10 +556,10 @@ krb5_salttype_to_string(salttype, buffer, buflen) return(EINVAL); } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_cksumtype_to_string(cksumtype, buffer, buflen) krb5_cksumtype cksumtype; - char * buffer; + char FAR * buffer; size_t buflen; { int i; @@ -583,10 +583,10 @@ krb5_cksumtype_to_string(cksumtype, buffer, buflen) return(EINVAL); } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_timestamp_to_string(timestamp, buffer, buflen) krb5_timestamp timestamp; - char * buffer; + char FAR * buffer; size_t buflen; { #if HAVE_STRFTIME @@ -605,12 +605,12 @@ krb5_timestamp_to_string(timestamp, buffer, buflen) #endif /* HAVE_STRFTIME */ } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_timestamp_to_sfstring(timestamp, buffer, buflen, pad) krb5_timestamp timestamp; - char * buffer; + char FAR * buffer; size_t buflen; - char * pad; + char FAR * pad; { struct tm *tmp; size_t i; @@ -640,10 +640,10 @@ krb5_timestamp_to_sfstring(timestamp, buffer, buflen, pad) return((ndone) ? 0 : ENOMEM); } -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_deltat_to_string(deltat, buffer, buflen) krb5_deltat deltat; - char * buffer; + char FAR * buffer; size_t buflen; { int days, hours, minutes, seconds; diff --git a/src/lib/krb5/krb/unparse.c b/src/lib/krb5/krb/unparse.c index 7247d9a44..1f0c79110 100644 --- a/src/lib/krb5/krb/unparse.c +++ b/src/lib/krb5/krb/unparse.c @@ -54,12 +54,12 @@ #define REALM_SEP '@' #define COMPONENT_SEP '/' -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_unparse_name_ext(context, principal, name, size) krb5_context context; krb5_const_principal principal; - register char **name; - int *size; + register char FAR * FAR *name; + int FAR *size; { register char *cp, *q; register int i,j; @@ -185,7 +185,7 @@ krb5_unparse_name_ext(context, principal, name, size) return 0; } -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_unparse_name(context, principal, name) krb5_context context; krb5_const_principal principal; diff --git a/src/lib/krb5/krb/valid_times.c b/src/lib/krb5/krb/valid_times.c index b1e26ced7..ed377d16b 100644 --- a/src/lib/krb5/krb/valid_times.c +++ b/src/lib/krb5/krb/valid_times.c @@ -33,7 +33,8 @@ * field in a krb5_ticket. */ -krb5_error_code krb5_validate_times(context, times) +krb5_error_code +krb5_validate_times(context, times) krb5_context context; krb5_ticket_times * times; { diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index a1d63cf2d..bd9bb29cb 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,3 +1,13 @@ +Thu Nov 21 11:55:16 EST 1996 Richard Basch + + * Makefile.in: win32 build + + * ccdefname.c, def_realm.c, free_hstrl.c, genaddrs.c, hst_realm.c, + init_os_ctx.c, ktdefname.c, localaddr.c, sn2princ.c, timeofday.c, + ustime.c + DLL export several more common functions (see lib/krb5.def + for the full list of functions exported) + Wed Nov 13 02:53:31 1996 Tom Yu * osconfig.c: Add warning re: global variables. diff --git a/src/lib/krb5/os/Makefile.in b/src/lib/krb5/os/Makefile.in index 72c7e0402..236ed80e8 100644 --- a/src/lib/krb5/os/Makefile.in +++ b/src/lib/krb5/os/Makefile.in @@ -2,8 +2,10 @@ CFLAGS = $(CCOPTS) $(DEFS) KRB5_RUN_ENV = @KRB5_RUN_ENV@ ##DOSBUILDTOP = ..\..\.. -##DOSLIBNAME=..\krb5.lib ##DOSDBFLAGS= +##DOSMYNAME=os +##DOSOBJFILE=..\$(MYNAME).lst +##WIN16##LIBNAME=..\krb5.lib .c.o: $(CC) $(CFLAGS) -c $(srcdir)/$*.c @@ -90,10 +92,13 @@ SRCS= \ $(srcdir)/write_msg.c all-unix:: shared $(OBJS) - all-mac:: $(OBJS) +all-windows:: $(OBJFILE) -all-windows:: $(OBJS) +##DOS$(OBJFILE): $(OBJS) +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) -p $(MYNAME)\ *.obj > $(OBJFILE) shared: mkdir shared @@ -155,4 +160,4 @@ clean-unix:: $(RM) shared/* clean-mac:: clean-windows:: - + $(RM) $(OBJFILE) diff --git a/src/lib/krb5/os/ccdefname.c b/src/lib/krb5/os/ccdefname.c index 1db1706f2..639fc666b 100644 --- a/src/lib/krb5/os/ccdefname.c +++ b/src/lib/krb5/os/ccdefname.c @@ -83,7 +83,7 @@ OSErr err; #endif -char * +KRB5_DLLIMP char FAR * KRB5_CALLCONV krb5_cc_default_name(context) krb5_context context; { diff --git a/src/lib/krb5/os/def_realm.c b/src/lib/krb5/os/def_realm.c index 053a604be..3c2e4a952 100644 --- a/src/lib/krb5/os/def_realm.c +++ b/src/lib/krb5/os/def_realm.c @@ -44,10 +44,10 @@ extern char *krb5_config_file; /* extern so can be set at load/runtime */ -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_get_default_realm(context, lrealm) krb5_context context; - char **lrealm; + char FAR * FAR *lrealm; { char *realm; char *cp; @@ -79,7 +79,7 @@ krb5_get_default_realm(context, lrealm) return(0); } -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_set_default_realm(context, lrealm) krb5_context context; const char *lrealm; diff --git a/src/lib/krb5/os/free_hstrl.c b/src/lib/krb5/os/free_hstrl.c index f112041e4..63bd3b338 100644 --- a/src/lib/krb5/os/free_hstrl.c +++ b/src/lib/krb5/os/free_hstrl.c @@ -31,10 +31,10 @@ Frees the storage taken by a realm list returned by krb5_get_local_realm. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_free_host_realm(context, realmlist) krb5_context context; - char * const *realmlist; + char FAR * const FAR *realmlist; { /* same format, so why duplicate code? */ return krb5_free_krbhst(context, realmlist); diff --git a/src/lib/krb5/os/genaddrs.c b/src/lib/krb5/os/genaddrs.c index 3260662c5..b8e677481 100644 --- a/src/lib/krb5/os/genaddrs.c +++ b/src/lib/krb5/os/genaddrs.c @@ -32,12 +32,12 @@ #include #endif -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_auth_con_genaddrs(context, auth_context, infd, flags) - krb5_context context; - krb5_auth_context auth_context; - int infd; - int flags; + krb5_context context; + krb5_auth_context auth_context; + int infd; + int flags; { krb5_error_code retval; krb5_address * laddr; diff --git a/src/lib/krb5/os/hst_realm.c b/src/lib/krb5/os/hst_realm.c index b93ed379e..6ff814abf 100644 --- a/src/lib/krb5/os/hst_realm.c +++ b/src/lib/krb5/os/hst_realm.c @@ -77,11 +77,11 @@ #define MAXHOSTNAMELEN 64 #endif -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_get_host_realm(context, host, realmsp) krb5_context context; - const char *host; - char ***realmsp; + const char FAR *host; + char FAR * FAR * FAR *realmsp; { char **retrealms; char *default_realm, *realm, *cp; diff --git a/src/lib/krb5/os/init_os_ctx.c b/src/lib/krb5/os/init_os_ctx.c index 5f8d48f5f..9b74a38f1 100644 --- a/src/lib/krb5/os/init_os_ctx.c +++ b/src/lib/krb5/os/init_os_ctx.c @@ -195,7 +195,7 @@ krb5_os_init_context(ctx) return retval; } -krb5_error_code INTERFACE +krb5_error_code krb5_set_config_files(ctx, filenames) krb5_context ctx; const char **filenames; @@ -214,7 +214,7 @@ krb5_set_config_files(ctx, filenames) return 0; } -krb5_error_code INTERFACE +krb5_error_code krb5_secure_config_files(ctx) krb5_context ctx; { diff --git a/src/lib/krb5/os/ktdefname.c b/src/lib/krb5/os/ktdefname.c index 29eb54fe2..c645635ab 100644 --- a/src/lib/krb5/os/ktdefname.c +++ b/src/lib/krb5/os/ktdefname.c @@ -30,10 +30,10 @@ extern char *krb5_defkeyname; -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_kt_default_name(context, name, namesize) krb5_context context; - char *name; + char FAR *name; int namesize; { char *cp = 0; diff --git a/src/lib/krb5/os/localaddr.c b/src/lib/krb5/os/localaddr.c index e93e45083..cb204b597 100644 --- a/src/lib/krb5/os/localaddr.c +++ b/src/lib/krb5/os/localaddr.c @@ -26,10 +26,10 @@ #include "k5-int.h" -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_os_localaddr(context, addr) krb5_context context; - krb5_address ***addr; + krb5_address FAR * FAR * FAR *addr; { return krb5_crypto_os_localaddr(addr); } diff --git a/src/lib/krb5/os/sn2princ.c b/src/lib/krb5/os/sn2princ.c index 75f52ace6..1cb133761 100644 --- a/src/lib/krb5/os/sn2princ.c +++ b/src/lib/krb5/os/sn2princ.c @@ -32,13 +32,13 @@ #include #endif -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_sname_to_principal(context, hostname, sname, type, ret_princ) krb5_context context; - const char * hostname; - const char * sname; + const char FAR * hostname; + const char FAR * sname; krb5_int32 type; - krb5_principal * ret_princ; + krb5_principal FAR * ret_princ; { struct hostent *hp; char **hrealms, *realm, *remote_host; diff --git a/src/lib/krb5/os/timeofday.c b/src/lib/krb5/os/timeofday.c index 72adc440e..131406fbb 100644 --- a/src/lib/krb5/os/timeofday.c +++ b/src/lib/krb5/os/timeofday.c @@ -39,10 +39,10 @@ extern int errno; #endif -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_timeofday(context, timeret) krb5_context context; - register krb5_int32 *timeret; + register krb5_int32 FAR *timeret; { krb5_os_context os_ctx = context->os_context; timetype tval; diff --git a/src/lib/krb5/os/ustime.c b/src/lib/krb5/os/ustime.c index ee7535324..2c8b7d4ab 100644 --- a/src/lib/krb5/os/ustime.c +++ b/src/lib/krb5/os/ustime.c @@ -30,10 +30,11 @@ #include "k5-int.h" -krb5_error_code INTERFACE +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_us_timeofday(context, seconds, microseconds) krb5_context context; - krb5_int32 *seconds, *microseconds; + krb5_int32 FAR *seconds; + krb5_int32 FAR *microseconds; { krb5_os_context os_ctx = context->os_context; krb5_int32 sec, usec; diff --git a/src/lib/krb5/posix/ChangeLog b/src/lib/krb5/posix/ChangeLog index e94ad00dc..76d7a62cf 100644 --- a/src/lib/krb5/posix/ChangeLog +++ b/src/lib/krb5/posix/ChangeLog @@ -1,3 +1,12 @@ +Tue Feb 4 15:54:11 1997 Richard Basch + + * Makefile.in: Only build sscanf for Win16 + * sscanf.c: Export sscanf in Windows DLL + +Thu Nov 21 11:55:16 EST 1996 Richard Basch + + * Makefile.in: win32 build + Mon Jun 10 21:51:35 1996 Theodore Ts'o * syslog.c: Change _WINDOWS to _MSDOS, and add check for _WIN32. diff --git a/src/lib/krb5/posix/Makefile.in b/src/lib/krb5/posix/Makefile.in index c056c0cc9..f1475edaa 100644 --- a/src/lib/krb5/posix/Makefile.in +++ b/src/lib/krb5/posix/Makefile.in @@ -1,7 +1,9 @@ CFLAGS = $(CCOPTS) $(DEFS) ##DOSBUILDTOP = ..\..\.. -##DOSLIBNAME=..\krb5.lib +##DOSMYNAME=posix +##DOSOBJFILE=..\$(MYNAME).lst +##WIN16##LIBNAME=..\krb5.lib .c.o: $(CC) $(CFLAGS) -c $(srcdir)/$*.c @@ -13,7 +15,15 @@ OBJS = setenv.$(OBJEXT) @LIBOBJS@ all-unix:: shared $(OBJS) all-mac: $(OBJS) -all-windows:: syslog.obj sscanf.obj +all-windows:: $(OBJFILE) + +##WIN16##$(OBJFILE): syslog.obj sscanf.obj +##WIN16## $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) + +##WIN32##$(OBJFILE): syslog.obj +##WIN32## $(RM) $(OBJFILE) +##WIN32## $(LIBECHO) -p $(MYNAME)\ *.obj > $(OBJFILE) shared: mkdir shared @@ -23,5 +33,5 @@ clean-unix:: clean-mac:: clean-windows:: - + $(RM) $(OBJFILE) diff --git a/src/lib/krb5/posix/sscanf.c b/src/lib/krb5/posix/sscanf.c index 3dbc415e6..9a96ff93f 100644 --- a/src/lib/krb5/posix/sscanf.c +++ b/src/lib/krb5/posix/sscanf.c @@ -49,6 +49,8 @@ #include #include +#include "k5-int.h" + #if 0 #if __STDC__ #include @@ -104,7 +106,7 @@ static u_char *__sccl(char *tab, u_char *fmt); /* * sscanf */ -int +KRB5_DLLIMP int KRB5_CALLCONV_C sscanf(char *str, char const *fmt0, ...) { va_list ap; diff --git a/src/lib/krb5/rcache/ChangeLog b/src/lib/krb5/rcache/ChangeLog index b5554fd25..1a0d6c9f0 100644 --- a/src/lib/krb5/rcache/ChangeLog +++ b/src/lib/krb5/rcache/ChangeLog @@ -1,3 +1,11 @@ +Thu Nov 21 11:55:16 EST 1996 Richard Basch + + * Makefile.in: win32 build + + * rc_dfl.c, rc_dfl.h: Win32/DLL calling conventions for rcache + functions. (Most rcache routines are still not exported + pending an API review). + Mon Nov 18 15:25:51 1996 Theodore Y. Ts'o * rc_dfl.c: Apply jik's fix to allow the expunging of the replay diff --git a/src/lib/krb5/rcache/Makefile.in b/src/lib/krb5/rcache/Makefile.in index 0225fca21..078ed1857 100644 --- a/src/lib/krb5/rcache/Makefile.in +++ b/src/lib/krb5/rcache/Makefile.in @@ -1,7 +1,9 @@ CFLAGS = $(CCOPTS) $(DEFS) ##DOSBUILDTOP = ..\..\.. -##DOSLIBNAME=..\krb5.lib +##DOSMYNAME=rcache +##DOSOBJFILE=..\$(MYNAME).lst +##WIN16##LIBNAME=..\krb5.lib .c.o: $(CC) $(CFLAGS) -c $(srcdir)/$*.c @@ -25,13 +27,18 @@ SRCS= \ all-unix:: shared $(OBJS) all-mac:: $(OBJS) -all-windows:: $(OBJS) +all-windows:: $(OBJFILE) + +##DOS$(OBJFILE): $(OBJS) +##DOS $(RM) $(OBJFILE) +##WIN16## $(CP) nul: $(OBJFILE) +##WIN32## $(LIBECHO) -p $(MYNAME)\ *.obj > $(OBJFILE) shared: mkdir shared clean-mac:: clean-windows:: - + $(RM) $(OBJFILE) clean-unix:: $(RM) shared/* diff --git a/src/lib/krb5/rcache/rc_dfl.c b/src/lib/krb5/rcache/rc_dfl.c index 9eede5323..57679f369 100644 --- a/src/lib/krb5/rcache/rc_dfl.c +++ b/src/lib/krb5/rcache/rc_dfl.c @@ -170,14 +170,16 @@ static int rc_store(context, id, rep) return CMP_HOHUM; } -char * krb5_rc_dfl_get_name(context, id) +char * KRB5_CALLCONV +krb5_rc_dfl_get_name(context, id) krb5_context context; krb5_rcache id; { return ((struct dfl_data *) (id->data))->name; } -krb5_error_code krb5_rc_dfl_get_span(context, id, lifespan) +krb5_error_code KRB5_CALLCONV +krb5_rc_dfl_get_span(context, id, lifespan) krb5_context context; krb5_rcache id; krb5_deltat *lifespan; @@ -186,7 +188,8 @@ krb5_error_code krb5_rc_dfl_get_span(context, id, lifespan) return 0; } -krb5_error_code krb5_rc_dfl_init(context, id, lifespan) +krb5_error_code KRB5_CALLCONV +krb5_rc_dfl_init(context, id, lifespan) krb5_context context; krb5_rcache id; krb5_deltat lifespan; @@ -232,7 +235,8 @@ krb5_error_code krb5_rc_dfl_close_no_free(context, id) return 0; } -krb5_error_code krb5_rc_dfl_close(context, id) +krb5_error_code KRB5_CALLCONV +krb5_rc_dfl_close(context, id) krb5_context context; krb5_rcache id; { @@ -241,7 +245,8 @@ krb5_error_code krb5_rc_dfl_close(context, id) return 0; } -krb5_error_code krb5_rc_dfl_destroy(context, id) +krb5_error_code KRB5_CALLCONV +krb5_rc_dfl_destroy(context, id) krb5_context context; krb5_rcache id; { @@ -252,7 +257,8 @@ krb5_rcache id; return krb5_rc_dfl_close(context, id); } -krb5_error_code krb5_rc_dfl_resolve(context, id, name) +krb5_error_code KRB5_CALLCONV +krb5_rc_dfl_resolve(context, id, name) krb5_context context; krb5_rcache id; char *name; @@ -385,7 +391,8 @@ errout: -krb5_error_code krb5_rc_dfl_recover(context, id) +krb5_error_code KRB5_CALLCONV +krb5_rc_dfl_recover(context, id) krb5_context context; krb5_rcache id; { @@ -497,7 +504,8 @@ krb5_rc_io_store (context, t, rep) return ret; } -krb5_error_code krb5_rc_dfl_store(context, id, rep) +krb5_error_code KRB5_CALLCONV +krb5_rc_dfl_store(context, id, rep) krb5_context context; krb5_rcache id; krb5_donot_replay *rep; @@ -533,7 +541,8 @@ krb5_donot_replay *rep; return 0; } -krb5_error_code krb5_rc_dfl_expunge(context, id) +krb5_error_code KRB5_CALLCONV +krb5_rc_dfl_expunge(context, id) krb5_context context; krb5_rcache id; { diff --git a/src/lib/krb5/rcache/rc_dfl.h b/src/lib/krb5/rcache/rc_dfl.h index 6529b6d41..aaa5e820d 100644 --- a/src/lib/krb5/rcache/rc_dfl.h +++ b/src/lib/krb5/rcache/rc_dfl.h @@ -15,34 +15,34 @@ extern krb5_rc_ops krb5_rc_dfl_ops; /* initialized to the following */ -krb5_error_code krb5_rc_dfl_init +krb5_error_code KRB5_CALLCONV krb5_rc_dfl_init PROTOTYPE((krb5_context, krb5_rcache, krb5_deltat)); -krb5_error_code krb5_rc_dfl_recover +krb5_error_code KRB5_CALLCONV krb5_rc_dfl_recover PROTOTYPE((krb5_context, krb5_rcache)); -krb5_error_code krb5_rc_dfl_destroy +krb5_error_code KRB5_CALLCONV krb5_rc_dfl_destroy PROTOTYPE((krb5_context, krb5_rcache)); -krb5_error_code krb5_rc_dfl_close +krb5_error_code KRB5_CALLCONV krb5_rc_dfl_close PROTOTYPE((krb5_context, krb5_rcache)); -krb5_error_code krb5_rc_dfl_store +krb5_error_code KRB5_CALLCONV krb5_rc_dfl_store PROTOTYPE((krb5_context, krb5_rcache, krb5_donot_replay *)); -krb5_error_code krb5_rc_dfl_expunge +krb5_error_code KRB5_CALLCONV krb5_rc_dfl_expunge PROTOTYPE((krb5_context, krb5_rcache)); -krb5_error_code krb5_rc_dfl_get_span +krb5_error_code KRB5_CALLCONV krb5_rc_dfl_get_span PROTOTYPE((krb5_context, krb5_rcache, krb5_deltat *)); -char * krb5_rc_dfl_get_name +char * KRB5_CALLCONV krb5_rc_dfl_get_name PROTOTYPE((krb5_context, krb5_rcache)); -krb5_error_code krb5_rc_dfl_resolve +krb5_error_code KRB5_CALLCONV krb5_rc_dfl_resolve PROTOTYPE((krb5_context, krb5_rcache, char *)); diff --git a/src/lib/krb5/rcache/ser_rc.c b/src/lib/krb5/rcache/ser_rc.c index 4ebfbe080..f70dfbfe3 100644 --- a/src/lib/krb5/rcache/ser_rc.c +++ b/src/lib/krb5/rcache/ser_rc.c @@ -208,7 +208,7 @@ krb5_rcache_internalize(kcontext, argp, buffer, lenremain) /* * Register the rcache serializer. */ -krb5_error_code +KRB5_DLLIMP krb5_error_code KRB5_CALLCONV krb5_ser_rcache_init(kcontext) krb5_context kcontext; { diff --git a/src/lib/krb5_16.def b/src/lib/krb5_16.def index abd9c7ee7..38a01227b 100644 --- a/src/lib/krb5_16.def +++ b/src/lib/krb5_16.def @@ -1,65 +1,191 @@ ;---------------------------------------------------- -; KRB5_16.DEF - KRB5_16.DLL module definition file +; KRB5.DEF - KRB5.DLL module definition file ;---------------------------------------------------- -LIBRARY KRB5_16 -DESCRIPTION 'DLL for Kerberos 5' -EXETYPE WINDOWS -CODE PRELOAD MOVEABLE DISCARDABLE -DATA PRELOAD MOVEABLE SINGLE -HEAPSIZE 8192 +LIBRARY KRB5_16 +DESCRIPTION 'DLL for Kerberos 5' +EXETYPE WINDOWS +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE SINGLE +HEAPSIZE 8192 EXPORTS - WEP @1001 RESIDENTNAME - LIBMAIN @1002 - GSS_ACQUIRE_CRED @1 - GSS_RELEASE_CRED @2 - GSS_INIT_SEC_CONTEXT @3 - GSS_ACCEPT_SEC_CONTEXT @4 - GSS_PROCESS_CONTEXT_TOKEN @5 - GSS_DELETE_SEC_CONTEXT @6 - GSS_CONTEXT_TIME @7 - GSS_SIGN @8 - GSS_VERIFY @9 - GSS_SEAL @10 - GSS_UNSEAL @11 - GSS_DISPLAY_STATUS @12 - GSS_INDICATE_MECHS @13 - GSS_COMPARE_NAME @14 - GSS_DISPLAY_NAME @15 - GSS_IMPORT_NAME @16 - GSS_RELEASE_NAME @17 - GSS_RELEASE_BUFFER @18 - GSS_RELEASE_OID_SET @19 - GSS_INQUIRE_CRED @20 + WEP @1001 RESIDENTNAME + LibMain @1002 ; Kerberos 5 + _krb5_build_principal _krb5_build_principal_ext - KRB5_CC_DEFAULT - KRB5_FREE_ADDRESSES - KRB5_FREE_AP_REP_ENC_PART - KRB5_FREE_CRED_CONTENTS - KRB5_FREE_CREDS - KRB5_FREE_PRINCIPAL - KRB5_GET_CREDENTIALS - KRB5_GET_DEFAULT_REALM - KRB5_GET_IN_TKT_WITH_PASSWORD - KRB5_GET_NOTIFICATION_MESSAGE - KRB5_INIT_CONTEXT - KRB5_INIT_ETS - KRB5_MK_REQ_EXTENDED - KRB5_OS_LOCALADDR - KRB5_PARSE_NAME - KRB5_RD_REP - KRB5_SNAME_TO_PRINCIPAL - KRB5_TIMEOFDAY - KRB5_US_TIMEOFDAY - KRB5_UNPARSE_NAME + krb5_copy_addr + krb5_copy_addresses + krb5_copy_authdata + krb5_copy_authenticator + krb5_copy_checksum + krb5_copy_creds + krb5_copy_data + krb5_copy_keyblock + krb5_copy_keyblock_contents + krb5_copy_principal + krb5_copy_ticket + krb5_decrypt_tkt_part + krb5_free_address + krb5_free_addresses + krb5_free_ap_rep + krb5_free_ap_rep_enc_part + krb5_free_ap_req + krb5_free_authdata + krb5_free_authenticator + krb5_free_authenticator_contents + krb5_free_checksum + krb5_free_context + krb5_free_cred + krb5_free_cred_contents + krb5_free_cred_enc_part + krb5_free_creds + krb5_free_enc_kdc_rep_part + krb5_free_enc_tkt_part + krb5_free_error + krb5_free_host_realm + krb5_free_kdc_rep + krb5_free_kdc_req + krb5_free_keyblock + krb5_free_keyblock_contents + krb5_free_last_req + krb5_free_pa_data + krb5_free_principal + krb5_free_priv + krb5_free_priv_enc_part + krb5_free_pwd_data + krb5_free_pwd_sequences + krb5_free_safe + krb5_free_tgt_creds + krb5_free_ticket + krb5_free_tickets + krb5_free_tkt_authent + krb5_fwd_tgt_creds + krb5_get_credentials + krb5_get_default_realm + krb5_get_host_realm + krb5_get_in_tkt + krb5_get_in_tkt_with_keytab + krb5_get_in_tkt_with_password + krb5_get_in_tkt_with_skey + krb5_get_notification_message + krb5_init_context + krb5_init_ets + krb5_mk_error + krb5_mk_priv + krb5_mk_rep + krb5_mk_req + krb5_mk_req_extended + krb5_mk_safe + krb5_os_localaddr + krb5_parse_name + krb5_principal_compare + krb5_rd_cred + krb5_rd_error + krb5_rd_priv + krb5_rd_rep + krb5_rd_req + krb5_rd_safe + krb5_recvauth + krb5_sendauth + krb5_sname_to_principal + krb5_timeofday + krb5_unparse_name + krb5_unparse_name_ext + krb5_us_timeofday +; + krb5_use_enctype + krb5_checksum_size + krb5_encrypt_size + krb5_calculate_checksum + krb5_verify_checksum + krb5_eblock_enctype +; + krb5_decrypt + krb5_encrypt + krb5_string_to_key + krb5_process_key + krb5_finish_key + krb5_init_random_key + krb5_finish_random_key + krb5_random_key +; + krb5_425_conv_principal + krb5_524_conv_principal +; + krb5_cksumtype_to_string + krb5_deltat_to_string + krb5_enctype_to_string + krb5_salttype_to_string + krb5_string_to_cksumtype + krb5_string_to_deltat + krb5_string_to_enctype + krb5_string_to_salttype + krb5_string_to_timestamp + krb5_timestamp_to_sfstring + krb5_timestamp_to_string +; + krb5_auth_con_free + krb5_auth_con_genaddrs + krb5_auth_con_getflags + krb5_auth_con_getkey + krb5_auth_con_getlocalsubkey + krb5_auth_con_getremotesubkey + krb5_auth_con_init + krb5_auth_con_setflags + krb5_auth_con_getlocalseqnumber + krb5_auth_con_getremoteseqnumber + krb5_auth_con_setuseruserkey + krb5_auth_con_getauthenticator + krb5_auth_con_set_req_cksumtype +; + krb5_cc_default + krb5_cc_register + krb5_cc_resolve +; + krb5_kt_default + krb5_kt_register + krb5_kt_resolve + krb5_kt_add_entry + krb5_kt_free_entry + krb5_kt_read_service_key + krb5_kt_remove_entry ;Kadm routines - KRB5_ADM_CONNECT - KRB5_ADM_DISCONNECT - KRB5_FREE_ADM_DATA - KRB5_READ_ADM_REPLY - KRB5_SEND_ADM_CMD + krb5_adm_connect + krb5_adm_disconnect + krb5_free_adm_data + krb5_read_adm_reply + krb5_send_adm_cmd ;Com_err routines - _com_err - ERROR_MESSAGE + _com_err + error_message + et_init + et_shutdown + et_add_error_table + et_error_message + _et_com_err + _et_com_err_va + et_set_hook + __et_list +; +;Temporary exports (DO NOT USE) + _sscanf + _decode_krb5_ticket + des_ecb_encrypt + des_new_random_key + des_key_sched + des_set_random_generator_seed + krb5_random_confounder + krb5_size_opaque + krb5_internalize_opaque + krb5_externalize_opaque + krb5_ser_pack_int32 + krb5_ser_unpack_int32 + krb5_ser_pack_bytes + krb5_ser_unpack_bytes + krb5_ser_auth_context_init + krb5_ser_context_init + krb5_ser_ccache_init + krb5_ser_keytab_init + krb5_ser_rcache_init diff --git a/src/lib/krb5_32.def b/src/lib/krb5_32.def new file mode 100644 index 000000000..76371cc6b --- /dev/null +++ b/src/lib/krb5_32.def @@ -0,0 +1,189 @@ +;---------------------------------------------------- +; KRB5.DEF - KRB5.DLL module definition file +;---------------------------------------------------- + +;LIBRARY KRB5 +DESCRIPTION 'DLL for Kerberos 5' +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE SINGLE +HEAPSIZE 8192 + +EXPORTS + WEP @1001 + LibMain @1002 +; Kerberos 5 + krb5_build_principal + krb5_build_principal_ext + krb5_copy_addr + krb5_copy_addresses + krb5_copy_authdata + krb5_copy_authenticator + krb5_copy_checksum + krb5_copy_creds + krb5_copy_data + krb5_copy_keyblock + krb5_copy_keyblock_contents + krb5_copy_principal + krb5_copy_ticket + krb5_decrypt_tkt_part + krb5_free_address + krb5_free_addresses + krb5_free_ap_rep + krb5_free_ap_rep_enc_part + krb5_free_ap_req + krb5_free_authdata + krb5_free_authenticator + krb5_free_authenticator_contents + krb5_free_checksum + krb5_free_context + krb5_free_cred + krb5_free_cred_contents + krb5_free_cred_enc_part + krb5_free_creds + krb5_free_enc_kdc_rep_part + krb5_free_enc_tkt_part + krb5_free_error + krb5_free_host_realm + krb5_free_kdc_rep + krb5_free_kdc_req + krb5_free_keyblock + krb5_free_keyblock_contents + krb5_free_last_req + krb5_free_pa_data + krb5_free_principal + krb5_free_priv + krb5_free_priv_enc_part + krb5_free_pwd_data + krb5_free_pwd_sequences + krb5_free_safe + krb5_free_tgt_creds + krb5_free_ticket + krb5_free_tickets + krb5_free_tkt_authent + krb5_fwd_tgt_creds + krb5_get_credentials + krb5_get_default_realm + krb5_get_host_realm + krb5_get_in_tkt + krb5_get_in_tkt_with_keytab + krb5_get_in_tkt_with_password + krb5_get_in_tkt_with_skey + krb5_get_notification_message + krb5_init_context + krb5_init_ets + krb5_mk_error + krb5_mk_priv + krb5_mk_rep + krb5_mk_req + krb5_mk_req_extended + krb5_mk_safe + krb5_os_localaddr + krb5_parse_name + krb5_principal_compare + krb5_rd_cred + krb5_rd_error + krb5_rd_priv + krb5_rd_rep + krb5_rd_req + krb5_rd_safe + krb5_recvauth + krb5_sendauth + krb5_sname_to_principal + krb5_timeofday + krb5_unparse_name + krb5_unparse_name_ext + krb5_us_timeofday +; + krb5_use_enctype + krb5_checksum_size + krb5_encrypt_size + krb5_calculate_checksum + krb5_verify_checksum + krb5_eblock_enctype +; + krb5_decrypt + krb5_encrypt + krb5_string_to_key + krb5_process_key + krb5_finish_key + krb5_init_random_key + krb5_finish_random_key + krb5_random_key +; + krb5_425_conv_principal + krb5_524_conv_principal +; + krb5_cksumtype_to_string + krb5_deltat_to_string + krb5_enctype_to_string + krb5_salttype_to_string + krb5_string_to_cksumtype + krb5_string_to_deltat + krb5_string_to_enctype + krb5_string_to_salttype + krb5_string_to_timestamp + krb5_timestamp_to_sfstring + krb5_timestamp_to_string +; + krb5_auth_con_free + krb5_auth_con_genaddrs + krb5_auth_con_getflags + krb5_auth_con_getkey + krb5_auth_con_getlocalsubkey + krb5_auth_con_getremotesubkey + krb5_auth_con_init + krb5_auth_con_setflags + krb5_auth_con_getlocalseqnumber + krb5_auth_con_getremoteseqnumber + krb5_auth_con_setuseruserkey + krb5_auth_con_getauthenticator + krb5_auth_con_set_req_cksumtype +; + krb5_cc_default + krb5_cc_register + krb5_cc_resolve +; + krb5_kt_default + krb5_kt_register + krb5_kt_resolve + krb5_kt_add_entry + krb5_kt_free_entry + krb5_kt_read_service_key + krb5_kt_remove_entry +;Kadm routines + krb5_adm_connect + krb5_adm_disconnect + krb5_free_adm_data + krb5_read_adm_reply + krb5_send_adm_cmd +;Com_err routines + com_err + error_message + et_init + et_shutdown + et_add_error_table + et_error_message + et_com_err + et_com_err_va + et_set_hook + _et_list +; +;Temporary exports (DO NOT USE) + decode_krb5_ticket + des_ecb_encrypt + des_new_random_key + des_key_sched + des_set_random_generator_seed + krb5_random_confounder + krb5_size_opaque + krb5_internalize_opaque + krb5_externalize_opaque + krb5_ser_pack_int32 + krb5_ser_unpack_int32 + krb5_ser_pack_bytes + krb5_ser_unpack_bytes + krb5_ser_auth_context_init + krb5_ser_context_init + krb5_ser_ccache_init + krb5_ser_keytab_init + krb5_ser_rcache_init diff --git a/src/lib/libkrb5.def b/src/lib/libkrb5.def deleted file mode 100644 index 9d9d5e5ef..000000000 --- a/src/lib/libkrb5.def +++ /dev/null @@ -1,65 +0,0 @@ -;---------------------------------------------------- -; LIBKRB5.DEF - LIBKRB5.DLL module definition file -;---------------------------------------------------- - -LIBRARY LIBKRB5 -DESCRIPTION 'DLL for Kerberos 5' -EXETYPE WINDOWS -CODE PRELOAD MOVEABLE DISCARDABLE -DATA PRELOAD MOVEABLE SINGLE -HEAPSIZE 8192 - -EXPORTS - WEP @1001 RESIDENTNAME - LIBMAIN @1002 - GSS_ACQUIRE_CRED @1 - GSS_RELEASE_CRED @2 - GSS_INIT_SEC_CONTEXT @3 - GSS_ACCEPT_SEC_CONTEXT @4 - GSS_PROCESS_CONTEXT_TOKEN @5 - GSS_DELETE_SEC_CONTEXT @6 - GSS_CONTEXT_TIME @7 - GSS_SIGN @8 - GSS_VERIFY @9 - GSS_SEAL @10 - GSS_UNSEAL @11 - GSS_DISPLAY_STATUS @12 - GSS_INDICATE_MECHS @13 - GSS_COMPARE_NAME @14 - GSS_DISPLAY_NAME @15 - GSS_IMPORT_NAME @16 - GSS_RELEASE_NAME @17 - GSS_RELEASE_BUFFER @18 - GSS_RELEASE_OID_SET @19 - GSS_INQUIRE_CRED @20 -; Kerberos 5 - _krb5_build_principal_ext - KRB5_CC_DEFAULT - KRB5_FREE_ADDRESSES - KRB5_FREE_AP_REP_ENC_PART - KRB5_FREE_CRED_CONTENTS - KRB5_FREE_CREDS - KRB5_FREE_PRINCIPAL - KRB5_GET_CREDENTIALS - KRB5_GET_DEFAULT_REALM - KRB5_GET_IN_TKT_WITH_PASSWORD - KRB5_GET_NOTIFICATION_MESSAGE - KRB5_INIT_CONTEXT - KRB5_INIT_ETS - KRB5_MK_REQ_EXTENDED - KRB5_OS_LOCALADDR - KRB5_PARSE_NAME - KRB5_RD_REP - KRB5_SNAME_TO_PRINCIPAL - KRB5_TIMEOFDAY - KRB5_US_TIMEOFDAY - KRB5_UNPARSE_NAME -;Kadm routines - KRB5_ADM_CONNECT - KRB5_ADM_DISCONNECT - KRB5_FREE_ADM_DATA - KRB5_READ_ADM_REPLY - KRB5_SEND_ADM_CMD -;Com_err routines - _com_err - ERROR_MESSAGE diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog index 9bfcde824..f27c74c80 100644 --- a/src/util/profile/ChangeLog +++ b/src/util/profile/ChangeLog @@ -1,3 +1,9 @@ +Wed Feb 5 20:18:33 1997 Richard Basch + + * Makefile.in: + Fixed typo (all-max -> all-mac) + Inconsistent colon usage; all-windows needed :: not : + Mon Nov 4 17:04:51 1996 Theodore Y. Ts'o * prof_parse.c (parse_std_line): Accept either ';' or '#' on the diff --git a/src/util/profile/Makefile.in b/src/util/profile/Makefile.in index a8ad8fff5..d59d240d8 100644 --- a/src/util/profile/Makefile.in +++ b/src/util/profile/Makefile.in @@ -26,13 +26,13 @@ LIBS = ../et/libcom_err.$(LIBEXT) install:: -all-max:: all-unix +all-mac:: all-unix all-unix:: shared includes libprofile.a test_parse test_profile shared: mkdir shared -all-windows: $(OBJS) +all-windows:: $(OBJS) awk-windows: $(AWK) -f $(BUILDTOP)/util/et/et_h.awk outfile=prof_err.h prof_err.et diff --git a/src/util/windows/ChangeLog b/src/util/windows/ChangeLog new file mode 100644 index 000000000..e69de29bb diff --git a/src/util/windows/Makefile.in b/src/util/windows/Makefile.in new file mode 100644 index 000000000..63bbcd7ff --- /dev/null +++ b/src/util/windows/Makefile.in @@ -0,0 +1,16 @@ +BUILDTOP = ..\.. + +CFLAGS = $(COPTS) $(INCLUDES) + +##WIN16##LFLAGS = /nologo /nod /nopackcode +##WIN32##LFLAGS = /nologo /nod + +##WIN32##all-windows:: libecho.exe + +libecho.exe: libecho.c + +install-windows:: + +clean-windows:: + $(RM) *.res *.map *.obj *.exe + diff --git a/src/util/windows/libecho.c b/src/util/windows/libecho.c new file mode 100644 index 000000000..9fcbe2e98 --- /dev/null +++ b/src/util/windows/libecho.c @@ -0,0 +1,76 @@ +/* + * libecho.c + * + * For each argument on the command line, echo it. Should expand + * DOS wildcards correctly. + * + * Syntax: libecho [-p prefix] list... + */ +#include +#include +#include + +void echo_files(char *, char *); + +int +main(int argc, char *argv[]) +{ + int i; + char *prefix; + + prefix = ""; + + if (argc < 2) { + fprintf(stderr, "Usage: libecho [-p prefix] list...\n"); + return 1; + } + + for (i = 1 ; i < argc ; i++) + if (!stricmp(argv[i], "-p")) + prefix = argv[++i]; + else + echo_files(prefix, argv[i]); + + return 0; +} + +void +echo_files(char *prefix, char *f) +{ + long ff; + struct _finddata_t fdt; + char *slash; + char filepath[256]; + + /* + * We're unix based quite a bit here. Look for normal slashes and + * make them reverse slashes. + */ + while((slash = strrchr(f, '/')) != NULL) + *slash = '\\'; + + strcpy(filepath, f); + + slash = strrchr(filepath, '\\'); + + if (slash) { + slash++; + *slash = 0; + } else { + filepath[0] = '\0'; + } + + ff = _findfirst(f, &fdt); + + if (ff < 0) + return; + + printf("%s%s%s\n", prefix, filepath, fdt.name); + + for (;;) { + if (_findnext(ff, &fdt) < 0) + break; + printf("%s%s%s\n", prefix, filepath, fdt.name); + } + _findclose(ff); +} diff --git a/src/windows/changelo b/src/windows/ChangeLog similarity index 100% rename from src/windows/changelo rename to src/windows/ChangeLog diff --git a/src/windows/makefile b/src/windows/Makefile.in similarity index 67% rename from src/windows/makefile rename to src/windows/Makefile.in index 059b60b64..58f7820cb 100644 --- a/src/windows/makefile +++ b/src/windows/Makefile.in @@ -1,7 +1,9 @@ +##DOSBUILDTOP=.. + # # Makefile that recurses into cns subdirectory. # -all:: +all-windows:: @echo Making in windows\cns cd cns -$(MAKE) -$(MAKEFLAGS) LIBCMD=$(LIBCMD) @@ -11,9 +13,12 @@ all:: @echo Making in windows\gss cd ..\gss -$(MAKE) -$(MAKEFLAGS) LIBCMD=$(LIBCMD) +##WIN32## @echo Making in windows\gina +##WIN32## cd ..\gina +##WIN32## -$(MAKE) -$(MAKEFLAGS) LIBCMD=$(LIBCMD) cd .. -clean:: +clean-windows:: @echo Making clean in windows\cns cd cns -$(MAKE) -$(MAKEFLAGS) clean @@ -23,5 +28,7 @@ clean:: @echo Making clean in windows\gss cd ..\gss -$(MAKE) -$(MAKEFLAGS) clean +##WIN32## @echo Making clean in windows\gina +##WIN32## cd ..\gina +##WIN32## -$(MAKE) -$(MAKEFLAGS) clean cd .. - diff --git a/src/windows/cns/ChangeLog b/src/windows/cns/ChangeLog index ef790cfdc..1fd2a5eec 100644 --- a/src/windows/cns/ChangeLog +++ b/src/windows/cns/ChangeLog @@ -1,19 +1,120 @@ -Sat Dec 21 03:13:02 1996 Theodore Y. Ts'o +Sun Feb 2 11:22:57 1997 Richard Basch - * krb5.def: New file, copied from cns.def, with Cygnus'isms #ifdef'ed - out. - * cns.c: Removed text "Contacting Cygnus Support for support" from - the "about" box. - * Makefile.in: Change name of cns.exe to be krb5.exe (CNS is a - Cygnus trademark) + * cns.c (k5_name_from_ccache): + Declare variable as (char FAR *) to match + krb5_unparse_name prototype -Sat Nov 23 00:26:44 1996 Theodore Ts'o + * Makefile.in: Build using CCOPTS2, not COPTS (win16) - * Makefile.in (KLIB): Change krb516.dll to krb5_16.dll. [PR#204] +Fri Dec 20 10:28:59 1996 Theodore Y. Ts'o -Wed Nov 20 18:32:06 1996 Theodore Y. Ts'o + * krb5.def: New file, modelled after krbnet.def - * Makefile.in (KLIB): Change libkrb5.dll to be krb516.dll + * cns.h, cns.c, krbini.h, cnsres5.c, Makefile: remove + Cygnus/KerbNet(tm) name from MIT distribution + +Fri Aug 9 03:41:52 1996 Michael Graff + + * Makefile.in: rename executable to kerbnet.exe + + * cns.def: rename to kerbnet.def + +Wed Aug 7 14:25:34 1996 Michael Graff + + * Makefile.in: Build kerbnet, not cns.exe + + * cns.c: + * cns.h: + * cnsres5.rc: + * krbini.h: Help file is kerbnet.hlp, program name is kerb*net. + + * cns.def: rename to kerbnet.def. + +Sat Aug 3 13:58:20 1996 Jeff Bigler + + * cns-help.hpj, cns-help.doc, cns-help.hlp: added help files. + The cns-help.hpj is a RoboHelp help project. RoboHelp requires + cns-help.doc, which is a Microsoft Word document, and it creates + cns-help.hlp, which is the actual help file. + + * Makefile.in: added line to install section to install help + file. + +Thu Jul 25 13:52:04 1996 + + * options.c (opts_command): Display a warning message when changing + the location of the krb.conf file, since the KRB5 libraries + will have opened it and tucked it away in krb5_context->profile, + which we as a client don't have access to. + +Wed Aug 7 18:03:16 1996 Jeff Bigler + + * kerbnet.hpj: new help project (RoboHelp) + * kerbnet.doc: help file (Microsoft Word document) + * kerbnet.hlp: new help file (Windows help file) + +Wed Jul 24 06:12:24 1996 Michael Graff + + * Makefile.in: Build cnsres[45].rc into executable, depending on + if we're compiling for V4 or V5. + + * cns.rc: remove, no longer needed. cnsres[45].rc replace this, + and allow GUI editors for editing the .rc files. + + * kpasswd.c: make this work for V5 + + * options.c: + * cns.c: + * cnsres5.rc: + * krbini.h: Add forwardable option to options menu + +Tue Jul 16 12:42:48 1996 Michael Graff + + * options.c: + * password.c: Split parts of cns.c into these files. Each deals + with the respective dialogs. + + * debug.c: + * heap.c: Added to aid in debugging. + +Wed Jul 10 18:01:03 1996 Michael Graff + + * cns.c: Remove the quick hacks mentioned below. + +Thu Jul 25 13:52:04 1996 + + * options.c (opts_command): Display a warning message when changing + the location of the krb.conf file, since the KRB5 libraries + will have opened it and tucked it away in krb5_context->profile, + which we as a client don't have access to. + +Fri Jun 28 19:29:14 1996 Michael Graff + + * cns.c: Really quick hacks to disable some features that just + plain don't work correctly. The "cns" client has some flavor of + memory problems (malloc/free) that needs to be tracked down. + + * cnsres5.rc: reload this using a dialog editor. Add clickbox + for "ticket options" of "forwardable" + +Wed Jun 26 14:58:23 1996 Michael Graff + + * cns.h kpasswd.c: formatting change, including changing + // to /* */ + + * Makefile.in: update some of the WIN32 entries for debugging. + Also make resouce.obj only a dependancy for WIN32 builds. + + * cns.c tktlist.h tktlist.c: Rewrite to use the message functions + from , included in VC 2.0 and above. This makes most + of the details of 16- vs 32-bit hidden to the code. (Disgusting + magic happens in ) + +Tue Jun 25 13:57:59 1996 Michael Graff + + * Makefile.in: Fix to work for WIN32 native compiles. Many + changes; some should be put into common files (win-post.in or + windows.in?) Wed Jun 12 00:20:08 1996 Theodore Ts'o diff --git a/src/windows/cns/Makefile.in b/src/windows/cns/Makefile.in index 9b3347fd2..caccee8f4 100644 --- a/src/windows/cns/Makefile.in +++ b/src/windows/cns/Makefile.in @@ -2,67 +2,61 @@ # Works for both k4 and k5 releases. # NAME = krb5 -OBJS = cns.obj tktlist.obj +OBJS = cns.obj tktlist.obj password.obj options.obj ##### Options -DEBUG = 1 +#DEBUG = 1 !IF ! defined(KVERSION) KVERSION = 5 !endif KRB = KRB$(KVERSION) -!if $(KVERSION) == 4 -BUILDTOP = .. -LIBDIR = $(BUILDTOP)\lib\krb -KLIB = $(LIBDIR)\kerberos.lib -WLIB = $(LIBDIR)\winsock.lib -INCLUDES = /I$(BUILDTOP)\include -XOBJS = -!endif - -!if $(KVERSION) == 5 BUILDTOP =..\.. -LIBDIR = $(BUILDTOP)\lib -KLIB = $(LIBDIR)\krb5_16.lib -WLIB = $(LIBDIR)\winsock.lib + +##WIN16##WLIB = $(BUILDTOP)\lib\winsock.lib INCLUDES = /I$(BUILDTOP)\include /I$(BUILDTOP)\include\krb5 -XOBJS = kpasswd.obj -!endif +##WIN16##XOBJS = kpasswd.obj +##WIN32##XOBJS = cnsres5.obj kpasswd.obj -##### C Compiler -CC = cl -CFLAGS_RELEASE = /nologo /W3 /AL /GAs /G2 /Zp /O2 /DNDEBUG=1 -CFLAGS_DEBUG = /nologo /W3 /AL /GAs /G2 /Zp /O2 /Od /Zi -!if $(DEBUG) -CFLAGS = $(CFLAGS_DEBUG) $(INCLUDES) /D$(KRB)=1 +!if defined(DEBUG) +CFLAGS = $(CCOPTS2) $(INCLUDES) /D$(KRB)=1 /Zi /Yd /DDEBUG !else -CFLAGS = $(CFLAGS_RELEASE) $(INCLUDES) /D$(KRB)=1 +CFLAGS = $(CCOPTS2) $(INCLUDES) /D$(KRB)=1 !endif -##### RC Compiler -RC = rc ##WIN16##RFLAGS = /nologo /D$(KRB)=1 $(INCLUDES) ##WIN32##RFLAGS = /D$(KRB)=1 $(INCLUDES) ##### Linker LINK = link LIBS = $(KLIB) $(WLIB) -SYSLIBS = libw llibcew -!if $(DEBUG) -LFLAGS = /co /nologo /nod /nopackcode /map:full +##WIN16##SYSLIBS = libw llibcew +!if defined(DEBUG) +##WIN16##LFLAGS = /co /nologo /nod /nopackcode /map:full +##WIN32##LFLAGS = /nologo /nod /debug +##WIN32##SYSLIBS = libcd.lib kernel32.lib wsock32.lib user32.lib gdi32.lib !else -LFLAGS = /nologo /nod /nopackcode +##WIN16##LFLAGS = /nologo /nod /nopackcode +##WIN32##LFLAGS = /nologo /nod +##WIN32##SYSLIBS = libc.lib kernel32.lib wsock32.lib user32.lib gdi32.lib !endif all:: makefile $(NAME).exe -$(NAME).exe: $*.def cns.res $(OBJS) $(XOBJS) $(LIBS) - $(LINK) $(LFLAGS) $(OBJS) $(XOBJS), $@, $*.map, \ - $(LIBS) $(SYSLIBS), $*.def - $(RC) $(RFLAGS) /k cns.res $@ +$(NAME).exe: $*.def $(OBJS) $(XOBJS) $(LIBS) +##WIN16## $(LINK) $(LFLAGS) $(OBJS) $(XOBJS), $@, $*.map, \ +##WIN16## $(LIBS) $(SYSLIBS), $*.def +##WIN16## $(RC) $(RFLAGS) /k cnsres5.rc $@ +##WIN32## $(LINK) $(LFLAGS) /map:$*.map /out:$@ $(OBJS) $(XOBJS) \ +##WIN32## $(LIBS) $(SYSLIBS) + +##WIN32##.rc.obj: +##WIN32## $(RC) $(RFLAGS) /r $*.rc +##WIN32## $(CVTRES) /nologo /out:$*.obj $*.res -install: - copy $(NAME).exe ..\floppy +install:: + $(CP) $(NAME).exe $(DESTDIR) + $(CP) $(NAME).hlp $(DESTDIR) clean:: if exist *.obj del *.obj @@ -71,11 +65,11 @@ clean:: if exist *.map del *.map if exist *.pdb del *.pdb if exist *.err del *.err - if exist ..\floppy\$(NAME).exe del ..\floppy\$(NAME).exe -$(OBJS) cns.res: cns.h tktlist.h +$(OBJS): cns.h tktlist.h -cns.res: clock00.ico clock05.ico clock10.ico clock15.ico clock20.ico \ - clock25.ico clock30.ico clock35.ico clock40.ico clock45.ico \ - clock50.ico clock55.ico clock60.ico clockexp.ico clocktkt.ico \ - cns.ico +cns.res: cns.h \ + clock00.ico clock05.ico clock10.ico clock15.ico clock20.ico \ + clock25.ico clock30.ico clock35.ico clock40.ico clock45.ico \ + clock50.ico clock55.ico clock60.ico clockexp.ico clocktkt.ico \ + cns.ico diff --git a/src/windows/cns/cns-help.doc b/src/windows/cns/cns-help.doc new file mode 100644 index 000000000..6aae7b752 Binary files /dev/null and b/src/windows/cns/cns-help.doc differ diff --git a/src/windows/cns/cns-help.hlp b/src/windows/cns/cns-help.hlp new file mode 100644 index 000000000..a9a00244d Binary files /dev/null and b/src/windows/cns/cns-help.hlp differ diff --git a/src/windows/cns/cns-help.hpj b/src/windows/cns/cns-help.hpj new file mode 100644 index 000000000..bd668b31c --- /dev/null +++ b/src/windows/cns/cns-help.hpj @@ -0,0 +1,133 @@ +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +; Help Project File for KERBNET +; +; You may edit this file. +; +; It's probably best not to change the CONTENTS= value +; unless you rename the IDH_CONTENTS context string in +; the KERBNET.DOC file. +; + +[OPTIONS] +; The optional ROOT= entry sets the working directory for the Help Compiler +; ROOT=C:\PROJECT + +; The optional BMROOT= entry sets forth the directories which the +; help compiler will search for bitmaps used in the Help system. +; +;BMROOT=C:\ROBOHELP + +; The CONTENTS= tells the help Engine which topic contains the contents +CONTENTS=IDH_CONTENTS + +; Title is Displayed in the Title Bar of WINHELP.EXE +TITLE=Kerb*Net + +; The BUILD= setting allows complex Help systems which require +; different versions to use the same source. This is similar to #ifdef's +; in the 'C' language. Everything to the right of the = sign in the +; BUILD= statement is an EXPRESSION. See the Help compiler +; documentation for more information about build expressions. +BUILD=WINDOWS + +; The Warning Level is used by the Help Compiler (HC.EXE) +; WARNING=1 - Only the most severe warnings are reported +; WARNING=2 - Intermediate Level of warnings +; WARNING=3 - Most stringent error reporting + +; The Compress option is used by the Help Compiler to make +; smaller, faster loading .HLP files. However, using compression +; increases Compile times. +; COMPRESS=YES, ON, OFF, NO, TRUE or FALSE + + +OLDKEYPHRASE=NO +OPTCDROM=0 +NOTES=1 +REPORT=YES +COMPRESS=12 +ERRORLOG=C:\krbhelp\KERBNET.ERR +[BUILDTAGS] +; The Build Tags section specifies to the Help Compiler the names +; of all the valid build tags used in this Help project. The [BUILDTAGS] +; section is optional. +WINDOWS + + +[CONFIG] +; The config section allows you to define some macros which will be +; executed when the help system is first executed. +; +; The next line gives you browse buttons: +; +BrowseButtons() + +; +; To create a glossary button which displays a list of defined terms +; in a secondary window, remove the semi colon at the start of the next +; line and do the same with the Glossary window in the [WINDOWS] section +;CreateButton("Glossary_Btn","&Glossary","JI(`bubble.hlp>Gloss',`IDH_Glossary')") +; + + +[FILES] +; The files section is where you specify to the Help Compiler which +; Rich Text Format (.RTF) (your help source) files will be used in the +; Help system. RoboHELP generates and maintains the main .RTF +; file for your Help System. If you desire to have multiple .RTF files, +; simply add the additonal names to the [FILES] section. + +KERBNET.RTF +[ALIAS] +; The Alias section allows you to set up aliases for context strings +; in your help system. +; +; Brief example: +; +; IDH_UserID = IDH_RoboGenerated_Id +; IDH_WMP_MenuID = IDH_RoboGenerated_Id +; IDH_Any = IDH_AnyOther + +[MAP] +; +; The Map Section is where the C language #defines are translated +; or mapped into the Help System Context Strings. Standard C syntax +; can be employed. The .HH file is meant to be #include(d) into your +; Windows application source code. +; + +[BITMAPS] +; +; The [BITMAPS] section is where you list any Bitmaps which have +; been placed by reference in the Help System. See the Help compiler +; documentation for more information about placing bitmaps. +; +; The [BITMAPS] section is not really required under Windows 3.1, +; with the advent of the BMROOT item in the [OPTIONS] section. +; +;FOO1.BMP +;FOO2.BMP +;C:\FOO\FOO3.BMP +;And So On + +[WINDOWS] +; Windows Help can display help in one of 5 secondary windows. +; Before using a secondary window, the window must be defined +; in this section: +; +;Gloss = "Glossary",(100,100,350,350),0,(255,255,255),(255,255,255) +main=,,0,, + +[BAGGAGE] +; +; The Baggage section allows the user to include files which +; will be placed in the internal file system for WinHelp. +; Using files from Baggage is a little faster for CDROM, since +; the CDROM drive table does not need to be read from disk. +; +; Baggage files are referred to as regular bitmaps, except +; that you prefix the filename with '!'. +; +; For Instance: +; {bmc !bitmap.bmp} instead of {bmc bitmap.bmp} +; diff --git a/src/windows/cns/cns.c b/src/windows/cns/cns.c index e5969a11c..021cc88ab 100644 --- a/src/windows/cns/cns.c +++ b/src/windows/cns/cns.c @@ -1,8 +1,6 @@ /* * cns.c * - * Tabs 4 - * * Main routine of the Kerberos user interface. Also handles * all dialog level management functions. * @@ -13,10 +11,12 @@ */ #if !defined(KRB5) && !defined(KRB4) - #define KRB5 1 +#error "Must define either KRB4 or KRB5" #endif #include +#include + #include #include #include @@ -25,77 +25,49 @@ #include #include -#ifdef KRB4 - #define DEFINE_SOCKADDR - #include "mit-copyright.h" - #include "krb.h" - #include "kadm.h" - #include "org.h" -#endif - -#ifdef KRB5 - #include "winsock.h" - #include "krb5.h" - #include "krbini.h" - #include "com_err.h" - - #define DEFAULT_TKT_LIFE 120 // In 5 minute units - #define ANAME_SZ 40 - #define REALM_SZ 40 - #define SNAME_SZ 40 - #define INST_SZ 40 - #define MAX_KPW_LEN 128 - /* include space for '.' and '@' */ - #define MAX_K_NAME_SZ (ANAME_SZ + INST_SZ + REALM_SZ + 2) -#ifdef CYGNUS - #define ORGANIZATION "Cygnus Support" -#endif - - #define CREDENTIALS char -#endif - #include "cns.h" #include "tktlist.h" -/* - * Constants - */ -#define BLOCK_MAX_SEC 30 /* Blocking timeout duration */ -#define KWIN_UPDATE_PERIOD 30000 /* Every 30 seconds update the screen */ -#define TIME_BUFFER 300 /* Pop-up time buffer in seconds */ -#define WM_KWIN_SETNAME (WM_USER+100) /* Sets the name fields in the dialog */ - -enum { /* Actions after login */ - LOGIN_AND_EXIT, - LOGIN_AND_MINIMIZE, - LOGIN_AND_RUN, +enum { /* Actions after login */ + LOGIN_AND_EXIT, + LOGIN_AND_MINIMIZE, + LOGIN_AND_RUN, }; +#ifndef _WIN32 +typedef MINMAXINFO *LPMINMAXINFO; +#define GET_WM_COMMAND_MPS(id, hwnd, cmd) \ + (WPARAM)MAKELONG(id, cmd), (LONG)(hwnd) +#endif + /* * Globals */ -static HICON kwin_icons[MAX_ICONS]; /* Icons depicting time */ -static HFONT hfontdialog = NULL; /* Font in which the dialog is drawn. */ -static HFONT hfonticon = NULL; /* Font for icon label */ -static HINSTANCE hinstance; -static int dlgncmdshow; /* ncmdshow from WinMain */ -static UINT wm_kerberos_changed; /* Registered message for cache changing */ -static int action; /* After login actions */ -static UINT kwin_timer_id; /* Timer being used for update */ -static BOOL alert; /* Actions on ticket expiration */ -static BOOL beep; -static BOOL alerted; /* TRUE when user already alerted */ -static BOOL isblocking = FALSE; /* TRUE when blocked in WinSock */ -static DWORD blocking_end_time; /* Ending tick count for blocking timeout */ -static FARPROC hook_instance; /* Intance handle for blocking hook function */ +static HICON kwin_icons[MAX_ICONS]; /* Icons depicting time */ +HFONT hfontdialog = NULL; /* Font in which the dialog is drawn. */ +static HFONT hfonticon = NULL; /* Font for icon label */ +HINSTANCE hinstance; +static int dlgncmdshow; /* ncmdshow from WinMain */ +static UINT wm_kerberos_changed; /* message for cache changing */ +static int action; /* After login actions */ +static UINT kwin_timer_id; /* Timer being used for update */ +BOOL alert; /* Actions on ticket expiration */ +BOOL beep; +static BOOL alerted; /* TRUE when user already alerted */ +BOOL isblocking = FALSE; /* TRUE when blocked in WinSock */ +static DWORD blocking_end_time; /* Ending count for blocking timeout */ +static FARPROC hook_instance; /* handle for blocking hook function */ + +char confname[FILENAME_MAX]; /* krb5.conf (or krb.conf for krb4) */ #ifdef KRB5 - krb5_context k5_context; - krb5_ccache k5_ccache; - static char ccname[FILENAME_MAX]; /* ccache file location */ +char ccname[FILENAME_MAX]; /* ccache file location */ +BOOL forwardable; /* TRUE to get forwardable tickets */ +krb5_context k5_context; +krb5_ccache k5_ccache; #endif -/*+ +/* * Function: Called during blocking operations. Implement a timeout * if nothing occurs within the specified time, cancel the blocking * operation. Also permit the user to press escape in order to @@ -103,106 +75,105 @@ static FARPROC hook_instance; /* Intance handle for blocking hook function */ * * Returns: TRUE if we got and dispatched a message, FALSE otherwise. */ -BOOL __export CALLBACK -blocking_hook_proc (void) +BOOL CALLBACK +blocking_hook_proc(void) { - MSG msg; - BOOL rc; + MSG msg; + BOOL rc; - if (GetTickCount() > blocking_end_time) { - WSACancelBlockingCall(); - return FALSE; - } - - rc = (BOOL) PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); - if (!rc) - return FALSE; + if (GetTickCount() > blocking_end_time) { + WSACancelBlockingCall(); + return FALSE; + } - if (msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE) { - WSACancelBlockingCall(); - blocking_end_time = msg.time - 1; - return FALSE; - } + rc = (BOOL)PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); + if (!rc) + return FALSE; - TranslateMessage(&msg); - DispatchMessage(&msg); + if (msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE) { + WSACancelBlockingCall(); + blocking_end_time = msg.time - 1; + return FALSE; + } - return TRUE; + TranslateMessage(&msg); + DispatchMessage(&msg); -} /* blocking_hook_proc */ + return TRUE; +} -/*+ +/* * Function: Set up a blocking hook function. * * Parameters: * timeout - # of seconds to block for before cancelling. */ -static void -start_blocking_hook ( - int timeout) +void +start_blocking_hook(int timeout) { - FARPROC proc; - - if (isblocking) - return; + FARPROC proc; - isblocking = TRUE; - blocking_end_time = GetTickCount() + (1000 * timeout); - hook_instance = MakeProcInstance(blocking_hook_proc, hinstance); - proc = WSASetBlockingHook(hook_instance); - assert(proc != NULL); + if (isblocking) + return; -} /* start_blocking_hook */ + isblocking = TRUE; + blocking_end_time = GetTickCount() + (1000 * timeout); +#ifdef _WIN32 + proc = WSASetBlockingHook(blocking_hook_proc); +#else + hook_instance = MakeProcInstance(blocking_hook_proc, hinstance); + proc = WSASetBlockingHook(hook_instance); +#endif + assert(proc != NULL); +} -/*+ +/* * Function: End the blocking hook fuction set up above. */ -static void -end_blocking_hook (void) +void +end_blocking_hook(void) { - - FreeProcInstance(hook_instance); - WSAUnhookBlockingHook(); - isblocking = FALSE; - -} /* end_blocking_hook */ +#ifndef _WIN32 + FreeProcInstance(hook_instance); +#endif + WSAUnhookBlockingHook(); + isblocking = FALSE; +} -/*+ +/* * Function: Centers the specified window on the screen. * * Parameters: * hwnd - the window to center on the screen. */ -static void -center_dialog ( - HWND hwnd) +void +center_dialog(HWND hwnd) { - int scrwidth, scrheight; - int dlgwidth, dlgheight; - RECT r; - HDC hdc; - - if (hwnd == NULL) - return; + int scrwidth, scrheight; + int dlgwidth, dlgheight; + RECT r; + HDC hdc; - GetWindowRect(hwnd, &r); - dlgwidth = r.right - r.left; - dlgheight = r.bottom - r.top ; - hdc = GetDC(NULL); - scrwidth = GetDeviceCaps(hdc, HORZRES); - scrheight = GetDeviceCaps(hdc, VERTRES); - ReleaseDC(NULL, hdc); - r.left = (scrwidth - dlgwidth) / 2; - r.top = (scrheight - dlgheight) / 2; - MoveWindow(hwnd, r.left, r.top, dlgwidth, dlgheight, TRUE); + if (hwnd == NULL) + return; -} /* center_dialog */ + GetWindowRect(hwnd, &r); + dlgwidth = r.right - r.left; + dlgheight = r.bottom - r.top ; + hdc = GetDC(NULL); + scrwidth = GetDeviceCaps(hdc, HORZRES); + scrheight = GetDeviceCaps(hdc, VERTRES); + ReleaseDC(NULL, hdc); + r.left = (scrwidth - dlgwidth) / 2; + r.top = (scrheight - dlgheight) / 2; + MoveWindow(hwnd, r.left, r.top, dlgwidth, dlgheight, TRUE); +} -/*+ +/* * Function: Positions the kwin dialog either to the saved location * or the center of the screen if no saved location. * @@ -210,109 +181,101 @@ center_dialog ( * hwnd - the window to center on the screen. */ static void -position_dialog ( - HWND hwnd) +position_dialog(HWND hwnd) { - int n; - int scrwidth, scrheight; - HDC hdc; - char position[256]; - int x, y, cx, cy; - - if (hwnd == NULL) - return; - - hdc = GetDC(NULL); - scrwidth = GetDeviceCaps(hdc, HORZRES); - scrheight = GetDeviceCaps(hdc, VERTRES); - ReleaseDC(NULL, hdc); - GetPrivateProfileString(INI_DEFAULTS, INI_POSITION, "", - position, sizeof(position), KERBEROS_INI); - - n = sscanf(position, " [%d , %d , %d , %d", &x, &y, &cx, &cy); - if (n != 4 || - x > scrwidth || - y > scrheight || - x + cx < 0 || - y + cy < 0) - center_dialog(hwnd); - else - MoveWindow(hwnd, x, y, cx, cy, TRUE); + int n; + int scrwidth, scrheight; + HDC hdc; + char position[256]; + int x, y, cx, cy; + + if (hwnd == NULL) + return; -} /* position_dialog */ + hdc = GetDC(NULL); + scrwidth = GetDeviceCaps(hdc, HORZRES); + scrheight = GetDeviceCaps(hdc, VERTRES); + ReleaseDC(NULL, hdc); + GetPrivateProfileString(INI_DEFAULTS, INI_POSITION, "", + position, sizeof(position), KERBEROS_INI); + + n = sscanf(position, " [%d , %d , %d , %d", &x, &y, &cx, &cy); + if (n != 4 || + x > scrwidth || + y > scrheight || + x + cx < 0 || + y + cy < 0) + center_dialog(hwnd); + else + MoveWindow(hwnd, x, y, cx, cy, TRUE); +} -/*+ +/* * Function: Set font of all dialog items. * * Parameters: * hwnd - the dialog to set the font of */ -static void -set_dialog_font ( - HWND hwnd, - HFONT hfont) +void +set_dialog_font(HWND hwnd, HFONT hfont) { - hwnd = GetWindow(hwnd, GW_CHILD); + hwnd = GetWindow(hwnd, GW_CHILD); - while (hwnd != NULL) { - SendMessage(hwnd, WM_SETFONT, (WPARAM) hfont, 0); - hwnd = GetWindow(hwnd, GW_HWNDNEXT); - } - -} /* set_dialog_font */ + while (hwnd != NULL) { + SetWindowFont(hwnd, hfont, 0); + hwnd = GetWindow(hwnd, GW_HWNDNEXT); + } +} -/*+ +/* * Function: Trim leading and trailing white space from a string. * * Parameters: * s - the string to trim. */ void -trim ( - char *s) +trim(char *s) { - int l; - int i; + int l; + int i; - for (i = 0; s[i]; i++) - if (s[i] != ' ' && s[i] != '\t') - break; + for (i = 0 ; s[i] ; i++) + if (s[i] != ' ' && s[i] != '\t') + break; - l = strlen(&s[i]); - memmove(s, &s[i], l + 1); + l = strlen(&s[i]); + memmove(s, &s[i], l + 1); - for (l--; l >= 0; l--) { - if (s[l] != ' ' && s[l] != '\t') - break; - } - s[l + 1] = 0; - -} /* trim */ + for (l--; l >= 0; l--) { + if (s[l] != ' ' && s[l] != '\t') + break; + } + s[l + 1] = 0; +} -/*+ +/* * Function: This routine figures out the current time epoch and * returns the conversion factor. It exists because Microloss * screwed the pooch on the time() and _ftime() calls in its release * 7.0 libraries. They changed the epoch to Dec 31, 1899! */ time_t -kwin_get_epoch (void) +kwin_get_epoch(void) { - static struct tm jan_1_70 = {0, 0, 0, 1, 0, 70}; - time_t epoch = 0; + static struct tm jan_1_70 = {0, 0, 0, 1, 0, 70}; + time_t epoch = 0; - epoch = -mktime(&jan_1_70); /* Seconds til 1970 localtime */ - epoch += _timezone; /* Seconds til 1970 GMT */ + epoch = -mktime(&jan_1_70); /* Seconds til 1970 localtime */ + epoch += _timezone; /* Seconds til 1970 GMT */ - return epoch; - -} /* kwin_get_epoch */ + return epoch; +} -/*+ +/* * Function: Save the credentials for later restoration. * * Parameters: @@ -325,53 +288,48 @@ kwin_get_epoch (void) * ncred - Returned number of credentials saved. */ static void -push_credentials ( - CREDENTIALS **cp, - char *pname, - char *pinstance, - int *ncred) +push_credentials(CREDENTIALS **cp, char *pname, char *pinstance, int *ncred) { #ifdef KRB4 - int i; - char service[ANAME_SZ]; - char instance[INST_SZ]; - char realm[REALM_SZ]; - CREDENTIALS *c; + int i; + char service[ANAME_SZ]; + char instance[INST_SZ]; + char realm[REALM_SZ]; + CREDENTIALS *c; - if (krb_get_tf_fullname ((char *) 0, pname, pinstance, (char *) 0) != KSUCCESS) { - pname[0] = 0; + if (krb_get_tf_fullname(NULL, pname, pinstance, NULL) != KSUCCESS) { + pname[0] = 0; - pinstance[0] = 0; - } + pinstance[0] = 0; + } - *ncred = krb_get_num_cred(); - if (*ncred <= 0) - return; + *ncred = krb_get_num_cred(); + if (*ncred <= 0) + return; - c= malloc(*ncred * sizeof(CREDENTIALS)); - assert(c != NULL); - if (c == NULL) { - *ncred = 0; + c= malloc(*ncred * sizeof(CREDENTIALS)); + assert(c != NULL); + if (c == NULL) { + *ncred = 0; - return; - } + return; + } - for (i = 0; i < *ncred; i++) { - krb_get_nth_cred(service, instance, realm, i + 1); - krb_get_cred(service, instance, realm, &c[i]); - } + for (i = 0; i < *ncred; i++) { + krb_get_nth_cred(service, instance, realm, i + 1); + krb_get_cred(service, instance, realm, &c[i]); + } - *cp = c; + *cp = c; #endif #ifdef KRB5 /* FIXME */ - return; + return; #endif - -} /* push_credentials */ +} -/*+ +/* * Function: Restore the saved credentials. * * c - Pointer to saved credential cache. @@ -383,2057 +341,1247 @@ push_credentials ( * ncred - Number of credentials saved. */ static void -pop_credentials ( - CREDENTIALS *c, - char *pname, - char *pinstance, - int ncred) +pop_credentials(CREDENTIALS *c, char *pname, char *pinstance, int ncred) { #ifdef KRB4 - int i; + int i; - if (pname[0]) - in_tkt(pname, pinstance); - else - dest_tkt(); + if (pname[0]) + in_tkt(pname, pinstance); + else + dest_tkt(); - if (ncred <= 0) - return; + if (ncred <= 0) + return; - for (i = 0; i < ncred; i++) { - krb_save_credentials(c[i].service, c[i].instance, c[i].realm, - c[i].session, c[i].lifetime, c[i].kvno, &(c[i].ticket_st), - c[i].issue_date); - } + for (i = 0; i < ncred; i++) { + krb_save_credentials(c[i].service, c[i].instance, c[i].realm, + c[i].session, c[i].lifetime, c[i].kvno, + &(c[i].ticket_st), + c[i].issue_date); + } - free(c); + free(c); #endif #ifdef KRB5 /* FIXME */ - return; + return; #endif - -} /* pop_credentials */ +} -/*+ - * Function: Changes the password. +/* + * Function: Save most recent login triplets for placement on the + * bottom of the file menu. * * Parameters: - * hwnd - the current window from which command was invoked. - * - * name - name of user to change password for - * - * instance - instance of user to change password for - * - * realm - realm in which to change password + * hwnd - the handle of the window containing the menu to edit. * - * oldpw - the old password + * name - A login name to save in the recent login list * - * newpw - the new password to change to + * instance - An instance to save in the recent login list * - * Returns: TRUE if change took place, FALSE otherwise. + * realm - A realm to save in the recent login list */ -static BOOL -change_password ( - HWND hwnd, - char *name, - char *instance, - char *realm, - char *oldpw, - char *newpw) +static void +kwin_push_login(HWND hwnd, char *name, char *instance, char *realm) { -#ifdef KRB4 - des_cblock new_key; - char *ret_st; - int krc; - char *p; - CREDENTIALS *c; - int ncred; - char pname[ANAME_SZ]; - char pinstance[INST_SZ]; - - push_credentials(&c, pname, pinstance, &ncred); - krc = krb_get_pw_in_tkt( - name, instance, realm, PWSERV_NAME, KADM_SINST, 1, oldpw); - - if (krc != KSUCCESS) { - if (krc == INTK_BADPW) - p = "Old password is incorrect"; - else - p = krb_get_err_text(krc); - pop_credentials(c, pname, pinstance, ncred); - MessageBox(hwnd, p, "", MB_OK | MB_ICONEXCLAMATION); - - return FALSE; - } + HMENU hmenu; + int i; + int id; + int ctitems; + char fullname[MAX_K_NAME_SZ + 3]; + char menuitem[MAX_K_NAME_SZ + 3]; + BOOL rc; - krc = kadm_init_link(PWSERV_NAME, KRB_MASTER, realm); + strcpy(fullname, "&x "); + strcat(fullname, name); + strcat(fullname, "."); + strcat(fullname, instance); + strcat(fullname, "@"); + strcat(fullname, realm); - if (krc != KSUCCESS) { - pop_credentials(c, pname, pinstance, ncred); - MessageBox(hwnd, kadm_get_err_text(krc), "", MB_OK | MB_ICONEXCLAMATION); + hmenu = GetMenu(hwnd); + assert(hmenu != NULL); - return FALSE; - } + hmenu = GetSubMenu(hmenu, 0); + assert(hmenu != NULL); - des_string_to_key(newpw, new_key); - krc = kadm_change_pw2(new_key, newpw, &ret_st); - pop_credentials(c, pname, pinstance, ncred); + ctitems = GetMenuItemCount(hmenu); + assert(ctitems >= FILE_MENU_ITEMS); - if (ret_st != NULL) - free(ret_st); + if (ctitems == FILE_MENU_ITEMS) { + rc = AppendMenu(hmenu, MF_SEPARATOR, 0, NULL); + assert(rc); - if (krc != KSUCCESS) { - MessageBox(hwnd, kadm_get_err_text(krc), "", MB_OK | MB_ICONEXCLAMATION); + ctitems++; + } - return FALSE; - } + for (i = FILE_MENU_ITEMS + 1; i < ctitems; i++) { + GetMenuString(hmenu, i, menuitem, sizeof(menuitem), MF_BYPOSITION); - return TRUE; -#endif + if (strcmp(&fullname[3], &menuitem[3]) == 0) { + rc = RemoveMenu(hmenu, i, MF_BYPOSITION); + assert(rc); -#ifdef KRB5 /* FIXME */ - char *msg; // Message string - krb5_error_code code; // Return value - code = k5_change_password (k5_context, name, realm, oldpw, newpw, &msg); - - if (msg != NULL) { - MessageBox (NULL, msg, NULL, MB_ICONEXCLAMATION); - } else if (code) { - if (code == KRB5KRB_AP_ERR_BAD_INTEGRITY) - MessageBox (NULL, "Password incorrect", NULL, MB_ICONEXCLAMATION); - else - com_err (NULL, code, "while changing password."); - } + ctitems--; - return (code == 0); + break; + } + } -#endif /* KRB5 */ + rc = InsertMenu(hmenu, FILE_MENU_ITEMS + 1, MF_BYPOSITION, 1, fullname); + assert(rc); + + ctitems++; + if (ctitems - FILE_MENU_ITEMS - 1 > FILE_MENU_MAX_LOGINS) { + RemoveMenu(hmenu, ctitems - 1, MF_BYPOSITION); + + ctitems--; + } + + id = 0; + for (i = FILE_MENU_ITEMS + 1; i < ctitems; i++) { + GetMenuString(hmenu, i, menuitem, sizeof(menuitem), MF_BYPOSITION); + + rc = RemoveMenu(hmenu, i, MF_BYPOSITION); + assert(rc); + + menuitem[1] = '1' + id; + rc = InsertMenu(hmenu, i, MF_BYPOSITION, IDM_FIRST_LOGIN + id, menuitem); + assert(rc); + + id++; + } } -/*+ - * Function: Process WM_COMMAND messages for the password dialog. + + +/* + * Function: Initialize the logins on the file menu form the KERBEROS.INI + * file. * * Parameters: - * hwnd - the window recieving the message. - * - * wparam - id of the command item - * - * lparam - LOWORD=hwnd of control, HIWORD=notification message. - * - * Returns: TRUE if initialized sucessfully, false otherwise. + * hwnd - handle of the dialog containing the file menu. */ -static LONG -password_command ( - HWND hwnd, - WPARAM wparam, - LPARAM lparam) +static void +kwin_init_file_menu(HWND hwnd) { - char name[ANAME_SZ]; - char instance[INST_SZ]; - char realm[REALM_SZ]; - char oldpw[MAX_KPW_LEN]; - char newpw1[MAX_KPW_LEN]; - char newpw2[MAX_KPW_LEN]; - HCURSOR hcursor; - BOOL b; - int id; - - if (HIWORD(lparam) != BN_CLICKED) { - GetDlgItemText(hwnd, IDD_PASSWORD_NAME, name, sizeof(name)); - trim(name); - GetDlgItemText(hwnd, IDD_PASSWORD_REALM, realm, sizeof(realm)); - trim(realm); - GetDlgItemText(hwnd, IDD_OLD_PASSWORD, oldpw, sizeof(oldpw)); - GetDlgItemText(hwnd, IDD_NEW_PASSWORD1, newpw1, sizeof(newpw1)); - GetDlgItemText(hwnd, IDD_NEW_PASSWORD2, newpw2, sizeof(newpw2)); - b = strlen(name) && strlen(realm) && strlen(oldpw) && - strlen(newpw1) && strlen(newpw2); - EnableWindow(GetDlgItem(hwnd, IDOK), b); - id = (b) ? IDOK : IDD_PASSWORD_CR; - SendMessage(hwnd, DM_SETDEFID, id, 0); - - return FALSE; - } + HMENU hmenu; + int i; + char login[sizeof(INI_LOGIN)+1]; + char menuitem[MAX_K_NAME_SZ + 3]; + int id; + BOOL rc; + + hmenu = GetMenu(hwnd); + assert(hmenu != NULL); + + hmenu = GetSubMenu(hmenu, 0); + assert(hmenu != NULL); + + strcpy(login, INI_LOGIN); + id = 0; + for (i = 0; i < FILE_MENU_MAX_LOGINS; i++) { + login[sizeof(INI_LOGIN) - 1] = '1' + i; + login[sizeof(INI_LOGIN)] = 0; + GetPrivateProfileString(INI_RECENT_LOGINS, login, "", + &menuitem[3], sizeof(menuitem) - 3, KERBEROS_INI); + if (!menuitem[3]) + continue; + + menuitem[0] = '&'; + menuitem[1] = '1' + id; + menuitem[2] = ' '; + + if (id == 0) { + rc = AppendMenu(hmenu, MF_SEPARATOR, 0, NULL); + assert(rc); + } + AppendMenu(hmenu, MF_STRING, IDM_FIRST_LOGIN + id, menuitem); - switch (wparam) { - case IDOK: - if (isblocking) - return TRUE; - - GetDlgItemText(hwnd, IDD_PASSWORD_NAME, name, sizeof(name)); - trim(name); - GetDlgItemText(hwnd, IDD_PASSWORD_INSTANCE, instance, sizeof(instance)); - trim(instance); - GetDlgItemText(hwnd, IDD_PASSWORD_REALM, realm, sizeof(realm)); - trim(realm); - GetDlgItemText(hwnd, IDD_OLD_PASSWORD, oldpw, sizeof(oldpw)); - GetDlgItemText(hwnd, IDD_NEW_PASSWORD1, newpw1, sizeof(newpw1)); - GetDlgItemText(hwnd, IDD_NEW_PASSWORD2, newpw2, sizeof(newpw2)); - - if (strcmp(newpw1, newpw2) != 0) { - MessageBox(hwnd, "The two passwords you entered don't match!", "", - MB_OK | MB_ICONEXCLAMATION); - SetDlgItemText(hwnd, IDD_NEW_PASSWORD1, ""); - SetDlgItemText(hwnd, IDD_NEW_PASSWORD2, ""); - PostMessage(hwnd, WM_NEXTDLGCTL, - GetDlgItem(hwnd, IDD_NEW_PASSWORD1), MAKELONG(1, 0)); - - return TRUE; - } - - hcursor = SetCursor(LoadCursor(NULL, IDC_WAIT)); - start_blocking_hook(BLOCK_MAX_SEC); - - if (change_password(hwnd, name, instance, realm, oldpw, newpw1)) - EndDialog(hwnd, IDOK); - else - PostMessage(hwnd, WM_NEXTDLGCTL, - GetDlgItem(hwnd, IDD_OLD_PASSWORD), MAKELONG(1, 0)); - - end_blocking_hook(); - SetCursor(hcursor); - - return TRUE; - - case IDCANCEL: - if (isblocking) - WSACancelBlockingCall(); - EndDialog(hwnd, IDCANCEL); - - return TRUE; - - case IDD_PASSWORD_CR: - id = GetDlgCtrlID(GetFocus()); - assert(id != 0); - - if (id == IDD_NEW_PASSWORD2) - PostMessage(hwnd, WM_NEXTDLGCTL, - GetDlgItem(hwnd, IDD_PASSWORD_NAME), MAKELONG(1, 0)); - else - PostMessage(hwnd, WM_NEXTDLGCTL, 0, 0); - - return TRUE; + id++; + } +} - } - return FALSE; +/* + * Function: Save the items on the file menu in the KERBEROS.INI file. + * + * Parameters: + * hwnd - handle of the dialog containing the file menu. + */ +static void +kwin_save_file_menu(HWND hwnd) +{ + HMENU hmenu; + int i; + int id; + int ctitems; + char menuitem[MAX_K_NAME_SZ + 3]; + char login[sizeof(INI_LOGIN)+1]; + BOOL rc; + + hmenu = GetMenu(hwnd); + assert(hmenu != NULL); + + hmenu = GetSubMenu(hmenu, 0); + assert(hmenu != NULL); + + strcpy(login, INI_LOGIN); + ctitems = GetMenuItemCount(hmenu); + assert(ctitems >= FILE_MENU_ITEMS); + + id = 0; + for (i = FILE_MENU_ITEMS + 1; i < ctitems; i++) { + GetMenuString(hmenu, i, menuitem, sizeof(menuitem), MF_BYPOSITION); + login[sizeof(INI_LOGIN) - 1] = '1' + id; + login[sizeof(INI_LOGIN)] = 0; + + rc = WritePrivateProfileString(INI_RECENT_LOGINS, login, + &menuitem[3], KERBEROS_INI); + assert(rc); + + id++; + } +} -} /* password_command */ -/*+ - * Function: Process WM_INITDIALOG messages for the password dialog. - * Set up all initial dialog values from the parent dialog. +/* + * Function: Given an expiration time, choose an appropriate + * icon to display. * * Parameters: - * hwnd - the window recieving the message. - * - * wparam - handle of the control for focus. - * - * lparam - lparam from dialog box call. + * expiration time of expiration in time() compatible units * - * Returns: TRUE if we didn't set the focus here, - * FALSE if we did. + * Returns: Handle of icon to display */ -static BOOL -password_initdialog ( - HWND hwnd, - WPARAM wparam, - LPARAM lparam) +HICON +kwin_get_icon(time_t expiration) { - char name[ANAME_SZ]; - char realm[REALM_SZ]; - HWND hwndparent; - int id; - #ifdef KRB4 - char instance[INST_SZ]; - #endif - - center_dialog(hwnd); - set_dialog_font(hwnd, hfontdialog); - - hwndparent = GetParent(hwnd); - assert(hwndparent != NULL); - - GetDlgItemText(hwndparent, IDD_LOGIN_NAME, name, sizeof(name)); - trim(name); - SetDlgItemText(hwnd, IDD_PASSWORD_NAME, name); - - #ifdef KRB4 - GetDlgItemText(hwndparent, IDD_LOGIN_INSTANCE, instance, sizeof(instance)); - trim(instance); - SetDlgItemText(hwnd, IDD_PASSWORD_INSTANCE, instance); - #endif - - GetDlgItemText(hwndparent, IDD_LOGIN_REALM, realm, sizeof(realm)); - trim(realm); - SetDlgItemText(hwnd, IDD_PASSWORD_REALM, realm); - - if (strlen(name) == 0) - id = IDD_PASSWORD_NAME; - else if (strlen(realm) == 0) - id = IDD_PASSWORD_REALM; - else - id = IDD_OLD_PASSWORD; - - SetFocus(GetDlgItem(hwnd, id)); - - return FALSE; - -} /* password_initdialog */ + int ixicon; + time_t dt; + + dt = expiration - time(NULL); + dt = dt / 60; /* convert to minutes */ + if (dt <= 0) + ixicon = IDI_EXPIRED - IDI_FIRST_CLOCK; + else if (dt > 60) + ixicon = IDI_TICKET - IDI_FIRST_CLOCK; + else + ixicon = (int)(dt / 5); + + return kwin_icons[ixicon]; +} -/*+ - * Function: Process dialog specific messages for the password dialog. +/* + * Function: Intialize name fields in the Kerberos dialog. * * Parameters: - * hwnd - the dialog receiving the message. - * - * message - the message to process. - * - * wparam - wparam of the message. - * - * lparam - lparam of the message. + * hwnd - the window recieving the message. * - * Returns: TRUE if message handled locally, FALSE otherwise. + * fullname - the full kerberos name to initialize with */ -static BOOL CALLBACK -password_dlg_proc ( - HWND hwnd, - UINT message, - WPARAM wparam, - LPARAM lparam) +void +kwin_init_name(HWND hwnd, char *fullname) { - LRESULT rc; - - switch (message) { - - case WM_INITDIALOG: - return password_initdialog(hwnd, wparam, lparam); + char name[ANAME_SZ]; + char instance[INST_SZ]; + char realm[REALM_SZ]; + int krc; +#ifdef KRB5 + krb5_error_code code; + char *ptr; +#endif - case WM_COMMAND: - password_command(hwnd, wparam, lparam); - return (BOOL) rc; + if (fullname == NULL || fullname[0] == 0) { +#ifdef KRB4 + strcpy(name, krb_get_default_user()); + GetPrivateProfileString(INI_DEFAULTS, INI_INSTANCE, "", + instance, sizeof(instance), KERBEROS_INI); + krc = krb_get_lrealm(realm, 1); + if (krc != KSUCCESS) + realm[0] = 0; + GetPrivateProfileString(INI_DEFAULTS, INI_REALM, realm, + realm, sizeof(realm), KERBEROS_INI); +#endif /* KRB4 */ - case WM_SETCURSOR: - if (isblocking) { - SetCursor(LoadCursor(NULL, IDC_WAIT)); - SetWindowLong(hwnd, DWL_MSGRESULT, TRUE); +#ifdef KRB5 + GetPrivateProfileString(INI_DEFAULTS, INI_USER, "", + name, sizeof(name), KERBEROS_INI); + + *realm = '\0'; + code = krb5_get_default_realm(k5_context, &ptr); + if (!code) { + strcpy(realm, ptr); + /* free(ptr); XXX */ + } + GetPrivateProfileString(INI_DEFAULTS, INI_REALM, realm, + realm, sizeof(realm), KERBEROS_INI); +#endif /* KRB5 */ - return TRUE; - } - break; - } + } else { +#ifdef KRB4 + kname_parse(name, instance, realm, fullname); + SetDlgItemText(hwnd, IDD_LOGIN_INSTANCE, instance); +#endif - return FALSE; +#ifdef KRB5 + krc = k5_kname_parse(name, realm, fullname); + *instance = '\0'; +#endif + } -} /* password_dlg_proc */ + SetDlgItemText(hwnd, IDD_LOGIN_NAME, name); + SetDlgItemText(hwnd, IDD_LOGIN_REALM, realm); +} -/*+ - * Function: Display and process the password dialog. +/* + * Function: Set the focus to the name control if no name + * exists, the realm control if no realm exists or the + * password control. Uses PostMessage not SetFocus. * * Parameters: - * hwnd - the parent window for the dialog - * - * Returns: TRUE if the dialog completed successfully, FALSE otherwise. + * hwnd - the Window handle of the parent. */ -static BOOL -password_dialog ( - HWND hwnd) +void +kwin_set_default_focus(HWND hwnd) { - DLGPROC dlgproc; - int rc; - - dlgproc = (FARPROC) MakeProcInstance(password_dlg_proc, hinstance); - assert(dlgproc != NULL); - - if (dlgproc == NULL) - return FALSE; + char name[ANAME_SZ]; + char realm[REALM_SZ]; + HWND hwnditem; - rc = DialogBox(hinstance, MAKEINTRESOURCE(ID_PASSWORD), hwnd, dlgproc); - assert(rc != -1); + GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name)); - FreeProcInstance((FARPROC) dlgproc); + trim(name); + if (strlen(name) <= 0) + hwnditem = GetDlgItem(hwnd, IDD_LOGIN_NAME); + else { + GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm)); + trim(realm); - return rc == IDOK; + if (strlen(realm) <= 0) + hwnditem = GetDlgItem(hwnd, IDD_LOGIN_REALM); + else + hwnditem = GetDlgItem(hwnd, IDD_LOGIN_PASSWORD); + } -} /* password_dialog */ + PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)hwnditem, MAKELONG(1, 0)); +} -/*+ - * Function: Process WM_INITDIALOG messages for the options dialog. - * Set up all initial dialog values from the KERBEROS_INI file. - * - * Parameters: - * hwnd - the window recieving the message. - * - * wparam - handle of the control for focus. - * - * lparam - lparam from dialog box call. - * - * Returns: TRUE if we didn't set the focus here, - * FALSE if we did. - */ -static LONG -opts_initdialog ( - HWND hwnd, - WPARAM wparam, - LPARAM lparam) -{ - char wdir[FILENAME_MAX]; - char defname[FILENAME_MAX]; - char newname[FILENAME_MAX]; - UINT rc; - int lifetime; - - center_dialog(hwnd); - set_dialog_font(hwnd, hfontdialog); - rc = GetWindowsDirectory(wdir, sizeof(wdir)); - assert(rc > 0); - strcat (wdir, "\\"); - - /* krb.conf file */ - strcpy(defname, wdir); - strcat(defname, DEF_KRB_CONF); - GetPrivateProfileString(INI_FILES, INI_KRB_CONF, defname, - newname, sizeof(newname), KERBEROS_INI); - _strupr(newname); - SetDlgItemText(hwnd, IDD_CONF, newname); - - #ifdef KRB4 - /* krb.realms file */ - strcpy(defname, wdir); - strcat(defname, DEF_KRB_REALMS); - GetPrivateProfileString(INI_FILES, INI_KRB_REALMS, defname, - newname, sizeof(newname), KERBEROS_INI); - _strupr(newname); - SetDlgItemText(hwnd, IDD_REALMS, newname); - #endif /* KRB4 */ - - /* Credential cache file */ - #ifdef KRB5 - strcpy(defname, wdir); - strcat(defname, INI_KRB_CCACHE); - GetPrivateProfileString(INI_FILES, INI_KRB_CCACHE, defname, - ccname, sizeof(ccname), KERBEROS_INI); - _strupr(ccname); - SetDlgItemText(hwnd, IDD_CCACHE, ccname); - #endif /* KRB5 */ - -/* Ticket duration */ - lifetime = GetPrivateProfileInt(INI_OPTIONS, INI_DURATION, - DEFAULT_TKT_LIFE * 5, KERBEROS_INI); - SetDlgItemInt(hwnd, IDD_LIFETIME, lifetime, FALSE); - -/* Expiration action */ - GetPrivateProfileString(INI_EXPIRATION, INI_ALERT, "No", - defname, sizeof(defname), KERBEROS_INI); - alert = _stricmp(defname, "Yes") == 0; - SendDlgItemMessage(hwnd, IDD_ALERT, BM_SETCHECK, alert, 0); - GetPrivateProfileString(INI_EXPIRATION, INI_BEEP, "No", - defname, sizeof(defname), KERBEROS_INI); - beep = _stricmp(defname, "Yes") == 0; - SendDlgItemMessage(hwnd, IDD_BEEP, BM_SETCHECK, beep, 0); - - return TRUE; - -} /* opts_initdialog */ - - -/*+ - * Function: Process WM_COMMAND messages for the options dialog. +/* + * Function: Save the values which live in the KERBEROS.INI file. * * Parameters: - * hwnd - the window recieving the message. - * - * wparam - id of the command item - * - * lparam - LOWORD=hwnd of control, HIWORD=notification message. - * - * Returns: TRUE if initialized sucessfully, false otherwise. + * hwnd - the window handle of the dialog containing fields to + * be saved */ -static LONG -opts_command ( - HWND hwnd, - WPARAM wparam, - LPARAM lparam) +static void +kwin_save_name(HWND hwnd) { - char wdir[FILENAME_MAX]; - char defname[FILENAME_MAX]; - char newname[FILENAME_MAX]; - char *p; - BOOL b; - int lifetime; - int rc; - - switch (wparam) { - case IDOK: - rc = GetWindowsDirectory(wdir, sizeof(wdir)); - assert(rc > 0); - strcat(wdir, "\\"); - -/* Ticket duration */ - lifetime = GetDlgItemInt(hwnd, IDD_LIFETIME, &b, FALSE); - - if (!b) { - MessageBox(hwnd, "Lifetime must be a number!", "", MB_OK | MB_ICONEXCLAMATION); - return TRUE; - } - - _itoa(lifetime, defname, 10); - b = WritePrivateProfileString(INI_OPTIONS, INI_DURATION, defname, KERBEROS_INI); - assert(b); - -/* krb.conf file */ - GetDlgItemText(hwnd, IDD_CONF, newname, sizeof(newname)); - trim(newname); - strcpy(defname, wdir); - strcat(defname, DEF_KRB_CONF); - p = (*newname && _stricmp(newname, defname)) ? newname : NULL; - b = WritePrivateProfileString(INI_FILES, INI_KRB_CONF, p, KERBEROS_INI); - assert(b); - -/* krb.realms file */ - #ifdef KRB4 - GetDlgItemText(hwnd, IDD_REALMS, newname, sizeof(newname)); - trim(newname); - strcpy(defname, wdir); - strcat(defname, DEF_KRB_REALMS); - p = (*newname && _stricmp(newname, defname)) ? newname : NULL; - b = WritePrivateProfileString(INI_FILES, INI_KRB_REALMS, p, KERBEROS_INI); - assert(b); - #endif /* KRB4 */ - -/* Credential cache file */ - #ifdef KRB5 - GetDlgItemText(hwnd, IDD_CCACHE, newname, sizeof(newname)); - trim(newname); - strcpy(defname, wdir); - strcat(defname, "krb5cc"); - if (*newname == '\0') // For detecting name change - strcpy (newname, defname); - p = (*newname && _stricmp(newname, defname)) ? newname : NULL; - b = WritePrivateProfileString(INI_FILES, INI_KRB_CCACHE, p, KERBEROS_INI); - assert(b); - - if (strcmp (ccname, newname)) { // Did we change ccache file? - krb5_error_code code; - krb5_ccache cctemp; - - code = k5_init_ccache (&cctemp); - if (code) { // Problem opening new one? - com_err (NULL, code, - "while changing ccache.\r\nRestoring old ccache."); - b = WritePrivateProfileString(INI_FILES, INI_KRB_CCACHE, - ccname, KERBEROS_INI); - } else { - code = krb5_cc_close (k5_context, k5_ccache); - k5_ccache = cctemp; // Copy new into old - if (k5_name_from_ccache (k5_ccache)) { - kwin_init_name (GetParent(hwnd), ""); - kwin_set_default_focus(GetParent(hwnd)); - } - ticket_init_list (GetDlgItem (GetParent(hwnd), - IDD_TICKET_LIST)); - } - } - - #endif /* KRB5 */ - -/* Expiration action */ - alert = (BOOL) SendDlgItemMessage(hwnd, IDD_ALERT, BM_GETCHECK, 0, 0); - p = (alert) ? "Yes" : "No"; - b = WritePrivateProfileString(INI_EXPIRATION, INI_ALERT, p, KERBEROS_INI); - assert(b); - - beep = (BOOL) SendDlgItemMessage(hwnd, IDD_BEEP, BM_GETCHECK, 0, 0); - p = (beep) ? "Yes" : "No"; - b = WritePrivateProfileString(INI_EXPIRATION, INI_BEEP, p, KERBEROS_INI); - assert(b); - - EndDialog(hwnd, IDOK); - - return TRUE; - - case IDCANCEL: - EndDialog(hwnd, IDCANCEL); - - return TRUE; - } + char name[ANAME_SZ]; + char instance[INST_SZ]; + char realm[REALM_SZ]; - return FALSE; + GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name)); + trim(name); -} /* opts_command */ +#ifdef KRB4 + krb_set_default_user(name); + GetDlgItemText(hwnd, IDD_LOGIN_INSTANCE, instance, sizeof(instance)); + trim(instance); + WritePrivateProfileString(INI_DEFAULTS, INI_INSTANCE, + instance, KERBEROS_INI); +#endif +#ifdef KRB5 + WritePrivateProfileString(INI_DEFAULTS, INI_USER, name, KERBEROS_INI); + *instance = '\0'; +#endif -/*+ - * Function: Process dialog specific messages for the opts dialog. - * - * Parameters: - * hwnd - the dialog receiving the message. - * - * message - the message to process. - * - * wparam - wparam of the message. - * - * lparam - lparam of the message. + GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm)); + trim(realm); + WritePrivateProfileString(INI_DEFAULTS, INI_REALM, realm, KERBEROS_INI); + + kwin_push_login(hwnd, name, instance, realm); +} + + +/* + * Function: Process WM_INITDIALOG messages. Set the fonts + * for all items on the dialog and populate the ticket list. + * Also set the default values for user, instance and realm. * - * Returns: TRUE if message handled locally, FALSE otherwise. + * Returns: TRUE if we didn't set the focus here, + * FALSE if we did. */ -static BOOL CALLBACK -opts_dlg_proc ( - HWND hwnd, - UINT message, - WPARAM wparam, - LPARAM lparam) +static BOOL +kwin_initdialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) { - LRESULT rc; + LOGFONT lf; + HDC hdc; + char name[ANAME_SZ]; + + position_dialog(hwnd); + ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST)); + kwin_init_file_menu(hwnd); + kwin_init_name(hwnd, (char *)lParam); + hdc = GetDC(NULL); + assert(hdc != NULL); + + memset(&lf, 0, sizeof(lf)); + lf.lfHeight = -MulDiv(9, GetDeviceCaps(hdc, LOGPIXELSY), 72); + strcpy(lf.lfFaceName, "Arial"); + hfontdialog = CreateFontIndirect(&lf); + assert(hfontdialog != NULL); + + if (hfontdialog == NULL) { + ReleaseDC(NULL, hdc); - switch (message) { + return TRUE; + } - case WM_INITDIALOG: - rc = opts_initdialog(hwnd, wparam, lparam); + lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72); + hfonticon = CreateFontIndirect(&lf); + assert(hfonticon != NULL); - return (BOOL) rc; + if (hfonticon == NULL) { + ReleaseDC(NULL, hdc); - case WM_COMMAND: - rc = opts_command(hwnd, wparam, lparam); + return TRUE; + } - return (BOOL) rc; - } + ReleaseDC(NULL, hdc); - return FALSE; + set_dialog_font(hwnd, hfontdialog); + GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name)); + trim(name); -} /* opts_dlg_proc */ + if (strlen(name) > 0) + SetFocus(GetDlgItem(hwnd, IDD_LOGIN_PASSWORD)); + else + SetFocus(GetDlgItem(hwnd, IDD_LOGIN_NAME)); + ShowWindow(hwnd, dlgncmdshow); -/*+ - * Function: Display and process the options dialog. - * - * Parameters: - * hwnd - the parent window for the dialog - * - * Returns: TRUE if the dialog completed successfully, FALSE otherwise. + kwin_timer_id = SetTimer(hwnd, 1, KWIN_UPDATE_PERIOD, NULL); + assert(kwin_timer_id != 0); + + return FALSE; +} + + +/* + * Function: Process WM_DESTROY messages. Delete the font + * created for use by the controls. */ -static BOOL -opts_dialog ( - HWND hwnd) +static void +kwin_destroy(HWND hwnd) { - DLGPROC dlgproc; - int rc; - - dlgproc = (FARPROC) MakeProcInstance(opts_dlg_proc, hinstance); - assert(dlgproc != NULL); + char position[256]; + RECT r; + BOOL b; - if (dlgproc == NULL) - return FALSE; + ticket_destroy(GetDlgItem(hwnd, IDD_TICKET_LIST)); - rc = DialogBox(hinstance, MAKEINTRESOURCE(ID_OPTS), hwnd, dlgproc); - assert(rc != -1); + if (hfontdialog != NULL) + DeleteObject(hfontdialog); - FreeProcInstance((FARPROC) dlgproc); + if (hfonticon != NULL) + DeleteObject(hfonticon); - return rc == IDOK; + kwin_save_file_menu(hwnd); + GetWindowRect(hwnd, &r); + sprintf(position, "[%d,%d,%d,%d]", r.left, r.top, + r.right - r.left, r.bottom - r.top); + b = WritePrivateProfileString(INI_DEFAULTS, INI_POSITION, + position, KERBEROS_INI); + assert(b); -} /* opts_dialog */ + KillTimer(hwnd, kwin_timer_id); +} -/*+ - * Function: Save most recent login triplets for placement on the - * bottom of the file menu. +/* + * Function: Retrievs item WindowRect in hwnd client + * coordiate system. * * Parameters: - * hwnd - the handle of the window containing the menu to edit. - * - * name - A login name to save in the recent login list + * hwnditem - the item to retrieve * - * instance - An instance to save in the recent login list + * item - dialog in which into which to translate * - * realm - A realm to save in the recent login list + * r - rectangle returned */ static void -kwin_push_login ( - HWND hwnd, - char *name, - char *instance, - char *realm) +windowrect(HWND hwnditem, HWND hwnd, RECT *r) { - HMENU hmenu; - int i; - int id; - int ctitems; - char fullname[MAX_K_NAME_SZ + 3]; - char menuitem[MAX_K_NAME_SZ + 3]; - BOOL rc; - - strcpy(fullname, "&x "); - strcat(fullname, name); - strcat(fullname, "."); - strcat(fullname, instance); - strcat(fullname, "@"); - strcat(fullname, realm); - - hmenu = GetMenu(hwnd); - assert(hmenu != NULL); - - hmenu = GetSubMenu(hmenu, 0); - assert(hmenu != NULL); - - ctitems = GetMenuItemCount(hmenu); - assert(ctitems >= FILE_MENU_ITEMS); - - if (ctitems == FILE_MENU_ITEMS) { - rc = AppendMenu(hmenu, MF_SEPARATOR, 0, NULL); - assert(rc); - - ctitems++; - } - - for (i = FILE_MENU_ITEMS + 1; i < ctitems; i++) { - GetMenuString(hmenu, i, menuitem, sizeof(menuitem), MF_BYPOSITION); - - if (strcmp(&fullname[3], &menuitem[3]) == 0) { - rc = RemoveMenu(hmenu, i, MF_BYPOSITION); - assert(rc); + GetWindowRect(hwnditem, r); + ScreenToClient(hwnd, (LPPOINT)&(r->left)); + ScreenToClient(hwnd, (LPPOINT)&(r->right)); +} - ctitems--; - break; - } - } - - rc = InsertMenu(hmenu, FILE_MENU_ITEMS + 1, MF_BYPOSITION, 1, fullname); - assert(rc); - - ctitems++; - if (ctitems - FILE_MENU_ITEMS - 1 > FILE_MENU_MAX_LOGINS) { - RemoveMenu(hmenu, ctitems - 1, MF_BYPOSITION); - - ctitems--; - } - - id = 0; - for (i = FILE_MENU_ITEMS + 1; i < ctitems; i++) { - GetMenuString(hmenu, i, menuitem, sizeof(menuitem), MF_BYPOSITION); - - rc = RemoveMenu(hmenu, i, MF_BYPOSITION); - assert(rc); - - menuitem[1] = '1' + id; - rc = InsertMenu(hmenu, i, MF_BYPOSITION, IDM_FIRST_LOGIN + id, menuitem); - assert(rc); - - id++; - } - -} /* kwin_push_login */ - - -/*+ - * Function: Initialize the logins on the file menu form the KERBEROS.INI - * file. - * - * Parameters: - * hwnd - handle of the dialog containing the file menu. +/* + * Function: Process WM_SIZE messages. Resize the + * list and position the buttons attractively. */ static void -kwin_init_file_menu ( - HWND hwnd) +kwin_size(HWND hwnd, UINT state, int cxdlg, int cydlg) { - HMENU hmenu; - int i; - char login[sizeof(INI_LOGIN)+1]; - char menuitem[MAX_K_NAME_SZ + 3]; - int id; - BOOL rc; - - hmenu = GetMenu(hwnd); - assert(hmenu != NULL); - - hmenu = GetSubMenu(hmenu, 0); - assert(hmenu != NULL); - - strcpy(login, INI_LOGIN); - id = 0; - for (i = 0; i < FILE_MENU_MAX_LOGINS; i++) { - login[sizeof(INI_LOGIN) - 1] = '1' + i; - login[sizeof(INI_LOGIN)] = 0; - GetPrivateProfileString(INI_RECENT_LOGINS, login, "", - &menuitem[3], sizeof(menuitem) - 3, KERBEROS_INI); - if (!menuitem[3]) - continue; - - menuitem[0] = '&'; - menuitem[1] = '1' + id; - menuitem[2] = ' '; - - if (id == 0) { - rc = AppendMenu(hmenu, MF_SEPARATOR, 0, NULL); - assert(rc); - } - AppendMenu(hmenu, MF_STRING, IDM_FIRST_LOGIN + id, menuitem); - - id++; - } - -} /* kwin_init_file_menu */ - +#define listgap 8 + RECT r; + RECT rdlg; + int hmargin, vmargin; + HWND hwnditem; + int cx, cy; + int i; + int titlebottom; + int editbottom; + int listbottom; + int gap; + int left; + int titleleft[IDD_MAX_TITLE - IDD_MIN_TITLE + 1]; + + if (state == SIZE_MINIMIZED) + return; -/*+ - * Function: Save the items on the file menu in the KERBEROS.INI file. - * - * Parameters: - * hwnd - handle of the dialog containing the file menu. - */ -static void -kwin_save_file_menu ( - HWND hwnd) -{ - HMENU hmenu; - int i; - int id; - int ctitems; - char menuitem[MAX_K_NAME_SZ + 3]; - char login[sizeof(INI_LOGIN)+1]; - BOOL rc; - - hmenu = GetMenu(hwnd); - assert(hmenu != NULL); - - hmenu = GetSubMenu(hmenu, 0); - assert(hmenu != NULL); - - strcpy(login, INI_LOGIN); - ctitems = GetMenuItemCount(hmenu); - assert(ctitems >= FILE_MENU_ITEMS); - - id = 0; - for (i = FILE_MENU_ITEMS + 1; i < ctitems; i++) { - GetMenuString(hmenu, i, menuitem, sizeof(menuitem), MF_BYPOSITION); - login[sizeof(INI_LOGIN) - 1] = '1' + id; - login[sizeof(INI_LOGIN)] = 0; - - rc = WritePrivateProfileString(INI_RECENT_LOGINS, login, &menuitem[3], KERBEROS_INI); - assert(rc); - - id++; - } + GetClientRect(hwnd, &rdlg); -} /* kwin_save_file_menu */ + /* + * The ticket list title + */ + hwnditem = GetDlgItem(hwnd, IDD_TICKET_LIST_TITLE); + if (hwnditem == NULL) + return; + windowrect(hwnditem, hwnd, &r); + hmargin = r.left; + vmargin = r.top; + cx = cxdlg - 2 * hmargin; + cy = r.bottom - r.top; + MoveWindow(hwnditem, r.left, r.top, cx, cy, TRUE); -/*+ - * Function: Given an expiration time, choose an appropriate - * icon to display. - * - * Parameters: - * expiration time of expiration in time() compatible units - * - * Returns: Handle of icon to display - */ -HICON -kwin_get_icon ( - time_t expiration) -{ - int ixicon; - time_t dt; + /* + * The buttons + */ + cx = 0; - dt = expiration - time(NULL); - dt = dt / 60; /* convert to minutes */ - if (dt <= 0) - ixicon = IDI_EXPIRED - IDI_FIRST_CLOCK; - else if (dt > 60) - ixicon = IDI_TICKET - IDI_FIRST_CLOCK; - else - ixicon = (int) (dt / 5); + for (i = IDD_MIN_BUTTON; i <= IDD_MAX_BUTTON; i++) { + hwnditem = GetDlgItem(hwnd, i); + windowrect(hwnditem, hwnd, &r); + if (i == IDD_MIN_BUTTON) + hmargin = r.left; - return kwin_icons[ixicon]; + cx += r.right - r.left; + } -} /* kwin_get_icon */ + gap = (cxdlg - 2 * hmargin - cx) / (IDD_MAX_BUTTON - IDD_MIN_BUTTON); + left = hmargin; + for (i = IDD_MIN_BUTTON; i <= IDD_MAX_BUTTON; i++) { + hwnditem = GetDlgItem(hwnd, i); + windowrect(hwnditem, hwnd, &r); + editbottom = -r.top; + cx = r.right - r.left; + cy = r.bottom - r.top; + r.top = rdlg.bottom - vmargin - cy; + MoveWindow(hwnditem, left, r.top, cx, cy, TRUE); + + left += cx + gap; + } + + /* + * Edit fields: stretch boxes, keeping the gap between boxes equal to + * what it was on entry. + */ + editbottom += r.top; + + hwnditem = GetDlgItem(hwnd, IDD_MIN_EDIT); + windowrect(hwnditem, hwnd, &r); + gap = r.right; + hmargin = r.left; + editbottom += r.bottom; + titlebottom = -r.top; + + hwnditem = GetDlgItem(hwnd, IDD_MIN_EDIT + 1); + windowrect(hwnditem, hwnd, &r); + gap = r.left - gap; + + cx = cxdlg - 2 * hmargin - (IDD_MAX_EDIT - IDD_MIN_EDIT) * gap; + cx = cx / (IDD_MAX_EDIT - IDD_MIN_EDIT + 1); + left = hmargin; + + for (i = IDD_MIN_EDIT; i <= IDD_MAX_EDIT; i++) { + hwnditem = GetDlgItem(hwnd, i); + windowrect(hwnditem, hwnd, &r); + cy = r.bottom - r.top; + r.top = editbottom - cy; + MoveWindow(hwnditem, left, r.top, cx, cy, TRUE); + titleleft[i-IDD_MIN_EDIT] = left; + + left += cx + gap; + } + + /* + * Edit field titles + */ + titlebottom += r.top; + windowrect(GetDlgItem(hwnd, IDD_MIN_TITLE), hwnd, &r); + titlebottom += r.bottom; + listbottom = -r.top; + + for (i = IDD_MIN_TITLE; i <= IDD_MAX_TITLE; i++) { + hwnditem = GetDlgItem(hwnd, i); + windowrect(hwnditem, hwnd, &r); + cx = r.right - r.left; + cy = r.bottom - r.top; + r.top = titlebottom - cy; + MoveWindow(hwnditem, titleleft[i-IDD_MIN_TITLE], r.top, cx, cy, TRUE); + } + + /* + * The list + */ + listbottom = r.top - listgap; + hwnditem = GetDlgItem(hwnd, IDD_TICKET_LIST); + windowrect(hwnditem, hwnd, &r); + hmargin = r.left; + cx = cxdlg - 2 * hmargin; + cy = listbottom - r.top; + MoveWindow(hwnditem, r.left, r.top, cx, cy, TRUE); +} -/*+ - * Function: Intialize name fields in the Kerberos dialog. - * - * Parameters: - * hwnd - the window recieving the message. - * - * fullname - the full kerberos name to initialize with +/* + * Function: Process WM_GETMINMAXINFO messages */ static void -kwin_init_name ( - HWND hwnd, - char *fullname) -{ - char name[ANAME_SZ]; - char instance[INST_SZ]; - char realm[REALM_SZ]; - int krc; - - if (fullname == NULL || fullname[0] == 0) { - #ifdef KRB4 - strcpy(name, krb_get_default_user()); - GetPrivateProfileString(INI_DEFAULTS, INI_INSTANCE, "", - instance, sizeof(instance), KERBEROS_INI); - krc = krb_get_lrealm(realm, 1); - if (krc != KSUCCESS) - realm[0] = 0; - GetPrivateProfileString(INI_DEFAULTS, INI_REALM, realm, - realm, sizeof(realm), KERBEROS_INI); - #endif - - - #ifdef KRB5 - { - krb5_error_code code; - char *ptr; - - GetPrivateProfileString (INI_DEFAULTS, INI_USER, "", - name, sizeof(name), KERBEROS_INI); - - *realm = '\0'; - code = krb5_get_default_realm (k5_context, &ptr); - if (! code) { - strcpy (realm, ptr); - free (ptr); - } - GetPrivateProfileString(INI_DEFAULTS, INI_REALM, realm, - realm, sizeof(realm), KERBEROS_INI); - } - #endif - - } else { - #ifdef KRB4 - kname_parse(name, instance, realm, fullname); - SetDlgItemText(hwnd, IDD_LOGIN_INSTANCE, instance); - #endif - - #ifdef KRB5 - krc = k5_kname_parse(name, realm, fullname); - *instance = '\0'; - #endif - } - - SetDlgItemText(hwnd, IDD_LOGIN_NAME, name); - SetDlgItemText(hwnd, IDD_LOGIN_REALM, realm); - -} /* kwin_init_name */ - - -/*+ - * Function: Set the focus to the name control if no name - * exists, the realm control if no realm exists or the - * password control. Uses PostMessage not SetFocus. - * - * Parameters: - * hwnd - the Window handle of the parent. - */ -void -kwin_set_default_focus ( - HWND hwnd) +kwin_getminmaxinfo(HWND hwnd, LPMINMAXINFO lpmmi) { - char name[ANAME_SZ]; - char realm[REALM_SZ]; - HWND hwnditem; - - GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name)); - - trim(name); - if (strlen(name) <= 0) - hwnditem = GetDlgItem(hwnd, IDD_LOGIN_NAME); - else { - GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm)); - trim(realm); - - if (strlen(realm) <= 0) - hwnditem = GetDlgItem(hwnd, IDD_LOGIN_REALM); - else - hwnditem = GetDlgItem(hwnd, IDD_LOGIN_PASSWORD); - } + lpmmi->ptMinTrackSize.x = + (KWIN_MIN_WIDTH * LOWORD(GetDialogBaseUnits())) / 4; - PostMessage(hwnd, WM_NEXTDLGCTL, hwnditem, MAKELONG(1, 0)); - -} /* kwin_set_default_focus */ + lpmmi->ptMinTrackSize.y = + (KWIN_MIN_HEIGHT * HIWORD(GetDialogBaseUnits())) / 8; +} -/*+ - * Function: Save the values which live in the KERBEROS.INI file. - * - * Parameters: - * hwnd - the window handle of the dialog containing fields to - * be saved +/* + * Function: Process WM_TIMER messages */ static void -kwin_save_name ( - HWND hwnd) +kwin_timer(HWND hwnd, UINT timer_id) { - char name[ANAME_SZ]; - char instance[INST_SZ]; - char realm[REALM_SZ]; - - GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name)); - trim(name); - - #ifdef KRB4 - krb_set_default_user(name); - GetDlgItemText(hwnd, IDD_LOGIN_INSTANCE, instance, sizeof(instance)); - trim(instance); - WritePrivateProfileString(INI_DEFAULTS, INI_INSTANCE, instance, KERBEROS_INI); - #endif - - #ifdef KRB5 - WritePrivateProfileString(INI_DEFAULTS, INI_USER, name, KERBEROS_INI); - *instance = '\0'; - #endif - - GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm)); - trim(realm); - WritePrivateProfileString(INI_DEFAULTS, INI_REALM, realm, KERBEROS_INI); - - kwin_push_login(hwnd, name, instance, realm); + HWND hwndfocus; + time_t t; + time_t expiration; + BOOL expired; +#ifdef KRB4 + CREDENTIALS c; + int ncred; + int i; + char service[ANAME_SZ]; + char instance[INST_SZ]; + char realm[REALM_SZ]; +#endif +#ifdef KRB5 + krb5_error_code code; + krb5_cc_cursor cursor; + krb5_creds cred; + int n; + char *s; +#endif -} /* kwin_save_name */ + if (timer_id != 1) { + FORWARD_WM_TIMER(hwnd, timer_id, DefDlgProc); + return; + } + expired = FALSE; + ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST)); -/*+ - * Function: Process WM_INITDIALOG messages. Set the fonts - * for all items on the dialog and populate the ticket list. - * Also set the default values for user, instance and realm. - * - * Parameters: - * hwnd - the window recieving the message. - * - * wparam - handle of the control for focus. - * - * lparam - lparam from dialog box call. - * - * Returns: TRUE if we didn't set the focus here, - * FALSE if we did. - */ -static BOOL -kwin_initdialog ( - HWND hwnd, - WPARAM wparam, - LPARAM lparam) -{ - LOGFONT lf; - HDC hdc; - char name[ANAME_SZ]; - - position_dialog(hwnd); - ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST)); - kwin_init_file_menu(hwnd); - kwin_init_name(hwnd, (char *) lparam); - hdc = GetDC(NULL); - assert(hdc != NULL); - - memset(&lf, 0, sizeof(lf)); - lf.lfHeight = -MulDiv(9, GetDeviceCaps(hdc, LOGPIXELSY), 72); - strcpy(lf.lfFaceName, "Arial"); - hfontdialog = CreateFontIndirect(&lf); - assert(hfontdialog != NULL); - - if (hfontdialog == NULL) { - ReleaseDC(NULL, hdc); - - return TRUE; - } - - lf.lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72); - hfonticon = CreateFontIndirect(&lf); - assert(hfonticon != NULL); + if (alerted) { + if (IsIconic(hwnd)) + InvalidateRect(hwnd, NULL, TRUE); - if (hfonticon == NULL) { - ReleaseDC(NULL, hdc); + return; + } - return TRUE; +#ifdef KRB4 + ncred = krb_get_num_cred(); + for (i = 1; i <= ncred; i++) { + krb_get_nth_cred(service, instance, realm, i); + + if (_stricmp(service, "krbtgt") == 0) { + /* Warn if ticket will expire w/i TIME_BUFFER seconds */ + krb_get_cred(service, instance, realm, &c); + expiration = c.issue_date + (long)c.lifetime * 5L * 60L; + t = TIME_BUFFER + time(NULL); + + if (t >= expiration) { + expired = TRUE; + /* Don't alert because of stale tickets */ + if (t >= expiration + KWIN_UPDATE_PERIOD / 1000) { + alerted = TRUE; + + if (IsIconic(hwnd)) + InvalidateRect(hwnd, NULL, TRUE); + return; } + break; + } + } + } +#endif - ReleaseDC(NULL, hdc); - - set_dialog_font(hwnd, hfontdialog); - GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name)); - trim(name); - - if (strlen(name) > 0) - SetFocus(GetDlgItem(hwnd, IDD_LOGIN_PASSWORD)); - else - SetFocus(GetDlgItem(hwnd, IDD_LOGIN_NAME)); - - ShowWindow(hwnd, dlgncmdshow); - kwin_timer_id = SetTimer(hwnd, 1, KWIN_UPDATE_PERIOD, NULL); - assert(kwin_timer_id != 0); - - return FALSE; - -} /* kwin_initdialog */ +#ifdef KRB5 + code = krb5_cc_start_seq_get(k5_context, k5_ccache, &cursor); + while (code == 0) { + code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &cred); + if (code) + break; + n = krb5_princ_component(k5_context, cred.server, 0)->length; + s = krb5_princ_component(k5_context, cred.server, 0)->data; + if (n != KRB5_TGS_NAME_SIZE) + continue; + if (memcmp(KRB5_TGS_NAME, s, KRB5_TGS_NAME_SIZE)) + continue; + + /* Warn if ticket will expire w/i TIME_BUFFER seconds */ + expiration = cred.times.endtime; + t = TIME_BUFFER + time(NULL); + + if (t >= expiration) { + expired = TRUE; + /* Don't alert because of stale tickets */ + if (t >= expiration + KWIN_UPDATE_PERIOD / 1000) { + alerted = TRUE; -/*+ - * Function: Process WM_DESTROY messages. Delete the font - * created for use by the controls. - * - * Parameters: - * hwnd - the window recieving the message. - * - * wparam - none - * - * lparam - none - * - * Returns: 0 - */ -static LONG -kwin_destroy ( - HWND hwnd, - WPARAM wparam, - LPARAM lparam) -{ - char position[256]; - RECT r; - BOOL b; + if (IsIconic(hwnd)) + InvalidateRect(hwnd, NULL, TRUE); + return; + } + break; + } + } + if (code == 0 || code == KRB5_CC_END) + krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor); + +#endif - ticket_destroy(GetDlgItem(hwnd, IDD_TICKET_LIST)); + if (!expired) { + if (IsIconic(hwnd)) + InvalidateRect(hwnd, NULL, TRUE); - if (hfontdialog != NULL) - DeleteObject(hfontdialog); + return; + } - if (hfonticon != NULL) - DeleteObject(hfonticon); + alerted = TRUE; - kwin_save_file_menu(hwnd); - GetWindowRect(hwnd, &r); - sprintf(position, "[%d,%d,%d,%d]", r.left, r.top, - r.right - r.left, r.bottom - r.top); - b = WritePrivateProfileString(INI_DEFAULTS, INI_POSITION, position, KERBEROS_INI); - assert(b); + if (beep) + MessageBeep(MB_ICONEXCLAMATION); - KillTimer(hwnd, kwin_timer_id); + if (alert) { + if (IsIconic(hwnd)) { + hwndfocus = GetFocus(); + ShowWindow(hwnd, SW_RESTORE); + SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, + SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE); + SetFocus(hwndfocus); + } - return 0; + SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, + SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE); -} /* kwin_destroy */ + return; + } + if (IsIconic(hwnd)) + InvalidateRect(hwnd, NULL, TRUE); +} -/*+ - * Function: Retrievs item WindowRect in hwnd client - * coordiate system. - * - * Parameters: - * hwnditem - the item to retrieve - * - * item - dialog in which into which to translate - * - * r - rectangle returned +/* + * Function: Process WM_COMMAND messages */ static void -windowrect ( - HWND hwnditem, - HWND hwnd, - RECT *r) +kwin_command(HWND hwnd, int cid, HWND hwndCtl, UINT codeNotify) { - GetWindowRect(hwnditem, r); - ScreenToClient(hwnd, (LPPOINT) &(r->left)); - ScreenToClient(hwnd, (LPPOINT) &(r->right)); - -} /* windowrect */ + char name[ANAME_SZ]; + char realm[REALM_SZ]; + char password[MAX_KPW_LEN]; + HCURSOR hcursor; + BOOL blogin; + HMENU hmenu; + char menuitem[MAX_K_NAME_SZ + 3]; + char copyright[128]; + int id; +#ifdef KRB4 + char instance[INST_SZ]; + int lifetime; + int krc; +#endif +#ifdef KRB5 + long lifetime; + krb5_error_code code; + krb5_principal principal; + krb5_creds creds; + krb5_principal server; + krb5_int32 sec, usec; +#endif +#ifdef KRB4 + EnableWindow(GetDlgItem(hwnd, IDD_TICKET_DELETE), krb_get_num_cred() > 0); +#endif -/*+ - * Function: Process WM_SIZE messages. Resize the - * list and position the buttons attractively. - * - * Parameters: - * hwnd - the window receiving the message. - * - * wparam - type of resize occuring - * - * lparam - LOWORD=width of client area, - * HIWORD=height of client area. - * - * Returns: 0 - */ -static LONG -kwin_size ( - HWND hwnd, - WPARAM wparam, - LPARAM lparam) -{ - #define listgap 8 - RECT r; - RECT rdlg; - int hmargin, vmargin; - HWND hwnditem; - int cx, cy; - int cxdlg, cydlg; - int i; - int titlebottom; - int editbottom; - int listbottom; - int gap; - int left; - int titleleft[IDD_MAX_TITLE - IDD_MIN_TITLE + 1]; - - if (wparam == SIZE_MINIMIZED) - return 0; - - GetClientRect(hwnd, &rdlg); - cxdlg = LOWORD(lparam); - cydlg = HIWORD(lparam); - - /* - * The ticket list title - */ - hwnditem = GetDlgItem(hwnd, IDD_TICKET_LIST_TITLE); - - if (hwnditem == NULL) - return 0; - - windowrect(hwnditem, hwnd, &r); - hmargin = r.left; - vmargin = r.top; - cx = cxdlg - 2 * hmargin; - cy = r.bottom - r.top; - MoveWindow(hwnditem, r.left, r.top, cx, cy, TRUE); - - /* - * The buttons - */ - cx = 0; - - for (i = IDD_MIN_BUTTON; i <= IDD_MAX_BUTTON; i++) { - hwnditem = GetDlgItem(hwnd, i); - windowrect(hwnditem, hwnd, &r); - if (i == IDD_MIN_BUTTON) - hmargin = r.left; - - cx += r.right - r.left; - } +#ifdef KRB5 + EnableWindow(GetDlgItem(hwnd, IDD_TICKET_DELETE), k5_get_num_cred(1) > 0); +#endif - gap = (cxdlg - 2 * hmargin - cx) / (IDD_MAX_BUTTON - IDD_MIN_BUTTON); - left = hmargin; - for (i = IDD_MIN_BUTTON; i <= IDD_MAX_BUTTON; i++) { - hwnditem = GetDlgItem(hwnd, i); - windowrect(hwnditem, hwnd, &r); - editbottom = -r.top; - cx = r.right - r.left; - cy = r.bottom - r.top; - r.top = rdlg.bottom - vmargin - cy; - MoveWindow(hwnditem, left, r.top, cx, cy, TRUE); - - left += cx + gap; - } + GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name)); + trim(name); + blogin = strlen(name) > 0; - /* - * Edit fields: stretch boxes, keeping the gap between boxes equal to - * what it was on entry. - */ - editbottom += r.top; + if (blogin) { + GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm)); + trim(realm); + blogin = strlen(realm) > 0; + } - hwnditem = GetDlgItem(hwnd, IDD_MIN_EDIT); - windowrect(hwnditem, hwnd, &r); - gap = r.right; - hmargin = r.left; - editbottom += r.bottom; - titlebottom = -r.top; + if (blogin) { + GetDlgItemText(hwnd, IDD_LOGIN_PASSWORD, password, sizeof(password)); + blogin = strlen(password) > 0; + } - hwnditem = GetDlgItem(hwnd, IDD_MIN_EDIT + 1); - windowrect(hwnditem, hwnd, &r); - gap = r.left - gap; + EnableWindow(GetDlgItem(hwnd, IDD_LOGIN), blogin); + id = (blogin) ? IDD_LOGIN : IDD_PASSWORD_CR2; + SendMessage(hwnd, DM_SETDEFID, id, 0); - cx = cxdlg - 2 * hmargin - (IDD_MAX_EDIT - IDD_MIN_EDIT) * gap; - cx = cx / (IDD_MAX_EDIT - IDD_MIN_EDIT + 1); - left = hmargin; + if (codeNotify != BN_CLICKED && codeNotify != 0 && codeNotify != 1) + return; /* FALSE */ - for (i = IDD_MIN_EDIT; i <= IDD_MAX_EDIT; i++) { - hwnditem = GetDlgItem(hwnd, i); - windowrect(hwnditem, hwnd, &r); - cy = r.bottom - r.top; - r.top = editbottom - cy; - MoveWindow(hwnditem, left, r.top, cx, cy, TRUE); - titleleft[i-IDD_MIN_EDIT] = left; + /* + * Check to see if this item is in a list of the ``recent hosts'' sort + * of list, under the FILE menu. + */ + if (cid >= IDM_FIRST_LOGIN && cid < IDM_FIRST_LOGIN + FILE_MENU_MAX_LOGINS) { + hmenu = GetMenu(hwnd); + assert(hmenu != NULL); - left += cx + gap; - } + hmenu = GetSubMenu(hmenu, 0); + assert(hmenu != NULL); - /* - * Edit field titles - */ - titlebottom += r.top; - windowrect(GetDlgItem(hwnd, IDD_MIN_TITLE), hwnd, &r); - titlebottom += r.bottom; - listbottom = -r.top; - - for (i = IDD_MIN_TITLE; i <= IDD_MAX_TITLE; i++) { - hwnditem = GetDlgItem(hwnd, i); - windowrect(hwnditem, hwnd, &r); - cx = r.right - r.left; - cy = r.bottom - r.top; - r.top = titlebottom - cy; - MoveWindow(hwnditem, titleleft[i-IDD_MIN_TITLE], r.top, cx, cy, TRUE); - } + if (!GetMenuString(hmenu, cid, menuitem, sizeof(menuitem), MF_BYCOMMAND)) + return; /* TRUE */ - /* - * The list - */ - listbottom = r.top - listgap; - hwnditem = GetDlgItem(hwnd, IDD_TICKET_LIST); - windowrect(hwnditem, hwnd, &r); - hmargin = r.left; - cx = cxdlg - 2 * hmargin; - cy = listbottom - r.top; - MoveWindow(hwnditem, r.left, r.top, cx, cy, TRUE); + if (menuitem[0]) + kwin_init_name(hwnd, &menuitem[3]); - return 0; + return; /* TRUE */ + } -} /* kwin_size */ + switch (cid) { + case IDM_EXIT: + if (isblocking) + WSACancelBlockingCall(); + WinHelp(hwnd, KERBEROS_HLP, HELP_QUIT, 0); + PostQuitMessage(0); + return; /* TRUE */ -/*+ - * Function: Process WM_GETMINMAXINFO messages - * - * Parameters: - * hwnd - the window recieving the message. - * - * wparam - none. - * - * lparam - LPMINMAXINFO - * - * Returns: 0 - */ -static LONG -kwin_getminmaxinfo ( - HWND hwnd, - WPARAM wparam, - LPARAM lparam) -{ - MINMAXINFO *lpmmi; + case IDD_PASSWORD_CR2: /* Make CR == TAB */ + id = GetDlgCtrlID(GetFocus()); + assert(id != 0); - lpmmi = (MINMAXINFO *) lparam; - lpmmi->ptMinTrackSize.x = (KWIN_MIN_WIDTH * LOWORD(GetDialogBaseUnits())) / 4; - lpmmi->ptMinTrackSize.y = (KWIN_MIN_HEIGHT * HIWORD(GetDialogBaseUnits())) / 8; + if (id == IDD_MAX_EDIT) + PostMessage(hwnd, WM_NEXTDLGCTL, + (WPARAM)GetDlgItem(hwnd, IDD_MIN_EDIT), MAKELONG(1, 0)); + else + PostMessage(hwnd, WM_NEXTDLGCTL, 0, 0); - return 0; + return; /* TRUE */ -} /* kwin_getminmaxinfo */ + case IDD_LOGIN: + if (isblocking) + return; /* TRUE */ + GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name)); + trim(name); + GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm)); + trim(realm); + GetDlgItemText(hwnd, IDD_LOGIN_PASSWORD, password, sizeof(password)); + trim(password); +#ifdef KRB4 + GetDlgItemText(hwnd, IDD_LOGIN_INSTANCE, instance, sizeof(instance)); + trim(instance); +#endif -/*+ - * Function: Process WM_TIMER messages - * - * Parameters: - * hwnd - the window recieving the message. - * - * wparam - the timer id. - * - * lparam - timer callback proceedure - * - * Returns: 0 - */ -static LONG -kwin_timer ( - HWND hwnd, - WPARAM wparam, - LPARAM lparam) -{ - HWND hwndfocus; - time_t t; - time_t expiration; - BOOL expired; - #ifdef KRB4 - CREDENTIALS c; - int ncred; - int i; - char service[ANAME_SZ]; - char instance[INST_SZ]; - char realm[REALM_SZ]; - #endif - #ifdef KRB5 - krb5_error_code code; - krb5_cc_cursor cursor; - krb5_creds cred; - int n; - char *s; - #endif - - if (wparam != 1) - return DefDlgProc(hwnd, WM_TIMER, wparam, lparam); - - expired = FALSE; - ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST)); - - if (alerted) { - if (IsIconic(hwnd)) - InvalidateRect(hwnd, NULL, TRUE); - - return 0; - } + hcursor = SetCursor(LoadCursor(NULL, IDC_WAIT)); + lifetime = GetPrivateProfileInt(INI_OPTIONS, INI_DURATION, + DEFAULT_TKT_LIFE * 5, KERBEROS_INI); + start_blocking_hook(BLOCK_MAX_SEC); - #ifdef KRB4 - ncred = krb_get_num_cred(); - for (i = 1; i <= ncred; i++) { - krb_get_nth_cred(service, instance, realm, i); - - if (_stricmp(service, "krbtgt") == 0) { - /* Warn if ticket will expire w/i TIME_BUFFER seconds */ - krb_get_cred(service, instance, realm, &c); - expiration = c.issue_date + (long) c.lifetime * 5L * 60L; - t = TIME_BUFFER + time(NULL); - - if (t >= expiration) { - expired = TRUE; - /* Don't alert because of stale tickets */ - if (t >= expiration + KWIN_UPDATE_PERIOD / 1000) { - alerted = TRUE; - - if (IsIconic(hwnd)) - InvalidateRect(hwnd, NULL, TRUE); - return 0; - } - break; - } - } - } - #endif - - #ifdef KRB5 - code = krb5_cc_start_seq_get (k5_context, k5_ccache, &cursor); - - while (code == 0) { - code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &cred); - if (code) - break; - n = krb5_princ_component(k5_context, cred.server, 0)->length; - s = krb5_princ_component(k5_context, cred.server, 0)->data; - if (n != KRB5_TGS_NAME_SIZE) - continue; - if (memcmp (KRB5_TGS_NAME, s, KRB5_TGS_NAME_SIZE)) - continue; - - /* Warn if ticket will expire w/i TIME_BUFFER seconds */ - expiration = cred.times.endtime; - t = TIME_BUFFER + time(NULL); - - if (t >= expiration) { - expired = TRUE; - /* Don't alert because of stale tickets */ - if (t >= expiration + KWIN_UPDATE_PERIOD / 1000) { - alerted = TRUE; - - if (IsIconic(hwnd)) - InvalidateRect(hwnd, NULL, TRUE); - return 0; - } - break; - } - } - if (code == 0 || code == KRB5_CC_END) - krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor); - - #endif +#ifdef KRB4 + lifetime = (lifetime + 4) / 5; + krc = krb_get_pw_in_tkt(name, instance, realm, "krbtgt", realm, + lifetime, password); +#endif - if (!expired) { - if (IsIconic(hwnd)) - InvalidateRect(hwnd, NULL, TRUE); +#ifdef KRB5 + do { + principal = server = NULL; + memset(&creds, 0, sizeof(creds)); + + sprintf(menuitem, "%s@%s", name, realm); + code = krb5_parse_name(k5_context, menuitem, &principal); + if (code) + break; + + code = krb5_cc_initialize(k5_context, k5_ccache, principal); + if (code) + break; + + code = krb5_build_principal_ext(k5_context, &server, + krb5_princ_realm(k5_context, principal)->length, + krb5_princ_realm(k5_context, principal)->data, + KRB5_TGS_NAME_SIZE, KRB5_TGS_NAME, + krb5_princ_realm(k5_context, principal)->length, + krb5_princ_realm(k5_context, principal)->data, 0); + if (code) + break; + + creds.client = principal; + creds.server = server; + + code = krb5_us_timeofday(k5_context, &sec, &usec); + if (code) + break; + creds.times.starttime = 0; + creds.times.endtime = sec + 60L * lifetime; + creds.times.renew_till = 0; + + /* + * XXX whether or not the credentials should be + * forwardable should be a configurable option in the + * UI. + */ + code = krb5_get_in_tkt_with_password(k5_context, + (forwardable ? KDC_OPT_FORWARDABLE : 0), + NULL, NULL, + NULL, password, k5_ccache, + &creds, 0); + } while (0); + + if (principal) + krb5_free_principal(k5_context, principal); + + if (server) + krb5_free_principal(k5_context, server); + +#endif /* KRB5 */ + + end_blocking_hook(); + SetCursor(hcursor); + kwin_set_default_focus(hwnd); - return 0; - } +#ifdef KRB4 + if (krc != KSUCCESS) { + MessageBox(hwnd, krb_get_err_text(krc), "", + MB_OK | MB_ICONEXCLAMATION); - alerted = TRUE; + return; /* TRUE */ + } +#endif - if (beep) - MessageBeep(MB_ICONEXCLAMATION); +#ifdef KRB5 + if (code) { + if (code == KRB5KRB_AP_ERR_BAD_INTEGRITY) + MessageBox(hwnd, "Password incorrect", NULL, + MB_OK | MB_ICONEXCLAMATION); + else + com_err(NULL, code, "while logging in"); + return; /* TRUE */ + } +#endif - if (alert) { - if (IsIconic(hwnd)) { - hwndfocus = GetFocus(); - ShowWindow(hwnd, SW_RESTORE); - SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE); - SetFocus(hwndfocus); - } + SetDlgItemText(hwnd, IDD_LOGIN_PASSWORD, ""); + kwin_save_name(hwnd); + alerted = FALSE; - SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE); + switch (action) { + case LOGIN_AND_EXIT: + SendMessage(hwnd, WM_COMMAND, GET_WM_COMMAND_MPS(IDM_EXIT, 0, 0)); + break; - return 0; - } + case LOGIN_AND_MINIMIZE: + ShowWindow(hwnd, SW_MINIMIZE); + break; + } - if (IsIconic(hwnd)) - InvalidateRect(hwnd, NULL, TRUE); + return; /* TRUE */ - return 0; + case IDD_TICKET_DELETE: + if (isblocking) + return; /* TRUE */ -} /* kwin_timer */ +#ifdef KRB4 + krc = dest_tkt(); + if (krc != KSUCCESS) + MessageBox(hwnd, krb_get_err_text(krc), "", + MB_OK | MB_ICONEXCLAMATION); +#endif +#ifdef KRB5 + code = k5_dest_tkt(); +#endif -/*+ - * Function: Process WM_COMMAND messages - * - * Parameters: - * hwnd - the window recieving the message. - * - * wparam - id of the command item - * - * lparam - LOWORD=hwnd of control, HIWORD=notification message. - * - * Returns: TRUE if initialized sucessfully, false otherwise. - */ -static LONG -kwin_command ( - HWND hwnd, - WPARAM wparam, - LPARAM lparam) -{ - char name[ANAME_SZ]; - char realm[REALM_SZ]; - char password[MAX_KPW_LEN]; - HCURSOR hcursor; - BOOL blogin; - HMENU hmenu; - char menuitem[MAX_K_NAME_SZ + 3]; - char copyright[128]; - int id; - #ifdef KRB4 - char instance[INST_SZ]; - int lifetime; - int krc; - #endif - #ifdef KRB5 - long lifetime; - krb5_error_code code; - krb5_principal principal; - krb5_creds creds; - krb5_principal server; - krb5_int32 sec, usec; - #endif - - #ifdef KRB4 - EnableWindow(GetDlgItem(hwnd, IDD_TICKET_DELETE), krb_get_num_cred() > 0); - #endif - - #ifdef KRB5 - EnableWindow(GetDlgItem(hwnd, IDD_TICKET_DELETE), k5_get_num_cred(0) > 0); - #endif - - GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name)); - trim(name); - blogin = strlen(name) > 0; - - if (blogin) { - GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm)); - trim(realm); - blogin = strlen(realm) > 0; - } + kwin_set_default_focus(hwnd); + alerted = FALSE; - if (blogin) { - GetDlgItemText(hwnd, IDD_LOGIN_PASSWORD, password, sizeof(password)); - blogin = strlen(password) > 0; - } + return; /* TRUE */ - EnableWindow(GetDlgItem(hwnd, IDD_LOGIN), blogin); - id = (blogin) ? IDD_LOGIN : IDD_PASSWORD_CR2; - SendMessage(hwnd, DM_SETDEFID, id, 0); + case IDD_CHANGE_PASSWORD: + if (isblocking) + return; /* TRUE */ + password_dialog(hwnd); + kwin_set_default_focus(hwnd); - if (HIWORD(lparam) != BN_CLICKED && HIWORD(lparam) != 0 && HIWORD(lparam) != 1) - return FALSE; + return; /* TRUE */ - if (wparam >= IDM_FIRST_LOGIN && wparam < IDM_FIRST_LOGIN + FILE_MENU_MAX_LOGINS) { - hmenu = GetMenu(hwnd); - assert(hmenu != NULL); + case IDM_OPTIONS: + if (isblocking) + return; /* TRUE */ + opts_dialog(hwnd); - hmenu = GetSubMenu(hmenu, 0); - assert(hmenu != NULL); + return; /* TRUE */ - if (!GetMenuString(hmenu, wparam, menuitem, sizeof(menuitem), MF_BYCOMMAND)) - return TRUE; + case IDM_HELP_INDEX: + WinHelp(hwnd, KERBEROS_HLP, HELP_INDEX, 0); - if (menuitem[0]) - kwin_init_name(hwnd, &menuitem[3]); + return; /* TRUE */ - return TRUE; - } + case IDM_ABOUT: + ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST)); + if (isblocking) + return; /* TRUE */ - switch (wparam) { - case IDM_EXIT: - if (isblocking) - WSACancelBlockingCall(); - WinHelp(hwnd, KERBEROS_HLP, HELP_QUIT, 0); - PostQuitMessage(0); - - return TRUE; - - case IDD_PASSWORD_CR2: // Make CR == TAB - id = GetDlgCtrlID(GetFocus()); - assert(id != 0); - - if (id == IDD_MAX_EDIT) - PostMessage(hwnd, WM_NEXTDLGCTL, - GetDlgItem(hwnd, IDD_MIN_EDIT), MAKELONG(1, 0)); - else - PostMessage(hwnd, WM_NEXTDLGCTL, 0, 0); - - return TRUE; - - case IDD_LOGIN: - if (isblocking) - return TRUE; - - GetDlgItemText(hwnd, IDD_LOGIN_NAME, name, sizeof(name)); - trim(name); - GetDlgItemText(hwnd, IDD_LOGIN_REALM, realm, sizeof(realm)); - trim(realm); - GetDlgItemText(hwnd, IDD_LOGIN_PASSWORD, password, sizeof(password)); - trim(password); - - #ifdef KRB4 - GetDlgItemText(hwnd, IDD_LOGIN_INSTANCE, instance, sizeof(instance)); - trim(instance); - #endif - - hcursor = SetCursor(LoadCursor(NULL, IDC_WAIT)); - lifetime = GetPrivateProfileInt(INI_OPTIONS, INI_DURATION, - DEFAULT_TKT_LIFE * 5, KERBEROS_INI); - start_blocking_hook(BLOCK_MAX_SEC); - - #ifdef KRB4 - lifetime = (lifetime + 4) / 5; - krc = krb_get_pw_in_tkt(name, instance, realm, "krbtgt", realm, - lifetime, password); - #endif - - #ifdef KRB5 - do { - principal = server = NULL; - memset(&creds, 0, sizeof(creds)); - - sprintf (menuitem, "%s@%s", name, realm); - code = krb5_parse_name(k5_context, menuitem, &principal); - if (code) break; - - code = krb5_cc_initialize(k5_context, k5_ccache, principal); - if (code) break; - - code = krb5_build_principal_ext(k5_context, &server, - krb5_princ_realm(k5_context, principal)->length, - krb5_princ_realm(k5_context, principal)->data, - KRB5_TGS_NAME_SIZE, KRB5_TGS_NAME, - krb5_princ_realm(k5_context, principal)->length, - krb5_princ_realm(k5_context, principal)->data, 0); - if (code) break; - - creds.client = principal; - creds.server = server; - - code = krb5_us_timeofday(k5_context, &sec, &usec); - if (code) break; - creds.times.starttime = 0; - creds.times.endtime = sec + 60L * lifetime; - creds.times.renew_till = 0; - - /* - * XXX whether or not the credentials should be - * forwardable should be a configurable option in the - * UI. - */ - code = krb5_get_in_tkt_with_password(k5_context, - KDC_OPT_FORWARDABLE, NULL, NULL, NULL, - password, k5_ccache, &creds, 0); - } while (0); - - if (principal) - krb5_free_principal(k5_context, principal); - if (server) - krb5_free_principal(k5_context, server); - - #endif /* KRB5 */ - - end_blocking_hook(); - SetCursor(hcursor); - kwin_set_default_focus(hwnd); - - #ifdef KRB4 - if (krc != KSUCCESS) { - MessageBox(hwnd, krb_get_err_text(krc), "", - MB_OK | MB_ICONEXCLAMATION); - - return TRUE; - } - #endif - - #ifdef KRB5 - if (code) { - if (code == KRB5KRB_AP_ERR_BAD_INTEGRITY) - MessageBox (hwnd, "Password incorrect", NULL, - MB_OK | MB_ICONEXCLAMATION); - else - com_err (NULL, code, "while logging in"); - return TRUE; - } - #endif - - SetDlgItemText(hwnd, IDD_LOGIN_PASSWORD, ""); - kwin_save_name(hwnd); - alerted = FALSE; - - switch (action) { - case LOGIN_AND_EXIT: - SendMessage(hwnd, WM_COMMAND, IDM_EXIT, 0); - break; - - case LOGIN_AND_MINIMIZE: - ShowWindow(hwnd, SW_MINIMIZE); - break; - } - - return TRUE; - - case IDD_TICKET_DELETE: - if (isblocking) - return TRUE; - - #ifdef KRB4 - krc = dest_tkt(); - if (krc != KSUCCESS) - MessageBox(hwnd, krb_get_err_text(krc), "", - MB_OK | MB_ICONEXCLAMATION); - #endif - - #ifdef KRB5 - code = k5_dest_tkt (); - #endif - - kwin_set_default_focus(hwnd); - alerted = FALSE; - - return TRUE; - - case IDD_CHANGE_PASSWORD: - if (isblocking) - return TRUE; - password_dialog(hwnd); - kwin_set_default_focus(hwnd); - - return TRUE; - - case IDM_OPTIONS: - if (isblocking) - return TRUE; - opts_dialog(hwnd); - - return TRUE; - - case IDM_HELP_INDEX: - WinHelp(hwnd, KERBEROS_HLP, HELP_INDEX, 0); - - return TRUE; - - case IDM_ABOUT: - ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST)); - if (isblocking) - return TRUE; - - #ifdef KRB4 - strcpy(copyright, " Kerberos 4 for Windows\n"); - #endif - #ifdef KRB5 - strcpy(copyright, " Kerberos 5 for Windows\n"); - #endif - strcat(copyright, "\n Version 1.00\n\n"); #ifdef CYGNUS - strcat(copyright, " For support, contact:\n"); - strcat(copyright, ORGANIZATION); - strcat(copyright, " - (415) 903-1400"); + strcpy(copyright, " KerbNet for Windows "); +#ifdef _WIN32 + strcat(copyright, "32-bit\n"); +#else + strcat(copyright, "16-bit\n"); #endif - MessageBox(hwnd, copyright, "Kerberos", MB_OK); - - return TRUE; - } + strcat(copyright, "\n Version 1.11\n\n"); + strcat(copyright, " For support, contact:\n"); + strcat(copyright, ORGANIZATION); +#else /* Cygnus */ + strcpy(copyright, " Kerberos V5 for Windows "); +#ifdef _WIN32 + strcat(copyright, "32-bit\n"); +#else + strcat(copyright, "16-bit\n"); +#endif + strcat(copyright, "\n Version 1.11\n\n"); +#endif /* Cygnus */ + MessageBox(hwnd, copyright, KWIN_DIALOG_NAME, MB_OK); - return FALSE; + return; /* TRUE */ + } -} /* kwin_command */ + return; /* FALSE */ +} -/*+ +/* * Function: Process WM_SYSCOMMAND messages by setting * the focus to the password or name on restore. - * - * Parameters: - * hwnd - the window recieving the message. - * - * wparam - the syscommand option. - * - * lparam - - * - * Returns: 0 */ -static LONG -kwin_syscommand ( - HWND hwnd, - WPARAM wparam, - LPARAM lparam) +static void +kwin_syscommand(HWND hwnd, UINT cmd, int x, int y) { - if ((wparam & 0xFFF0) == SC_RESTORE) - kwin_set_default_focus(hwnd); + if (cmd == SC_RESTORE) + kwin_set_default_focus(hwnd); - if ((wparam & 0xFFF0) == SC_CLOSE) { - SendMessage(hwnd, WM_COMMAND, IDM_EXIT, 0); - - return 0; - } - - return DefDlgProc(hwnd, WM_SYSCOMMAND, wparam, lparam); + if (cmd == SC_CLOSE) { + SendMessage(hwnd, WM_COMMAND, GET_WM_COMMAND_MPS(IDM_EXIT, 0, 0)); + return; + } -} /* kwin_syscommand */ + FORWARD_WM_SYSCOMMAND(hwnd, cmd, x, y, DefDlgProc); +} -/*+ +/* * Function: Process WM_PAINT messages by displaying an * informative icon when we are iconic. - * - * Parameters: - * hwnd - the window recieving the message. - * - * wparam - none - * - * lparam - none - * - * Returns: 0 */ -static LONG -kwin_paint ( - HWND hwnd, - WPARAM wparam, - LPARAM lparam) +static void +kwin_paint(HWND hwnd) { - HDC hdc; - PAINTSTRUCT ps; - HICON hicon; - time_t expiration = 0; - time_t dt; - char buf[20]; - RECT r; - #ifdef KRB4 - int i; - int ncred; - char service[ANAME_SZ]; - char instance[INST_SZ]; - char realm[REALM_SZ]; - CREDENTIALS c; - #endif - #ifdef KRB5 - krb5_error_code code; - krb5_cc_cursor cursor; - krb5_creds c; - int n; - char *service; - #endif - - if (!IsIconic(hwnd)) - return DefDlgProc(hwnd, WM_PAINT, wparam, lparam); - - #ifdef KRB4 - ncred = krb_get_num_cred(); - - for (i = 1; i <= ncred; i++) { - krb_get_nth_cred(service, instance, realm, i); - krb_get_cred(service, instance, realm, &c); - if (_stricmp(c.service, "krbtgt") == 0) { - expiration = c.issue_date - kwin_get_epoch() + (long) c.lifetime * 5L * 60L; - break; - } - } - #endif - - #ifdef KRB5 - code = krb5_cc_start_seq_get (k5_context, k5_ccache, &cursor); - - while (code == 0) { - code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &c); - if (code) - break; - n = krb5_princ_component(k5_context, c.server, 0)->length; - service = krb5_princ_component(k5_context, c.server, 0)->data; - if (n != KRB5_TGS_NAME_SIZE) - continue; - if (memcmp (KRB5_TGS_NAME, service, KRB5_TGS_NAME_SIZE)) - continue; - expiration = c.times.endtime; - break; + HDC hdc; + PAINTSTRUCT ps; + HICON hicon; + time_t expiration = 0; + time_t dt; + char buf[20]; + RECT r; +#ifdef KRB4 + int i; + int ncred; + char service[ANAME_SZ]; + char instance[INST_SZ]; + char realm[REALM_SZ]; + CREDENTIALS c; +#endif +#ifdef KRB5 + krb5_error_code code; + krb5_cc_cursor cursor; + krb5_creds c; + int n; + char *service; +#endif + + if (!IsIconic(hwnd)) { + FORWARD_WM_PAINT(hwnd, DefDlgProc); + return; + } + +#ifdef KRB4 + ncred = krb_get_num_cred(); + + for (i = 1; i <= ncred; i++) { + krb_get_nth_cred(service, instance, realm, i); + krb_get_cred(service, instance, realm, &c); + if (_stricmp(c.service, "krbtgt") == 0) { + expiration = c.issue_date - kwin_get_epoch() + + (long)c.lifetime * 5L * 60L; + break; + } + } +#endif + +#ifdef KRB5 + code = krb5_cc_start_seq_get(k5_context, k5_ccache, &cursor); + + while (code == 0) { + code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &c); + if (code) + break; + n = krb5_princ_component(k5_context, c.server, 0)->length; + service = krb5_princ_component(k5_context, c.server, 0)->data; + if (n != KRB5_TGS_NAME_SIZE) + continue; + if (memcmp(KRB5_TGS_NAME, service, KRB5_TGS_NAME_SIZE)) + continue; + expiration = c.times.endtime; + break; - } - if (code == 0 || code == KRB5_CC_END) - krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor); - #endif - - hdc = BeginPaint(hwnd, &ps); - GetClientRect(hwnd, &r); - DefWindowProc(hwnd, WM_ICONERASEBKGND, hdc, 0); - - if (expiration == 0) { - strcpy(buf, KWIN_DIALOG_NAME); - hicon = LoadIcon(hinstance, MAKEINTRESOURCE(IDI_KWIN)); - } - else { - hicon = kwin_get_icon(expiration); - dt = (expiration - time(NULL)) / 60; - - if (dt <= 0) - sprintf(buf, "%s - %s", KWIN_DIALOG_NAME, "Expired"); - else if (dt < 60) { - dt %= 60; - sprintf(buf, "%s - %ld min", KWIN_DIALOG_NAME, dt); - } - else { - dt /= 60; - sprintf(buf, "%s - %ld hr", KWIN_DIALOG_NAME, dt); - } - - if (dt > 1) - strcat(buf, "s"); - } + } + if (code == 0 || code == KRB5_CC_END) + krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor); +#endif - DrawIcon(hdc, r.left, r.top, hicon); - EndPaint(hwnd, &ps); - SetWindowText(hwnd, buf); + hdc = BeginPaint(hwnd, &ps); + GetClientRect(hwnd, &r); + DefWindowProc(hwnd, WM_ICONERASEBKGND, (WPARAM)hdc, 0); + + if (expiration == 0) { + strcpy(buf, KWIN_DIALOG_NAME); + hicon = LoadIcon(hinstance, MAKEINTRESOURCE(IDI_KWIN)); + } + else { + hicon = kwin_get_icon(expiration); + dt = (expiration - time(NULL)) / 60; + + if (dt <= 0) + sprintf(buf, "%s - %s", KWIN_DIALOG_NAME, "Expired"); + else if (dt < 60) { + dt %= 60; + sprintf(buf, "%s - %ld min", KWIN_DIALOG_NAME, dt); + } + else { + dt /= 60; + sprintf(buf, "%s - %ld hr", KWIN_DIALOG_NAME, dt); + } - return 0; + if (dt > 1) + strcat(buf, "s"); + } -} /* kwin_paint */ + DrawIcon(hdc, r.left, r.top, hicon); + EndPaint(hwnd, &ps); + SetWindowText(hwnd, buf); +} -/*+ - * Function: Window proceedure for the Kerberos control panel dialog. - * - * Parameters: - * hwnd - the window receiving the message. - * - * message - the message to process. - * - * wparam - wparam of the message. - * - * lparam - lparam of the message. - * - * Returns: message dependent value. +/* + * Function: Window procedure for the Kerberos control panel dialog. */ -LRESULT __export CALLBACK -kwin_wnd_proc ( - HWND hwnd, - UINT message, - WPARAM wparam, - LPARAM lparam) +LRESULT CALLBACK +kwin_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - LRESULT rc; - int n; + int n; - if (message == wm_kerberos_changed) { /* Message from the ccache */ - n = ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST)); - EnableWindow(GetDlgItem(hwnd, IDD_TICKET_DELETE), n > 0); + if (message == wm_kerberos_changed) { /* Message from the ccache */ + n = ticket_init_list(GetDlgItem(hwnd, IDD_TICKET_LIST)); + EnableWindow(GetDlgItem(hwnd, IDD_TICKET_DELETE), n > 0); - return 0; - } + return 0; + } - switch (message) { - case WM_GETMINMAXINFO: - rc = kwin_getminmaxinfo(hwnd, wparam, lparam); - return rc; - - case WM_DESTROY: - rc = kwin_destroy(hwnd, wparam, lparam); - return rc; - - case WM_MEASUREITEM: - if (wparam == IDD_TICKET_LIST) { - rc = ticket_measureitem(hwnd, wparam, lparam); - return rc; - } - break; - - case WM_DRAWITEM: - if (wparam == IDD_TICKET_LIST) { - rc = ticket_drawitem(hwnd, wparam, lparam); - return rc; - } - break; - - case WM_SETCURSOR: - if (isblocking) { - SetCursor(LoadCursor(NULL, IDC_WAIT)); - return TRUE; - } - break; - - case WM_SIZE: - rc = kwin_size(hwnd, wparam, lparam); - return rc; - - case WM_SYSCOMMAND: - rc = kwin_syscommand(hwnd, wparam, lparam); - return rc; - - case WM_TIMER: - rc = kwin_timer(hwnd, wparam, lparam); - return 0; - - case WM_PAINT: - rc = kwin_paint(hwnd, wparam, lparam); - return rc; - - case WM_ERASEBKGND: - if (!IsIconic(hwnd)) - break; - return 0; - - case WM_KWIN_SETNAME: - kwin_init_name(hwnd, (char *) lparam); - } + switch (message) { + + HANDLE_MSG(hwnd, WM_GETMINMAXINFO, kwin_getminmaxinfo); + HANDLE_MSG(hwnd, WM_DESTROY, kwin_destroy); + HANDLE_MSG(hwnd, WM_MEASUREITEM, ticket_measureitem); + HANDLE_MSG(hwnd, WM_DRAWITEM, ticket_drawitem); + + case WM_SETCURSOR: + if (isblocking) { + SetCursor(LoadCursor(NULL, IDC_WAIT)); + return TRUE; + } + break; + + HANDLE_MSG(hwnd, WM_SIZE, kwin_size); + HANDLE_MSG(hwnd, WM_SYSCOMMAND, kwin_syscommand); + HANDLE_MSG(hwnd, WM_TIMER, kwin_timer); + HANDLE_MSG(hwnd, WM_PAINT, kwin_paint); + + case WM_ERASEBKGND: + if (!IsIconic(hwnd)) + break; + return 0; - return DefDlgProc(hwnd, message, wparam, lparam); + case WM_KWIN_SETNAME: + kwin_init_name(hwnd, (char *)lParam); + } -} /* kwin_wnd_proc */ + return DefDlgProc(hwnd, message, wParam, lParam); +} -/*+ +/* * Function: Dialog procedure called by the dialog manager * to process dialog specific messages. - * - * Parameters: - * hwnd - the dialog receiving the message. - * - * message - the message to process. - * - * wparam - wparam of the message. - * - * lparam - lparam of the message. - * - * Returns: TRUE if message handled locally, FALSE otherwise. */ static BOOL CALLBACK -kwin_dlg_proc ( - HWND hwnd, - UINT message, - WPARAM wparam, - LPARAM lparam) +kwin_dlg_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - LRESULT rc; - - switch (message) { - case WM_INITDIALOG: - return kwin_initdialog(hwnd, wparam, lparam); - - case WM_COMMAND: - rc = kwin_command(hwnd, wparam, lparam); - return TRUE; - } - - return FALSE; + switch (message) { + HANDLE_MSG(hwnd, WM_INITDIALOG, kwin_initdialog); + HANDLE_MSG(hwnd, WM_COMMAND, kwin_command); + } -} /* kwin_dlg_proc */ + return FALSE; +} -/*+ +/* * Function: Initialize the kwin dialog class. * * Parameters: @@ -2442,33 +1590,31 @@ kwin_dlg_proc ( * Returns: TRUE if dialog class registration is sucessfully, false otherwise. */ static BOOL -kwin_init ( - HINSTANCE hinstance) +kwin_init(HINSTANCE hinstance) { - WNDCLASS class; - ATOM rc; - - class.style = CS_HREDRAW | CS_VREDRAW; - class.lpfnWndProc = (WNDPROC) kwin_wnd_proc; - class.cbClsExtra = 0; - class.cbWndExtra = DLGWINDOWEXTRA; - class.hInstance = hinstance; - class.hIcon = NULL; -// LoadIcon(hinstance, MAKEINTRESOURCE(IDI_KWIN)); - class.hCursor = NULL; - class.hbrBackground = NULL; - class.lpszMenuName = NULL; - class.lpszClassName = KWIN_DIALOG_CLASS; - - rc = RegisterClass (&class); - assert(rc); - - return rc; - -} /* kwin_init */ + WNDCLASS class; + ATOM rc; + + class.style = CS_HREDRAW | CS_VREDRAW; + class.lpfnWndProc = (WNDPROC)kwin_wnd_proc; + class.cbClsExtra = 0; + class.cbWndExtra = DLGWINDOWEXTRA; + class.hInstance = hinstance; + class.hIcon = NULL; + /* LoadIcon(hinstance, MAKEINTRESOURCE(IDI_KWIN)); */ + class.hCursor = NULL; + class.hbrBackground = NULL; + class.lpszMenuName = NULL; + class.lpszClassName = KWIN_DIALOG_CLASS; + + rc = RegisterClass(&class); + assert(rc); + + return rc; +} -/*+ +/* * Function: Initialize the KWIN application. This routine should * only be called if no previous instance of the application * exists. Currently it only registers a class for the kwin @@ -2480,27 +1626,24 @@ kwin_init ( * Returns: TRUE if initialized sucessfully, false otherwise. */ static BOOL -init_application ( - HINSTANCE hinstance) +init_application(HINSTANCE hinstance) { - BOOL rc; - - #ifdef KRB4 - wm_kerberos_changed = krb_get_notification_message(); - #endif + BOOL rc; - #ifdef KRB5 - wm_kerberos_changed = krb5_get_notification_message(); - #endif - - rc = kwin_init(hinstance); +#ifdef KRB4 + wm_kerberos_changed = krb_get_notification_message(); +#endif +#ifdef KRB5 + wm_kerberos_changed = krb5_get_notification_message(); +#endif - return rc; + rc = kwin_init(hinstance); -} /* init_application */ + return rc; +} -/*+ +/* * Function: Quits the KWIN application. This routine should * be called when the last application instance exits. * @@ -2510,14 +1653,13 @@ init_application ( * Returns: TRUE if initialized sucessfully, false otherwise. */ static BOOL -quit_application ( - HINSTANCE hinstance) +quit_application(HINSTANCE hinstance) { - return TRUE; -} /* quit_application */ + return TRUE; +} -/*+ +/* * Function: Initialize the current instance of the KWIN application. * * Parameters: @@ -2529,74 +1671,81 @@ quit_application ( * Returns: TRUE if initialized sucessfully, false otherwise. */ static BOOL -init_instance ( - HINSTANCE hinstance, - int ncmdshow) +init_instance(HINSTANCE hinstance, int ncmdshow) { - WORD versionrequested; - WSADATA wsadata; - int rc; - char buf[20]; - int i; - - versionrequested = 0x0101; /* We need version 1.1 */ - rc = WSAStartup(versionrequested, &wsadata); - if (rc != 0) { - MessageBox(NULL, "Couldn't initialize Winsock library", "", MB_OK | MB_ICONSTOP); - - return FALSE; - } + WORD versionrequested; + WSADATA wsadata; + int rc; + char buf[20]; + int i; + + versionrequested = 0x0101; /* We need version 1.1 */ + rc = WSAStartup(versionrequested, &wsadata); + if (rc != 0) { + MessageBox(NULL, "Couldn't initialize Winsock library", "", + MB_OK | MB_ICONSTOP); + + return FALSE; + } + + if (versionrequested != wsadata.wVersion) { + WSACleanup(); + MessageBox(NULL, "Winsock version 1.1 not available", "", + MB_OK | MB_ICONSTOP); + + return FALSE; + } + + /* + * Set up expiration action + */ + GetPrivateProfileString(INI_EXPIRATION, INI_ALERT, "No", + buf, sizeof(buf), KERBEROS_INI); + alert = _stricmp(buf, "Yes") == 0; + GetPrivateProfileString(INI_EXPIRATION, INI_BEEP, "No", + buf, sizeof(buf), KERBEROS_INI); + beep = _stricmp(buf, "Yes") == 0; + + /* + * ticket options + */ + GetPrivateProfileString(INI_TICKETOPTS, INI_FORWARDABLE, "No", + buf, sizeof(buf), KERBEROS_INI); + forwardable = _stricmp(buf, "Yes") == 0; + + /* + * Load clock icons + */ + for (i = IDI_FIRST_CLOCK; i <= IDI_LAST_CLOCK; i++) + kwin_icons[i - IDI_FIRST_CLOCK] = LoadIcon(hinstance, MAKEINTRESOURCE(i)); + +#ifdef KRB4 + krb_start_session(NULL); +#endif - if (versionrequested != wsadata.wVersion) { - WSACleanup(); - MessageBox(NULL, "Winsock version 1.1 not available", "", MB_OK | MB_ICONSTOP); +#ifdef KRB5 + { + krb5_error_code code; - return FALSE; + code = krb5_init_context(&k5_context); + if (!code) { + krb5_init_ets(k5_context); + code = k5_init_ccache(&k5_ccache); } + if (code) { + com_err(NULL, code, "while initializing program"); + return FALSE; + } + k5_name_from_ccache(k5_ccache); + } + +#endif + + return TRUE; +} + - /* - * Set up expiration action - */ - GetPrivateProfileString(INI_EXPIRATION, INI_ALERT, "No", - buf, sizeof(buf), KERBEROS_INI); - alert = _stricmp(buf, "Yes") == 0; - GetPrivateProfileString(INI_EXPIRATION, INI_BEEP, "No", - buf, sizeof(buf), KERBEROS_INI); - beep = _stricmp(buf, "Yes") == 0; - - /* - * Load clock icons - */ - for (i = IDI_FIRST_CLOCK; i <= IDI_LAST_CLOCK; i++) - kwin_icons[i - IDI_FIRST_CLOCK] = LoadIcon(hinstance, MAKEINTRESOURCE(i)); - - #ifdef KRB4 - krb_start_session(NULL); - #endif - - #ifdef KRB5 - { - krb5_error_code code; - - code = krb5_init_context(&k5_context); - if (! code) { - krb5_init_ets(k5_context); - code = k5_init_ccache (&k5_ccache); - } - if (code) { - com_err (NULL, code, "while initializing program"); - return FALSE; - } - k5_name_from_ccache (k5_ccache); - } - #endif - - return TRUE; - -} /* init_instance */ - - -/*+ +/* * Function: Quits the current instance of the KWIN application. * * Parameters: @@ -2605,33 +1754,31 @@ init_instance ( * Returns: TRUE if termination was sucessfully, false otherwise. */ static BOOL -quit_instance ( - HINSTANCE hinstance) +quit_instance(HINSTANCE hinstance) { - int i; - - #ifdef KRB4 - krb_end_session((char *) NULL); - #endif + int i; - #ifdef KRB5 /* FIXME */ - krb5_cc_close (k5_context, k5_ccache); - #endif +#ifdef KRB4 + krb_end_session(NULL); +#endif - WSACleanup(); +#ifdef KRB5 /* FIXME */ + krb5_cc_close(k5_context, k5_ccache); +#endif - /* - * Unload clock icons - */ - for (i = IDI_FIRST_CLOCK; i <= IDI_LAST_CLOCK; i++) - DestroyIcon(kwin_icons[i - IDI_FIRST_CLOCK]); + WSACleanup(); - return TRUE; + /* + * Unload clock icons + */ + for (i = IDI_FIRST_CLOCK; i <= IDI_LAST_CLOCK; i++) + DestroyIcon(kwin_icons[i - IDI_FIRST_CLOCK]); -} /* quit_instance */ + return TRUE; +} -/*+ +/* * Function: Main routine called on program invocation. * * Parameters: @@ -2647,349 +1794,356 @@ quit_instance ( * Returns: TRUE if initialized sucessfully, false otherwise. */ int PASCAL -WinMain ( - HINSTANCE hinst, - HINSTANCE hprevinstance, - LPSTR cmdline, - int ncmdshow) +WinMain(HINSTANCE hinst, HINSTANCE hprevinstance, LPSTR cmdline, int ncmdshow) { - DLGPROC dlgproc; - HWND hwnd; - HACCEL haccel; - MSG msg; - char *p; - char buf[MAX_K_NAME_SZ + 9]; - char name[MAX_K_NAME_SZ]; - - strcpy(buf, cmdline); - action = LOGIN_AND_RUN; - name[0] = 0; - p = strtok(buf, " ,"); - - while (p != NULL) { - if (_stricmp(p, "/exit") == 0) - action = LOGIN_AND_EXIT; - else if (_stricmp(p, "/minimize") == 0) - action = LOGIN_AND_MINIMIZE; - else - strcpy(name, p); - - p = strtok(NULL, " ,"); - } + DLGPROC dlgproc; + HWND hwnd; + HACCEL haccel; + MSG msg; + char *p; + char buf[MAX_K_NAME_SZ + 9]; + char name[MAX_K_NAME_SZ]; + + strcpy(buf, cmdline); + action = LOGIN_AND_RUN; + name[0] = 0; + p = strtok(buf, " ,"); + + while (p != NULL) { + if (_stricmp(p, "/exit") == 0) + action = LOGIN_AND_EXIT; + else if (_stricmp(p, "/minimize") == 0) + action = LOGIN_AND_MINIMIZE; + else + strcpy(name, p); + + p = strtok(NULL, " ,"); + } + + dlgncmdshow = ncmdshow; + hinstance = hinst; + +#ifndef _WIN32 + /* + * If a previous instance of this application exits, bring it + * to the front and exit. + * + * This code is not compiled for WIN32, since hprevinstance will always + * be NULL. + */ + if (hprevinstance != NULL) { + hwnd = FindWindow(KWIN_DIALOG_CLASS, NULL); + + if (IsWindow(hwnd) && IsWindowVisible(hwnd)) { + if (GetWindowWord(hwnd, GWW_HINSTANCE) == hprevinstance) { + if (name[0]) + SendMessage(hwnd, WM_KWIN_SETNAME, 0, (LONG)name); + + ShowWindow(hwnd, ncmdshow); + SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, + SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE); - dlgncmdshow = ncmdshow; - hinstance = hinst; + return FALSE; + } + } + } - /* - * If a previous instance of this application exits, bring it - * to the front and exit. - */ - if (hprevinstance != NULL) { - hwnd = FindWindow(KWIN_DIALOG_CLASS, NULL); + if (hprevinstance == NULL) +#endif /* _WIN32 */ + if (!init_application(hinstance)) + return FALSE; - if (IsWindow(hwnd) && IsWindowVisible(hwnd)) { - if (GetWindowWord(hwnd, GWW_HINSTANCE) == hprevinstance) { - if (name[0]) - SendMessage(hwnd, WM_KWIN_SETNAME, 0, (LONG) name); + if (!init_instance(hinstance, ncmdshow)) + return FALSE; - ShowWindow(hwnd, ncmdshow); - SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, - SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE); +#ifdef _WIN32 + dlgproc = kwin_dlg_proc; +#else + dlgproc = (FARPROC)MakeProcInstance(kwin_dlg_proc, hinstance); + assert(dlgproc != NULL); - return FALSE; - } - } - } + if (dlgproc == NULL) + return 1; +#endif - if (hprevinstance == NULL) - if (!init_application(hinstance)) - return FALSE; + hwnd = CreateDialogParam(hinstance, MAKEINTRESOURCE(ID_KWIN), + HWND_DESKTOP, dlgproc, (LONG)name); + assert(hwnd != NULL); + + if (hwnd == NULL) + return 1; + haccel = LoadAccelerators(hinstance, MAKEINTRESOURCE(IDA_KWIN)); + assert(hwnd != NULL); + + while (GetMessage(&msg, NULL, 0, 0)) { + if (!TranslateAccelerator(hwnd, haccel, &msg) && + !IsDialogMessage(hwnd, &msg)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } - if (!init_instance(hinstance, ncmdshow)) - return FALSE; + DestroyWindow(hwnd); - dlgproc = (FARPROC) MakeProcInstance(kwin_dlg_proc, hinstance); - assert(dlgproc != NULL); +#ifndef _WIN32 + FreeProcInstance((FARPROC)dlgproc); +#endif - if (dlgproc == NULL) - return 1; + return 0; +} - hwnd = CreateDialogParam(hinstance, MAKEINTRESOURCE (ID_KWIN), - HWND_DESKTOP, dlgproc, (LONG) name); - assert(hwnd != NULL); - if (hwnd == NULL) - return 1; - haccel = LoadAccelerators(hinstance, MAKEINTRESOURCE(IDA_KWIN)); - assert(hwnd != NULL); +#if 0 - while (GetMessage(&msg, NULL, 0, 0)) { - if (!TranslateAccelerator(hwnd, haccel, &msg) && - !IsDialogMessage(hwnd, &msg)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } +#define WM_ASYNC_COMPLETED (WM_USER + 1) +#define GETHOSTBYNAME_CLASS "krb_gethostbyname" +static HTASK htaskasync; /* Asynchronos call in progress */ +static BOOL iscompleted; /* True when async call is completed */ - DestroyWindow(hwnd); - FreeProcInstance((FARPROC) dlgproc); +/* + * This routine is called to cancel a blocking hook call within + * the Kerberos library. The need for this routine arises due + * to bugs which exist in existing WINSOCK implementations. We + * blocking gethostbyname with WSAASyncGetHostByName. In order + * to cancel such an operation, this routine must be called. + * Applications may call this routine in addition to calls to + * WSACancelBlockingCall to get any sucy Async calls canceled. + * Return values are as they would be for WSACancelAsyncRequest. + */ +int +krb_cancel_blocking_call(void) +{ + if (htaskasync == NULL) + return 0; + iscompleted = TRUE; - return 0; + return WSACancelAsyncRequest(htask); +} -} /* WinMain */ +/* + * Window proceedure for temporary Windows created in + * krb_gethostbyname. Fields completion messages. + */ +LRESULT CALLBACK +krb_gethostbyname_wnd_proc(HWND hwnd, UINT message, + WPARAM wParam, LPARAM lParam) +{ + if (message == WM_ASYNC_COMPLETED) { + iscompleted = TRUE; + return 0; + } + + return DefWindowProc(hwnd, message, wParam, lParam); +} -#if 0 - #define WM_ASYNC_COMPLETED (WM_USER + 1) - #define GETHOSTBYNAME_CLASS "krb_gethostbyname" - static HTASK htaskasync; /* Asynchronos call in progress */ - static BOOL iscompleted; /* True when async call is completed */ - - /* - * This routine is called to cancel a blocking hook call within - * the Kerberos library. The need for this routine arises due - * to bugs which exist in existing WINSOCK implementations. We - * blocking gethostbyname with WSAASyncGetHostByName. In order - * to cancel such an operation, this routine must be called. - * Applications may call this routine in addition to calls to - * WSACancelBlockingCall to get any sucy Async calls canceled. - * Return values are as they would be for WSACancelAsyncRequest. - */ - int - krb_cancel_blocking_call(void) - { - if (htaskasync == NULL) - return 0; - iscompleted = TRUE; - - return WSACancelAsyncRequest(htask); - - } /* krb_cancel_blocking_call */ - - - /* - * Window proceedure for temporary Windows created in - * krb_gethostbyname. Fields completion messages. - */ - LRESULT __export CALLBACK krb_gethostbyname_wnd_proc( - HWND hwnd, - UINT message, - WPARAM wparam, - LPARAM lparam) - { - if (message == WM_ASYNC_COMPLETED) { - iscompleted = TRUE; - return 0; - } - - return DefWindowProc(hwnd, message, wparam, lparam); - - } /* krb_gethostbyname_wnd_proc */ - - - /* - * The WINSOCK routine gethostbyname has a bug in both FTP and NetManage - * implementations which causes the blocking hook, if any, not to be - * called. This routine attempts to work around the problem by using - * the async routines to emulate the functionality of the synchronous - * routines - */ - struct hostent FAR *PASCAL FAR - krb_gethostbyname( - const char FAR *name) - { - HWND hwnd; - char buf[MAXGETHOSTSTRUCT]; - BOOL FARPROC blockinghook; - WNDCLASS wc; - static BOOL isregistered; - - blockinghook = WSASetBlockingHook(NULL); - WSASetBlockingHook(blockinghook); - - if (blockinghook == NULL) - return gethostbyname(name); - - if (RegisterWndClass() == NULL) - return gethostbyname(name); - - if (!isregistered) { - wc.style = 0; - wc.lpfnWndProc = gethostbyname_wnd_proc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hlibinstance; - wc.hIcon = NULL; - wc.hCursor = NULL; - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; - wc.lpszClassName = GETHOSTBYNAME_CLASS; - - if (!RegisterClass(&wc)) - return gethostbyname(name); - - isregistered = TRUE; - } - - hwnd = CreateWindow(GETHOSTBYNAME_CLASS, "", WS_OVERLAPPED, - -100, -100, 0, 0, HWND_DESKTOP, NULL, hlibinstance, NULL); - if (hwnd == NULL) - return gethostbyname(name); - - htaskasync = - WSAAsyncGetHostByName(hwnd, WM_ASYNC_COMPLETED, name, buf, sizeof(buf)); - b = blockinghook(NULL); - - } /* krb_gethostbyname */ +/* + * The WINSOCK routine gethostbyname has a bug in both FTP and NetManage + * implementations which causes the blocking hook, if any, not to be + * called. This routine attempts to work around the problem by using + * the async routines to emulate the functionality of the synchronous + * routines + */ +struct hostent FAR *PASCAL FAR +krb_gethostbyname( + const char FAR *name) +{ + HWND hwnd; + char buf[MAXGETHOSTSTRUCT]; + BOOL FARPROC blockinghook; + WNDCLASS wc; + static BOOL isregistered; + + blockinghook = WSASetBlockingHook(NULL); + WSASetBlockingHook(blockinghook); + + if (blockinghook == NULL) + return gethostbyname(name); + + if (RegisterWndClass() == NULL) + return gethostbyname(name); + + if (!isregistered) { + wc.style = 0; + wc.lpfnWndProc = gethostbyname_wnd_proc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hlibinstance; + wc.hIcon = NULL; + wc.hCursor = NULL; + wc.hbrBackground = NULL; + wc.lpszMenuName = NULL; + wc.lpszClassName = GETHOSTBYNAME_CLASS; + + if (!RegisterClass(&wc)) + return gethostbyname(name); + + isregistered = TRUE; + } + + hwnd = CreateWindow(GETHOSTBYNAME_CLASS, "", WS_OVERLAPPED, + -100, -100, 0, 0, HWND_DESKTOP, NULL, hlibinstance, NULL); + if (hwnd == NULL) + return gethostbyname(name); + + htaskasync = + WSAAsyncGetHostByName(hwnd, WM_ASYNC_COMPLETED, name, buf, sizeof(buf)); + b = blockinghook(NULL); +} -#endif +#endif /* if 0 */ #ifdef KRB5 -/*+ +/* * Function: destroys all tickets in a k5 ccache * - * Parameters: - * none - * * Returns: K5 error code (0 == success) */ -static krb5_error_code -k5_dest_tkt (void) { - krb5_error_code code; - krb5_principal princ; - - if (code = krb5_cc_get_principal(k5_context, k5_ccache, &princ)) { - com_err (NULL, code, "while retrieving principal name"); - return code; - } +krb5_error_code +k5_dest_tkt(void) +{ + krb5_error_code code; + krb5_principal princ; - code = krb5_cc_initialize (k5_context, k5_ccache, princ); - if (code != 0) { - com_err (NULL, code, "when re-initializing cache"); - krb5_free_principal (k5_context, princ); - return code; - } + if (code = krb5_cc_get_principal(k5_context, k5_ccache, &princ)) { + com_err(NULL, code, "while retrieving principal name"); + return code; + } - krb5_free_principal (k5_context, princ); + code = krb5_cc_initialize(k5_context, k5_ccache, princ); + if (code != 0) { + com_err(NULL, code, "when re-initializing cache"); + krb5_free_principal(k5_context, princ); return code; + } + + krb5_free_principal(k5_context, princ); + + return code; } -/*+ +/* * * k5_get_num_cred * * Returns: number of creds in the credential cache, -1 on error * */ -static int -k5_get_num_cred (int verbose) { - krb5_error_code code; - krb5_cc_cursor cursor; - krb5_creds c; - int ncreds = 0; - - /* Turn off OPENCLOSE and leave open while we use ccache */ - if (code = krb5_cc_set_flags(k5_context, k5_ccache, 0)) { - if (code == KRB5_FCC_NOFILE) - return 0; - if (verbose) - com_err (NULL, code, - "while setting cache flags (ticket cache %s)", - krb5_cc_get_name(k5_context, k5_ccache)); - return -1; - } - - if (code = krb5_cc_start_seq_get(k5_context, k5_ccache, &cursor)) { - if (verbose) - com_err (NULL, code, "while starting to retrieve tickets."); - return -1; - } - - while (1) { /* Loop and get creds */ - code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &c); - if (code) - break; - ++ncreds; - } - - if (code != KRB5_CC_END) { /* Error while looping??? */ - if (verbose) - com_err (NULL, code, "while retrieving a ticket."); - return -1; - } - - if (code = krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor)) { - if (verbose) - com_err (NULL, code, "while closing ccache."); - } else if (code = krb5_cc_set_flags(k5_context, k5_ccache, KRB5_TC_OPENCLOSE)) { - if (verbose) - com_err(NULL, code, "while closing ccache."); - } +int +k5_get_num_cred(int verbose) +{ + krb5_error_code code; + krb5_cc_cursor cursor; + krb5_creds c; + int ncreds = 0; - return ncreds; + /* Turn off OPENCLOSE and leave open while we use ccache */ + if (code = krb5_cc_set_flags(k5_context, k5_ccache, 0)) { + if (code == KRB5_FCC_NOFILE) + return 0; + if (verbose) + com_err(NULL, code, + "while setting cache flags (ticket cache %s)", + krb5_cc_get_name(k5_context, k5_ccache)); + return -1; + } + + if (code = krb5_cc_start_seq_get(k5_context, k5_ccache, &cursor)) { + if (verbose) + com_err(NULL, code, "while starting to retrieve tickets."); + return -1; + } + + while (1) { /* Loop and get creds */ + code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &c); + if (code) + break; + ++ncreds; + } + + if (code != KRB5_CC_END) { /* Error while looping??? */ + if (verbose) + com_err(NULL, code, "while retrieving a ticket."); + return -1; + } + + if (code = krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor)) { + if (verbose) + com_err(NULL, code, "while closing ccache."); + } else if (code = krb5_cc_set_flags(k5_context, k5_ccache, + KRB5_TC_OPENCLOSE)) { + if (verbose) + com_err(NULL, code, "while closing ccache."); + } + + return ncreds; } static int -k5_get_num_cred2 () { - krb5_error_code code; - krb5_cc_cursor cursor; - krb5_creds c; - int ncreds = 0; +k5_get_num_cred2() +{ + krb5_error_code code; + krb5_cc_cursor cursor; + krb5_creds c; + int ncreds = 0; - code = krb5_cc_start_seq_get (k5_context, k5_ccache, &cursor); - if (code == KRB5_FCC_NOFILE) - return 0; + code = krb5_cc_start_seq_get(k5_context, k5_ccache, &cursor); + if (code == KRB5_FCC_NOFILE) + return 0; - while (1) { - code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &c); - if (code) - break; - ++ncreds; - } - if (code == KRB5_CC_END) - krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor); + while (1) { + code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &c); + if (code) + break; + ++ncreds; + } - return ncreds; + if (code == KRB5_CC_END) + krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor); + + return ncreds; } -/*+ - * Function: Parses fullname into name, instance and realm + +/* + * Function: Parses fullname into name and realm * * Parameters: * name - buffer filled with name of user - * * realm - buffer filled with realm of user - * * fullname - string in form name.instance@realm * * Returns: 0 */ -static int -k5_kname_parse (char *name, char *realm, char *fullname) { - char *ptr; /* For parsing */ +int +k5_kname_parse(char *name, char *realm, char *fullname) +{ + char *ptr; /* For parsing */ - ptr = strchr (fullname, '@'); /* Name, realm separator */ + ptr = strchr(fullname, '@'); /* Name, realm separator */ - if (ptr != NULL) /* Get realm */ - strcpy (realm, ptr + 1); - else - *realm = '\0'; + if (ptr != NULL) /* Get realm */ + strcpy(realm, ptr + 1); + else + *realm = '\0'; - if (ptr != NULL) { /* Get the name */ - strncpy (name, fullname, ptr - fullname); - name[ptr - fullname] = '\0'; - } else - strcpy (name, fullname); + if (ptr != NULL) { /* Get the name */ + strncpy(name, fullname, ptr - fullname); + name[ptr - fullname] = '\0'; + } else + strcpy(name, fullname); - ptr = strchr (name, '.'); /* K4 compatability */ - if (ptr != NULL) - *ptr = '\0'; + ptr = strchr(name, '.'); /* K4 compatability */ + if (ptr != NULL) + *ptr = '\0'; - return 0; + return 0; } -/*+ + + +/* * Function: Initializes ccache and catches illegal caches such as * bad format or no permissions. * @@ -2998,37 +2152,41 @@ k5_kname_parse (char *name, char *realm, char *fullname) { * * Returns: krb5_error_code */ -static krb5_error_code -k5_init_ccache (krb5_ccache *ccache) { - krb5_error_code code; - krb5_principal princ; - FILE *fp; +krb5_error_code +k5_init_ccache(krb5_ccache *ccache) +{ + krb5_error_code code; + krb5_principal princ; + FILE *fp; - code = krb5_cc_default (k5_context, ccache); // Initialize the ccache + code = krb5_cc_default(k5_context, ccache); /* Initialize the ccache */ + if (code) + return code; + + code = krb5_cc_get_principal(k5_context, *ccache, &princ); + if (code == KRB5_FCC_NOFILE) { /* Doesn't exist yet */ + fp = fopen(krb5_cc_get_name(k5_context, *ccache), "w"); + if (fp == NULL) /* Can't open it */ + return KRB5_FCC_PERM; + fclose (fp); + } + + if (code) { /* Bad, delete and try again */ + remove(krb5_cc_get_name(k5_context, *ccache)); + code = krb5_cc_get_principal(k5_context, *ccache, &princ); + if (code == KRB5_FCC_NOFILE) /* Doesn't exist yet */ + return 0; if (code) - return code; - - code = krb5_cc_get_principal (k5_context, *ccache, &princ); - if (code == KRB5_FCC_NOFILE) { // Doesn't exist yet - fp = fopen (krb5_cc_get_name(k5_context, *ccache), "w"); - if (fp == NULL) // Can't open it - return KRB5_FCC_PERM; - fclose (fp); - } + return code; + } - if (code) { // Bad, delete and try again - remove (krb5_cc_get_name(k5_context, *ccache)); - code = krb5_cc_get_principal (k5_context, *ccache, &princ); - if (code == KRB5_FCC_NOFILE) // Doesn't exist yet - return 0; - if (code) - return code; - } + /* krb5_free_principal(k5_context, princ); */ - krb5_free_principal (k5_context, princ); - return 0; + return 0; } -/*+ + + +/* * * Function: Reads the name and realm out of the ccache. * @@ -3043,30 +2201,27 @@ k5_init_ccache (krb5_ccache *ccache) { * Returns: TRUE if read names, FALSE if not * */ -static int -k5_name_from_ccache (krb5_ccache k5_ccache) { - krb5_error_code code; - krb5_principal princ; - char name[ANAME_SZ]; - char realm[REALM_SZ]; - char *defname; - - if (code = krb5_cc_get_principal(k5_context, k5_ccache, &princ)) - return FALSE; +int +k5_name_from_ccache(krb5_ccache k5_ccache) +{ + krb5_error_code code; + krb5_principal princ; + char name[ANAME_SZ]; + char realm[REALM_SZ]; + char FAR *defname; - code = krb5_unparse_name(k5_context, princ, &defname); - if (code) { - krb5_free_principal (k5_context, princ); - return FALSE; - } + if (code = krb5_cc_get_principal(k5_context, k5_ccache, &princ)) + return FALSE; - k5_kname_parse(name, realm, defname); // Extract the components - WritePrivateProfileString(INI_DEFAULTS, INI_USER, name, KERBEROS_INI); - WritePrivateProfileString(INI_DEFAULTS, INI_REALM, realm, KERBEROS_INI); + code = krb5_unparse_name(k5_context, princ, &defname); + if (code) { + return FALSE; + } - krb5_free_principal(k5_context, princ); - free (defname); + k5_kname_parse(name, realm, defname); /* Extract the components */ + WritePrivateProfileString(INI_DEFAULTS, INI_USER, name, KERBEROS_INI); + WritePrivateProfileString(INI_DEFAULTS, INI_REALM, realm, KERBEROS_INI); - return TRUE; + return TRUE; } #endif /* KRB5 */ diff --git a/src/windows/cns/cns.def b/src/windows/cns/cns.def deleted file mode 100644 index 01fd7f5ea..000000000 --- a/src/windows/cns/cns.def +++ /dev/null @@ -1,9 +0,0 @@ -NAME CNS -DESCRIPTION 'CNS - Cygnus Network Security' -EXETYPE WINDOWS -STUB 'WINSTUB.EXE' -SEGMENTS _TEXT CLASS 'CODE' PRELOAD -CODE DISCARDABLE -DATA PRELOAD MULTIPLE MOVEABLE -HEAPSIZE 20480 -STACKSIZE 20480 diff --git a/src/windows/cns/cns.h b/src/windows/cns/cns.h index 35a50e94c..9f6c852cf 100644 --- a/src/windows/cns/cns.h +++ b/src/windows/cns/cns.h @@ -8,18 +8,58 @@ #ifndef KWIN_DEFS #define KWIN_DEFS +#ifndef RC_INVOKED + +#ifdef KRB4 +#define DEFINE_SOCKADDR +#include "mit-copyright.h" +#include "krb.h" +#include "kadm.h" +#include "org.h" +#endif + +#ifdef KRB5 +#include "winsock.h" +#include "krb5.h" +#include "krbini.h" +#include "com_err.h" + +#define DEFAULT_TKT_LIFE 120 /* In 5 minute units */ +#define ANAME_SZ 40 +#define REALM_SZ 40 +#define SNAME_SZ 40 +#define INST_SZ 40 +#define MAX_KPW_LEN 128 +/* include space for '.' and '@' */ +#define MAX_K_NAME_SZ (ANAME_SZ + INST_SZ + REALM_SZ + 2) +#ifdef CYGNUS +#define ORGANIZATION "Cygnus Support - (415) 903-1400" +#endif +#define CREDENTIALS char +#endif + +/* + * Constants + */ +#define BLOCK_MAX_SEC 30 /* Blocking timeout duration */ +#define KWIN_UPDATE_PERIOD 30000 /* Every 30 seconds update the screen */ +#define TIME_BUFFER 300 /* Pop-up time buffer in seconds */ +#define WM_KWIN_SETNAME (WM_USER+100) /* Sets the name fields in the dialog */ + +#endif /* RC_INVOKED */ + /* * Menu items */ #define FILE_MENU_ITEMS 3 #define FILE_MENU_MAX_LOGINS 5 #define IDM_KWIN 1000 - #define IDM_OPTIONS 1001 - #define IDM_EXIT 1002 - #define IDM_FIRST_LOGIN 1003 +#define IDM_OPTIONS 1001 +#define IDM_EXIT 1002 +#define IDM_FIRST_LOGIN 1003 - #define IDM_HELP_INDEX 1020 - #define IDM_ABOUT 1021 +#define IDM_HELP_INDEX 1020 +#define IDM_ABOUT 1021 /* * Accelerator @@ -30,74 +70,82 @@ * Dialog and dialog item ids */ #define KWIN_DIALOG_CLASS "KERBEROS" /* class for kerberos dialog */ -#define KWIN_DIALOG_NAME "Kerberos" /* name for kerberos dialog */ - -#define ID_KWIN 100 /* the main kerberos dialog */ - #define IDD_KWIN_FIRST 101 - #define IDD_TICKET_LIST_TITLE 101 - #define IDD_TICKET_LIST 102 - - #ifdef KRB4 - - #define IDD_MIN_TITLE 103 - #define IDD_LOGIN_NAME_TITLE 103 - #define IDD_LOGIN_INSTANCE_TITLE 104 - #define IDD_LOGIN_REALM_TITLE 105 - #define IDD_LOGIN_PASSWORD_TITLE 106 - #define IDD_MAX_TITLE 106 - - #define IDD_MIN_EDIT 107 - #define IDD_LOGIN_NAME 107 - #define IDD_LOGIN_INSTANCE 108 - #define IDD_LOGIN_REALM 109 - #define IDD_LOGIN_PASSWORD 110 - #define IDD_MAX_EDIT 110 +#ifdef CYGNUS +#define KWIN_DIALOG_NAME "KerbNet" /* name for kerberos dialog */ +#else +#define KWIN_DIALOG_NAME "Krb5" /* name for kerberos dialog */ +#endif + +#define ID_KWIN 100 /* the main kerberos dialog */ +#define IDD_KWIN_FIRST 101 +#define IDD_TICKET_LIST_TITLE 101 +#define IDD_TICKET_LIST 102 + +#ifdef KRB4 + +#define IDD_MIN_TITLE 103 +#define IDD_LOGIN_NAME_TITLE 103 +#define IDD_LOGIN_INSTANCE_TITLE 104 +#define IDD_LOGIN_REALM_TITLE 105 +#define IDD_LOGIN_PASSWORD_TITLE 106 +#define IDD_MAX_TITLE 106 + +#define IDD_MIN_EDIT 107 +#define IDD_LOGIN_NAME 107 +#define IDD_LOGIN_INSTANCE 108 +#define IDD_LOGIN_REALM 109 +#define IDD_LOGIN_PASSWORD 110 +#define IDD_MAX_EDIT 110 - #endif +#endif - #ifdef KRB5 +#ifdef KRB5 - #define IDD_MIN_TITLE 103 - #define IDD_LOGIN_NAME_TITLE 103 - #define IDD_LOGIN_PASSWORD_TITLE 104 - #define IDD_LOGIN_REALM_TITLE 105 - #define IDD_MAX_TITLE 105 +#define IDD_MIN_TITLE 103 +#define IDD_LOGIN_NAME_TITLE 103 +#define IDD_LOGIN_PASSWORD_TITLE 104 +#define IDD_LOGIN_REALM_TITLE 105 +#define IDD_MAX_TITLE 105 - #define IDD_MIN_EDIT 107 - #define IDD_LOGIN_NAME 107 - #define IDD_LOGIN_PASSWORD 108 - #define IDD_LOGIN_REALM 109 - #define IDD_MAX_EDIT 109 +#define IDD_MIN_EDIT 107 +#define IDD_LOGIN_NAME 107 +#define IDD_LOGIN_PASSWORD 108 +#define IDD_LOGIN_REALM 109 +#define IDD_MAX_EDIT 109 - #endif +#endif - #define IDD_MIN_BUTTON 111 - #define IDD_CHANGE_PASSWORD 111 - #define IDD_TICKET_DELETE 112 - #define IDD_LOGIN 113 - #define IDD_MAX_BUTTON 113 - #define IDD_PASSWORD_CR2 114 // For better cr handling +#define IDD_MIN_BUTTON 111 +#define IDD_CHANGE_PASSWORD 111 +#define IDD_TICKET_DELETE 112 +#define IDD_LOGIN 113 +#define IDD_MAX_BUTTON 113 +#define IDD_PASSWORD_CR2 114 /* For better cr handling */ - #define IDD_KWIN_LAST 114 +#define IDD_KWIN_LAST 114 #define ID_PASSWORD 200 - #define IDD_PASSWORD_NAME 204 - #define IDD_PASSWORD_INSTANCE 205 - #define IDD_PASSWORD_REALM 206 - #define IDD_OLD_PASSWORD 207 - #define IDD_NEW_PASSWORD1 208 - #define IDD_NEW_PASSWORD2 209 - #define IDD_PASSWORD_CR 210 +#define IDD_PASSWORD_NAME 204 +#define IDD_PASSWORD_INSTANCE 205 +#define IDD_PASSWORD_REALM 206 +#define IDD_OLD_PASSWORD 207 +#define IDD_NEW_PASSWORD1 208 +#define IDD_NEW_PASSWORD2 209 +#define IDD_PASSWORD_CR 210 #define ID_OPTS 300 - #define IDD_CONF 301 - #define IDD_REALMS 302 - #define IDD_LIFETIME 303 - #define IDD_BEEP 304 - #define IDD_ALERT 305 - #define IDD_CCACHE 306 +#define IDD_CONF 301 +#define IDD_REALMS 302 +#define IDD_LIFETIME 303 +#define IDD_CCACHE 304 +#define IDD_ACTIONS 310 +#define IDD_BEEP 311 +#define IDD_ALERT 312 +#define IDD_TKOPT 320 +#define IDD_FORWARDABLE 321 + /* * Dialog dimensions */ @@ -133,37 +181,55 @@ #ifndef RC_INVOKED +extern BOOL isblocking; +extern HFONT hfontdialog; +extern HINSTANCE hinstance; +extern BOOL alert; +extern BOOL beep; + +extern char confname[]; + #ifdef KRB5 - extern krb5_context k5_context; - extern krb5_ccache k5_ccache; +extern krb5_context k5_context; +extern krb5_ccache k5_ccache; +extern char ccname[]; +extern BOOL forwardable; #endif /* * Prototypes */ -static void kwin_init_name (HWND hwnd, char *fullname); -void kwin_set_default_focus (HWND hwnd); +/* in cns.c */ + +void kwin_init_name(HWND, char *); +void kwin_set_default_focus(HWND); time_t kwin_get_epoch(void); -#ifdef KRB5 - static krb5_error_code k5_dest_tkt (void); - static int k5_get_num_cred (int verbose); - static int k5_kname_parse (char *name, char *realm, char *fullname); - static int k5_get_lrealm (char *realm); - static krb5_error_code k5_init_ccache (krb5_ccache *ccache); - static int k5_name_from_ccache (krb5_ccache k5_ccache); - krb5_error_code k5_change_password ( - krb5_context context, - char *user, - char *realm, - char *old_password, - char *new_password, - char **text); +/* in options.c */ +BOOL opts_initdialog(HWND, HWND, LPARAM); +void opts_command(HWND, int, HWND, UINT); +BOOL CALLBACK opts_dlg_proc(HWND, UINT, WPARAM, LPARAM); +BOOL opts_dialog(HWND); + +/* in password.c */ +BOOL change_password(HWND, char *, char *, char *, char *, char *); +void password_command(HWND, int, HWND, UINT); +BOOL password_initdialog(HWND, HWND, LPARAM); +BOOL CALLBACK password_dlg_proc(HWND, UINT, WPARAM, LPARAM); +BOOL password_dialog(HWND); +#ifdef KRB5 +krb5_error_code k5_dest_tkt(void); +int k5_get_num_cred(int); +int k5_kname_parse(char *, char *, char *); +krb5_error_code k5_init_ccache(krb5_ccache *); +int k5_name_from_ccache(krb5_ccache); +krb5_error_code k5_change_password(krb5_context, char *, char *, char *, + char *, char **); #endif -HICON kwin_get_icon(time_t expiration); +HICON kwin_get_icon(time_t); #endif /* RC_INVOKED */ diff --git a/src/windows/cns/cns.rc b/src/windows/cns/cns.rc deleted file mode 100644 index da70ec98c..000000000 --- a/src/windows/cns/cns.rc +++ /dev/null @@ -1,166 +0,0 @@ -#include -#include "cns.h" - -IDI_KWIN ICON PRELOAD cns.ico -IDI_0_MIN ICON PRELOAD clock00.ico -IDI_5_MIN ICON PRELOAD clock05.ico -IDI_10_MIN ICON PRELOAD clock10.ico -IDI_15_MIN ICON PRELOAD clock15.ico -IDI_20_MIN ICON PRELOAD clock20.ico -IDI_25_MIN ICON PRELOAD clock25.ico -IDI_30_MIN ICON PRELOAD clock30.ico -IDI_35_MIN ICON PRELOAD clock35.ico -IDI_40_MIN ICON PRELOAD clock40.ico -IDI_45_MIN ICON PRELOAD clock45.ico -IDI_50_MIN ICON PRELOAD clock50.ico -IDI_55_MIN ICON PRELOAD clock55.ico -IDI_60_MIN ICON PRELOAD clock60.ico -IDI_EXPIRED ICON PRELOAD clockexp.ico -IDI_TICKET ICON PRELOAD clocktkt.ico - -IDM_KWIN MENU PRELOAD -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&Options...", IDM_OPTIONS - MENUITEM SEPARATOR - MENUITEM "E&xit", IDM_EXIT - END - - POPUP "&Help" - BEGIN - MENUITEM "&Index\tF1", IDM_HELP_INDEX - MENUITEM SEPARATOR - MENUITEM "&About Kerberos...", IDM_ABOUT - END -END - -IDA_KWIN ACCELERATORS PRELOAD -BEGIN - VK_F1, IDM_HELP_INDEX, VIRTKEY -END - -ID_KWIN DIALOG PRELOAD MOVEABLE DISCARDABLE 0, 0, 276, 114 -STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX -CLASS KWIN_DIALOG_CLASS -CAPTION KWIN_DIALOG_NAME -MENU IDM_KWIN -FONT 8, "Arial" -BEGIN - CONTROL " Start Time End Time Ticket", IDD_TICKET_LIST_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 16, 7, 240, 8 - CONTROL "", IDD_TICKET_LIST, "LISTBOX", LBS_NOTIFY | LBS_DISABLENOSCROLL | LBS_OWNERDRAWFIXED | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 8, 18, 261, 52 - #ifdef KRB4 - CONTROL "&Name", IDD_LOGIN_NAME_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 6, 69, 27, 8 - CONTROL "&Instance", IDD_LOGIN_INSTANCE_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 73, 69, 36, 8 - CONTROL "&Realm", IDD_LOGIN_REALM_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 140, 69, 26, 8 - CONTROL "&Password", IDD_LOGIN_PASSWORD_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 207, 69, 36, 8 - CONTROL "", IDD_LOGIN_NAME, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 6, 79, 62, 12 - CONTROL "", IDD_LOGIN_INSTANCE, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 73, 79, 62, 12 - CONTROL "", IDD_LOGIN_REALM, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_UPPERCASE | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 140, 79, 62, 12 - CONTROL "", IDD_LOGIN_PASSWORD, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 207, 79, 62, 12 - #endif - #ifdef KRB5 - CONTROL "&Name", IDD_LOGIN_NAME_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 6, 69, 27, 8 - CONTROL "&Password", IDD_LOGIN_PASSWORD_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 95, 69, 36, 8 - CONTROL "&Realm", IDD_LOGIN_REALM_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 184, 69, 26, 8 - CONTROL "", IDD_LOGIN_NAME, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 6, 79, 84, 12 - CONTROL "", IDD_LOGIN_PASSWORD, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 95, 79, 84, 12 - #ifdef ENABLE_LC_REALMS - CONTROL "", IDD_LOGIN_REALM, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 184, 79, 84, 12 - #else - CONTROL "", IDD_LOGIN_REALM, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_UPPERCASE | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 184, 79, 84, 12 - #endif - #endif - CONTROL "&Change Password...", IDD_CHANGE_PASSWORD, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 6, 96, 74, 14 - CONTROL "&Delete", IDD_TICKET_DELETE, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 122, 96, 52, 14 - CONTROL "&Login", IDD_LOGIN, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 216, 96, 52, 14 - CONTROL "", IDD_PASSWORD_CR2, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE, 5000, 5000, 0, 0 -END - -#ifdef KRB4 - ID_PASSWORD DIALOG 96, 50, 143, 129 - STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU - CAPTION "Change Password" - FONT 8, "Arial" - BEGIN - CONTROL "&Name:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 9, 53, 8 - CONTROL "", IDD_PASSWORD_NAME, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_GROUP | WS_TABSTOP, 61, 6, 76, 12 - CONTROL "&Instance:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 26, 53, 8 - CONTROL "", IDD_PASSWORD_INSTANCE, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 23, 76, 12 - CONTROL "&Realm:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 43, 53, 8 - CONTROL "", IDD_PASSWORD_REALM, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 40, 76, 12 - CONTROL "&Old Password:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 60, 53, 8 - CONTROL "", IDD_OLD_PASSWORD, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 57, 76, 12 - CONTROL "&New Password:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 77, 53, 8 - CONTROL "", IDD_NEW_PASSWORD1, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 74, 76, 12 - CONTROL "&New Password:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 94, 53, 8 - CONTROL "", IDD_NEW_PASSWORD2, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 91, 76, 12 - CONTROL "", IDD_PASSWORD_CR, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE, 5000, 5000, 0, 0 - CONTROL "OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 13, 110, 52, 14 - CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 77, 110, 52, 14 - END -#endif /* KRB4 */ - -#ifdef KRB5 - ID_PASSWORD DIALOG 96, 50, 143, 112 - STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU - CAPTION "Change Password" - FONT 8, "Arial" - BEGIN - CONTROL "&Name:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 9, 53, 8 - CONTROL "", IDD_PASSWORD_NAME, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_GROUP | WS_TABSTOP, 61, 6, 76, 12 - CONTROL "&Realm:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 26, 53, 8 - CONTROL "", IDD_PASSWORD_REALM, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 23, 76, 12 - CONTROL "&Old Password:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 43, 53, 8 - CONTROL "", IDD_OLD_PASSWORD, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 40, 76, 12 - CONTROL "&New Password:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 60, 53, 8 - CONTROL "", IDD_NEW_PASSWORD1, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 57, 76, 12 - CONTROL "&New Password:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 77, 53, 8 - CONTROL "", IDD_NEW_PASSWORD2, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 74, 76, 12 - CONTROL "", IDD_PASSWORD_CR, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE, 5000, 5000, 0, 0 - CONTROL "OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 13, 93, 52, 14 - CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 77, 93, 52, 14 - END -#endif /* KRB5 */ - -#ifdef KRB4 - ID_OPTS DIALOG 97, 52, 148, 107 - STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU - CAPTION "Kerberos Options" - FONT 8, "Arial" - BEGIN - CONTROL "&Conf file:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 9, 40, 8 - CONTROL "", IDD_CONF, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 60, 6, 82, 12 - CONTROL "&Realms file:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 26, 40, 8 - CONTROL "", IDD_REALMS, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 60, 23, 82, 12 - CONTROL "&Ticket lifetime:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 43, 53, 8 - CONTROL "", IDD_LIFETIME, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 60, 40, 20, 12 - CONTROL "minutes", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 85, 43, 46, 8 - CONTROL "Action when login expires", 209, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP, 5, 56, 138, 23 - CONTROL "&Alert ", IDD_ALERT, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 31, 65, 28, 12 - CONTROL "&Beep", IDD_BEEP, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 80, 65, 39, 12 - CONTROL "OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 17, 87, 52, 14 - CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 81, 87, 52, 14 - END -#endif /* KRB4 */ - -#ifdef KRB5 - ID_OPTS DIALOG 97, 52, 168, 107 - STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU - CAPTION "Kerberos Options" - FONT 8, "Arial" - BEGIN - CONTROL "&Config file:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 9, 40, 8 - CONTROL "", IDD_CONF, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 70, 6, 92, 12 - CONTROL "Cre&dential cache:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 26, 58, 8 - CONTROL "", IDD_CCACHE, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 70, 23, 92, 12 - CONTROL "&Ticket lifetime:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 43, 53, 8 - CONTROL "", IDD_LIFETIME, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 70, 40, 20, 12 - CONTROL "minutes", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 95, 43, 46, 8 - CONTROL "Action when login expires", 209, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP, 5, 56, 158, 23 - CONTROL "&Alert ", IDD_ALERT, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 41, 65, 28, 12 - CONTROL "&Beep", IDD_BEEP, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 95, 65, 39, 12 - CONTROL "OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 22, 87, 52, 14 - CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 95, 87, 52, 14 - END -#endif /* KRB5 */ diff --git a/src/windows/cns/cnsres4.rc b/src/windows/cns/cnsres4.rc new file mode 100644 index 000000000..77e21e028 --- /dev/null +++ b/src/windows/cns/cnsres4.rc @@ -0,0 +1,108 @@ +#include + +#define KRB4 +#include "cns.h" + +IDI_KWIN ICON PRELOAD cns.ico +IDI_0_MIN ICON PRELOAD clock00.ico +IDI_5_MIN ICON PRELOAD clock05.ico +IDI_10_MIN ICON PRELOAD clock10.ico +IDI_15_MIN ICON PRELOAD clock15.ico +IDI_20_MIN ICON PRELOAD clock20.ico +IDI_25_MIN ICON PRELOAD clock25.ico +IDI_30_MIN ICON PRELOAD clock30.ico +IDI_35_MIN ICON PRELOAD clock35.ico +IDI_40_MIN ICON PRELOAD clock40.ico +IDI_45_MIN ICON PRELOAD clock45.ico +IDI_50_MIN ICON PRELOAD clock50.ico +IDI_55_MIN ICON PRELOAD clock55.ico +IDI_60_MIN ICON PRELOAD clock60.ico +IDI_EXPIRED ICON PRELOAD clockexp.ico +IDI_TICKET ICON PRELOAD clocktkt.ico + +IDM_KWIN MENU PRELOAD +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&Options...", IDM_OPTIONS + MENUITEM SEPARATOR + MENUITEM "E&xit", IDM_EXIT + END + + POPUP "&Help" + BEGIN + MENUITEM "&Index\tF1", IDM_HELP_INDEX + MENUITEM SEPARATOR + MENUITEM "&About Kerberos...", IDM_ABOUT + END +END + +IDA_KWIN ACCELERATORS PRELOAD +BEGIN + VK_F1, IDM_HELP_INDEX, VIRTKEY +END + +ID_KWIN DIALOG PRELOAD MOVEABLE DISCARDABLE 0, 0, 276, 114 +STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX +CLASS KWIN_DIALOG_CLASS +CAPTION KWIN_DIALOG_NAME +MENU IDM_KWIN +FONT 8, "Arial" +BEGIN + CONTROL " Start Time End Time Ticket", IDD_TICKET_LIST_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 16, 7, 240, 8 + CONTROL "", IDD_TICKET_LIST, "LISTBOX", LBS_NOTIFY | LBS_DISABLENOSCROLL | LBS_OWNERDRAWFIXED | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL, 8, 18, 261, 52 + CONTROL "&Name", IDD_LOGIN_NAME_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 6, 69, 27, 8 + CONTROL "&Instance", IDD_LOGIN_INSTANCE_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 73, 69, 36, 8 + CONTROL "&Realm", IDD_LOGIN_REALM_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 140, 69, 26, 8 + CONTROL "&Password", IDD_LOGIN_PASSWORD_TITLE, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 207, 69, 36, 8 + CONTROL "", IDD_LOGIN_NAME, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 6, 79, 62, 12 + CONTROL "", IDD_LOGIN_INSTANCE, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 73, 79, 62, 12 + CONTROL "", IDD_LOGIN_REALM, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_UPPERCASE | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 140, 79, 62, 12 + CONTROL "", IDD_LOGIN_PASSWORD, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 207, 79, 62, 12 + + CONTROL "&Change Password...", IDD_CHANGE_PASSWORD, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 6, 96, 74, 14 + CONTROL "&Delete", IDD_TICKET_DELETE, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 122, 96, 52, 14 + CONTROL "&Login", IDD_LOGIN, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 216, 96, 52, 14 + CONTROL "", IDD_PASSWORD_CR2, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE, 5000, 5000, 0, 0 +END + +ID_PASSWORD DIALOG 96, 50, 143, 129 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Change Password" +FONT 8, "Arial" +BEGIN + CONTROL "&Name:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 9, 53, 8 + CONTROL "", IDD_PASSWORD_NAME, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_GROUP | WS_TABSTOP, 61, 6, 76, 12 + CONTROL "&Instance:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 26, 53, 8 + CONTROL "", IDD_PASSWORD_INSTANCE, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 23, 76, 12 + CONTROL "&Realm:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 43, 53, 8 + CONTROL "", IDD_PASSWORD_REALM, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 40, 76, 12 + CONTROL "&Old Password:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 60, 53, 8 + CONTROL "", IDD_OLD_PASSWORD, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 57, 76, 12 + CONTROL "&New Password:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 77, 53, 8 + CONTROL "", IDD_NEW_PASSWORD1, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 74, 76, 12 + CONTROL "&New Password:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 94, 53, 8 + CONTROL "", IDD_NEW_PASSWORD2, "EDIT", ES_LEFT | ES_AUTOHSCROLL | ES_PASSWORD | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 61, 91, 76, 12 + CONTROL "", IDD_PASSWORD_CR, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE, 5000, 5000, 0, 0 + CONTROL "OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 13, 110, 52, 14 + CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 77, 110, 52, 14 +END + +ID_OPTS DIALOG 97, 52, 148, 107 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Kerberos Options" +FONT 8, "Arial" +BEGIN + CONTROL "&Conf file:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 9, 40, 8 + CONTROL "", IDD_CONF, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 60, 6, 82, 12 + CONTROL "&Realms file:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 26, 40, 8 + CONTROL "", IDD_REALMS, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 60, 23, 82, 12 + CONTROL "&Ticket lifetime:", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 5, 43, 53, 8 + CONTROL "", IDD_LIFETIME, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 60, 40, 20, 12 + CONTROL "minutes", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 85, 43, 46, 8 + CONTROL "Action when login expires", 209, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP, 5, 56, 138, 23 + CONTROL "&Alert ", IDD_ALERT, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 31, 65, 28, 12 + CONTROL "&Beep", IDD_BEEP, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 80, 65, 39, 12 + CONTROL "OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 17, 87, 52, 14 + CONTROL "Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 81, 87, 52, 14 +END diff --git a/src/windows/cns/cnsres5.rc b/src/windows/cns/cnsres5.rc new file mode 100644 index 000000000..a62c682b3 --- /dev/null +++ b/src/windows/cns/cnsres5.rc @@ -0,0 +1,210 @@ +//Microsoft Developer Studio generated resource script. +// + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +#undef APSTUDIO_HIDDEN_SYMBOLS +#include "cns.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_KWIN ICON PRELOAD DISCARDABLE "cns.ico" +IDI_0_MIN ICON PRELOAD DISCARDABLE "clock00.ico" +IDI_5_MIN ICON PRELOAD DISCARDABLE "clock05.ico" +IDI_10_MIN ICON PRELOAD DISCARDABLE "clock10.ico" +IDI_15_MIN ICON PRELOAD DISCARDABLE "clock15.ico" +IDI_20_MIN ICON PRELOAD DISCARDABLE "clock20.ico" +IDI_25_MIN ICON PRELOAD DISCARDABLE "clock25.ico" +IDI_30_MIN ICON PRELOAD DISCARDABLE "clock30.ico" +IDI_35_MIN ICON PRELOAD DISCARDABLE "clock35.ico" +IDI_40_MIN ICON PRELOAD DISCARDABLE "clock40.ico" +IDI_45_MIN ICON PRELOAD DISCARDABLE "clock45.ico" +IDI_50_MIN ICON PRELOAD DISCARDABLE "clock50.ico" +IDI_55_MIN ICON PRELOAD DISCARDABLE "clock55.ico" +IDI_60_MIN ICON PRELOAD DISCARDABLE "clock60.ico" +IDI_EXPIRED ICON PRELOAD DISCARDABLE "clockexp.ico" +IDI_TICKET ICON PRELOAD DISCARDABLE "clocktkt.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDM_KWIN MENU PRELOAD DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&Options...", IDM_OPTIONS + MENUITEM SEPARATOR + MENUITEM "E&xit", IDM_EXIT + END + POPUP "&Help" + BEGIN + MENUITEM "&Index\tF1", IDM_HELP_INDEX + MENUITEM SEPARATOR + MENUITEM "&About Kerberos...", IDM_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDA_KWIN ACCELERATORS PRELOAD MOVEABLE PURE +BEGIN + VK_F1, IDM_HELP_INDEX, VIRTKEY +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +ID_KWIN DIALOG PRELOAD DISCARDABLE 0, 0, 336, 115 +STYLE WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +#ifdef CYGNUS +CAPTION "Kerb*Net" +#else +CAPTION "Kerberos" +#endif +MENU IDM_KWIN +CLASS "KERBEROS" +FONT 8, "Arial" +BEGIN + CONTROL " Start Time End Time Ticket", + IDD_TICKET_LIST_TITLE,"Static",SS_LEFTNOWORDWRAP | + WS_GROUP,16,7,311,8 + LISTBOX IDD_TICKET_LIST,8,18,319,52,LBS_OWNERDRAWFIXED | + LBS_DISABLENOSCROLL | WS_VSCROLL + LTEXT "&Name",IDD_LOGIN_NAME_TITLE,6,69,27,8 + LTEXT "&Password",IDD_LOGIN_PASSWORD_TITLE,125,69,42,8 + LTEXT "&Realm",IDD_LOGIN_REALM_TITLE,239,69,26,8 + EDITTEXT IDD_LOGIN_NAME,6,79,84,12,ES_AUTOHSCROLL + EDITTEXT IDD_LOGIN_PASSWORD,126,78,84,12,ES_PASSWORD|ES_AUTOHSCROLL + EDITTEXT IDD_LOGIN_REALM,239,79,84,12,ES_AUTOHSCROLL + PUSHBUTTON "&Change Password...",IDD_CHANGE_PASSWORD,6,96,84,14 + PUSHBUTTON "&Destroy Credentials",IDD_TICKET_DELETE,126,96,84,14 + DEFPUSHBUTTON "&Login",IDD_LOGIN,271,96,52,14 + PUSHBUTTON "",IDD_PASSWORD_CR2,5000,5000,6,6,NOT WS_TABSTOP +END + +ID_PASSWORD DIALOG DISCARDABLE 96, 50, 143, 112 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Change Password" +FONT 8, "Arial" +BEGIN + LTEXT "&Name:",-1,5,9,53,8,NOT WS_GROUP + EDITTEXT IDD_PASSWORD_NAME,61,6,76,12,ES_AUTOHSCROLL | WS_GROUP + LTEXT "&Realm:",-1,5,26,53,8,NOT WS_GROUP + EDITTEXT IDD_PASSWORD_REALM,61,23,76,12,ES_AUTOHSCROLL + LTEXT "&Old Password:",-1,5,43,53,8,NOT WS_GROUP + EDITTEXT IDD_OLD_PASSWORD,61,40,76,12,ES_PASSWORD | + ES_AUTOHSCROLL + LTEXT "&New Password:",-1,5,60,53,8,NOT WS_GROUP + EDITTEXT IDD_NEW_PASSWORD1,61,57,76,12,ES_PASSWORD | + ES_AUTOHSCROLL + LTEXT "&New Password:",-1,5,77,53,8,NOT WS_GROUP + EDITTEXT IDD_NEW_PASSWORD2,61,74,76,12,ES_PASSWORD | + ES_AUTOHSCROLL + PUSHBUTTON "",IDD_PASSWORD_CR,5000,5000,0,0,NOT WS_TABSTOP + DEFPUSHBUTTON "OK",IDOK,13,93,52,14,WS_GROUP + PUSHBUTTON "Cancel",IDCANCEL,77,93,52,14 +END + +ID_OPTS DIALOG DISCARDABLE 97, 52, 169, 138 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +#ifdef CYGNUS +CAPTION "Kerb*Net Options" +#else +CAPTION "Kerberos Options" +#endif +FONT 8, "Arial" +BEGIN + LTEXT "&Config file:",-1,5,9,40,8,NOT WS_GROUP + EDITTEXT IDD_CONF,70,6,92,12,ES_AUTOHSCROLL + LTEXT "Cre&dential cache:",-1,5,26,58,8,NOT WS_GROUP + EDITTEXT IDD_CCACHE,70,23,92,12,ES_AUTOHSCROLL + LTEXT "&Ticket lifetime:",-1,5,43,53,8,NOT WS_GROUP + EDITTEXT IDD_LIFETIME,70,40,32,12,ES_AUTOHSCROLL + LTEXT "minutes",-1,109,42,46,8,NOT WS_GROUP + GROUPBOX "Action when login expires",IDD_ACTIONS,5,56,158,23, + WS_GROUP + CONTROL "&Alert ",IDD_ALERT,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,41,65,28,12 + CONTROL "&Beep",IDD_BEEP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, + 95,65,39,12 + GROUPBOX "Ticket options",IDD_TKOPT,5,86,158,23,WS_GROUP + CONTROL "&Forwardable",IDD_FORWARDABLE,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,54,95,65,12 + DEFPUSHBUTTON "OK",IDOK,19,117,52,14 + PUSHBUTTON "Cancel",IDCANCEL,95,117,52,14 +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""windows.h""\r\n" + "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""cns.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/src/windows/cns/debug.c b/src/windows/cns/debug.c new file mode 100644 index 000000000..101fe30b5 --- /dev/null +++ b/src/windows/cns/debug.c @@ -0,0 +1,92 @@ +#ifdef DEBUG +#define _DEBUG + +#include +#include +#include +#include + +void +OutputHeading(const char *explanation) +{ + _RPT1(_CRT_WARN, + "\n\n%s:\n*********************************\n", explanation ); +} + +/* + * The following macros set and clear, respectively, given bits + * of the C runtime library debug flag, as specified by a bitmask. + */ +#define SET_CRT_DEBUG_FIELD(a) \ + _CrtSetDbgFlag((a) | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)) +#define CLEAR_CRT_DEBUG_FIELD(a) \ + _CrtSetDbgFlag(~(a) & _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)) + +_CrtMemState s1; +_CrtMemState s2; +_CrtMemState s3; +static _CrtMemState *ss1 = NULL; +static _CrtMemState *ss2 = NULL; + +void debug_init(); + +void +debug_check() +{ + _CrtMemState *temp; + + OutputHeading("Checking memory..."); + + if (ss1 == NULL) { + debug_init(); + ss1 = &s1; + ss2 = &s2; + } + + _CrtCheckMemory(); + + /* _CrtMemDumpAllObjectsSince( NULL ); */ + + _CrtMemCheckpoint( &s2 ); + + if ( _CrtMemDifference( &s3, &s1, &s2 ) ) + _CrtMemDumpStatistics( &s3 ); + + /* _CrtDumpMemoryLeaks(); */ + + /* + * swap the snapshots around + */ + temp = ss1; + ss1 = ss2; + ss2 = temp; +} + +void +debug_init() +{ + /* Send all reports to STDOUT */ + _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); + _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT ); + _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE ); + _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT ); + _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE ); + _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT ); + + _CrtMemCheckpoint( &s1 ); + + /* + * Set the debug-heap flag so that freed blocks are kept on the + * linked list, to catch any inadvertent use of freed memory + */ + SET_CRT_DEBUG_FIELD( _CRTDBG_DELAY_FREE_MEM_DF ); + + + /* + * Set the debug-heap flag so that memory leaks are reported when + * the process terminates. Then, exit. + */ + SET_CRT_DEBUG_FIELD( _CRTDBG_LEAK_CHECK_DF ); +} +#endif /* DEBUG */ + diff --git a/src/windows/cns/heap.c b/src/windows/cns/heap.c new file mode 100644 index 000000000..46d39df0b --- /dev/null +++ b/src/windows/cns/heap.c @@ -0,0 +1,33 @@ +#include +#include + +void heapdump( void ) +{ + _HEAPINFO hinfo; + int heapstatus; + hinfo._pentry = NULL; + while( ( heapstatus = _heapwalk( &hinfo ) ) == _HEAPOK ) + { printf( "%6s block at %Fp of size %4.4X\n", + ( hinfo._useflag == _USEDENTRY ? "USED" : "FREE" ), + hinfo._pentry, hinfo._size ); + } + + switch( heapstatus ) + { + case _HEAPEMPTY: + printf( "OK - empty heap\n" ); + break; + case _HEAPEND: + printf( "OK - end of heap\n" ); + break; + case _HEAPBADPTR: + printf( "ERROR - bad pointer to heap\n" ); + break; + case _HEAPBADBEGIN: + printf( "ERROR - bad start of heap\n" ); + break; + case _HEAPBADNODE: + printf( "ERROR - bad node in heap\n" ); + break; + } +} diff --git a/src/windows/cns/kerbnet.doc b/src/windows/cns/kerbnet.doc new file mode 100644 index 000000000..161b3c31e Binary files /dev/null and b/src/windows/cns/kerbnet.doc differ diff --git a/src/windows/cns/kerbnet.hlp b/src/windows/cns/kerbnet.hlp new file mode 100644 index 000000000..c25fafcd5 Binary files /dev/null and b/src/windows/cns/kerbnet.hlp differ diff --git a/src/windows/cns/kerbnet.hpj b/src/windows/cns/kerbnet.hpj new file mode 100644 index 000000000..7d0356993 --- /dev/null +++ b/src/windows/cns/kerbnet.hpj @@ -0,0 +1,133 @@ +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +; Help Project File for KERBNET +; +; You may edit this file. +; +; It's probably best not to change the CONTENTS= value +; unless you rename the IDH_CONTENTS context string in +; the KERBNET.DOC file. +; + +[OPTIONS] +; The optional ROOT= entry sets the working directory for the Help Compiler +; ROOT=C:\PROJECT + +; The optional BMROOT= entry sets forth the directories which the +; help compiler will search for bitmaps used in the Help system. +; +;BMROOT=C:\ROBOHELP + +; The CONTENTS= tells the help Engine which topic contains the contents +CONTENTS=IDH_CONTENTS + +; Title is Displayed in the Title Bar of WINHELP.EXE +TITLE=Kerb*Net + +; The BUILD= setting allows complex Help systems which require +; different versions to use the same source. This is similar to #ifdef's +; in the 'C' language. Everything to the right of the = sign in the +; BUILD= statement is an EXPRESSION. See the Help compiler +; documentation for more information about build expressions. +BUILD=WINDOWS + +; The Warning Level is used by the Help Compiler (HC.EXE) +; WARNING=1 - Only the most severe warnings are reported +; WARNING=2 - Intermediate Level of warnings +; WARNING=3 - Most stringent error reporting + +; The Compress option is used by the Help Compiler to make +; smaller, faster loading .HLP files. However, using compression +; increases Compile times. +; COMPRESS=YES, ON, OFF, NO, TRUE or FALSE + + +OLDKEYPHRASE=NO +OPTCDROM=0 +NOTES=1 +REPORT=YES +COMPRESS=12 +ERRORLOG=C:\windows\desktop\kerberos 5\win95 gui\cns help\KERBNET.ERR +[BUILDTAGS] +; The Build Tags section specifies to the Help Compiler the names +; of all the valid build tags used in this Help project. The [BUILDTAGS] +; section is optional. +WINDOWS + + +[CONFIG] +; The config section allows you to define some macros which will be +; executed when the help system is first executed. +; +; The next line gives you browse buttons: +; +BrowseButtons() + +; +; To create a glossary button which displays a list of defined terms +; in a secondary window, remove the semi colon at the start of the next +; line and do the same with the Glossary window in the [WINDOWS] section +;CreateButton("Glossary_Btn","&Glossary","JI(`bubble.hlp>Gloss',`IDH_Glossary')") +; + + +[FILES] +; The files section is where you specify to the Help Compiler which +; Rich Text Format (.RTF) (your help source) files will be used in the +; Help system. RoboHELP generates and maintains the main .RTF +; file for your Help System. If you desire to have multiple .RTF files, +; simply add the additonal names to the [FILES] section. + +KERBNET.RTF +[ALIAS] +; The Alias section allows you to set up aliases for context strings +; in your help system. +; +; Brief example: +; +; IDH_UserID = IDH_RoboGenerated_Id +; IDH_WMP_MenuID = IDH_RoboGenerated_Id +; IDH_Any = IDH_AnyOther + +[MAP] +; +; The Map Section is where the C language #defines are translated +; or mapped into the Help System Context Strings. Standard C syntax +; can be employed. The .HH file is meant to be #include(d) into your +; Windows application source code. +; + +[BITMAPS] +; +; The [BITMAPS] section is where you list any Bitmaps which have +; been placed by reference in the Help System. See the Help compiler +; documentation for more information about placing bitmaps. +; +; The [BITMAPS] section is not really required under Windows 3.1, +; with the advent of the BMROOT item in the [OPTIONS] section. +; +;FOO1.BMP +;FOO2.BMP +;C:\FOO\FOO3.BMP +;And So On + +[WINDOWS] +; Windows Help can display help in one of 5 secondary windows. +; Before using a secondary window, the window must be defined +; in this section: +; +;Gloss = "Glossary",(100,100,350,350),0,(255,255,255),(255,255,255) +main=,,0,, + +[BAGGAGE] +; +; The Baggage section allows the user to include files which +; will be placed in the internal file system for WinHelp. +; Using files from Baggage is a little faster for CDROM, since +; the CDROM drive table does not need to be read from disk. +; +; Baggage files are referred to as regular bitmaps, except +; that you prefix the filename with '!'. +; +; For Instance: +; {bmc !bitmap.bmp} instead of {bmc bitmap.bmp} +; diff --git a/src/windows/cns/kpasswd.c b/src/windows/cns/kpasswd.c index f3687f448..2f1327126 100644 --- a/src/windows/cns/kpasswd.c +++ b/src/windows/cns/kpasswd.c @@ -1,13 +1,15 @@ -/*+************************************************************************* -** -** k5passwd -** -** Changes your password in the Kerberos V5. This should have been -** part of the kadm stuff but we're forced to build a nicer API on top -** of the calls they provide. -** -***************************************************************************/ +/* + * + * k5passwd + * + * Changes your password in the Kerberos V5. This should have been + * part of the kadm stuff but we're forced to build a nicer API on top + * of the calls they provide. + * + */ + #ifdef KRB5 + #include #include #include @@ -17,200 +19,195 @@ #include "adm_proto.h" static const char *kadm_replies[] = { - "Operation successful", /* KRB5_ADM_SUCCESS */ - "Command not recognized", /* KRB5_ADM_CMD_UNKNOWN */ - "Password unacceptable to server", /* KRB5_ADM_PW_UNACCEPT */ - "Old password incorrect", /* KRB5_ADM_BAD_PW */ - "Invalid ticket (TKT_FLAG_INITIAL not set)",/* KRB5_ADM_NOT_IN_TKT */ - "Server refused password change", /* KRB5_ADM_CANT_CHANGE */ - "Language not supported", /* KRB5_ADM_LANG_NOT_SUPPORTED */ + "Operation successful", /* KRB5_ADM_SUCCESS */ + "Command not recognized", /* KRB5_ADM_CMD_UNKNOWN */ + "Password unacceptable to server", /* KRB5_ADM_PW_UNACCEPT */ + "Old password incorrect", /* KRB5_ADM_BAD_PW */ + "Invalid ticket (TKT_FLAG_INITIAL not set)",/* KRB5_ADM_NOT_IN_TKT */ + "Server refused password change", /* KRB5_ADM_CANT_CHANGE */ + "Language not supported", /* KRB5_ADM_LANG_NOT_SUPPORTED */ }; + static const char *kadm_replies_unknown = "UNKNOWN ERROR"; -static char errbuf[1024]; /* For response from kadm */ - -/*+************************************************************************* -** -** get_admin_response -** -** Builds into a static buffer the replies sent back by the admin server. -** -***************************************************************************/ +static char errbuf[1024]; /* For response from kadm */ + +/* + * get_admin_response + * + * Builds into a static buffer the replies sent back by the admin server. + */ static char * -get_admin_response ( - krb5_int32 status, // Type of error - krb5_int32 nreplies, // Size of reply - krb5_data * reply) // Buffer of messages +get_admin_response(krb5_int32 status, /* Type of error */ + krb5_int32 nreplies, /* Size of reply */ + krb5_data *reply) /* Buffer of messages */ { - char *ptr; // For building the response - char *end = errbuf + sizeof (errbuf); // So we don't overflow - int i; // Index - int n; // Length - - if (status <= KRB5_ADM_LANG_NOT_SUPPORTED) // Is it of a known type??? - strcpy (errbuf, kadm_replies[status]); - else - strcpy (errbuf, kadm_replies_unknown); // Unknown error type - ptr = errbuf + strlen (errbuf); // Point at the end - - if (nreplies > 0) { // Are there more message? - *ptr++ = ':'; - *ptr = '\0'; - } - - for (i = 0; i < nreplies; ++i) { // Append additional messages - *ptr++ = '\n'; - - n = reply[i].length; // Easier to work with - if (ptr + n + 2 >= errbuf) // Check for overflow - break; - memcpy (ptr, reply[i].data, n); // Add the message - ptr += n; // Point to the end - *ptr = '\0'; - } - - return errbuf; + char *ptr; /* For building the response */ + char *end = errbuf + sizeof (errbuf); /* So we don't overflow */ + int i; /* Index */ + int n; /* Length */ + + if (status <= KRB5_ADM_LANG_NOT_SUPPORTED) /* Is it of a known type??? */ + strcpy (errbuf, kadm_replies[status]); + else + strcpy (errbuf, kadm_replies_unknown); /* Unknown error type */ + ptr = errbuf + strlen (errbuf); /* Point at the end */ + + if (nreplies > 0) { /* Are there more message? */ + *ptr++ = ':'; + *ptr = '\0'; + } + + for (i = 0; i < nreplies; ++i) { /* Append additional messages */ + *ptr++ = '\n'; + + n = reply[i].length; /* Easier to work with */ + if (ptr + n + 2 >= errbuf) /* Check for overflow */ + break; + memcpy (ptr, reply[i].data, n); /* Add the message */ + ptr += n; /* Point to the end */ + *ptr = '\0'; + } + + return errbuf; } -/*+************************************************************************* -** -** keyadmin_send_recieve -** -** Sends a command to the key admin and reads the reply. -** -***************************************************************************/ + +/* + * keyadmin_send_recieve + * + * Sends a command to the key admin and reads the reply. + */ static krb5_error_code -keyadmin_send_receive ( - krb5_context k5context, - int * conn_socket, - krb5_auth_context auth_context, - krb5_int32 nargs, - krb5_data * arglist, - krb5_int32 * cmd_stat, - krb5_int32 * nreplies, - krb5_data ** reply) +keyadmin_send_receive(krb5_context k5context, + int *conn_socket, + krb5_auth_context auth_context, + krb5_int32 nargs, + krb5_data *arglist, + krb5_int32 *cmd_stat, + krb5_int32 *nreplies, + krb5_data **reply) { - krb5_error_code kret; + krb5_error_code kret; + char foo[1024]; + int i; - kret = krb5_send_adm_cmd (k5context, conn_socket, auth_context, - nargs, arglist); + kret = krb5_send_adm_cmd (k5context, conn_socket, auth_context, + nargs, arglist); - if (! kret) - kret = krb5_read_adm_reply (k5context, conn_socket, auth_context, - cmd_stat, nreplies, reply); + if (! kret) + kret = krb5_read_adm_reply (k5context, conn_socket, auth_context, + cmd_stat, nreplies, reply); - return kret; + return kret; } -/*+************************************************************************* -** -** k5_change_password -** -** Bundles all the crude needed to change the password into one file. -** -***************************************************************************/ -krb5_error_code -k5_change_password ( - krb5_context k5context, - char *user, - char *realm, - char *opasswd, - char *npasswd, - char **text) -{ - krb5_error_code kret, kret2; - krb5_auth_context auth_context; - krb5_ccache ccache; - int conn_socket; /* Socket for talking over */ - krb5_int32 nreplies; - krb5_data data[3]; - krb5_data * reply; - krb5_int32 status; - char * name; - - *text = NULL; /* Be safe */ - name = malloc (strlen (user) + strlen (realm) + 2); - if (name == NULL) - return ENOMEM; - sprintf (name, "%s@%s", user, realm); - ccache = (krb5_ccache) NULL; -/* -** Establish the connection. -*/ - kret = krb5_adm_connect (k5context, name, NULL, opasswd, &conn_socket, - &auth_context, &ccache, NULL, 0); - if (kret) - goto done; -/* -** Check to see if it's an acceptable password -*/ - data[0].data = KRB5_ADM_CHECKPW_CMD; - data[0].length = strlen (data[0].data); - data[1].data = npasswd; - data[1].length = strlen (npasswd); - - kret = keyadmin_send_receive (k5context, &conn_socket, auth_context, - 2, data, &status, &nreplies, &reply); - if (kret) /* Some external error */ - goto cleanup; - - if (status != KRB5_ADM_SUCCESS) { /* Some problem??? */ - kret = status; - *text = get_admin_response (status, nreplies, reply); - krb5_free_adm_data (k5context, nreplies, reply); - - goto quit; - } - krb5_free_adm_data (k5context, nreplies, reply); /* -** The new password is ok, so now actually change the password -*/ - data[0].data = KRB5_ADM_CHANGEPW_CMD; - data[0].length = strlen (data[0].data); - data[1].data = opasswd; - data[1].length = strlen (opasswd); - data[2].data = npasswd; - data[2].length = strlen (npasswd); - - kret = keyadmin_send_receive (k5context, &conn_socket, auth_context, - 3, data, &status, &nreplies, &reply); - if (kret) - goto cleanup; - - if (status != KRB5_ADM_SUCCESS) { - kret = status; - *text = get_admin_response (status, nreplies, reply); - krb5_free_adm_data (k5context, nreplies, reply); - - goto quit; - } - - krb5_free_adm_data (k5context, nreplies, reply); -/*+ -** Need to send quit command. -*/ - quit: - data[0].data = KRB5_ADM_QUIT_CMD; - data[0].length = strlen (data[0].data); - - kret2 = keyadmin_send_receive (k5context, &conn_socket, auth_context, - 1, data, &status, &nreplies, &reply); - if (kret2) { - if (! kret) - kret = kret2; - } else if (status != KRB5_ADM_SUCCESS) { - if (! kret) - kret = status; - if (*text == NULL) - *text = get_admin_response (status, nreplies, reply); - } - krb5_free_adm_data (k5context, nreplies, reply); - - cleanup: - krb5_adm_disconnect (k5context, &conn_socket, auth_context, ccache); - done: - free (name); - - return kret; + * k5_change_password + * + * Bundles all the crud needed to change the password into one file. + */ +krb5_error_code +k5_change_password (krb5_context k5context, char *user, char *realm, + char *opasswd, char *npasswd, char **text) +{ + krb5_error_code kret, kret2; + krb5_auth_context auth_context; + krb5_ccache ccache; + int conn_socket; /* Socket for talking over */ + krb5_int32 nreplies; + krb5_data data[3]; + krb5_data *reply; + krb5_int32 status; + char *name; + + *text = NULL; /* Be safe */ + name = malloc(strlen(user) + strlen(realm) + 2); + if (name == NULL) + return ENOMEM; + sprintf(name, "%s@%s", user, realm); + ccache = (krb5_ccache)NULL; + + /* + * Establish the connection. + */ + kret = krb5_adm_connect(k5context, name, NULL, opasswd, &conn_socket, + &auth_context, &ccache, "kadm.tk", 0); + if (kret) + goto done; + + /* + * Check to see if it's an acceptable password + */ + data[0].data = KRB5_ADM_CHECKPW_CMD; + data[0].length = strlen (data[0].data); + data[1].data = npasswd; + data[1].length = strlen (npasswd); + + kret = keyadmin_send_receive (k5context, &conn_socket, auth_context, + 2, data, &status, &nreplies, &reply); + if (kret) /* Some external error */ + goto cleanup; + + if (status != KRB5_ADM_SUCCESS) { /* Some problem??? */ + kret = status; + *text = get_admin_response (status, nreplies, reply); + krb5_free_adm_data (k5context, nreplies, reply); + + goto quit; + } + krb5_free_adm_data (k5context, nreplies, reply); + + /* + * The new password is ok, so now actually change the password + */ + data[0].data = KRB5_ADM_CHANGEPW_CMD; + data[0].length = strlen (data[0].data); + data[1].data = opasswd; + data[1].length = strlen (opasswd); + data[2].data = npasswd; + data[2].length = strlen (npasswd); + + kret = keyadmin_send_receive (k5context, &conn_socket, auth_context, + 3, data, &status, &nreplies, &reply); + if (kret) + goto cleanup; + + if (status != KRB5_ADM_SUCCESS) { + kret = status; + *text = get_admin_response (status, nreplies, reply); + krb5_free_adm_data (k5context, nreplies, reply); + + goto quit; + } + + krb5_free_adm_data (k5context, nreplies, reply); + /* + * Need to send quit command. + */ +quit: + data[0].data = KRB5_ADM_QUIT_CMD; + data[0].length = strlen (data[0].data); + + kret2 = keyadmin_send_receive (k5context, &conn_socket, auth_context, + 1, data, &status, &nreplies, &reply); + if (kret2) { + if (! kret) + kret = kret2; + } else if (status != KRB5_ADM_SUCCESS) { + if (! kret) + kret = status; + if (*text == NULL) + *text = get_admin_response (status, nreplies, reply); + } + krb5_free_adm_data (k5context, nreplies, reply); + +cleanup: + krb5_adm_disconnect (k5context, &conn_socket, auth_context, ccache); + +done: + free (name); + + return kret; } #endif /* KRB5 */ diff --git a/src/windows/cns/krbini.h b/src/windows/cns/krbini.h index 0264c2016..a3dd4854e 100644 --- a/src/windows/cns/krbini.h +++ b/src/windows/cns/krbini.h @@ -3,29 +3,35 @@ /* Kerberos Windows initialization file */ #define KERBEROS_INI "kerberos.ini" -#define KERBEROS_HLP "kerberos.hlp" +#ifdef CYGNUS +#define KERBEROS_HLP "kerbnet.hlp" +#else +#define KERBEROS_HLP "krb5clnt.hlp" +#endif #define INI_DEFAULTS "Defaults" -#define INI_USER "User" /* Default user */ -#define INI_INSTANCE "Instance" /* Default instance */ -#define INI_REALM "Realm" /* Default realm */ -#define INI_POSITION "Position" -#define INI_OPTIONS "Options" -#define INI_DURATION "Duration" /* Ticket duration in minutes */ -#define INI_EXPIRATION "Expiration" /* Action on expiration (alert or beep) */ -#define INI_ALERT "Alert" -#define INI_BEEP "Beep" -#define INI_FILES "Files" +#define INI_USER "User" /* Default user */ +#define INI_INSTANCE "Instance" /* Default instance */ +#define INI_REALM "Realm" /* Default realm */ +#define INI_POSITION "Position" +#define INI_OPTIONS "Options" +#define INI_DURATION "Duration" /* Ticket duration in minutes */ +#define INI_EXPIRATION "Expiration" /* Action on expiration (alert or beep) */ +#define INI_ALERT "Alert" +#define INI_BEEP "Beep" +#define INI_FILES "Files" #ifdef KRB4 - #define INI_KRB_CONF "krb.conf" /* Location of krb.conf file */ - #define DEF_KRB_CONF "krb.con" /* Default name for krb.conf file */ +#define INI_KRB_CONF "krb.conf" /* Location of krb.conf file */ +#define DEF_KRB_CONF "krb.conf" /* Default name for krb.conf file */ #endif /* KRB4 */ #ifdef KRB5 - #define INI_KRB5_CONF "krb5.ini" /* From k5-config.h */ - #define INI_KRB_CONF INI_KRB5_CONF /* Location of krb.conf file */ - #define DEF_KRB_CONF INI_KRB5_CONF /* Default name for krb.conf file */ +#define INI_KRB5_CONF "krb5.ini" /* From k5-config.h */ +#define INI_KRB_CONF INI_KRB5_CONF /* Location of krb.conf file */ +#define DEF_KRB_CONF INI_KRB5_CONF /* Default name for krb.conf file */ +#define INI_TICKETOPTS "TicketOptions" /* Ticket options */ +#define INI_FORWARDABLE "Forwardable" /* get forwardable tickets */ +#define INI_KRB_CCACHE "krb5cc" /* From k5-config.h */ #endif /* KRB5 */ -#define INI_KRB_REALMS "krb.realms" /* Location of krb.realms file */ -#define DEF_KRB_REALMS "krb.rea" /* Default name for krb.realms file */ +#define INI_KRB_REALMS "krb.realms" /* Location of krb.realms file */ +#define DEF_KRB_REALMS "krb.realms" /* Default name for krb.realms file */ #define INI_RECENT_LOGINS "Recent Logins" #define INI_LOGIN "Login" -#define INI_KRB_CCACHE "krb5cc" /* From k5-config.h */ diff --git a/src/windows/cns/options.c b/src/windows/cns/options.c new file mode 100644 index 000000000..8a3b77bf1 --- /dev/null +++ b/src/windows/cns/options.c @@ -0,0 +1,291 @@ +/* + * Copyright 1994 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * . + */ + +/* + * functions to tweak the options dialog + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "cns.h" + +char confname[FILENAME_MAX]; +char ccname[FILENAME_MAX]; + +/* + * Function: Process WM_INITDIALOG messages for the options dialog. + * Set up all initial dialog values from the KERBEROS_INI file. + * + * Returns: TRUE if we didn't set the focus here, + * FALSE if we did. + */ +BOOL +opts_initdialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) +{ + char wdir[FILENAME_MAX]; + char defname[FILENAME_MAX]; + char newname[FILENAME_MAX]; + UINT rc; + int lifetime; + + center_dialog(hwnd); + set_dialog_font(hwnd, hfontdialog); + rc = GetWindowsDirectory(wdir, sizeof(wdir)); + assert(rc > 0); + strcat(wdir, "\\"); + + /* krb.conf file */ + strcpy(defname, wdir); + strcat(defname, DEF_KRB_CONF); + GetPrivateProfileString(INI_FILES, INI_KRB_CONF, defname, + confname, sizeof(confname), KERBEROS_INI); +#ifndef _WIN32 + _strupr(confname); +#endif + SetDlgItemText(hwnd, IDD_CONF, confname); + +#ifdef KRB4 + /* krb.realms file */ + strcpy(defname, wdir); + strcat(defname, DEF_KRB_REALMS); + GetPrivateProfileString(INI_FILES, INI_KRB_REALMS, defname, + newname, sizeof(newname), KERBEROS_INI); +#ifndef _WIN32 + _strupr(newname); +#endif + SetDlgItemText(hwnd, IDD_REALMS, newname); +#endif /* KRB4 */ + +#ifdef KRB5 + /* Credential cache file */ + strcpy(defname, wdir); + strcat(defname, INI_KRB_CCACHE); + GetPrivateProfileString(INI_FILES, INI_KRB_CCACHE, defname, + ccname, sizeof(ccname), KERBEROS_INI); +#ifndef _WIN32 + _strupr(ccname); +#endif + SetDlgItemText(hwnd, IDD_CCACHE, ccname); +#endif /* KRB5 */ + + /* Ticket duration */ + lifetime = GetPrivateProfileInt(INI_OPTIONS, INI_DURATION, + DEFAULT_TKT_LIFE * 5, KERBEROS_INI); + SetDlgItemInt(hwnd, IDD_LIFETIME, lifetime, FALSE); + + /* Expiration action */ + GetPrivateProfileString(INI_EXPIRATION, INI_ALERT, "No", + defname, sizeof(defname), KERBEROS_INI); + alert = _stricmp(defname, "Yes") == 0; + SendDlgItemMessage(hwnd, IDD_ALERT, BM_SETCHECK, alert, 0); + + GetPrivateProfileString(INI_EXPIRATION, INI_BEEP, "No", + defname, sizeof(defname), KERBEROS_INI); + beep = _stricmp(defname, "Yes") == 0; + SendDlgItemMessage(hwnd, IDD_BEEP, BM_SETCHECK, beep, 0); + +#ifdef KRB5 + GetPrivateProfileString(INI_TICKETOPTS, INI_FORWARDABLE, "No", + defname, sizeof(defname), KERBEROS_INI); + forwardable = _stricmp(defname, "Yes") == 0; + SendDlgItemMessage(hwnd, IDD_FORWARDABLE, BM_SETCHECK, forwardable, 0); +#endif + + return TRUE; +} + + +/* + * Function: Process WM_COMMAND messages for the options dialog. + */ +void +opts_command(HWND hwnd, int cid, HWND hwndCtl, UINT codeNotify) +{ + char wdir[FILENAME_MAX]; + char defname[FILENAME_MAX]; + char newname[FILENAME_MAX]; + char *p; + BOOL b; + int lifetime; + int rc; + + switch (cid) { + case IDOK: + rc = GetWindowsDirectory(wdir, sizeof(wdir)); + assert(rc > 0); + strcat(wdir, "\\"); + + /* Ticket duration */ + lifetime = GetDlgItemInt(hwnd, IDD_LIFETIME, &b, FALSE); + + if (!b) { + MessageBox(hwnd, "Lifetime must be a number!", "", + MB_OK | MB_ICONEXCLAMATION); + return; /* TRUE */ + } + + _itoa(lifetime, defname, 10); + b = WritePrivateProfileString(INI_OPTIONS, INI_DURATION, + defname, KERBEROS_INI); + assert(b); + + /* krb.conf file */ + GetDlgItemText(hwnd, IDD_CONF, newname, sizeof(newname)); + trim(newname); + if (_stricmp(newname, confname)) { /* file name changed */ + MessageBox(NULL, + "Change to configuration file location requires a restart" + "of KerbNet.\n" + "Please exit this application and restart this application", + "", MB_OK | MB_ICONEXCLAMATION); + } + strcpy(defname, wdir); + strcat(defname, DEF_KRB_CONF); + p = (*newname && _stricmp(newname, defname)) ? newname : NULL; + if (p) + strcpy(confname, p); + b = WritePrivateProfileString(INI_FILES, INI_KRB_CONF, p, KERBEROS_INI); + assert(b); + + /* krb.realms file */ +#ifdef KRB4 + GetDlgItemText(hwnd, IDD_REALMS, newname, sizeof(newname)); + trim(newname); + strcpy(defname, wdir); + strcat(defname, DEF_KRB_REALMS); + p = (*newname && _stricmp(newname, defname)) ? newname : NULL; + b = WritePrivateProfileString(INI_FILES, INI_KRB_REALMS, p, KERBEROS_INI); + assert(b); +#endif /* KRB4 */ + + /* Credential cache file */ +#ifdef KRB5 + GetDlgItemText(hwnd, IDD_CCACHE, newname, sizeof(newname)); + trim(newname); + strcpy(defname, wdir); + strcat(defname, "krb5cc"); + if (*newname == '\0') /* For detecting name change */ + strcpy(newname, defname); + p = (*newname && _stricmp(newname, defname)) ? newname : NULL; + b = WritePrivateProfileString(INI_FILES, INI_KRB_CCACHE, p, KERBEROS_INI); + assert(b); + + if (_stricmp(ccname, newname)) { /* Did we change ccache file? */ + krb5_error_code code; + krb5_ccache cctemp; + + code = k5_init_ccache(&cctemp); + if (code) { /* Problem opening new one? */ + com_err(NULL, code, + "while changing ccache.\r\nRestoring old ccache."); + b = WritePrivateProfileString(INI_FILES, INI_KRB_CCACHE, + ccname, KERBEROS_INI); + } else { + code = krb5_cc_close(k5_context, k5_ccache); + k5_ccache = cctemp; /* Copy new into old */ + if (k5_name_from_ccache(k5_ccache)) { + kwin_init_name(GetParent(hwnd), ""); + kwin_set_default_focus(GetParent(hwnd)); + } + ticket_init_list(GetDlgItem (GetParent(hwnd), + IDD_TICKET_LIST)); + } + } +#endif /* KRB5 */ + + /* Expiration action */ + alert = (BOOL)SendDlgItemMessage(hwnd, IDD_ALERT, BM_GETCHECK, 0, 0); + p = (alert) ? "Yes" : "No"; + b = WritePrivateProfileString(INI_EXPIRATION, INI_ALERT, p, KERBEROS_INI); + assert(b); + + beep = (BOOL)SendDlgItemMessage(hwnd, IDD_BEEP, BM_GETCHECK, 0, 0); + p = (beep) ? "Yes" : "No"; + b = WritePrivateProfileString(INI_EXPIRATION, INI_BEEP, p, KERBEROS_INI); + assert(b); + +#ifdef KRB5 + forwardable = (BOOL)SendDlgItemMessage(hwnd, IDD_FORWARDABLE, + BM_GETCHECK, 0, 0); + p = (forwardable) ? "Yes" : "No"; + b = WritePrivateProfileString(INI_TICKETOPTS, INI_FORWARDABLE, + p, KERBEROS_INI); + assert(b); +#endif + + EndDialog(hwnd, IDOK); + + return; /* TRUE */ + + case IDCANCEL: + EndDialog(hwnd, IDCANCEL); + + return; /* TRUE */ + } + + return; /* FALSE */ +} + + +/* + * Function: Process dialog specific messages for the opts dialog. + */ +BOOL CALLBACK +opts_dlg_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { + HANDLE_MSG(hwnd, WM_INITDIALOG, opts_initdialog); + + HANDLE_MSG(hwnd, WM_COMMAND, opts_command); + } + + return FALSE; +} + + +/* + * Function: Display and process the options dialog. + * + * Parameters: + * hwnd - the parent window for the dialog + * + * Returns: TRUE if the dialog completed successfully, FALSE otherwise. + */ +BOOL +opts_dialog(HWND hwnd) +{ + DLGPROC dlgproc; + int rc; + +#ifdef _WIN32 + dlgproc = opts_dlg_proc; +#else + dlgproc = (FARPROC)MakeProcInstance(opts_dlg_proc, hinstance); + assert(dlgproc != NULL); + + if (dlgproc == NULL) + return FALSE; +#endif + + rc = DialogBox(hinstance, MAKEINTRESOURCE(ID_OPTS), hwnd, dlgproc); + assert(rc != -1); + +#ifndef _WIN32 + FreeProcInstance((FARPROC)dlgproc); +#endif + + return rc == IDOK; +} diff --git a/src/windows/cns/password.c b/src/windows/cns/password.c new file mode 100644 index 000000000..c9aaa6574 --- /dev/null +++ b/src/windows/cns/password.c @@ -0,0 +1,328 @@ +/* + * Copyright 1994 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * . + */ + +/* + * functions to tweak the options dialog + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "cns.h" + +/* + * Function: Changes the password. + * + * Parameters: + * hwnd - the current window from which command was invoked. + * + * name - name of user to change password for + * + * instance - instance of user to change password for + * + * realm - realm in which to change password + * + * oldpw - the old password + * + * newpw - the new password to change to + * + * Returns: TRUE if change took place, FALSE otherwise. + */ +BOOL +change_password(HWND hwnd, char *name, char *instance, char *realm, + char *oldpw, char *newpw) +{ +#ifdef KRB4 + des_cblock new_key; + char *ret_st; + int krc; + char *p; + CREDENTIALS *c; + int ncred; + char pname[ANAME_SZ]; + char pinstance[INST_SZ]; + + push_credentials(&c, pname, pinstance, &ncred); + krc = krb_get_pw_in_tkt(name, instance, realm, PWSERV_NAME, KADM_SINST, + 1, oldpw); + + if (krc != KSUCCESS) { + if (krc == INTK_BADPW) + p = "Old password is incorrect"; + else + p = krb_get_err_text(krc); + pop_credentials(c, pname, pinstance, ncred); + MessageBox(hwnd, p, "", MB_OK | MB_ICONEXCLAMATION); + + return FALSE; + } + + krc = kadm_init_link(PWSERV_NAME, KRB_MASTER, realm); + + if (krc != KSUCCESS) { + pop_credentials(c, pname, pinstance, ncred); + MessageBox(hwnd, kadm_get_err_text(krc), "", MB_OK | MB_ICONEXCLAMATION); + + return FALSE; + } + + des_string_to_key(newpw, new_key); + krc = kadm_change_pw2(new_key, newpw, &ret_st); + pop_credentials(c, pname, pinstance, ncred); + + if (ret_st != NULL) + free(ret_st); + + if (krc != KSUCCESS) { + MessageBox(hwnd, kadm_get_err_text(krc), "", MB_OK | MB_ICONEXCLAMATION); + + return FALSE; + } + + return TRUE; +#endif /* KRB4 */ + +#ifdef KRB5 + char *msg; /* Message string */ + krb5_error_code code; /* Return value */ + code = k5_change_password(k5_context, name, realm, oldpw, newpw, &msg); + + if (msg != NULL) { + MessageBox(NULL, msg, NULL, MB_ICONEXCLAMATION); + } else if (code) { + if (code == KRB5KRB_AP_ERR_BAD_INTEGRITY) + MessageBox(NULL, "Password incorrect", NULL, MB_ICONEXCLAMATION); + else if (code == ENOENT) + MessageBox(NULL, "Cannot connect to admin server", NULL, + MB_ICONEXCLAMATION); + else + com_err(NULL, code, "while changing password."); + } + + if (code == 0) + MessageBox(NULL, "Password changed.", "Kerberos", MB_OK | MB_APPLMODAL); + + return (code == 0); + +#endif /* KRB5 */ +} +/* + * Function: Process WM_COMMAND messages for the password dialog. + */ +void +password_command(HWND hwnd, int cid, HWND hwndCtl, UINT codeNotify) +{ + char name[ANAME_SZ]; + char instance[INST_SZ]; + char realm[REALM_SZ]; + char oldpw[MAX_KPW_LEN]; + char newpw1[MAX_KPW_LEN]; + char newpw2[MAX_KPW_LEN]; + HCURSOR hcursor; + BOOL b; + int id; + + if (codeNotify != BN_CLICKED) { + GetDlgItemText(hwnd, IDD_PASSWORD_NAME, name, sizeof(name)); + trim(name); + GetDlgItemText(hwnd, IDD_PASSWORD_REALM, realm, sizeof(realm)); + trim(realm); + GetDlgItemText(hwnd, IDD_OLD_PASSWORD, oldpw, sizeof(oldpw)); + GetDlgItemText(hwnd, IDD_NEW_PASSWORD1, newpw1, sizeof(newpw1)); + GetDlgItemText(hwnd, IDD_NEW_PASSWORD2, newpw2, sizeof(newpw2)); + b = strlen(name) && strlen(realm) && strlen(oldpw) && + strlen(newpw1) && strlen(newpw2); + EnableWindow(GetDlgItem(hwnd, IDOK), b); + id = (b) ? IDOK : IDD_PASSWORD_CR; + SendMessage(hwnd, DM_SETDEFID, id, 0); + + return; /* FALSE */ + } + + switch (cid) { + case IDOK: + if (isblocking) + return; /* TRUE */ + + GetDlgItemText(hwnd, IDD_PASSWORD_NAME, name, sizeof(name)); + trim(name); + GetDlgItemText(hwnd, IDD_PASSWORD_INSTANCE, instance, sizeof(instance)); + trim(instance); + GetDlgItemText(hwnd, IDD_PASSWORD_REALM, realm, sizeof(realm)); + trim(realm); + GetDlgItemText(hwnd, IDD_OLD_PASSWORD, oldpw, sizeof(oldpw)); + GetDlgItemText(hwnd, IDD_NEW_PASSWORD1, newpw1, sizeof(newpw1)); + GetDlgItemText(hwnd, IDD_NEW_PASSWORD2, newpw2, sizeof(newpw2)); + + if (strcmp(newpw1, newpw2) != 0) { + MessageBox(hwnd, "The two passwords you entered don't match!", "", + MB_OK | MB_ICONEXCLAMATION); + SetDlgItemText(hwnd, IDD_NEW_PASSWORD1, ""); + SetDlgItemText(hwnd, IDD_NEW_PASSWORD2, ""); + PostMessage(hwnd, WM_NEXTDLGCTL, + (WPARAM)GetDlgItem(hwnd, IDD_NEW_PASSWORD1), MAKELONG(1, 0)); + + return; /* TRUE */ + } + + hcursor = SetCursor(LoadCursor(NULL, IDC_WAIT)); + start_blocking_hook(BLOCK_MAX_SEC); + + if (change_password(hwnd, name, instance, realm, oldpw, newpw1)) + EndDialog(hwnd, IDOK); + else + PostMessage(hwnd, WM_NEXTDLGCTL, + (WPARAM)GetDlgItem(hwnd, IDD_OLD_PASSWORD), MAKELONG(1, 0)); + + end_blocking_hook(); + SetCursor(hcursor); + + return; /* TRUE */ + + case IDCANCEL: + if (isblocking) + WSACancelBlockingCall(); + EndDialog(hwnd, IDCANCEL); + + return; /* TRUE */ + + case IDD_PASSWORD_CR: + id = GetDlgCtrlID(GetFocus()); + assert(id != 0); + + if (id == IDD_NEW_PASSWORD2) + PostMessage(hwnd, WM_NEXTDLGCTL, + (WPARAM)GetDlgItem(hwnd, IDD_PASSWORD_NAME), MAKELONG(1, 0)); + else + PostMessage(hwnd, WM_NEXTDLGCTL, 0, 0); + + return; /* TRUE */ + + } + + return; /* FALSE */ +} + + +/* + * Function: Process WM_INITDIALOG messages for the password dialog. + * Set up all initial dialog values from the parent dialog. + * + * Returns: TRUE if we didn't set the focus here, + * FALSE if we did. + */ +BOOL +password_initdialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) +{ + char name[ANAME_SZ]; + char realm[REALM_SZ]; + HWND hwndparent; + int id; +#ifdef KRB4 + char instance[INST_SZ]; +#endif + + center_dialog(hwnd); + set_dialog_font(hwnd, hfontdialog); + + hwndparent = GetParent(hwnd); + assert(hwndparent != NULL); + + GetDlgItemText(hwndparent, IDD_LOGIN_NAME, name, sizeof(name)); + trim(name); + SetDlgItemText(hwnd, IDD_PASSWORD_NAME, name); + +#ifdef KRB4 + GetDlgItemText(hwndparent, IDD_LOGIN_INSTANCE, instance, sizeof(instance)); + trim(instance); + SetDlgItemText(hwnd, IDD_PASSWORD_INSTANCE, instance); +#endif + + GetDlgItemText(hwndparent, IDD_LOGIN_REALM, realm, sizeof(realm)); + trim(realm); + SetDlgItemText(hwnd, IDD_PASSWORD_REALM, realm); + + if (strlen(name) == 0) + id = IDD_PASSWORD_NAME; + else if (strlen(realm) == 0) + id = IDD_PASSWORD_REALM; + else + id = IDD_OLD_PASSWORD; + + SetFocus(GetDlgItem(hwnd, id)); + + return FALSE; +} + + +/* + * Function: Process dialog specific messages for the password dialog. + */ +BOOL CALLBACK +password_dlg_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { + + HANDLE_MSG(hwnd, WM_INITDIALOG, password_initdialog); + + HANDLE_MSG(hwnd, WM_COMMAND, password_command); + + case WM_SETCURSOR: + if (isblocking) { + SetCursor(LoadCursor(NULL, IDC_WAIT)); + SetWindowLong(hwnd, DWL_MSGRESULT, TRUE); + + return TRUE; + } + break; + } + + return FALSE; +} + + +/* + * Function: Display and process the password dialog. + * + * Parameters: + * hwnd - the parent window for the dialog + * + * Returns: TRUE if the dialog completed successfully, FALSE otherwise. + */ +BOOL +password_dialog(HWND hwnd) +{ + DLGPROC dlgproc; + int rc; + +#ifdef _WIN32 + dlgproc = password_dlg_proc; +#else + dlgproc = (FARPROC)MakeProcInstance(password_dlg_proc, hinstance); + assert(dlgproc != NULL); + + if (dlgproc == NULL) + return FALSE; +#endif + + rc = DialogBox(hinstance, MAKEINTRESOURCE(ID_PASSWORD), hwnd, dlgproc); + assert(rc != -1); + +#ifndef _WIN32 + FreeProcInstance((FARPROC)dlgproc); +#endif + + return rc == IDOK; +} diff --git a/src/windows/cns/tktlist.c b/src/windows/cns/tktlist.c index 8e5db5395..79d9483de 100644 --- a/src/windows/cns/tktlist.c +++ b/src/windows/cns/tktlist.c @@ -10,10 +10,12 @@ */ #if !defined(KRB5) && !defined(KRB4) - #define KRB5 1 +#define KRB5 1 #endif #include +#include + #include #include #include @@ -21,24 +23,23 @@ #include #ifdef KRB4 - #include "mit-copyright.h" - #include "kerberos.h" +#include "mit-copyright.h" +#include "kerberos.h" #endif #ifdef KRB5 - #include "winsock.h" - #include "krb5.h" - #include "com_err.h" - - #define DEFAULT_TKT_LIFE 120 - #define ANAME_SZ 40 - #define REALM_SZ 40 - #define SNAME_SZ 40 - #define INST_SZ 40 - #define MAX_KPW_LEN 128 - /* include space for '.' and '@' */ - #define MAX_K_NAME_SZ (ANAME_SZ + INST_SZ + REALM_SZ + 2) - #define ORGANIZATION "Cygnus Support" +#include "winsock.h" +#include "krb5.h" +#include "com_err.h" + +#define DEFAULT_TKT_LIFE 120 +#define ANAME_SZ 40 +#define REALM_SZ 40 +#define SNAME_SZ 40 +#define INST_SZ 40 +#define MAX_KPW_LEN 128 +/* include space for '.' and '@' */ +#define MAX_K_NAME_SZ (ANAME_SZ + INST_SZ + REALM_SZ + 2) #endif #include "cns.h" @@ -48,13 +49,13 @@ * Ticket information for a list line */ typedef struct { - BOOL ticket; /* TRUE if this is a real ticket */ - time_t issue_time; /* time_t of issue */ - long lifetime; /* Lifetime for ticket in 5 minute intervals */ - char buf[0]; /* String to display */ + BOOL ticket; /* TRUE if this is a real ticket */ + time_t issue_time; /* time_t of issue */ + long lifetime; /* Lifetime for ticket in 5 minute intervals */ + char buf[0]; /* String to display */ } TICKETINFO, *LPTICKETINFO; -/*+ +/* * Function: Returns a standard ctime date with day of week and year * removed. * @@ -64,22 +65,22 @@ typedef struct { * Returns: A pointer to the adjusted time value. */ static char * -short_date (long t) { - static char buf[26 - 4]; - char *p; - - p = ctime(&t); - assert(p != NULL); +short_date (long t) +{ + static char buf[26 - 4]; + char *p; - strcpy (buf, p + 4); - buf[12] = '\0'; + p = ctime(&t); + assert(p != NULL); - return buf; + strcpy (buf, p + 4); + buf[12] = '\0'; -} /* short_date */ + return buf; +} -/*++ +/*+ * Function: Initializes and populates the ticket list with all existing * Kerberos tickets. * @@ -89,170 +90,165 @@ short_date (long t) { * Returns: Number of elements in the list or -1 on error */ int -ticket_init_list ( - HWND hwnd) +ticket_init_list (HWND hwnd) { - int ncred; - LRESULT rc; - int l; - LPTICKETINFO lpinfo; - char buf[26+2 + 26+2 + ANAME_SZ+1 + INST_SZ+1 + REALM_SZ + 22]; - #ifdef KRB4 - int i; - time_t expiration; - char service[ANAME_SZ]; - char instance[INST_SZ]; - char realm[REALM_SZ]; - CREDENTIALS c; - #endif - #ifdef KRB5 - krb5_cc_cursor cursor; - krb5_error_code code; - krb5_creds c; - krb5_flags flags; - char *sname; /* Name of the service */ - char *flags_string(krb5_creds *cred); - #endif - - SendMessage(hwnd, WM_SETREDRAW, FALSE, 0); - - rc = SendMessage(hwnd, LB_GETCOUNT, 0, 0); - assert(rc != LB_ERR); - - if (rc > 0) - ticket_destroy(hwnd); - - while (--rc >= 0) - SendMessage(hwnd, LB_DELETESTRING, (WPARAM) rc, 0); - - #ifdef KRB4 - - ncred = krb_get_num_cred(); - for (i = 1; i <= ncred; i++) { - krb_get_nth_cred(service, instance, realm, i); - krb_get_cred(service, instance, realm, &c); - strcpy(buf, " "); - strcat(buf, short_date(c.issue_date - kwin_get_epoch())); - expiration = c.issue_date - kwin_get_epoch() + (long) c.lifetime * 5L * 60L; - strcat (buf, " "); - strcat(buf, short_date(expiration)); - strcat (buf, " "); - l = strlen(buf); - sprintf(&buf[l], "%s%s%s%s%s (%d)", - c.service, (c.instance[0] ? "." : ""), c.instance, - (c.realm[0] ? "@" : ""), c.realm, c.kvno); - l = strlen(buf); - - lpinfo = (LPTICKETINFO) malloc(sizeof(TICKETINFO) + l + 1); - assert(lpinfo != NULL); - - if (lpinfo == NULL) - return -1; - - lpinfo->ticket = TRUE; - lpinfo->issue_time = c.issue_date - kwin_get_epoch(); /* back to system time */ - lpinfo->lifetime = (long) c.lifetime * 5L * 60L; - strcpy(lpinfo->buf, buf); - - rc = SendMessage(hwnd, LB_ADDSTRING, 0, (LPARAM) lpinfo); - assert(rc >= 0); - - if (rc < 0) - return -1; - } - - #endif - - #ifdef KRB5 - - ncred = 0; - flags = 0; - if (code = krb5_cc_set_flags(k5_context, k5_ccache, flags)) { - if (code != KRB5_FCC_NOFILE) { - return -1; - } - } else { - if (code = krb5_cc_start_seq_get(k5_context, k5_ccache, &cursor)) { - return -1; - } - - while (1) { - code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &c); - if (code != 0) - break; - - ncred++; - strcpy (buf, " "); - strcat (buf, short_date (c.times.starttime - kwin_get_epoch())); - strcat (buf, " "); - strcat (buf, short_date (c.times.endtime - kwin_get_epoch())); - strcat (buf, " "); - - /* Add ticket service name and realm */ - code = krb5_unparse_name (k5_context, c.server, &sname); - if (code) { - com_err (NULL, code, "while unparsing server name"); - break; - } - strcat (buf, sname); - free (sname); - strcat (buf, flags_string (&c)); /* Add flag info */ - - l = strlen(buf); - lpinfo = (LPTICKETINFO) malloc(sizeof(TICKETINFO) + l + 1); - assert(lpinfo != NULL); - - if (lpinfo == NULL) - return -1; - - lpinfo->ticket = TRUE; - lpinfo->issue_time = c.times.starttime - kwin_get_epoch(); - lpinfo->lifetime = c.times.endtime - c.times.starttime; - strcpy(lpinfo->buf, buf); - - rc = SendMessage(hwnd, LB_ADDSTRING, 0, (LPARAM) lpinfo); - assert(rc >= 0); - - if (rc < 0) - return -1; - } - - if (code == KRB5_CC_END) { /* End of ccache */ - if (code = krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor)) { - return -1; - } - flags = KRB5_TC_OPENCLOSE; /* turns on OPENCLOSE mode */ - if (code = krb5_cc_set_flags(k5_context, k5_ccache, flags)) { - return -1; - } - } else { - return -1; - } - } - #endif - - if (ncred <= 0) { - strcpy(buf, " No Tickets"); - lpinfo = (LPTICKETINFO) malloc(sizeof(TICKETINFO) + strlen(buf) + 1); - assert(lpinfo != NULL); - - if (lpinfo == NULL) - return -1; - - lpinfo->ticket = FALSE; - strcpy (lpinfo->buf, buf); - rc = SendMessage(hwnd, LB_ADDSTRING, 0, (LPARAM) lpinfo); - assert(rc >= 0); - } - - SendMessage(hwnd, WM_SETREDRAW, TRUE, 0); - - return ncred; - -} /* ticket_init_list */ + int ncred; + LRESULT rc; + int l; + LPTICKETINFO lpinfo; + char buf[26+2 + 26+2 + ANAME_SZ+1 + INST_SZ+1 + REALM_SZ + 22]; +#ifdef KRB4 + int i; + time_t expiration; + char service[ANAME_SZ]; + char instance[INST_SZ]; + char realm[REALM_SZ]; + CREDENTIALS c; +#endif +#ifdef KRB5 + krb5_cc_cursor cursor; + krb5_error_code code; + krb5_creds c; + krb5_flags flags; + char *sname; /* Name of the service */ + char *flags_string(krb5_creds *cred); +#endif + SetWindowRedraw(hwnd, FALSE); -/*+ + rc = ListBox_GetCount(hwnd); + assert(rc != LB_ERR); + + if (rc > 0) + ticket_destroy(hwnd); + + while (--rc >= 0) + ListBox_DeleteString(hwnd, rc); + +#ifdef KRB4 + ncred = krb_get_num_cred(); + for (i = 1; i <= ncred; i++) { + krb_get_nth_cred(service, instance, realm, i); + krb_get_cred(service, instance, realm, &c); + strcpy(buf, " "); + strcat(buf, short_date(c.issue_date - kwin_get_epoch())); + expiration = c.issue_date - kwin_get_epoch() + (long) c.lifetime * 5L * 60L; + strcat (buf, " "); + strcat(buf, short_date(expiration)); + strcat (buf, " "); + l = strlen(buf); + sprintf(&buf[l], "%s%s%s%s%s (%d)", + c.service, (c.instance[0] ? "." : ""), c.instance, + (c.realm[0] ? "@" : ""), c.realm, c.kvno); + l = strlen(buf); + + lpinfo = (LPTICKETINFO) malloc(sizeof(TICKETINFO) + l + 1); + assert(lpinfo != NULL); + + if (lpinfo == NULL) + return -1; + + lpinfo->ticket = TRUE; + lpinfo->issue_time = c.issue_date - kwin_get_epoch(); /* back to system time */ + lpinfo->lifetime = (long) c.lifetime * 5L * 60L; + strcpy(lpinfo->buf, buf); + + rc = ListBox_AddItemData(hwnd, lpinfo); + assert(rc >= 0); + + if (rc < 0) + return -1; + } + +#endif + +#ifdef KRB5 + + ncred = 0; + flags = 0; + if (code = krb5_cc_set_flags(k5_context, k5_ccache, flags)) { + if (code != KRB5_FCC_NOFILE) { + return -1; + } + } else { + if (code = krb5_cc_start_seq_get(k5_context, k5_ccache, &cursor)) { + return -1; + } + while (1) { + code = krb5_cc_next_cred(k5_context, k5_ccache, &cursor, &c); + if (code != 0) + break; + + ncred++; + strcpy (buf, " "); + strcat (buf, short_date (c.times.starttime - kwin_get_epoch())); + strcat (buf, " "); + strcat (buf, short_date (c.times.endtime - kwin_get_epoch())); + strcat (buf, " "); + + /* Add ticket service name and realm */ + code = krb5_unparse_name (k5_context, c.server, &sname); + if (code) { + com_err (NULL, code, "while unparsing server name"); + break; + } + strcat (buf, sname); + + strcat (buf, flags_string (&c)); /* Add flag info */ + + l = strlen(buf); + lpinfo = (LPTICKETINFO) malloc(sizeof(TICKETINFO) + l + 1); + assert(lpinfo != NULL); + + if (lpinfo == NULL) + return -1; + + lpinfo->ticket = TRUE; + lpinfo->issue_time = c.times.starttime - kwin_get_epoch(); + lpinfo->lifetime = c.times.endtime - c.times.starttime; + strcpy(lpinfo->buf, buf); + + rc = ListBox_AddItemData(hwnd, lpinfo); + assert(rc >= 0); + + if (rc < 0) + return -1; + } + if (code == KRB5_CC_END) { /* End of ccache */ + if (code = krb5_cc_end_seq_get(k5_context, k5_ccache, &cursor)) { + return -1; + } + flags = KRB5_TC_OPENCLOSE; /* turns on OPENCLOSE mode */ + if (code = krb5_cc_set_flags(k5_context, k5_ccache, flags)) { + return -1; + } + } else { + return -1; + } + } +#endif + + if (ncred <= 0) { + strcpy(buf, " No Tickets"); + lpinfo = (LPTICKETINFO) malloc(sizeof(TICKETINFO) + strlen(buf) + 1); + assert(lpinfo != NULL); + + if (lpinfo == NULL) + return -1; + + lpinfo->ticket = FALSE; + strcpy (lpinfo->buf, buf); + rc = ListBox_AddItemData(hwnd, lpinfo); + assert(rc >= 0); + } + + SetWindowRedraw(hwnd, TRUE); + + return ncred; +} + + +/* * Function: Destroy the ticket list. Make sure to delete all * ticket entries created during ticket initialization. * @@ -261,171 +257,151 @@ ticket_init_list ( */ void ticket_destroy ( - HWND hwnd) + HWND hwnd) { - int i; - int n; - LRESULT rc; + int i; + int n; + LRESULT rc; - n = (int) SendMessage(hwnd, LB_GETCOUNT, 0, 0); + n = ListBox_GetCount(hwnd); - for (i = 0; i < n; i++) { - rc = SendMessage(hwnd, LB_GETITEMDATA, i, 0); - assert(rc != LB_ERR); + for (i = 0; i < n; i++) { + rc = ListBox_GetItemData(hwnd, i); + assert(rc != LB_ERR); - if (rc != LB_ERR) - free ((void *) rc); - } - -} /* ticket_destroy */ + if (rc != LB_ERR) + free ((void *) rc); + } +} -/*+ +/* * Function: Respond to the WM_MEASUREITEM message for the ticket list - * by setting each list item up at 1/4" hight. - * - * Parameters: - * hwnd - the window handle of the ticket window. - * - * wparam - control id of the ticket list. - * - * lparam - pointer to the MEASUREITEMSTRUCT. - * - * Returns: TRUE if message process, FALSE otherwise. + * by setting each list item up at 1/4 inch hight. */ -LONG -ticket_measureitem ( - HWND hwnd, - WPARAM wparam, - LPARAM lparam) +void +ticket_measureitem(HWND hwnd, MEASUREITEMSTRUCT *lpmi) { - int logpixelsy; - LPMEASUREITEMSTRUCT lpmi; - HDC hdc; - - lpmi = (LPMEASUREITEMSTRUCT) lparam; - hdc = GetDC(HWND_DESKTOP); - logpixelsy = GetDeviceCaps(hdc, LOGPIXELSY); - ReleaseDC(HWND_DESKTOP, hdc); - lpmi->itemHeight = logpixelsy / 4; /* 1/4 inch */ + int logpixelsy; + HDC hdc; - return TRUE; + if (lpmi->CtlID != IDD_TICKET_LIST) + return; -} /* ticket_measureitem */ + hdc = GetDC(HWND_DESKTOP); + logpixelsy = GetDeviceCaps(hdc, LOGPIXELSY); + ReleaseDC(HWND_DESKTOP, hdc); + lpmi->itemHeight = logpixelsy / 4; /* 1/4 inch */ +} -/*+ +/* * Function: Respond to the WM_DRAWITEM message for the ticket list * by displaying a single list item. - * - * Parameters: - * hwnd - the window handle of the ticket window. - * - * wparam - control id of the ticket list. - * - * lparam - pointer to the DRAWITEMSTRUCT. - * - * Returns: TRUE if message process, FALSE otherwise. */ -LONG ticket_drawitem( - HWND hwnd, - WPARAM wparam, - LPARAM lparam) +void +ticket_drawitem(HWND hwnd, const DRAWITEMSTRUCT *lpdi) { - LPDRAWITEMSTRUCT lpdi; - BOOL rc; - COLORREF bkcolor; - HBRUSH hbrush; - UINT textheight; - UINT alignment; - int left, top; - BOOL b; - LPTICKETINFO lpinfo; - HICON hicon; - #if 0 - COLORREF textcolor; - COLORREF orgbkcolor; - COLORREF orgtextcolor; - #endif - - lpdi = (LPDRAWITEMSTRUCT) lparam; - lpinfo = (LPTICKETINFO) lpdi->itemData; - - if (lpdi->itemAction == ODA_FOCUS) - return TRUE; - - #if 0 - if (lpdi->itemState & ODS_SELECTED) { - textcolor = GetSysColor(COLOR_HIGHLIGHTTEXT); - bkcolor = GetSysColor(COLOR_HIGHLIGHT); - - orgtextcolor = SetTextColor(lpdi->hDC, textcolor); - assert(textcolor != 0x80000000); - - orgbkcolor = SetBkColor(lpdi->hDC, bkcolor); - assert(bkcolor != 0x80000000); - } - else - #endif - - bkcolor = GetBkColor(lpdi->hDC); - hbrush = CreateSolidBrush(bkcolor); - assert(hbrush != NULL); - - FillRect(lpdi->hDC, &(lpdi->rcItem), hbrush); - DeleteObject(hbrush); - - /* - * Display the appropriate icon - */ - if (lpinfo->ticket) { - hicon = kwin_get_icon(lpinfo->issue_time + lpinfo->lifetime); - left = lpdi->rcItem.left - (32 - ICON_WIDTH) / 2; - top = lpdi->rcItem.top; - top += (lpdi->rcItem.bottom - lpdi->rcItem.top - 32) / 2; - - b = DrawIcon(lpdi->hDC, left, top, hicon); - assert(b); - } - - /* - * Display centered string - */ - textheight = HIWORD(GetTextExtent(lpdi->hDC, "X", 1)); - alignment = SetTextAlign(lpdi->hDC, TA_TOP | TA_LEFT); - - if (lpinfo->ticket) - left = lpdi->rcItem.left + ICON_WIDTH; - else - left = lpdi->rcItem.left; - - top = lpdi->rcItem.top; - top += (lpdi->rcItem.bottom - lpdi->rcItem.top - textheight) / 2; - rc = TextOut(lpdi->hDC, left, top, (LPSTR) lpinfo->buf, - strlen((LPSTR) lpinfo->buf)); - assert(rc); - - alignment = SetTextAlign(lpdi->hDC, alignment); - - #if 0 - if (lpdi->itemState & ODS_SELECTED) { - textcolor = SetTextColor(lpdi->hDC, orgtextcolor); - assert(textcolor != 0x80000000); - - bkcolor = SetBkColor(lpdi->hDC, orgbkcolor); - assert(bkcolor != 0x80000000); - } - - #endif - - return TRUE; - -} /* ticket_drawitem */ + BOOL rc; + COLORREF bkcolor; + HBRUSH hbrush; + UINT textheight; + UINT alignment; + int left, top; + BOOL b; + LPTICKETINFO lpinfo; + HICON hicon; +#if 0 + COLORREF textcolor; + COLORREF orgbkcolor; + COLORREF orgtextcolor; +#endif + SIZE Size; + + if (lpdi->CtlID != IDD_TICKET_LIST) + return; + + lpinfo = (LPTICKETINFO) lpdi->itemData; + + if (lpdi->itemAction == ODA_FOCUS) + return; + +#if 0 + if (lpdi->itemState & ODS_SELECTED) { + textcolor = GetSysColor(COLOR_HIGHLIGHTTEXT); + bkcolor = GetSysColor(COLOR_HIGHLIGHT); + + orgtextcolor = SetTextColor(lpdi->hDC, textcolor); + assert(textcolor != 0x80000000); + + orgbkcolor = SetBkColor(lpdi->hDC, bkcolor); + assert(bkcolor != 0x80000000); + } + else +#endif + + bkcolor = GetBkColor(lpdi->hDC); + hbrush = CreateSolidBrush(bkcolor); + assert(hbrush != NULL); + + FillRect(lpdi->hDC, &(lpdi->rcItem), hbrush); + DeleteObject(hbrush); + + /* + * Display the appropriate icon + */ + if (lpinfo->ticket) { + hicon = kwin_get_icon(lpinfo->issue_time + lpinfo->lifetime); + left = lpdi->rcItem.left - (32 - ICON_WIDTH) / 2; + top = lpdi->rcItem.top; + top += (lpdi->rcItem.bottom - lpdi->rcItem.top - 32) / 2; + + b = DrawIcon(lpdi->hDC, left, top, hicon); + assert(b); + } + + /* + * Display centered string + */ +#ifdef _WIN32 + GetTextExtentPoint32(lpdi->hDC, "X", 1, &Size); +#else + GetTextExtentPoint(lpdi->hDC, "X", 1, &Size); +#endif + + textheight = Size.cy; + + alignment = SetTextAlign(lpdi->hDC, TA_TOP | TA_LEFT); + + if (lpinfo->ticket) + left = lpdi->rcItem.left + ICON_WIDTH; + else + left = lpdi->rcItem.left; + + top = lpdi->rcItem.top; + top += (lpdi->rcItem.bottom - lpdi->rcItem.top - textheight) / 2; + rc = TextOut(lpdi->hDC, left, top, (LPSTR) lpinfo->buf, + strlen((LPSTR) lpinfo->buf)); + assert(rc); + + alignment = SetTextAlign(lpdi->hDC, alignment); + +#if 0 + if (lpdi->itemState & ODS_SELECTED) { + textcolor = SetTextColor(lpdi->hDC, orgtextcolor); + assert(textcolor != 0x80000000); + + bkcolor = SetBkColor(lpdi->hDC, orgbkcolor); + assert(bkcolor != 0x80000000); + } + +#endif +} #ifdef KRB5 -/*+ +/* * * Flags_string * @@ -434,39 +410,39 @@ LONG ticket_drawitem( */ char * flags_string(krb5_creds *cred) { - static char buf[32]; - int i = 0; - - buf[i++] = ' '; - buf[i++] = '('; - if (cred->ticket_flags & TKT_FLG_FORWARDABLE) - buf[i++] = 'F'; - if (cred->ticket_flags & TKT_FLG_FORWARDED) - buf[i++] = 'f'; - if (cred->ticket_flags & TKT_FLG_PROXIABLE) - buf[i++] = 'P'; - if (cred->ticket_flags & TKT_FLG_PROXY) - buf[i++] = 'p'; - if (cred->ticket_flags & TKT_FLG_MAY_POSTDATE) - buf[i++] = 'D'; - if (cred->ticket_flags & TKT_FLG_POSTDATED) - buf[i++] = 'd'; - if (cred->ticket_flags & TKT_FLG_INVALID) - buf[i++] = 'i'; - if (cred->ticket_flags & TKT_FLG_RENEWABLE) - buf[i++] = 'R'; - if (cred->ticket_flags & TKT_FLG_INITIAL) - buf[i++] = 'I'; - if (cred->ticket_flags & TKT_FLG_HW_AUTH) - buf[i++] = 'H'; - if (cred->ticket_flags & TKT_FLG_PRE_AUTH) - buf[i++] = 'A'; - - buf[i++] = ')'; - buf[i] = '\0'; - if (i <= 3) - buf[0] = '\0'; - return(buf); + static char buf[32]; + int i = 0; + + buf[i++] = ' '; + buf[i++] = '('; + if (cred->ticket_flags & TKT_FLG_FORWARDABLE) + buf[i++] = 'F'; + if (cred->ticket_flags & TKT_FLG_FORWARDED) + buf[i++] = 'f'; + if (cred->ticket_flags & TKT_FLG_PROXIABLE) + buf[i++] = 'P'; + if (cred->ticket_flags & TKT_FLG_PROXY) + buf[i++] = 'p'; + if (cred->ticket_flags & TKT_FLG_MAY_POSTDATE) + buf[i++] = 'D'; + if (cred->ticket_flags & TKT_FLG_POSTDATED) + buf[i++] = 'd'; + if (cred->ticket_flags & TKT_FLG_INVALID) + buf[i++] = 'i'; + if (cred->ticket_flags & TKT_FLG_RENEWABLE) + buf[i++] = 'R'; + if (cred->ticket_flags & TKT_FLG_INITIAL) + buf[i++] = 'I'; + if (cred->ticket_flags & TKT_FLG_HW_AUTH) + buf[i++] = 'H'; + if (cred->ticket_flags & TKT_FLG_PRE_AUTH) + buf[i++] = 'A'; + + buf[i++] = ')'; + buf[i] = '\0'; + if (i <= 3) + buf[0] = '\0'; + return(buf); } #endif /* KRB5 */ diff --git a/src/windows/cns/tktlist.h b/src/windows/cns/tktlist.h index 1ebd146a7..a522f76c7 100644 --- a/src/windows/cns/tktlist.h +++ b/src/windows/cns/tktlist.h @@ -16,20 +16,12 @@ /* * Prototypes */ -BOOL ticket_init_list( - HWND hwnd); +BOOL ticket_init_list(HWND); -void ticket_destroy( - HWND hwnd); +void ticket_destroy(HWND); -LONG ticket_measureitem( - HWND hwnd, - WPARAM wparam, - LPARAM lparam); +void ticket_measureitem(HWND, MEASUREITEMSTRUCT *); -LONG ticket_drawitem( - HWND hwnd, - WPARAM wparam, - LPARAM lparam); +void ticket_drawitem(HWND, const DRAWITEMSTRUCT *); #endif diff --git a/src/windows/gina/Makefile.in b/src/windows/gina/Makefile.in new file mode 100644 index 000000000..21576ffc9 --- /dev/null +++ b/src/windows/gina/Makefile.in @@ -0,0 +1,36 @@ +##DOSBUILDTOP=..\.. + +OBJS= ginastub.$(OBJEXT) + +DEBUG=1 + +INCLUDES = -I$(BUILDTOP)\include + +WINLIBS = advapi32.lib comctl32.lib \ + libc.lib kernel32.lib wsock32.lib user32.lib shell32.lib oldnames.lib + +#comctl32.lib msvcrt.lib advapi32.lib gdi32.lib comdlg32.lib winspool.lib + +WINDLLFLAGS = /nodefaultlib /incremental:no /pdb:none /release \ + /nologo /align:0x1000 /base:0x1c000000 /dll /debug + +##WIN32##!if defined(DEBUG) +##WIN32##CFLAGS = $(CCOPTS2) $(INCLUDES) -DUNICODE -D_UNICODE -DDBG +##WIN32##!else +##WIN32##CFLAGS = $(CCOPTS2) $(INCLUDES) -DUNICODE -D_UNICODE +##WIN32##!endif + +all-windows:: +##WIN32##all-windows:: kgina.dll + +clean-windows:: + $(RM) kgina.dll + +kgina.dll: $(OBJS) $(KLIB) + link $(WINDLLFLAGS) -def:gina.def -out:$*.dll \ + $** $(WINLIBS) + +ginastub.obj: ginastub.h + +#gina.res: res.rc +# $(RC) $(RFLAGS) -r -fo $@ res.rc diff --git a/src/windows/gina/gina.def b/src/windows/gina/gina.def new file mode 100644 index 000000000..99e066bec --- /dev/null +++ b/src/windows/gina/gina.def @@ -0,0 +1,21 @@ +LIBRARY KGINA + +DESCRIPTION 'Alternate Windows NT Logon GUI' + +EXPORTS +; Version 1.0 + WlxNegotiate + WlxInitialize + WlxDisplaySASNotice + WlxLoggedOutSAS + WlxActivateUserShell + WlxLoggedOnSAS + WlxDisplayLockedNotice + WlxWkstaLockedSAS + WlxIsLockOk + WlxIsLogoffOk + WlxLogoff + WlxShutdown +; Version 1.1 + WlxScreenSaverNotify + WlxStartApplication diff --git a/src/windows/gina/ginastub.c b/src/windows/gina/ginastub.c new file mode 100644 index 000000000..ec4291b2b --- /dev/null +++ b/src/windows/gina/ginastub.c @@ -0,0 +1,365 @@ + +/* + Copyright (c) 1996 Microsoft Corporation + +Module Name: + ginastub.c + +Abstract: + This sample illustrates a pass-thru "stub" gina which can be used + in some cases to simplify gina development. + + A common use for a gina is to implement code which requires the + credentials of the user logging onto the workstation. The credentials + may be required for syncronization with foreign account databases + or custom authentication activities. + + In this example case, it is possible to implement a simple gina + stub layer which simply passes control for the required functions + to the previously installed gina, and captures the interesting + parameters from that gina. In this scenario, the existing functionality + in the existent gina is retained. In addition, the development time + is reduced drastically, as existing functionality does not need to + be duplicated. + + When dealing with credentials, take steps to maintain the security + of the credentials. For instance, if transporting credentials over + a network, be sure to encrypt the credentials. + +Author: + Scott Field (sfield) 18-Jul-96 +*/ + + +#include +#include +#include +#include "ginastub.h" + + +/* Location of the real msgina. */ + +#define REALGINA_PATH TEXT("MSGINA.DLL") + + +/* winlogon function dispatch table */ +PGWLX_DISPATCH_VERSION pWlxFuncs; + + +/* winlogon version */ +DWORD WlxVersion; + + +/* Functions pointers to the real msgina which we will call. */ + +PGWLX_Negotiate GWlxNegotiate; +PGWLX_Initialize GWlxInitialize; +PGWLX_DisplaySASNotice GWlxDisplaySASNotice; +PGWLX_LoggedOutSAS GWlxLoggedOutSAS; +PGWLX_ActivateUserShell GWlxActivateUserShell; +PGWLX_LoggedOnSAS GWlxLoggedOnSAS; +PGWLX_DisplayLockedNotice GWlxDisplayLockedNotice; +PGWLX_WkstaLockedSAS GWlxWkstaLockedSAS; +PGWLX_IsLockOk GWlxIsLockOk; +PGWLX_IsLogoffOk GWlxIsLogoffOk; +PGWLX_Logoff GWlxLogoff; +PGWLX_Shutdown GWlxShutdown; + + +/* NEW for version 1.1 */ + +PGWLX_StartApplication GWlxStartApplication; +PGWLX_ScreenSaverNotify GWlxScreenSaverNotify; + + +/* hook into the real GINA. */ + +static BOOL +MyInitialize(void) +{ + HINSTANCE hDll; + + /* Load MSGINA.DLL. */ + + if (! (hDll = LoadLibrary(REALGINA_PATH))) + return FALSE; + + + /* Get pointers to all of the WLX functions in the real MSGINA. */ + + GWlxNegotiate = (PGWLX_Negotiate) + GetProcAddress(hDll, "WlxNegotiate"); + if (! GWlxNegotiate) + return FALSE; + + GWlxInitialize = (PGWLX_Initialize) + GetProcAddress(hDll, "WlxInitialize"); + if (! GWlxInitialize) + return FALSE; + + GWlxDisplaySASNotice = (PGWLX_DisplaySASNotice) + GetProcAddress(hDll, "WlxDisplaySASNotice"); + if (! GWlxDisplaySASNotice) + return FALSE; + + GWlxLoggedOutSAS = (PGWLX_LoggedOutSAS) + GetProcAddress(hDll, "WlxLoggedOutSAS"); + if (! GWlxLoggedOutSAS) + return FALSE; + + GWlxActivateUserShell = (PGWLX_ActivateUserShell) + GetProcAddress(hDll, "WlxActivateUserShell"); + if (! GWlxActivateUserShell) + return FALSE; + + GWlxLoggedOnSAS = (PGWLX_LoggedOnSAS) + GetProcAddress(hDll, "WlxLoggedOnSAS"); + if (! GWlxLoggedOnSAS) + return FALSE; + + GWlxDisplayLockedNotice = (PGWLX_DisplayLockedNotice) + GetProcAddress(hDll, "WlxDisplayLockedNotice"); + if (! GWlxDisplayLockedNotice) + return FALSE; + + GWlxIsLockOk = (PGWLX_IsLockOk) + GetProcAddress(hDll, "WlxIsLockOk"); + if (! GWlxIsLockOk) + return FALSE; + + GWlxWkstaLockedSAS = (PGWLX_WkstaLockedSAS) + GetProcAddress(hDll, "WlxWkstaLockedSAS"); + if (! GWlxWkstaLockedSAS) + return FALSE; + + GWlxIsLogoffOk = (PGWLX_IsLogoffOk) + GetProcAddress(hDll, "WlxIsLogoffOk"); + if (! GWlxIsLogoffOk) + return FALSE; + + GWlxLogoff = (PGWLX_Logoff) + GetProcAddress(hDll, "WlxLogoff"); + if (! GWlxLogoff) + return FALSE; + + GWlxShutdown = (PGWLX_Shutdown) + GetProcAddress(hDll, "WlxShutdown"); + if (! GWlxShutdown) + return FALSE; + + + /* Don't check for failure because these don't exist prior to NT 4.0 */ + + GWlxStartApplication = (PGWLX_StartApplication) + GetProcAddress(hDll, "WlxStartApplication"); + GWlxScreenSaverNotify = (PGWLX_ScreenSaverNotify) + GetProcAddress(hDll, "WlxScreenSaverNotify"); + + + /* Everything loaded ok. Return success. */ + return TRUE; +} + +BOOL +WINAPI +WlxNegotiate( + DWORD dwWinlogonVersion, + DWORD *pdwDllVersion) +{ + if (! MyInitialize()) + return FALSE; + + WlxVersion = dwWinlogonVersion; + return (* GWlxNegotiate)(dwWinlogonVersion, pdwDllVersion); +} + +BOOL +WINAPI +WlxInitialize( + LPWSTR lpWinsta, + HANDLE hWlx, + PVOID pvReserved, + PVOID pWinlogonFunctions, + PVOID *pWlxContext) +{ + pWlxFuncs = (PGWLX_DISPATCH_VERSION) pWinlogonFunctions; + + return (* GWlxInitialize)( + lpWinsta, + hWlx, + pvReserved, + pWinlogonFunctions, + pWlxContext + ); +} + +VOID +WINAPI +WlxDisplaySASNotice( + PVOID pWlxContext) +{ + (* GWlxDisplaySASNotice)(pWlxContext); +} + +int +WINAPI +WlxLoggedOutSAS( + PVOID pWlxContext, + DWORD dwSasType, + PLUID pAuthenticationId, + PSID pLogonSid, + PDWORD pdwOptions, + PHANDLE phToken, + PWLX_MPR_NOTIFY_INFO pMprNotifyInfo, + PVOID *pProfile) +{ + int iRet; + + iRet = (* GWlxLoggedOutSAS)( + pWlxContext, + dwSasType, + pAuthenticationId, + pLogonSid, + pdwOptions, + phToken, + pMprNotifyInfo, + pProfile + ); + + if (iRet == WLX_SAS_ACTION_LOGON) { + /* copy pMprNotifyInfo and pLogonSid for later use */ + + /* pMprNotifyInfo->pszUserName */ + /* pMprNotifyInfo->pszDomain */ + /* pMprNotifyInfo->pszPassword */ + /* pMprNotifyInfo->pszOldPassword */ + } + + return iRet; +} + +BOOL +WINAPI +WlxActivateUserShell( + PVOID pWlxContext, + PWSTR pszDesktopName, + PWSTR pszMprLogonScript, + PVOID pEnvironment) +{ + return (* GWlxActivateUserShell)( + pWlxContext, + pszDesktopName, + pszMprLogonScript, + pEnvironment + ); +} + +int +WINAPI +WlxLoggedOnSAS( + PVOID pWlxContext, + DWORD dwSasType, + PVOID pReserved) +{ + return (* GWlxLoggedOnSAS)(pWlxContext, dwSasType, pReserved); +} + +VOID +WINAPI +WlxDisplayLockedNotice( + PVOID pWlxContext) +{ + (* GWlxDisplayLockedNotice)(pWlxContext); +} + +BOOL +WINAPI +WlxIsLockOk( + PVOID pWlxContext) +{ + return (* GWlxIsLockOk)(pWlxContext); +} + +int +WINAPI +WlxWkstaLockedSAS( + PVOID pWlxContext, + DWORD dwSasType) +{ + return (* GWlxWkstaLockedSAS)(pWlxContext, dwSasType); +} + +BOOL +WINAPI +WlxIsLogoffOk( + PVOID pWlxContext + ) +{ + BOOL bSuccess; + + bSuccess = (* GWlxIsLogoffOk)(pWlxContext); + if (bSuccess) { + /* if it's ok to logoff, finish with the stored credentials */ + /* and scrub the buffers */ + } + + return bSuccess; +} + +VOID +WINAPI +WlxLogoff( + PVOID pWlxContext + ) +{ + (* GWlxLogoff)(pWlxContext); +} + +VOID +WINAPI +WlxShutdown( +PVOID pWlxContext, +DWORD ShutdownType +) +{ + (* GWlxShutdown)(pWlxContext, ShutdownType); +} + + +/* NEW for version 1.1 */ + +BOOL +WINAPI +WlxScreenSaverNotify( +PVOID pWlxContext, +BOOL * pSecure +) +{ + if (GWlxScreenSaverNotify) + return (* GWlxScreenSaverNotify)(pWlxContext, pSecure); + + /* if not exported, return something intelligent */ + *pSecure = TRUE; + return TRUE; +} + +BOOL +WINAPI +WlxStartApplication( + PVOID pWlxContext, + PWSTR pszDesktopName, + PVOID pEnvironment, + PWSTR pszCmdLine + ) +{ + if (GWlxStartApplication) + return (* GWlxStartApplication)( + pWlxContext, + pszDesktopName, + pEnvironment, + pszCmdLine + ); + + /* if not exported, return something intelligent */ + return TRUE; /* ??? */ +} diff --git a/src/windows/gina/ginastub.h b/src/windows/gina/ginastub.h new file mode 100644 index 000000000..e9c833492 --- /dev/null +++ b/src/windows/gina/ginastub.h @@ -0,0 +1,39 @@ +/* WinLogin 1.0 */ +typedef BOOL (CALLBACK * PGWLX_Negotiate) + (DWORD, DWORD *); +typedef BOOL (CALLBACK * PGWLX_Initialize) + (LPWSTR, HANDLE, PVOID, PVOID, PVOID); +typedef VOID (CALLBACK * PGWLX_DisplaySASNotice) + (PVOID); +typedef int (CALLBACK * PGWLX_LoggedOutSAS) + (PVOID, DWORD, PLUID, PSID, PDWORD, PHANDLE, + PWLX_MPR_NOTIFY_INFO, PVOID *); +typedef BOOL (CALLBACK * PGWLX_ActivateUserShell) + (PVOID, PWSTR, PWSTR, PVOID); +typedef int (CALLBACK * PGWLX_LoggedOnSAS) + (PVOID, DWORD, PVOID); +typedef VOID (CALLBACK * PGWLX_DisplayLockedNotice) + (PVOID); +typedef int (CALLBACK * PGWLX_WkstaLockedSAS) + (PVOID, DWORD); +typedef BOOL (CALLBACK * PGWLX_IsLockOk) + (PVOID); +typedef BOOL (CALLBACK * PGWLX_IsLogoffOk) + (PVOID); +typedef VOID (CALLBACK * PGWLX_Logoff) + (PVOID); +typedef VOID (CALLBACK * PGWLX_Shutdown) + (PVOID, DWORD); + +/* WinLogin 1.1 */ +typedef BOOL (CALLBACK * PGWLX_StartApplication) + (PVOID, PWSTR, PVOID, PWSTR); +typedef BOOL (CALLBACK * PGWLX_ScreenSaverNotify) + (PVOID, BOOL *); + + +#if defined(WLX_VERSION_1_1) +typedef PWLX_DISPATCH_VERSION_1_1 PGWLX_DISPATCH_VERSION; +#else +typedef PWLX_DISPATCH_VERSION_1_0 PGWLX_DISPATCH_VERSION; +#endif diff --git a/src/windows/gss/ChangeLog b/src/windows/gss/ChangeLog index b2fa4d7b3..ebd251620 100644 --- a/src/windows/gss/ChangeLog +++ b/src/windows/gss/ChangeLog @@ -1,3 +1,11 @@ +Tue Feb 4 16:18:25 1997 Richard Basch + + * Makefile.in: win16 - fixed the winsock.lib path reference + +Thu Jan 30 22:07:35 1997 Richard Basch + + * Makefile.in: Win32 - link in the resource file + Fri Nov 22 15:52:55 1996 unknown * gss-client.c (connect_to_server): use sizeof instead of h_length diff --git a/src/windows/gss/Makefile.in b/src/windows/gss/Makefile.in index 540f24e99..949a8dbb0 100644 --- a/src/windows/gss/Makefile.in +++ b/src/windows/gss/Makefile.in @@ -1,51 +1,59 @@ # makefile: Constructs the Kerberos for Windows ticket manager # Works for both k4 and k5 releases. # -NAME = gss OBJS = gss.obj gss-client.obj gss-misc.obj +##WIN32##XOBJS = resource.obj ##### Options DEBUG = 1 BUILDTOP =..\.. -LIBDIR = $(BUILDTOP)\lib -GLIB = $(LIBDIR)\gssapi.lib -WLIB = $(LIBDIR)\winsock.lib +##WIN16##WLIB = $(BUILDTOP)\lib\winsock.lib INCLUDES = /I$(BUILDTOP)\include /I$(BUILDTOP)\include\krb5 ##### C Compiler -CC = cl -CFLAGS_RELEASE = /nologo /W3 /AL /GAs /Gy /G2 /Zp /O2 /DNDEBUG=1 -CFLAGS_DEBUG = /nologo /W3 /AL /GAs /Gy /G2 /Zp /O2 /Od /Zi !if $(DEBUG) -CFLAGS = $(CFLAGS_DEBUG) $(INCLUDES) +CFLAGS = $(CCOPTS2) $(INCLUDES) /Zi !else -CFLAGS = $(CFLAGS_RELEASE) $(INCLUDES) +CFLAGS = $(CCOPTS2) $(INCLUDES) !endif ##### RC Compiler -RC = rc -##WIN16##RFLAGS = /nologo $(INCLUDES) +##WIN16##RFLAGS = /nologo /D$(KRB)=1 $(INCLUDES) ##WIN32##RFLAGS = $(INCLUDES) + ##### Linker LINK = link LIBS = $(GLIB) $(WLIB) -SYSLIBS = libw llibcew +##WIN16##SYSLIBS = libw llibcew +##WIN32##SYSLIBS = libc.lib kernel32.lib wsock32.lib user32.lib \ +##WIN32## gdi32.lib comdlg32.lib !if $(DEBUG) -LFLAGS = /co /nologo /nod /nopackcode /map:full +##WIN16##LFLAGS = /co /nologo /nod /nopackcode /map:full +##WIN32##LFLAGS = /nologo /nod /debug !else -LFLAGS = /nologo /nod /nopackcode +##WIN16##LFLAGS = /nologo /nod /nopackcode +##WIN32##LFLAGS = /nologo /nod !endif -all:: makefile $(NAME).exe +all:: makefile gss.exe + +gss.exe: $*.def $*.res $(OBJS) $(XOBJS) $(LIBS) +##WIN16## $(LINK) $(LFLAGS) $(OBJS), $@, $*.map, \ +##WIN16## $(LIBS) $(SYSLIBS), $*.def +##WIN16## $(RC) $(RFLAGS) /k $*.res $@ +##WIN32## $(LINK) $(LFLAGS) /map:$*.map /out:$@ $(OBJS) $(XOBJS) \ +##WIN32## $(LIBS) $(SYSLIBS) + +##WIN32##gss.res: gss.rc +##WIN32## $(RC) $(RFLAGS) /r $*.rc -$(NAME).exe: $*.def $*.res $(OBJS) $(LIBS) - $(LINK) $(LFLAGS) $(OBJS), $@, $*.map, $(LIBS) $(SYSLIBS), $*.def - $(RC) $(RFLAGS) /k $*.res $@ +##WIN32##resource.obj: gss.res +##WIN32## $(CVTRES) /nologo /out:$@ gss.res -$(OBJS) $(NAME).res: gss.h +$(OBJS) gss.res: gss.h -install: +install:: copy gss.exe ..\floppy clean:: diff --git a/src/windows/wintel/ChangeLog b/src/windows/wintel/ChangeLog index 9e2a9a532..521c68f58 100644 --- a/src/windows/wintel/ChangeLog +++ b/src/windows/wintel/ChangeLog @@ -1,16 +1,3 @@ -Sat Dec 21 03:34:35 1996 Theodore Y. Ts'o - - * screen.c (ScreenWndProc): Remove (under #ifdef) mention of - calling Cygnus Support for support. - -Sat Nov 23 00:27:45 1996 Theodore Ts'o - - * Makefile.in (KLIB): Change krb516.dll to krb5_16.dll. [PR#204] - -Wed Nov 20 18:32:26 1996 Theodore Y. Ts'o - - * Makefile.in (KLIB): Change libkrb5.dll to be krb516.dll - Wed Jun 12 00:22:02 1996 Theodore Ts'o * makefile: Renamed to Makefile.in, so that we can do WIN16/WIN32 diff --git a/src/windows/wintel/Makefile.in b/src/windows/wintel/Makefile.in index 5f49bcf6e..2912ab172 100644 --- a/src/windows/wintel/Makefile.in +++ b/src/windows/wintel/Makefile.in @@ -1,106 +1,65 @@ -# makefile: Constructs the kerborized telnet client +# Makefile for the Kerberos for Windows telnet client # Works for both k4 and k5 releases. # -NAME = telnet -OBJS = $(NAME).obj negotiat.obj auth.obj edit.obj emul.obj \ - font.obj intern.obj screen.obj +OBJS = telnet.obj negotiat.obj auth.obj edit.obj emul.obj \ + font.obj intern.obj screen.obj encrypt.obj genget.obj ##### Options DEBUG = 1 !IF ! defined(KVERSION) +KRBOPT=-DFORWARD -DAUTHENTICATION -DENCRYPTION -DDES_ENCRYPTION KVERSION = 5 !endif KRB = KRB$(KVERSION) -!if $(KVERSION) == 4 -BUILDTOP = .. -LIBDIR = $(BUILDTOP)\lib\krb -KLIB = $(LIBDIR)\kerberos.lib -WLIB = $(LIBDIR)\winsock.lib -INCLUDES = /I$(BUILDTOP)\include -XOBJS = -!endif +###WIN16##WLIB = $(BUILDTOP)\lib\winsock.lib -!if $(KVERSION) == 5 BUILDTOP =..\.. -LIBDIR = $(BUILDTOP)\lib -KLIB = $(LIBDIR)\krb5_16.lib -WLIB = $(LIBDIR)\winsock.lib INCLUDES = /I$(BUILDTOP)\include /I$(BUILDTOP)\include\krb5 \ - /I$(BUILDTOP)\lib\crypto\des -XOBJS = k5stream.obj -!endif + /I$(BUILDTOP)\lib\crypto\des +##WIN16##XOBJS = k5stream.obj +##WIN32##XOBJS = resource.obj k5stream.obj enc_des.obj -##### C Compiler -CC = cl -CFLAGS_RELEASE = /nologo /W3 /AL /GAs /G2 /Zp /O2 /DNDEBUG=1 -CFLAGS_DEBUG = /nologo /W3 /AL /GAs /G2 /Zp /O2 /Od /Zi -!if $(DEBUG) -CFLAGS = $(CFLAGS_DEBUG) $(INCLUDES) /D$(KRB)=1 +!if defined(DEBUG) +CFLAGS = $(CCOPTS2) $(INCLUDES) /D$(KRB)=1 $(KRBOPT) /Zi !else -CFLAGS = $(CFLAGS_RELEASE) $(INCLUDES) /D$(KRB)=1 +CFLAGS = $(CCOPTS2) $(INCLUDES) /D$(KRB)=1 $(KRBOPT) !endif -##### RC Compiler -RC = rc -##WIN16##RFLAGS_RELEASE = /nologo /DNDEBUG -##WIN16##RFLAGS_DEBUG = /nologo -##WIN32##RFLAGS_RELEASE = /DNDEBUG -##WIN32##RFLAGS_DEBUG = -!if $(DEBUG) -RFLAGS = $(RFLAGS_DEBUG) $(INCLUDES) -!else -RFLAGS = $(RFLAGS_RELEASE) $(INCLUDES) -!endif +#RFLAGS = /D$(KRB)=1 $(INCLUDES) $(KRBOPT) +RFLAGS = -D$(KRB)=1 $(KRBOPT) + ##### Linker -LINK = link +LINK = link LIBS = $(KLIB) $(WLIB) -SYSLIBS = libw llibcew commdlg -!if $(DEBUG) -LFLAGS = /co /nologo /nod /packc:61440 /stack:32768 /align:16 /onerror:noexe +##WIN16##SYSLIBS = libw llibcew +##WIN32##SYSLIBS = libc.lib kernel32.lib wsock32.lib user32.lib gdi32.lib \ +##WIN32## comdlg32.lib +!if defined(DEBUG) +##WIN16##LFLAGS = /co /nologo /nod /nopackcode /map:full +##WIN32##LFLAGS = /nologo /nod /debug !else -LFLAGS = /nologo /nod /packc:61440 /stack:32768 /align:16 /onerror:noexe +##WIN16##LFLAGS = /nologo /nod /nopackcode +##WIN32##LFLAGS = /nologo /nod !endif -all:: makefile $(NAME).exe - -$(NAME).exe: $*.def $*.res $(OBJS) $(XOBJS) $(LIBS) - $(LINK) $(LFLAGS) $(OBJS) $(XOBJS), $@, $*.map, \ - $(LIBS) $(SYSLIBS), $*.def - $(RC) $(RFLAGS) /k $*.res $@ - -install: - copy $(NAME).exe ..\floppy - -clean:: - if exist *.obj del *.obj - if exist *.exe del *.exe - if exist *.res del *.res - if exist *.map del *.map - if exist *.pdb del *.pdb - if exist *.err del *.err - if exist ..\floppy\$(NAME).exe del ..\floppy\$(NAME).exe +all:: makefile telnet.exe -telnet.obj: telnet.h dialog.h screen.h struct.h wt-proto.h ini.h +telnet.exe: $*.def $*.res $(OBJS) $(XOBJS) $(LIBS) +##WIN16## $(LINK) $(LFLAGS) $(OBJS) $(XOBJS), $@, $*.map, \ +##WIN16## $(LIBS) $(SYSLIBS), $*.def +##WIN16## $(RC) $(RFLAGS) /k telnet.rc $@ +##WIN32## $(LINK) $(LFLAGS) /map:$*.map /out:$@ $(OBJS) $(XOBJS) \ +##WIN32## $(LIBS) $(SYSLIBS) -negotiat.obj: telnet.h dialog.h screen.h struct.h wt-proto.h ini.h +##WIN32##telnet.res: telnet.rc +##WIN32## $(RC) $(RFLAGS) /r $*.rc +##WIN32##resource.obj: telnet.res +##WIN32## $(CVTRES) /nologo /out:resource.obj telnet.res -auth.obj: telopts.h telnet.h dialog.h screen.h struct.h wt-proto.h ini.h - -edit.obj: screen.h - -emul.obj: screen.h - -font.obj: screen.h ini.h - -intern.obj: screen.h - -screen.obj: screen.h ini.h - -telnet.res: screen.h dialog.h telnet.dlg ncsa.ico terminal.ico - -!if $(KVERSION) == 5 -k5stream.c: k5stream.h auth.h -!endif +install:: + copy telnet.exe $(DESTDIR) +clean:: + $(RM) *.exe *.res *.map diff --git a/src/windows/wintel/auth.c b/src/windows/wintel/auth.c index 4d3d380e5..bba43865f 100644 --- a/src/windows/wintel/auth.c +++ b/src/windows/wintel/auth.c @@ -3,169 +3,197 @@ */ #ifdef KRB4 - #include - #include - #include - #include "winsock.h" - #include "kerberos.h" +#include +#include +#include +#include "winsock.h" +#include "kerberos.h" #endif #ifdef KRB5 - #include - #include - #include "krb5.h" - #include "com_err.h" +#include +#include +#include "krb5.h" +#include "com_err.h" #endif #include "telnet.h" -#include "telopts.h" +#include "telnet_arpa.h" + +#ifdef ENCRYPTION +#include "encrypt.h" +#endif /* * Constants */ - #define IS 0 - #define SEND 1 - #define REPLY 2 - #define NAME 3 - - #define AUTH_NULL 0 - #define KERBEROS_V4 1 - #define KERBEROS_V5 2 - #define SPX 3 - #define RSA 6 - #define LOKI 10 - - #define AUTH 0 - #define K4_REJECT 1 - #define K4_ACCEPT 2 - #define K4_CHALLENGE 3 - #define K4_RESPONSE 4 - - #define K5_REJECT 1 - #define K5_ACCEPT 2 - #define K5_RESPONSE 3 // They had to make it different - - #define AUTH_WHO_MASK 1 - #define AUTH_CLIENT_TO_SERVER 0 - #define AUTH_SERVER_TO_CLIENT 1 - - #define AUTH_HOW_MASK 2 - #define AUTH_HOW_ONE_WAY 0 - #define AUTH_HOW_MUTUAL 2 - - #ifndef KSUCCESS // Let K5 use K4 constants - #define KSUCCESS 0 - #define KFAILURE 255 - #endif +#ifdef KRB4 +#define KRB_AUTH 0 +#define KRB_REJECT 1 +#define KRB_ACCEPT 2 +#define KRB_CHALLENGE 3 +#define KRB_RESPONSE 4 +#endif +#ifdef KRB5 +#define KRB_AUTH 0 /* Authentication data follows */ +#define KRB_REJECT 1 /* Rejected (reason might follow) */ +#define KRB_ACCEPT 2 /* Accepted */ +#define KRB_RESPONSE 3 /* Response for mutual auth. */ + +#define KRB_FORWARD 4 /* Forwarded credentials follow */ +#define KRB_FORWARD_ACCEPT 5 /* Forwarded credentials accepted */ +#define KRB_FORWARD_REJECT 6 /* Forwarded credentials rejected */ +#endif + +#ifndef KSUCCESS /* Let K5 use K4 constants */ +#define KSUCCESS 0 +#define KFAILURE 255 +#endif + /* * Globals */ - #ifdef KRB4 - static CREDENTIALS cred; - static KTEXT_ST auth; +#ifdef KRB4 +static CREDENTIALS cred; +static KTEXT_ST auth; - #define KRB_SERVICE_NAME "rcmd" - #define KERBEROS_VERSION KERBEROS_V4 +#define KRB_SERVICE_NAME "rcmd" +#define KERBEROS_VERSION KERBEROS_V4 - static int auth_how; - static int k4_auth_send (kstream ks); - static int k4_auth_reply (kstream ks, unsigned char *data, int cnt); - #endif - #ifdef KRB5 - static krb5_data auth; - static int auth_how; - static krb5_auth_context auth_context; +static int auth_how; +static int k4_auth_send(kstream); +static int k4_auth_reply(kstream, unsigned char *, int); +#endif - #define KRB_SERVICE_NAME "host" - #define KERBEROS_VERSION KERBEROS_V5 +#ifdef KRB5 +static krb5_data auth; +static int auth_how; +static krb5_auth_context auth_context; +krb5_keyblock *session_key = NULL; +#ifdef FORWARD +void kerberos5_forward(kstream); +#endif - static int k5_auth_send (int how); - static int k5_auth_reply (int how, unsigned char *data, int cnt); - #endif +#define KRB_SERVICE_NAME "host" +#define KERBEROS_VERSION AUTHTYPE_KERBEROS_V5 + +static int k5_auth_send(kstream, int); +static int k5_auth_reply(kstream, int, unsigned char *, int); +#endif + +static int Data(kstream, int, void *, int); + +#ifdef ENCRYPTION +BOOL encrypt_flag = 1; +#endif +#ifdef FORWARD +BOOL forward_flag = 1; /* forward tickets? */ +BOOL forwardable_flag = 1; /* get forwardable tickets to forward? */ +BOOL forwarded_tickets = 0; /* were tickets forwarded? */ +#endif - BOOL encrypt_enable; +static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0, + AUTHTYPE_KERBEROS_V5, }; -/*+ +static int +Data(kstream ks, int type, void *d, int c) +{ + unsigned char *p = str_data + 4; + unsigned char *cd = (unsigned char *)d; + + if (c == -1) + c = strlen((char *)cd); + + *p++ = AUTHTYPE_KERBEROS_V5; + *p = AUTH_WHO_CLIENT|AUTH_HOW_MUTUAL; +#ifdef ENCRYPTION + *p |= AUTH_ENCRYPT_ON; +#endif + p++; + *p++ = type; + while (c-- > 0) { + if ((*p++ = *cd++) == IAC) + *p++ = IAC; + } + *p++ = IAC; + *p++ = SE; + + return(TelnetSend(ks, (LPSTR)str_data, p - str_data, 0)); +} + +#ifdef ENCRYPTION +/* * Function: Enable or disable the encryption process. * * Parameters: * enable - TRUE to enable, FALSE to disable. */ static void -auth_encrypt_enable( - BOOL enable) +auth_encrypt_enable(BOOL enable) { - encrypt_enable = enable; - -} /* auth_encrypt_enable */ - + encrypt_flag = enable; +} +#endif -/*+ +/* * Function: Abort the authentication process * * Parameters: * ks - kstream to send abort message to. */ static void -auth_abort( - kstream ks, - char *errmsg, - long r) +auth_abort(kstream ks, char *errmsg, long r) { - char buf[9]; - - wsprintf(buf, "%c%c%c%c%c%c%c%c", IAC, SB, AUTHENTICATION, IS, AUTH_NULL, - AUTH_NULL, IAC, SE); - TelnetSend(ks, (LPSTR)buf, 8, 0); - - if (errmsg != NULL) { - strcpy(strTmp, errmsg); - - if (r != KSUCCESS) { - strcat(strTmp, "\n"); - #ifdef KRB4 - lstrcat(strTmp, krb_get_err_text((int) r)); - #endif - #ifdef KRB5 - lstrcat (strTmp, error_message(r)); - #endif - } - - MessageBox(HWND_DESKTOP, strTmp, "Kerberos authentication failed!", - MB_OK | MB_ICONEXCLAMATION); - } - -} /* auth_abort */ + char buf[9]; + + wsprintf(buf, "%c%c%c%c%c%c%c%c", IAC, SB, TELOPT_AUTHENTICATION, + TELQUAL_IS, AUTHTYPE_NULL, + AUTHTYPE_NULL, IAC, SE); + TelnetSend(ks, (LPSTR)buf, 8, 0); + + if (errmsg != NULL) { + strcpy(strTmp, errmsg); + + if (r != KSUCCESS) { + strcat(strTmp, "\n"); +#ifdef KRB4 + lstrcat(strTmp, krb_get_err_text((int)r)); +#endif +#ifdef KRB5 + lstrcat(strTmp, error_message(r)); +#endif + } + + MessageBox(HWND_DESKTOP, strTmp, "Kerberos authentication failed!", + MB_OK | MB_ICONEXCLAMATION); + } +} -/*+ +/* * Function: Copy data to buffer, doubling IAC character if present. * * Parameters: * kstream - kstream to send abort message to. */ static int -copy_for_net( - unsigned char *to, - unsigned char *from, - int c) +copy_for_net(unsigned char *to, unsigned char *from, int c) { - int n; - - n = c; + int n; - while (c-- > 0) { - if ((*to++ = *from++) == IAC) { - n++; - *to++ = IAC; - } - } + n = c; - return n; + while (c-- > 0) { + if ((*to++ = *from++) == IAC) { + n++; + *to++ = IAC; + } + } -} /* copy_for_net */ + return n; +} -/*++ +/* * Function: Parse authentication send command * * Parameters: @@ -179,70 +207,66 @@ copy_for_net( * Returns: Kerberos error code. */ static int -auth_send( - kstream ks, - unsigned char *parsedat, - int end_sub) +auth_send(kstream ks, unsigned char *parsedat, int end_sub) { - char buf[512]; - char *pname; - int plen; - int r; - int i; - - auth_how = -1; - - for (i = 2; i+1 <= end_sub; i += 2) { - if (parsedat[i] == KERBEROS_VERSION) - if ((parsedat[i+1] & AUTH_WHO_MASK) == AUTH_CLIENT_TO_SERVER) { - auth_how = parsedat[i+1] & AUTH_HOW_MASK; - break; - } - } - - if (auth_how == -1) { - auth_abort(ks, NULL, 0); - return KFAILURE; - } - - #ifdef KRB4 - r = k4_auth_send (ks); - #endif /* KRB4 */ - - #ifdef KRB5 - r = k5_auth_send (auth_how); - #endif /* KRB5 */ + char buf[512]; + char *pname; + int plen; + int r; + int i; + + auth_how = -1; + + for (i = 2; i+1 <= end_sub; i += 2) { + if (parsedat[i] == KERBEROS_VERSION) + if ((parsedat[i+1] & AUTH_WHO_MASK) == AUTH_WHO_CLIENT) { + auth_how = parsedat[i+1] & AUTH_HOW_MASK; + break; + } + } + + if (auth_how == -1) { + auth_abort(ks, NULL, 0); + return KFAILURE; + } - if (! r) - return KFAILURE; +#ifdef KRB4 + r = k4_auth_send(ks); +#endif /* KRB4 */ + +#ifdef KRB5 + r = k5_auth_send(ks, auth_how); +#endif /* KRB5 */ - plen = strlen (szUserName); // Set by k#_send if needed - pname = szUserName; + if (!r) + return KFAILURE; - wsprintf(buf, "%c%c%c%c", IAC, SB, AUTHENTICATION, NAME); - memcpy (&buf[4], pname, plen); - wsprintf(&buf[plen + 4], "%c%c", IAC, SE); - TelnetSend(ks, (LPSTR)buf, lstrlen(pname)+6, 0); + plen = strlen(szUserName); /* Set by k#_send if needed */ + pname = szUserName; - wsprintf(buf, "%c%c%c%c%c%c%c", IAC, SB, AUTHENTICATION, IS, - KERBEROS_VERSION, auth_how | AUTH_CLIENT_TO_SERVER, AUTH); + wsprintf(buf, "%c%c%c%c", IAC, SB, TELOPT_AUTHENTICATION, TELQUAL_NAME); + memcpy(&buf[4], pname, plen); + wsprintf(&buf[plen + 4], "%c%c", IAC, SE); + TelnetSend(ks, (LPSTR)buf, lstrlen(pname)+6, 0); - #if KRB4 - auth.length = copy_for_net(&buf[7], auth.dat, auth.length); - #endif /* KRB4 */ - #if KRB5 - auth.length = copy_for_net(&buf[7], auth.data, auth.length); - #endif /* KRB5 */ + wsprintf(buf, "%c%c%c%c%c%c%c", IAC, SB, TELOPT_AUTHENTICATION, TELQUAL_IS, + KERBEROS_VERSION, auth_how | AUTH_WHO_CLIENT, KRB_AUTH); - wsprintf(&buf[auth.length+7], "%c%c", IAC, SE); +#if KRB4 + auth.length = copy_for_net(&buf[7], auth.dat, auth.length); +#endif /* KRB4 */ +#if KRB5 + auth.length = copy_for_net(&buf[7], auth.data, auth.length); +#endif /* KRB5 */ - TelnetSend(ks, (LPSTR)buf, auth.length+9, 0); + wsprintf(&buf[auth.length+7], "%c%c", IAC, SE); - return KSUCCESS; + TelnetSend(ks, (LPSTR)buf, auth.length+9, 0); -} /* auth_send */ + return KSUCCESS; +} -/*+ +/* * Function: Parse authentication reply command * * Parameters: @@ -256,25 +280,22 @@ auth_send( * Returns: Kerberos error code. */ static int -auth_reply( - kstream ks, - unsigned char *parsedat, - int end_sub) +auth_reply(kstream ks, unsigned char *parsedat, int end_sub) { - int n; + int n; - #ifdef KRB4 - n = k4_auth_reply (ks, parsedat, end_sub); - #endif +#ifdef KRB4 + n = k4_auth_reply(ks, parsedat, end_sub); +#endif - #ifdef KRB5 - n = k5_auth_reply (auth_how, parsedat, end_sub); - #endif +#ifdef KRB5 + n = k5_auth_reply(ks, auth_how, parsedat, end_sub); +#endif - return n; + return n; } -/*+ +/* * Function: Parse the athorization sub-options and reply. * * Parameters: @@ -285,21 +306,17 @@ auth_reply( * end_sub - last charcter position in parsedat. */ void -auth_parse( - kstream ks, - unsigned char *parsedat, - int end_sub) +auth_parse(kstream ks, unsigned char *parsedat, int end_sub) { - if (parsedat[1] == SEND) - auth_send(ks, parsedat, end_sub); + if (parsedat[1] == TELQUAL_SEND) + auth_send(ks, parsedat, end_sub); - if (parsedat[1] == REPLY) - auth_reply(ks, parsedat, end_sub); - -} /* auth_parse */ + if (parsedat[1] == TELQUAL_REPLY) + auth_reply(ks, parsedat, end_sub); +} -/*+ +/* * Function: Initialization routine called kstream encryption system. * * Parameters: @@ -307,17 +324,17 @@ auth_parse( * * data - user data. */ -int INTERFACE -auth_init( - kstream str, - kstream_ptr data) +int +auth_init(kstream str, kstream_ptr data) { - return 0; - -} /* auth_init */ +#ifdef ENCRYPTION + encrypt_init(str, data); +#endif + return 0; +} -/*+ +/* * Function: Destroy routine called kstream encryption system. * * Parameters: @@ -325,14 +342,13 @@ auth_init( * * data - user data. */ -void INTERFACE -auth_destroy( - kstream str) +void +auth_destroy(kstream str) { -} /* auth_destroy */ +} -/*+ +/* * Function: Callback to encrypt a block of characters * * Parameters: @@ -344,22 +360,20 @@ auth_destroy( * * Returns: number of characters converted. */ -int INTERFACE -auth_encrypt( - struct kstream_data_block *out, - struct kstream_data_block *in, - kstream str) +int +auth_encrypt(struct kstream_data_block *out, + struct kstream_data_block *in, + kstream str) { - out->ptr = in->ptr; - - out->length = in->length; + out->ptr = in->ptr; - return(out->length); + out->length = in->length; -} /* auth_encrypt */ + return(out->length); +} -/*+ +/* * Function: Callback to decrypt a block of characters * * Parameters: @@ -371,81 +385,77 @@ auth_encrypt( * * Returns: number of characters converted. */ -int INTERFACE -auth_decrypt( - struct kstream_data_block *out, - struct kstream_data_block *in, - kstream str) +int +auth_decrypt(struct kstream_data_block *out, + struct kstream_data_block *in, + kstream str) { - out->ptr = in->ptr; - - out->length = in->length; + out->ptr = in->ptr; - return(out->length); + out->length = in->length; -} /* auth_decrypt */ + return(out->length); +} -/*++*/ #ifdef KRB4 /* -** -** K4_auth_send - gets authentication bits we need to send to KDC. -** -** Result is left in auth -** -** Returns: 0 on failure, 1 on success -*/ + * + * K4_auth_send - gets authentication bits we need to send to KDC. + * + * Result is left in auth + * + * Returns: 0 on failure, 1 on success + */ static int -k4_auth_send ( - kstream ks) +k4_auth_send(kstream ks) { - int r; // Return value - char instance[INST_SZ]; - char *realm; - char buf[256]; + int r; /* Return value */ + char instance[INST_SZ]; + char *realm; + char buf[256]; - memset(instance, 0, sizeof(instance)); + memset(instance, 0, sizeof(instance)); - if (realm = krb_get_phost(szHostName)) - lstrcpy(instance, realm); + if (realm = krb_get_phost(szHostName)) + lstrcpy(instance, realm); - realm = krb_realmofhost(szHostName); + realm = krb_realmofhost(szHostName); - if (!realm) { - strcpy(buf, "Can't find realm for host \""); - strcat(buf, szHostName); - strcat(buf, "\""); - auth_abort(ks, buf, 0); - return KFAILURE; - } + if (!realm) { + strcpy(buf, "Can't find realm for host \""); + strcat(buf, szHostName); + strcat(buf, "\""); + auth_abort(ks, buf, 0); + return KFAILURE; + } - r = krb_mk_req(&auth, KRB_SERVICE_NAME, instance, realm, 0); + r = krb_mk_req(&auth, KRB_SERVICE_NAME, instance, realm, 0); - if (r == 0) - r = krb_get_cred(KRB_SERVICE_NAME, instance, realm, &cred); + if (r == 0) + r = krb_get_cred(KRB_SERVICE_NAME, instance, realm, &cred); - if (r) { - strcpy(buf, "Can't get \""); - strcat(buf, KRB_SERVICE_NAME); - if (instance[0] != 0) { - strcat(buf, "."); - lstrcat(buf, instance); - } - strcat(buf, "@"); - lstrcat(buf, realm); - strcat(buf, "\" ticket"); - auth_abort(ks, buf, r); - - return r; + if (r) { + strcpy(buf, "Can't get \""); + strcat(buf, KRB_SERVICE_NAME); + if (instance[0] != 0) { + strcat(buf, "."); + lstrcat(buf, instance); } + strcat(buf, "@"); + lstrcat(buf, realm); + strcat(buf, "\" ticket"); + auth_abort(ks, buf, r); + + return r; + } - if (!szUserName[0]) // Copy if not there - strcpy (szUserName, cred.pname); + if (!szUserName[0]) /* Copy if not there */ + strcpy(szUserName, cred.pname); - return(1); + return(1); } -/*+ +/* * Function: K4 parse authentication reply command * * Parameters: @@ -459,232 +469,398 @@ k4_auth_send ( * Returns: Kerberos error code. */ static int -k4_auth_reply( - kstream ks, - unsigned char *parsedat, - int end_sub) +k4_auth_reply(kstream ks, unsigned char *parsedat, int end_sub) { - time_t t; - int x; - char buf[512]; - int i; - des_cblock session_key; - des_key_schedule sched; - static des_cblock challenge; - - if (end_sub < 4) - return KFAILURE; + time_t t; + int x; + char buf[512]; + int i; + des_cblock session_key; + des_key_schedule sched; + static des_cblock challenge; + + if (end_sub < 4) + return KFAILURE; - if (parsedat[2] != KERBEROS_V4) - return KFAILURE; - - if (parsedat[4] == K4_REJECT) { - buf[0] = 0; - - for (i = 5; i <= end_sub; i++) { - if (parsedat[i] == IAC) - break; - buf[i-5] = parsedat[i]; - buf[i-4] = 0; - } - - if (!buf[0]) - strcpy(buf, "Authentication rejected by remote machine!"); - MessageBox(HWND_DESKTOP, buf, NULL, MB_OK | MB_ICONEXCLAMATION); - - return KFAILURE; - } - - if (parsedat[4] == K4_ACCEPT) { - if ((parsedat[3] & AUTH_HOW_MASK) == AUTH_HOW_ONE_WAY) - return KSUCCESS; - - if ((parsedat[3] & AUTH_HOW_MASK) != AUTH_HOW_MUTUAL) - return KFAILURE; - - des_key_sched(cred.session, sched); - - t = time(NULL); - memcpy(challenge, &t, 4); - memcpy(&challenge[4], &t, 4); - des_ecb_encrypt(&challenge, &session_key, sched, 1); - - /* - * Increment the challenge by 1, and encrypt it for - * later comparison. - */ - for (i = 7; i >= 0; --i) { - x = (unsigned int)challenge[i] + 1; - challenge[i] = x; /* ignore overflow */ - if (x < 256) /* if no overflow, all done */ - break; - } - - des_ecb_encrypt(&challenge, &challenge, sched, 1); - - wsprintf(buf, "%c%c%c%c%c%c%c", IAC, SB, AUTHENTICATION, IS, - KERBEROS_V4, AUTH_CLIENT_TO_SERVER|AUTH_HOW_MUTUAL, K4_CHALLENGE); - memcpy(&buf[7], session_key, 8); - wsprintf(&buf[15], "%c%c", IAC, SE); - TelnetSend(ks, (LPSTR)buf, 17, 0); - - return KSUCCESS; - } - - if (parsedat[4] == K4_RESPONSE) { - if (end_sub < 12) - return KFAILURE; - - if (memcmp(&parsedat[5], challenge, sizeof(challenge)) != 0) { - MessageBox(HWND_DESKTOP, "Remote machine is being impersonated!", - NULL, MB_OK | MB_ICONEXCLAMATION); - - return KFAILURE; - } - - return KSUCCESS; - } + if (parsedat[2] != KERBEROS_V4) + return KFAILURE; + + if (parsedat[4] == KRB_REJECT) { + buf[0] = 0; + + for (i = 5; i <= end_sub; i++) { + if (parsedat[i] == IAC) + break; + buf[i-5] = parsedat[i]; + buf[i-4] = 0; + } + + if (!buf[0]) + strcpy(buf, "Authentication rejected by remote machine!"); + MessageBox(HWND_DESKTOP, buf, NULL, MB_OK | MB_ICONEXCLAMATION); + + return KFAILURE; + } + + if (parsedat[4] == KRB_ACCEPT) { + if ((parsedat[3] & AUTH_HOW_MASK) == AUTH_HOW_ONE_WAY) + return KSUCCESS; + + if ((parsedat[3] & AUTH_HOW_MASK) != AUTH_HOW_MUTUAL) + return KFAILURE; + + des_key_sched(cred.session, sched); + + t = time(NULL); + memcpy(challenge, &t, 4); + memcpy(&challenge[4], &t, 4); + des_ecb_encrypt(&challenge, &session_key, sched, 1); + + /* + * Increment the challenge by 1, and encrypt it for + * later comparison. + */ + for (i = 7; i >= 0; --i) { + x = (unsigned int)challenge[i] + 1; + challenge[i] = x; /* ignore overflow */ + if (x < 256) /* if no overflow, all done */ + break; + } + + des_ecb_encrypt(&challenge, &challenge, sched, 1); + + wsprintf(buf, "%c%c%c%c%c%c%c", IAC, SB, TELOPT_AUTHENTICATION, TELQUAL_IS, + KERBEROS_V4, AUTH_WHO_CLIENT|AUTH_HOW_MUTUAL, KRB_CHALLENGE); + memcpy(&buf[7], session_key, 8); + wsprintf(&buf[15], "%c%c", IAC, SE); + TelnetSend(ks, (LPSTR)buf, 17, 0); + + return KSUCCESS; + } + + if (parsedat[4] == KRB_RESPONSE) { + if (end_sub < 12) + return KFAILURE; + + if (memcmp(&parsedat[5], challenge, sizeof(challenge)) != 0) { + MessageBox(HWND_DESKTOP, "Remote machine is being impersonated!", + NULL, MB_OK | MB_ICONEXCLAMATION); + + return KFAILURE; + } + + return KSUCCESS; + } - return KFAILURE; + return KFAILURE; -} /* auth_reply */ +} #endif /* KRB4 */ -/*++*/ + #ifdef KRB5 /* -** -** K5_auth_send - gets authentication bits we need to send to KDC. -** -** Code lifted from telnet sample code in the appl directory. -** -** Result is left in auth -** -** Returns: 0 on failure, 1 on success -** -*/ + * + * K5_auth_send - gets authentication bits we need to send to KDC. + * + * Code lifted from telnet sample code in the appl directory. + * + * Result is left in auth + * + * Returns: 0 on failure, 1 on success + * + */ static int -k5_auth_send (int how) +k5_auth_send(kstream ks, int how) { - krb5_error_code r; - krb5_ccache ccache; - krb5_creds cred; - krb5_creds * new_cred; - extern krb5_flags krb5_kdc_default_options; - krb5_flags ap_opts; - int len; - - if (r = krb5_cc_default(k5_context, &ccache)) { - com_err (NULL, r, "while authorizing."); - return(0); - } - - memset((char *)&cred, 0, sizeof(cred)); - if (r = krb5_sname_to_principal(k5_context, szHostName, KRB_SERVICE_NAME, - KRB5_NT_SRV_HST, &cred.server)) { - com_err (NULL, r, "while authorizing."); - return(0); + krb5_error_code r; + krb5_ccache ccache; + krb5_creds creds; + krb5_creds * new_creds; + extern krb5_flags krb5_kdc_default_options; + krb5_flags ap_opts; + char type_check[2]; + krb5_data check_data; + int len; +#ifdef ENCRYPTION + krb5_keyblock *newkey = 0; +#endif + + if (r = krb5_cc_default(k5_context, &ccache)) { + com_err(NULL, r, "while authorizing."); + return(0); + } + + memset((char *)&creds, 0, sizeof(creds)); + if (r = krb5_sname_to_principal(k5_context, szHostName, KRB_SERVICE_NAME, + KRB5_NT_SRV_HST, &creds.server)) { + com_err(NULL, r, "while authorizing."); + return(0); + } + + if (r = krb5_cc_get_principal(k5_context, ccache, &creds.client)) { + com_err(NULL, r, "while authorizing."); + krb5_free_cred_contents(k5_context, &creds); + return(0); + } + if (szUserName[0] == '\0') { /* Get user name now */ + len = krb5_princ_component(k5_context, creds.client, 0)->length; + memcpy(szUserName, + krb5_princ_component(k5_context, creds.client, 0)->data, + len); + szUserName[len] = '\0'; + } + + if (r = krb5_get_credentials(k5_context, 0, + ccache, &creds, &new_creds)) { + com_err(NULL, r, "while authorizing."); + krb5_free_cred_contents(k5_context, &creds); + return(0); + } + + ap_opts = 0; + if ((how & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) + ap_opts = AP_OPTS_MUTUAL_REQUIRED; + +#ifdef ENCRYPTION + ap_opts |= AP_OPTS_USE_SUBKEY; +#endif + + if (auth_context) { + krb5_auth_con_free(k5_context, auth_context); + auth_context = 0; + } + if ((r = krb5_auth_con_init(k5_context, &auth_context))) { + com_err(NULL, r, "while initializing auth context"); + return(0); + } + + krb5_auth_con_setflags(k5_context, auth_context, + KRB5_AUTH_CONTEXT_RET_TIME); + + type_check[0] = AUTHTYPE_KERBEROS_V5; + type_check[1] = AUTH_WHO_CLIENT| (how & AUTH_HOW_MASK); +#ifdef ENCRYPTION + type_check[1] |= AUTH_ENCRYPT_ON; +#endif + check_data.magic = KV5M_DATA; + check_data.length = 2; + check_data.data = (char *)&type_check; + + r = krb5_mk_req_extended(k5_context, &auth_context, ap_opts, + NULL, new_creds, &auth); + +#ifdef ENCRYPTION + krb5_auth_con_getlocalsubkey(k5_context, auth_context, &newkey); + if (session_key) { + krb5_free_keyblock(k5_context, session_key); + session_key = 0; + } + + if (newkey) { + /* + * keep the key in our private storage, but don't use it + * yet---see kerberos5_reply() below + */ + if ((newkey->enctype != ENCTYPE_DES_CBC_CRC) && + (newkey-> enctype != ENCTYPE_DES_CBC_MD5)) { + if ((new_creds->keyblock.enctype == ENCTYPE_DES_CBC_CRC) || + (new_creds->keyblock.enctype == ENCTYPE_DES_CBC_MD5)) + /* use the session key in credentials instead */ + krb5_copy_keyblock(k5_context, &new_creds->keyblock, &session_key); + else + ; /* What goes here? XXX */ + } else { + krb5_copy_keyblock(k5_context, newkey, &session_key); } + krb5_free_keyblock(k5_context, newkey); + } +#endif /* ENCRYPTION */ + + krb5_free_cred_contents(k5_context, &creds); + krb5_free_creds(k5_context, new_creds); + + if (r) { + com_err(NULL, r, "while authorizing."); + return(0); + } + + return(1); +} - if (r = krb5_cc_get_principal(k5_context, ccache, &cred.client)) { - com_err (NULL, r, "while authorizing."); - krb5_free_cred_contents(k5_context, &cred); - return(0); - } - if (szUserName[0] == '\0') { /* Get user name now */ - len = krb5_princ_component(k5_context, cred.client, 0)->length; - memcpy (szUserName, - krb5_princ_component(k5_context, cred.client, 0)->data, - len); - szUserName[len] = '\0'; +/* + * + * K5_auth_reply -- checks the reply for mutual authentication. + * + * Code lifted from telnet sample code in the appl directory. + * + */ +static int +k5_auth_reply(kstream ks, int how, unsigned char *data, int cnt) +{ +#ifdef ENCRYPTION + Session_Key skey; +#endif + static int mutual_complete = 0; + + data += 4; /* Point to status byte */ + + switch (*data++) { + case KRB_REJECT: + if (cnt > 0) { + char *s; + wsprintf(strTmp, "Kerberos V5 refuses authentication because\n\t"); + s = strTmp + strlen(strTmp); + strncpy(s, data, cnt); + s[cnt] = 0; + } else + wsprintf(strTmp, "Kerberos V5 refuses authentication"); + MessageBox(HWND_DESKTOP, strTmp, "", MB_OK | MB_ICONEXCLAMATION); + + return KFAILURE; + + case KRB_ACCEPT: + if (!mutual_complete) { + if ((how & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL && !mutual_complete) { + wsprintf(strTmp, + "Kerberos V5 accepted you, but didn't provide" + " mutual authentication"); + MessageBox(HWND_DESKTOP, strTmp, "", MB_OK | MB_ICONEXCLAMATION); + return KFAILURE; + } +#ifdef ENCRYPTION + if (session_key) { + skey.type = SK_DES; + skey.length = 8; + skey.data = session_key->contents; + encrypt_session_key(&skey, 0); + } +#endif } +#ifdef FORWARD + if (forward_flag) + kerberos5_forward(ks); +#endif - if (r = krb5_get_credentials(k5_context, 0, - ccache, &cred, &new_cred)) { - com_err (NULL, r, "while authorizing."); - krb5_free_cred_contents(k5_context, &cred); - return(0); - } + return KSUCCESS; + break; - ap_opts = 0; - if ((how & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) - ap_opts = AP_OPTS_MUTUAL_REQUIRED; + case KRB_RESPONSE: + if ((how & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) { + /* the rest of the reply should contain a krb_ap_rep */ + krb5_ap_rep_enc_part *reply; + krb5_data inbuf; + krb5_error_code r; - r = krb5_mk_req_extended(k5_context, &auth_context, ap_opts, - NULL, new_cred, &auth); + inbuf.length = cnt; + inbuf.data = (char *)data; - krb5_free_cred_contents(k5_context, &cred); - krb5_free_creds(k5_context, new_cred); + if (r = krb5_rd_rep(k5_context, auth_context, &inbuf, &reply)) { + com_err(NULL, r, "while authorizing."); + return KFAILURE; + } + krb5_free_ap_rep_enc_part(k5_context, reply); + +#ifdef ENCRYPTION + if (encrypt_flag && session_key) { + skey.type = SK_DES; + skey.length = 8; + skey.data = session_key->contents; + encrypt_session_key(&skey, 0); + } +#endif + mutual_complete = 1; + } + return KSUCCESS; + +#ifdef FORWARD + case KRB_FORWARD_ACCEPT: + forwarded_tickets = 1; + return KSUCCESS; + + case KRB_FORWARD_REJECT: + forwarded_tickets = 0; + if (cnt > 0) { + char *s; + + wsprintf(strTmp, + "Kerberos V5 refuses forwarded credentials because\n\t"); + s = strTmp + strlen(strTmp); + strncpy(s, data, cnt); + s[cnt] = 0; + } else + wsprintf(strTmp, "Kerberos V5 refuses forwarded credentials"); + + MessageBox(HWND_DESKTOP, strTmp, "", MB_OK | MB_ICONEXCLAMATION); + return KFAILURE; +#endif /* FORWARD */ + + default: + return KFAILURE; /* Unknown reply type */ + } +} - if (r) { - com_err (NULL, r, "while authorizing."); - return(0); - } +#ifdef FORWARD +void +kerberos5_forward(kstream ks) +{ + krb5_error_code r; + krb5_ccache ccache; + krb5_principal client = 0; + krb5_principal server = 0; + krb5_data forw_creds; - return(1); -} + forw_creds.data = 0; -/*+ -** -** K5_auth_reply -- checks the reply for mutual authentication. -** -** Code lifted from telnet sample code in the appl directory. -** -*/ -static int -k5_auth_reply (int how, unsigned char *data, int cnt) { - static int mutual_complete = 0; - - data += 4; /* Point to status byte */ - - switch (*data++) { - case K5_REJECT: - if (cnt > 0) - wsprintf (strTmp, - "Kerberos V5 refuses authentication because %.*s", - cnt, data); - else - wsprintf (strTmp, "Kerberos V5 refuses authentication"); - MessageBox (HWND_DESKTOP, strTmp, "", MB_OK | MB_ICONEXCLAMATION); - - return KFAILURE; - - case K5_ACCEPT: - if ((how & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL && !mutual_complete) { - wsprintf(strTmp, "Kerberos V5 accepted you, " - "but didn't provide mutual authentication"); - MessageBox (HWND_DESKTOP, strTmp, "", MB_OK | MB_ICONEXCLAMATION); - return KSUCCESS; - } - - return KSUCCESS; - break; - - case K5_RESPONSE: - if ((how & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) { - /* the rest of the reply should contain a krb_ap_rep */ - krb5_ap_rep_enc_part *reply; - krb5_data inbuf; - krb5_error_code r; - - inbuf.length = cnt; - inbuf.data = (char *)data; - - if (r = krb5_rd_rep (k5_context, auth_context, &inbuf, &reply)) { - com_err (NULL, r, "while authorizing."); - return KFAILURE; - } - krb5_free_ap_rep_enc_part(k5_context, reply); - - mutual_complete = 1; - } - return KSUCCESS; - - default: - return KSUCCESS; // Unknown reply type - } + if ((r = krb5_cc_default(k5_context, &ccache))) { + com_err(NULL, r, "Kerberos V5: could not get default ccache"); + return; + } + + if ((r = krb5_cc_get_principal(k5_context, ccache, &client))) { + com_err(NULL, r, "Kerberos V5: could not get default principal"); + goto cleanup; + } + + if ((r = krb5_sname_to_principal(k5_context, szHostName, KRB_SERVICE_NAME, + KRB5_NT_SRV_HST, &server))) { + com_err(NULL, r, "Kerberos V5: could not make server principal"); + goto cleanup; + } + + if ((r = krb5_auth_con_genaddrs(k5_context, auth_context, ks->fd, + KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR))) { + com_err(NULL, r, "Kerberos V5: could not gen local full address"); + goto cleanup; + } + + if (r = krb5_fwd_tgt_creds(k5_context, auth_context, 0, client, server, + ccache, forwardable_flag, &forw_creds)) { + com_err(NULL, r, "Kerberos V5: error getting forwarded creds"); + goto cleanup; + } + + /* Send forwarded credentials */ + if (!Data(ks, KRB_FORWARD, forw_creds.data, forw_creds.length)) { + MessageBox(HWND_DESKTOP, + "Not enough room for authentication data", "", + MB_OK | MB_ICONEXCLAMATION); + } + +cleanup: + if (client) + krb5_free_principal(k5_context, client); + if (server) + krb5_free_principal(k5_context, server); +#if 0 /* XXX */ + if (forw_creds.data) + free(forw_creds.data); +#endif + krb5_cc_close(k5_context, ccache); } +#endif /* FORWARD */ + #endif /* KRB5 */ diff --git a/src/windows/wintel/auth.h b/src/windows/wintel/auth.h index ddc8b2169..e0f60ec40 100644 --- a/src/windows/wintel/auth.h +++ b/src/windows/wintel/auth.h @@ -2,24 +2,27 @@ * Implements Kerberos 4 authentication and ecryption */ -void auth_parse( - kstream ks, - unsigned char *parsedat, - int end_sub); - -int INTERFACE auth_init( - kstream str, - kstream_ptr data); - -void INTERFACE auth_destroy( - kstream str); - -int INTERFACE auth_encrypt( - struct kstream_data_block *out, - struct kstream_data_block *in, - kstream str); - -int INTERFACE auth_decrypt( - struct kstream_data_block *out, - struct kstream_data_block *in, - kstream str); +#ifndef WINTEL_AUTH_H +#define WINTEL_AUTH_H + +void auth_parse(kstream, unsigned char *, int); + +int auth_init(kstream, kstream_ptr); + +void auth_destroy(kstream); + +int auth_encrypt(struct kstream_data_block *, struct kstream_data_block *, + kstream); + +int auth_decrypt(struct kstream_data_block *, struct kstream_data_block *, + kstream); + +extern BOOL forward_flag; +extern BOOL forwardable_flag; +extern BOOL forwarded_tickets; + +#ifdef ENCRYPTION +extern BOOL encrypt_flag; +#endif + +#endif /* WINTEL_AUTH_H */ diff --git a/src/windows/wintel/dialog.h b/src/windows/wintel/dialog.h index cfec5928a..c95ec0491 100644 --- a/src/windows/wintel/dialog.h +++ b/src/windows/wintel/dialog.h @@ -6,6 +6,15 @@ #define TEL_MANUALCONFIGURE 203 #define TEL_OK 204 #define TEL_CANCEL 206 +#define IDC_FORWARD 207 +#define IDC_FORWARDFORWARD 208 +#define IDC_ENCRYPT 210 +#define TEL_CONNECT_USERID 211 + +#define IDM_SEND_IP 800 +#define IDM_SEND_AYT 801 +#define IDM_SEND_ABORT 802 + #define CON_SESSIONNAME 302 #define CON_WINDOWTITLE 304 #define CON_COLUMNS132 305 @@ -21,8 +30,11 @@ #define CONFIGDLG 300 #define CON_SCRLBCK 317 #define CON_NUMLINES 318 + #define PRINTQUEUE 400 + #define IDM_PRINTQUEUE 500 + #define TEL_PUSH1 601 #define TEL_PUSH2 602 #define TEL_PUSH3 603 diff --git a/src/windows/wintel/edit.c b/src/windows/wintel/edit.c index 02de7bea1..aa230cfc9 100644 --- a/src/windows/wintel/edit.c +++ b/src/windows/wintel/edit.c @@ -14,427 +14,431 @@ static int iLocStart; static int iLocEnd; void Edit_LbuttonDown( - HWND hWnd, - LPARAM lParam) + HWND hWnd, + LPARAM lParam) { - SCREEN *pScr; - HMENU hMenu; - int iTmp; - int iXlocStart; - int iYlocStart; - HDC hDC; - - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert(pScr != NULL); - - hDC = GetDC(hWnd); - for (iTmp = 0; iTmp < pScr->width * pScr->height; iTmp++) { - if (cInvertedArray[iTmp]) { - PatBlt(hDC, iTmp % pScr->width * pScr->cxChar, - (int) (iTmp / pScr->width) * pScr->cyChar, - pScr->cxChar, pScr->cyChar, DSTINVERT); - cInvertedArray[iTmp] = 0; - } - } - bSelection = FALSE; - hMenu = GetMenu(hWnd); - EnableMenuItem(hMenu, IDM_COPY, MF_GRAYED); - ReleaseDC(hWnd, hDC); - iXlocStart = (int) LOWORD(lParam) / pScr->cxChar; - if (iXlocStart >= pScr->width) - iXlocStart = pScr->width - 1; - iYlocStart = (int) HIWORD(lParam) / pScr->cyChar; - if (iYlocStart >= pScr->height) - iYlocStart = pScr->height - 1; - iLocStart = iXlocStart + iYlocStart * pScr->width; - bMouseDown = TRUE; + SCREEN *pScr; + HMENU hMenu; + int iTmp; + int iXlocStart; + int iYlocStart; + HDC hDC; + + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert(pScr != NULL); + + hDC = GetDC(hWnd); + for (iTmp = 0; iTmp < pScr->width * pScr->height; iTmp++) { + if (cInvertedArray[iTmp]) { + PatBlt(hDC, iTmp % pScr->width * pScr->cxChar, + (int) (iTmp / pScr->width) * pScr->cyChar, + pScr->cxChar, pScr->cyChar, DSTINVERT); + cInvertedArray[iTmp] = 0; + } + } + bSelection = FALSE; + hMenu = GetMenu(hWnd); + EnableMenuItem(hMenu, IDM_COPY, MF_GRAYED); + ReleaseDC(hWnd, hDC); + iXlocStart = (int) LOWORD(lParam) / pScr->cxChar; + if (iXlocStart >= pScr->width) + iXlocStart = pScr->width - 1; + iYlocStart = (int) HIWORD(lParam) / pScr->cyChar; + if (iYlocStart >= pScr->height) + iYlocStart = pScr->height - 1; + iLocStart = iXlocStart + iYlocStart * pScr->width; + bMouseDown = TRUE; } /* Edit_LbuttonDown */ void Edit_LbuttonUp( - HWND hWnd, - LPARAM lParam) + HWND hWnd, + LPARAM lParam) { - SCREEN *pScr; - int iTmp; - int iTmp2; - HMENU hMenu; - - bMouseDown = FALSE; - if (bSelection) - return; - bSelection = TRUE; - - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert(pScr != NULL); - - iTmp = (int) LOWORD(lParam) / pScr->cxChar; - if (iTmp >= pScr->width) - iTmp = pScr->width - 1; - iTmp2 = (int) HIWORD(lParam) / pScr->cyChar; - if (iTmp2 >= pScr->height) - iTmp2 = pScr->height - 1; - iLocEnd = iTmp + iTmp2 * pScr->width; - if (iLocEnd == iLocStart) { - bSelection = FALSE; - } - else { - hMenu = GetMenu(hWnd); - EnableMenuItem(hMenu, IDM_COPY, MF_ENABLED); - } + SCREEN *pScr; + int iTmp; + int iTmp2; + HMENU hMenu; + + bMouseDown = FALSE; + if (bSelection) + return; + bSelection = TRUE; + + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert(pScr != NULL); + + iTmp = (int) LOWORD(lParam) / pScr->cxChar; + if (iTmp >= pScr->width) + iTmp = pScr->width - 1; + iTmp2 = (int) HIWORD(lParam) / pScr->cyChar; + if (iTmp2 >= pScr->height) + iTmp2 = pScr->height - 1; + iLocEnd = iTmp + iTmp2 * pScr->width; + if (iLocEnd == iLocStart) { + bSelection = FALSE; + } + else { + hMenu = GetMenu(hWnd); + EnableMenuItem(hMenu, IDM_COPY, MF_ENABLED); + } } /* Edit_LbuttonUp */ void Edit_MouseMove(HWND hWnd, LPARAM lParam){ - SCREEN *pScr; - int iTmp; - int iTmp2; - int iXlocCurr; - int iYlocCurr; - int iLocCurr; - int iX; - int iX2; - int iY; - int iY2; - SCREENLINE *pScrLine; - HDC hDC; - - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert(pScr != NULL); - - hDC = GetDC(hWnd); - iXlocCurr = (int) LOWORD(lParam) / pScr->cxChar; - if (iXlocCurr >= pScr->width) - iXlocCurr = pScr->width - 1; - iYlocCurr = (int) HIWORD(lParam) / pScr->cyChar; - if (iYlocCurr >= pScr->height) - iYlocCurr = pScr->height - 1; - iLocCurr = iXlocCurr + (iYlocCurr * pScr->width); - if (iLocCurr > iLocStart) { - for (iTmp=0; iTmp < iLocStart; iTmp++) { - if (cInvertedArray[iTmp]) { - PatBlt(hDC, (iTmp % pScr->width) * pScr->cxChar, - (int) (iTmp / pScr->width) * pScr->cyChar, - pScr->cxChar, pScr->cyChar, DSTINVERT); - cInvertedArray[iTmp] = 0; - } - } - iX = iLocStart % pScr->width; - iY = (int) (iLocStart / pScr->width); - iX2 = iLocCurr % pScr->width; - iY2 = (int) (iLocCurr / pScr->width); - if (iY == iY2) { - pScrLine = GetScreenLineFromY(pScr, iY); - for (iTmp2 = iX; iTmp2 < iX2; iTmp2++) { - if ((!cInvertedArray[iTmp2 + (pScr->width * iY)]) && pScrLine->text[iTmp2]) { - PatBlt(hDC, iTmp2 * pScr->cxChar, iY * pScr->cyChar, - pScr->cxChar, pScr->cyChar, DSTINVERT); - cInvertedArray[iTmp2 + (pScr->width * iY)] = pScrLine->text[iTmp2]; - } - } - } - else { - pScrLine = GetScreenLineFromY(pScr, iY); - - for (iTmp2 = iX; iTmp2 < pScr->width; iTmp2++) { - if ((!cInvertedArray[iTmp2 + (pScr->width * iY)]) && pScrLine->text[iTmp2]) { - PatBlt(hDC, iTmp2 * pScr->cxChar, iY * pScr->cyChar, - pScr->cxChar, pScr->cyChar, DSTINVERT); - cInvertedArray[iTmp2 + (pScr->width * iY)] = pScrLine->text[iTmp2]; - } - } - - for (iTmp = iY + 1; iTmp < iY2; iTmp++) { - pScrLine = GetScreenLineFromY(pScr, iTmp); - for (iTmp2 = 0; iTmp2 < pScr->width; iTmp2++) { - if ((!cInvertedArray[iTmp2 + (pScr->width * iTmp)]) && pScrLine->text[iTmp2]) { - PatBlt(hDC, iTmp2 * pScr->cxChar, iTmp * pScr->cyChar, - pScr->cxChar, pScr->cyChar, DSTINVERT); - cInvertedArray[iTmp2 + (pScr->width * iTmp)] = pScrLine->text[iTmp2]; - } - } - } - - if (iY2 != iY) { - pScrLine = GetScreenLineFromY(pScr, iY2); - for (iTmp2 = 0; iTmp2 < iX2; iTmp2++) { - if ((!cInvertedArray[iTmp2 + (pScr->width * iY2)]) && pScrLine->text[iTmp2]) { - PatBlt(hDC, iTmp2 * pScr->cxChar, iY2 * pScr->cyChar, - pScr->cxChar, pScr->cyChar, DSTINVERT); - cInvertedArray[iTmp2 + (pScr->width * iY2)] = pScrLine->text[iTmp2]; - } - } - } - } - - for (iTmp = iLocCurr; iTmp < pScr->width * pScr->height; iTmp++) { - if (cInvertedArray[iTmp]) { - PatBlt(hDC, (iTmp % pScr->width) * pScr->cxChar, (int) (iTmp / pScr->width) * pScr->cyChar, - pScr->cxChar, pScr->cyChar, DSTINVERT); - cInvertedArray[iTmp] = 0; - } - } + SCREEN *pScr; + int iTmp; + int iTmp2; + int iXlocCurr; + int iYlocCurr; + int iLocCurr; + int iX; + int iX2; + int iY; + int iY2; + SCREENLINE *pScrLine; + HDC hDC; + + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert(pScr != NULL); + + hDC = GetDC(hWnd); + iXlocCurr = (int) LOWORD(lParam) / pScr->cxChar; + if (iXlocCurr >= pScr->width) + iXlocCurr = pScr->width - 1; + iYlocCurr = (int) HIWORD(lParam) / pScr->cyChar; + if (iYlocCurr >= pScr->height) + iYlocCurr = pScr->height - 1; + iLocCurr = iXlocCurr + (iYlocCurr * pScr->width); + if (iLocCurr > iLocStart) { + for (iTmp=0; iTmp < iLocStart; iTmp++) { + if (cInvertedArray[iTmp]) { + PatBlt(hDC, (iTmp % pScr->width) * pScr->cxChar, + (int) (iTmp / pScr->width) * pScr->cyChar, + pScr->cxChar, pScr->cyChar, DSTINVERT); + cInvertedArray[iTmp] = 0; + } + } + iX = iLocStart % pScr->width; + iY = (int) (iLocStart / pScr->width); + iX2 = iLocCurr % pScr->width; + iY2 = (int) (iLocCurr / pScr->width); + if (iY == iY2) { + pScrLine = GetScreenLineFromY(pScr, iY); + for (iTmp2 = iX; iTmp2 < iX2; iTmp2++) { + if ((!cInvertedArray[iTmp2 + (pScr->width * iY)]) && pScrLine->text[iTmp2]) { + PatBlt(hDC, iTmp2 * pScr->cxChar, iY * pScr->cyChar, + pScr->cxChar, pScr->cyChar, DSTINVERT); + cInvertedArray[iTmp2 + (pScr->width * iY)] = pScrLine->text[iTmp2]; + } + } + } + else { + pScrLine = GetScreenLineFromY(pScr, iY); + + for (iTmp2 = iX; iTmp2 < pScr->width; iTmp2++) { + if ((!cInvertedArray[iTmp2 + (pScr->width * iY)]) && pScrLine->text[iTmp2]) { + PatBlt(hDC, iTmp2 * pScr->cxChar, iY * pScr->cyChar, + pScr->cxChar, pScr->cyChar, DSTINVERT); + cInvertedArray[iTmp2 + (pScr->width * iY)] = pScrLine->text[iTmp2]; + } + } + + for (iTmp = iY + 1; iTmp < iY2; iTmp++) { + pScrLine = GetScreenLineFromY(pScr, iTmp); + for (iTmp2 = 0; iTmp2 < pScr->width; iTmp2++) { + if ((!cInvertedArray[iTmp2 + (pScr->width * iTmp)]) && pScrLine->text[iTmp2]) { + PatBlt(hDC, iTmp2 * pScr->cxChar, iTmp * pScr->cyChar, + pScr->cxChar, pScr->cyChar, DSTINVERT); + cInvertedArray[iTmp2 + (pScr->width * iTmp)] = pScrLine->text[iTmp2]; + } } - else { /* going backwards */ - for (iTmp = 0; iTmp < iLocCurr; iTmp++) { - if (cInvertedArray[iTmp]) { - PatBlt(hDC, (iTmp % pScr->width) * pScr->cxChar, (int) (iTmp / pScr->width) * pScr->cyChar, - pScr->cxChar, pScr->cyChar, DSTINVERT); - cInvertedArray[iTmp] = 0; - } - } - iX = iLocCurr % pScr->width; - iY = (int) (iLocCurr / pScr->width); - iX2 = (iLocStart % pScr->width); - iY2 = (int) (iLocStart / pScr->width); - if (iY == iY2) { - pScrLine = GetScreenLineFromY(pScr, iY); - for (iTmp2= iX; iTmp2 < iX2; iTmp2++) { - if ((!cInvertedArray[iTmp2 + (pScr->width * iY)]) && pScrLine->text[iTmp2]) { - PatBlt(hDC, iTmp2 * pScr->cxChar, iY * pScr->cyChar, - pScr->cxChar, pScr->cyChar, DSTINVERT); - cInvertedArray[iTmp2 + (pScr->width * iY)] = pScrLine->text[iTmp2]; - } - } - } - else { - pScrLine = GetScreenLineFromY(pScr, iY); - for (iTmp2 = iX; iTmp2 < pScr->width; iTmp2++) { - if ((!cInvertedArray[iTmp2 + (pScr->width * iY)]) && pScrLine->text[iTmp2]) { - PatBlt(hDC, iTmp2 * pScr->cxChar, iY * pScr->cyChar, - pScr->cxChar, pScr->cyChar, DSTINVERT); - cInvertedArray[iTmp2 + (pScr->width * iY)] = pScrLine->text[iTmp2]; - } - } - for (iTmp = iY + 1; iTmp < iY2; iTmp++) { - pScrLine = GetScreenLineFromY(pScr, iTmp); - for (iTmp2 = 0; iTmp2 < pScr->width; iTmp2++) { - if ((!cInvertedArray[iTmp2 + (pScr->width * iTmp)]) && pScrLine->text[iTmp2]) { - PatBlt(hDC, iTmp2 * pScr->cxChar, iTmp * pScr->cyChar, - pScr->cxChar, pScr->cyChar, DSTINVERT); - cInvertedArray[iTmp2 + (pScr->width * iTmp)] = pScrLine->text[iTmp2]; - } - } - } - if (iY2 != iY) { - pScrLine = GetScreenLineFromY(pScr, iY2); - for (iTmp2 = 0; iTmp2 < iX2; iTmp2++) { - if ((!cInvertedArray[iTmp2 + (pScr->width * iY2)]) && pScrLine->text[iTmp2]) { - PatBlt(hDC, iTmp2 * pScr->cxChar, iY2 * pScr->cyChar, - pScr->cxChar, pScr->cyChar, DSTINVERT); - cInvertedArray[iTmp2 + (pScr->width * iY2)] = pScrLine->text[iTmp2]; - } - } - } - } - for (iTmp = iLocStart; iTmp < pScr->width * pScr->height; iTmp++) { - if (cInvertedArray[iTmp]) { - PatBlt(hDC, (iTmp % pScr->width) * pScr->cxChar, (int) (iTmp / pScr->width) * pScr->cyChar, - pScr->cxChar, pScr->cyChar, DSTINVERT); - cInvertedArray[iTmp] = 0; - } - } - } - ReleaseDC(hWnd, hDC); + } + + if (iY2 != iY) { + pScrLine = GetScreenLineFromY(pScr, iY2); + for (iTmp2 = 0; iTmp2 < iX2; iTmp2++) { + if ((!cInvertedArray[iTmp2 + (pScr->width * iY2)]) && pScrLine->text[iTmp2]) { + PatBlt(hDC, iTmp2 * pScr->cxChar, iY2 * pScr->cyChar, + pScr->cxChar, pScr->cyChar, DSTINVERT); + cInvertedArray[iTmp2 + (pScr->width * iY2)] = pScrLine->text[iTmp2]; + } + } + } + } + + for (iTmp = iLocCurr; iTmp < pScr->width * pScr->height; iTmp++) { + if (cInvertedArray[iTmp]) { + PatBlt(hDC, (iTmp % pScr->width) * pScr->cxChar, (int) (iTmp / pScr->width) * pScr->cyChar, + pScr->cxChar, pScr->cyChar, DSTINVERT); + cInvertedArray[iTmp] = 0; + } + } + } + else { /* going backwards */ + for (iTmp = 0; iTmp < iLocCurr; iTmp++) { + if (cInvertedArray[iTmp]) { + PatBlt(hDC, (iTmp % pScr->width) * pScr->cxChar, (int) (iTmp / pScr->width) * pScr->cyChar, + pScr->cxChar, pScr->cyChar, DSTINVERT); + cInvertedArray[iTmp] = 0; + } + } + iX = iLocCurr % pScr->width; + iY = (int) (iLocCurr / pScr->width); + iX2 = (iLocStart % pScr->width); + iY2 = (int) (iLocStart / pScr->width); + if (iY == iY2) { + pScrLine = GetScreenLineFromY(pScr, iY); + for (iTmp2= iX; iTmp2 < iX2; iTmp2++) { + if ((!cInvertedArray[iTmp2 + (pScr->width * iY)]) && pScrLine->text[iTmp2]) { + PatBlt(hDC, iTmp2 * pScr->cxChar, iY * pScr->cyChar, + pScr->cxChar, pScr->cyChar, DSTINVERT); + cInvertedArray[iTmp2 + (pScr->width * iY)] = pScrLine->text[iTmp2]; + } + } + } + else { + pScrLine = GetScreenLineFromY(pScr, iY); + for (iTmp2 = iX; iTmp2 < pScr->width; iTmp2++) { + if ((!cInvertedArray[iTmp2 + (pScr->width * iY)]) && pScrLine->text[iTmp2]) { + PatBlt(hDC, iTmp2 * pScr->cxChar, iY * pScr->cyChar, + pScr->cxChar, pScr->cyChar, DSTINVERT); + cInvertedArray[iTmp2 + (pScr->width * iY)] = pScrLine->text[iTmp2]; + } + } + for (iTmp = iY + 1; iTmp < iY2; iTmp++) { + pScrLine = GetScreenLineFromY(pScr, iTmp); + for (iTmp2 = 0; iTmp2 < pScr->width; iTmp2++) { + if ((!cInvertedArray[iTmp2 + (pScr->width * iTmp)]) && pScrLine->text[iTmp2]) { + PatBlt(hDC, iTmp2 * pScr->cxChar, iTmp * pScr->cyChar, + pScr->cxChar, pScr->cyChar, DSTINVERT); + cInvertedArray[iTmp2 + (pScr->width * iTmp)] = pScrLine->text[iTmp2]; + } + } + } + if (iY2 != iY) { + pScrLine = GetScreenLineFromY(pScr, iY2); + for (iTmp2 = 0; iTmp2 < iX2; iTmp2++) { + if ((!cInvertedArray[iTmp2 + (pScr->width * iY2)]) && pScrLine->text[iTmp2]) { + PatBlt(hDC, iTmp2 * pScr->cxChar, iY2 * pScr->cyChar, + pScr->cxChar, pScr->cyChar, DSTINVERT); + cInvertedArray[iTmp2 + (pScr->width * iY2)] = pScrLine->text[iTmp2]; + } + } + } + } + for (iTmp = iLocStart; iTmp < pScr->width * pScr->height; iTmp++) { + if (cInvertedArray[iTmp]) { + PatBlt(hDC, (iTmp % pScr->width) * pScr->cxChar, (int) (iTmp / pScr->width) * pScr->cyChar, + pScr->cxChar, pScr->cyChar, DSTINVERT); + cInvertedArray[iTmp] = 0; + } + } + } + ReleaseDC(hWnd, hDC); } /* Edit_MouseMove */ void Edit_ClearSelection( - SCREEN *pScr) + SCREEN *pScr) { - int iTmp; - HDC hDC; - HMENU hMenu; - - hDC = GetDC(pScr->hWnd); - for (iTmp = 0; iTmp < pScr->width * pScr->height; iTmp++) { - if (cInvertedArray[iTmp]) { - PatBlt(hDC, (iTmp % pScr->width) * pScr->cxChar, - (int) (iTmp / pScr->width) * pScr->cyChar, - pScr->cxChar, pScr->cyChar, DSTINVERT); - cInvertedArray[iTmp] = 0; - } - } - bSelection = FALSE; - hMenu=GetMenu(pScr->hWnd); - EnableMenuItem(hMenu, IDM_COPY, MF_GRAYED); - ReleaseDC(pScr->hWnd, hDC); + int iTmp; + HDC hDC; + HMENU hMenu; + + hDC = GetDC(pScr->hWnd); + for (iTmp = 0; iTmp < pScr->width * pScr->height; iTmp++) { + if (cInvertedArray[iTmp]) { + PatBlt(hDC, (iTmp % pScr->width) * pScr->cxChar, + (int) (iTmp / pScr->width) * pScr->cyChar, + pScr->cxChar, pScr->cyChar, DSTINVERT); + cInvertedArray[iTmp] = 0; + } + } + bSelection = FALSE; + hMenu=GetMenu(pScr->hWnd); + EnableMenuItem(hMenu, IDM_COPY, MF_GRAYED); + ReleaseDC(pScr->hWnd, hDC); } /* Edit_ClearSelection */ void Edit_Copy( - HWND hWnd) + HWND hWnd) { - int iTmp,iIdx; - HGLOBAL hCutBuffer; - LPSTR lpCutBuffer; - SCREEN *pScr; - - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert(pScr != NULL); - - hCutBuffer= GlobalAlloc(GHND, (DWORD) (pScr->width * pScr->height + 1)); - lpCutBuffer= GlobalLock(hCutBuffer); - - if (iLocStart > iLocEnd) { /* swap variables */ - iTmp = iLocStart; - iLocStart = iLocEnd; - iLocEnd = iLocStart; - } - iTmp = iLocStart; - iIdx = 0; - while (iTmp < iLocEnd) { - if (!cInvertedArray[iTmp]) { - lpCutBuffer[iIdx++] = '\r'; - lpCutBuffer[iIdx++] = '\n'; - iTmp = (((int) (iTmp / pScr->width)) + 1) * pScr->width; - continue; - } - lpCutBuffer[iIdx++] = cInvertedArray[iTmp++]; - } - lpCutBuffer[iIdx] = 0; - GlobalUnlock(hCutBuffer); - OpenClipboard(hWnd); - EmptyClipboard(); - SetClipboardData(CF_TEXT, hCutBuffer); - CloseClipboard(); + int iTmp,iIdx; + HGLOBAL hCutBuffer; + LPSTR lpCutBuffer; + SCREEN *pScr; + + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert(pScr != NULL); + + hCutBuffer= GlobalAlloc(GHND, (DWORD) (pScr->width * pScr->height + 1)); + lpCutBuffer= GlobalLock(hCutBuffer); + + if (iLocStart > iLocEnd) { /* swap variables */ + iTmp = iLocStart; + iLocStart = iLocEnd; + iLocEnd = iLocStart; + } + iTmp = iLocStart; + iIdx = 0; + while (iTmp < iLocEnd) { + if (!cInvertedArray[iTmp]) { + lpCutBuffer[iIdx++] = '\r'; + lpCutBuffer[iIdx++] = '\n'; + iTmp = (((int) (iTmp / pScr->width)) + 1) * pScr->width; + continue; + } + lpCutBuffer[iIdx++] = cInvertedArray[iTmp++]; + } + lpCutBuffer[iIdx] = 0; + GlobalUnlock(hCutBuffer); + OpenClipboard(hWnd); + EmptyClipboard(); + SetClipboardData(CF_TEXT, hCutBuffer); + CloseClipboard(); } /* Edit_Copy */ void Edit_Paste( - HWND hWnd) + HWND hWnd) { - HGLOBAL hClipMemory; - static HGLOBAL hMyClipBuffer; - LPSTR lpClipMemory; - LPSTR lpMyClipBuffer; - SCREEN *pScr; - - if (hMyClipBuffer) - GlobalFree(hMyClipBuffer); - OpenClipboard(hWnd); - hClipMemory = GetClipboardData(CF_TEXT); - hMyClipBuffer = GlobalAlloc(GHND, GlobalSize(hClipMemory)); - lpMyClipBuffer = GlobalLock(hMyClipBuffer); - lpClipMemory= GlobalLock(hClipMemory); - - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert(pScr != NULL); - - lstrcpy(lpMyClipBuffer, lpClipMemory); -// OutputDebugString(lpMyClipBuffer); - PostMessage(pScr->hwndTel, WM_MYSCREENBLOCK, (WPARAM) hMyClipBuffer, (LPARAM) pScr); - CloseClipboard(); - GlobalUnlock(hClipMemory); - GlobalUnlock(hMyClipBuffer); + HGLOBAL hClipMemory; + static HGLOBAL hMyClipBuffer; + LPSTR lpClipMemory; + LPSTR lpMyClipBuffer; + SCREEN *pScr; + + if (hMyClipBuffer) + GlobalFree(hMyClipBuffer); + OpenClipboard(hWnd); + hClipMemory = GetClipboardData(CF_TEXT); + hMyClipBuffer = GlobalAlloc(GHND, GlobalSize(hClipMemory)); + lpMyClipBuffer = GlobalLock(hMyClipBuffer); + lpClipMemory= GlobalLock(hClipMemory); + + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert(pScr != NULL); + + lstrcpy(lpMyClipBuffer, lpClipMemory); +#if 0 + OutputDebugString(lpMyClipBuffer); +#endif + PostMessage(pScr->hwndTel, WM_MYSCREENBLOCK, (WPARAM) hMyClipBuffer, (LPARAM) pScr); + CloseClipboard(); + GlobalUnlock(hClipMemory); + GlobalUnlock(hMyClipBuffer); } /* Edit_Paste */ void Edit_LbuttonDblclk( - HWND hWnd, - LPARAM lParam) + HWND hWnd, + LPARAM lParam) { - HDC hDC; - SCREEN *pScr; - int iTmp; - int iTmp2; - int iXlocStart; - int iYloc; - SCREENLINE *pScrLine; - - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert(pScr != NULL); - - hDC = GetDC(hWnd); - for (iTmp = 0; iTmp < pScr->width * pScr->height; iTmp++) { - if (cInvertedArray[iTmp]) { - PatBlt(hDC, (iTmp % pScr->width) * pScr->cxChar, - (int) (iTmp / pScr->width) * pScr->cyChar, - pScr->cxChar, pScr->cyChar, DSTINVERT); - cInvertedArray[iTmp] = 0; - } - } - bSelection = FALSE; - iXlocStart = (int) LOWORD(lParam) / pScr->cxChar; - if (iXlocStart >= pScr->width) - iXlocStart = pScr->width - 1; - iYloc = (int) HIWORD(lParam) / pScr->cyChar; - if (iYloc >= pScr->height) - iYloc = pScr->height - 1; - iLocStart = iXlocStart + (iYloc * pScr->width); - - pScrLine = GetScreenLineFromY(pScr, iYloc); - - iTmp = iXlocStart; - while (isalnum((int) pScrLine->text[iTmp])) { - PatBlt(hDC, iTmp * pScr->cxChar, iYloc * pScr->cyChar, - pScr->cxChar, pScr->cyChar, DSTINVERT); - cInvertedArray[iTmp + (iYloc * pScr->width)] = pScrLine->text[iTmp]; - iTmp++; - } - iTmp2 = iXlocStart - 1; - while (isalnum((int) pScrLine->text[iTmp2])) { - PatBlt(hDC, iTmp2 * pScr->cxChar, iYloc * pScr->cyChar, - pScr->cxChar, pScr->cyChar, DSTINVERT); - cInvertedArray[iTmp2 + (iYloc * pScr->width)] = pScrLine->text[iTmp2]; - iTmp2--; - } - iLocStart = (iTmp2 + 1) + (iYloc * pScr->width); - iLocEnd = iTmp + (iYloc * pScr->width); - - bSelection = TRUE; - ReleaseDC(hWnd, hDC); + HDC hDC; + SCREEN *pScr; + int iTmp; + int iTmp2; + int iXlocStart; + int iYloc; + SCREENLINE *pScrLine; + + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert(pScr != NULL); + + hDC = GetDC(hWnd); + for (iTmp = 0; iTmp < pScr->width * pScr->height; iTmp++) { + if (cInvertedArray[iTmp]) { + PatBlt(hDC, (iTmp % pScr->width) * pScr->cxChar, + (int) (iTmp / pScr->width) * pScr->cyChar, + pScr->cxChar, pScr->cyChar, DSTINVERT); + cInvertedArray[iTmp] = 0; + } + } + bSelection = FALSE; + iXlocStart = (int) LOWORD(lParam) / pScr->cxChar; + if (iXlocStart >= pScr->width) + iXlocStart = pScr->width - 1; + iYloc = (int) HIWORD(lParam) / pScr->cyChar; + if (iYloc >= pScr->height) + iYloc = pScr->height - 1; + iLocStart = iXlocStart + (iYloc * pScr->width); + + pScrLine = GetScreenLineFromY(pScr, iYloc); + + iTmp = iXlocStart; + while (isalnum((int) pScrLine->text[iTmp])) { + PatBlt(hDC, iTmp * pScr->cxChar, iYloc * pScr->cyChar, + pScr->cxChar, pScr->cyChar, DSTINVERT); + cInvertedArray[iTmp + (iYloc * pScr->width)] = pScrLine->text[iTmp]; + iTmp++; + } + iTmp2 = iXlocStart - 1; + while (isalnum((int) pScrLine->text[iTmp2])) { + PatBlt(hDC, iTmp2 * pScr->cxChar, iYloc * pScr->cyChar, + pScr->cxChar, pScr->cyChar, DSTINVERT); + cInvertedArray[iTmp2 + (iYloc * pScr->width)] = pScrLine->text[iTmp2]; + iTmp2--; + } + iLocStart = (iTmp2 + 1) + (iYloc * pScr->width); + iLocEnd = iTmp + (iYloc * pScr->width); + + bSelection = TRUE; + ReleaseDC(hWnd, hDC); } /* Edit_LbuttonDblclk */ void Edit_TripleClick( - HWND hWnd, - LPARAM lParam) + HWND hWnd, + LPARAM lParam) { - HDC hDC; - SCREEN *pScr; - int iTmp; - int iYloc; - SCREENLINE *pScrLine; - -// OutputDebugString("Triple Click \r\n"); - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert(pScr != NULL); - - hDC = GetDC(hWnd); - for (iTmp = 0; iTmp < pScr->width * pScr->height; iTmp++) { - if (cInvertedArray[iTmp]) { - PatBlt(hDC, (iTmp % pScr->width) * pScr->cxChar, - (int) (iTmp / pScr->width) * pScr->cyChar, - pScr->cxChar, pScr->cyChar, DSTINVERT); - cInvertedArray[iTmp] = 0; - } - } - bSelection = FALSE; - iYloc = (int) HIWORD(lParam) / pScr->cyChar; - if (iYloc >= pScr->height) - iYloc = pScr->height - 1; - iLocStart = iYloc * pScr->width; - - pScrLine = GetScreenLineFromY(pScr, iYloc); - - for (iTmp = 0; iTmp < pScr->width; iTmp++) { - if (pScrLine->text[iTmp]) { - PatBlt(hDC, iTmp * pScr->cxChar, iYloc * pScr->cyChar, - pScr->cxChar, pScr->cyChar, DSTINVERT); - cInvertedArray[iTmp + (iYloc * pScr->width)] = pScrLine->text[iTmp]; - } - else - break; - } - iLocEnd = iTmp + (iYloc * pScr->width); - - bSelection = TRUE; - ReleaseDC(hWnd, hDC); + HDC hDC; + SCREEN *pScr; + int iTmp; + int iYloc; + SCREENLINE *pScrLine; + +#if 0 + OutputDebugString("Triple Click \r\n"); +#endif + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert(pScr != NULL); + + hDC = GetDC(hWnd); + for (iTmp = 0; iTmp < pScr->width * pScr->height; iTmp++) { + if (cInvertedArray[iTmp]) { + PatBlt(hDC, (iTmp % pScr->width) * pScr->cxChar, + (int) (iTmp / pScr->width) * pScr->cyChar, + pScr->cxChar, pScr->cyChar, DSTINVERT); + cInvertedArray[iTmp] = 0; + } + } + bSelection = FALSE; + iYloc = (int) HIWORD(lParam) / pScr->cyChar; + if (iYloc >= pScr->height) + iYloc = pScr->height - 1; + iLocStart = iYloc * pScr->width; + + pScrLine = GetScreenLineFromY(pScr, iYloc); + + for (iTmp = 0; iTmp < pScr->width; iTmp++) { + if (pScrLine->text[iTmp]) { + PatBlt(hDC, iTmp * pScr->cxChar, iYloc * pScr->cyChar, + pScr->cxChar, pScr->cyChar, DSTINVERT); + cInvertedArray[iTmp + (iYloc * pScr->width)] = pScrLine->text[iTmp]; + } + else + break; + } + iLocEnd = iTmp + (iYloc * pScr->width); + + bSelection = TRUE; + ReleaseDC(hWnd, hDC); } /* Edit_TripleClick */ diff --git a/src/windows/wintel/emul.c b/src/windows/wintel/emul.c index a80d37a42..18547ab80 100644 --- a/src/windows/wintel/emul.c +++ b/src/windows/wintel/emul.c @@ -4,757 +4,763 @@ #include "screen.h" -static int ScreenEmChars( - SCREEN *pScr, - char *c, - int len) +static int +ScreenEmChars(SCREEN *pScr, char *c, int len) { + /* + * Function: Send a string of characters to the screen. Placement + * continues as long as the stream of characters does not contain any + * control chracters or cause wrapping to another line. When a control + * character is encountered or wrapping occurs, display stops and a + * count of the number of characters is returned. + * + * Parameters: + * pScr - the screen to place the characters on. + * c - the string of characters to place on the screen. + * len - the number of characters contained in the string + * + * Returns: The number of characters actually placed on the screen. + */ + + int insert; + int ocount; + int attrib; + int extra; + int nchars; + char *acurrent; /* place to put attributes */ + char *current; /* place to put characters */ + char *start; + SCREENLINE *pScrLine; + + if (len <= 0) + return(0); + + if (pScr->x != pScr->width - 1) + pScr->bWrapPending = FALSE; + else { + if (pScr->bWrapPending) { + pScr->x = 0; + pScr->bWrapPending = FALSE; + ScreenIndex(pScr); + } + } + + pScrLine = GetScreenLineFromY(pScr, pScr->y); + if (pScrLine == NULL) + return(0); + + current = &pScrLine->text[pScr->x]; + acurrent = &pScrLine->attrib[pScr->x]; + start = current; + ocount = pScr->x; + extra = 0; + + attrib = pScr->attrib; + insert = pScr->IRM; + + for (nchars = 0; nchars < len && *c >= 32; nchars++) { + if (insert) + ScreenInsChar(pScr, 1); + + *current = *c; + *acurrent = (char) attrib; + c++; + if (pScr->x < pScr->width - 1) { + acurrent++; + current++; + pScr->x++; + } + else { + extra = 1; + if (pScr->DECAWM) { + pScr->bWrapPending = TRUE; + nchars++; + break; + } + } + } + + ScreenDraw(pScr, ocount, pScr->y, pScr->attrib, + pScr->x - ocount + extra, start); + + return(nchars); +} + + +void +ScreenEm(LPSTR c, int len, SCREEN *pScr) +{ + int escflg; /* vt100 escape level */ + RECT rc; + unsigned int ic; + char stat[20]; + int i; + int nchars; + + if (pScr->screen_bottom != pScr->buffer_bottom) { + ScreenUnscroll(pScr); + InvalidateRect(pScr->hWnd, NULL, TRUE); + SetScrollPos(pScr->hWnd, SB_VERT, pScr->numlines, TRUE); + } + + ScreenCursorOff(pScr); + escflg = pScr->escflg; + +#ifdef UM + if (pScr->localprint && len > 0) { /* see if printer needs anything */ + pcount = send_localprint(c, len); + len -= pcount; + c += pcount; + } +#endif + + while (len > 0) { + /* + * look at first character in the vt100 string, if it is a + * non-printable ascii code + */ + while((*c < 32) && (escflg == 0) && (len > 0)) { + switch(*c) { + + case 0x1b: /* ESC found (begin vt100 control sequence) */ + escflg++; + break; + + case -1: /* IAC from telnet session */ + escflg = 6; + break; + +#ifdef CISB + case 0x05: /* CTRL-E found (answerback) */ + bp_ENQ(); + break; +#endif + + case 0x07: /* CTRL-G found (bell) */ + ScreenBell(pScr); + break; + + case 0x08: /* CTRL-H found (backspace) */ + ScreenBackspace(pScr); + break; + + case 0x09: /* CTRL-I found (tab) */ + ScreenTab(pScr); /* Later change for versatile tabbing */ + break; + + case 0x0a: /* CTRL-J found (line feed) */ + case 0x0b: /* CTRL-K found (treat as line feed) */ + case 0x0c: /* CTRL-L found (treat as line feed) */ + ScreenIndex(pScr); + break; + + case 0x0d: /* CTRL-M found (carriage feed) */ + ScreenCarriageFeed(pScr); + break; + +#if 0 + case 0x0e: /* CTRL-N found (invoke Graphics (G1) character set) */ + if (pScr->G1) + pScr->attrib = VSgraph(pScr->attrib); + else + pScr->attrib = VSnotgraph(pScr->attrib); + pScr->charset = 1; + break; + + case 0x0f: /* CTRL-O found (invoke 'normal' (G0) character set) */ + if(pScr->G0) + pScr->attrib = VSgraph(pScr->attrib); + else + pScr->attrib = VSnotgraph(pScr->attrib); + pScr->charset = 0; + break; +#endif + +#ifdef CISB + case 0x10: /* CTRL-P found (undocumented in vt100) */ + bp_DLE(c, len); + len = 0; + break; +#endif + +#if 0 + case 0x11: /* CTRL-Q found (XON) (unused presently) */ + case 0x13: /* CTRL-S found (XOFF) (unused presently) */ + case 0x18: /* CTRL-X found (CAN) (unused presently) */ + case 0x1a: /* CTRL-Z found (SUB) (unused presently) */ + break; +#endif + } + + c++; /* advance to the next character in the string */ + len--; /* decrement the counter */ + } + + if (escflg == 0) { /* check for normal character to print */ + nchars = ScreenEmChars(pScr, c, len); + c += nchars; + len -= nchars; + } + + while ((len > 0) && (escflg == 1)) { /* ESC character was found */ + switch(*c) { + + case 0x08: /* CTRL-H found (backspace) */ + ScreenBackspace(pScr); + break; + /* - Function: Send a string of characters to the screen. Placement - continues as long as the stream of characters does not contain any - control chracters or cause wrapping to another line. When a control - character is encountered or wrapping occurs, display stops and a - count of the number of characters is returned. - - Parameters: - pScr - the screen to place the characters on. - - c - the string of characters to place on the screen. - - len - the number of characters contained in the string - - Returns: The number of characters actually placed on the screen. - */ - - int insert; - int ocount; - int attrib; - int extra; - int nchars; - char *acurrent; /* place to put attributes */ - char *current; /* place to put characters */ - char *start; - SCREENLINE *pScrLine; - - if (len <= 0) - return(0); - - if (pScr->x != pScr->width - 1) - pScr->bWrapPending = FALSE; - else { - if (pScr->bWrapPending) { - pScr->x = 0; - pScr->bWrapPending = FALSE; - ScreenIndex(pScr); - } + * mostly cursor movement options, and DEC private stuff following + */ + case '[': + ScreenApClear(pScr); + escflg = 2; + break; + + case '#': /* various screen adjustments */ + escflg = 3; + break; + + case '(': /* G0 character set options */ + escflg = 4; + break; + + case ')': /* G1 character set options */ + escflg = 5; + break; + + case '>': /* keypad numeric mode (DECKPAM) */ + pScr->DECPAM = 0; + escflg = 0; + break; + + case '=': /* keypad application mode (DECKPAM) */ + pScr->DECPAM = 1; + escflg = 0; + break; + + case '7': /* save cursor (DECSC) */ + ScreenSaveCursor(pScr); + escflg = 0; + break; + + case '8': /* restore cursor (DECRC) */ + ScreenRestoreCursor(pScr); + escflg = 0; + break; + +#if 0 + case 'c': /* reset to initial state (RIS) */ + ScreenReset(pScr); + escflg = 0; + break; +#endif + + case 'D': /* index (move down one line) (IND) */ + ScreenIndex(pScr); + escflg = 0; + break; + + case 'E': /* next line (move down one line and to first column) (NEL) */ + pScr->x = 0; + ScreenIndex(pScr); + escflg = 0; + break; + + case 'H': /* horizontal tab set (HTS) */ + pScr->tabs[pScr->x] = 'x'; + escflg = 0; + break; + +#ifdef CISB + case 'I': /* undoumented in vt100 */ + bp_ESC_I(); + break; +#endif + + case 'M': /* reverse index (move up one line) (RI) */ + ScreenRevIndex(pScr); + escflg = 0; + break; + + case 'Z': /* identify terminal (DECID) */ + escflg = 0; + break; + + default: + /* put the ESC character into the Screen */ + ScreenEmChars(pScr, "\033", 1); + /* put the next character into the Screen */ + ScreenEmChars(pScr, c, 1); + escflg = 0; + break; + + } /* end switch */ + + c++; + len--; + } + + while((escflg == 2) && (len > 0)) { /* '[' handling */ + switch(*c) { + + case 0x08: /* backspace */ + ScreenBackspace(pScr); + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': /* numeric parameters */ + if (pScr->parms[pScr->parmptr] < 0) + pScr->parms[pScr->parmptr] = 0; + pScr->parms[pScr->parmptr] *= 10; + pScr->parms[pScr->parmptr] += *c - '0'; + break; + + case '?': /* vt100 mode change */ + pScr->parms[pScr->parmptr++] = -2; + break; + + case ';': /* parameter divider */ + pScr->parmptr++; + break; + + case 'A': /* cursor up (CUU) */ + pScr->bWrapPending = FALSE; + rc.left = pScr->x * pScr->cxChar; + rc.right = (pScr->x + 1) * pScr->cxChar; + rc.top = pScr->cyChar * pScr->y; + rc.bottom = pScr->cyChar * (pScr->y + 1); + InvalidateRect(pScr->hWnd, &rc, TRUE); + if (pScr->parms[0] < 1) + pScr->y--; + else + pScr->y -= pScr->parms[0]; + if(pScr->y < pScr->top) + pScr->y = pScr->top; + ScreenRange(pScr); + escflg = 0; + SendMessage(pScr->hWnd, WM_PAINT, 0, 0); + break; + + case 'B': /* cursor down (CUD) */ + pScr->bWrapPending = FALSE; + rc.left = pScr->x * pScr->cxChar; + rc.right = (pScr->x + 1) * pScr->cxChar; + rc.top = pScr->cyChar * pScr->y; + rc.bottom = pScr->cyChar * (pScr->y + 1); + InvalidateRect(pScr->hWnd, &rc, TRUE); + if (pScr->parms[0] < 1) + pScr->y++; + else + pScr->y += pScr->parms[0]; + if (pScr->y > pScr->bottom) + pScr->y = pScr->bottom; + ScreenRange(pScr); + escflg = 0; + SendMessage(pScr->hWnd, WM_PAINT, 0, 0); + break; + + case 'C': /* cursor forward (right) (CUF) */ + pScr->bWrapPending = FALSE; + rc.left = pScr->x * pScr->cxChar; + rc.right = (pScr->x + 1) * pScr->cxChar; + rc.top = pScr->cyChar * pScr->y; + rc.bottom = pScr->cyChar * (pScr->y +1); + InvalidateRect(pScr->hWnd, &rc, TRUE); + if(pScr->parms[0] < 1) + pScr->x++; + else + pScr->x += pScr->parms[0]; + ScreenRange(pScr); + if (pScr->x > pScr->width) + pScr->x = pScr->width; + escflg = 0; + SendMessage(pScr->hWnd, WM_PAINT, 0, 0); + break; + + case 'D': /* cursor backward (left) (CUB) */ + pScr->bWrapPending = FALSE; + rc.left = pScr->x * pScr->cxChar; + rc.right = (pScr->x + 1) * pScr->cxChar; + rc.top = pScr->cyChar * pScr->y; + rc.bottom = pScr->cyChar * (pScr->y + 1); + InvalidateRect(pScr->hWnd, &rc, TRUE); + if(pScr->parms[0] < 1) + pScr->x--; + else + pScr->x -= pScr->parms[0]; + ScreenRange(pScr); + escflg = 0; + SendMessage(pScr->hWnd, WM_PAINT, 0, 0); + break; + + case 'f': /* horizontal & vertical position (HVP) */ + case 'H': /* cursor position (CUP) */ + pScr->bWrapPending = FALSE; + rc.left = pScr->x * pScr->cxChar; + rc.right = (pScr->x + 1) * pScr->cxChar; + rc.top = pScr->cyChar * pScr->y; + rc.bottom = pScr->cyChar * (pScr->y + 1); + InvalidateRect(pScr->hWnd, &rc, TRUE); + pScr->x = pScr->parms[1] - 1; + pScr->y = pScr->parms[0] - 1; + ScreenRange(pScr); /* make certain the cursor position is valid */ + escflg = 0; + SendMessage(pScr->hWnd, WM_PAINT, 0, 0); + break; + + case 'J': /* erase in display (ED) */ + switch(pScr->parms[0]) { + + case -1: + case 0: /* erase from active position to end of screen */ + ScreenEraseToEndOfScreen(pScr); + break; + case 1: /* erase from start of screen to active position */ +#if 0 + ScreenEraseToPosition(pScr); +#endif + break; + + case 2: /* erase whole screen */ + ScreenEraseScreen(pScr); + break; + + default: + break; } - - pScrLine = GetScreenLineFromY(pScr, pScr->y); - if (pScrLine == NULL) - return(0); - - current = &pScrLine->text[pScr->x]; - acurrent = &pScrLine->attrib[pScr->x]; - start = current; - ocount = pScr->x; - extra = 0; - - attrib = pScr->attrib; - insert = pScr->IRM; - - for (nchars = 0; nchars < len && *c >= 32; nchars++) { - if (insert) - ScreenInsChar(pScr, 1); - - *current = *c; - *acurrent = (char) attrib; - c++; - if (pScr->x < pScr->width - 1) { - acurrent++; - current++; - pScr->x++; - } - else { - extra = 1; - if (pScr->DECAWM) { - pScr->bWrapPending = TRUE; - nchars++; - break; - } - } + + escflg = 0; + break; + + case 'K': /* erase in line (EL) */ + switch(pScr->parms[0]) { + case -1: + case 0: /* erase to end of line */ + ScreenEraseToEOL(pScr); + break; + + case 1: /* erase to beginning of line */ + ScreenEraseToBOL(pScr); + break; + + case 2: /* erase whole line */ + ScreenEraseLine(pScr, -1); + break; + + default: + break; } - - ScreenDraw(pScr, ocount, pScr->y, pScr->attrib, pScr->x - ocount + extra, start); - return(nchars); - -} /* ScreenEmChars */ - - -void ScreenEm( - LPSTR c, - int len, - SCREEN *pScr) -{ - int escflg; /* vt100 escape level */ - RECT rc; - unsigned int ic; - char stat[20]; - int i; - int nchars; - - if (pScr->screen_bottom != pScr->buffer_bottom) { - ScreenUnscroll(pScr); - InvalidateRect(pScr->hWnd, NULL, TRUE); - SetScrollPos(pScr->hWnd, SB_VERT, pScr->numlines, TRUE); + escflg = 0; + break; + + case 'L': /* insert n lines preceding current line (IL) */ + if (pScr->parms[0] < 1) + pScr->parms[0] = 1; + ScreenInsLines(pScr, pScr->parms[0], -1); + escflg = 0; + break; + + case 'M': /* delete n lines from current position downward (DL) */ + if (pScr->parms[0] < 1) + pScr->parms[0] = 1; + ScreenDelLines(pScr, pScr->parms[0], -1); + escflg = 0; + break; + + case 'P': /* delete n chars from cursor to the left (DCH) */ + if (pScr->parms[0] < 1) + pScr->parms[0] = 1; + ScreenDelChars(pScr, pScr->parms[0]); + escflg = 0; + break; + +#if 0 + case 'R': /* receive cursor position status from host */ + break; +#endif + +#if 0 + case 'c': /* device attributes (DA) */ + ScreenSendIdent(); + escflg = 0; + break; +#endif + + case 'g': /* tabulation clear (TBC) */ + if (pScr->parms[0] == 3)/* clear all tabs */ + ScreenTabClear(pScr); + else + if (pScr->parms[0] <= 0) /* clear tab stop at active position */ + pScr->tabs[pScr->x] = ' '; + escflg = 0; + break; + + case 'h': /* set mode (SM) */ + ScreenSetOption(pScr,1); + escflg = 0; + break; + + case 'i': /* toggle printer */ +#if 0 + if(pScr->parms[pScr->parmptr] == 5) + pScr->localprint = 1; + else if (pScr->parms[pScr->parmptr] == 4) + pScr->localprint = 0; +#endif + escflg = 0; + break; + + case 'l': /* reset mode (RM) */ + ScreenSetOption(pScr,0); + escflg = 0; + break; + + case 'm': /* select graphics rendition (SGR) */ + { + int temp = 0; + + while (temp <= pScr->parmptr) { + if (pScr->parms[temp] < 1) + pScr->attrib &= 128; + else + pScr->attrib |= 1 << (pScr->parms[temp] - 1); + temp++; + } } - - ScreenCursorOff(pScr); - escflg = pScr->escflg; - - #ifdef UM - if (pScr->localprint && len > 0) { /* see if printer needs anything */ - pcount = send_localprint(c, len); - len -= pcount; - c += pcount; - } - #endif - - while (len > 0) { - while((*c < 32) && (escflg == 0) && (len > 0)) { /* look at first character in the vt100 string, if it is a non-printable ascii code */ - switch(*c) { - - case 0x1b: /* ESC found (begin vt100 control sequence) */ - escflg++; - break; - - case -1: /* IAC from telnet session */ - escflg = 6; - break; - - #ifdef CISB - case 0x05: /* CTRL-E found (answerback) */ - bp_ENQ(); - break; - #endif - - case 0x07: /* CTRL-G found (bell) */ - ScreenBell(pScr); - break; - - case 0x08: /* CTRL-H found (backspace) */ - ScreenBackspace(pScr); - break; - - case 0x09: /* CTRL-I found (tab) */ - ScreenTab(pScr); /* Later change for versatile tabbing */ - break; - - case 0x0a: /* CTRL-J found (line feed) */ - case 0x0b: /* CTRL-K found (treat as line feed) */ - case 0x0c: /* CTRL-L found (treat as line feed) */ - ScreenIndex(pScr); - break; - - case 0x0d: /* CTRL-M found (carriage feed) */ - ScreenCarriageFeed(pScr); - break; - - #if 0 - case 0x0e: /* CTRL-N found (invoke Graphics (G1) character set) */ - if (pScr->G1) - pScr->attrib = VSgraph(pScr->attrib); - else - pScr->attrib = VSnotgraph(pScr->attrib); - pScr->charset = 1; - break; - - case 0x0f: /* CTRL-O found (invoke 'normal' (G0) character set) */ - if(pScr->G0) - pScr->attrib = VSgraph(pScr->attrib); - else - pScr->attrib = VSnotgraph(pScr->attrib); - pScr->charset = 0; - break; - #endif - - #ifdef CISB - case 0x10: /* CTRL-P found (undocumented in vt100) */ - bp_DLE(c, len); - len = 0; - break; - #endif - - #if 0 - case 0x11: /* CTRL-Q found (XON) (unused presently) */ - case 0x13: /* CTRL-S found (XOFF) (unused presently) */ - case 0x18: /* CTRL-X found (CAN) (unused presently) */ - case 0x1a: /* CTRL-Z found (SUB) (unused presently) */ - break; - #endif - - } /* end switch */ - - c++; /* advance to the next character in the string */ - len--; /* decrement the counter */ - - } /* end while */ - - if (escflg == 0) { /* check for normal character to print */ - nchars = ScreenEmChars(pScr, c, len); - c += nchars; - len -= nchars; - } - - while ((len > 0) && (escflg == 1)) { /* ESC character was found */ - switch(*c) { - - case 0x08: /* CTRL-H found (backspace) */ - ScreenBackspace(pScr); - break; - - case '[': /* mostly cursor movement options, and DEC private stuff following */ - ScreenApClear(pScr); - escflg = 2; - break; - - case '#': /* various screen adjustments */ - escflg = 3; - break; - - case '(': /* G0 character set options */ - escflg = 4; - break; - - case ')': /* G1 character set options */ - escflg = 5; - break; - - case '>': /* keypad numeric mode (DECKPAM) */ - pScr->DECPAM = 0; - escflg = 0; - break; - - case '=': /* keypad application mode (DECKPAM) */ - pScr->DECPAM = 1; - escflg = 0; - break; - - case '7': /* save cursor (DECSC) */ - ScreenSaveCursor(pScr); - escflg = 0; - break; - - case '8': /* restore cursor (DECRC) */ - ScreenRestoreCursor(pScr); - escflg = 0; - break; - - #if 0 - case 'c': /* reset to initial state (RIS) */ - ScreenReset(pScr); - escflg = 0; - break; - #endif - - case 'D': /* index (move down one line) (IND) */ - ScreenIndex(pScr); - escflg = 0; - break; - - case 'E': /* next line (move down one line and to first column) (NEL) */ - pScr->x = 0; - ScreenIndex(pScr); - escflg = 0; - break; - - case 'H': /* horizontal tab set (HTS) */ - pScr->tabs[pScr->x] = 'x'; - escflg = 0; - break; - - #ifdef CISB - case 'I': /* undoumented in vt100 */ - bp_ESC_I(); - break; - #endif - - case 'M': /* reverse index (move up one line) (RI) */ - ScreenRevIndex(pScr); - escflg = 0; - break; - - case 'Z': /* identify terminal (DECID) */ - escflg = 0; - break; - - default: - ScreenEmChars(pScr, "\033", 1); /* put the ESC character into the Screen */ - ScreenEmChars(pScr, c, 1); /* put the next character into the Screen */ - escflg = 0; - break; - - } /* end switch */ - - c++; - len--; - } - - while((escflg == 2) && (len > 0)) { /* '[' handling */ - switch(*c) { - - case 0x08: /* backspace */ - ScreenBackspace(pScr); - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': /* numeric parameters */ - if (pScr->parms[pScr->parmptr] < 0) - pScr->parms[pScr->parmptr] = 0; - pScr->parms[pScr->parmptr] *= 10; - pScr->parms[pScr->parmptr] += *c - '0'; - break; - - case '?': /* vt100 mode change */ - pScr->parms[pScr->parmptr++] = -2; - break; - - case ';': /* parameter divider */ - pScr->parmptr++; - break; - - case 'A': /* cursor up (CUU) */ - pScr->bWrapPending = FALSE; - rc.left = pScr->x * pScr->cxChar; - rc.right = (pScr->x + 1) * pScr->cxChar; - rc.top = pScr->cyChar * pScr->y; - rc.bottom = pScr->cyChar * (pScr->y + 1); - InvalidateRect(pScr->hWnd, &rc, TRUE); - if (pScr->parms[0] < 1) - pScr->y--; - else - pScr->y -= pScr->parms[0]; - if(pScr->y < pScr->top) - pScr->y = pScr->top; - ScreenRange(pScr); - escflg = 0; - SendMessage(pScr->hWnd, WM_PAINT, NULL, NULL); - break; - - case 'B': /* cursor down (CUD) */ - pScr->bWrapPending = FALSE; - rc.left = pScr->x * pScr->cxChar; - rc.right = (pScr->x + 1) * pScr->cxChar; - rc.top = pScr->cyChar * pScr->y; - rc.bottom = pScr->cyChar * (pScr->y + 1); - InvalidateRect(pScr->hWnd, &rc, TRUE); - if (pScr->parms[0] < 1) - pScr->y++; - else - pScr->y += pScr->parms[0]; - if (pScr->y > pScr->bottom) - pScr->y = pScr->bottom; - ScreenRange(pScr); - escflg = 0; - SendMessage(pScr->hWnd, WM_PAINT, NULL, NULL); - break; - - case 'C': /* cursor forward (right) (CUF) */ - pScr->bWrapPending = FALSE; - rc.left = pScr->x * pScr->cxChar; - rc.right = (pScr->x + 1) * pScr->cxChar; - rc.top = pScr->cyChar * pScr->y; - rc.bottom = pScr->cyChar * (pScr->y +1); - InvalidateRect(pScr->hWnd, &rc, TRUE); - if(pScr->parms[0] < 1) - pScr->x++; - else - pScr->x += pScr->parms[0]; - ScreenRange(pScr); - if (pScr->x > pScr->width) - pScr->x = pScr->width; - escflg = 0; - SendMessage(pScr->hWnd, WM_PAINT, NULL, NULL); - break; - - case 'D': /* cursor backward (left) (CUB) */ - pScr->bWrapPending = FALSE; - rc.left = pScr->x * pScr->cxChar; - rc.right = (pScr->x + 1) * pScr->cxChar; - rc.top = pScr->cyChar * pScr->y; - rc.bottom = pScr->cyChar * (pScr->y + 1); - InvalidateRect(pScr->hWnd, &rc, TRUE); - if(pScr->parms[0] < 1) - pScr->x--; - else - pScr->x -= pScr->parms[0]; - ScreenRange(pScr); - escflg = 0; - SendMessage(pScr->hWnd, WM_PAINT, NULL, NULL); - break; - - case 'f': /* horizontal & vertical position (HVP) */ - case 'H': /* cursor position (CUP) */ - pScr->bWrapPending = FALSE; - rc.left = pScr->x * pScr->cxChar; - rc.right = (pScr->x + 1) * pScr->cxChar; - rc.top = pScr->cyChar * pScr->y; - rc.bottom = pScr->cyChar * (pScr->y + 1); - InvalidateRect(pScr->hWnd, &rc, TRUE); - pScr->x = pScr->parms[1] - 1; - pScr->y = pScr->parms[0] - 1; - ScreenRange(pScr); /* make certain the cursor position is valid */ - escflg = 0; - SendMessage(pScr->hWnd, WM_PAINT, NULL, NULL); - break; - - case 'J': /* erase in display (ED) */ - switch(pScr->parms[0]) { - - case -1: - case 0: /* erase from active position to end of screen */ - ScreenEraseToEndOfScreen(pScr); - break; - case 1: /* erase from start of screen to active position */ - #if 0 - ScreenEraseToPosition(pScr); - #endif - break; - - case 2: /* erase whole screen */ - ScreenEraseScreen(pScr); - break; - - default: - break; - } - - escflg = 0; - break; - - case 'K': /* erase in line (EL) */ - switch(pScr->parms[0]) { - case -1: - case 0: /* erase to end of line */ - ScreenEraseToEOL(pScr); - break; - - case 1: /* erase to beginning of line */ - ScreenEraseToBOL(pScr); - break; - - case 2: /* erase whole line */ - ScreenEraseLine(pScr, -1); - break; - - default: - break; - } - - escflg = 0; - break; - - case 'L': /* insert n lines preceding current line (IL) */ - if (pScr->parms[0] < 1) - pScr->parms[0] = 1; - ScreenInsLines(pScr, pScr->parms[0], -1); - escflg = 0; - break; - - case 'M': /* delete n lines from current position downward (DL) */ - if (pScr->parms[0] < 1) - pScr->parms[0] = 1; - ScreenDelLines(pScr, pScr->parms[0], -1); - escflg = 0; - break; - - case 'P': /* delete n chars from cursor to the left (DCH) */ - if (pScr->parms[0] < 1) - pScr->parms[0] = 1; - ScreenDelChars(pScr, pScr->parms[0]); - escflg = 0; - break; - - #if 0 - case 'R': /* receive cursor position status from host */ - break; - #endif - - #if 0 - case 'c': /* device attributes (DA) */ - ScreenSendIdent(); - escflg = 0; - break; - #endif - - case 'g': /* tabulation clear (TBC) */ - if (pScr->parms[0] == 3)/* clear all tabs */ - ScreenTabClear(pScr); - else - if (pScr->parms[0] <= 0) /* clear tab stop at active position */ - pScr->tabs[pScr->x] = ' '; - escflg = 0; - break; - - case 'h': /* set mode (SM) */ - ScreenSetOption(pScr,1); - escflg = 0; - break; - - case 'i': /* toggle printer */ - #if 0 - if(pScr->parms[pScr->parmptr] == 5) - pScr->localprint = 1; - else if (pScr->parms[pScr->parmptr] == 4) - pScr->localprint = 0; - #endif - escflg = 0; - break; - - case 'l': /* reset mode (RM) */ - ScreenSetOption(pScr,0); - escflg = 0; - break; - - case 'm': /* select graphics rendition (SGR) */ - { - int temp = 0; - - while (temp <= pScr->parmptr) { - if (pScr->parms[temp] < 1) - pScr->attrib &= 128; - else - pScr->attrib |= 1 << (pScr->parms[temp] - 1); - temp++; - } - } - escflg = 0; - break; - - case 'n': /* device status report (DSR) */ - switch (pScr->parms[0]) { - #if 0 - case 0: /* response from vt100; ready, no malfunctions */ - case 3: /* response from vt100; malfunction, retry */ - #endif - case 5: /* send status */ - case 6: /* send active position */ - wsprintf(stat, "\033[%d;%dR", pScr->y + 1, pScr->x + 1); - for (i = 0; stat[i]; i++) - SendMessage(pScr->hwndTel, WM_MYSCREENCHAR, stat[i], (LPARAM) pScr); - break; - } /* end switch */ - escflg = 0; - break; - - case 'q': /* load LEDs (unsupported) (DECLL) */ - escflg = 0; - break; - - case 'r': /* set top & bottom margins (DECSTBM) */ - if (pScr->parms[0] < 0) - pScr->top = 0; - else - pScr->top = pScr->parms[0] - 1; - if (pScr->parms[1] < 0) - pScr->bottom = pScr->height - 1; - else - pScr->bottom = pScr->parms[1] - 1; - if (pScr->top < 0) - pScr->top = 0; - if (pScr->top > pScr->height-1) - pScr->top = pScr->height-1; - if (pScr->bottom < 1) - pScr->bottom = pScr->height; - if (pScr->bottom >= pScr->height) - pScr->bottom = pScr->height - 1; - if (pScr->top >= pScr->bottom) {/* check for valid scrolling region */ - if (pScr->bottom >= 1) /* assume the bottom value has precedence, unless it is as the top of the screen */ - pScr->top = pScr->bottom - 1; - else /* totally psychotic case, bottom of screen set to the very top line, move the bottom to below the top */ - pScr->bottom = pScr->top + 1; - } - pScr->x = 0; - pScr->y = 0; - #if 0 - if (pScr->DECORG) - pScr->y = pScr->top; /* origin mode relative */ - #endif - escflg = 0; - break; - - #if 0 - case 'x': /* request/report terminal parameters (DECREQTPARM/DECREPTPARM) */ - case 'y': /* invoke confidence test (DECTST) */ - break; - #endif - - default: - escflg = 0; - break; - - } - - c++; - len--; - - #if 0 - if (pScr->localprint && (len > 0)) { /* see if printer needs anything */ - pcount = send_localprint(c, len); - len -= pcount; - c += pcount; - } - #endif - } - - while ((escflg == 3) && (len > 0)) { /* # Handling */ - switch (*c) { - case 0x08: /* backspace */ - ScreenBackspace(pScr); - break; - - #if 0 - case '3': /* top half of double line (DECDHL) */ - case '4': /* bottom half of double line (DECDHL) */ - case '5': /* single width line (DECSWL) */ - case '6': /* double width line (DECDWL) */ - break; - #endif - - case '8': /* screen alignment display (DECALN) */ - ScreenAlign(pScr); - escflg = 0; - break; - - default: - escflg = 0; - break; - - } - - c++; - len--; - } - - while ((escflg == 4) && (len > 0)) { /* ( Handling (GO character set) */ - switch (*c) { - - case 0x08: /* backspace */ - ScreenBackspace(pScr); - break; - - #if 0 - case 'A': /* united kingdom character set (unsupported) */ - case 'B': /* ASCII character set */ - case '1': /* choose standard graphics (same as ASCII) */ - pScr->G0 = 0; - if (!pScr->charset) - pScr->attrib = ScreenNotGraph(pScr->attrib); - escflg = 0; - break; - - case '0': /* choose special graphics set */ - case '2': /* alternate character set (special graphics) */ - pScr->G0 = 1; - if(!pScr->charset) - pScr->attrib = ScreenGraph(pScr->attrib); - escflg = 0; - break; - #endif - - default: - escflg = 0; - break; - } - - c++; - len--; - - } /* end while */ - - while((escflg == 5) && (len > 0)) { /* ) Handling (G1 handling) */ - switch (*c) { - - case 0x08: /* backspace */ - ScreenBackspace(pScr); - break; - - #if 0 - case 'A': /* united kingdom character set (unsupported) */ - case 'B': /* ASCII character set */ - case '1': /* choose standard graphics (same as ASCII) */ - pScr->G1 = 0; - if (pScr->charset) - pScr->attrib = ScreenNotGraph(pScr->attrib); - escflg = 0; - break; - - case '0': /* choose special graphics set */ - case '2': /* alternate character set (special graphics) */ - pScr->G1 = 1; - if(pScr->charset) - pScr->attrib = ScreenGraph(pScr->attrib); - escflg = 0; - break; - #endif - - default: - escflg = 0; - break; - } /* end switch */ - - c++; - len--; - } /* end while */ - - while ((escflg >= 6) && (escflg <= 10) && (len > 0)) { /* Handling IAC */ - ic = (unsigned char) *c; - switch (escflg) { - - case 6: /* Handling IAC xx */ - if (ic == 255) /* if IAC */ - escflg = 0; - else if (ic == 250) /* if SB */ - escflg = 7; - else - escflg = 9; - break; - - case 7: /* Handling IAC SB xx */ - if (ic == 255) /* if IAC */ - escflg = 8; - break; - - case 8: /* Handling IAC SB IAC xx */ - if (ic == 255) /* if IAC IAC */ - escflg = 7; - else if (ic == 240) /* if IAC SE */ - escflg = 0; - break; - - case 9: /* IAC xx xx */ - escflg = 0; - break; - } - c++; /* advance to the next character in the string */ - len--; /* decrement the counter */ - } - - if (escflg > 2 && escflg < 6 && len > 0) { - escflg = 0; - c++; - len--; - } + escflg = 0; + break; + + case 'n': /* device status report (DSR) */ + switch (pScr->parms[0]) { +#if 0 + case 0: /* response from vt100; ready, no malfunctions */ + case 3: /* response from vt100; malfunction, retry */ +#endif + case 5: /* send status */ + case 6: /* send active position */ + wsprintf(stat, "\033[%d;%dR", pScr->y + 1, pScr->x + 1); + for (i = 0; stat[i]; i++) + SendMessage(pScr->hwndTel, WM_MYSCREENCHAR, + stat[i], (LPARAM) pScr); + break; + } /* end switch */ + escflg = 0; + break; + + case 'q': /* load LEDs (unsupported) (DECLL) */ + escflg = 0; + break; + + case 'r': /* set top & bottom margins (DECSTBM) */ + if (pScr->parms[0] < 0) + pScr->top = 0; + else + pScr->top = pScr->parms[0] - 1; + if (pScr->parms[1] < 0) + pScr->bottom = pScr->height - 1; + else + pScr->bottom = pScr->parms[1] - 1; + if (pScr->top < 0) + pScr->top = 0; + if (pScr->top > pScr->height-1) + pScr->top = pScr->height-1; + if (pScr->bottom < 1) + pScr->bottom = pScr->height; + if (pScr->bottom >= pScr->height) + pScr->bottom = pScr->height - 1; + if (pScr->top >= pScr->bottom) {/* check for valid scrolling region */ + if (pScr->bottom >= 1) /* + * assume the bottom value has + * precedence, unless it is as the + * top of the screen + */ + pScr->top = pScr->bottom - 1; + else /* totally psychotic case, bottom of screen set to the very top line, move the bottom to below the top */ + pScr->bottom = pScr->top + 1; } - pScr->escflg = escflg; - ScreenCursorOn(pScr); - -} /* ScreenEm */ + pScr->x = 0; + pScr->y = 0; +#if 0 + if (pScr->DECORG) + pScr->y = pScr->top; /* origin mode relative */ +#endif + escflg = 0; + break; + +#if 0 + case 'x': /* request/report terminal parameters + (DECREQTPARM/DECREPTPARM) */ + case 'y': /* invoke confidence test (DECTST) */ + break; +#endif + + default: + escflg = 0; + break; + + } + + c++; + len--; + +#if 0 + if (pScr->localprint && (len > 0)) { /* see if printer needs anything */ + pcount = send_localprint(c, len); + len -= pcount; + c += pcount; + } +#endif + } + + while ((escflg == 3) && (len > 0)) { /* # Handling */ + switch (*c) { + case 0x08: /* backspace */ + ScreenBackspace(pScr); + break; + +#if 0 + case '3': /* top half of double line (DECDHL) */ + case '4': /* bottom half of double line (DECDHL) */ + case '5': /* single width line (DECSWL) */ + case '6': /* double width line (DECDWL) */ + break; +#endif + + case '8': /* screen alignment display (DECALN) */ + ScreenAlign(pScr); + escflg = 0; + break; + + default: + escflg = 0; + break; + + } + + c++; + len--; + } + + while ((escflg == 4) && (len > 0)) { /* ( Handling (GO character set) */ + switch (*c) { + + case 0x08: /* backspace */ + ScreenBackspace(pScr); + break; + +#if 0 + case 'A': /* united kingdom character set (unsupported) */ + case 'B': /* ASCII character set */ + case '1': /* choose standard graphics (same as ASCII) */ + pScr->G0 = 0; + if (!pScr->charset) + pScr->attrib = ScreenNotGraph(pScr->attrib); + escflg = 0; + break; + + case '0': /* choose special graphics set */ + case '2': /* alternate character set (special graphics) */ + pScr->G0 = 1; + if(!pScr->charset) + pScr->attrib = ScreenGraph(pScr->attrib); + escflg = 0; + break; +#endif + + default: + escflg = 0; + break; + } + + c++; + len--; + + } /* end while */ + + while((escflg == 5) && (len > 0)) { /* ) Handling (G1 handling) */ + switch (*c) { + + case 0x08: /* backspace */ + ScreenBackspace(pScr); + break; + +#if 0 + case 'A': /* united kingdom character set (unsupported) */ + case 'B': /* ASCII character set */ + case '1': /* choose standard graphics (same as ASCII) */ + pScr->G1 = 0; + if (pScr->charset) + pScr->attrib = ScreenNotGraph(pScr->attrib); + escflg = 0; + break; + + case '0': /* choose special graphics set */ + case '2': /* alternate character set (special graphics) */ + pScr->G1 = 1; + if(pScr->charset) + pScr->attrib = ScreenGraph(pScr->attrib); + escflg = 0; + break; +#endif + + default: + escflg = 0; + break; + } /* end switch */ + + c++; + len--; + } /* end while */ + + while ((escflg >= 6) && (escflg <= 10) && (len > 0)) { /* Handling IAC */ + ic = (unsigned char) *c; + switch (escflg) { + + case 6: /* Handling IAC xx */ + if (ic == 255) /* if IAC */ + escflg = 0; + else if (ic == 250) /* if SB */ + escflg = 7; + else + escflg = 9; + break; + + case 7: /* Handling IAC SB xx */ + if (ic == 255) /* if IAC */ + escflg = 8; + break; + + case 8: /* Handling IAC SB IAC xx */ + if (ic == 255) /* if IAC IAC */ + escflg = 7; + else if (ic == 240) /* if IAC SE */ + escflg = 0; + break; + + case 9: /* IAC xx xx */ + escflg = 0; + break; + } + c++; /* advance to the next character in the string */ + len--; /* decrement the counter */ + } + + if (escflg > 2 && escflg < 6 && len > 0) { + escflg = 0; + c++; + len--; + } + } + pScr->escflg = escflg; + ScreenCursorOn(pScr); +} diff --git a/src/windows/wintel/enc_des.c b/src/windows/wintel/enc_des.c new file mode 100644 index 000000000..8357dba7c --- /dev/null +++ b/src/windows/wintel/enc_des.c @@ -0,0 +1,725 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* based on @(#)enc_des.c 8.1 (Berkeley) 6/4/93 */ + +#ifdef ENCRYPTION + +#include "telnet_arpa.h" +#include +#include + +#include "telnet.h" + +#include "encrypt.h" + +#define CFB 0 +#define OFB 1 + +#define NO_SEND_IV 1 +#define NO_RECV_IV 2 +#define NO_KEYID 4 +#define IN_PROGRESS (NO_SEND_IV|NO_RECV_IV|NO_KEYID) +#define SUCCESS 0 +#define xFAILED -1 + + +struct fb { + Block krbdes_key; + Schedule krbdes_sched; + Block temp_feed; + unsigned char fb_feed[64]; + int need_start; + int state[2]; + int keyid[2]; + int once; + struct stinfo { + Block str_output; + Block str_feed; + Block str_iv; + Block str_ikey; + Schedule str_sched; + int str_index; + int str_flagshift; + } streams[2]; +}; + +static struct fb fb[2]; + +struct keyidlist { + char *keyid; + int keyidlen; + char *key; + int keylen; + int flags; +} keyidlist [] = { + { "\0", 1, 0, 0, 0 }, /* default key of zero */ + { 0, 0, 0, 0, 0 } +}; + +#define KEYFLAG_MASK 03 + +#define KEYFLAG_NOINIT 00 +#define KEYFLAG_INIT 01 +#define KEYFLAG_OK 02 +#define KEYFLAG_BAD 03 + +#define KEYFLAG_SHIFT 2 + +#define SHIFT_VAL(a,b) (KEYFLAG_SHIFT*((a)+((b)*2))) + +#define FB64_IV 1 +#define FB64_IV_OK 2 +#define FB64_IV_BAD 3 + +extern kstream EncryptKSGlobalHack; + +void fb64_stream_iv P((Block, struct stinfo *)); +void fb64_init P((struct fb *)); +static int fb64_start P((struct fb *, int, int)); +int fb64_is P((unsigned char *, int, struct fb *)); +int fb64_reply P((unsigned char *, int, struct fb *)); +static void fb64_session P((Session_Key *, int, struct fb *)); +void fb64_stream_key P((Block, struct stinfo *)); +int fb64_keyid P((int, unsigned char *, int *, struct fb *)); + + void +cfb64_init(server) + int server; +{ + fb64_init(&fb[CFB]); + fb[CFB].fb_feed[4] = ENCTYPE_DES_CFB64; + fb[CFB].streams[0].str_flagshift = SHIFT_VAL(0, CFB); + fb[CFB].streams[1].str_flagshift = SHIFT_VAL(1, CFB); +} + + void +ofb64_init(server) + int server; +{ + fb64_init(&fb[OFB]); + fb[OFB].fb_feed[4] = ENCTYPE_DES_OFB64; + fb[CFB].streams[0].str_flagshift = SHIFT_VAL(0, OFB); + fb[CFB].streams[1].str_flagshift = SHIFT_VAL(1, OFB); +} + + void +fb64_init(fbp) + register struct fb *fbp; +{ + memset((void *)fbp, 0, sizeof(*fbp)); + fbp->state[0] = fbp->state[1] = xFAILED; + fbp->fb_feed[0] = IAC; + fbp->fb_feed[1] = SB; + fbp->fb_feed[2] = TELOPT_ENCRYPT; + fbp->fb_feed[3] = ENCRYPT_IS; +} + +/* + * Returns: + * -1: some error. Negotiation is done, encryption not ready. + * 0: Successful, initial negotiation all done. + * 1: successful, negotiation not done yet. + * 2: Not yet. Other things (like getting the key from + * Kerberos) have to happen before we can continue. + */ + int +cfb64_start(dir, server) + int dir; + int server; +{ + return(fb64_start(&fb[CFB], dir, server)); +} + int +ofb64_start(dir, server) + int dir; + int server; +{ + return(fb64_start(&fb[OFB], dir, server)); +} + + static int +fb64_start(fbp, dir, server) + struct fb *fbp; + int dir; + int server; +{ + int x; + unsigned char *p; + register int state; + + switch (dir) { + case DIR_DECRYPT: + /* + * This is simply a request to have the other side + * start output (our input). He will negotiate an + * IV so we need not look for it. + */ + state = fbp->state[dir-1]; + if (state == xFAILED) + state = IN_PROGRESS; + break; + + case DIR_ENCRYPT: + state = fbp->state[dir-1]; + if (state == xFAILED) + state = IN_PROGRESS; + else if ((state & NO_SEND_IV) == 0) + break; + + if (!VALIDKEY(fbp->krbdes_key)) { + fbp->need_start = 1; + break; + } + state &= ~NO_SEND_IV; + state |= NO_RECV_IV; + /* + * Create a random feed and send it over. + */ + des_new_random_key(fbp->temp_feed); + des_ecb_encrypt(fbp->temp_feed, fbp->temp_feed, + fbp->krbdes_sched, 1); + p = fbp->fb_feed + 3; + *p++ = ENCRYPT_IS; + p++; + *p++ = FB64_IV; + for (x = 0; x < sizeof(Block); ++x) { + if ((*p++ = fbp->temp_feed[x]) == IAC) + *p++ = IAC; + } + *p++ = IAC; + *p++ = SE; +#ifdef DEBUG + printsub('>', &fbp->fb_feed[2], p - &fbp->fb_feed[2]); +#endif + TelnetSend(EncryptKSGlobalHack, fbp->fb_feed, p - fbp->fb_feed, 0); + break; + default: + return(xFAILED); + } + return(fbp->state[dir-1] = state); +} + +/* + * Returns: + * -1: some error. Negotiation is done, encryption not ready. + * 0: Successful, initial negotiation all done. + * 1: successful, negotiation not done yet. + */ + int +cfb64_is(data, cnt) + unsigned char *data; + int cnt; +{ + return(fb64_is(data, cnt, &fb[CFB])); +} + int +ofb64_is(data, cnt) + unsigned char *data; + int cnt; +{ + return(fb64_is(data, cnt, &fb[OFB])); +} + + int +fb64_is(data, cnt, fbp) + unsigned char *data; + int cnt; + struct fb *fbp; +{ + unsigned char *p; + register int state = fbp->state[DIR_DECRYPT-1]; + + if (cnt-- < 1) + goto failure; + + switch (*data++) { + case FB64_IV: + if (cnt != sizeof(Block)) { +#ifdef DEBUG + if (encrypt_debug_mode) + printf("CFB64: initial vector failed on size\r\n"); +#endif + state = xFAILED; + goto failure; + } + +#ifdef DEBUG + if (encrypt_debug_mode) { + printf("CFB64: initial vector received\r\n"); + printf("Initializing Decrypt stream\r\n"); + } +#endif + fb64_stream_iv((void *)data, &fbp->streams[DIR_DECRYPT-1]); + + p = fbp->fb_feed + 3; + *p++ = ENCRYPT_REPLY; + p++; + *p++ = FB64_IV_OK; + *p++ = IAC; + *p++ = SE; +#ifdef DEBUG + printsub('>', &fbp->fb_feed[2], p - &fbp->fb_feed[2]); +#endif + TelnetSend(EncryptKSGlobalHack, fbp->fb_feed, p - fbp->fb_feed, 0); + + state = fbp->state[DIR_DECRYPT-1] = IN_PROGRESS; + break; + + default: +#if 0 + if (encrypt_debug_mode) { + printf("Unknown option type: %d\r\n", *(data-1)); + printd(data, cnt); + printf("\r\n"); + } +#endif + /* FALL THROUGH */ + failure: + /* + * We failed. Send an FB64_IV_BAD option + * to the other side so it will know that + * things failed. + */ + p = fbp->fb_feed + 3; + *p++ = ENCRYPT_REPLY; + p++; + *p++ = FB64_IV_BAD; + *p++ = IAC; + *p++ = SE; +#ifdef DEBUG + printsub('>', &fbp->fb_feed[2], p - &fbp->fb_feed[2]); +#endif + TelnetSend(EncryptKSGlobalHack, fbp->fb_feed, p - fbp->fb_feed, 0); + + break; + } + return(fbp->state[DIR_DECRYPT-1] = state); +} + +/* + * Returns: + * -1: some error. Negotiation is done, encryption not ready. + * 0: Successful, initial negotiation all done. + * 1: successful, negotiation not done yet. + */ + int +cfb64_reply(data, cnt) + unsigned char *data; + int cnt; +{ + return(fb64_reply(data, cnt, &fb[CFB])); +} + int +ofb64_reply(data, cnt) + unsigned char *data; + int cnt; +{ + return(fb64_reply(data, cnt, &fb[OFB])); +} + + + int +fb64_reply(data, cnt, fbp) + unsigned char *data; + int cnt; + struct fb *fbp; +{ + register int state = fbp->state[DIR_ENCRYPT-1]; + + if (cnt-- < 1) + goto failure; + + switch (*data++) { + case FB64_IV_OK: + fb64_stream_iv(fbp->temp_feed, &fbp->streams[DIR_ENCRYPT-1]); + if (state == xFAILED) + state = IN_PROGRESS; + state &= ~NO_RECV_IV; + encrypt_send_keyid(DIR_ENCRYPT, (unsigned char *)"\0", 1, 1); + break; + + case FB64_IV_BAD: + memset(fbp->temp_feed, 0, sizeof(Block)); + fb64_stream_iv(fbp->temp_feed, &fbp->streams[DIR_ENCRYPT-1]); + state = xFAILED; + break; + + default: +#if 0 + if (encrypt_debug_mode) { + printf("Unknown option type: %d\r\n", data[-1]); + printd(data, cnt); + printf("\r\n"); + } +#endif + /* FALL THROUGH */ + failure: + state = xFAILED; + break; + } + return(fbp->state[DIR_ENCRYPT-1] = state); +} + + void +cfb64_session(key, server) + Session_Key *key; + int server; +{ + fb64_session(key, server, &fb[CFB]); +} + + void +ofb64_session(key, server) + Session_Key *key; + int server; +{ + fb64_session(key, server, &fb[OFB]); +} + + static void +fb64_session(key, server, fbp) + Session_Key *key; + int server; + struct fb *fbp; +{ + + if (!key || key->type != SK_DES) { +#ifdef DEBUG + if (encrypt_debug_mode) + printf("Can't set krbdes's session key (%d != %d)\r\n", + key ? key->type : -1, SK_DES); +#endif + return; + } + memcpy((void *)fbp->krbdes_key, (void *)key->data, sizeof(Block)); + + fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_ENCRYPT-1]); + fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_DECRYPT-1]); + + if (fbp->once == 0) { + des_set_random_generator_seed(fbp->krbdes_key); + fbp->once = 1; + } + des_key_sched(fbp->krbdes_key, fbp->krbdes_sched); + /* + * Now look to see if krbdes_start() was was waiting for + * the key to show up. If so, go ahead an call it now + * that we have the key. + */ + if (fbp->need_start) { + fbp->need_start = 0; + fb64_start(fbp, DIR_ENCRYPT, server); + } +} + +/* + * We only accept a keyid of 0. If we get a keyid of + * 0, then mark the state as SUCCESS. + */ + int +cfb64_keyid(dir, kp, lenp) + int dir, *lenp; + unsigned char *kp; +{ + return(fb64_keyid(dir, kp, lenp, &fb[CFB])); +} + + int +ofb64_keyid(dir, kp, lenp) + int dir, *lenp; + unsigned char *kp; +{ + return(fb64_keyid(dir, kp, lenp, &fb[OFB])); +} + + int +fb64_keyid(dir, kp, lenp, fbp) + int dir, *lenp; + unsigned char *kp; + struct fb *fbp; +{ + register int state = fbp->state[dir-1]; + + if (*lenp != 1 || (*kp != '\0')) { + *lenp = 0; + return(state); + } + + if (state == xFAILED) + state = IN_PROGRESS; + + state &= ~NO_KEYID; + + return(fbp->state[dir-1] = state); +} + +#if 0 + void +fb64_printsub(data, cnt, buf, buflen, type) + unsigned char *data, *buf, *type; + int cnt, buflen; +{ + char lbuf[32]; + register int i; + char *cp; + + buf[buflen-1] = '\0'; /* make sure it's NULL terminated */ + buflen -= 1; + + switch(data[2]) { + case FB64_IV: + sprintf(lbuf, "%s_IV", type); + cp = lbuf; + goto common; + + case FB64_IV_OK: + sprintf(lbuf, "%s_IV_OK", type); + cp = lbuf; + goto common; + + case FB64_IV_BAD: + sprintf(lbuf, "%s_IV_BAD", type); + cp = lbuf; + goto common; + + default: + sprintf(lbuf, " %d (unknown)", data[2]); + cp = lbuf; + common: + for (; (buflen > 0) && (*buf = *cp++); buf++) + buflen--; + for (i = 3; i < cnt; i++) { + sprintf(lbuf, " %d", data[i]); + for (cp = lbuf; (buflen > 0) && (*buf = *cp++); buf++) + buflen--; + } + break; + } +} + + void +cfb64_printsub(data, cnt, buf, buflen) + unsigned char *data, *buf; + int cnt, buflen; +{ + fb64_printsub(data, cnt, buf, buflen, "CFB64"); +} + + void +ofb64_printsub(data, cnt, buf, buflen) + unsigned char *data, *buf; + int cnt, buflen; +{ + fb64_printsub(data, cnt, buf, buflen, "OFB64"); +} +#endif + + void +fb64_stream_iv(seed, stp) + Block seed; + register struct stinfo *stp; +{ + + memcpy((void *)stp->str_iv, (void *)seed, sizeof(Block)); + memcpy((void *)stp->str_output, (void *)seed, sizeof(Block)); + + des_key_sched(stp->str_ikey, stp->str_sched); + + stp->str_index = sizeof(Block); +} + + void +fb64_stream_key(key, stp) + Block key; + register struct stinfo *stp; +{ + memcpy((void *)stp->str_ikey, (void *)key, sizeof(Block)); + des_key_sched(key, stp->str_sched); + + memcpy((void *)stp->str_output, (void *)stp->str_iv, sizeof(Block)); + + stp->str_index = sizeof(Block); +} + +/* + * DES 64 bit Cipher Feedback + * + * key --->+-----+ + * +->| DES |--+ + * | +-----+ | + * | v + * INPUT --(--------->(+)+---> DATA + * | | + * +-------------+ + * + * + * Given: + * iV: Initial vector, 64 bits (8 bytes) long. + * Dn: the nth chunk of 64 bits (8 bytes) of data to encrypt (decrypt). + * On: the nth chunk of 64 bits (8 bytes) of encrypted (decrypted) output. + * + * V0 = DES(iV, key) + * On = Dn ^ Vn + * V(n+1) = DES(On, key) + */ + + void +cfb64_encrypt(s, c) + register unsigned char *s; + int c; +{ + register struct stinfo *stp = &fb[CFB].streams[DIR_ENCRYPT-1]; + register int index; + + index = stp->str_index; + while (c-- > 0) { + if (index == sizeof(Block)) { + Block b; + des_ecb_encrypt(stp->str_output, b, stp->str_sched, 1); + memcpy((void *)stp->str_feed,(void *)b,sizeof(Block)); + index = 0; + } + + /* On encryption, we store (feed ^ data) which is cypher */ + *s = stp->str_output[index] = (stp->str_feed[index] ^ *s); + s++; + index++; + } + stp->str_index = index; +} + + int +cfb64_decrypt(data) + int data; +{ + register struct stinfo *stp = &fb[CFB].streams[DIR_DECRYPT-1]; + int index; + + if (data == -1) { + /* + * Back up one byte. It is assumed that we will + * never back up more than one byte. If we do, this + * may or may not work. + */ + if (stp->str_index) + --stp->str_index; + return(0); + } + + index = stp->str_index++; + if (index == sizeof(Block)) { + Block b; + des_ecb_encrypt(stp->str_output, b, stp->str_sched, 1); + memcpy((void *)stp->str_feed, (void *)b, sizeof(Block)); + stp->str_index = 1; /* Next time will be 1 */ + index = 0; /* But now use 0 */ + } + + /* On decryption we store (data) which is cypher. */ + stp->str_output[index] = data; + return(data ^ stp->str_feed[index]); +} + +/* + * DES 64 bit Output Feedback + * + * key --->+-----+ + * +->| DES |--+ + * | +-----+ | + * +-----------+ + * v + * INPUT -------->(+) ----> DATA + * + * Given: + * iV: Initial vector, 64 bits (8 bytes) long. + * Dn: the nth chunk of 64 bits (8 bytes) of data to encrypt (decrypt). + * On: the nth chunk of 64 bits (8 bytes) of encrypted (decrypted) output. + * + * V0 = DES(iV, key) + * V(n+1) = DES(Vn, key) + * On = Dn ^ Vn + */ + void +ofb64_encrypt(s, c) + register unsigned char *s; + int c; +{ + register struct stinfo *stp = &fb[OFB].streams[DIR_ENCRYPT-1]; + register int index; + + index = stp->str_index; + while (c-- > 0) { + if (index == sizeof(Block)) { + Block b; + des_ecb_encrypt(stp->str_feed, b, stp->str_sched, 1); + memcpy((void *)stp->str_feed,(void *)b,sizeof(Block)); + index = 0; + } + *s++ ^= stp->str_feed[index]; + index++; + } + stp->str_index = index; +} + + int +ofb64_decrypt(data) + int data; +{ + register struct stinfo *stp = &fb[OFB].streams[DIR_DECRYPT-1]; + int index; + + if (data == -1) { + /* + * Back up one byte. It is assumed that we will + * never back up more than one byte. If we do, this + * may or may not work. + */ + if (stp->str_index) + --stp->str_index; + return(0); + } + + index = stp->str_index++; + if (index == sizeof(Block)) { + Block b; + des_ecb_encrypt(stp->str_feed, b, stp->str_sched, 1); + memcpy((void *)stp->str_feed, (void *)b, sizeof(Block)); + stp->str_index = 1; /* Next time will be 1 */ + index = 0; /* But now use 0 */ + } + + return(data ^ stp->str_feed[index]); +} + +#endif /* ENCRYPTION */ diff --git a/src/windows/wintel/enc_des.h b/src/windows/wintel/enc_des.h new file mode 100644 index 000000000..996a4f5d0 --- /dev/null +++ b/src/windows/wintel/enc_des.h @@ -0,0 +1,126 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)enc-proto.h 8.1 (Berkeley) 6/4/93 + */ + +/* + * Copyright (C) 1990 by the Massachusetts Institute of Technology + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + */ +#if !defined(P) +#ifdef __STDC__ +#define P(x) x +#else +#define P(x) () +#endif +#endif + +#ifdef ENCRYPTION +void encrypt_init P((char *, int)); +Encryptions *findencryption P((int)); +void encrypt_send_supprt P((void)); +void encrypt_auto P((int)); +void decrypt_auto P((int)); +void encrypt_is P((unsigned char *, int)); +void encrypt_reply P((unsigned char *, int)); +void encrypt_start_input P((int)); +void encrypt_session_key P((Session_Key *, int)); +void encrypt_end_input P((void)); +void encrypt_start_output P((int)); +void encrypt_end_output P((void)); +void encrypt_send_request_start P((void)); +void encrypt_send_request_end P((void)); +void encrypt_send_end P((void)); +void encrypt_wait P((void)); +int encrypt_is_encrypting P((void)); +void encrypt_send_support P((void)); +void encrypt_send_keyid P((int, unsigned char *, int, int)); +int net_write P((unsigned char *, int)); + +#ifdef TELENTD +void encrypt_wait P((void)); +#else +int encrypt_cmd P((int, char **)); +void encrypt_display P((void)); +#endif + +void krbdes_encrypt P((unsigned char *, int)); +int krbdes_decrypt P((int)); +int krbdes_is P((unsigned char *, int)); +int krbdes_reply P((unsigned char *, int)); +void krbdes_init P((int)); +int krbdes_start P((int, int)); +void krbdes_session P((Session_Key *, int)); +void krbdes_printsub P((unsigned char *, int, unsigned char *, int)); + +void cfb64_encrypt P((unsigned char *, int)); +int cfb64_decrypt P((int)); +void cfb64_init P((int)); +int cfb64_start P((int, int)); +int cfb64_is P((unsigned char *, int)); +int cfb64_reply P((unsigned char *, int)); +void cfb64_session P((Session_Key *, int)); +int cfb64_keyid P((int, unsigned char *, int *)); +void cfb64_printsub P((unsigned char *, int, unsigned char *, int)); + +void ofb64_encrypt P((unsigned char *, int)); +int ofb64_decrypt P((int)); +void ofb64_init P((int)); +int ofb64_start P((int, int)); +int ofb64_is P((unsigned char *, int)); +int ofb64_reply P((unsigned char *, int)); +void ofb64_session P((Session_Key *, int)); +int ofb64_keyid P((int, unsigned char *, int *)); +void ofb64_printsub P((unsigned char *, int, unsigned char *, int)); + +int des_new_random_key P((Block)); +void des_set_random_generator_seed P((Block)); +void des_key_sched P((Block, Schedule)); +void des_ecb_encrypt P((Block, Block, Schedule, int)); +int des_string_to_key P((char *, Block)); +#endif /* ENCRYPTION */ diff --git a/src/windows/wintel/encrypt.c b/src/windows/wintel/encrypt.c new file mode 100644 index 000000000..9c72a478f --- /dev/null +++ b/src/windows/wintel/encrypt.c @@ -0,0 +1,988 @@ +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* based on @(#)encrypt.c 8.1 (Berkeley) 6/4/93 */ + +/* + * Copyright (C) 1990 by the Massachusetts Institute of Technology + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + */ + +#ifdef ENCRYPTION + +#include + +#define isprefix(a, b) (!strncmp((a), (b), strlen(b))) + +#ifdef KRB4 +#include +#include +#include +#include "winsock.h" +#include "kerberos.h" +#endif +#ifdef KRB5 +#include +#include +#include "krb5.h" +#include "com_err.h" +#endif + +#include "telnet.h" +#include "encrypt.h" + +#define ENCRYPT_NAMES +#include "telnet_arpa.h" + +/* + * These function pointers point to the current routines + * for encrypting and decrypting data. + */ +void (*encrypt_output) P((unsigned char *, int)); +int (*decrypt_input) P((int)); + +#ifdef DEBUG +int encrypt_debug_mode = 1; +int encrypt_verbose = 1; +#else +int encrypt_verbose = 0; +#endif + +char dbgbuf [10240]; + +static int decrypt_mode = 0; +static int encrypt_mode = 0; +static int autoencrypt = 1; +static int autodecrypt = 1; +static int havesessionkey = 0; + +kstream EncryptKSGlobalHack = NULL; + +#define typemask(x) ((x) > 0 ? 1 << ((x)-1) : 0) + +static long i_support_encrypt = + typemask(ENCTYPE_DES_CFB64) | typemask(ENCTYPE_DES_OFB64); +static long i_support_decrypt = + typemask(ENCTYPE_DES_CFB64) | typemask(ENCTYPE_DES_OFB64); +static long i_wont_support_encrypt = 0; +static long i_wont_support_decrypt = 0; +#define I_SUPPORT_ENCRYPT (i_support_encrypt & ~i_wont_support_encrypt) +#define I_SUPPORT_DECRYPT (i_support_decrypt & ~i_wont_support_decrypt) + +static long remote_supports_encrypt = 0; +static long remote_supports_decrypt = 0; + +static Encryptions encryptions[] = { + { "DES_CFB64", + ENCTYPE_DES_CFB64, + cfb64_encrypt, + cfb64_decrypt, + cfb64_init, + cfb64_start, + cfb64_is, + cfb64_reply, + cfb64_session, + cfb64_keyid, + NULL }, + { "DES_OFB64", + ENCTYPE_DES_OFB64, + ofb64_encrypt, + ofb64_decrypt, + ofb64_init, + ofb64_start, + ofb64_is, + ofb64_reply, + ofb64_session, + ofb64_keyid, + NULL }, + { 0, }, +}; + +static unsigned char str_send[64] = { IAC, SB, TELOPT_ENCRYPT, + ENCRYPT_SUPPORT }; +static unsigned char str_suplen = 0; +static unsigned char str_start[72] = { IAC, SB, TELOPT_ENCRYPT }; +static unsigned char str_end[] = { IAC, SB, TELOPT_ENCRYPT, 0, IAC, SE }; + +void encrypt_request_end(void); +void encrypt_request_start(unsigned char *, int); +void encrypt_enc_keyid(unsigned char *, int); +void encrypt_dec_keyid(unsigned char *, int); +void encrypt_support(unsigned char *, int); +void encrypt_start(unsigned char *, int); +void encrypt_end(void); + +int encrypt_ks_stream(struct kstream_data_block *, /* output */ + struct kstream_data_block *, /* input */ + struct kstream *); + +int decrypt_ks_stream(struct kstream_data_block *, /* output */ + struct kstream_data_block *, /* input */ + struct kstream *); + +int +encrypt_ks_stream(struct kstream_data_block *i, + struct kstream_data_block *o, + struct kstream *ks) +{ + + /* + * this is really quite bogus, since it does an in-place encryption... + */ + if (encrypt_output) { + encrypt_output(i->ptr, i->length); + return 1; + } + + return 0; +} + + +int +decrypt_ks_stream(struct kstream_data_block *i, + struct kstream_data_block *o, + struct kstream *ks) +{ + unsigned int len; + /* + * this is really quite bogus, since it does an in-place decryption... + */ + if (decrypt_input) { + for (len = 0 ; len < i->length ; len++) + ((unsigned char *)i->ptr)[len] + = decrypt_input(((unsigned char *)i->ptr)[len]); + return 1; + } + + return 0; +} + +int +decrypt_ks_hack(unsigned char *buf, int cnt) +{ + int len; + /* + * this is really quite bogus, since it does an in-place decryption... + */ + for (len = 0 ; len < cnt ; len++) + buf[len] = decrypt_input(buf[len]); + +#ifdef DEBUG + hexdump("hack:", buf, cnt); +#endif + return 1; +} + +#ifdef DEBUG +int +printsub(char c, unsigned char *s, size_t len) +{ + size_t i; + char *p = dbgbuf; + + *p++ = c; + + for (i = 0 ; i < len ; i++) + p += sprintf(p, "%02x ", s[i]); + + strcat(p, "\n"); + + OutputDebugString(dbgbuf); + + return 0; +} +#endif + +/* + * parsedat[0] == the suboption we might be negoating, + */ +void +encrypt_parse(kstream ks, unsigned char *parsedat, int end_sub) +{ + char *p = dbgbuf; + +#ifdef DEBUG + printsub('<', parsedat, end_sub); +#endif + + switch(parsedat[1]) { + case ENCRYPT_START: + encrypt_start(parsedat + 2, end_sub - 2); + break; + case ENCRYPT_END: + encrypt_end(); + break; + case ENCRYPT_SUPPORT: + encrypt_support(parsedat + 2, end_sub - 2); + break; + case ENCRYPT_REQSTART: + encrypt_request_start(parsedat + 2, end_sub - 2); + break; + case ENCRYPT_REQEND: + /* + * We can always send an REQEND so that we cannot + * get stuck encrypting. We should only get this + * if we have been able to get in the correct mode + * anyhow. + */ + encrypt_request_end(); + break; + case ENCRYPT_IS: + encrypt_is(parsedat + 2, end_sub - 2); + break; + case ENCRYPT_REPLY: + encrypt_reply(parsedat + 2, end_sub - 2); + break; + case ENCRYPT_ENC_KEYID: + encrypt_enc_keyid(parsedat + 2, end_sub - 2); + break; + case ENCRYPT_DEC_KEYID: + encrypt_dec_keyid(parsedat + 2, end_sub - 2); + break; + default: + break; + } +} + +/* XXX */ +Encryptions * +findencryption(type) + int type; +{ + Encryptions *ep = encryptions; + + if (!(I_SUPPORT_ENCRYPT & remote_supports_decrypt & typemask(type))) + return(0); + while (ep->type && ep->type != type) + ++ep; + return(ep->type ? ep : 0); +} + +Encryptions * +finddecryption(int type) +{ + Encryptions *ep = encryptions; + + if (!(I_SUPPORT_DECRYPT & remote_supports_encrypt & typemask(type))) + return(0); + while (ep->type && ep->type != type) + ++ep; + return(ep->type ? ep : 0); +} + +#define MAXKEYLEN 64 + +static struct key_info { + unsigned char keyid[MAXKEYLEN]; + int keylen; + int dir; + int *modep; + Encryptions *(*getcrypt)(); +} ki[2] = { + { { 0 }, 0, DIR_ENCRYPT, &encrypt_mode, findencryption }, + { { 0 }, 0, DIR_DECRYPT, &decrypt_mode, finddecryption }, +}; + +void +encrypt_init(kstream iks, kstream_ptr data) +{ + Encryptions *ep = encryptions; + + i_support_encrypt = i_support_decrypt = 0; + remote_supports_encrypt = remote_supports_decrypt = 0; + encrypt_mode = 0; + decrypt_mode = 0; + encrypt_output = NULL; + decrypt_input = NULL; + + str_suplen = 4; + + EncryptKSGlobalHack = iks; + + while (ep->type) { +#ifdef DEBUG + if (encrypt_debug_mode) { + sprintf(dbgbuf, ">>>I will support %s\n", + ENCTYPE_NAME(ep->type)); + OutputDebugString(dbgbuf); + } +#endif + i_support_encrypt |= typemask(ep->type); + i_support_decrypt |= typemask(ep->type); + if ((i_wont_support_decrypt & typemask(ep->type)) == 0) + if ((str_send[str_suplen++] = ep->type) == IAC) + str_send[str_suplen++] = IAC; + if (ep->init) + (*ep->init)(0); + ++ep; + } + str_send[str_suplen++] = IAC; + str_send[str_suplen++] = SE; +} + +void +encrypt_send_support() +{ + if (str_suplen) { + /* + * If the user has requested that decryption start + * immediatly, then send a "REQUEST START" before + * we negotiate the type. + */ + if (autodecrypt) + encrypt_send_request_start(); + TelnetSend(EncryptKSGlobalHack, str_send, str_suplen, 0); + +#ifdef DEBUG + printsub('>', &str_send[2], str_suplen - 2); +#endif + + str_suplen = 0; + } +} + +/* + * Called when ENCRYPT SUPPORT is received. + */ +void +encrypt_support(typelist, cnt) + unsigned char *typelist; + int cnt; +{ + register int type, use_type = 0; + Encryptions *ep; + + /* + * Forget anything the other side has previously told us. + */ + remote_supports_decrypt = 0; + + while (cnt-- > 0) { + type = *typelist++; +#ifdef DEBUG + if (encrypt_debug_mode) { + sprintf(dbgbuf, ">>>Remote supports %s (%d)\n", + ENCTYPE_NAME(type), type); + OutputDebugString(dbgbuf); + } +#endif + if ((type < ENCTYPE_CNT) && + (I_SUPPORT_ENCRYPT & typemask(type))) { + remote_supports_decrypt |= typemask(type); + if (use_type == 0) + use_type = type; + } + } + if (use_type) { + ep = findencryption(use_type); + if (!ep) + return; + type = ep->start ? (*ep->start)(DIR_ENCRYPT, 0) : 0; +#ifdef DEBUG + if (encrypt_debug_mode) { + sprintf(dbgbuf, ">>>(*ep->start)() %s returned %d (%s)\n", + ENCTYPE_NAME(use_type), type, ENCRYPT_NAME(type)); + OutputDebugString(dbgbuf); + } +#endif + if (type < 0) + return; + encrypt_mode = use_type; + if (type == 0) + encrypt_start_output(use_type); + } +} + +void +encrypt_is(data, cnt) + unsigned char *data; + int cnt; +{ + Encryptions *ep; + register int type, ret; + + if (--cnt < 0) + return; + type = *data++; + if (type < ENCTYPE_CNT) + remote_supports_encrypt |= typemask(type); + if (!(ep = finddecryption(type))) { +#ifdef DEBUG + if (encrypt_debug_mode) { + sprintf(dbgbuf, ">>>encrypt_reply: " + "Can't find type %s (%d) for initial negotiation\n", + ENCTYPE_NAME_OK(type) + ? ENCTYPE_NAME(type) : "(unknown)", + type); + OutputDebugString(dbgbuf); + } +#endif + return; + } + if (!ep->is) { +#ifdef DEBUG + if (encrypt_debug_mode) { + sprintf(dbgbuf, ">>>encrypt_reply: " + "No initial negotiation needed for type %s (%d)\n", + ENCTYPE_NAME_OK(type) + ? ENCTYPE_NAME(type) : "(unknown)", + type); + OutputDebugString(dbgbuf); + } +#endif + ret = 0; + } else { + ret = (*ep->is)(data, cnt); +#ifdef DEBUG + if (encrypt_debug_mode) { + sprintf(dbgbuf, "encrypt_reply: " + "(*ep->is)(%x, %d) returned %s(%d)\n", data, cnt, + (ret < 0) ? "FAIL " : + (ret == 0) ? "SUCCESS " : "MORE_TO_DO ", ret); + OutputDebugString(dbgbuf); + } +#endif + } + if (ret < 0) { + autodecrypt = 0; + } else { + decrypt_mode = type; + if (ret == 0 && autodecrypt) + encrypt_send_request_start(); + } +} + +void +encrypt_reply(data, cnt) + unsigned char *data; + int cnt; +{ + Encryptions *ep; + register int ret, type; + + if (--cnt < 0) + return; + type = *data++; + if (!(ep = findencryption(type))) { +#ifdef DEBUG + if (encrypt_debug_mode) { + sprintf(dbgbuf, ">>>Can't find type %s (%d) for initial negotiation\n", + ENCTYPE_NAME_OK(type) + ? ENCTYPE_NAME(type) : "(unknown)", + type); + OutputDebugString(dbgbuf); + } +#endif + return; + } + if (!ep->reply) { +#ifdef DEBUG + if (encrypt_debug_mode) { + sprintf(dbgbuf, ">>>No initial negotiation needed for type %s (%d)\n", + ENCTYPE_NAME_OK(type) + ? ENCTYPE_NAME(type) : "(unknown)", + type); + OutputDebugString(dbgbuf); + } +#endif + ret = 0; + } else { + ret = (*ep->reply)(data, cnt); +#ifdef DEBUG + if (encrypt_debug_mode) { + sprintf(dbgbuf, "(*ep->reply)(%x, %d) returned %s(%d)\n", + data, cnt, + (ret < 0) ? "FAIL " : + (ret == 0) ? "SUCCESS " : "MORE_TO_DO ", ret); + OutputDebugString(dbgbuf); + } +#endif + } +#ifdef DEBUG + if (encrypt_debug_mode) { + sprintf(dbgbuf, ">>>encrypt_reply returned %d\n", ret); + OutputDebugString(dbgbuf); + } +#endif + if (ret < 0) { + autoencrypt = 0; + } else { + encrypt_mode = type; + if (ret == 0 && autoencrypt) + encrypt_start_output(type); + } +} + +/* + * Called when a ENCRYPT START command is received. + */ +void +encrypt_start(data, cnt) + unsigned char *data; + int cnt; +{ + Encryptions *ep; + + if (!decrypt_mode) { + /* + * Something is wrong. We should not get a START + * command without having already picked our + * decryption scheme. Send a REQUEST-END to + * attempt to clear the channel... + */ + printf("Warning, Cannot decrypt input stream!!!\n"); + encrypt_send_request_end(); + return; + } + + if (ep = finddecryption(decrypt_mode)) { + extern BOOL encrypt_flag; + + decrypt_input = ep->input; + EncryptKSGlobalHack->decrypt = decrypt_ks_stream; + encrypt_flag = 2; /* XXX hack */ + + if (encrypt_verbose) { + sprintf(dbgbuf, "[ Input is now decrypted with type %s ]\n", + ENCTYPE_NAME(decrypt_mode)); + OutputDebugString(dbgbuf); + } +#ifdef DEBUG + if (encrypt_debug_mode) { + sprintf(dbgbuf, ">>>Start to decrypt input with type %s\n", + ENCTYPE_NAME(decrypt_mode)); + OutputDebugString(dbgbuf); + } +#endif + } else { + printf("Warning, Cannot decrypt type %s (%d)!!!\n", + ENCTYPE_NAME_OK(decrypt_mode) + ? ENCTYPE_NAME(decrypt_mode) + : "(unknown)", + decrypt_mode); + encrypt_send_request_end(); + } +} + +void +encrypt_session_key(key, server) + Session_Key *key; + int server; +{ + Encryptions *ep = encryptions; + + havesessionkey = 1; + + while (ep->type) { + if (ep->session) + (*ep->session)(key, server); +#if defined(notdef) + if (!encrypt_output && autoencrypt && !server) + encrypt_start_output(ep->type); + if (!decrypt_input && autodecrypt && !server) + encrypt_send_request_start(); +#endif + ++ep; + } +} + +/* + * Called when ENCRYPT END is received. + */ +void +encrypt_end() +{ + decrypt_input = NULL; + EncryptKSGlobalHack->decrypt = NULL; +#ifdef DEBUG + if (encrypt_debug_mode) { + sprintf(dbgbuf, ">>>Input is back to clear text\n"); + OutputDebugString(dbgbuf); + } +#endif + if (encrypt_verbose) + printf("[ Input is now clear text ]\n"); +} + +/* + * Called when ENCRYPT REQUEST-END is received. + */ +void +encrypt_request_end() +{ + encrypt_send_end(); +} + +/* + * Called when ENCRYPT REQUEST-START is received. If we receive + * this before a type is picked, then that indicates that the + * other side wants us to start encrypting data as soon as we + * can. + */ +void +encrypt_request_start(data, cnt) + unsigned char *data; + int cnt; +{ + if (encrypt_mode == 0) { + return; + } + encrypt_start_output(encrypt_mode); +} + +static unsigned char str_keyid[(MAXKEYLEN*2)+5] = { IAC, SB, TELOPT_ENCRYPT }; + +void +encrypt_keyid(); + +void +encrypt_enc_keyid(keyid, len) + unsigned char *keyid; + int len; +{ + encrypt_keyid(&ki[1], keyid, len); +} + +void +encrypt_dec_keyid(keyid, len) + unsigned char *keyid; + int len; +{ + encrypt_keyid(&ki[0], keyid, len); +} + +void +encrypt_keyid(kp, keyid, len) + struct key_info *kp; + unsigned char *keyid; + int len; +{ + Encryptions *ep; + int dir = kp->dir; + register int ret = 0; + + if (!(ep = (*kp->getcrypt)(*kp->modep))) { + if (len == 0) + return; + kp->keylen = 0; + } else if (len == 0) { + /* + * Empty option, indicates a failure. + */ + if (kp->keylen == 0) + return; + kp->keylen = 0; + if (ep->keyid) + (void)(*ep->keyid)(dir, kp->keyid, &kp->keylen); + + } else if ((len != kp->keylen) || (memcmp(keyid, kp->keyid, len) != 0)) { + /* + * Length or contents are different + */ + kp->keylen = len; + memcpy(kp->keyid, keyid, len); + if (ep->keyid) + (void)(*ep->keyid)(dir, kp->keyid, &kp->keylen); + } else { + if (ep->keyid) + ret = (*ep->keyid)(dir, kp->keyid, &kp->keylen); + if ((ret == 0) && (dir == DIR_ENCRYPT) && autoencrypt) + encrypt_start_output(*kp->modep); + return; + } + + encrypt_send_keyid(dir, kp->keyid, kp->keylen, 0); +} + +void +encrypt_send_keyid(dir, keyid, keylen, saveit) + int dir; + unsigned char *keyid; + int keylen; + int saveit; +{ + unsigned char *strp; + + str_keyid[3] = (dir == DIR_ENCRYPT) + ? ENCRYPT_ENC_KEYID : ENCRYPT_DEC_KEYID; + if (saveit) { + struct key_info *kp = &ki[(dir == DIR_ENCRYPT) ? 0 : 1]; + memcpy(kp->keyid, keyid, keylen); + kp->keylen = keylen; + } + + for (strp = &str_keyid[4]; keylen > 0; --keylen) { + if ((*strp++ = *keyid++) == IAC) + *strp++ = IAC; + } + *strp++ = IAC; + *strp++ = SE; + TelnetSend(EncryptKSGlobalHack, str_keyid, strp - str_keyid, 0); + +#ifdef DEBUG + printsub('>', &str_keyid[2], strp - str_keyid - 2); +#endif + +} + +void +encrypt_auto(on) + int on; +{ + if (on < 0) + autoencrypt ^= 1; + else + autoencrypt = on ? 1 : 0; +} + +void +decrypt_auto(on) + int on; +{ + if (on < 0) + autodecrypt ^= 1; + else + autodecrypt = on ? 1 : 0; +} + +void +encrypt_start_output(type) + int type; +{ + Encryptions *ep; + register unsigned char *p; + register int i; + + if (!(ep = findencryption(type))) { +#ifdef DEBUG + if (encrypt_debug_mode) { + sprintf(dbgbuf, ">>>Can't encrypt with type %s (%d)\n", + ENCTYPE_NAME_OK(type) + ? ENCTYPE_NAME(type) : "(unknown)", + type); + OutputDebugString(dbgbuf); + } +#endif + return; + } + if (ep->start) { + i = (*ep->start)(DIR_ENCRYPT, 0); +#ifdef DEBUG + if (encrypt_debug_mode) { + sprintf(dbgbuf, ">>>Encrypt start: %s (%d) %s\n", + (i < 0) ? "failed" : + "initial negotiation in progress", + i, ENCTYPE_NAME(type)); + OutputDebugString(dbgbuf); + } +#endif + if (i) + return; + } + p = str_start + 3; + *p++ = ENCRYPT_START; + for (i = 0; i < ki[0].keylen; ++i) { + if ((*p++ = ki[0].keyid[i]) == IAC) + *p++ = IAC; + } + *p++ = IAC; + *p++ = SE; + TelnetSend(EncryptKSGlobalHack, str_start, p - str_start, 0); +#ifdef DEBUG + printsub('>', &str_start[2], p - &str_start[2]); +#endif + + /* + * If we are already encrypting in some mode, then + * encrypt the ring (which includes our request) in + * the old mode, mark it all as "clear text" and then + * switch to the new mode. + */ + encrypt_output = ep->output; + EncryptKSGlobalHack->encrypt = encrypt_ks_stream; + encrypt_mode = type; +#ifdef DEBUG + if (encrypt_debug_mode) { + sprintf(dbgbuf, ">>>Started to encrypt output with type %s\n", + ENCTYPE_NAME(type)); + OutputDebugString(dbgbuf); + } +#endif + if (encrypt_verbose) { + sprintf(dbgbuf, "[ Output is now encrypted with type %s ]\n", + ENCTYPE_NAME(type)); + OutputDebugString(dbgbuf); + } +} + +void +encrypt_send_end() +{ + if (!encrypt_output) + return; + + str_end[3] = ENCRYPT_END; + TelnetSend(EncryptKSGlobalHack, str_end, sizeof(str_end), 0); +#ifdef DEBUG + printsub('>', &str_end[2], sizeof(str_end) - 2); +#endif + + /* + * Encrypt the output buffer now because it will not be done by + * netflush... + */ + encrypt_output = 0; + EncryptKSGlobalHack->encrypt = NULL; +#ifdef DEBUG + if (encrypt_debug_mode) { + sprintf(dbgbuf, ">>>Output is back to clear text\n"); + OutputDebugString(dbgbuf); + } +#endif + if (encrypt_verbose) + printf("[ Output is now clear text ]\n"); +} + +void +encrypt_send_request_start() +{ + register unsigned char *p; + register int i; + + p = &str_start[3]; + *p++ = ENCRYPT_REQSTART; + for (i = 0; i < ki[1].keylen; ++i) { + if ((*p++ = ki[1].keyid[i]) == IAC) + *p++ = IAC; + } + *p++ = IAC; + *p++ = SE; + TelnetSend(EncryptKSGlobalHack, str_start, p - str_start, 0); +#ifdef DEBUG + printsub('>', &str_start[2], p - &str_start[2]); + + if (encrypt_debug_mode) { + sprintf(dbgbuf, ">>>Request input to be encrypted\n"); + OutputDebugString(dbgbuf); + } +#endif +} + +void +encrypt_send_request_end() +{ + str_end[3] = ENCRYPT_REQEND; + TelnetSend(EncryptKSGlobalHack, str_end, sizeof(str_end), 0); +#ifdef DEBUG + printsub('>', &str_end[2], sizeof(str_end) - 2); + + if (encrypt_debug_mode) { + sprintf(dbgbuf, ">>>Request input to be clear text\n"); + OutputDebugString(dbgbuf); + } +#endif +} + +int encrypt_is_encrypting() +{ + if (encrypt_output && decrypt_input) + return 1; + return 0; +} + +#ifdef DEBUG +void +encrypt_debug(mode) + int mode; +{ + encrypt_debug_mode = mode; +} +#endif + +#if 0 +void +encrypt_gen_printsub(data, cnt, buf, buflen) + unsigned char *data, *buf; + int cnt, buflen; +{ + char tbuf[16], *cp; + + cnt -= 2; + data += 2; + buf[buflen-1] = '\0'; + buf[buflen-2] = '*'; + buflen -= 2;; + for (; cnt > 0; cnt--, data++) { + sprintf(tbuf, " %d", *data); + for (cp = tbuf; *cp && buflen > 0; --buflen) + *buf++ = *cp++; + if (buflen <= 0) + return; + } + *buf = '\0'; +} + +void +encrypt_printsub(data, cnt, buf, buflen) + unsigned char *data, *buf; + int cnt, buflen; +{ + Encryptions *ep; + register int type = data[1]; + + for (ep = encryptions; ep->type && ep->type != type; ep++) + ; + + if (ep->printsub) + (*ep->printsub)(data, cnt, buf, buflen); + else + encrypt_gen_printsub(data, cnt, buf, buflen); +} +#endif + +#endif /* ENCRYPTION */ diff --git a/src/windows/wintel/encrypt.h b/src/windows/wintel/encrypt.h new file mode 100644 index 000000000..80295681c --- /dev/null +++ b/src/windows/wintel/encrypt.h @@ -0,0 +1,182 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)encrypt.h 8.1 (Berkeley) 6/4/93 + */ + +/* + * Copyright (C) 1990 by the Massachusetts Institute of Technology + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + */ + +#ifdef ENCRYPTION + +#ifndef __ENCRYPTION__ +#define __ENCRYPTION__ + +#define DIR_DECRYPT 1 +#define DIR_ENCRYPT 2 + +typedef unsigned char Block[8]; +typedef unsigned char *BlockT; +typedef struct { Block _; } Schedule[16]; + +#define VALIDKEY(key) ( key[0] | key[1] | key[2] | key[3] | key[4] | key[5] | key[6] | key[7]) + +#define SAMEKEY(k1, k2) (!memcmp((void *)k1, (void *)k2, sizeof(Block))) + +typedef struct { + short type; + int length; + unsigned char *data; +} Session_Key; + +#if !defined(P) +#ifdef __STDC__ +#define P(x) x +#else +#define P(x) () +#endif +#endif + +#ifdef DEBUG +int printsub(char, unsigned char *, size_t); +#endif + +void encrypt_parse(kstream, unsigned char *, int); + +typedef struct { + char *name; + int type; + void (*output) P((unsigned char *, int)); + int (*input) P((int)); + void (*init) P((int)); + int (*start) P((int, int)); + int (*is) P((unsigned char *, int)); + int (*reply) P((unsigned char *, int)); + void (*session) P((Session_Key *, int)); + int (*keyid) P((int, unsigned char *, int *)); + void (*printsub) P((unsigned char *, int, unsigned char *, int)); +} Encryptions; + +#define SK_DES 1 /* Matched Kerberos v5 ENCTYPE_DES */ + +void encrypt_init P((kstream, char *, int)); +Encryptions *findencryption P((int)); +void encrypt_send_supprt P((void)); +void encrypt_auto P((int)); +void decrypt_auto P((int)); +void encrypt_is P((unsigned char *, int)); +void encrypt_reply P((unsigned char *, int)); +void encrypt_start_input P((int)); +void encrypt_session_key P((Session_Key *, int)); +void encrypt_end_input P((void)); +void encrypt_start_output P((int)); +void encrypt_end_output P((void)); +void encrypt_send_request_start P((void)); +void encrypt_send_request_end P((void)); +void encrypt_send_end P((void)); +void encrypt_wait P((void)); +int encrypt_is_encrypting P((void)); +void encrypt_send_support P((void)); +void encrypt_send_keyid P((int, unsigned char *, int, int)); +int net_write P((unsigned char *, int)); + +int encrypt_cmd P((int, char **)); +void encrypt_display P((void)); + +void krbdes_encrypt P((unsigned char *, int)); +int krbdes_decrypt P((int)); +int krbdes_is P((unsigned char *, int)); +int krbdes_reply P((unsigned char *, int)); +void krbdes_init P((int)); +int krbdes_start P((int, int)); +void krbdes_session P((Session_Key *, int)); +void krbdes_printsub P((unsigned char *, int, unsigned char *, int)); + +void cfb64_encrypt P((unsigned char *, int)); +int cfb64_decrypt P((int)); +void cfb64_init P((int)); +int cfb64_start P((int, int)); +int cfb64_is P((unsigned char *, int)); +int cfb64_reply P((unsigned char *, int)); +void cfb64_session P((Session_Key *, int)); +int cfb64_keyid P((int, unsigned char *, int *)); +void cfb64_printsub P((unsigned char *, int, unsigned char *, int)); + +void ofb64_encrypt P((unsigned char *, int)); +int ofb64_decrypt P((int)); +void ofb64_init P((int)); +int ofb64_start P((int, int)); +int ofb64_is P((unsigned char *, int)); +int ofb64_reply P((unsigned char *, int)); +void ofb64_session P((Session_Key *, int)); +int ofb64_keyid P((int, unsigned char *, int *)); +void ofb64_printsub P((unsigned char *, int, unsigned char *, int)); + +__declspec(dllimport) int __stdcall +des_new_random_key P((Block)); +__declspec(dllimport) void __stdcall +des_set_random_generator_seed P((Block)); +__declspec(dllimport) void __stdcall +des_key_sched P((Block, Schedule)); +__declspec(dllimport) void __stdcall +des_ecb_encrypt P((Block, Block, Schedule, int)); +int des_string_to_key P((char *, Block)); + +#ifdef DEBUG +extern int encrypt_debug_mode; +#endif + +extern int (*decrypt_input) P((int)); +extern void (*encrypt_output) P((unsigned char *, int)); + +int decrypt_ks_hack(unsigned char *, int); + +#endif /* __ENCRYPTION__ */ + +#endif /* ENCRYPTION */ diff --git a/src/windows/wintel/font.c b/src/windows/wintel/font.c index ce6708325..1bab00c7e 100644 --- a/src/windows/wintel/font.c +++ b/src/windows/wintel/font.c @@ -7,91 +7,94 @@ #include "ini.h" void ProcessFontChange( - HWND hWnd) + HWND hWnd) { - static DWORD dwFontColor; /* Color of font if one has been selected */ - CHOOSEFONT cf; - HDC hDC; - SCREEN *pScr; - TEXTMETRIC tm; - char buf[16]; - char szStyle[LF_FACESIZE]; + static DWORD dwFontColor; /* Color of font if one has been selected */ + CHOOSEFONT cf; + HDC hDC; + SCREEN *pScr; + TEXTMETRIC tm; + char buf[16]; + char szStyle[LF_FACESIZE]; - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert(pScr != NULL); + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert(pScr != NULL); - cf.lStructSize = sizeof(cf); - cf.hwndOwner = hWnd; - cf.lpLogFont = (LPLOGFONT) &(pScr->lf); - cf.lpszStyle = szStyle; - cf.Flags = CF_INITTOLOGFONTSTRUCT; // | CF_USESTYLE; - cf.Flags |= CF_SCREENFONTS; -// cf.Flags |= CF_ANSIONLY; - cf.Flags |= CF_FORCEFONTEXIST; - cf.Flags |= CF_FIXEDPITCHONLY; - cf.Flags |= CF_NOSIMULATIONS; + cf.lStructSize = sizeof(cf); + cf.hwndOwner = hWnd; + cf.lpLogFont = (LPLOGFONT) &(pScr->lf); + cf.lpszStyle = szStyle; + cf.Flags = CF_INITTOLOGFONTSTRUCT; /* | CF_USESTYLE; */ + cf.Flags |= CF_SCREENFONTS; +#if 0 + cf.Flags |= CF_ANSIONLY; +#endif + cf.Flags |= CF_FORCEFONTEXIST; + cf.Flags |= CF_FIXEDPITCHONLY; + cf.Flags |= CF_NOSIMULATIONS; - if (ChooseFont(&cf)) { - if (pScr->hSelectedFont) - DeleteObject(pScr->hSelectedFont); + if (ChooseFont(&cf)) { + if (pScr->hSelectedFont) + DeleteObject(pScr->hSelectedFont); - pScr->hSelectedFont = CreateFontIndirect(&(pScr->lf)); - pScr->lf.lfUnderline = TRUE; - pScr->hSelectedULFont = CreateFontIndirect(&(pScr->lf)); - pScr->lf.lfUnderline = FALSE; - hDC = GetDC(hWnd); - SelectObject(hDC, pScr->hSelectedFont); - GetTextMetrics(hDC, &tm); - pScr->cxChar = tm.tmAveCharWidth; - pScr->cyChar = tm.tmHeight + tm.tmExternalLeading; - ReleaseDC(hWnd, hDC); - SetWindowPos(hWnd, NULL, 0, 0, pScr->cxChar * pScr->width + - FRAME_WIDTH, pScr->cyChar * pScr->height + - FRAME_HEIGHT, SWP_NOMOVE | SWP_NOZORDER); + pScr->hSelectedFont = CreateFontIndirect(&(pScr->lf)); + pScr->lf.lfUnderline = TRUE; + pScr->hSelectedULFont = CreateFontIndirect(&(pScr->lf)); + pScr->lf.lfUnderline = FALSE; + hDC = GetDC(hWnd); + SelectObject(hDC, pScr->hSelectedFont); + GetTextMetrics(hDC, &tm); + pScr->cxChar = tm.tmAveCharWidth; + pScr->cyChar = tm.tmHeight + tm.tmExternalLeading; + ReleaseDC(hWnd, hDC); + SetWindowPos(hWnd, NULL, 0, 0, pScr->cxChar * pScr->width + + FRAME_WIDTH, pScr->cyChar * pScr->height + + FRAME_HEIGHT, SWP_NOMOVE | SWP_NOZORDER); - dwFontColor = RGB(255, 255, 255); - InvalidateRect(hWnd, NULL, TRUE); - } + dwFontColor = RGB(255, 255, 255); + InvalidateRect(hWnd, NULL, TRUE); + } - WritePrivateProfileString(INI_FONT, "FaceName", pScr->lf.lfFaceName, TELNET_INI); - wsprintf(buf, "%d", (int) pScr->lf.lfHeight); - WritePrivateProfileString(INI_FONT, "Height", buf, TELNET_INI); - wsprintf(buf, "%d", (int) pScr->lf.lfWidth); - WritePrivateProfileString(INI_FONT, "Width", buf, TELNET_INI); - wsprintf(buf, "%d", (int) pScr->lf.lfEscapement); - WritePrivateProfileString(INI_FONT, "Escapement", buf, TELNET_INI); - wsprintf(buf, "%d", (int) pScr->lf.lfCharSet); - WritePrivateProfileString(INI_FONT, "CharSet", buf, TELNET_INI); - wsprintf(buf, "%d", (int) pScr->lf.lfPitchAndFamily); - WritePrivateProfileString(INI_FONT, "PitchAndFamily", buf, TELNET_INI); + WritePrivateProfileString(INI_FONT, "FaceName", pScr->lf.lfFaceName, TELNET_INI); + wsprintf(buf, "%d", (int) pScr->lf.lfHeight); + WritePrivateProfileString(INI_FONT, "Height", buf, TELNET_INI); + wsprintf(buf, "%d", (int) pScr->lf.lfWidth); + WritePrivateProfileString(INI_FONT, "Width", buf, TELNET_INI); + wsprintf(buf, "%d", (int) pScr->lf.lfEscapement); + WritePrivateProfileString(INI_FONT, "Escapement", buf, TELNET_INI); + wsprintf(buf, "%d", (int) pScr->lf.lfCharSet); + WritePrivateProfileString(INI_FONT, "CharSet", buf, TELNET_INI); + wsprintf(buf, "%d", (int) pScr->lf.lfPitchAndFamily); + WritePrivateProfileString(INI_FONT, "PitchAndFamily", buf, TELNET_INI); - return; + return; } /* ProcessFontChange */ void NEAR InitializeStruct( - WORD wCommDlgType, - LPSTR lpStruct, - HWND hWnd) + WORD wCommDlgType, + LPSTR lpStruct, + HWND hWnd) { - LPCHOOSEFONT lpFontChunk; + LPCHOOSEFONT lpFontChunk; - if (wCommDlgType == IDC_FONT) { - lpFontChunk = (LPCHOOSEFONT) lpStruct; + if (wCommDlgType == IDC_FONT) { + lpFontChunk = (LPCHOOSEFONT) lpStruct; - lpFontChunk->lStructSize = sizeof(CHOOSEFONT); - lpFontChunk->hwndOwner = hWnd; - lpFontChunk->Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_INITTOLOGFONTSTRUCT | CF_APPLY; - lpFontChunk->rgbColors = RGB(0, 0, 255); - lpFontChunk->lCustData = 0L; - lpFontChunk->lpfnHook = NULL; - lpFontChunk->lpTemplateName = NULL; - lpFontChunk->hInstance = NULL; - lpFontChunk->lpszStyle = NULL; - lpFontChunk->nFontType = SCREEN_FONTTYPE; - lpFontChunk->nSizeMin = 0; - lpFontChunk->nSizeMax = 0; - } + lpFontChunk->lStructSize = sizeof(CHOOSEFONT); + lpFontChunk->hwndOwner = hWnd; + lpFontChunk->Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY + | CF_INITTOLOGFONTSTRUCT | CF_APPLY; + lpFontChunk->rgbColors = RGB(0, 0, 255); + lpFontChunk->lCustData = 0L; + lpFontChunk->lpfnHook = NULL; + lpFontChunk->lpTemplateName = NULL; + lpFontChunk->hInstance = NULL; + lpFontChunk->lpszStyle = NULL; + lpFontChunk->nFontType = SCREEN_FONTTYPE; + lpFontChunk->nSizeMin = 0; + lpFontChunk->nSizeMax = 0; + } } /* InitialiseStruct */ diff --git a/src/windows/wintel/genget.c b/src/windows/wintel/genget.c new file mode 100644 index 000000000..4e760d72e --- /dev/null +++ b/src/windows/wintel/genget.c @@ -0,0 +1,101 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* based on @(#)genget.c 8.1 (Berkeley) 6/4/93 */ + +#include + +#define LOWER(x) (isupper(x) ? tolower(x) : (x)) +/* + * The prefix function returns 0 if *s1 is not a prefix + * of *s2. If *s1 exactly matches *s2, the negative of + * the length is returned. If *s1 is a prefix of *s2, + * the length of *s1 is returned. + */ + int +isprefix(s1, s2) + register char *s1, *s2; +{ + char *os1; + register char c1, c2; + + if (*s1 == '\0') + return(-1); + os1 = s1; + c1 = *s1; + c2 = *s2; + while (LOWER(c1) == LOWER(c2)) { + if (c1 == '\0') + break; + c1 = *++s1; + c2 = *++s2; + } + return(*s1 ? 0 : (*s2 ? (s1 - os1) : (os1 - s1))); +} + +static char *ambiguous; /* special return value for command routines */ + + char ** +genget(name, table, stlen) + char *name; /* name to match */ + char **table; /* name entry in table */ + int stlen; +{ + register char **c, **found; + register int n; + + if (name == 0) + return 0; + + found = 0; + for (c = table; *c != 0; c = (char **)((char *)c + stlen)) { + if ((n = isprefix(name, *c)) == 0) + continue; + if (n < 0) /* exact match */ + return(c); + if (found) + return(&ambiguous); + found = c; + } + return(found); +} + +/* + * Function call version of Ambiguous() + */ + int +Ambiguous(s) + char *s; +{ + return((char **)s == &ambiguous); +} diff --git a/src/windows/wintel/ini.h b/src/windows/wintel/ini.h index d391c8a86..f26c162e3 100644 --- a/src/windows/wintel/ini.h +++ b/src/windows/wintel/ini.h @@ -1,16 +1,16 @@ /* Defines INI file vocabulary */ #define TELNET_INI "kerberos.ini" - #define INI_TELNET "Telnet" - #define INI_FONT "Font" - #define INI_WIDTH "Width" - #define INI_HEIGHT "Height" - #define INI_POSITION "Position" - #define INI_BACKSPACE "Backspace" - #define INI_BACKSPACE_BS "BS" - #define INI_BACKSPACE_DEL "DEL" +#define INI_TELNET "Telnet" +#define INI_FONT "Font" +#define INI_WIDTH "Width" +#define INI_HEIGHT "Height" +#define INI_POSITION "Position" +#define INI_BACKSPACE "Backspace" +#define INI_BACKSPACE_BS "BS" +#define INI_BACKSPACE_DEL "DEL" - #define INI_HOSTS "Telnet Hosts" - #define INI_HOST "Host" - #define INI_HOST_BS "BS" - #define INI_HOST_DEL "DEL" +#define INI_HOSTS "Telnet Hosts" +#define INI_HOST "Host" +#define INI_HOST_BS "BS" +#define INI_HOST_DEL "DEL" diff --git a/src/windows/wintel/intern.c b/src/windows/wintel/intern.c index 426de2f82..176cbedcd 100644 --- a/src/windows/wintel/intern.c +++ b/src/windows/wintel/intern.c @@ -7,859 +7,808 @@ #define ScreenClearAttrib 0 -SCREENLINE *GetScreenLineFromY( - SCREEN *pScr, - int y) +SCREENLINE * +GetScreenLineFromY(SCREEN *pScr, int y) { - SCREENLINE *pScrLine; - int idx; + SCREENLINE *pScrLine; + int idx; - pScrLine = pScr->screen_top; - for (idx = 0; idx < pScr->height; idx++) { - if (idx == y) - return(pScrLine); - if (pScrLine == NULL) - return(NULL); - pScrLine = pScrLine->next; - } + pScrLine = pScr->screen_top; + for (idx = 0; idx < pScr->height; idx++) { + if (idx == y) + return(pScrLine); + if (pScrLine == NULL) + return(NULL); + pScrLine = pScrLine->next; + } - return(NULL); + return(NULL); +} -} /* GetScreenLineFromY */ - -SCREENLINE *ScreenClearLine( - SCREEN *pScr, - SCREENLINE *pScrLine) +SCREENLINE * +ScreenClearLine(SCREEN *pScr, SCREENLINE *pScrLine) { - memset(pScrLine->attrib, ScreenClearAttrib, pScr->width); - memset(pScrLine->text, ' ', pScr->width); - return(pScrLine); - -} /* ScreenClearLine */ + memset(pScrLine->attrib, ScreenClearAttrib, pScr->width); + memset(pScrLine->text, ' ', pScr->width); + return(pScrLine); +} -void ScreenUnscroll( - SCREEN *pScr) +void +ScreenUnscroll(SCREEN *pScr) { - int idx; - SCREENLINE *pScrLine; - - if (pScr->screen_bottom == pScr->buffer_bottom) - return; + int idx; + SCREENLINE *pScrLine; - pScr->screen_bottom = pScr->buffer_bottom; - pScrLine = pScr->screen_bottom; - for (idx = 1; idx < pScr->height; idx++) { - if (pScrLine == NULL) - return; - pScrLine = pScrLine->prev; - } - pScr->screen_top = pScrLine; + if (pScr->screen_bottom == pScr->buffer_bottom) + return; -} /* ScreenUnscroll */ + pScr->screen_bottom = pScr->buffer_bottom; + pScrLine = pScr->screen_bottom; + for (idx = 1; idx < pScr->height; idx++) { + if (pScrLine == NULL) + return; + pScrLine = pScrLine->prev; + } + pScr->screen_top = pScrLine; +} -void ScreenCursorOn( - SCREEN *pScr) +void +ScreenCursorOn(SCREEN *pScr) { - int y; - int nlines; + int y; + int nlines; - if (pScr->screen_bottom != pScr->buffer_bottom) - nlines = pScr->numlines - GetScrollPos(pScr->hWnd, SB_VERT); - else - nlines = 0; + if (pScr->screen_bottom != pScr->buffer_bottom) + nlines = pScr->numlines - GetScrollPos(pScr->hWnd, SB_VERT); + else + nlines = 0; - y = pScr->y + nlines; - SetCaretPos(pScr->x * pScr->cxChar, (y+1) * pScr->cyChar); - ShowCaret(pScr->hWnd); + y = pScr->y + nlines; + SetCaretPos(pScr->x * pScr->cxChar, (y+1) * pScr->cyChar); + ShowCaret(pScr->hWnd); +} -} /* ScreenCursorOn */ - -void ScreenCursorOff( - SCREEN *pScr) +void +ScreenCursorOff(SCREEN *pScr) { - HideCaret(pScr->hWnd); - -} /* ScreenCursorOff */ + HideCaret(pScr->hWnd); +} -void ScreenELO( - SCREEN *pScr, - int s) +void +ScreenELO(SCREEN *pScr, int s) { - SCREENLINE *pScrLine; - RECT rc; + SCREENLINE *pScrLine; + RECT rc; - if (s < 0) - s = pScr->y; + if (s < 0) + s = pScr->y; - pScrLine = GetScreenLineFromY(pScr,s); - memset(pScrLine->attrib, ScreenClearAttrib, pScr->width); - memset(pScrLine->text, ' ', pScr->width); - rc.left = 0; - rc.right = pScr->width * pScr->cxChar; - rc.top = pScr->cyChar * s; - rc.bottom = pScr->cyChar * (s+1); - InvalidateRect(pScr->hWnd, &rc, TRUE); - -} /* ScreenELO */ - -void ScreenEraseScreen( - SCREEN *pScr) -{ - int i; - int x1 = 0; - int y1 = 0; - int x2 = pScr->width; - int y2 = pScr->height; - int n = -1; + pScrLine = GetScreenLineFromY(pScr,s); + memset(pScrLine->attrib, ScreenClearAttrib, pScr->width); + memset(pScrLine->text, ' ', pScr->width); + rc.left = 0; + rc.right = pScr->width * pScr->cxChar; + rc.top = pScr->cyChar * s; + rc.bottom = pScr->cyChar * (s+1); + InvalidateRect(pScr->hWnd, &rc, TRUE); +} + +void +ScreenEraseScreen(SCREEN *pScr) +{ + int i; + int x1 = 0; + int y1 = 0; + int x2 = pScr->width; + int y2 = pScr->height; + int n = -1; - for(i = 0; i < pScr->height; i++) - ScreenELO(pScr,i); + for(i = 0; i < pScr->height; i++) + ScreenELO(pScr,i); - InvalidateRect(pScr->hWnd, NULL, TRUE); - UpdateWindow(pScr->hWnd); + InvalidateRect(pScr->hWnd, NULL, TRUE); + UpdateWindow(pScr->hWnd); +} -} /* ScreenEraseScreen */ - -void ScreenTabClear( - SCREEN *pScr) +void +ScreenTabClear(SCREEN *pScr) { - int x = 0; - - while(x <= pScr->width) { - pScr->tabs[x] = ' '; - x++; - } + int x = 0; -} /* ScreenTabClear */ + while(x <= pScr->width) { + pScr->tabs[x] = ' '; + x++; + } +} -void ScreenTabInit( - SCREEN *pScr) +void +ScreenTabInit(SCREEN *pScr) { - int x = 0; - - ScreenTabClear(pScr); + int x = 0; - while(x <= pScr->width) { - pScr->tabs[x] = 'x'; - x += 8; - } - pScr->tabs[pScr->width] = 'x'; + ScreenTabClear(pScr); -} /* ScreenTabInit */ + while(x <= pScr->width) { + pScr->tabs[x] = 'x'; + x += 8; + } + pScr->tabs[pScr->width] = 'x'; +} -void ScreenReset( - SCREEN *pScr) +void +ScreenReset(SCREEN *pScr) { - pScr->top = 0; - pScr->bottom = pScr->height-1; - pScr->parmptr = 0; - pScr->escflg = 0; - pScr->DECAWM = 1; - pScr->bWrapPending = FALSE; - pScr->DECCKM = 0; - pScr->DECPAM = 0; -/* pScr->DECORG = 0; */ -/* pScr->Pattrib = -1; */ - pScr->IRM = 0; - pScr->attrib = 0; - pScr->x = 0; - pScr->y = 0; -// pScr->charset = 0; - ScreenEraseScreen(pScr); - ScreenTabInit(pScr); -// set_vtwrap(pScrn, pScr->DECAWM); /* QAK - 7/27/90: added because resetting the virtual screen's wrapping flag doesn't reset telnet window's wrapping */ - -} /* ScreenReset */ + pScr->top = 0; + pScr->bottom = pScr->height-1; + pScr->parmptr = 0; + pScr->escflg = 0; + pScr->DECAWM = 1; + pScr->bWrapPending = FALSE; + pScr->DECCKM = 0; + pScr->DECPAM = 0; + /* pScr->DECORG = 0; */ + /* pScr->Pattrib = -1; */ + pScr->IRM = 0; + pScr->attrib = 0; + pScr->x = 0; + pScr->y = 0; + /* pScr->charset = 0; */ + ScreenEraseScreen(pScr); + ScreenTabInit(pScr); +#if 0 + /* + * QAK - 7/27/90: added because resetting the virtual screen's + * wrapping flag doesn't reset telnet window's wrapping + */ + set_vtwrap(pScrn, pScr->DECAWM); +#endif +} -void ScreenListMove( - SCREENLINE *TD, - SCREENLINE *BD, - SCREENLINE *TI, - SCREENLINE *BI) +void +ScreenListMove(SCREENLINE *TD, SCREENLINE *BD, SCREENLINE *TI, SCREENLINE *BI) { - if (TD->prev != NULL) - TD->prev->next = BD->next; /* Maintain circularity */ + if (TD->prev != NULL) + TD->prev->next = BD->next; /* Maintain circularity */ - if (BD->next != NULL) - BD->next->prev = TD->prev; + if (BD->next != NULL) + BD->next->prev = TD->prev; - TD->prev = TI; /* Place the node in its new home */ - BD->next = BI; + TD->prev = TI; /* Place the node in its new home */ + BD->next = BI; - if (TI != NULL) - TI->next = TD; /* Ditto prev->prev */ + if (TI != NULL) + TI->next = TD; /* Ditto prev->prev */ - if (BI != NULL) - BI->prev = BD; + if (BI != NULL) + BI->prev = BD; +} -} /* ScreenListMove */ - -void ScreenDelLines( - SCREEN *pScr, - int n, - int s) +void +ScreenDelLines(SCREEN *pScr, int n, int s) { - SCREENLINE *BI; - SCREENLINE *TI; - SCREENLINE *TD; - SCREENLINE *BD; - SCREENLINE *pLine; - int idx; - RECT rc; - HDC hDC; + SCREENLINE *BI; + SCREENLINE *TI; + SCREENLINE *TD; + SCREENLINE *BD; + SCREENLINE *pLine; + int idx; + RECT rc; + HDC hDC; - pScr->bWrapPending = FALSE; - - if (s < 0) - s = pScr->y; - - if (s + n - 1 > pScr->bottom) - n = pScr->bottom - s + 1; - - TD = GetScreenLineFromY(pScr, s); - BD = GetScreenLineFromY(pScr, s + n - 1); - TI = GetScreenLineFromY(pScr, pScr->bottom); - BI = TI->next; - - /* - Adjust the top of the screen and buffer if they will move. - */ - if (TD == pScr->screen_top) { - if (pScr->screen_top == pScr->buffer_top) - pScr->buffer_top = BD->next; - pScr->screen_top = BD->next; - } - - /* - Adjust the bottom of the screen and buffer if they will move. - */ - if (TI == pScr->screen_bottom) { - if (pScr->screen_bottom == pScr->buffer_bottom) - pScr->buffer_bottom = BD; - pScr->screen_bottom = BD; - } - - if (TI != BD) - ScreenListMove(TD, BD, TI, BI); - - /* - Clear the lines moved from the deleted area to the - bottom of the scrolling area. - */ - pLine = TI; - - for (idx = 0; idx < n; idx++) { - pLine = pLine->next; - ScreenClearLine(pScr, pLine); - } - -// CheckScreen(pScr); - - /* - Scroll the affected area on the screen. - */ - rc.left = 0; - rc.right = pScr->width * pScr->cxChar; - rc.top = s * pScr->cyChar; - rc.bottom = (pScr->bottom + 1) * pScr->cyChar; - - hDC = GetDC(pScr->hWnd); - - ScrollDC(hDC, 0, -pScr->cyChar * n, &rc, &rc, NULL, NULL); - - PatBlt(hDC, 0, (pScr->bottom - n + 1) * pScr->cyChar, - pScr->width * pScr->cxChar, n * pScr->cyChar, WHITENESS); - - ReleaseDC(pScr->hWnd, hDC); - -} /* ScreenDelLines */ - - -void ScreenInsertLine( - SCREEN *pScr, - int s) + pScr->bWrapPending = FALSE; + + if (s < 0) + s = pScr->y; + + if (s + n - 1 > pScr->bottom) + n = pScr->bottom - s + 1; + + TD = GetScreenLineFromY(pScr, s); + BD = GetScreenLineFromY(pScr, s + n - 1); + TI = GetScreenLineFromY(pScr, pScr->bottom); + BI = TI->next; + + /* + * Adjust the top of the screen and buffer if they will move. + */ + if (TD == pScr->screen_top) { + if (pScr->screen_top == pScr->buffer_top) + pScr->buffer_top = BD->next; + pScr->screen_top = BD->next; + } + + /* + * Adjust the bottom of the screen and buffer if they will move. + */ + if (TI == pScr->screen_bottom) { + if (pScr->screen_bottom == pScr->buffer_bottom) + pScr->buffer_bottom = BD; + pScr->screen_bottom = BD; + } + + if (TI != BD) + ScreenListMove(TD, BD, TI, BI); + + /* + * Clear the lines moved from the deleted area to the + * bottom of the scrolling area. + */ + pLine = TI; + + for (idx = 0; idx < n; idx++) { + pLine = pLine->next; + ScreenClearLine(pScr, pLine); + } + + /* CheckScreen(pScr); */ + + /* + * Scroll the affected area on the screen. + */ + rc.left = 0; + rc.right = pScr->width * pScr->cxChar; + rc.top = s * pScr->cyChar; + rc.bottom = (pScr->bottom + 1) * pScr->cyChar; + + hDC = GetDC(pScr->hWnd); + + ScrollDC(hDC, 0, -pScr->cyChar * n, &rc, &rc, NULL, NULL); + + PatBlt(hDC, 0, (pScr->bottom - n + 1) * pScr->cyChar, + pScr->width * pScr->cxChar, n * pScr->cyChar, WHITENESS); + + ReleaseDC(pScr->hWnd, hDC); +} + + +void +ScreenInsertLine(SCREEN *pScr, int s) { - ScreenInsLines(pScr, 1, s); - -} /* ScreenInsertLine */ + ScreenInsLines(pScr, 1, s); +} -void ScreenInsLines( - SCREEN *pScr, - int n, - int s) +void +ScreenInsLines(SCREEN *pScr, int n, int s) { - SCREENLINE *TI; - SCREENLINE *BI; - SCREENLINE *TD; - SCREENLINE *BD; - SCREENLINE *pLine; - int idx; - RECT rc; - HDC hDC; + SCREENLINE *TI; + SCREENLINE *BI; + SCREENLINE *TD; + SCREENLINE *BD; + SCREENLINE *pLine; + int idx; + RECT rc; + HDC hDC; - pScr->bWrapPending = FALSE; - - if (s < 0) - s = pScr->y; - - if (s + n - 1 > pScr->bottom) - n = pScr->bottom - s + 1; - - /* - Determine the top and bottom of the insert area. Also determine - the top and bottom of the area to be deleted and moved to the - insert area. - */ - BI = GetScreenLineFromY(pScr, s); - TI = BI->prev; - TD = GetScreenLineFromY(pScr, pScr->bottom - n + 1); - BD = GetScreenLineFromY(pScr, pScr->bottom); - - /* - Adjust the top of the screen and buffer if they will move. - */ - if (BI == pScr->screen_top) { - if (pScr->screen_top == pScr->buffer_top) - pScr->buffer_top = TD; - pScr->screen_top = TD; - } - - /* - Adjust the bottom of the screen and buffer if they will move. - */ - if (BD == pScr->screen_bottom) { - if (pScr->screen_bottom == pScr->buffer_bottom) - pScr->buffer_bottom = TD->prev; - pScr->screen_bottom = TD->prev; - } - - /* - Move lines from the bottom of the scrolling region to the insert area. - */ - if (TD != BI) - ScreenListMove(TD,BD,TI,BI); - - /* - Clear the inserted lines - */ - pLine = GetScreenLineFromY(pScr, s); - - for (idx = 0; idx < n; idx++) { - ScreenClearLine(pScr, pLine); - pLine = pLine->next; - } - -// CheckScreen(pScr); - - /* - Scroll the affected area on the screen. - */ - rc.left = 0; - rc.right = pScr->width * pScr->cxChar; - rc.top = s * pScr->cyChar; - rc.bottom = (pScr->bottom + 1) * pScr->cyChar; - - hDC = GetDC(pScr->hWnd); - - ScrollDC(hDC, 0, pScr->cyChar * n, &rc, &rc, NULL, NULL); - - PatBlt(hDC, 0, s * pScr->cyChar, - pScr->width * pScr->cxChar, n * pScr->cyChar, WHITENESS); - - ReleaseDC(pScr->hWnd, hDC); - -} /* ScreenInsLines */ - - -void ScreenIndex( - SCREEN * pScr) + pScr->bWrapPending = FALSE; + + if (s < 0) + s = pScr->y; + + if (s + n - 1 > pScr->bottom) + n = pScr->bottom - s + 1; + + /* + * Determine the top and bottom of the insert area. Also determine + * the top and bottom of the area to be deleted and moved to the + * insert area. + */ + BI = GetScreenLineFromY(pScr, s); + TI = BI->prev; + TD = GetScreenLineFromY(pScr, pScr->bottom - n + 1); + BD = GetScreenLineFromY(pScr, pScr->bottom); + + /* + * Adjust the top of the screen and buffer if they will move. + */ + if (BI == pScr->screen_top) { + if (pScr->screen_top == pScr->buffer_top) + pScr->buffer_top = TD; + pScr->screen_top = TD; + } + + /* + * Adjust the bottom of the screen and buffer if they will move. + */ + if (BD == pScr->screen_bottom) { + if (pScr->screen_bottom == pScr->buffer_bottom) + pScr->buffer_bottom = TD->prev; + pScr->screen_bottom = TD->prev; + } + + /* + * Move lines from the bottom of the scrolling region to the insert area. + */ + if (TD != BI) + ScreenListMove(TD,BD,TI,BI); + + /* + * Clear the inserted lines + */ + pLine = GetScreenLineFromY(pScr, s); + + for (idx = 0; idx < n; idx++) { + ScreenClearLine(pScr, pLine); + pLine = pLine->next; + } + + /* CheckScreen(pScr); */ + + /* + * Scroll the affected area on the screen. + */ + rc.left = 0; + rc.right = pScr->width * pScr->cxChar; + rc.top = s * pScr->cyChar; + rc.bottom = (pScr->bottom + 1) * pScr->cyChar; + + hDC = GetDC(pScr->hWnd); + + ScrollDC(hDC, 0, pScr->cyChar * n, &rc, &rc, NULL, NULL); + + PatBlt(hDC, 0, s * pScr->cyChar, + pScr->width * pScr->cxChar, n * pScr->cyChar, WHITENESS); + + ReleaseDC(pScr->hWnd, hDC); +} + + +void +ScreenIndex(SCREEN * pScr) { - if (pScr->y >= pScr->bottom) - ScreenScroll(pScr); - else - pScr->y++; - - pScr->bWrapPending = FALSE; + if (pScr->y >= pScr->bottom) + ScreenScroll(pScr); + else + pScr->y++; -} /* ScreenIndex */ + pScr->bWrapPending = FALSE; +} -void ScreenWrapNow( - SCREEN *pScr, - int *xp, - int *yp) +void +ScreenWrapNow(SCREEN *pScr, int *xp, int *yp) { - if (pScr->bWrapPending && pScr->x >= pScr->width - 1) { - pScr->x = 0; - ScreenIndex(pScr); - } - - pScr->bWrapPending = FALSE; + if (pScr->bWrapPending && pScr->x >= pScr->width - 1) { + pScr->x = 0; + ScreenIndex(pScr); + } - *xp = pScr->x; - *yp = pScr->y; + pScr->bWrapPending = FALSE; -} /* ScreenWrapNow */ + *xp = pScr->x; + *yp = pScr->y; +} -void ScreenEraseToEOL( - SCREEN *pScr) +void +ScreenEraseToEOL(SCREEN *pScr) { - int x1 = pScr->x; - int y1 = pScr->y; - int x2 = pScr->width; - int y2 = pScr->y; - int n = -1; - SCREENLINE *pScrLine; - RECT rc; + int x1 = pScr->x; + int y1 = pScr->y; + int x2 = pScr->width; + int y2 = pScr->y; + int n = -1; + SCREENLINE *pScrLine; + RECT rc; - ScreenWrapNow(pScr, &x1, &y1); - - y2 = y1; -// wsprintf(strTmp,"[EraseEOL:%d]",y2); -// OutputDebugString(strTmp); - pScrLine = GetScreenLineFromY(pScr,y2); - memset(&pScrLine->attrib[x1], ScreenClearAttrib, pScr->width-x1+1); - memset(&pScrLine->text[x1], ' ', pScr->width - x1 + 1); - rc.left = x1 * pScr->cxChar; - rc.right = pScr->width * pScr->cxChar; - rc.top = pScr->cyChar * y1; - rc.bottom = pScr->cyChar * (y1 + 1); - InvalidateRect(pScr->hWnd, &rc, TRUE); - UpdateWindow(pScr->hWnd); - -} /* ScreenEraseToEOL */ - - -void ScreenDelChars( - SCREEN *pScr, - int n) -{ - int x = pScr->x; - int y = pScr->y; - int width; - SCREENLINE *pScrLine; - RECT rc; + ScreenWrapNow(pScr, &x1, &y1); + + y2 = y1; +#if 0 + wsprintf(strTmp,"[EraseEOL:%d]",y2); + OutputDebugString(strTmp); +#endif + pScrLine = GetScreenLineFromY(pScr,y2); + memset(&pScrLine->attrib[x1], ScreenClearAttrib, pScr->width-x1+1); + memset(&pScrLine->text[x1], ' ', pScr->width - x1 + 1); + rc.left = x1 * pScr->cxChar; + rc.right = pScr->width * pScr->cxChar; + rc.top = pScr->cyChar * y1; + rc.bottom = pScr->cyChar * (y1 + 1); + InvalidateRect(pScr->hWnd, &rc, TRUE); + UpdateWindow(pScr->hWnd); +} + + +void +ScreenDelChars(SCREEN *pScr, int n) +{ + int x = pScr->x; + int y = pScr->y; + int width; + SCREENLINE *pScrLine; + RECT rc; - pScr->bWrapPending = FALSE; + pScr->bWrapPending = FALSE; - pScrLine = GetScreenLineFromY(pScr, y); + pScrLine = GetScreenLineFromY(pScr, y); - width = pScr->width - x - n; + width = pScr->width - x - n; - if (width > 0) { - memmove(&pScrLine->attrib[x], &pScrLine->attrib[x + n], width); - memmove(&pScrLine->text[x], &pScrLine->text[x + n], width); - } + if (width > 0) { + memmove(&pScrLine->attrib[x], &pScrLine->attrib[x + n], width); + memmove(&pScrLine->text[x], &pScrLine->text[x + n], width); + } - memset(&pScrLine->attrib[pScr->width - n], ScreenClearAttrib, n); - memset(&pScrLine->text[pScr->width - n], ' ', n); + memset(&pScrLine->attrib[pScr->width - n], ScreenClearAttrib, n); + memset(&pScrLine->text[pScr->width - n], ' ', n); - rc.left = x * pScr->cxChar; - rc.right = pScr->width * pScr->cxChar; - rc.top = pScr->cyChar * y; - rc.bottom = pScr->cyChar * (y + 1); + rc.left = x * pScr->cxChar; + rc.right = pScr->width * pScr->cxChar; + rc.top = pScr->cyChar * y; + rc.bottom = pScr->cyChar * (y + 1); - InvalidateRect(pScr->hWnd, &rc, TRUE); + InvalidateRect(pScr->hWnd, &rc, TRUE); - UpdateWindow(pScr->hWnd); + UpdateWindow(pScr->hWnd); +} -} /* ScreenDelChars */ - -void ScreenRevIndex( - SCREEN *pScr) +void +ScreenRevIndex(SCREEN *pScr) { - SCREENLINE *pScrLine; - SCREENLINE *pTopLine; + SCREENLINE *pScrLine; + SCREENLINE *pTopLine; - pScr->bWrapPending = FALSE; - pScrLine = GetScreenLineFromY(pScr, pScr->y); - pTopLine = GetScreenLineFromY(pScr, pScr->top); - - if(pScrLine == pTopLine) - ScreenInsertLine(pScr, pScr->y); - else - pScr->y--; + pScr->bWrapPending = FALSE; + pScrLine = GetScreenLineFromY(pScr, pScr->y); + pTopLine = GetScreenLineFromY(pScr, pScr->top); -} /* ScreenRevIndex */ + if(pScrLine == pTopLine) + ScreenInsertLine(pScr, pScr->y); + else + pScr->y--; +} -void ScreenEraseToBOL( - SCREEN *pScr) +void +ScreenEraseToBOL(SCREEN *pScr) { - int x1 = 0; - int y1 = pScr->y; - int x2 = pScr->x; - int y2 = pScr->y; - int n = -1; - SCREENLINE *pScrLine; + int x1 = 0; + int y1 = pScr->y; + int x2 = pScr->x; + int y2 = pScr->y; + int n = -1; + SCREENLINE *pScrLine; - pScrLine = GetScreenLineFromY(pScr, pScr->y); + pScrLine = GetScreenLineFromY(pScr, pScr->y); - ScreenWrapNow(pScr, &x2, &y1); - y2 = y1; - memset(pScrLine->attrib, ScreenClearAttrib, x2); - memset(pScrLine->text, ' ', x2); + ScreenWrapNow(pScr, &x2, &y1); + y2 = y1; + memset(pScrLine->attrib, ScreenClearAttrib, x2); + memset(pScrLine->text, ' ', x2); +} -} /* ScreenEraseToBOL */ - -void ScreenEraseLine( - SCREEN *pScr, - int s) +void +ScreenEraseLine(SCREEN *pScr, int s) { - int x1 = 0; - int y1 = s; - int x2 = pScr->width; - int y2 = s; - int n = -1; - SCREENLINE *pScrLine; - RECT rc; + int x1 = 0; + int y1 = s; + int x2 = pScr->width; + int y2 = s; + int n = -1; + SCREENLINE *pScrLine; + RECT rc; - if (s < 0) { - ScreenWrapNow(pScr, &x1, &y1); - s = y2 = y1; - x1 = 0; - } - - pScrLine = GetScreenLineFromY(pScr,y1); - memset(pScrLine->attrib, ScreenClearAttrib, pScr->width); - memset(pScrLine->text, ' ', pScr->width); - rc.left = 0; - rc.right = pScr->width * pScr->cxChar; - rc.top = pScr->cyChar * y1; - rc.bottom = pScr->cyChar * (y1+1); - InvalidateRect(pScr->hWnd, &rc, TRUE); - SendMessage(pScr->hWnd, WM_PAINT, NULL, NULL); - -} /* ScreenEraseLine */ - - -void ScreenEraseToEndOfScreen( - SCREEN *pScr) + if (s < 0) { + ScreenWrapNow(pScr, &x1, &y1); + s = y2 = y1; + x1 = 0; + } + + pScrLine = GetScreenLineFromY(pScr,y1); + memset(pScrLine->attrib, ScreenClearAttrib, pScr->width); + memset(pScrLine->text, ' ', pScr->width); + rc.left = 0; + rc.right = pScr->width * pScr->cxChar; + rc.top = pScr->cyChar * y1; + rc.bottom = pScr->cyChar * (y1+1); + InvalidateRect(pScr->hWnd, &rc, TRUE); + SendMessage(pScr->hWnd, WM_PAINT, 0, 0); +} + + +void +ScreenEraseToEndOfScreen(SCREEN *pScr) { - int i; - int x1 = 0; - int y1 = pScr->y+1; - int x2 = pScr->width; - int y2 = pScr->height; - int n = -1; - - ScreenWrapNow(pScr, &x1, &y1); - y1++; - x1 = 0; - i = y1; - ScreenEraseToEOL(pScr); - while (i < pScr->height) { - ScreenELO(pScr, i); - ScreenEraseLine(pScr, i); - i++; - } - -} /* ScreenEraseToEndOfScreen */ - - -void ScreenRange( - SCREEN *pScr) + int i; + int x1 = 0; + int y1 = pScr->y+1; + int x2 = pScr->width; + int y2 = pScr->height; + int n = -1; + + ScreenWrapNow(pScr, &x1, &y1); + y1++; + x1 = 0; + i = y1; + ScreenEraseToEOL(pScr); + while (i < pScr->height) { + ScreenELO(pScr, i); + ScreenEraseLine(pScr, i); + i++; + } +} + + +void +ScreenRange(SCREEN *pScr) { - if (pScr->x < 0) - pScr->x = 0; + if (pScr->x < 0) + pScr->x = 0; - if (pScr->x >= pScr->width) - pScr->x = pScr->width - 1; + if (pScr->x >= pScr->width) + pScr->x = pScr->width - 1; - if (pScr->y < 0) - pScr->y = 0; + if (pScr->y < 0) + pScr->y = 0; - if (pScr->y >= pScr->height) - pScr->y = pScr->height - 1; + if (pScr->y >= pScr->height) + pScr->y = pScr->height - 1; +} -} /* ScreenRange */ - -void ScreenAlign( - SCREEN *pScr) /* vt100 alignment, fill screen with 'E's */ +void +ScreenAlign(SCREEN *pScr) /* vt100 alignment, fill screen with 'E's */ { - char *tt; - int i; - int j; - SCREENLINE *pScrLine; + char *tt; + int i; + int j; + SCREENLINE *pScrLine; - pScrLine = GetScreenLineFromY(pScr, pScr->top); - ScreenEraseScreen(pScr); - - for(j = 0; j < pScr->height; j++) { - tt = &pScrLine->text[0]; - for(i = 0; i <= pScr->width; i++) - *tt++ = 'E'; - pScrLine = pScrLine->next; - } + pScrLine = GetScreenLineFromY(pScr, pScr->top); + ScreenEraseScreen(pScr); -} /* ScreenAlign */ + for(j = 0; j < pScr->height; j++) { + tt = &pScrLine->text[0]; + for(i = 0; i <= pScr->width; i++) + *tt++ = 'E'; + pScrLine = pScrLine->next; + } +} -void ScreenApClear( - SCREEN *pScr) +void +ScreenApClear(SCREEN *pScr) { - /* - reset all the ANSI parameters back to the default state - */ - for(pScr->parmptr=5; pScr->parmptr>=0; pScr->parmptr--) - pScr->parms[pScr->parmptr] = -1; + /* + * reset all the ANSI parameters back to the default state + */ + for(pScr->parmptr=5; pScr->parmptr>=0; pScr->parmptr--) + pScr->parms[pScr->parmptr] = -1; - pScr->parmptr = 0; + pScr->parmptr = 0; +} -} /* ScreenApClear */ - -void ScreenSetOption( - SCREEN *pScr, - int toggle) +void +ScreenSetOption(SCREEN *pScr, int toggle) { - if (pScr->parms[0] == -2 && pScr->parms[1] == 1) - pScr->DECCKM = toggle; - - #if 0 - switch(pScr->parms[0]) { + if (pScr->parms[0] == -2 && pScr->parms[1] == 1) + pScr->DECCKM = toggle; - case -2: // Set on the '?' char - switch(pScr->parms[1]) { +#if 0 + switch(pScr->parms[0]) { - case 1: /* set/reset cursor key mode */ - pScr->DECCKM = toggle; - break; + case -2: /* Set on the '?' char */ + switch(pScr->parms[1]) { - #ifdef NOT_SUPPORTED - case 2: /* set/reset ANSI/vt52 mode */ - break; - #endif + case 1: /* set/reset cursor key mode */ + pScr->DECCKM = toggle; + break; - case 3: /* set/reset column mode */ - pScr->x = pScr->y = 0; /* Clear the screen, mama! */ - ScreenEraseScreen(pScr); - #if 0 /* removed for variable screen size */ - if (toggle) /* 132 column mode */ - pScr->width = pScr->allwidth; - else - pScr->width = 79; - #endif - break; +#ifdef NOT_SUPPORTED + case 2: /* set/reset ANSI/vt52 mode */ + break; +#endif - #ifdef NOT_SUPPORTED - case 4: /* set/reset scrolling mode */ - case 5: /* set/reset screen mode */ - case 6: /* set/rest origin mode */ - pScr->DECORG = toggle; - break; - #endif + case 3: /* set/reset column mode */ + pScr->x = pScr->y = 0; /* Clear the screen, mama! */ + ScreenEraseScreen(pScr); +#if 0 /* removed for variable screen size */ + if (toggle) /* 132 column mode */ + pScr->width = pScr->allwidth; + else + pScr->width = 79; +#endif + break; - case 7: /* set/reset wrap mode */ - pScr->DECAWM = toggle; -// set_vtwrap(pScrn, fpScr->DECAWM); /* QAK - 7/27/90: added because resetting the virtual screen's wrapping flag doesn't reset telnet window's wrapping */ - break; +#ifdef NOT_SUPPORTED + case 4: /* set/reset scrolling mode */ + case 5: /* set/reset screen mode */ + case 6: /* set/rest origin mode */ + pScr->DECORG = toggle; + break; +#endif - #ifdef NOT_SUPPORTED - case 8: /* set/reset autorepeat mode */ - case 9: /* set/reset interlace mode */ - break; - #endif + case 7: /* set/reset wrap mode */ + pScr->DECAWM = toggle; +#if 0 + /* + * QAK - 7/27/90: added because resetting the virtual screen's + * wrapping flag doesn't reset telnet window's wrapping + */ + set_vtwrap(pScrn, fpScr->DECAWM); +#endif + break; - default: - break; - } /* end switch */ - break; +#ifdef NOT_SUPPORTED + case 8: /* set/reset autorepeat mode */ + case 9: /* set/reset interlace mode */ + break; +#endif - case 4: - pScr->IRM=toggle; - break; + default: + break; + } /* end switch */ + break; - default: - break; + case 4: + pScr->IRM=toggle; + break; - } /* end switch */ + default: + break; - #endif -} /* ScreenSetOption */ + } /* end switch */ +#endif +} #ifdef NOT_SUPPORTED - void ScreenTab( - SCREEN *pScr) - { - if (pScr->x> = pScr->width) - pScr->x = pScr->width; - pScr->x++; - while (pScr->tabs[fpScr->x] != 'x' && pScr->x < pScr->width) - pScr->x++; - } /* ScreenTab */ +void +ScreenTab(SCREEN *pScr) +{ + if (pScr->x> = pScr->width) + pScr->x = pScr->width; + pScr->x++; + while (pScr->tabs[fpScr->x] != 'x' && pScr->x < pScr->width) + pScr->x++; +} #endif -int ScreenInsChar( - SCREEN *pScr, - int x) +int +ScreenInsChar(SCREEN *pScr, int x) { - int i; - SCREENLINE *pScrLine; - RECT rc; + int i; + SCREENLINE *pScrLine; + RECT rc; - pScrLine = GetScreenLineFromY(pScr, pScr->y); - if (pScrLine == NULL) - return(-1); - - for(i = pScr->width - x; i >= pScr->x; i--) { - pScrLine->text[x+i] = pScrLine->text[i]; - pScrLine->attrib[x+i] = pScrLine->attrib[i]; - } - - memset(&pScrLine->attrib[pScr->x], ScreenClearAttrib, x); - memset(&pScrLine->text[pScr->x], ' ', x); - rc.left = pScr->cxChar * x; - rc.right = pScr->cxChar * (x + pScr->x); - rc.top = pScr->cyChar * (pScr->y - 1); - rc.bottom = pScr->cyChar * pScr->y; - InvalidateRect(pScr->hWnd, &rc, TRUE); - SendMessage(pScr->hWnd, WM_PAINT, NULL, NULL); - -} /* ScreenInsChar */ - - -void ScreenSaveCursor( - SCREEN *pScr) + pScrLine = GetScreenLineFromY(pScr, pScr->y); + if (pScrLine == NULL) + return(-1); + + for(i = pScr->width - x; i >= pScr->x; i--) { + pScrLine->text[x+i] = pScrLine->text[i]; + pScrLine->attrib[x+i] = pScrLine->attrib[i]; + } + + memset(&pScrLine->attrib[pScr->x], ScreenClearAttrib, x); + memset(&pScrLine->text[pScr->x], ' ', x); + rc.left = pScr->cxChar * x; + rc.right = pScr->cxChar * (x + pScr->x); + rc.top = pScr->cyChar * (pScr->y - 1); + rc.bottom = pScr->cyChar * pScr->y; + InvalidateRect(pScr->hWnd, &rc, TRUE); + SendMessage(pScr->hWnd, WM_PAINT, 0, 0); +} + + +void +ScreenSaveCursor(SCREEN *pScr) { - pScr->Px = pScr->x; - pScr->Py = pScr->y; - pScr->Pattrib = pScr->attrib; - -} /* ScreenSaveCursor */ + pScr->Px = pScr->x; + pScr->Py = pScr->y; + pScr->Pattrib = pScr->attrib; +} -void ScreenRestoreCursor( - SCREEN *pScr) +void +ScreenRestoreCursor(SCREEN *pScr) { - pScr->x = pScr->Px; - pScr->y = pScr->Py; - ScreenRange(pScr); - -} /* ScreenRestoreCursor */ + pScr->x = pScr->Px; + pScr->y = pScr->Py; + ScreenRange(pScr); +} -void ScreenDraw( - SCREEN *pScr, - int x, - int y, - int a, - int len, - char *c) +void +ScreenDraw(SCREEN *pScr, int x, int y, int a, int len, char *c) { - int idx; - SCREENLINE *pScrLine; - RECT rc; + int idx; + SCREENLINE *pScrLine; + RECT rc; - pScrLine = GetScreenLineFromY(pScr, y); - assert(pScrLine != NULL); + pScrLine = GetScreenLineFromY(pScr, y); + assert(pScrLine != NULL); - for(idx = x; idx < x + len; idx++) { - pScrLine->text[idx] = c[idx - x]; - pScrLine->attrib[idx - x] = a; - } + for(idx = x; idx < x + len; idx++) { + pScrLine->text[idx] = c[idx - x]; + pScrLine->attrib[idx - x] = a; + } - rc.left = pScr->cxChar * x; - rc.right = pScr->cxChar * (x + len); - rc.top = pScr->cyChar * pScr->y; - rc.bottom = pScr->cyChar * (pScr->y + 1); - InvalidateRect(pScr->hWnd, &rc, TRUE); - SendMessage(pScr->hWnd, WM_PAINT, NULL, NULL); - -} /* ScreenDraw */ + rc.left = pScr->cxChar * x; + rc.right = pScr->cxChar * (x + len); + rc.top = pScr->cyChar * pScr->y; + rc.bottom = pScr->cyChar * (pScr->y + 1); + InvalidateRect(pScr->hWnd, &rc, TRUE); + SendMessage(pScr->hWnd, WM_PAINT, 0, 0); +} #if ! defined(NDEBUG) - BOOL CheckScreen( - SCREEN *pScr) - { - SCREENLINE *pLinePrev; - SCREENLINE *pLine; - int nscreen = 0; - int nbuffer = 0; - int topline = 0; - char buf[512]; - BOOL bBottom; - BOOL bOK; - - pLine = pScr->buffer_top; - - if (pLine == NULL) { - OutputDebugString("CheckScreen: buffer_top invalid"); - MessageBox(NULL, "buffer_top invalid", "CheckScreen", MB_OK); - return(FALSE); - } - - bBottom = FALSE; - while (TRUE) { - pLinePrev = pLine; - if (nscreen > 0 || pLine == pScr->screen_top) - if (!bBottom) - nscreen++; - nbuffer++; - if (pLine == pScr->screen_top) - topline = nbuffer - 1; - if (pLine == pScr->screen_bottom) - bBottom = TRUE; - pLine = pLine->next; - if (pLine == NULL) - break; - if (pLine->prev != pLinePrev) { - wsprintf(buf, - "Previous ptr of line %d does not match next ptr of line %d", - nbuffer, nbuffer - 1); - OutputDebugString(buf); - MessageBox(NULL, buf, "CheckScreen", MB_OK); - } - } - - if (pLinePrev == pScr->buffer_bottom && nscreen == pScr->height) - bOK = TRUE; - else { - OutputDebugString("CheckScreen: Invalid number of lines on screen"); - bOK = FALSE; - } - - wsprintf(buf, \ - "screen.width = %d\n" - "screen.height = %d\n" - "screen.maxlines = %d\n" - "screen.numlines = %d\n" - "screen.x = %d\n" - "screen.y = %d\n" - "screen.top = %d\n" - "screen.bottom = %d\n" - "Actual top line = %d\n" - "Actual buffer lines = %d\n" - "Actual screen lines = %d\n" - "Bottom of buffer is %s", - pScr->width, pScr->height, pScr->maxlines, pScr->numlines, - pScr->x, pScr->y, pScr->top, pScr->bottom, - topline, nbuffer, nscreen, - (pLinePrev == pScr->buffer_bottom) ? "valid" : "invalid"); - - MessageBox(NULL, buf, "CheckScreen", MB_OK); - - return(bOK); - - } /* CheckScreen */ +BOOL +CheckScreen(SCREEN *pScr) +{ + SCREENLINE *pLinePrev; + SCREENLINE *pLine; + int nscreen = 0; + int nbuffer = 0; + int topline = 0; + char buf[512]; + BOOL bBottom; + BOOL bOK; + + pLine = pScr->buffer_top; + + if (pLine == NULL) { + OutputDebugString("CheckScreen: buffer_top invalid"); + MessageBox(NULL, "buffer_top invalid", "CheckScreen", MB_OK); + return(FALSE); + } + + bBottom = FALSE; + while (TRUE) { + pLinePrev = pLine; + if (nscreen > 0 || pLine == pScr->screen_top) + if (!bBottom) + nscreen++; + nbuffer++; + if (pLine == pScr->screen_top) + topline = nbuffer - 1; + if (pLine == pScr->screen_bottom) + bBottom = TRUE; + pLine = pLine->next; + if (pLine == NULL) + break; + if (pLine->prev != pLinePrev) { + wsprintf(buf, + "Previous ptr of line %d does not match next ptr of line %d", + nbuffer, nbuffer - 1); + OutputDebugString(buf); + MessageBox(NULL, buf, "CheckScreen", MB_OK); + } + } + + if (pLinePrev == pScr->buffer_bottom && nscreen == pScr->height) + bOK = TRUE; + else { + OutputDebugString("CheckScreen: Invalid number of lines on screen"); + bOK = FALSE; + } + + wsprintf(buf, "screen.width = %d\nscreen.height = %d\nscreen.maxlines = %d\nscreen.numlines = %d\nscreen.x = %d\nscreen.y = %d\nscreen.top = %d\nscreen.bottom = %d\nActual top line = %d\nActual buffer lines = %d\nActual screen lines = %d\nBottom of buffer is %s", + pScr->width, pScr->height, pScr->maxlines, pScr->numlines, + pScr->x, pScr->y, pScr->top, pScr->bottom, + topline, nbuffer, nscreen, + (pLinePrev == pScr->buffer_bottom) ? "valid" : "invalid"); + + MessageBox(NULL, buf, "CheckScreen", MB_OK); + + return(bOK); +} #endif diff --git a/src/windows/wintel/k5stream.c b/src/windows/wintel/k5stream.c index 3745ed5a1..4c36cd0b0 100644 --- a/src/windows/wintel/k5stream.c +++ b/src/windows/wintel/k5stream.c @@ -1,10 +1,10 @@ -/*+************************************************************************* -** -** K5stream -** -** Emulates the kstream package in Kerberos 4 -** -***************************************************************************/ +/* + * + * K5stream + * + * Emulates the kstream package in Kerberos 4 + * + */ #include #include @@ -14,50 +14,106 @@ #include "auth.h" int -kstream_destroy (kstream ks) { - if (ks != NULL) { - auth_destroy (ks); /* Destroy authorizing */ - - closesocket (ks->fd); /* Close the socket??? */ - free (ks); - } - return 0; +kstream_destroy(kstream ks) +{ + if (ks != NULL) { + auth_destroy(ks); /* Destroy authorizing */ + + closesocket(ks->fd); /* Close the socket??? */ + free(ks); + } + return 0; } void -kstream_set_buffer_mode (kstream ks, int mode) { +kstream_set_buffer_mode(kstream ks, int mode) +{ } kstream -kstream_create_from_fd (int fd, - const struct kstream_crypt_ctl_block __far *ctl, - kstream_ptr data) +kstream_create_from_fd(int fd, + const struct kstream_crypt_ctl_block FAR *ctl, + kstream_ptr data) { - kstream ks; - int n; + kstream ks; + int n; + BOOL on = 1; + + ks = malloc(sizeof(struct kstream_int)); + if (ks == NULL) + return NULL; + + ks->fd = fd; - ks = malloc (sizeof(kstream *)); - if (ks == NULL) - return NULL; + setsockopt(ks->fd, SOL_SOCKET, SO_OOBINLINE, (const char *)&on, sizeof(on)); - ks->fd = fd; + n = auth_init(ks, data); /* Initialize authorizing */ + if (n) { + free(ks); + return NULL; + } - n = auth_init (ks, data); /* Initialize authorizing */ - if (n) { - free (ks); - return NULL; - } + ks->encrypt = NULL; + ks->decrypt = NULL; - return ks; + return ks; } int -kstream_write (kstream ks, void __far *p_data, size_t p_len) { - int n; +kstream_write(kstream ks, void FAR *p_data, size_t p_len) +{ + int n; + struct kstream_data_block i; + +#ifdef DEBUG + hexdump("plaintext:", p_data, p_len); +#endif + + if (ks->encrypt) { + i.ptr = p_data; + i.length = p_len; + ks->encrypt(&i, NULL, NULL); +#ifdef DEBUG + hexdump("cyphertext:", p_data, p_len); +#endif + } - n = send (ks->fd, p_data, p_len, 0); /* Write the data */ + n = send(ks->fd, p_data, p_len, 0); /* Write the data */ - return n; /* higher layer does retries */ + return n; /* higher layer does retries */ +} + + +int +kstream_read(kstream ks, void FAR *p_data, size_t p_len) +{ + int n; + struct kstream_data_block i; + + n = recv(ks->fd, p_data, p_len, 0); /* read the data */ + + if (n < 0) + return n; + +#ifdef DEBUG + hexdump("input data:", p_data, n); +#endif + + if (ks->decrypt) { + extern int encrypt_flag; + + if (encrypt_flag == 2) + encrypt_flag = 1; + + i.ptr = p_data; + i.length = n; + ks->decrypt(&i, NULL, NULL); +#ifdef DEBUG + hexdump("decrypted data:", p_data, n); +#endif + } + + return n; /* higher layer does retries */ } diff --git a/src/windows/wintel/k5stream.h b/src/windows/wintel/k5stream.h index 0a9ce0808..b9b9ebd33 100644 --- a/src/windows/wintel/k5stream.h +++ b/src/windows/wintel/k5stream.h @@ -15,38 +15,43 @@ #ifndef K5STREAM_H #define K5STREAM_H -typedef struct { /* Object we pass around */ - int fd; /* Open socket descriptor */ +typedef struct kstream_int { /* Object we pass around */ + int fd; /* Open socket descriptor */ + int (*encrypt)(struct kstream_data_block *, /* output */ + struct kstream_data_block *, /* input */ + struct kstream *kstream); + int (*decrypt)(struct kstream_data_block *, /* output */ + struct kstream_data_block *, /* input */ + struct kstream *kstream); } *kstream; typedef void *kstream_ptr; /* Data send on the kstream */ struct kstream_data_block { - kstream_ptr ptr; - size_t length; + kstream_ptr ptr; + size_t length; }; struct kstream_crypt_ctl_block { - int (INTERFACE *encrypt) ( - struct kstream_data_block *, /* output -- written */ - struct kstream_data_block *, /* input */ - kstream str); - int (INTERFACE *decrypt) ( - struct kstream_data_block *, /* output -- written */ - struct kstream_data_block *, /* input */ - kstream str); - int (INTERFACE *init) (kstream str, kstream_ptr data); - void (INTERFACE *destroy) (kstream str); + int (*encrypt)(struct kstream_data_block *, /* output */ + struct kstream_data_block *, /* input */ + kstream); + int (*decrypt)(struct kstream_data_block *, /* output */ + struct kstream_data_block *, /* input */ + kstream); + int (*init)(kstream, kstream_ptr); + void (*destroy)(kstream); }; /* Prototypes */ -int kstream_destroy (kstream); -void kstream_set_buffer_mode (kstream, int); -kstream kstream_create_from_fd (int fd, - const struct kstream_crypt_ctl_block __far *ctl, - kstream_ptr data); -int kstream_write (kstream, void __far *, size_t); +int kstream_destroy(kstream); +void kstream_set_buffer_mode(kstream, int); +kstream kstream_create_from_fd(int fd, + const struct kstream_crypt_ctl_block FAR *, + kstream_ptr); +int kstream_write(kstream, void FAR *, size_t); +int kstream_read(kstream, void FAR *, size_t); #endif /* K5STREAM_H */ diff --git a/src/windows/wintel/ktelnet.doc b/src/windows/wintel/ktelnet.doc new file mode 100644 index 000000000..64e4f4526 Binary files /dev/null and b/src/windows/wintel/ktelnet.doc differ diff --git a/src/windows/wintel/ktelnet.hlp b/src/windows/wintel/ktelnet.hlp new file mode 100644 index 000000000..e44cebfe5 Binary files /dev/null and b/src/windows/wintel/ktelnet.hlp differ diff --git a/src/windows/wintel/ktelnet.hpj b/src/windows/wintel/ktelnet.hpj new file mode 100644 index 000000000..d69185cd8 --- /dev/null +++ b/src/windows/wintel/ktelnet.hpj @@ -0,0 +1,92 @@ +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +; Help Project File for KTELNET +; +; This file is maintained by RoboHELP. Do not modify this file directly. +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + + +[OPTIONS] +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +; The Options section contains the following information: +; +; The optional BMROOT= entry sets the directories in which the Help Compiler +; will look for graphics. +; +; The CONTENTS= tells WinHelp which topic contains the contents. +; +; The TITLE= is displayed in the Title Bar of WINHELP.EXE +; +; The BUILD= setting allows you to create different Help systems from +; the same source file. +; +; The COMPRESS= option tells the Help Compiler how much to compress +; the Help file. +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +;BMROOT=C:\WINDOWS\DESKTOP\KERBEROS 5\WIN95 GUI\CNS HELP +TITLE=Kerb*Net Telnet for Windows +BUILD=WINDOWS +NOTES=1 + + +OLDKEYPHRASE=NO +OPTCDROM=0 +REPORT=YES +COMPRESS=12 +ERRORLOG=C:\windows\desktop\kerberos 5\win95 gui\cns help\KTELNET.ERR +[BUILDTAGS] +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +; The Build Tags section specifies to the Help Compiler the names +; of all the valid build tags used in this Help project. +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +WINDOWS + + +[CONFIG] +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +; The Config section defines macros which will run at startup. +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + + + + +[FILES] +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +; The Files section specifies the RTF files for a project. +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + + +KTELNET.RTF +[ALIAS] +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +; The Alias section sets up aliases for Topic IDs in your Help system. +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + + +[MAP] +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +; The Map section specifies the project HH files. +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + + +[BITMAPS] +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +; The Bitmaps section specifies the referenced bitmaps used in +; your help system. +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + + +[WINDOWS] +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +; The Windows section contains all of the information about the windows +; in a Help project. +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +;Gloss = "Glossary",(100,100,350,350),0,(255,255,255),(255,255,255) +main=,,29188,, +(w95sec)=,,20740,(r14745599),(r14745599),f2 + + +[BAGGAGE] +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +; The Baggage section specifies any additional files. +;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + diff --git a/src/windows/wintel/negotiat.c b/src/windows/wintel/negotiat.c index 58bf97d90..685092df5 100644 --- a/src/windows/wintel/negotiat.c +++ b/src/windows/wintel/negotiat.c @@ -1,24 +1,34 @@ /* -* negotiat.c -* -* Telnet option negotiation functions -* + * negotiat.c + * + * Telnet option negotiation functions + * /* -* Includes -*/ + * Includes + */ /* #define USETEK */ /* #define USERAS */ -#if 0 /* define this to print the raw network data to debuging monitor */ -#define NEGOTIATEDEBUG +#ifdef DEBUG /* define this to print the raw network data to debuging monitor */ +#define NEGOTIATEDEBUG +#endif + +#if 0 +#define PRINT_EVERYTHING /* talk a lot */ #endif #include #include "telnet.h" -#include "telopts.h" +#include "telnet_arpa.h" #include "auth.h" +#include "encrypt.h" + +#define STNORM 0 +#define NEGOTIATE 1 +#define ESCFOUND 5 +#define IACFOUND 6 unsigned char parsedat[256]; @@ -27,766 +37,829 @@ static void parse_subnegotiat(kstream ks,int end_sub); /* Local variables */ static char *telstates[]={ - "EOF", - "Suspend Process", - "Abort Process", - "Unknown (239)", - "Subnegotiation End", - "NOP", - "Data Mark", - "Break", - "Interrupt Process", - "Abort Output", - "Are You There", - "Erase Character", - "Erase Line", - "Go Ahead", - "Subnegotiate", - "Will", - "Won't", - "Do", - "Don't" + "EOF", + "Suspend Process", + "Abort Process", + "Unknown (239)", + "Subnegotiation End", + "NOP", + "Data Mark", + "Break", + "Interrupt Process", + "Abort Output", + "Are You There", + "Erase Character", + "Erase Line", + "Go Ahead", + "Subnegotiate", + "Will", + "Won't", + "Do", + "Don't" }; static char *teloptions[256]={ /* ascii strings for Telnet options */ - "Binary", /* 0 */ - "Echo", - "Reconnection", - "Supress Go Ahead", - "Message Size Negotiation", - "Status", /* 5 */ - "Timing Mark", - "Remote Controlled Trans and Echo", - "Output Line Width", - "Output Page Size", - "Output Carriage-Return Disposition", /* 10 */ - "Output Horizontal Tab Stops", - "Output Horizontal Tab Disposition", - "Output Formfeed Disposition", - "Output Vertical Tabstops", - "Output Vertical Tab Disposition", /* 15 */ - "Output Linefeed Disposition", - "Extended ASCII", - "Logout", - "Byte Macro", - "Data Entry Terminal", /* 20 */ - "SUPDUP", - "SUPDUP Output", - "Send Location", - "Terminal Type", - "End of Record", /* 25 */ - "TACACS User Identification", - "Output Marking", - "Terminal Location Number", - "3270 Regime", - "X.3 PAD", /* 30 */ - "Negotiate About Window Size", - "Terminal Speed", - "Toggle Flow Control", - "Linemode", - "X Display Location", /* 35 */ - "Environment", - "Authentication", - "Data Encryption", - "39", - "40","41","42","43","44","45","46","47","48","49", - "50","51","52","53","54","55","56","57","58","59", - "60","61","62","63","64","65","66","67","68","69", - "70","71","72","73","74","75","76","77","78","79", - "80","81","82","83","84","85","86","87","88","89", - "90","91","92","93","94","95","96","97","98","99", - "100","101","102","103","104","105","106","107","108","109", - "110","111","112","113","114","115","116","117","118","119", - "120","121","122","123","124","125","126","127","128","129", - "130","131","132","133","134","135","136","137","138","139", - "140","141","142","143","144","145","146","147","148","149", - "150","151","152","153","154","155","156","157","158","159", - "160","161","162","163","164","165","166","167","168","169", - "170","171","172","173","174","175","176","177","178","179", - "180","181","182","183","184","185","186","187","188","189", - "190","191","192","193","194","195","196","197","198","199", - "200","201","202","203","204","205","206","207","208","209", - "210","211","212","213","214","215","216","217","218","219", - "220","221","222","223","224","225","226","227","228","229", - "230","231","232","233","234","235","236","237","238","239", - "240","241","242","243","244","245","246","247","248","249", - "250","251","252","253","254", - "Extended Options List" /* 255 */ + "Binary", /* 0 */ + "Echo", + "Reconnection", + "Supress Go Ahead", + "Message Size Negotiation", + "Status", /* 5 */ + "Timing Mark", + "Remote Controlled Trans and Echo", + "Output Line Width", + "Output Page Size", + "Output Carriage-Return Disposition", /* 10 */ + "Output Horizontal Tab Stops", + "Output Horizontal Tab Disposition", + "Output Formfeed Disposition", + "Output Vertical Tabstops", + "Output Vertical Tab Disposition", /* 15 */ + "Output Linefeed Disposition", + "Extended ASCII", + "Logout", + "Byte Macro", + "Data Entry Terminal", /* 20 */ + "SUPDUP", + "SUPDUP Output", + "Send Location", + "Terminal Type", + "End of Record", /* 25 */ + "TACACS User Identification", + "Output Marking", + "Terminal Location Number", + "3270 Regime", + "X.3 PAD", /* 30 */ + "Negotiate About Window Size", + "Terminal Speed", + "Toggle Flow Control", + "Linemode", + "X Display Location", /* 35 */ + "Environment", + "Authentication", + "Data Encryption", + "39", + "40","41","42","43","44","45","46","47","48","49", + "50","51","52","53","54","55","56","57","58","59", + "60","61","62","63","64","65","66","67","68","69", + "70","71","72","73","74","75","76","77","78","79", + "80","81","82","83","84","85","86","87","88","89", + "90","91","92","93","94","95","96","97","98","99", + "100","101","102","103","104","105","106","107","108","109", + "110","111","112","113","114","115","116","117","118","119", + "120","121","122","123","124","125","126","127","128","129", + "130","131","132","133","134","135","136","137","138","139", + "140","141","142","143","144","145","146","147","148","149", + "150","151","152","153","154","155","156","157","158","159", + "160","161","162","163","164","165","166","167","168","169", + "170","171","172","173","174","175","176","177","178","179", + "180","181","182","183","184","185","186","187","188","189", + "190","191","192","193","194","195","196","197","198","199", + "200","201","202","203","204","205","206","207","208","209", + "210","211","212","213","214","215","216","217","218","219", + "220","221","222","223","224","225","226","227","228","229", + "230","231","232","233","234","235","236","237","238","239", + "240","241","242","243","244","245","246","247","248","249", + "250","251","252","253","254", + "Extended Options List" /* 255 */ }; static char *LMoptions[]={ /* ascii strings for Linemode sub-options */ - "None", "MODE", "FORWARDMASK", "SLC" + "None", "MODE", "FORWARDMASK", "SLC" }; static char *ModeOptions[]={ /* ascii strings for Linemode edit options */ - "None", "EDIT", "TRAPSIG", "ACK", "SOFT TAB", "LIT ECHO" + "None", "EDIT", "TRAPSIG", "ACK", "SOFT TAB", "LIT ECHO" }; static char *SLCoptions[]={ /* ascii strings for Linemode SLC characters */ - "None", "SYNCH", "BREAK", "IP", "ABORT OUTPUT", - "AYT", "EOR", "ABORT", "EOF", "SUSP", - "EC", "EL", "EW", "RP", "LNEXT", - "XON", "XOFF", "FORW1", "FORW2", "MCL", - "MCR", "MCWL", "MCWR", "MCBOL", "MCEOL", - "INSRT", "OVER", "ECR", "EWR", "EBOL", - "EEOL" + "None", "SYNCH", "BREAK", "IP", "ABORT OUTPUT", + "AYT", "EOR", "ABORT", "EOF", "SUSP", + "EC", "EL", "EW", "RP", "LNEXT", + "XON", "XOFF", "FORW1", "FORW2", "MCL", + "MCR", "MCWL", "MCWR", "MCBOL", "MCEOL", + "INSRT", "OVER", "ECR", "EWR", "EBOL", + "EEOL" }; static char *SLCflags[]={ /* ascii strings for Linemode SLC flags */ - "SLC_NOSUPPORT", "SLC_CANTCHANGE", "SLC_VALUE", "SLC_DEFAULT" + "SLC_NOSUPPORT", "SLC_CANTCHANGE", "SLC_VALUE", "SLC_DEFAULT" }; - /* Linemode default character for each function */ -static unsigned char LMdefaults[NUMLMODEOPTIONS+1]={ - (unsigned char)-1, /* zero isn't used */ - (unsigned char)-1, /* we don't support SYNCH */ - 3, /* ^C is default for BRK */ - 3, /* ^C is default for IP */ - 15, /* ^O is default for AO */ - 25, /* ^Y is default for AYT */ /* 5 */ - (unsigned char)-1, /* we don't support EOR */ - 3, /* ^C is default for ABORT */ - 4, /* ^D is default for EOF */ - 26, /* ^Z is default for SUSP */ - 8, /* ^H is default for EC */ /* 10 */ - 21, /* ^U is default for EL */ - 23, /* ^W is default for EW */ - 18, /* ^R is default for RP */ - 22, /* ^V is default for LNEXT */ - 17, /* ^Q is default for XON */ /* 15 */ - 19, /* ^S is default for XOFF */ - 22, /* ^V is default for FORW1 */ - 5, /* ^E is default for FORW2 */ - (unsigned char)-1, /* we don't support MCL */ - (unsigned char)-1, /* we don't support MCR */ /* 20 */ - (unsigned char)-1, /* we don't support MCWL */ - (unsigned char)-1, /* we don't support MCWR */ - (unsigned char)-1, /* we don't support MCBOL */ - (unsigned char)-1, /* we don't support MCEOL */ - (unsigned char)-1, /* we don't support INSRT */ /* 25 */ - (unsigned char)-1, /* we don't support OVER */ - (unsigned char)-1, /* we don't support ECR */ - (unsigned char)-1, /* we don't support EWR */ - (unsigned char)-1, /* we don't support EBOL */ - (unsigned char)-1 /* we don't support EEOL */ /* 30 */ +/* Linemode default character for each function */ +static unsigned char LMdefaults[NTELOPTS + 1]={ + (unsigned char)-1, /* zero isn't used */ + (unsigned char)-1, /* we don't support SYNCH */ + 3, /* ^C is default for BRK */ + 3, /* ^C is default for IP */ + 15, /* ^O is default for AO */ + 25, /* ^Y is default for AYT */ /* 5 */ + (unsigned char)-1, /* we don't support EOR */ + 3, /* ^C is default for ABORT */ + 4, /* ^D is default for EOF */ + 26, /* ^Z is default for SUSP */ + 8, /* ^H is default for EC */ /* 10 */ + 21, /* ^U is default for EL */ + 23, /* ^W is default for EW */ + 18, /* ^R is default for RP */ + 22, /* ^V is default for LNEXT */ + 17, /* ^Q is default for XON */ /* 15 */ + 19, /* ^S is default for XOFF */ + 22, /* ^V is default for FORW1 */ + 5, /* ^E is default for FORW2 */ + (unsigned char)-1, /* we don't support MCL */ + (unsigned char)-1, /* we don't support MCR */ /* 20 */ + (unsigned char)-1, /* we don't support MCWL */ + (unsigned char)-1, /* we don't support MCWR */ + (unsigned char)-1, /* we don't support MCBOL */ + (unsigned char)-1, /* we don't support MCEOL */ + (unsigned char)-1, /* we don't support INSRT */ /* 25 */ + (unsigned char)-1, /* we don't support OVER */ + (unsigned char)-1, /* we don't support ECR */ + (unsigned char)-1, /* we don't support EWR */ + (unsigned char)-1, /* we don't support EBOL */ + (unsigned char)-1 /* we don't support EEOL */ /* 30 */ }; -/*+******************************************************************** -* Function : start_negotiation() -* Purpose : Send the initial negotiations on the network and print -* the negotitations to the console screen. -* Parameters : -* dat - the port number to write to -* cvs - the console's virtual screen -* Returns : none -* Calls : tprintf(), netprintf() -* Called by : dosessions() -**********************************************************************/ +/* + * Function : start_negotiation() + * Purpose : Send the initial negotiations on the network and print + * the negotitations to the console screen. + * Parameters : + * dat - the port number to write to + * cvs - the console's virtual screen + * Returns : none + * Calls : tprintf(), netprintf() + * Called by : dosessions() + */ void start_negotiation(kstream ks) { - char buf[128]; + char buf[128]; - /* Send the initial tlnet negotiations */ - wsprintf(buf,"%c%c%c",IAC,DOTEL,SGA); - TelnetSend(ks,buf,lstrlen(buf),0); - wsprintf(buf,"%c%c%c",IAC,DOTEL,ECHO); - TelnetSend(ks,buf,lstrlen(buf),0); - wsprintf(buf,"%c%c%c",IAC,WILLTEL,NAWS); - TelnetSend(ks,buf,lstrlen(buf),0); + /* Send the initial telnet negotiations */ +#ifdef ENCRYPTION /* XXX */ + if (encrypt_flag) + wsprintf(buf,"%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", + IAC, WILL, TELOPT_AUTHENTICATION, + IAC, WILL, TELOPT_ENCRYPT, + IAC, DO, TELOPT_SGA, + IAC, DO, TELOPT_ECHO, + IAC, WILL, TELOPT_NAWS + ); + else +#endif + wsprintf(buf,"%c%c%c%c%c%c%c%c%c%c%c%c", + IAC, WILL, TELOPT_AUTHENTICATION, + IAC, DO, TELOPT_SGA, + IAC, DO, TELOPT_ECHO, + IAC, WILL, TELOPT_NAWS + ); + TelnetSend(ks,buf,lstrlen(buf),0); #ifdef NOT - /* check whether we are going to be output mapping */ - if(tw->mapoutput) { - netprintf(tw->pnum,"%c%c%c",IAC,DOTEL,BINARY); + /* check whether we are going to be output mapping */ + if(tw->mapoutput) { + netprintf(tw->pnum,"%c%c%c",IAC,DO,TELOPT_BINARY); /* set the flag indicating we wanted server to start transmitting binary */ - tw->uwantbinary=1; - netprintf(tw->pnum,"%c%c%c",IAC,WILLTEL,BINARY); + tw->uwantbinary=1; + netprintf(tw->pnum,"%c%c%c",IAC,WILL,TELOPT_BINARY); /* set the flag indicating we want to start transmitting binary */ - tw->iwantbinary=1; - } /* end if */ + tw->iwantbinary=1; + } /* end if */ #endif - /* Print to the console what we just did */ + /* Print to the console what we just did */ #ifdef NEGOTIATEDEBUG - wsprintf(strTmp,"SEND: %ls %ls\r\n",telstates[DOTEL-LOW_TEL_OPT], - teloptions[ECHO]); - OutputDebugString(strTmp); - wsprintf(strTmp,"SEND: %ls %ls\r\n",telstates[DOTEL-LOW_TEL_OPT], - teloptions[SGA]); - OutputDebugString(strTmp); - wsprintf(strTmp,"SEND: %ls %ls\r\n",telstates[WILLTEL-LOW_TEL_OPT], - teloptions[NAWS]); - OutputDebugString(strTmp); + wsprintf(strTmp,"SEND: %s %s\r\n",telstates[DO - TELCMD_FIRST], + teloptions[TELOPT_ECHO]); + OutputDebugString(strTmp); + wsprintf(strTmp,"SEND: %s %s\r\n",telstates[DO - TELCMD_FIRST], + teloptions[TELOPT_SGA]); + OutputDebugString(strTmp); + wsprintf(strTmp,"SEND: %s %s\r\n",telstates[WILL - TELCMD_FIRST], + teloptions[TELOPT_NAWS]); + OutputDebugString(strTmp); #ifdef NOT - tprintf(cvs,"SEND: %ls %ls\r\n",telstates[DOTEL-LOW_TEL_OPT], - teloptions[BINARY]); - tprintf(cvs,"SEND: %ls %ls\r\n",telstates[WILLTEL-LOW_TEL_OPT], - teloptions[BINARY]); + tprintf(cvs,"SEND: %s %s\r\n",telstates[DO - TELCMD_FIRST], + teloptions[BINARY]); + tprintf(cvs,"SEND: %s %s\r\n",telstates[WILL - TELCMD_FIRST], + teloptions[BINARY]); #endif #endif } /* end start_negotiation() */ -/*+******************************************************************* -* parse -* Do the telnet negotiation parsing. -* -* look at the string which has just come in from outside and -* check for special sequences that we are interested in. -* -* Tries to pass through routine strings immediately, waiting for special -* characters ESC and IAC to change modes. -*/ +/* + * parse + * Do the telnet negotiation parsing. + * + * look at the string which has just come in from outside and + * check for special sequences that we are interested in. + * + * Tries to pass through routine strings immediately, waiting for special + * characters ESC and IAC to change modes. + */ void -parse (CONNECTION *con,unsigned char *st,int cnt) { - static int sub_pos; /* the position we are in the subnegotiation parsing */ - static int end_sub; /* index of last byte in parsedat in a subnegotiation */ - unsigned char *mark, *orig; - char buf[256]; - kstream ks; +parse(CONNECTION *con,unsigned char *st,int cnt) +{ + static int sub_pos; /* the position we are in the subnegotiation parsing */ + static int end_sub; /* index of last byte in parsedat in a subnegotiation */ + unsigned char *mark, *orig; + char buf[256]; + kstream ks; - ks=con->ks; + ks = con->ks; -#ifdef PRINT_EVERYTHING - OutputDebugString("\r\n"); - for(i=0; ipnum); + netpush(tw->pnum); #endif -/* -* traverse string, looking for any special characters which indicate that -* we need to change modes. -*/ - while(sttelstate!=STNORM && sttelstate) { - case IACFOUND: /* telnet option negotiation */ - if(*st==IAC) { /* real data=255 */ - st++; /* real 255 will get sent */ - con->telstate=STNORM; - break; - } /* end if */ - - if(*st>239) { - con->telstate=*st++; /* by what the option is */ - break; - } /* end if */ + /* + * traverse string, looking for any special characters which indicate that + * we need to change modes. + */ + while(st < mark) { + + while(con->telstate != STNORM && st < mark) { + switch(con->telstate) { + case IACFOUND: /* telnet option negotiation */ + if(*st == IAC) { /* real data=255 */ + st++; /* real 255 will get sent */ + con->telstate = STNORM; + break; + } /* end if */ + + if(*st > 239) { + con->telstate = *st++; /* by what the option is */ + break; + } /* end if */ #ifdef NEGOTIATEDEBUG - wsprintf(buf,"\r\n strange telnet option"); - OutputDebugString(buf); + wsprintf(buf, "\r\n strange telnet option"); + OutputDebugString(buf); #endif - orig=++st; - con->telstate=STNORM; - break; - - case EL: /* received a telnet erase line command */ - case EC: /* received a telnet erase character command */ - case AYT: /* received a telnet Are-You-There command */ - case AO: /* received a telnet Abort Output command */ - case IP: /* received a telnet Interrupt Process command */ - case BREAK: /* received a telnet Break command */ - case DM: /* received a telnet Data Mark command */ - case NOP: /* received a telnet No Operation command */ - case SE: /* received a telnet Subnegotiation End command */ - case ABORT: /* received a telnet Abort Process command */ - case SUSP: /* received a telnet Suspend Process command */ - case TEL_EOF:/* received a telnet EOF command */ + orig=++st; + con->telstate=STNORM; + break; + + case EL: /* received a telnet erase line command */ + case EC: /* received a telnet erase character command */ + case AYT: /* received a telnet Are-You-There command */ + case AO: /* received a telnet Abort Output command */ + case IP: /* received a telnet Interrupt Process command */ + case BREAK: /* received a telnet Break command */ + case DM: /* received a telnet Data Mark command */ + case NOP: /* received a telnet No Operation command */ + case SE: /* received a telnet Subnegotiation End command */ + case ABORT: /* received a telnet Abort Process command */ + case SUSP: /* received a telnet Suspend Process command */ + case xEOF: /* received a telnet EOF command */ #ifdef NEGOTIATEDEBUG - wsprintf(buf,"RECV: %ls\r\n", - telstates[con->telstate-LOW_TEL_OPT]); - OutputDebugString(buf); + wsprintf(buf,"RECV: %s\r\n", + telstates[con->telstate-TELCMD_FIRST]); + OutputDebugString(buf); #endif - con->telstate=STNORM; - orig=++st; - break; + con->telstate=STNORM; + orig=++st; + break; - case GOAHEAD: /* telnet go ahead option*/ + case GA: /* telnet go ahead option*/ #ifdef NEGOTIATEDEBUG - wsprintf(buf,"RECV: %ls\r\n", - telstates[con->telstate-LOW_TEL_OPT]); - OutputDebugString(buf); + wsprintf(buf,"RECV: %s\r\n", + telstates[con->telstate-TELCMD_FIRST]); + OutputDebugString(buf); #endif - con->telstate=STNORM; - orig=++st; - break; + con->telstate=STNORM; + orig=++st; + break; - case DOTEL: /* received a telnet DO negotiation */ + case DO: /* received a telnet DO negotiation */ #ifdef NEGOTIATEDEBUG - wsprintf(buf,"RECV: %ls %ls\r\n", - telstates[con->telstate-LOW_TEL_OPT],teloptions[*st]); - OutputDebugString(buf); + wsprintf(buf,"RECV: %s %s\r\n", + telstates[con->telstate-TELCMD_FIRST],teloptions[*st]); + OutputDebugString(buf); #endif - switch(*st) { + switch(*st) { #ifdef NOT - case BINARY: /* DO: binary transmission */ - if(!tw->ibinary) { /* binary */ - if(!tw->iwantbinary) { - netprintf(tw->pnum,"%c%c%c", - IAC,WILLTEL,BINARY); - if(tw->condebug>0) - tprintf(cv,"SEND: %ls %ls\r\n", - telstates[WILLTEL-LOW_TEL_OPT], - teloptions[BINARY]); - } /* end if */ - else - tw->iwantbinary=0; /* turn off this now */ - tw->ibinary=1; - } /* end if */ - else { - if(tw->condebug>0) - tprintf(cv,"NO REPLY NEEDED: %ls %ls\r\n", - telstates[WILLTEL-LOW_TEL_OPT], - teloptions[BINARY]); - } /* end else */ - break; -#endif - - case SGA: /* DO: Suppress go-ahead */ - if(!con->igoahead) { /* suppress go-ahead */ - wsprintf(buf,"%c%c%c",IAC,WILLTEL,SGA); - TelnetSend(ks,buf,lstrlen(buf),0); + case TELOPT_BINARY: /* DO: binary transmission */ + if(!tw->ibinary) { /* binary */ + if(!tw->iwantbinary) { + netprintf(tw->pnum,"%c%c%c", + IAC,WILL,BINARY); + if(tw->condebug>0) + tprintf(cv,"SEND: %s %s\r\n", + telstates[WILL - TELCMD_FIRST], + teloptions[BINARY]); + } /* end if */ + else + tw->iwantbinary=0; /* turn off this now */ + tw->ibinary=1; + } /* end if */ + else { + if(tw->condebug>0) + tprintf(cv,"NO REPLY NEEDED: %s %s\r\n", + telstates[WILL - TELCMD_FIRST], + teloptions[BINARY]); + } /* end else */ + break; +#endif + + case TELOPT_SGA: /* DO: Suppress go-ahead */ + if(!con->igoahead) { /* suppress go-ahead */ + wsprintf(buf,"%c%c%c",IAC,WILL,TELOPT_SGA); + TelnetSend(ks,buf,lstrlen(buf),0); #ifdef NEGOTIATEDEBUG - wsprintf(strTmp,"SEND: %ls %ls\r\n", - telstates[WILLTEL-LOW_TEL_OPT], - teloptions[SGA]); - OutputDebugString(strTmp); - OutputDebugString("igoahead"); -#endif - con->igoahead=1; - } /* end if */ - else { + wsprintf(strTmp,"SEND: %s %s\r\n", + telstates[WILL - TELCMD_FIRST], + teloptions[TELOPT_SGA]); + OutputDebugString(strTmp); + OutputDebugString("igoahead"); +#endif + con->igoahead=1; + } /* end if */ + else { #ifdef NEGOTIATEDEBUG - wsprintf(strTmp, - "NO REPLY NEEDED: %ls %ls\r\n", - telstates[WILLTEL-LOW_TEL_OPT], - teloptions[SGA]); - OutputDebugString(strTmp); -#endif - } /* end else */ - break; - - case TERMTYPE: /* DO: terminal type negotiation */ - if(!con->termsent) { - con->termsent=TRUE; - wsprintf(buf,"%c%c%c",IAC,WILLTEL,TERMTYPE); - TelnetSend(ks,buf,lstrlen(buf),0); + wsprintf(strTmp, + "NO REPLY NEEDED: %s %s\r\n", + telstates[WILL - TELCMD_FIRST], + teloptions[TELOPT_SGA]); + OutputDebugString(strTmp); +#endif + } /* end else */ + break; + + case TELOPT_TTYPE: /* DO: terminal type negotiation */ + if(!con->termsent) { + con->termsent=TRUE; + wsprintf(buf,"%c%c%c",IAC,WILL,TELOPT_TTYPE); + TelnetSend(ks,buf,lstrlen(buf),0); #ifdef NEGOTIATEDEBUG - wsprintf(strTmp,"SEND: %ls %ls\r\n", - telstates[WILLTEL-LOW_TEL_OPT], - teloptions[TERMTYPE]); - OutputDebugString(strTmp); + wsprintf(strTmp,"SEND: %s %s\r\n", + telstates[WILL - TELCMD_FIRST], + teloptions[TELOPT_TTYPE]); + OutputDebugString(strTmp); #endif - } /* end if */ - else { + } /* end if */ + else { #ifdef NEGOTIATEDEBUG - wsprintf(strTmp,"NO REPLY NEEDED: %ls %ls\r\n", - telstates[WILLTEL-LOW_TEL_OPT], - teloptions[TERMTYPE]); - OutputDebugString(strTmp); + wsprintf(strTmp,"NO REPLY NEEDED: %s %s\r\n", + telstates[WILL - TELCMD_FIRST], + teloptions[TELOPT_TTYPE]); + OutputDebugString(strTmp); #endif - } /* end else */ - break; + } /* end else */ + break; #ifdef LATER - case LINEMODE: /* DO: linemode negotiation */ - tw->lmflag=1; /* set the linemode flag */ - netprintf(tw->pnum,"%c%c%c",IAC,WILLTEL,LINEMODE); - /* - ** Tell the other side to send us - ** it's default character set - */ - netprintf(tw->pnum,"%c%c%c%c", - IAC,SB,LINEMODE,SLC,0,SLC_DEFAULT,0,IAC,SE); - if(tw->condebug>0) { - tprintf(cv,"SEND: %ls %ls\r\n", - telstates[WILLTEL-LOW_TEL_OPT], - teloptions[LINEMODE]); - tprintf(cv, - "SEND: SB LINEMODE SLC 0 SLC_DEFAULT 0 IAC SE\r\n"); - } /* end if */ - break; -#endif - case NAWS: /* DO: Negotiate About Window Size */ - con->bResizeable=TRUE; - send_naws(con); - break; - - case AUTHENTICATION: /* DO: Authentication requested */ - wsprintf(buf,"%c%c%c",IAC,WILLTEL,AUTHENTICATION); - TelnetSend(ks,buf,lstrlen(buf),0); + case TELOPT_LINEMODE: /* DO: linemode negotiation */ + tw->lmflag=1; /* set the linemode flag */ + netprintf(tw->pnum,"%c%c%c",IAC,WILL,TELOPT_LINEMODE); + /* + * Tell the other side to send us + * its default character set + */ + netprintf(tw->pnum,"%c%c%c%c", + IAC,SB,TELOPT_LINEMODE,SLC,0,SLC_DEFAULT,0,IAC,SE); + if(tw->condebug>0) { + tprintf(cv,"SEND: %s %s\r\n", + telstates[WILL - TELCMD_FIRST], + teloptions[TELOPT_LINEMODE]); + tprintf(cv, + "SEND: SB LINEMODE SLC 0 SLC_DEFAULT 0 IAC SE\r\n"); + } /* end if */ + break; +#endif + case TELOPT_NAWS: /* DO: Negotiate About Window Size */ + con->bResizeable=TRUE; + send_naws(con); + break; + + case TELOPT_AUTHENTICATION: /* DO: Authentication requested */ + wsprintf(buf, "%c%c%c", IAC, WILL, TELOPT_AUTHENTICATION); + TelnetSend(ks, buf, lstrlen(buf), 0); +#ifdef NEGOTIATEDEBUG + wsprintf(strTmp,"SEND: %s %s\r\n", + telstates[WILL - TELCMD_FIRST], + teloptions[TELOPT_AUTHENTICATION]); + OutputDebugString(strTmp); +#endif + break; + +#ifdef ENCRYPTION + case TELOPT_ENCRYPT: /* DO: Remote is willing to receive encrypted */ + wsprintf(buf, "%c%c%c", IAC, + (encrypt_flag ? WILL : WONT), TELOPT_ENCRYPT); + TelnetSend(ks, buf, lstrlen(buf), 0); #ifdef NEGOTIATEDEBUG - wsprintf(strTmp,"SEND: %ls %ls\r\n", - telstates[WILLTEL-LOW_TEL_OPT], - teloptions[AUTHENTICATION]); - OutputDebugString(strTmp); + wsprintf(strTmp,"SEND: %s %s\r\n", + telstates[(encrypt_flag ? WILL : WONT) + - TELCMD_FIRST], + teloptions[TELOPT_ENCRYPT]); + OutputDebugString(strTmp); #endif - break; + break; +#endif /* ENCRYPTION */ - default: /* DO: */ - wsprintf(buf,"%c%c%c",IAC,WONTTEL,*st); - TelnetSend(ks,buf,lstrlen(buf),0); + default: /* DO: */ + wsprintf(buf, "%c%c%c", IAC, WONT, *st); + TelnetSend(ks, buf, lstrlen(buf), 0); #ifdef NEGOTIATEDEBUG - wsprintf(strTmp,"SEND: %ls %ls\r\n", - telstates[WONTTEL-LOW_TEL_OPT],teloptions[*st]); - OutputDebugString(strTmp); + wsprintf(strTmp,"SEND: %s %s\r\n", + telstates[WONT - TELCMD_FIRST], teloptions[*st]); + OutputDebugString(strTmp); #endif - break; + break; - } /* end switch */ - con->telstate=STNORM; - orig=++st; - break; + } /* end switch */ + con->telstate = STNORM; + orig = ++st; + break; - case DONTTEL: /* Received a telnet DONT option */ - if (*st==NAWS) - con->bResizeable=FALSE; + case DONT: /* Received a telnet DONT option */ + switch (*st) { + case TELOPT_NAWS: + con->bResizeable=FALSE; #ifdef NEGOTIATEDEBUG - wsprintf(strTmp,"RECV: %ls %ls\r\n", - telstates[con->telstate-LOW_TEL_OPT],teloptions[*st]); - OutputDebugString(strTmp); + wsprintf(strTmp,"RECV: %s %s\r\n", + telstates[con->telstate-TELCMD_FIRST],teloptions[*st]); + OutputDebugString(strTmp); #endif + break; #ifdef NOT - if((*st)==BINARY) { /* DONT: check for binary neg. */ - if(tw->ibinary) { /* binary */ - if(!tw->iwantbinary) { - netprintf(tw->pnum,"%c%c%c",IAC,WONTTEL,BINARY); - if(tw->condebug>0) - tprintf(cv,"SEND: %ls %ls\r\n", - telstates[WONTTEL-LOW_TEL_OPT], - teloptions[BINARY]); - } /* end if */ - else - tw->iwantbinary=0; /* turn off this now */ - tw->ibinary=0; - tw->mapoutput=0; /* turn output mapping off */ - } /* end if */ + case BINARY: /* DONT: check for binary neg. */ + if(tw->ibinary) { /* binary */ + if(!tw->iwantbinary) { + netprintf(tw->pnum,"%c%c%c",IAC,WONT,BINARY); + if(tw->condebug>0) + tprintf(cv,"SEND: %s %s\r\n", + telstates[WONT-TELCMD_FIRST], + teloptions[BINARY]); + } /* end if */ + else + tw->iwantbinary=0; /* turn off this now */ + tw->ibinary=0; + tw->mapoutput=0; /* turn output mapping off */ + } /* end if */ #ifdef NEGOTIATEDEBUG - wsprintf(strTmp,"NO REPLY NEEDED: %ls %ls\r\n", - telstates[WONTTEL-LOW_TEL_OPT], - teloptions[BINARY]); - OutputDebugString(strTmp); + wsprintf(strTmp,"NO REPLY NEEDED: %s %s\r\n", + telstates[WONT-TELCMD_FIRST], + teloptions[BINARY]); + OutputDebugString(strTmp); #endif - } + break; #endif - con->telstate=STNORM; - orig=++st; - break; - - case WILLTEL: /* received a telnet WILL option */ +#ifdef ENCRYPTION + case ENCRYPTION: + break; +#endif + } + + /* all these just fall through to here... */ + + con->telstate=STNORM; + orig=++st; + break; + + case WILL: /* received a telnet WILL option */ #ifdef NEGOTIATEDEBUG - wsprintf(strTmp,"RECV: %ls %ls\r\n", - telstates[con->telstate-LOW_TEL_OPT], - teloptions[*st]); - OutputDebugString(strTmp); + wsprintf(strTmp,"RECV: %s %s\r\n", + telstates[con->telstate-TELCMD_FIRST], + teloptions[*st]); + OutputDebugString(strTmp); #endif - switch(*st) { + switch(*st) { #ifdef NOT - case BINARY: /* WILL: binary */ - if(!tw->ubinary) { /* binary */ - if(!tw->uwantbinary) { - netprintf(tw->pnum,"%c%c%c", - IAC,DOTEL,BINARY); - if(tw->condebug>0) - tprintf(cv,"SEND: %ls %ls\r\n", - telstates[DOTEL-LOW_TEL_OPT], - teloptions[BINARY]); - } /* end if */ - else - tw->uwantbinary=0; /* turn off this now */ - tw->ubinary=1; - } /* end if */ - else { - if(tw->condebug>0) - tprintf(cv,"NO REPLY NEEDED: %ls %ls\r\n", - telstates[DOTEL-LOW_TEL_OPT], - teloptions[BINARY]); - } /* end else */ - break; -#endif - - case SGA: /* WILL: suppress go-ahead */ - if(!con->ugoahead) { - con->ugoahead=1; - wsprintf(buf,"%c%c%c",IAC,DOTEL,SGA); /* ack */ - TelnetSend(ks,buf,lstrlen(buf),0); + case TELOPT_BINARY: /* WILL: binary */ + if(!tw->ubinary) { /* binary */ + if(!tw->uwantbinary) { + netprintf(tw->pnum,"%c%c%c", + IAC,DO,TELOPT_BINARY); + if(tw->condebug>0) + tprintf(cv,"SEND: %s %s\r\n", + telstates[DO - TELCMD_FIRST], + teloptions[TELOPT_BINARY]); + } /* end if */ + else + tw->uwantbinary=0; /* turn off this now */ + tw->ubinary=1; + } /* end if */ + else { + if(tw->condebug>0) + tprintf(cv,"NO REPLY NEEDED: %s %s\r\n", + telstates[DO - TELCMD_FIRST], + teloptions[TELOPT_BINARY]); + } /* end else */ + break; +#endif + + case TELOPT_SGA: /* WILL: suppress go-ahead */ + if(!con->ugoahead) { + con->ugoahead=1; + wsprintf(buf,"%c%c%c",IAC,DO,TELOPT_SGA); /* ack */ + TelnetSend(ks,buf,lstrlen(buf),0); #ifdef NEGOTIATEDEBUG - wsprintf(strTmp,"SEND: %ls %ls\r\n", - telstates[DOTEL-LOW_TEL_OPT], - teloptions[SGA]); - OutputDebugString(strTmp); -#endif - } /* end if */ - break; - - case ECHO: /* WILL: echo */ - if(!con->echo) { - con->echo=1; - wsprintf(buf,"%c%c%c",IAC,DOTEL,ECHO); /* ack */ - TelnetSend(ks,buf,lstrlen(buf),0); + wsprintf(strTmp,"SEND: %s %s\r\n", + telstates[DO - TELCMD_FIRST], + teloptions[TELOPT_SGA]); + OutputDebugString(strTmp); +#endif + } /* end if */ + break; + + case TELOPT_ECHO: /* WILL: echo */ + if(!con->echo) { + con->echo = 1; + wsprintf(buf, "%c%c%c", IAC, DO, TELOPT_ECHO); /* ack */ + TelnetSend(ks, buf, lstrlen(buf), 0); #ifdef NEGOTIATEDEBUG - - wsprintf(strTmp,"SEND: %ls %ls\r\n", - telstates[DOTEL-LOW_TEL_OPT], - teloptions[ECHO]); - OutputDebugString(strTmp); + wsprintf(strTmp,"SEND: %s %s\r\n", + telstates[DO - TELCMD_FIRST], + teloptions[TELOPT_ECHO]); + OutputDebugString(strTmp); #endif - } /* end if */ - break; - - case TIMING: /* WILL: Timing mark */ - con->timing=0; - break; + } /* end if */ + break; + + case TELOPT_TM: /* WILL: Timing mark */ + con->timing=0; + break; +#ifdef ENCRYPTION + case TELOPT_ENCRYPT: /* WILL: decrypt our input */ + wsprintf(buf, "%c%c%c", IAC, + (encrypt_flag ? DO : DONT), TELOPT_ENCRYPT); + TelnetSend(ks, buf, lstrlen(buf), 0); + if (encrypt_flag) + encrypt_send_support(); - default: - wsprintf(buf,"%c%c%c",IAC,DONTTEL,*st); - TelnetSend(ks,buf,lstrlen(buf),0); #ifdef NEGOTIATEDEBUG - wsprintf(strTmp,"SEND: %ls %ls\r\n", - telstates[DONTTEL-LOW_TEL_OPT],teloptions[*st]); - OutputDebugString(strTmp); + wsprintf(strTmp,"SEND: %s %s\r\n", + telstates[(encrypt_flag ? DO : DONT) - TELCMD_FIRST], + teloptions[TELOPT_ENCRYPT]); + OutputDebugString(strTmp); +#endif + break; +#endif + + default: + wsprintf(buf,"%c%c%c",IAC,DONT,*st); + TelnetSend(ks,buf,lstrlen(buf),0); +#ifdef NEGOTIATEDEBUG + wsprintf(strTmp,"SEND: %s %s\r\n", + telstates[DONT-TELCMD_FIRST],teloptions[*st]); + OutputDebugString(strTmp); #endif - break; - } /* end switch */ - con->telstate=STNORM; - orig=++st; - break; + break; + } /* end switch */ + con->telstate=STNORM; + orig=++st; + break; - case WONTTEL: /* Received a telnet WONT option */ + case WONT: /* Received a telnet WONT option */ #ifdef NEGOTIATEDEBUG - wsprintf(strTmp,"RECV: %ls %ls\r\n", - telstates[con->telstate-LOW_TEL_OPT],teloptions[*st]); - OutputDebugString((LPSTR)strTmp); + wsprintf(strTmp,"RECV: %s %s\r\n", + telstates[con->telstate-TELCMD_FIRST],teloptions[*st]); + OutputDebugString((LPSTR)strTmp); #endif - con->telstate=STNORM; - switch(*st++) { /* which option? */ + con->telstate=STNORM; + switch(*st++) { /* which option? */ #ifdef NOT - case BINARY: /* WONT: binary */ - if(tw->ubinary) { /* binary */ - if(!tw->uwantbinary) { - netprintf(tw->pnum,"%c%c%c", - IAC,DONTTEL,BINARY); - if(tw->condebug>0) - tprintf(cv,"SEND: %ls %ls\r\n", - telstates[DONTTEL-LOW_TEL_OPT], - teloptions[BINARY]); - } /* end if */ - else - tw->uwantbinary=0; /* turn off this now */ - tw->ubinary=0; - tw->mapoutput=0; /* turn output mapping off */ - } /* end if */ - else { - if(tw->condebug>0) - tprintf(cv,"NO REPLY NEEDED: %ls %ls\r\n", - telstates[DONTTEL-LOW_TEL_OPT], - teloptions[BINARY]); - } /* end else */ - break; - -#endif - case ECHO: /* WONT: echo */ - if(con->echo) { - con->echo=0; - wsprintf(buf,"%c%c%c",IAC,DONTTEL,ECHO); - TelnetSend(ks,buf,lstrlen(buf),0); + case BINARY: /* WONT: binary */ + if(tw->ubinary) { /* binary */ + if(!tw->uwantbinary) { + netprintf(tw->pnum,"%c%c%c", + IAC,DONT,BINARY); + if(tw->condebug>0) + tprintf(cv,"SEND: %s %s\r\n", + telstates[DONT-TELCMD_FIRST], + teloptions[BINARY]); + } /* end if */ + else + tw->uwantbinary=0; /* turn off this now */ + tw->ubinary=0; + tw->mapoutput=0; /* turn output mapping off */ + } /* end if */ + else { + if(tw->condebug>0) + tprintf(cv,"NO REPLY NEEDED: %s %s\r\n", + telstates[DONT-TELCMD_FIRST], + teloptions[BINARY]); + } /* end else */ + break; + +#endif + case TELOPT_ECHO: /* WONT: echo */ + if(con->echo) { + con->echo=0; + wsprintf(buf,"%c%c%c",IAC,DONT,TELOPT_ECHO); + TelnetSend(ks,buf,lstrlen(buf),0); #ifdef NEGOTIATEDEBUG - wsprintf(strTmp,"SEND: %ls %ls\r\n", - telstates[DONTTEL-LOW_TEL_OPT], - teloptions[ECHO]); - OutputDebugString(strTmp); - OutputDebugString("Other side won't echo!"); -#endif - } /* end if */ - break; - - case TIMING: /* WONT: Telnet timing mark option */ - con->timing=0; - break; - - default: - break; - } /* end switch */ - orig=st; - break; - - case SB: /* telnet sub-options negotiation */ -// OutputDebugString("[SB]"); - con->telstate=NEGOTIATE; - orig=st; - end_sub=0; - sub_pos=con->substate=0; /* Defined for each */ + wsprintf(strTmp,"SEND: %s %s\r\n", + telstates[DONT-TELCMD_FIRST], + teloptions[TELOPT_ECHO]); + OutputDebugString(strTmp); + OutputDebugString("Other side won't echo!"); +#endif + } /* end if */ + break; + + case TELOPT_TM: /* WONT: Telnet timing mark option */ + con->timing=0; + break; + +#ifdef ENCRYPTION + case TELOPT_ENCRYPT: /* WONT: don't encrypt our input */ + break; +#endif + + default: + break; + } /* end switch */ + orig=st; + break; + + case SB: /* telnet sub-options negotiation */ + con->telstate=NEGOTIATE; + orig=st; + end_sub=0; + sub_pos=con->substate=0; /* Defined for each */ #ifdef OLD_WAY - break; + break; #endif - case NEGOTIATE: -// OutputDebugString("[NEG:"); -// OutputDebugString(st); + case NEGOTIATE: /* until we change sub-negotiation states, accumulate bytes */ - if(con->substate==0) { - if(*st==IAC) { /* check if we found an IAC byte */ - if(*(st+1)==IAC) { /* skip over double IAC's */ - st++; - parsedat[sub_pos++]=*st++; - } /* end if */ - else { - end_sub=sub_pos; - con->substate=*st++; - } /* end else */ - } /* end if */ - else /* otherwise, just stash the byte */ - parsedat[sub_pos++]=*st++; - } /* end if */ - else { - con->substate=*st++; - /* check if we've really ended the sub-negotiations */ - if(con->substate==SE) - parse_subnegotiat(ks,end_sub); - orig=st; - con->telstate=STNORM; - } /* end else */ - break; - - default: - con->telstate=STNORM; - break; - } /* end switch */ - } /* end while */ - -/* -* quick scan of the remaining string, skip chars while they are -* uninteresting -*/ - if(con->telstate==STNORM && stubinary) -// *st&=127; /* mask off high bit */ - st++; - } /* end while */ -// if(!tw->timing) -// parsewrite(tw,orig,st-orig); - orig=st; /* forget what we have sent already */ - if(sttelstate=IACFOUND; - st++; - break; - - default: -#ifdef NEGOTIATEDEBUG -// wsprintf(buf," strange char>128\r\n"); -// OutputDebugString(buf); + if(con->substate==0) { + if(*st==IAC) { /* check if we found an IAC byte */ + if(*(st+1)==IAC) { /* skip over double IAC's */ + st++; + parsedat[sub_pos++]=*st++; + } /* end if */ + else { + end_sub=sub_pos; + con->substate=*st++; + } /* end else */ + } /* end if */ + else /* otherwise, just stash the byte */ + parsedat[sub_pos++]=*st++; + } /* end if */ + else { + con->substate=*st++; + /* check if we've really ended the sub-negotiations */ + if(con->substate==SE) + parse_subnegotiat(ks,end_sub); + + orig=st; + /* + * XXX hack to decrypt the rest of the buffer + */ + if (encrypt_flag == 2) { + decrypt_ks_hack(orig, mark - orig); + encrypt_flag = 1; + } + + con->telstate=STNORM; + } /* end else */ + break; + + default: + con->telstate=STNORM; + break; + } /* end switch */ + } /* end while */ + + /* + * quick scan of the remaining string, skip chars while they are + * uninteresting + */ + if(con->telstate==STNORM && stubinary) + *st&=127; /* mask off high bit */ #endif - st++; - break; - } /* end switch */ - } /* end if */ + st++; } /* end while */ +#if 0 + if(!tw->timing) + parsewrite(tw,orig,st-orig); +#endif + orig=st; /* forget what we have sent already */ + if(sttelstate=IACFOUND; + st++; + break; + + default: +#ifdef NEGOTIATEDEBUG + wsprintf(buf," strange char>128 0x%x\r\n", *st); + OutputDebugString(buf); +#endif + st++; + break; + } /* end switch */ + } /* end if */ + } /* end while */ } /* end parse() */ - -/*+******************************************************************** -* Function : parse_subnegotiat() -* Purpose : Parse the telnet sub-negotiations read into the parsedat -* array. -* Parameters : -* end_sub - index of the character in the 'parsedat' array which -* is the last byte in a sub-negotiation -* Returns : none -* Calls : -* Called by : parse() -**********************************************************************/ +/* + * Function : parse_subnegotiat() + * Purpose : Parse the telnet sub-negotiations read into the parsedat + * array. + * Parameters : + * end_sub - index of the character in the 'parsedat' array which + * is the last byte in a sub-negotiation + * Returns : none + * Calls : + * Called by : parse() + */ static void -parse_subnegotiat(kstream ks,int end_sub) { - char buf[128]; - -// OutputDebugString("INTO SUBNEGOTIATE"); - switch(parsedat[0]) { - case TERMTYPE: -// OutputDebugString(":INTO TERMTYPE"); - if(parsedat[1]==1) { -/* QAK!!! */ wsprintf(buf,"%c%c%c%cvt100%c%c",IAC,SB,TERMTYPE,0,IAC,SE); - TelnetSend(ks,(LPSTR)buf,11,0); +parse_subnegotiat(kstream ks, int end_sub) +{ + char buf[128]; + + switch(parsedat[0]) { + case TELOPT_TTYPE: + if(parsedat[1]==1) { + /* QAK!!! */ wsprintf(buf,"%c%c%c%cvt100%c%c",IAC,SB,TELOPT_TTYPE, + 0,IAC,SE); + TelnetSend(ks,(LPSTR)buf,11,0); #ifdef NEGOTIATEDEBUG - wsprintf(strTmp,"SB TERMINAL-TYPE SEND\r\n" - "SEND: SB TERMINAL-TYPE IS vt100 \r\n len=%d \r\n", - lstrlen((LPSTR)buf)); -// OutputDebugString(strTmp); + wsprintf(strTmp,"SB TERMINAL-TYPE SEND\r\n" + "SEND: SB TERMINAL-TYPE IS vt100 \r\n len=%d \r\n", + lstrlen((LPSTR)buf)); + OutputDebugString(strTmp); #endif - } - break; - - case AUTHENTICATION: - auth_parse(ks, parsedat, end_sub); - break; - default: - break; - } /* end switch */ + } + break; + + case TELOPT_AUTHENTICATION: + auth_parse(ks, parsedat, end_sub); + break; +#ifdef ENCRYPTION + case TELOPT_ENCRYPT: + if (encrypt_flag) + encrypt_parse(ks, parsedat, end_sub); + break; +#endif + default: + break; + } /* end switch */ } /* parse_subnegotiat */ -/*+******************************************************************** -* Function : send_naws -* Purpose : Send a window size sub-negotiation. -* Parameters : -* ks - the kstream to send to. -* Returns : none -**********************************************************************/ +/* + * Function : send_naws + * Purpose : Send a window size sub-negotiation. + * Parameters : + * ks - the kstream to send to. + * Returns : none + */ void send_naws(CONNECTION *con) { - unsigned char buf[40]; - int len; + unsigned char buf[40]; + int len; - wsprintf(buf, "%c%c%c", IAC, SB, NAWS); - len = 3; + wsprintf(buf, "%c%c%c", IAC, SB, TELOPT_NAWS); + len = 3; - buf[len++] = HIBYTE(con->width); - if (buf[len-1] == IAC) buf[len++] = IAC; + buf[len++] = HIBYTE(con->width); + if (buf[len-1] == IAC) buf[len++] = IAC; - buf[len++] = LOBYTE(con->width); - if (buf[len-1] == IAC) buf[len++] = IAC; + buf[len++] = LOBYTE(con->width); + if (buf[len-1] == IAC) buf[len++] = IAC; - buf[len++] = HIBYTE(con->height); - if (buf[len-1] == IAC) buf[len++] = IAC; + buf[len++] = HIBYTE(con->height); + if (buf[len-1] == IAC) buf[len++] = IAC; - buf[len++] = LOBYTE(con->height); - if (buf[len-1] == IAC) buf[len++] = IAC; + buf[len++] = LOBYTE(con->height); + if (buf[len-1] == IAC) buf[len++] = IAC; - buf[len++] = IAC; - buf[len++] = SE; + buf[len++] = IAC; + buf[len++] = SE; - TelnetSend(con->ks, buf, len, 0); + TelnetSend(con->ks, buf, len, 0); - #ifdef NEGOTIATEDEBUG - wsprintf(buf, "SEND: SB NAWS %d %d %d %d IAC SE\r\n", - HIBYTE(con->width), LOBYTE(con->width), - HIBYTE(con->height), LOBYTE(con->height)); - OutputDebugString(buf); - #endif +#ifdef NEGOTIATEDEBUG + wsprintf(buf, "SEND: SB NAWS %d %d %d %d IAC SE\r\n", + HIBYTE(con->width), LOBYTE(con->width), + HIBYTE(con->height), LOBYTE(con->height)); + OutputDebugString(buf); +#endif } /* send_naws */ diff --git a/src/windows/wintel/resource.h b/src/windows/wintel/resource.h new file mode 100644 index 000000000..0d39d5ca0 --- /dev/null +++ b/src/windows/wintel/resource.h @@ -0,0 +1,17 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by telnet.rc +// +#define IDD_DIALOG1 101 +#define IDC_STATIC -1 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40005 +#define _APS_NEXT_CONTROL_VALUE 1002 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/src/windows/wintel/screen.c b/src/windows/wintel/screen.c index 505f23599..888103cdb 100644 --- a/src/windows/wintel/screen.c +++ b/src/windows/wintel/screen.c @@ -7,6 +7,10 @@ #include #include "telnet.h" #include "ini.h" +#include "auth.h" + +extern char *encrypt_output; /* XXX hack... I wonder if this will work. These are */ +extern char *decrypt_input; /* XXX really functions... */ extern char *cInvertedArray; extern int bMouseDown; @@ -16,1126 +20,1127 @@ static SCREEN *ScreenList; static HINSTANCE hInst; static char szScreenClass[] = "ScreenWClass"; static char szScreenMenu[] = "ScreenMenu"; -static char cursor_key[8][4] = { // Send for cursor keys - "\x1B[D", "\x1B[A", "\x1B[C", "\x1B[B", // Normal mode - "\x1BOD", "\x1BOA", "\x1BOC", "\x1BOB", // Numpad on mode +static char cursor_key[8][4] = { /* Send for cursor keys */ + "\x1B[D", "\x1B[A", "\x1B[C", "\x1B[B", /* Normal mode */ + "\x1BOD", "\x1BOA", "\x1BOC", "\x1BOB", /* Numpad on mode */ }; -void ScreenInit( - HINSTANCE hInstance) +void +ScreenInit(HINSTANCE hInstance) { - BOOL b; - WNDCLASS wc; + BOOL b; + WNDCLASS wc; - hInst = hInstance; - - ScreenList = NULL; + hInst = hInstance; - wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; /* Class style(s) */ - wc.lpfnWndProc = ScreenWndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = sizeof(long); - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(hInstance, "TERMINAL"); - wc.hCursor = LoadCursor(NULL, IDC_IBEAM); - wc.hbrBackground = GetStockObject(WHITE_BRUSH); - wc.lpszMenuName = szScreenMenu; - wc.lpszClassName = szScreenClass; + ScreenList = NULL; - b = RegisterClass(&wc); - assert(b); + wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; /* Class style(s) */ + wc.lpfnWndProc = ScreenWndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = sizeof(long); + wc.hInstance = hInstance; + wc.hIcon = LoadIcon(hInstance, "TERMINAL"); + wc.hCursor = LoadCursor(NULL, IDC_IBEAM); + wc.hbrBackground = GetStockObject(WHITE_BRUSH); + wc.lpszMenuName = szScreenMenu; + wc.lpszClassName = szScreenClass; -} /* ScreenInit */ + b = RegisterClass(&wc); + assert(b); +} -void SetScreenInstance( - HINSTANCE hInstance) +void +SetScreenInstance(HINSTANCE hInstance) { - hInst = hInstance; - -} /* SetScreenInstance */ - + hInst = hInstance; +} -int GetNewScreen(void) +int +GetNewScreen(void) { - SCREEN *pScr; - static int id = 0; - - pScr = (SCREEN *) calloc(sizeof(SCREEN), 1); - if (pScr == NULL) - return(-1); - - if (ScreenList == NULL) { - pScr->next = NULL; - pScr->prev = NULL; - } - else { - if (ScreenList->next == NULL) { - ScreenList->next = ScreenList; - ScreenList->prev = ScreenList; - } - pScr->next = ScreenList; - pScr->prev = ScreenList->prev; - ScreenList->prev->next = pScr; - ScreenList->prev = pScr; - } - - ScreenList = pScr; - return(id++); - -} /* GetNewScreen */ - - -SCREENLINE *ScreenNewLine(void) + SCREEN *pScr; + static int id = 0; + + pScr = (SCREEN *) calloc(sizeof(SCREEN), 1); + if (pScr == NULL) + return(-1); + + if (ScreenList == NULL) { + pScr->next = NULL; + pScr->prev = NULL; + } + else { + if (ScreenList->next == NULL) { + ScreenList->next = ScreenList; + ScreenList->prev = ScreenList; + } + pScr->next = ScreenList; + pScr->prev = ScreenList->prev; + ScreenList->prev->next = pScr; + ScreenList->prev = pScr; + } + + ScreenList = pScr; + return(id++); +} + +SCREENLINE * +ScreenNewLine(void) { - SCREENLINE *pScrLine; - - pScrLine = calloc(sizeof(SCREENLINE) + 2*MAX_LINE_WIDTH, 1); - if (pScrLine == NULL) - return (NULL); - pScrLine->text = &pScrLine->buffer[0]; - pScrLine->attrib = &pScrLine->buffer[MAX_LINE_WIDTH]; - return(pScrLine); - -} /* ScreenNewLine */ - - -static void MakeWindowTitle( - char *host, - int width, - int height, - char *title, - int nchars) + SCREENLINE *pScrLine; + + pScrLine = calloc(sizeof(SCREENLINE) + 2*MAX_LINE_WIDTH, 1); + if (pScrLine == NULL) + return (NULL); + pScrLine->text = &pScrLine->buffer[0]; + pScrLine->attrib = &pScrLine->buffer[MAX_LINE_WIDTH]; + return(pScrLine); +} + +static void +MakeWindowTitle(char *host, int width, int height, char *title, int nchars) { - char buf[128]; - int hlen; - - hlen = strlen(host); + char buf[128]; + int hlen; - title[0] = 0; + hlen = strlen(host); - if (hlen + 1 > nchars) - return; + title[0] = 0; - strcpy(title, host); + if (hlen + 1 > nchars) + return; - wsprintf(buf, " (%dh x %dw)", height, width); + strcpy(title, host); - if ((int) strlen(buf) + hlen + 1 > nchars) - return; + wsprintf(buf, " (%dh x %dw)", height, width); - strcat(title, buf); + if ((int) strlen(buf) + hlen + 1 > nchars) + return; -} /* MakeWindowTitle */ + strcat(title, buf); +} -SCREEN *InitNewScreen( - CONFIG *Config) +SCREEN * +InitNewScreen(CONFIG *Config) { - TEXTMETRIC tm; - HMENU hMenu = NULL; - SCREEN *scr = NULL; - SCREENLINE *pScrLine; - SCREENLINE *pScrLineLast; - int id; - int idx = 0; - char title[128]; - HDC hDC; - HFONT hFont; - - id = GetNewScreen(); - if (id == -1) - return(0); - - scr = ScreenList; - assert(scr != NULL); - - hMenu = LoadMenu(hInst, szScreenMenu); - assert(hMenu != NULL); - - scr->title = Config->title; - MakeWindowTitle(Config->title, Config->width, Config->height, title, sizeof(title)); - - scr->hwndTel = Config->hwndTel; /* save HWND of calling window */ - - if (Config->backspace) { - CheckMenuItem(hMenu, IDM_BACKSPACE, MF_CHECKED); - CheckMenuItem(hMenu, IDM_DELETE, MF_UNCHECKED); - } - else { - CheckMenuItem(hMenu, IDM_BACKSPACE, MF_UNCHECKED); - CheckMenuItem(hMenu, IDM_DELETE, MF_CHECKED); - } - - hDC = GetDC(NULL); - assert(hDC != NULL); - - scr->lf.lfPitchAndFamily = FIXED_PITCH; - GetPrivateProfileString(INI_FONT, "FaceName", "Courier", scr->lf. - lfFaceName, LF_FACESIZE, TELNET_INI); - scr->lf.lfHeight = (int) GetPrivateProfileInt(INI_FONT, "Height", 0, TELNET_INI); - scr->lf.lfWidth = (int) GetPrivateProfileInt(INI_FONT, "Width", 0, TELNET_INI); - scr->lf.lfPitchAndFamily = (BYTE) GetPrivateProfileInt(INI_FONT, "PitchAndFamily", 0, TELNET_INI); - scr->lf.lfCharSet = (BYTE) GetPrivateProfileInt(INI_FONT, "CharSet", 0, TELNET_INI); - scr->lf.lfEscapement = (BYTE) GetPrivateProfileInt(INI_FONT, "Escapement", 0, TELNET_INI); - scr->lf.lfQuality = PROOF_QUALITY; - scr->hSelectedFont = CreateFontIndirect((LPLOGFONT) &(scr->lf)); - hFont = SelectObject(hDC, scr->hSelectedFont); - GetTextMetrics(hDC, (LPTEXTMETRIC) &tm); - SelectObject(hDC, hFont); - scr->cxChar = tm.tmAveCharWidth; - scr->cyChar = tm.tmHeight + tm.tmExternalLeading; - - ReleaseDC(NULL, hDC); - - scr->width = Config->width; - scr->height = Config->height; - scr->ID = id; - scr->x = 0; - scr->y = 0; - scr->Oldx = 0; - scr->Oldy = 0; - scr->attrib = 0; - scr->DECAWM = 1; - scr->bWrapPending = FALSE; - scr->top = 0; - scr->bottom = scr->height-1; - scr->parmptr = 0; - scr->escflg = 0; - scr->bAlert = FALSE; - scr->numlines = 0; - scr->maxlines = 150; - - cInvertedArray = calloc(scr->width * scr->height, 1); - - pScrLineLast = ScreenNewLine(); - if (pScrLineLast == NULL) - return(NULL); - scr->screen_top = scr->buffer_top = pScrLineLast; - - for (idx = 0; idx < scr->height - 1; idx++) { - pScrLine = ScreenNewLine(); - if (pScrLine == NULL) - return(NULL); - pScrLine->prev = pScrLineLast; - pScrLineLast->next = pScrLine; - pScrLineLast = pScrLine; - } - - scr->screen_bottom = scr->buffer_bottom = pScrLine; - - scr->hWnd = CreateWindow(szScreenClass, title, WS_OVERLAPPEDWINDOW | WS_VSCROLL, - CW_USEDEFAULT, CW_USEDEFAULT, - scr->cxChar * scr->width + FRAME_WIDTH, - scr->cyChar * scr->height + FRAME_HEIGHT, - NULL, hMenu, hInst, scr); - assert(scr->hWnd != NULL); - - ShowWindow(scr->hWnd, SW_SHOW); - - CreateCaret(scr->hWnd, NULL, scr->cxChar, 2); - SetCaretPos(scr->x*scr->cxChar, (scr->y+1) * scr->cyChar); - ShowCaret(scr->hWnd); - - return(ScreenList); - -} /* InitNewScreen */ + TEXTMETRIC tm; + HMENU hMenu = NULL; + SCREEN *scr = NULL; + SCREENLINE *pScrLine; + SCREENLINE *pScrLineLast; + int id; + int idx = 0; + char title[128]; + HDC hDC; + HFONT hFont; + + id = GetNewScreen(); + if (id == -1) + return(0); + + scr = ScreenList; + assert(scr != NULL); + + hMenu = LoadMenu(hInst, szScreenMenu); + assert(hMenu != NULL); + + scr->title = Config->title; + MakeWindowTitle(Config->title, Config->width, Config->height, + title, sizeof(title)); + + scr->hwndTel = Config->hwndTel; /* save HWND of calling window */ + + if (Config->backspace) { + CheckMenuItem(hMenu, IDM_BACKSPACE, MF_CHECKED); + CheckMenuItem(hMenu, IDM_DELETE, MF_UNCHECKED); + } else { + CheckMenuItem(hMenu, IDM_BACKSPACE, MF_UNCHECKED); + CheckMenuItem(hMenu, IDM_DELETE, MF_CHECKED); + } + + hDC = GetDC(NULL); + assert(hDC != NULL); + + scr->lf.lfPitchAndFamily = FIXED_PITCH; + GetPrivateProfileString(INI_FONT, "FaceName", "Courier", scr->lf. + lfFaceName, LF_FACESIZE, TELNET_INI); + scr->lf.lfHeight = (int) GetPrivateProfileInt(INI_FONT, "Height", 0, TELNET_INI); + scr->lf.lfWidth = (int) GetPrivateProfileInt(INI_FONT, "Width", 0, TELNET_INI); + scr->lf.lfPitchAndFamily = (BYTE) GetPrivateProfileInt(INI_FONT, "PitchAndFamily", 0, TELNET_INI); + scr->lf.lfCharSet = (BYTE) GetPrivateProfileInt(INI_FONT, "CharSet", 0, TELNET_INI); + scr->lf.lfEscapement = (BYTE) GetPrivateProfileInt(INI_FONT, "Escapement", 0, TELNET_INI); + scr->lf.lfQuality = PROOF_QUALITY; + scr->hSelectedFont = CreateFontIndirect((LPLOGFONT) &(scr->lf)); + hFont = SelectObject(hDC, scr->hSelectedFont); + GetTextMetrics(hDC, (LPTEXTMETRIC) &tm); + SelectObject(hDC, hFont); + scr->cxChar = tm.tmAveCharWidth; + scr->cyChar = tm.tmHeight + tm.tmExternalLeading; + + ReleaseDC(NULL, hDC); + + scr->width = Config->width; + scr->height = Config->height; + scr->ID = id; + scr->x = 0; + scr->y = 0; + scr->Oldx = 0; + scr->Oldy = 0; + scr->attrib = 0; + scr->DECAWM = 1; + scr->bWrapPending = FALSE; + scr->top = 0; + scr->bottom = scr->height-1; + scr->parmptr = 0; + scr->escflg = 0; + scr->bAlert = FALSE; + scr->numlines = 0; + scr->maxlines = 150; + + cInvertedArray = calloc(scr->width * scr->height, 1); + + pScrLineLast = ScreenNewLine(); + if (pScrLineLast == NULL) + return(NULL); + scr->screen_top = scr->buffer_top = pScrLineLast; + + for (idx = 0; idx < scr->height - 1; idx++) { + pScrLine = ScreenNewLine(); + if (pScrLine == NULL) + return(NULL); + pScrLine->prev = pScrLineLast; + pScrLineLast->next = pScrLine; + pScrLineLast = pScrLine; + } + + scr->screen_bottom = scr->buffer_bottom = pScrLine; + + scr->hWnd = CreateWindow(szScreenClass, title, WS_OVERLAPPEDWINDOW | WS_VSCROLL, + CW_USEDEFAULT, CW_USEDEFAULT, + scr->cxChar * scr->width + FRAME_WIDTH, + scr->cyChar * scr->height + FRAME_HEIGHT, + NULL, hMenu, hInst, scr); + assert(scr->hWnd != NULL); + + ShowWindow(scr->hWnd, SW_SHOW); + + CreateCaret(scr->hWnd, NULL, scr->cxChar, 2); + SetCaretPos(scr->x*scr->cxChar, (scr->y+1) * scr->cyChar); + ShowCaret(scr->hWnd); + + return(ScreenList); +} void DeleteTopLine( - SCREEN *pScr) + SCREEN *pScr) { - assert(pScr->buffer_top != NULL); + assert(pScr->buffer_top != NULL); - pScr->buffer_top = pScr->buffer_top->next; - assert(pScr->buffer_top != NULL); + pScr->buffer_top = pScr->buffer_top->next; + assert(pScr->buffer_top != NULL); - pScr->buffer_top->prev = NULL; + pScr->buffer_top->prev = NULL; - pScr->numlines--; + pScr->numlines--; } /* DeleteTopLine */ static void SetScreenScrollBar( - SCREEN *pScr) + SCREEN *pScr) { - if (pScr->numlines <= 0) { - SetScrollRange(pScr->hWnd, SB_VERT, 0, 100, FALSE); - SetScrollPos(pScr->hWnd, SB_VERT, 0, TRUE); - EnableScrollBar(pScr->hWnd, SB_VERT, ESB_DISABLE_BOTH); - } - else { - SetScrollRange(pScr->hWnd, SB_VERT, 0, pScr->numlines, FALSE); - SetScrollPos(pScr->hWnd, SB_VERT, pScr->numlines, TRUE); - EnableScrollBar(pScr->hWnd, SB_VERT, ESB_ENABLE_BOTH); - } + if (pScr->numlines <= 0) { + SetScrollRange(pScr->hWnd, SB_VERT, 0, 100, FALSE); + SetScrollPos(pScr->hWnd, SB_VERT, 0, TRUE); + EnableScrollBar(pScr->hWnd, SB_VERT, ESB_DISABLE_BOTH); + } + else { + SetScrollRange(pScr->hWnd, SB_VERT, 0, pScr->numlines, FALSE); + SetScrollPos(pScr->hWnd, SB_VERT, pScr->numlines, TRUE); + EnableScrollBar(pScr->hWnd, SB_VERT, ESB_ENABLE_BOTH); + } } /* SetScreenScrollBar */ int ScreenScroll( - SCREEN *pScr) + SCREEN *pScr) { - SCREENLINE *pScrLine; - SCREENLINE *pPrev; - SCREENLINE *pNext; - SCREENLINE *pScrollTop; - SCREENLINE *pScrollBottom; - BOOL bFullScreen = TRUE; - HDC hDC; - RECT rc; + SCREENLINE *pScrLine; + SCREENLINE *pPrev; + SCREENLINE *pNext; + SCREENLINE *pScrollTop; + SCREENLINE *pScrollBottom; + BOOL bFullScreen = TRUE; + HDC hDC; + RECT rc; + + Edit_ClearSelection(pScr); + + pScrollTop = GetScreenLineFromY(pScr, pScr->top); + + pScrollBottom = GetScreenLineFromY(pScr, pScr->bottom); + + if (pScrollTop != pScr->screen_top) { + bFullScreen = FALSE; + rc.left = 0; + rc.right = pScr->cxChar * pScr->width; + rc.top = pScr->cyChar * (pScr->top); + rc.bottom = pScr->cyChar * (pScr->bottom+1); + + pNext = pScrollTop->next; + pPrev = pScrollTop->prev; + + pPrev->next = pNext; + pNext->prev = pPrev; + + pScrLine = pScrollTop; + ScreenClearLine(pScr, pScrLine); + } + else { + pScr->numlines++; + pScrLine = ScreenNewLine(); + if (pScrLine == NULL) + return(0); + pScr->screen_top = pScrollTop->next; + } + + if (pScrLine == NULL) + return(0); + + pNext = pScrollBottom->next; + pScrollBottom->next = pScrLine; + pScrLine->next = pNext; + pScrLine->prev = pScrollBottom; + if (pNext != NULL) + pNext->prev = pScrLine; + + if (pScrollBottom != pScr->screen_bottom) { + bFullScreen = FALSE; + rc.left = 0; + rc.right = pScr->cxChar * pScr->width; + rc.top = pScr->cyChar * pScr->top; + rc.bottom = pScr->cyChar * (pScr->bottom+1); + } + else { + if (pScr->screen_bottom == pScr->buffer_bottom) + pScr->buffer_bottom = pScrLine; + pScr->screen_bottom = pScrLine; + } + +#if 0 + CheckScreen(fpScr); +#endif - Edit_ClearSelection(pScr); + pScr->y++; - pScrollTop = GetScreenLineFromY(pScr, pScr->top); + if (pScr->y > pScr->bottom) + pScr->y = pScr->bottom; - pScrollBottom = GetScreenLineFromY(pScr, pScr->bottom); + hDC = GetDC(pScr->hWnd); + assert(hDC != NULL); - if (pScrollTop != pScr->screen_top) { - bFullScreen = FALSE; - rc.left = 0; - rc.right = pScr->cxChar * pScr->width; - rc.top = pScr->cyChar * (pScr->top); - rc.bottom = pScr->cyChar * (pScr->bottom+1); + if (bFullScreen) + ScrollDC(hDC, 0, -pScr->cyChar, NULL, NULL, NULL, NULL); + else + ScrollDC(hDC, 0, -pScr->cyChar, &rc, &rc, NULL, NULL); - pNext = pScrollTop->next; - pPrev = pScrollTop->prev; + PatBlt(hDC, 0, pScr->bottom * pScr->cyChar, + pScr->width * pScr->cxChar, pScr->cyChar, WHITENESS); - pPrev->next = pNext; - pNext->prev = pPrev; + ReleaseDC(pScr->hWnd, hDC); - pScrLine = pScrollTop; - ScreenClearLine(pScr, pScrLine); - } - else { - pScr->numlines++; - pScrLine = ScreenNewLine(); - if (pScrLine == NULL) - return(0); - pScr->screen_top = pScrollTop->next; - } - - if (pScrLine == NULL) - return(0); - - pNext = pScrollBottom->next; - pScrollBottom->next = pScrLine; - pScrLine->next = pNext; - pScrLine->prev = pScrollBottom; - if (pNext != NULL) - pNext->prev = pScrLine; - - if (pScrollBottom != pScr->screen_bottom) { - bFullScreen = FALSE; - rc.left = 0; - rc.right = pScr->cxChar * pScr->width; - rc.top = pScr->cyChar * pScr->top; - rc.bottom = pScr->cyChar * (pScr->bottom+1); - } - else { - if (pScr->screen_bottom == pScr->buffer_bottom) - pScr->buffer_bottom = pScrLine; - pScr->screen_bottom = pScrLine; - } + if (pScr->numlines == pScr->maxlines) + DeleteTopLine(pScr); + else + SetScreenScrollBar(pScr); -// CheckScreen(fpScr); + return(1); - pScr->y++; +} /* ScreenScroll */ - if (pScr->y > pScr->bottom) - pScr->y = pScr->bottom; - hDC = GetDC(pScr->hWnd); - assert(hDC != NULL); +int DrawTextScreen( + RECT rcInvalid, + SCREEN *pScr, + HDC hDC) +{ + SCREENLINE *pScrLineTmp; + SCREENLINE *pScrLine; + int x = 0; + int y = 0; + int left = 0; + int right = 0; + int i; + int len; + char attrib; +#define YPOS (y*pScr->cyChar) - if (bFullScreen) - ScrollDC(hDC, 0, -pScr->cyChar, NULL, NULL, NULL, NULL); - else - ScrollDC(hDC, 0, -pScr->cyChar, &rc, &rc, NULL, NULL); + pScrLine = pScr->screen_top; - PatBlt(hDC, 0, pScr->bottom * pScr->cyChar, - pScr->width * pScr->cxChar, pScr->cyChar, WHITENESS); - - ReleaseDC(pScr->hWnd, hDC); + for (y = 0; y < pScr->height; y++) { + if (!pScrLine) + continue; - if (pScr->numlines == pScr->maxlines) - DeleteTopLine(pScr); - else - SetScreenScrollBar(pScr); + if (YPOS >= rcInvalid.top - pScr->cyChar && + YPOS <= rcInvalid.bottom + pScr->cyChar) { - return(1); + if (y < 0) + y = 0; -} /* ScreenScroll */ + if (y >= pScr->height) + y = pScr->height - 1; + left = (rcInvalid.left / pScr->cxChar) - 1; -int DrawTextScreen( - RECT rcInvalid, - SCREEN *pScr, - HDC hDC) -{ - SCREENLINE *pScrLineTmp; - SCREENLINE *pScrLine; - int x = 0; - int y = 0; - int left = 0; - int right = 0; - int i; - int len; - char attrib; - #define YPOS (y*pScr->cyChar) - - pScrLine = pScr->screen_top; - - for (y = 0; y < pScr->height; y++) { - if (!pScrLine) - continue; - - if (YPOS >= rcInvalid.top - pScr->cyChar && - YPOS <= rcInvalid.bottom + pScr->cyChar) { - - if (y < 0) - y = 0; - - if (y >= pScr->height) - y = pScr->height - 1; - - left = (rcInvalid.left / pScr->cxChar) - 1; - - right = (rcInvalid.right / pScr->cxChar) + 1; - - if (left < 0) - left = 0; - - if (right > pScr->width - 1) - right = pScr->width - 1; - - x = left; - - while (x <= right) { - if (!pScrLine->text[x]) { - x++; - continue; - } - - if (SCR_isrev(pScrLine->attrib[x])) { - SelectObject(hDC, pScr->hSelectedFont); - SetTextColor(hDC, RGB(255, 255, 255)); - SetBkColor(hDC, RGB(0, 0, 0)); - } - else if (SCR_isblnk(pScrLine->attrib[x])) { - SelectObject(hDC, pScr->hSelectedFont); - SetTextColor(hDC, RGB(255, 0, 0)); - SetBkColor(hDC, RGB(255, 255, 255)); - } - else if (SCR_isundl(pScrLine->attrib[x])) { - SetTextColor(hDC, RGB(255, 0, 0)); - SetBkColor(hDC, RGB(255, 255, 255)); - SelectObject(hDC, pScr->hSelectedULFont); - } - else { - SelectObject(hDC,pScr->hSelectedFont); - SetTextColor(hDC, RGB(0, 0, 0)); - SetBkColor(hDC, RGB(255, 255, 255)); - } - - len = 1; - attrib = pScrLine->attrib[x]; - for (i = x + 1; i <= right; i++) { - if (pScrLine->attrib[i] != attrib || !pScrLine->text[i]) - break; - len++; - } - - TextOut(hDC, x*pScr->cxChar, y*pScr->cyChar, &pScrLine->text[x], len); - x += len; - } - } - pScrLineTmp = pScrLine->next; - pScrLine = pScrLineTmp; + right = (rcInvalid.right / pScr->cxChar) + 1; + + if (left < 0) + left = 0; + + if (right > pScr->width - 1) + right = pScr->width - 1; + + x = left; + + while (x <= right) { + if (!pScrLine->text[x]) { + x++; + continue; + } + + if (SCR_isrev(pScrLine->attrib[x])) { + SelectObject(hDC, pScr->hSelectedFont); + SetTextColor(hDC, RGB(255, 255, 255)); + SetBkColor(hDC, RGB(0, 0, 0)); + } + else if (SCR_isblnk(pScrLine->attrib[x])) { + SelectObject(hDC, pScr->hSelectedFont); + SetTextColor(hDC, RGB(255, 0, 0)); + SetBkColor(hDC, RGB(255, 255, 255)); + } + else if (SCR_isundl(pScrLine->attrib[x])) { + SetTextColor(hDC, RGB(255, 0, 0)); + SetBkColor(hDC, RGB(255, 255, 255)); + SelectObject(hDC, pScr->hSelectedULFont); + } + else { + SelectObject(hDC,pScr->hSelectedFont); + SetTextColor(hDC, RGB(0, 0, 0)); + SetBkColor(hDC, RGB(255, 255, 255)); + } + + len = 1; + attrib = pScrLine->attrib[x]; + for (i = x + 1; i <= right; i++) { + if (pScrLine->attrib[i] != attrib || !pScrLine->text[i]) + break; + len++; } - return(0); + TextOut(hDC, x*pScr->cxChar, y*pScr->cyChar, &pScrLine->text[x], len); + x += len; + } + } + pScrLineTmp = pScrLine->next; + pScrLine = pScrLineTmp; + } + + return(0); } /* DrawTextScreen */ static BOOL SetInternalScreenSize( - SCREEN *pScr, - int width, - int height) + SCREEN *pScr, + int width, + int height) { - RECT rc; - char *p; - int idx; - int n; - int newlines; - SCREENLINE *pNewLine; - SCREENLINE *pTopLine; - SCREENLINE *pBottomLine; - #if 0 - int col; - int row; - int dydestbottom; - #endif - - GetClientRect(pScr->hWnd, &rc); - - width = (rc.right - rc.left) / pScr->cxChar; - height = (rc.bottom - rc.top) / pScr->cyChar; - - if (pScr->height == height && pScr->width == width) - return(FALSE); - - pScr->Oldx = 0; - pScr->Oldy = 0; - pScr->attrib = 0; - - /* - Reallocate the inverted array of bytes and copy the values - from the old screen to the new screen. - */ - p = calloc(width * height, 1); - - ScreenCursorOff(pScr); - - #if 0 /* Copy inversion array to desitination */ - for (col = 0; col < width; col++) { - for (row = 0; row < height; row++) { - dydestbottom = height - 1 - row; - if (col < pScr->width && dydestbottom < pScr->height - 1) - p[row * width + col] = - cInvertedArray[(pScr->height - 1 - dydestbottom) * pScr->width + col]; - } - } - #endif - - free(cInvertedArray); - cInvertedArray = p; - - /* - Append any new lines which need to be added to accomodate the new - screen size. - */ - pBottomLine = pScr->buffer_bottom; - newlines = height - (pScr->height + pScr->numlines); - - if (newlines > 0) { - pScr->y += pScr->numlines; - pScr->numlines = 0; - - for (idx = 0; idx < newlines; idx++) { - pNewLine = ScreenNewLine(); - if (pNewLine == NULL) - return(FALSE); - pNewLine->prev = pBottomLine; - if (pBottomLine == NULL) - return(FALSE); - pBottomLine->next = pNewLine; - pBottomLine = pNewLine; - } - } + RECT rc; + char *p; + int idx; + int n; + int newlines; + SCREENLINE *pNewLine; + SCREENLINE *pTopLine; + SCREENLINE *pBottomLine; +#if 0 + int col; + int row; + int dydestbottom; +#endif - /* - If we already have plenty of lines, then we need to get rid of the - scrollback lines, if too many exist. The cursor should end up - the same distance from the bottom of the screen as is started out - in this instance. - */ - if (newlines < 0) { - pScr->y = (height - 1) - (pScr->bottom - pScr->y); - if (pScr->y < 0) - pScr->y = 0; - pScr->numlines = -newlines; - n = pScr->numlines - pScr->maxlines; - for (idx = 0; idx < n; idx++) - DeleteTopLine(pScr); - } - - /* - Calculate the position of the buffer relative to the screen. - */ - pScr->screen_bottom = pBottomLine; - pScr->buffer_bottom = pBottomLine; + GetClientRect(pScr->hWnd, &rc); - pTopLine = pBottomLine; + width = (rc.right - rc.left) / pScr->cxChar; + height = (rc.bottom - rc.top) / pScr->cyChar; - for (idx = 1; idx < height; idx++) { - pTopLine = pTopLine->prev; - } + if (pScr->height == height && pScr->width == width) + return(FALSE); - pScr->screen_top = pTopLine; - pScr->width = width; - pScr->height = height; - pScr->top = 0; - pScr->bottom = height - 1; + pScr->Oldx = 0; + pScr->Oldy = 0; + pScr->attrib = 0; - if (pScr->x >= width) - pScr->x = width - 1; + /* + Reallocate the inverted array of bytes and copy the values + from the old screen to the new screen. + */ + p = calloc(width * height, 1); - if (pScr->y >= height) - pScr->y = height - 1; + ScreenCursorOff(pScr); + +#if 0 /* Copy inversion array to desitination */ + for (col = 0; col < width; col++) { + for (row = 0; row < height; row++) { + dydestbottom = height - 1 - row; + if (col < pScr->width && dydestbottom < pScr->height - 1) + p[row * width + col] = + cInvertedArray[(pScr->height - 1 - dydestbottom) * pScr->width + col]; + } + } +#endif - SetScreenScrollBar(pScr); - ScreenCursorOn(pScr); - return(TRUE); + free(cInvertedArray); + cInvertedArray = p; + + /* + Append any new lines which need to be added to accomodate the new + screen size. + */ + pBottomLine = pScr->buffer_bottom; + newlines = height - (pScr->height + pScr->numlines); + + if (newlines > 0) { + pScr->y += pScr->numlines; + pScr->numlines = 0; + + for (idx = 0; idx < newlines; idx++) { + pNewLine = ScreenNewLine(); + if (pNewLine == NULL) + return(FALSE); + pNewLine->prev = pBottomLine; + if (pBottomLine == NULL) + return(FALSE); + pBottomLine->next = pNewLine; + pBottomLine = pNewLine; + } + } + + /* + If we already have plenty of lines, then we need to get rid of the + scrollback lines, if too many exist. The cursor should end up + the same distance from the bottom of the screen as is started out + in this instance. + */ + if (newlines < 0) { + pScr->y = (height - 1) - (pScr->bottom - pScr->y); + if (pScr->y < 0) + pScr->y = 0; + pScr->numlines = -newlines; + n = pScr->numlines - pScr->maxlines; + for (idx = 0; idx < n; idx++) + DeleteTopLine(pScr); + } + + /* + Calculate the position of the buffer relative to the screen. + */ + pScr->screen_bottom = pBottomLine; + pScr->buffer_bottom = pBottomLine; + + pTopLine = pBottomLine; + + for (idx = 1; idx < height; idx++) { + pTopLine = pTopLine->prev; + } + + pScr->screen_top = pTopLine; + pScr->width = width; + pScr->height = height; + pScr->top = 0; + pScr->bottom = height - 1; + + if (pScr->x >= width) + pScr->x = width - 1; + + if (pScr->y >= height) + pScr->y = height - 1; + + SetScreenScrollBar(pScr); + ScreenCursorOn(pScr); + return(TRUE); } /* SetInternalScreenSize */ static int ScreenAdjustUp( - SCREEN *pScr, - int n) + SCREEN *pScr, + int n) { - int idx; - SCREENLINE *pLine1; - SCREENLINE *pLine2; - - for (idx = 0; idx < n; idx++) { - if (pScr->screen_top == pScr->buffer_top) - return(-idx); - pLine1 = pScr->screen_top->prev; - if (pLine1 == NULL) - return(-idx); - pLine2 = pScr->screen_bottom->prev; - if (pLine2 == NULL) - return(-idx); - pScr->screen_top = pLine1; - pScr->screen_bottom = pLine2; - } - - return(idx); + int idx; + SCREENLINE *pLine1; + SCREENLINE *pLine2; + + for (idx = 0; idx < n; idx++) { + if (pScr->screen_top == pScr->buffer_top) + return(-idx); + pLine1 = pScr->screen_top->prev; + if (pLine1 == NULL) + return(-idx); + pLine2 = pScr->screen_bottom->prev; + if (pLine2 == NULL) + return(-idx); + pScr->screen_top = pLine1; + pScr->screen_bottom = pLine2; + } + + return(idx); } /* ScreenAdjustUp */ static int ScreenAdjustDown( - SCREEN *pScr, - int n) + SCREEN *pScr, + int n) { - int idx; - SCREENLINE *pLine1; - SCREENLINE *pLine2; - - for (idx = 0; idx < n; idx++) { - if (pScr->screen_bottom == pScr->buffer_bottom) - return(-idx); - pLine1 = pScr->screen_top->next; - if (pLine1 == NULL) - return(-idx); - pLine2 = pScr->screen_bottom->next; - if (pLine2 == NULL) - return(-idx); - pScr->screen_top = pLine1; - pScr->screen_bottom = pLine2; - } - - return(idx); + int idx; + SCREENLINE *pLine1; + SCREENLINE *pLine2; + + for (idx = 0; idx < n; idx++) { + if (pScr->screen_bottom == pScr->buffer_bottom) + return(-idx); + pLine1 = pScr->screen_top->next; + if (pLine1 == NULL) + return(-idx); + pLine2 = pScr->screen_bottom->next; + if (pLine2 == NULL) + return(-idx); + pScr->screen_top = pLine1; + pScr->screen_bottom = pLine2; + } + + return(idx); } /* ScreenAdjustDown */ long FAR PASCAL ScreenWndProc( - HWND hWnd, - UINT message, - WPARAM wParam, - LPARAM lParam) + HWND hWnd, + UINT message, + WPARAM wParam, + LPARAM lParam) { - MINMAXINFO *lpmmi; - SCREEN *pScr; - HMENU hMenu; - PAINTSTRUCT ps; - int x = 0; - int y = 0; - int ScrollPos; - int tmpScroll = 0; - int idx; - HDC hDC; - RECT rc; - char title[128]; - static int bDoubleClick = FALSE; - - switch (message) { - - case WM_COMMAND: - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert (pScr != NULL); - - switch (wParam) { - - case IDM_BACKSPACE: - hMenu = GetMenu(hWnd); - CheckMenuItem(hMenu, IDM_BACKSPACE, MF_CHECKED); - CheckMenuItem(hMenu, IDM_DELETE, MF_UNCHECKED); - SendMessage(pScr->hwndTel, WM_MYSCREENCHANGEBKSP, VK_BACK, (LPARAM) pScr); - break; - - case IDM_DELETE: - hMenu = GetMenu(hWnd); - CheckMenuItem(hMenu, IDM_BACKSPACE, MF_UNCHECKED); - CheckMenuItem(hMenu, IDM_DELETE, MF_CHECKED); - SendMessage(pScr->hwndTel, WM_MYSCREENCHANGEBKSP, 0x7f, (LPARAM) pScr); - break; - - case IDM_FONT: - ScreenCursorOff(pScr); - ProcessFontChange(hWnd); - ScreenCursorOn(pScr); - break; - - case IDM_COPY: - Edit_Copy(hWnd); - hMenu=GetMenu(hWnd); - Edit_ClearSelection(pScr); - break; - - case IDM_PASTE: - Edit_Paste(hWnd); - break; - - case IDM_ABOUT: + MINMAXINFO *lpmmi; + SCREEN *pScr; + HMENU hMenu; + PAINTSTRUCT ps; + int x = 0; + int y = 0; + int ScrollPos; + int tmpScroll = 0; + int idx; + HDC hDC; + RECT rc; + char title[128]; + static int bDoubleClick = FALSE; + + switch (message) { + + case WM_COMMAND: + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert (pScr != NULL); + + switch (wParam) { + + case IDM_EXIT: + if (MessageBox(hWnd, "Terminate this connection?", "Telnet", MB_OKCANCEL) == IDOK) { + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert (pScr != NULL); + SendMessage(pScr->hwndTel, WM_MYSCREENCLOSE, 0, (LPARAM) pScr); + } + break; + + case IDM_BACKSPACE: + hMenu = GetMenu(hWnd); + CheckMenuItem(hMenu, IDM_BACKSPACE, MF_CHECKED); + CheckMenuItem(hMenu, IDM_DELETE, MF_UNCHECKED); + SendMessage(pScr->hwndTel, WM_MYSCREENCHANGEBKSP, VK_BACK, (LPARAM) pScr); + break; + + case IDM_DELETE: + hMenu = GetMenu(hWnd); + CheckMenuItem(hMenu, IDM_BACKSPACE, MF_UNCHECKED); + CheckMenuItem(hMenu, IDM_DELETE, MF_CHECKED); + SendMessage(pScr->hwndTel, WM_MYSCREENCHANGEBKSP, 0x7f, (LPARAM) pScr); + break; + + case IDM_FONT: + ScreenCursorOff(pScr); + ProcessFontChange(hWnd); + ScreenCursorOn(pScr); + break; + + case IDM_COPY: + Edit_Copy(hWnd); + hMenu=GetMenu(hWnd); + Edit_ClearSelection(pScr); + break; + + case IDM_PASTE: + Edit_Paste(hWnd); + break; + + case IDM_HELP_INDEX: + WinHelp(hWnd, HELP_FILE, HELP_INDEX, 0); + break; + + case IDM_ABOUT: #ifdef CYGNUS #ifdef KRB4 - strcpy(strTmp, " Kerberos 4 for Windows\n"); + strcpy(strTmp, " Kerberos 4 for Windows\n"); #endif #ifdef KRB5 - strcpy(strTmp, " Kerberos 5 for Windows\n"); + strcpy(strTmp, " KerbNet for Windows\n"); #endif - strcat(strTmp, "\n Version 1.00\n\n"); - strcat(strTmp, " For support, contact:\n"); - strcat(strTmp, "Cygnus Support"); - strcat(strTmp, " - (415) 903-1400"); -#else - strcpy(strTmp, " Kerberos 5 Telnet for Windows\n"); - strcat(strTmp, "\n Version 1.00\n\n"); + strcat(strTmp, "\n Version 1.00\n\n"); + strcat(strTmp, " For support, contact:\n"); + strcat(strTmp, " Cygnus Support - (415) 903-1400\n"); +#else /* CYGNUS */ + strcpy(strTmp, " Kerberos 5 Telnet for Windows\n"); + strcat(strTmp, " ALPHA SNAPSHOT 1\n\n"); +#endif /* CYGNUS */ + if (encrypt_flag) { + strcat(strTmp, "\n[Encryption of output requested. State: "); + strcat(strTmp, (encrypt_output ? "encrypting]" : "INACTIVE]")); + strcat(strTmp, "\n[Decryption of input requested. State: "); + strcat(strTmp, (decrypt_input ? "decrypting]\n" : "INACTIVE]\n")); + } + MessageBox(NULL, strTmp, "Kerberos", MB_OK); + break; + +#if defined(DEBUG) + case IDM_DEBUG: + CheckScreen(pScr); + break; #endif - MessageBox(NULL, strTmp, "Kerberos", MB_OK); - break; - - #if ! defined(NDEBUG) - case IDM_DEBUG: - CheckScreen(pScr); - break; - #endif - } - - break; - - case WM_NCCREATE: - pScr = (SCREEN *) ((LPCREATESTRUCT) lParam)->lpCreateParams; - pScr->hWnd = hWnd; - SetWindowLong(hWnd, SCREEN_HANDLE, (LONG) pScr); - SetScrollRange(hWnd, SB_VERT, 0, 100, FALSE); - SetScrollPos(hWnd, SB_VERT, 0, TRUE); - EnableScrollBar(hWnd, SB_VERT, ESB_DISABLE_BOTH); - return(TRUE); - - case WM_VSCROLL: - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert (pScr != NULL); - - ScreenCursorOff(pScr); - - switch(wParam) { - - case SB_LINEDOWN: - if (ScreenAdjustDown(pScr, 1) <= 0) - break; - hDC = GetDC(hWnd); - assert(hDC != NULL); - rc.left = 0; - rc.right = pScr->cxChar * pScr->width; - rc.top = 0; - rc.bottom = pScr->cyChar * (pScr->bottom + 1); - ScrollDC(hDC, 0, -pScr->cyChar, &rc, &rc, NULL, NULL); - ReleaseDC(hWnd, hDC); - rc.top = pScr->cyChar * pScr->bottom; - InvalidateRect(hWnd, &rc, TRUE); - ScrollPos = GetScrollPos(hWnd, SB_VERT); - SetScrollPos(hWnd, SB_VERT, ScrollPos + 1, TRUE); - UpdateWindow(hWnd); - break; - - case SB_LINEUP: - if (ScreenAdjustUp(pScr, 1) <= 0) - break; - hDC = GetDC(hWnd); - assert(hDC != NULL); - rc.left = 0; - rc.right = pScr->cxChar * pScr->width; - rc.top = 0; - rc.bottom = pScr->cyChar * (pScr->bottom + 1); - ScrollDC(hDC, 0, pScr->cyChar, &rc, &rc, NULL, NULL); - ReleaseDC(hWnd, hDC); - rc.bottom = pScr->cyChar; - InvalidateRect(hWnd, &rc, TRUE); - ScrollPos = GetScrollPos(pScr->hWnd, SB_VERT); - SetScrollPos(hWnd,SB_VERT, ScrollPos - 1, TRUE); - UpdateWindow(hWnd); - break; - - case SB_PAGEDOWN: - idx = abs(ScreenAdjustDown(pScr, pScr->height)); - hDC = GetDC(hWnd); - assert(hDC != NULL); - rc.left = 0; - rc.right = pScr->cxChar * pScr->width; - rc.top = 0; - rc.bottom = pScr->cyChar * (pScr->bottom+1); - ScrollDC(hDC, 0, -idx * pScr->cyChar, &rc, &rc, NULL, NULL); - ReleaseDC(hWnd, hDC); - rc.top = pScr->cyChar * (pScr->bottom - idx + 1); - InvalidateRect(hWnd, &rc, TRUE); - ScrollPos=GetScrollPos(hWnd, SB_VERT); - SetScrollPos(hWnd, SB_VERT, ScrollPos + idx, TRUE); - break; - - case SB_PAGEUP: - idx = abs(ScreenAdjustUp(pScr, pScr->height)); - hDC = GetDC(hWnd); - assert(hDC != NULL); - rc.left = 0; - rc.right = pScr->cxChar * pScr->width; - rc.top = 0; - rc.bottom = pScr->cyChar * (pScr->bottom + 1); - ScrollDC(hDC, 0, idx * pScr->cyChar, &rc, &rc, NULL, NULL); - ReleaseDC(hWnd, hDC); - rc.bottom = idx * pScr->cyChar; - InvalidateRect(hWnd, &rc, TRUE); - ScrollPos=GetScrollPos(hWnd, SB_VERT); - SetScrollPos(hWnd, SB_VERT, ScrollPos - idx, TRUE); - break; - - case SB_THUMBPOSITION: - case SB_THUMBTRACK: - ScrollPos = GetScrollPos(hWnd, SB_VERT); - tmpScroll = ScrollPos - LOWORD(lParam); - if (tmpScroll == 0) - break; - if (tmpScroll > 0) - ScreenAdjustUp(pScr, tmpScroll); - else - ScreenAdjustDown(pScr, -tmpScroll); - if (abs(tmpScroll) < pScr->height) { - hDC = GetDC(hWnd); - assert(hDC != NULL); - rc.left = 0; - rc.right = pScr->cxChar * pScr->width; - rc.top = 0; - rc.bottom = pScr->cyChar * (pScr->bottom + 1); - ScrollDC(hDC, 0, tmpScroll * pScr->cyChar, &rc, &rc, NULL, NULL); - ReleaseDC(hWnd, hDC); - if (tmpScroll > 0) { - rc.bottom = tmpScroll * pScr->cyChar; - InvalidateRect(hWnd, &rc, TRUE); - } - else { - rc.top = (pScr->bottom + tmpScroll + 1) * pScr->cyChar; - InvalidateRect(hWnd, &rc, TRUE); - } - } - else - InvalidateRect(hWnd, NULL, TRUE); - - SetScrollPos(hWnd, SB_VERT, LOWORD(lParam), TRUE); - UpdateWindow(hWnd); - break; - } - - ScreenCursorOn(pScr); - break; - - case WM_KEYDOWN: - if (wParam == VK_INSERT) { - if (GetKeyState(VK_SHIFT) < 0) - PostMessage(hWnd, WM_COMMAND, IDM_PASTE, NULL); - else if (GetKeyState(VK_CONTROL) < 0) - PostMessage(hWnd, WM_COMMAND, IDM_COPY, NULL); - break; - } - /* - ** Check for cursor keys. With control pressed, we treat as - ** keyboard equivalents to scrolling. Otherwise, we send - ** a WM_MYCURSORKEY message with the appropriate string - ** to be sent. Sending the actual string allows the upper - ** level to be ignorant of keyboard modes, etc. - */ - if (wParam < VK_PRIOR || wParam > VK_DOWN) // Is it a cursor key? - break; - - if (GetKeyState (VK_CONTROL) >= 0) { // No control key - if (wParam >= VK_LEFT && wParam <= VK_DOWN) { - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert (pScr != NULL); - wParam = wParam - VK_LEFT + (pScr->DECCKM ? 4 : 0); - SendMessage (pScr->hwndTel, WM_MYCURSORKEY, - strlen(cursor_key[wParam]), - (LPARAM) (char FAR *) cursor_key[wParam]); - } - } else { // Control is down - switch (wParam) { - case VK_PRIOR: /* Page up */ - SendMessage(hWnd, WM_VSCROLL, SB_PAGEUP, NULL); - break; - case VK_NEXT: /* Page down */ - SendMessage(hWnd, WM_VSCROLL, SB_PAGEDOWN, NULL); - break; - case VK_UP: /* Line up */ - SendMessage(hWnd, WM_VSCROLL, SB_LINEUP, NULL); - break; - case VK_DOWN: /* Line down */ - SendMessage(hWnd, WM_VSCROLL, SB_LINEDOWN, NULL); - break; - } - } - UpdateWindow(hWnd); - break; - - case WM_CHAR: - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert (pScr != NULL); - SendMessage(pScr->hwndTel, WM_MYSCREENCHAR, wParam, (LPARAM) pScr); - break; - - case WM_SYSCHAR: - if (wParam == 'c' || wParam == 'e') - return (DefWindowProc(hWnd, message, wParam, lParam)); - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert (pScr != NULL); - SendMessage(pScr->hwndTel, WM_MYSYSCHAR, wParam, (LPARAM) pScr); - break; - - case WM_INITMENU: - if (IsClipboardFormatAvailable(CF_TEXT)) - EnableMenuItem((HMENU) wParam, IDM_PASTE, MF_ENABLED); - else - EnableMenuItem((HMENU) wParam, IDM_PASTE, MF_GRAYED); - if (bSelection) - EnableMenuItem((HMENU) wParam, IDM_COPY, MF_ENABLED); - else - EnableMenuItem((HMENU) wParam, IDM_COPY, MF_GRAYED); - break; - - case WM_GETMINMAXINFO: - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - if (pScr == NULL) // Used on creation when window word not set - pScr = ScreenList; - lpmmi = (MINMAXINFO *) lParam; - if (FRAME_WIDTH + MAX_LINE_WIDTH * pScr->cxChar < lpmmi->ptMaxSize.x) - lpmmi->ptMaxSize.x = FRAME_WIDTH + MAX_LINE_WIDTH * pScr->cxChar; - lpmmi->ptMaxTrackSize.x = lpmmi->ptMaxSize.x; - lpmmi->ptMinTrackSize.x = FRAME_WIDTH + 20 * pScr->cxChar; - lpmmi->ptMinTrackSize.y = FRAME_HEIGHT + 4 * pScr->cyChar; - break; - - case WM_LBUTTONDOWN: - if (bDoubleClick) - Edit_TripleClick(hWnd, lParam); - else - Edit_LbuttonDown(hWnd, lParam); - break; - - case WM_LBUTTONUP: - Edit_LbuttonUp(hWnd, lParam); - break; - - case WM_LBUTTONDBLCLK: - bDoubleClick = TRUE; - SetTimer(hWnd, TIMER_TRIPLECLICK, GetDoubleClickTime(), NULL); - Edit_LbuttonDblclk(hWnd, lParam); - break; - - case WM_TIMER: - if (wParam == TIMER_TRIPLECLICK) - bDoubleClick = FALSE; - break; - - case WM_RBUTTONUP: - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert (pScr != NULL); - Edit_Copy(hWnd); - Edit_ClearSelection(pScr); - Edit_Paste(hWnd); - break; - - case WM_MOUSEMOVE: - if (bMouseDown) - Edit_MouseMove(hWnd, lParam); - break; - - case WM_RBUTTONDOWN: - #if 0 - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert (pScr != NULL); - wsprintf(strTmp,"fp->x=%d fp->y=%d text=%s \r\n", - pScr->screen_top->x, pScr->screen_top->y, pScr->screen_top->text); - OutputDebugString(strTmp); - #endif - break; - - case WM_PAINT: - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert (pScr != NULL); - BeginPaint (hWnd, &ps); - SelectObject(ps.hdc, pScr->hSelectedFont); - if (pScr->screen_bottom != NULL) - DrawTextScreen(ps.rcPaint, pScr, ps.hdc); - else - OutputDebugString("screen_bottom is NULL.\r\n"); - EndPaint(hWnd, &ps); - break; - - case WM_CLOSE: - if (MessageBox(hWnd, "Terminate this connection?", "Telnet", MB_OKCANCEL) == IDOK) { - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert (pScr != NULL); - SendMessage(pScr->hwndTel, WM_MYSCREENCLOSE, NULL, (LPARAM) pScr); - return (DefWindowProc(hWnd, message, wParam, lParam)); - } - break; - - case WM_DESTROY: - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - if (pScr != NULL) - DeleteObject(pScr->hSelectedFont); - return (DefWindowProc(hWnd, message, wParam, lParam)); - - case WM_ACTIVATE: - if (wParam != WA_INACTIVE) { - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert (pScr != NULL); - if (pScr->bAlert) { - char strTitle[128]; - int idx; - - GetWindowText(hWnd, strTitle, sizeof(strTitle)); - if (strTitle[0] == ALERT) { - idx = lstrlen(strTitle); - strTitle[idx - 2] = 0; - SetWindowText(hWnd, &strTitle[2]); - pScr->bAlert = FALSE; - } - } - } - return (DefWindowProc(hWnd, message, wParam, lParam)); - - case WM_SIZE: - if (wParam == SIZE_MINIMIZED) - break; - - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert (pScr != NULL); - - if (SetInternalScreenSize(pScr, LOWORD(lParam), HIWORD(lParam))) { - SendMessage(pScr->hwndTel, WM_MYSCREENSIZE, 0, - MAKELONG(pScr->width, pScr->height)); - } - MakeWindowTitle(pScr->title, pScr->width, pScr->height, title, sizeof(title)); - SetWindowText(hWnd, title); - break; - - case WM_SETFOCUS: - pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); - assert (pScr != NULL); - CreateCaret(hWnd, NULL, pScr->cxChar, 2); - ScreenCursorOn(pScr); - break; - - case WM_KILLFOCUS: - DestroyCaret(); - break; - - default: - return(DefWindowProc(hWnd, message, wParam, lParam)); + } + + break; + + case WM_NCCREATE: + pScr = (SCREEN *) ((LPCREATESTRUCT) lParam)->lpCreateParams; + pScr->hWnd = hWnd; + SetWindowLong(hWnd, SCREEN_HANDLE, (LONG) pScr); + SetScrollRange(hWnd, SB_VERT, 0, 100, FALSE); + SetScrollPos(hWnd, SB_VERT, 0, TRUE); + EnableScrollBar(hWnd, SB_VERT, ESB_DISABLE_BOTH); + return(TRUE); + + case WM_VSCROLL: + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert (pScr != NULL); + + ScreenCursorOff(pScr); + + switch(wParam) { + + case SB_LINEDOWN: + if (ScreenAdjustDown(pScr, 1) <= 0) + break; + hDC = GetDC(hWnd); + assert(hDC != NULL); + rc.left = 0; + rc.right = pScr->cxChar * pScr->width; + rc.top = 0; + rc.bottom = pScr->cyChar * (pScr->bottom + 1); + ScrollDC(hDC, 0, -pScr->cyChar, &rc, &rc, NULL, NULL); + ReleaseDC(hWnd, hDC); + rc.top = pScr->cyChar * pScr->bottom; + InvalidateRect(hWnd, &rc, TRUE); + ScrollPos = GetScrollPos(hWnd, SB_VERT); + SetScrollPos(hWnd, SB_VERT, ScrollPos + 1, TRUE); + UpdateWindow(hWnd); + break; + + case SB_LINEUP: + if (ScreenAdjustUp(pScr, 1) <= 0) + break; + hDC = GetDC(hWnd); + assert(hDC != NULL); + rc.left = 0; + rc.right = pScr->cxChar * pScr->width; + rc.top = 0; + rc.bottom = pScr->cyChar * (pScr->bottom + 1); + ScrollDC(hDC, 0, pScr->cyChar, &rc, &rc, NULL, NULL); + ReleaseDC(hWnd, hDC); + rc.bottom = pScr->cyChar; + InvalidateRect(hWnd, &rc, TRUE); + ScrollPos = GetScrollPos(pScr->hWnd, SB_VERT); + SetScrollPos(hWnd,SB_VERT, ScrollPos - 1, TRUE); + UpdateWindow(hWnd); + break; + + case SB_PAGEDOWN: + idx = abs(ScreenAdjustDown(pScr, pScr->height)); + hDC = GetDC(hWnd); + assert(hDC != NULL); + rc.left = 0; + rc.right = pScr->cxChar * pScr->width; + rc.top = 0; + rc.bottom = pScr->cyChar * (pScr->bottom+1); + ScrollDC(hDC, 0, -idx * pScr->cyChar, &rc, &rc, NULL, NULL); + ReleaseDC(hWnd, hDC); + rc.top = pScr->cyChar * (pScr->bottom - idx + 1); + InvalidateRect(hWnd, &rc, TRUE); + ScrollPos=GetScrollPos(hWnd, SB_VERT); + SetScrollPos(hWnd, SB_VERT, ScrollPos + idx, TRUE); + break; + + case SB_PAGEUP: + idx = abs(ScreenAdjustUp(pScr, pScr->height)); + hDC = GetDC(hWnd); + assert(hDC != NULL); + rc.left = 0; + rc.right = pScr->cxChar * pScr->width; + rc.top = 0; + rc.bottom = pScr->cyChar * (pScr->bottom + 1); + ScrollDC(hDC, 0, idx * pScr->cyChar, &rc, &rc, NULL, NULL); + ReleaseDC(hWnd, hDC); + rc.bottom = idx * pScr->cyChar; + InvalidateRect(hWnd, &rc, TRUE); + ScrollPos=GetScrollPos(hWnd, SB_VERT); + SetScrollPos(hWnd, SB_VERT, ScrollPos - idx, TRUE); + break; + + case SB_THUMBPOSITION: + case SB_THUMBTRACK: + ScrollPos = GetScrollPos(hWnd, SB_VERT); + tmpScroll = ScrollPos - LOWORD(lParam); + if (tmpScroll == 0) + break; + if (tmpScroll > 0) + ScreenAdjustUp(pScr, tmpScroll); + else + ScreenAdjustDown(pScr, -tmpScroll); + if (abs(tmpScroll) < pScr->height) { + hDC = GetDC(hWnd); + assert(hDC != NULL); + rc.left = 0; + rc.right = pScr->cxChar * pScr->width; + rc.top = 0; + rc.bottom = pScr->cyChar * (pScr->bottom + 1); + ScrollDC(hDC, 0, tmpScroll * pScr->cyChar, &rc, &rc, NULL, NULL); + ReleaseDC(hWnd, hDC); + if (tmpScroll > 0) { + rc.bottom = tmpScroll * pScr->cyChar; + InvalidateRect(hWnd, &rc, TRUE); } + else { + rc.top = (pScr->bottom + tmpScroll + 1) * pScr->cyChar; + InvalidateRect(hWnd, &rc, TRUE); + } + } + else + InvalidateRect(hWnd, NULL, TRUE); + + SetScrollPos(hWnd, SB_VERT, LOWORD(lParam), TRUE); + UpdateWindow(hWnd); + break; + } + + ScreenCursorOn(pScr); + break; + + case WM_KEYDOWN: + if (wParam == VK_INSERT) { + if (GetKeyState(VK_SHIFT) < 0) + PostMessage(hWnd, WM_COMMAND, IDM_PASTE, 0); + else if (GetKeyState(VK_CONTROL) < 0) + PostMessage(hWnd, WM_COMMAND, IDM_COPY, 0); + break; + } + /* + ** Check for cursor keys. With control pressed, we treat as + ** keyboard equivalents to scrolling. Otherwise, we send + ** a WM_MYCURSORKEY message with the appropriate string + ** to be sent. Sending the actual string allows the upper + ** level to be ignorant of keyboard modes, etc. + */ + if (wParam < VK_PRIOR || wParam > VK_DOWN) /* Is it a cursor key? */ + break; + + if (GetKeyState (VK_CONTROL) >= 0) { /* No control key */ + if (wParam >= VK_LEFT && wParam <= VK_DOWN) { + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert (pScr != NULL); + wParam = wParam - VK_LEFT + (pScr->DECCKM ? 4 : 0); + SendMessage (pScr->hwndTel, WM_MYCURSORKEY, + strlen(cursor_key[wParam]), + (LPARAM) (char FAR *) cursor_key[wParam]); + } + } else { /* Control is down */ + switch (wParam) { + case VK_PRIOR: /* Page up */ + SendMessage(hWnd, WM_VSCROLL, SB_PAGEUP, 0); + break; + case VK_NEXT: /* Page down */ + SendMessage(hWnd, WM_VSCROLL, SB_PAGEDOWN, 0); + break; + case VK_UP: /* Line up */ + SendMessage(hWnd, WM_VSCROLL, SB_LINEUP, 0); + break; + case VK_DOWN: /* Line down */ + SendMessage(hWnd, WM_VSCROLL, SB_LINEDOWN, 0); + break; + } + } + UpdateWindow(hWnd); + break; + + case WM_CHAR: + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert (pScr != NULL); + SendMessage(pScr->hwndTel, WM_MYSCREENCHAR, wParam, (LPARAM) pScr); + break; + + case WM_INITMENU: + if (IsClipboardFormatAvailable(CF_TEXT)) + EnableMenuItem((HMENU) wParam, IDM_PASTE, MF_ENABLED); + else + EnableMenuItem((HMENU) wParam, IDM_PASTE, MF_GRAYED); + if (bSelection) + EnableMenuItem((HMENU) wParam, IDM_COPY, MF_ENABLED); + else + EnableMenuItem((HMENU) wParam, IDM_COPY, MF_GRAYED); + break; + + case WM_GETMINMAXINFO: + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + if (pScr == NULL) /* Used on creation when window word not set */ + pScr = ScreenList; + lpmmi = (MINMAXINFO *) lParam; + if (FRAME_WIDTH + MAX_LINE_WIDTH * pScr->cxChar < lpmmi->ptMaxSize.x) + lpmmi->ptMaxSize.x = FRAME_WIDTH + MAX_LINE_WIDTH * pScr->cxChar; + lpmmi->ptMaxTrackSize.x = lpmmi->ptMaxSize.x; + lpmmi->ptMinTrackSize.x = FRAME_WIDTH + 20 * pScr->cxChar; + lpmmi->ptMinTrackSize.y = FRAME_HEIGHT + 4 * pScr->cyChar; + break; + + case WM_LBUTTONDOWN: + if (bDoubleClick) + Edit_TripleClick(hWnd, lParam); + else + Edit_LbuttonDown(hWnd, lParam); + break; + + case WM_LBUTTONUP: + Edit_LbuttonUp(hWnd, lParam); + break; + + case WM_LBUTTONDBLCLK: + bDoubleClick = TRUE; + SetTimer(hWnd, TIMER_TRIPLECLICK, GetDoubleClickTime(), NULL); + Edit_LbuttonDblclk(hWnd, lParam); + break; + + case WM_TIMER: + if (wParam == TIMER_TRIPLECLICK) + bDoubleClick = FALSE; + break; + + case WM_RBUTTONUP: + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert (pScr != NULL); + Edit_Copy(hWnd); + Edit_ClearSelection(pScr); + Edit_Paste(hWnd); + break; + + case WM_MOUSEMOVE: + if (bMouseDown) + Edit_MouseMove(hWnd, lParam); + break; + + case WM_RBUTTONDOWN: +#if 0 + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert (pScr != NULL); + wsprintf(strTmp,"fp->x=%d fp->y=%d text=%s \r\n", + pScr->screen_top->x, pScr->screen_top->y, pScr->screen_top->text); + OutputDebugString(strTmp); +#endif + break; + + case WM_PAINT: + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert (pScr != NULL); + BeginPaint (hWnd, &ps); + SelectObject(ps.hdc, pScr->hSelectedFont); + if (pScr->screen_bottom != NULL) + DrawTextScreen(ps.rcPaint, pScr, ps.hdc); + else + OutputDebugString("screen_bottom is NULL.\r\n"); + EndPaint(hWnd, &ps); + break; + + case WM_CLOSE: + if (MessageBox(hWnd, "Terminate this connection?", "Telnet", MB_OKCANCEL) == IDOK) { + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert (pScr != NULL); + SendMessage(pScr->hwndTel, WM_MYSCREENCLOSE, 0, (LPARAM) pScr); + return (DefWindowProc(hWnd, message, wParam, lParam)); + } + break; + + case WM_DESTROY: + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + if (pScr != NULL) + DeleteObject(pScr->hSelectedFont); + return (DefWindowProc(hWnd, message, wParam, lParam)); + + case WM_ACTIVATE: + if (wParam != WA_INACTIVE) { + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert (pScr != NULL); + if (pScr->bAlert) { + char strTitle[128]; + int idx; - return(NULL); + GetWindowText(hWnd, strTitle, sizeof(strTitle)); + if (strTitle[0] == ALERT) { + idx = lstrlen(strTitle); + strTitle[idx - 2] = 0; + SetWindowText(hWnd, &strTitle[2]); + pScr->bAlert = FALSE; + } + } + } + return (DefWindowProc(hWnd, message, wParam, lParam)); + + case WM_SIZE: + if (wParam == SIZE_MINIMIZED) + break; + + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert (pScr != NULL); + + if (SetInternalScreenSize(pScr, LOWORD(lParam), HIWORD(lParam))) { + SendMessage(pScr->hwndTel, WM_MYSCREENSIZE, 0, + MAKELONG(pScr->width, pScr->height)); + } + MakeWindowTitle(pScr->title, pScr->width, pScr->height, + title, sizeof(title)); + SetWindowText(hWnd, title); + break; + + case WM_SETFOCUS: + pScr = (SCREEN *) GetWindowLong(hWnd, SCREEN_HANDLE); + assert (pScr != NULL); + CreateCaret(hWnd, NULL, pScr->cxChar, 2); + ScreenCursorOn(pScr); + break; + + case WM_KILLFOCUS: + DestroyCaret(); + break; + + default: + return(DefWindowProc(hWnd, message, wParam, lParam)); + } + + return(0); } /* ScreenWndProc */ void ScreenBell( - SCREEN *pScr) + SCREEN *pScr) { - char strTitle[128]; - int idx; - - MessageBeep(MB_ICONEXCLAMATION); - if (pScr->hWnd != GetActiveWindow()) { - FlashWindow(pScr->hWnd, TRUE); - if (!pScr->bAlert) { - strTitle[0] = ALERT; - strTitle[1] = SPACE; - GetWindowText(pScr->hWnd, &strTitle[2], sizeof(strTitle) - 2); - idx = lstrlen(strTitle); - strTitle[idx] = SPACE; - strTitle[idx+1] = ALERT; - strTitle[idx+2] = 0; - SetWindowText(pScr->hWnd, strTitle); - } - FlashWindow(pScr->hWnd, FALSE); - pScr->bAlert = TRUE; - } + char strTitle[128]; + int idx; + + MessageBeep(MB_ICONEXCLAMATION); + if (pScr->hWnd != GetActiveWindow()) { + FlashWindow(pScr->hWnd, TRUE); + if (!pScr->bAlert) { + strTitle[0] = ALERT; + strTitle[1] = SPACE; + GetWindowText(pScr->hWnd, &strTitle[2], sizeof(strTitle) - 2); + idx = lstrlen(strTitle); + strTitle[idx] = SPACE; + strTitle[idx+1] = ALERT; + strTitle[idx+2] = 0; + SetWindowText(pScr->hWnd, strTitle); + } + FlashWindow(pScr->hWnd, FALSE); + pScr->bAlert = TRUE; + } } /* ScreenBell */ void ScreenBackspace(SCREEN *pScr) { - RECT rc; - - pScr->bWrapPending = FALSE; - rc.left = pScr->x * pScr->cxChar; - rc.right = (pScr->x + 1) * pScr->cxChar; - rc.top = pScr->cyChar * pScr->y; - rc.bottom = pScr->cyChar * (pScr->y + 1); - InvalidateRect(pScr->hWnd, &rc, TRUE); - pScr->x--; - if (pScr->x < 0) - pScr->x = 0; - UpdateWindow(pScr->hWnd); + RECT rc; + + pScr->bWrapPending = FALSE; + rc.left = pScr->x * pScr->cxChar; + rc.right = (pScr->x + 1) * pScr->cxChar; + rc.top = pScr->cyChar * pScr->y; + rc.bottom = pScr->cyChar * (pScr->y + 1); + InvalidateRect(pScr->hWnd, &rc, TRUE); + pScr->x--; + if (pScr->x < 0) + pScr->x = 0; + UpdateWindow(pScr->hWnd); } /* ScreenBackspace */ void ScreenTab( - SCREEN *pScr) + SCREEN *pScr) { - int num_spaces; - int idx; - SCREENLINE *pScrLine; - int iTest = 0; - HDC hDC; - - num_spaces = TAB_SPACES - (pScr->x % TAB_SPACES); - if (pScr->x + num_spaces >= pScr->width) - num_spaces = pScr->width - pScr->x; - pScrLine = GetScreenLineFromY(pScr, pScr->y); - if (pScrLine == NULL) - return; - for (idx = 0; idx < num_spaces; idx++, pScr->x++) { - if (!pScrLine->text[pScr->x]) - iTest=1; - if (iTest) - pScrLine->text[pScr->x] = SPACE; - } - hDC = GetDC(pScr->hWnd); - assert(hDC != NULL); - SelectObject(hDC, pScr->hSelectedFont); - TextOut(hDC, (pScr->x - num_spaces) * pScr->cxChar, pScr->y * pScr->cyChar, - pScrLine->text + pScr->x - num_spaces, num_spaces); - ReleaseDC(pScr->hWnd, hDC); - if (pScr->x >= pScr->width) - pScr->x = pScr->width - 1; - pScr->bWrapPending = FALSE; + int num_spaces; + int idx; + SCREENLINE *pScrLine; + int iTest = 0; + HDC hDC; + + num_spaces = TAB_SPACES - (pScr->x % TAB_SPACES); + if (pScr->x + num_spaces >= pScr->width) + num_spaces = pScr->width - pScr->x; + pScrLine = GetScreenLineFromY(pScr, pScr->y); + if (pScrLine == NULL) + return; + for (idx = 0; idx < num_spaces; idx++, pScr->x++) { + if (!pScrLine->text[pScr->x]) + iTest=1; + if (iTest) + pScrLine->text[pScr->x] = SPACE; + } + hDC = GetDC(pScr->hWnd); + assert(hDC != NULL); + SelectObject(hDC, pScr->hSelectedFont); + TextOut(hDC, (pScr->x - num_spaces) * pScr->cxChar, pScr->y * pScr->cyChar, + pScrLine->text + pScr->x - num_spaces, num_spaces); + ReleaseDC(pScr->hWnd, hDC); + if (pScr->x >= pScr->width) + pScr->x = pScr->width - 1; + pScr->bWrapPending = FALSE; } /* ScreenTab */ void ScreenCarriageFeed( - SCREEN *pScr) + SCREEN *pScr) { - pScr->bWrapPending = FALSE; - pScr->x = 0; + pScr->bWrapPending = FALSE; + pScr->x = 0; } /* ScreenCarriageFeed */ diff --git a/src/windows/wintel/screen.h b/src/windows/wintel/screen.h index 60618f7b6..bc4267b33 100644 --- a/src/windows/wintel/screen.h +++ b/src/windows/wintel/screen.h @@ -40,7 +40,7 @@ extern long FAR PASCAL ScreenWndProc(HWND,UINT,WPARAM,LPARAM); #define TAB_SPACES 8 #define SPACE 32 #define ALERT 0x21 -#define MAX_LINE_WIDTH 256 /* not restricted to 1 byte */ +#define MAX_LINE_WIDTH 512 /* not restricted to 1 byte */ typedef struct SCREENLINE { struct SCREENLINE *next; @@ -63,32 +63,32 @@ typedef struct SCREEN { int type; int width; int height; - int maxlines; // Maximum number of scrollback lines - int numlines; // Current number of scrollback lines - int savelines; // Save lines off top? - int ESscroll; // Scroll screen when ES received - int attrib; // current attribute - int x; // current cursor position - int y; // current cursor position - int Oldx; // internally used to redraw cursor + int maxlines; /* Maximum number of scrollback lines */ + int numlines; /* Current number of scrollback lines */ + int savelines; /* Save lines off top? */ + int ESscroll; /* Scroll screen when ES received */ + int attrib; /* current attribute */ + int x; /* current cursor position */ + int y; /* current cursor position */ + int Oldx; /* internally used to redraw cursor */ int Oldy; - int Px; // saved cursor pos and attribute + int Px; /* saved cursor pos and attribute */ int Py; int Pattrib; - int VSIDC; // Insert/Delete character mode 0=draw line - int DECAWM; // AutoWrap mode 0=off - BOOL bWrapPending; // AutoWrap mode is on - wrap on next character - int DECCKM; // Cursor key mode - int DECPAM; // keyPad Application mode - int IRM; // Insert/Replace mode - int escflg; // Current Escape level - int top; // Vertical bounds of screen + int VSIDC; /* Insert/Delete character mode 0=draw line */ + int DECAWM; /* AutoWrap mode 0=off */ + BOOL bWrapPending; /* AutoWrap mode is on - wrap on next character */ + int DECCKM; /* Cursor key mode */ + int DECPAM; /* keyPad Application mode */ + int IRM; /* Insert/Replace mode */ + int escflg; /* Current Escape level */ + int top; /* Vertical bounds of screen */ int bottom; int parmptr; - int cxChar; // Width of the current font - int cyChar; // Height of the current font + int cxChar; /* Width of the current font */ + int cyChar; /* Height of the current font */ BOOL bAlert; - int parms[6]; // Ansi Params + int parms[6]; /* Ansi Params */ LOGFONT lf; HFONT hSelectedFont; HFONT hSelectedULFont; @@ -104,12 +104,12 @@ typedef struct CONFIG { int type; int height; int width; - int maxlines; // Maximum number of scrollback lines + int maxlines; /* Maximum number of scrollback lines */ int backspace; - int ESscroll; // Scroll screen when ES received - int VSIDC; // Insert/Delete character mode 0=draw line - int DECAWM; // AutoWrap mode 0=off - int IRM; // Insert/Replace mode + int ESscroll; /* Scroll screen when ES received */ + int VSIDC; /* Insert/Delete character mode 0=draw line */ + int DECAWM; /* AutoWrap mode 0=off */ + int IRM; /* Insert/Replace mode */ } CONFIG; #define TELNET_SCREEN 0 @@ -119,6 +119,10 @@ typedef struct CONFIG { #define IDM_BACKSPACE 101 #define IDM_DELETE 102 #define IDM_ABOUT 103 +#define IDM_HELP_INDEX 104 +#define IDM_EXIT 105 + +#define HELP_FILE "ktelnet.hlp" #define IDM_COPY 200 #define IDM_PASTE 201 diff --git a/src/windows/wintel/struct.h b/src/windows/wintel/struct.h index cbea7850b..bc1cc4912 100644 --- a/src/windows/wintel/struct.h +++ b/src/windows/wintel/struct.h @@ -9,12 +9,12 @@ #define HCONNECTION HGLOBAL typedef struct CONNECTION { - SCREEN *pScreen; // handle to screen associated with connection + SCREEN *pScreen; /* handle to screen associated with connection */ kstream ks; SOCKET socket; - int pnum; // port number associated with connection - int telstate; // telnet state for this connection - int substate; // telnet subnegotiation state + int pnum; /* port number associated with connection */ + int telstate; /* telnet state for this connection */ + int substate; /* telnet subnegotiation state */ int termsent; int echo; int ugoahead; @@ -22,7 +22,7 @@ typedef struct CONNECTION { int timing; int backspace; int ctrl_backspace; - int termstate; // terminal type for this connection + int termstate; /* terminal type for this connection */ int width; int height; BOOL bResizeable; diff --git a/src/windows/wintel/telnet.c b/src/windows/wintel/telnet.c index 1b9ef1098..0845b74c6 100644 --- a/src/windows/wintel/telnet.c +++ b/src/windows/wintel/telnet.c @@ -1,24 +1,24 @@ /**************************************************************************** - - PROGRAM: telnet.c - - PURPOSE: Windows networking kernel - Telnet - - FUNCTIONS: - - WinMain() - calls initialization function, processes message loop - InitApplication() - initializes window data and registers window - InitInstance() - saves instance handle and creates main window - MainWndProc() - processes messages - About() - processes messages for "About" dialog box - - COMMENTS: - - Windows can have several copies of your application running at the - same time. The variable hInst keeps track of which instance this - application is so that processing will be to the correct window. - -****************************************************************************/ + + Program: telnet.c + + PURPOSE: Windows networking kernel - Telnet + + FUNCTIONS: + + WinMain() - calls initialization function, processes message loop + InitApplication() - initializes window data and registers window + InitInstance() - saves instance handle and creates main window + MainWndProc() - processes messages + About() - processes messages for "About" dialog box + + COMMENTS: + + Windows can have several copies of your application running at the + same time. The variable hInst keeps track of which instance this + application is so that processing will be to the correct window. + + ****************************************************************************/ #include #include @@ -35,852 +35,874 @@ static char hostdata[MAXGETHOSTSTRUCT]; static SCREEN *pScr; static int debug = 1; -char strTmp[1024]; // Scratch buffer +char strTmp[1024]; /* Scratch buffer */ BOOL bAutoConnection = FALSE; -int port_no = 23; -char szUserName[64]; // Used in auth.c +short port_no = 23; +char szUserName[64]; /* Used in auth.c */ char szHostName[64]; #ifdef KRB4 - #define WINDOW_CLASS "K4_telnetWClass" +#define WINDOW_CLASS "K4_telnetWClass" #endif #ifdef KRB5 - krb5_context k5_context; - #define WINDOW_CLASS "K5_telnetWClass" +krb5_context k5_context; +#define WINDOW_CLASS "K5_telnetWClass" #endif -/*+************************************************************************** - - FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int) - - PURPOSE: calls initialization function, processes message loop - - COMMENTS: - - Windows recognizes this function by name as the initial entry point - for the program. This function calls the application initialization - routine, if no other instance of the program is running, and always - calls the instance initialization routine. It then executes a message - retrieval and dispatch loop that is the top-level control structure - for the remainder of execution. The loop is terminated when a WM_QUIT - message is received, at which time this function exits the application - instance by returning the value passed by PostQuitMessage(). - - If this function must abort before entering the message loop, it - returns the conventional value NULL. - -****************************************************************************/ +/* + * + * FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int) + * + * PURPOSE: calls initialization function, processes message loop + * + * COMMENTS: + * + * Windows recognizes this function by name as the initial entry point + * for the program. This function calls the application initialization + * routine, if no other instance of the program is running, and always + * calls the instance initialization routine. It then executes a message + * retrieval and dispatch loop that is the top-level control structure + * for the remainder of execution. The loop is terminated when a WM_QUIT + * message is received, at which time this function exits the application + * instance by returning the value passed by PostQuitMessage(). + * + * If this function must abort before entering the message loop, it + * returns the conventional value NULL. + */ -int PASCAL WinMain( - HANDLE hInstance, // current instance - HANDLE hPrevInstance, // previous instance - LPSTR lpCmdLine, // command line - int nCmdShow) // show-window type (open/icon) +int PASCAL +WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { - MSG msg; - - if (!hPrevInstance) - if (!InitApplication(hInstance)) - return(FALSE); - - /* - Perform initializations that apply to a specific instance - */ - bAutoConnection = parse_cmdline(lpCmdLine); - - if (!InitInstance(hInstance, nCmdShow)) - return(FALSE); - - /* - Acquire and dispatch messages until a WM_QUIT message is received. - */ - while (GetMessage(&msg, NULL, NULL, NULL)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - return (msg.wParam); // Returns the value from PostQuitMessage - -} /* WinMain */ - - -/*+************************************************************************** - - FUNCTION: InitApplication(HANDLE) - - PURPOSE: Initializes window data and registers window class - - COMMENTS: - - This function is called at initialization time only if no other - instances of the application are running. This function performs - initialization tasks that can be done once for any number of running - instances. - - In this case, we initialize a window class by filling out a data - structure of type WNDCLASS and calling the Windows RegisterClass() - function. Since all instances of this application use the same window - class, we only need to do this when the first instance is initialized. - - -****************************************************************************/ + MSG msg; + + if (!hPrevInstance) + if (!InitApplication(hInstance)) + return(FALSE); + + /* + * Perform initializations that apply to a specific instance + */ + bAutoConnection = parse_cmdline(lpCmdLine); + + if (!InitInstance(hInstance, nCmdShow)) + return(FALSE); + + SetDebugErrorLevel(SLE_WARNING); + + /* + * Acquire and dispatch messages until a WM_QUIT message is received. + */ + while (GetMessage(&msg, NULL, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + + /* Process all non-network messages */ + while (PeekMessage(&msg, NULL, 0, WM_NETWORKEVENT-1, PM_REMOVE) || + PeekMessage(&msg, NULL, WM_NETWORKEVENT+1, (UINT)-1, PM_REMOVE)) + { + if (msg.message == WM_QUIT) // Special case: WM_QUIT -- return + return msg.wParam; // the value from PostQuitMessage + + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + return (msg.wParam); /* Returns the value from PostQuitMessage */ +} + +/* + * FUNCTION: InitApplication(HANDLE) + * + * PURPOSE: Initializes window data and registers window class + * + * COMMENTS: + * + * This function is called at initialization time only if no other + * instances of the application are running. This function performs + * initialization tasks that can be done once for any number of running + * instances. + * + * In this case, we initialize a window class by filling out a data + * structure of type WNDCLASS and calling the Windows RegisterClass() + * function. Since all instances of this application use the same window + * class, we only need to do this when the first instance is initialized. + */ -BOOL InitApplication( - HANDLE hInstance) +BOOL +InitApplication(HANDLE hInstance) { - WNDCLASS wc; - - ScreenInit(hInstance); - - /* - Fill in window class structure with parameters that describe the - main window. - */ - wc.style = CS_HREDRAW | CS_VREDRAW; // Class style(s). - wc.lpfnWndProc = MainWndProc; // Function to retrieve messages for - // windows of this class. - wc.cbClsExtra = 0; // No per-class extra data. - wc.cbWndExtra = 0; // No per-window extra data. - wc.hInstance = hInstance; // Application that owns the class. - wc.hIcon = NULL; // LoadIcon(hInstance, "NCSA"); - wc.hCursor = NULL; // Cursor(NULL, IDC_ARROW); - wc.hbrBackground = NULL; // GetStockObject(WHITE_BRUSH); - wc.lpszMenuName = NULL; // Name of menu resource in .RC file. - wc.lpszClassName = WINDOW_CLASS; // Name used in call to CreateWindow. - - return(RegisterClass(&wc)); - -} /* InitApplication */ - - -/*+************************************************************************** - - FUNCTION: InitInstance(HANDLE, int) - - PURPOSE: Saves instance handle and creates main window - - COMMENTS: - - This function is called at initialization time for every instance of - this application. This function performs initialization tasks that - cannot be shared by multiple instances. - - In this case, we save the instance handle in a static variable and - create and display the main program window. - -****************************************************************************/ - -BOOL InitInstance( - HANDLE hInstance, - int nCmdShow) + WNDCLASS wc; + + ScreenInit(hInstance); + + /* + * Fill in window class structure with parameters that describe the + * main window. + */ + wc.style = CS_HREDRAW | CS_VREDRAW; /* Class style(s). */ + wc.lpfnWndProc = MainWndProc; /* Function to retrieve messages for + * windows of this class. + */ + wc.cbClsExtra = 0; /* No per-class extra data. */ + wc.cbWndExtra = 0; /* No per-window extra data. */ + wc.hInstance = hInstance; /* Application that owns the class. */ + wc.hIcon = NULL; /* LoadIcon(hInstance, "NCSA"); */ + wc.hCursor = NULL; /* Cursor(NULL, IDC_ARROW); */ + wc.hbrBackground = NULL; /* GetStockObject(WHITE_BRUSH); */ + wc.lpszMenuName = NULL; /* Name of menu resource in .RC file. */ + wc.lpszClassName = WINDOW_CLASS; /* Name used in call to CreateWindow. */ + + return(RegisterClass(&wc)); +} + + +/* + * FUNCTION: InitInstance(HANDLE, int) + * + * PURPOSE: Saves instance handle and creates main window + * + * COMMENTS: + * + * This function is called at initialization time for every instance of + * this application. This function performs initialization tasks that + * cannot be shared by multiple instances. + * + * In this case, we save the instance handle in a static variable and + * create and display the main program window. + */ +BOOL +InitInstance(HANDLE hInstance, int nCmdShow) { - int xScreen = 0; - int yScreen = 0; - WSADATA wsaData; - - SetScreenInstance(hInstance); - - /* - Save the instance handle in static variable, which will be used in - many subsequence calls from this application to Windows. - */ - hInst = hInstance; - - /* - Create a main window for this application instance. - */ - hWnd = CreateWindow( - WINDOW_CLASS, // See RegisterClass() call. - "TCPWin", // Text for window title bar. - WS_SYSMENU, // Window style. - xScreen / 3, // Default horizontal position. - yScreen / 3, // Default vertical position. - xScreen / 3, // Default width. - yScreen / 3, // Default height. - NULL, // Overlapped windows have no parent. - NULL, // Use the window class menu. - hInstance, // This instance owns this window. - NULL); // Pointer not needed. - - if (!hWnd) - return (FALSE); + int xScreen = 0; + int yScreen = 0; + WSADATA wsaData; + + SetScreenInstance(hInstance); + + /* + * Save the instance handle in static variable, which will be used in + * many subsequence calls from this application to Windows. + */ + hInst = hInstance; + + /* + * Create a main window for this application instance. + */ + hWnd = CreateWindow( + WINDOW_CLASS, /* See RegisterClass() call. */ + "TCPWin", /* Text for window title bar. */ + WS_SYSMENU, /* Window style. */ + xScreen / 3, /* Default horizontal position. */ + yScreen / 3, /* Default vertical position. */ + xScreen / 3, /* Default width. */ + yScreen / 3, /* Default height. */ + NULL, /* Overlapped windows have no parent */ + NULL, /* Use the window class menu. */ + hInstance, /* This instance owns this window. */ + NULL); /* Pointer not needed. */ + + if (!hWnd) + return (FALSE); - if (WSAStartup(0x0101, &wsaData) != 0) { /* Initialize the network */ - MessageBox(NULL, "Couldn't initialize Winsock!", NULL, - MB_OK | MB_ICONEXCLAMATION); - return(FALSE); - } - - if (!OpenTelnetConnection()) { - WSACleanup(); - return(FALSE); - } - - #ifdef KRB5 - krb5_init_context(&k5_context); - krb5_init_ets(k5_context); - #endif + if (WSAStartup(0x0101, &wsaData) != 0) { /* Initialize the network */ + MessageBox(NULL, "Couldn't initialize Winsock!", NULL, + MB_OK | MB_ICONEXCLAMATION); + return(FALSE); + } - return (TRUE); + if (!OpenTelnetConnection()) { + WSACleanup(); + return(FALSE); + } -} /* InitInstance */ - - -/*+*************************************************************************** - - FUNCTION: MainWndProc(HWND, UINT, WPARAM, LPARAM) - - PURPOSE: Processes messages - - MESSAGES: +#ifdef KRB5 + krb5_init_context(&k5_context); + krb5_init_ets(k5_context); +#endif - WM_COMMAND - application menu (About dialog box) - WM_DESTROY - destroy window + return (TRUE); +} -****************************************************************************/ +char buf[2048]; -long FAR PASCAL MainWndProc( - HWND hWnd, - UINT message, - WPARAM wParam, - LPARAM lParam) +/* + * FUNCTION: MainWndProc(HWND, UINT, WPARAM, LPARAM) + * + * PURPOSE: Processes messages + * + * MESSAGES: + * + * WM_COMMAND - application menu (About dialog box) + * WM_DESTROY - destroy window + */ +long FAR PASCAL +MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - HGLOBAL hBuffer; - LPSTR lpBuffer; - char c; - int iEvent, namelen, cnt, ret; - char buf[1024]; - struct sockaddr_in name; - struct sockaddr_in remote_addr; - struct hostent *remote_host; - char *tmpCommaLoc; + HGLOBAL hBuffer; + LPSTR lpBuffer; + int iEvent, cnt, ret; + char *tmpCommaLoc; + struct sockaddr_in remote_addr; + struct hostent *remote_host; - switch (message) { - - case WM_MYSCREENCHANGEBKSP: - if (!con) - break; - con->backspace = wParam; - if (con->backspace == VK_BACK) { - con->ctrl_backspace = 0x7f; - WritePrivateProfileString(INI_TELNET, INI_BACKSPACE, + switch (message) { + case WM_MYSCREENCHANGEBKSP: + if (!con) + break; + con->backspace = wParam; + if (con->backspace == VK_BACK) { + con->ctrl_backspace = 0x7f; + WritePrivateProfileString(INI_TELNET, INI_BACKSPACE, INI_BACKSPACE_BS, TELNET_INI); - } - else { - con->ctrl_backspace = VK_BACK; - WritePrivateProfileString(INI_TELNET, INI_BACKSPACE, + } + else { + con->ctrl_backspace = VK_BACK; + WritePrivateProfileString(INI_TELNET, INI_BACKSPACE, INI_BACKSPACE_DEL, TELNET_INI); - } - GetPrivateProfileString(INI_HOSTS, INI_HOST "0", "", buf, 128, TELNET_INI); - tmpCommaLoc = strchr(buf, ','); - if (tmpCommaLoc == NULL) { - strcat (buf, ","); - tmpCommaLoc = strchr(buf, ','); - } - if (tmpCommaLoc) { - tmpCommaLoc++; - if (con->backspace == VK_BACK) - strcpy(tmpCommaLoc, INI_HOST_BS); - else - strcpy(tmpCommaLoc, INI_HOST_DEL); - } - WritePrivateProfileString(INI_HOSTS, INI_HOST "0", buf, TELNET_INI); - break; - - case WM_MYSCREENCHAR: - if (!con) - break; - if (wParam == VK_BACK) - wParam = con->backspace; - else if (wParam == 0x7f) - wParam = con->ctrl_backspace; - else if (wParam == VK_SPACE && GetKeyState(VK_CONTROL) < 0) - wParam = 0; - TelnetSend(con->ks, (char *) &wParam, 1, NULL); - break; - - case WM_MYCURSORKEY: - /* Acts as a send through: buffer is lParam and length in wParam */ - if (!con) - break; - TelnetSend (con->ks, (char *) lParam, wParam, NULL); - break; - - case WM_MYSYSCHAR: - if (!con) - break; - c = (char) wParam; - - switch (c) { - - case 'f': - getsockname(con->socket, (struct sockaddr *) &name, (int *) &namelen); - wsprintf(buf, "ftp %d.%d.%d.%d\n", - name.sin_addr.S_un.S_un_b.s_b1, - name.sin_addr.S_un.S_un_b.s_b2, - name.sin_addr.S_un.S_un_b.s_b3, - name.sin_addr.S_un.S_un_b.s_b4); - TelnetSend(con->ks, buf, lstrlen(buf), NULL); - break; - - case 'x': - PostMessage(con->pScreen->hWnd, WM_CLOSE, NULL, NULL); - break; - } - - break; - - case WM_MYSCREENBLOCK: - if (!con) - break; - hBuffer = (HGLOBAL) wParam; - lpBuffer = GlobalLock(hBuffer); - TelnetSend(con->ks, lpBuffer, lstrlen(lpBuffer), NULL); - GlobalUnlock(hBuffer); - break; - - case WM_MYSCREENCLOSE: - if (!con) - break; - kstream_destroy(con->ks); - DestroyWindow(hWnd); - break; - - case WM_QUERYOPEN: - return(0); - break; - - case WM_DESTROY: /* message: window being destroyed */ - kstream_destroy(con->ks); - free(con); - WSACleanup(); - PostQuitMessage(0); - break; - - case WM_NETWORKEVENT: - iEvent = WSAGETSELECTEVENT(lParam); - - switch (iEvent) { - - case FD_READ: - cnt = recv(con->socket, buf, 1024, NULL); - /* - The following line has been removed until kstream supports - non-blocking IO or larger size reads (jrivlin@fusion.com). - */ - /* cnt = kstream_read(con->ks, buf, 1024); */ - buf[cnt] = 0; - parse((CONNECTION *) con, (unsigned char *) buf, cnt); - ScreenEm(buf, cnt, con->pScreen); - break; - - case FD_CLOSE: - kstream_destroy(con->ks); - free(con); - WSACleanup(); - PostQuitMessage(0); - break; - - case FD_CONNECT: - ret = WSAGETSELECTERROR(lParam); - if (ret) { - wsprintf(buf, "Error %d on Connect", ret); - MessageBox(NULL, buf, NULL, MB_OK | MB_ICONEXCLAMATION); - kstream_destroy(con->ks); - free(con); - WSACleanup(); - PostQuitMessage(0); - break; - } - start_negotiation(con->ks); - break; - } - - break; - - case WM_HOSTNAMEFOUND: - ret = WSAGETASYNCERROR(lParam); - if (ret) { - wsprintf(buf, "Error %d on GetHostbyName", ret); - MessageBox(NULL, buf, NULL, MB_OK | MB_ICONEXCLAMATION); - kstream_destroy(con->ks); - free(con); - WSACleanup(); - PostQuitMessage(0); - break; - } - - remote_host = (struct hostent *) hostdata; - remote_addr.sin_family = AF_INET; - remote_addr.sin_addr.S_un.S_un_b.s_b1 = remote_host->h_addr[0]; - remote_addr.sin_addr.S_un.S_un_b.s_b2 = remote_host->h_addr[1]; - remote_addr.sin_addr.S_un.S_un_b.s_b3 = remote_host->h_addr[2]; - remote_addr.sin_addr.S_un.S_un_b.s_b4 = remote_host->h_addr[3]; - remote_addr.sin_port = htons(port_no); - - connect(con->socket, (struct sockaddr *) &remote_addr, - sizeof(struct sockaddr)); - break; - - case WM_MYSCREENSIZE: - con->width = LOWORD(lParam); // width in characters - con->height = HIWORD(lParam); // height in characters - if (con->bResizeable && con->ks) - send_naws(con); - wsprintf(buf, "%d", con->height); - WritePrivateProfileString(INI_TELNET, INI_HEIGHT, buf, TELNET_INI); - wsprintf(buf, "%d", con->width); - WritePrivateProfileString(INI_TELNET, INI_WIDTH, buf, TELNET_INI); - break; + } + GetPrivateProfileString(INI_HOSTS, INI_HOST "0", "", buf, 128, TELNET_INI); + tmpCommaLoc = strchr(buf, ','); + if (tmpCommaLoc == NULL) { + strcat (buf, ","); + tmpCommaLoc = strchr(buf, ','); + } + if (tmpCommaLoc) { + tmpCommaLoc++; + if (con->backspace == VK_BACK) + strcpy(tmpCommaLoc, INI_HOST_BS); + else + strcpy(tmpCommaLoc, INI_HOST_DEL); + } + WritePrivateProfileString(INI_HOSTS, INI_HOST "0", buf, TELNET_INI); + break; + + case WM_MYSCREENCHAR: + { + unsigned char c; + + if (!con) + break; + if (wParam == VK_BACK) + c = con->backspace; + else if (wParam == 0x7f) + c = con->ctrl_backspace; + else if (wParam == VK_SPACE && GetKeyState(VK_CONTROL) < 0) + c = 0; + else + c = wParam; + TelnetSend(con->ks, &c, 1, 0); + } + break; + + case WM_MYCURSORKEY: + /* Acts as a send through: buffer is lParam and length in wParam */ + if (!con) + break; + memcpy(buf, (char *)lParam, wParam); + TelnetSend (con->ks, buf, wParam, 0); + break; + + case WM_MYSCREENBLOCK: + if (!con) + break; + hBuffer = (HGLOBAL) wParam; + lpBuffer = GlobalLock(hBuffer); + TelnetSend(con->ks, lpBuffer, lstrlen(lpBuffer), 0); + GlobalUnlock(hBuffer); + break; + + case WM_MYSCREENCLOSE: +#if 0 + if (con) + { + kstream_destroy(con->ks); + con->ks = NULL; + } +#endif + DestroyWindow(hWnd); + break; + + case WM_QUERYOPEN: + return(0); + break; + + case WM_DESTROY: /* message: window being destroyed */ + if (con) + { + kstream_destroy(con->ks); + free(con); + WSACleanup(); + } + PostQuitMessage(0); + break; + + case WM_NETWORKEVENT: + iEvent = WSAGETSELECTEVENT(lParam); + + switch (iEvent) { + + case FD_READ: + if (con == NULL) + break; + cnt = kstream_read(con->ks, buf, 1500); + buf[cnt] = 0; + parse((CONNECTION *)con, (unsigned char *)buf, cnt); + ScreenEm(buf, cnt, con->pScreen); + break; + + case FD_CLOSE: + kstream_destroy(con->ks); + free(con); + con = NULL; + WSACleanup(); + PostQuitMessage(0); + break; + + case FD_CONNECT: + ret = WSAGETSELECTERROR(lParam); + if (ret) { + wsprintf(buf, "Error %d on Connect", ret); + MessageBox(NULL, buf, NULL, MB_OK | MB_ICONEXCLAMATION); + kstream_destroy(con->ks); + free(con); + WSACleanup(); + PostQuitMessage(0); + break; + } + start_negotiation(con->ks); + break; + } + + break; + + case WM_HOSTNAMEFOUND: + ret = WSAGETASYNCERROR(lParam); + if (ret) { + wsprintf(buf, "Error %d on GetHostbyName", ret); + MessageBox(NULL, buf, NULL, MB_OK | MB_ICONEXCLAMATION); + kstream_destroy(con->ks); + free(con); + WSACleanup(); + PostQuitMessage(0); + break; + } + + remote_host = (struct hostent *)hostdata; + remote_addr.sin_family = AF_INET; + memcpy(&(remote_addr.sin_addr), &(remote_host->h_addr[0]), 4); + remote_addr.sin_port = htons(port_no); + + connect(con->socket, (struct sockaddr *)&remote_addr, sizeof(struct sockaddr)); + break; + + case WM_MYSCREENSIZE: + con->width = LOWORD(lParam); /* width in characters */ + con->height = HIWORD(lParam); /* height in characters */ + if (con->bResizeable && con->ks) + send_naws(con); + wsprintf(buf, "%d", con->height); + WritePrivateProfileString(INI_TELNET, INI_HEIGHT, buf, TELNET_INI); + wsprintf(buf, "%d", con->width); + WritePrivateProfileString(INI_TELNET, INI_WIDTH, buf, TELNET_INI); + break; - default: // Passes it on if unproccessed - return(DefWindowProc(hWnd, message, wParam, lParam)); - } - return (NULL); + default: /* Passes it on if unproccessed */ + return(DefWindowProc(hWnd, message, wParam, lParam)); + } + return (0); +} -} /* MainWndProc */ - -/*+*************************************************************************** - - FUNCTION: SaveHostName(hostname, port) - - PURPOSE: Saves the currently selected host name and port number - in the KERBEROS.INI file and returns the preferred backspace - setting if one exists for that host. - - RETURNS: VK_BACK or 0x7f depending on the desired backspace setting. - -****************************************************************************/ - -int SaveHostName( - char *host, - int port) +/* + * + * FUNCTION: SaveHostName(hostname, port) + * + * PURPOSE: Saves the currently selected host name and port number + * in the KERBEROS.INI file and returns the preferred backspace + * setting if one exists for that host. + * + * RETURNS: VK_BACK or 0x7f depending on the desired backspace setting. + */ +int +SaveHostName(char *host, int port) { - char buf[128]; // Scratch buffer - char fullhost[128]; // Host & port combination - char hostName[10][128]; // Entries from INI files - char *comma; // For parsing del/bs info - int len; // Length of fullhost - int n; // Number of items written - int i; // Index - int bs; // What we return - - if (port == 23) // Default telnet port - strcpy(fullhost, host); // ...then don't add it on - else - wsprintf(fullhost, "%s %d", host, port); - len = strlen(fullhost); - - comma = NULL; - for (i = 0; i < 10; i++) { - wsprintf(buf, INI_HOST "%d", i); // INI item to fetch - GetPrivateProfileString(INI_HOSTS, buf, "", hostName[i], - 128, TELNET_INI); - - if (!hostName[i][0]) - break; - - if (strncmp (hostName[i], fullhost, len)) // A match?? - continue; // Nope, keep going - comma = strchr (hostName[i], ','); - } - - if (comma) { - ++comma; // Past the comma - while (*comma == ' ') // Past leading white space - ++comma; - bs = VK_BACK; // Default for unknown entry - if (_stricmp(comma, INI_HOST_DEL) == 0) - bs = 0x7f; - } - else { // No matching entry - GetPrivateProfileString(INI_TELNET, INI_BACKSPACE, INI_BACKSPACE_BS, - buf, sizeof(buf), TELNET_INI); - bs = VK_BACK; // Default value - if (_stricmp(buf, INI_BACKSPACE_DEL) == 0) - bs = 0x7f; - } - - /* - ** Build up default host name - */ - strcpy(buf, fullhost); - strcat(buf, ", "); - strcat(buf, (bs == VK_BACK) ? INI_BACKSPACE_BS : INI_BACKSPACE_DEL); - WritePrivateProfileString(INI_HOSTS, INI_HOST "0", buf, TELNET_INI); - - n = 0; - for (i = 0; i < 10; i++) { - if (!hostName[i][0]) // End of the list? - break; - if (strncmp(hostName[i], fullhost, len) != 0) { - wsprintf(buf, INI_HOST "%d", ++n); - WritePrivateProfileString(INI_HOSTS, buf, hostName[i], TELNET_INI); - } - } - return(bs); - -} /* SaveHostName */ - - -int OpenTelnetConnection(void) + char buf[128]; /* Scratch buffer */ + char fullhost[128]; /* Host & port combination */ + char hostName[10][128]; /* Entries from INI files */ + char *comma; /* For parsing del/bs info */ + int len; /* Length of fullhost */ + int n; /* Number of items written */ + int i; /* Index */ + int bs; /* What we return */ + + if (port == 23) /* Default telnet port */ + strcpy(fullhost, host); /* ...then don't add it on */ + else + wsprintf(fullhost, "%s %d", host, port); + len = strlen(fullhost); + + comma = NULL; + for (i = 0; i < 10; i++) { + wsprintf(buf, INI_HOST "%d", i); /* INI item to fetch */ + GetPrivateProfileString(INI_HOSTS, buf, "", hostName[i], + 128, TELNET_INI); + + if (!hostName[i][0]) + break; + + if (strncmp (hostName[i], fullhost, len)) /* A match?? */ + continue; /* Nope, keep going */ + comma = strchr (hostName[i], ','); + } + + if (comma) { + ++comma; /* Past the comma */ + while (*comma == ' ') /* Past leading white space */ + ++comma; + bs = VK_BACK; /* Default for unknown entry */ + if (_stricmp(comma, INI_HOST_DEL) == 0) + bs = 0x7f; + } + else { /* No matching entry */ + GetPrivateProfileString(INI_TELNET, INI_BACKSPACE, INI_BACKSPACE_BS, + buf, sizeof(buf), TELNET_INI); + bs = VK_BACK; /* Default value */ + if (_stricmp(buf, INI_BACKSPACE_DEL) == 0) + bs = 0x7f; + } + + /* + * Build up default host name + */ + strcpy(buf, fullhost); + strcat(buf, ", "); + strcat(buf, (bs == VK_BACK) ? INI_BACKSPACE_BS : INI_BACKSPACE_DEL); + WritePrivateProfileString(INI_HOSTS, INI_HOST "0", buf, TELNET_INI); + + n = 0; + for (i = 0; i < 10; i++) { + if (!hostName[i][0]) /* End of the list? */ + break; + if (strncmp(hostName[i], fullhost, len) != 0) { + wsprintf(buf, INI_HOST "%d", ++n); + WritePrivateProfileString(INI_HOSTS, buf, hostName[i], TELNET_INI); + } + } + return(bs); +} + + +int +OpenTelnetConnection(void) { - int nReturn, ret; - struct sockaddr_in sockaddr; - char *p; - static struct kstream_crypt_ctl_block ctl; - char buf[128]; + int nReturn, ret; + struct sockaddr_in sockaddr; + char *p; + static struct kstream_crypt_ctl_block ctl; + char buf[128]; - tmpConfig = calloc(sizeof(CONFIG), 1); + tmpConfig = calloc(sizeof(CONFIG), 1); - if (bAutoConnection) { - tmpConfig->title = calloc(lstrlen(szHostName), 1); - lstrcpy(tmpConfig->title, (char *) szHostName); - } else { - nReturn = DoDialog("OPENTELNETDLG", OpenTelnetDlg); - if (nReturn == FALSE) - return(FALSE); - } + if (bAutoConnection) { + tmpConfig->title = calloc(lstrlen(szHostName), 1); + lstrcpy(tmpConfig->title, (char *) szHostName); + } else { + nReturn = DoDialog("OPENTELNETDLG", OpenTelnetDlg); + if (nReturn == FALSE) + return(FALSE); + } - con = (CONNECTION *) GetNewConnection(); - if (con == NULL) - return(0); - - tmpConfig->width = - GetPrivateProfileInt(INI_TELNET, INI_WIDTH, DEF_WIDTH, TELNET_INI); - - tmpConfig->height = - GetPrivateProfileInt(INI_TELNET, INI_HEIGHT, DEF_HEIGHT, TELNET_INI); - con->width = tmpConfig->width; - con->height = tmpConfig->height; - - con->backspace = SaveHostName(tmpConfig->title, port_no); - - if (con->backspace == VK_BACK) { - tmpConfig->backspace = TRUE; - con->ctrl_backspace = 0x7f; - } else { - tmpConfig->backspace = FALSE; - con->ctrl_backspace = 0x08; - } - - tmpConfig->hwndTel = hWnd; - con->pScreen = InitNewScreen(tmpConfig); - if (!con->pScreen) { - assert(FALSE); - free(con->pScreen); - free(con); - free(tmpConfig); - return(-1); - } - - ret = (SOCKET) socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + con = (CONNECTION *) GetNewConnection(); + if (con == NULL) + return(0); + + tmpConfig->width = + GetPrivateProfileInt(INI_TELNET, INI_WIDTH, DEF_WIDTH, TELNET_INI); + + tmpConfig->height = + GetPrivateProfileInt(INI_TELNET, INI_HEIGHT, DEF_HEIGHT, TELNET_INI); + con->width = tmpConfig->width; + con->height = tmpConfig->height; + + con->backspace = SaveHostName(tmpConfig->title, port_no); + + if (con->backspace == VK_BACK) { + tmpConfig->backspace = TRUE; + con->ctrl_backspace = 0x7f; + } else { + tmpConfig->backspace = FALSE; + con->ctrl_backspace = 0x08; + } + + tmpConfig->hwndTel = hWnd; + con->pScreen = InitNewScreen(tmpConfig); + if (!con->pScreen) { + assert(FALSE); + free(con->pScreen); + free(con); + free(tmpConfig); + return(-1); + } + + ret = (SOCKET) socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (ret == SOCKET_ERROR) { - wsprintf(buf, "Socket error on socket = %d!", WSAGetLastError()); - MessageBox(NULL, buf, NULL, MB_OK | MB_ICONEXCLAMATION); - if (con->pScreen != NULL) - DestroyWindow(con->pScreen->hWnd); - free(con); - free(tmpConfig); - return(-1); - } + if (ret == SOCKET_ERROR) { + wsprintf(buf, "Socket error on socket = %d!", WSAGetLastError()); + MessageBox(NULL, buf, NULL, MB_OK | MB_ICONEXCLAMATION); + if (con->pScreen != NULL) + DestroyWindow(con->pScreen->hWnd); + free(con); + free(tmpConfig); + return(-1); + } - con->socket = ret; + con->socket = ret; - sockaddr.sin_family = AF_INET; - sockaddr.sin_addr.s_addr = htonl(INADDR_ANY); - sockaddr.sin_port = htons(0); + sockaddr.sin_family = AF_INET; + sockaddr.sin_addr.s_addr = htonl(INADDR_ANY); + sockaddr.sin_port = htons(0); - ret = bind(con->socket, (struct sockaddr *) &sockaddr, - (int) sizeof(struct sockaddr_in)); + ret = bind(con->socket, (struct sockaddr *) &sockaddr, + (int) sizeof(struct sockaddr_in)); - if (ret == SOCKET_ERROR) { - wsprintf(buf, "Socket error on bind!"); - MessageBox(NULL, buf, NULL, MB_OK | MB_ICONEXCLAMATION); - if (con->pScreen != NULL) - DestroyWindow(con->pScreen->hWnd); - free(con); - free(tmpConfig); - return(-1); - } - - WSAAsyncSelect(con->socket, hWnd, WM_NETWORKEVENT, - FD_READ | FD_CLOSE | FD_CONNECT); + if (ret == SOCKET_ERROR) { + wsprintf(buf, "Socket error on bind!"); + MessageBox(NULL, buf, NULL, MB_OK | MB_ICONEXCLAMATION); + if (con->pScreen != NULL) + DestroyWindow(con->pScreen->hWnd); + free(con); + free(tmpConfig); + return(-1); + } - lstrcpy(szHostName, tmpConfig->title); - p = strchr(szHostName, '@'); - if (p != NULL) { - *p = 0; - strcpy (szUserName, szHostName); - strcpy(szHostName, ++p); - } + WSAAsyncSelect(con->socket, hWnd, WM_NETWORKEVENT, + FD_READ | FD_CLOSE | FD_CONNECT); - WSAAsyncGetHostByName(hWnd, WM_HOSTNAMEFOUND, szHostName, hostdata, - MAXGETHOSTSTRUCT); - free(tmpConfig); + lstrcpy(szHostName, tmpConfig->title); + p = strchr(szHostName, '@'); + if (p != NULL) { + *p = 0; + strcpy (szUserName, szHostName); + strcpy(szHostName, ++p); + } - ctl.encrypt = auth_encrypt; - ctl.decrypt = auth_decrypt; - ctl.init = auth_init; - ctl.destroy = auth_destroy; + WSAAsyncGetHostByName(hWnd, WM_HOSTNAMEFOUND, szHostName, hostdata, + MAXGETHOSTSTRUCT); - con->ks = kstream_create_from_fd(con->socket, &ctl, NULL); + ctl.encrypt = auth_encrypt; + ctl.decrypt = auth_decrypt; + ctl.init = auth_init; + ctl.destroy = auth_destroy; - kstream_set_buffer_mode(con->ks, 0); + con->ks = kstream_create_from_fd(con->socket, &ctl, NULL); - if (con->ks == NULL) - return(-1); + if (con->ks == NULL) + return(-1); - return(1); + kstream_set_buffer_mode(con->ks, 0); -} /* OpenTelnetConnection */ + return(1); +} -CONNECTION *GetNewConnection(void) +CONNECTION * +GetNewConnection(void) { - CONNECTION *pCon; + CONNECTION *pCon; - pCon = calloc(sizeof(CONNECTION), 1); - if (pCon == NULL) - return NULL; - pCon->backspace = TRUE; - pCon->bResizeable = TRUE; - return(pCon); + pCon = calloc(sizeof(CONNECTION), 1); + if (pCon == NULL) + return NULL; + pCon->backspace = TRUE; + pCon->bResizeable = TRUE; + return(pCon); +} -} /* GetNewConnection */ - -int NEAR DoDialog( - char *szDialog, - FARPROC lpfnDlgProc) +int NEAR +DoDialog(char *szDialog, FARPROC lpfnDlgProc) { - int nReturn; + int nReturn; - lpfnDlgProc = MakeProcInstance(lpfnDlgProc, hInst); - if (lpfnDlgProc == NULL) - MessageBox(hWnd, "Couldn't make procedure instance", NULL, MB_OK); + lpfnDlgProc = MakeProcInstance(lpfnDlgProc, hInst); + if (lpfnDlgProc == NULL) + MessageBox(hWnd, "Couldn't make procedure instance", NULL, MB_OK); - nReturn = DialogBox(hInst, szDialog, hWnd, lpfnDlgProc); - FreeProcInstance(lpfnDlgProc); - return (nReturn); - -} /* DoDialog */ - + nReturn = DialogBox(hInst, szDialog, hWnd, lpfnDlgProc); + FreeProcInstance(lpfnDlgProc); + return (nReturn); +} -/*+*************************************************************************** - FUNCTION: OpenTelnetDlg(HWND, unsigned, WORD, LONG) - - PURPOSE: Processes messages for "Open New Telnet Connection" dialog box +/* + * FUNCTION: OpenTelnetDlg(HWND, unsigned, WORD, LONG) + * + * PURPOSE: Processes messages for "Open New Telnet Connection" dialog box + * + * MESSAGES: + * + * WM_INITDIALOG - initialize dialog box + * WM_COMMAND - Input received + */ +BOOL FAR PASCAL +OpenTelnetDlg(HWND hDlg, WORD message, WORD wParam, LONG lParam) +{ + char szConnectName[256]; + HDC hDC; + int xExt, yExt; + DWORD Ext; + HWND hEdit; + int n; + int iHostNum = 0; + char tmpName[128]; + char tmpBuf[80]; + char *tmpCommaLoc; + + switch (message) { + case WM_INITDIALOG: + hDC = GetDC(hDlg); + Ext = GetDialogBaseUnits(); + xExt = (190 *LOWORD(Ext)) /4 ; + yExt = (72 * HIWORD(Ext)) /8 ; + GetPrivateProfileString(INI_HOSTS, INI_HOST "0", "", tmpName, + 128, TELNET_INI); + if (tmpName[0]) { + tmpCommaLoc = strchr(tmpName, ','); + if (tmpCommaLoc) + *tmpCommaLoc = '\0'; + SetDlgItemText(hDlg, TEL_CONNECT_NAME, tmpName); + } + hEdit = GetWindow(GetDlgItem(hDlg, TEL_CONNECT_NAME), GW_CHILD); + while (TRUE) { + wsprintf(tmpBuf, INI_HOST "%d", iHostNum++); + GetPrivateProfileString(INI_HOSTS, tmpBuf, "", tmpName, + 128, TELNET_INI); + tmpCommaLoc = strchr(tmpName, ','); + if (tmpCommaLoc) + *tmpCommaLoc = '\0'; + if (tmpName[0]) + SendDlgItemMessage(hDlg, TEL_CONNECT_NAME, CB_ADDSTRING, 0, + (LPARAM) ((LPSTR) tmpName)); + else + break; + } +#ifdef FORWARD + EnableWindow(GetDlgItem(hDlg, IDC_FORWARD), 1); + SendDlgItemMessage(hDlg, IDC_FORWARD, BM_SETCHECK, forward_flag, 0); + if (forward_flag) + EnableWindow(GetDlgItem(hDlg, IDC_FORWARDFORWARD), 1); + else + EnableWindow(GetDlgItem(hDlg, IDC_FORWARDFORWARD), 0); + SendDlgItemMessage(hDlg, IDC_FORWARDFORWARD, BM_SETCHECK, + forwardable_flag, 0); +#endif - MESSAGES: +#ifdef ENCRYPTION + EnableWindow(GetDlgItem(hDlg, IDC_ENCRYPT), 1); + SendDlgItemMessage(hDlg, IDC_ENCRYPT, + BM_SETCHECK, encrypt_flag, 0); +#endif - WM_INITDIALOG - initialize dialog box - WM_COMMAND - Input received + EnableWindow(GetDlgItem(hDlg, TEL_CONNECT_USERID), 1); + + SetWindowPos(hDlg, NULL, + (GetSystemMetrics(SM_CXSCREEN)/2)-(xExt/2), + (GetSystemMetrics(SM_CYSCREEN)/2)-(yExt/2), + 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); + ReleaseDC(hDlg, hDC); + SendMessage(hEdit, WM_USER + 1, 0, 0); + SendMessage(hDlg, WM_SETFOCUS, 0, 0); + return (TRUE); + + case WM_COMMAND: + switch (wParam) { + case TEL_CANCEL: + case IDCANCEL: /* From the menu */ + EndDialog(hDlg, FALSE); + break; + +#ifdef FORWARD + case IDC_FORWARD: + forward_flag = (BOOL)SendDlgItemMessage(hDlg, IDC_FORWARD, + BM_GETCHECK, 0, 0); + if (forward_flag) + EnableWindow(GetDlgItem(hDlg, IDC_FORWARDFORWARD), 1); + else + EnableWindow(GetDlgItem(hDlg, IDC_FORWARDFORWARD), 0); + break; + + case IDC_FORWARDFORWARD: + forwardable_flag = (BOOL)SendDlgItemMessage(hDlg, IDC_FORWARDFORWARD, + BM_GETCHECK, 0, 0); + break; +#endif -****************************************************************************/ +#if ENCRYPTION + case IDC_ENCRYPT: + encrypt_flag = (BOOL)SendDlgItemMessage(hDlg, IDC_ENCRYPT, + BM_GETCHECK, 0, 0); + break; +#endif + case TEL_CONNECT_USERID: + GetDlgItemText(hDlg, TEL_CONNECT_USERID, szUserName, sizeof(szUserName)); + break; -BOOL FAR PASCAL OpenTelnetDlg( - HWND hDlg, - WORD message, - WORD wParam, - LONG lParam) -{ - char szConnectName[256]; - HDC hDC; - int xExt, yExt; - DWORD Ext; - HWND hEdit; - int n; - int iHostNum = 0; - char tmpName[128]; - char tmpBuf[80]; - char *tmpCommaLoc; - - switch (message) { - - case WM_INITDIALOG: - hDC = GetDC(hDlg); - Ext = GetDialogBaseUnits(); - xExt = (190 *LOWORD(Ext)) /4 ; - yExt = (72 * HIWORD(Ext)) /8 ; - GetPrivateProfileString(INI_HOSTS, INI_HOST "0", "", tmpName, - 128, TELNET_INI); - if (tmpName[0]) { - tmpCommaLoc = strchr(tmpName, ','); - if (tmpCommaLoc) - *tmpCommaLoc = '\0'; - SetDlgItemText(hDlg, TEL_CONNECT_NAME, tmpName); - } - hEdit = GetWindow(GetDlgItem(hDlg, TEL_CONNECT_NAME), GW_CHILD); - while (TRUE) { - wsprintf(tmpBuf, INI_HOST "%d", iHostNum++); - GetPrivateProfileString(INI_HOSTS, tmpBuf, "", tmpName, - 128, TELNET_INI); - tmpCommaLoc = strchr(tmpName, ','); - if (tmpCommaLoc) - *tmpCommaLoc = '\0'; - if (tmpName[0]) - SendDlgItemMessage(hDlg, TEL_CONNECT_NAME, CB_ADDSTRING, 0, - (LPARAM) ((LPSTR) tmpName)); - else - break; - } - SetWindowPos(hDlg, NULL, - (GetSystemMetrics(SM_CXSCREEN)/2)-(xExt/2), - (GetSystemMetrics(SM_CYSCREEN)/2)-(yExt/2), - 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); - ReleaseDC(hDlg, hDC); - SendMessage(hEdit, WM_USER+1, NULL, NULL); - SendMessage(hDlg, WM_SETFOCUS, NULL, NULL); - return (TRUE); - - case WM_COMMAND: - switch (wParam) { - case TEL_CANCEL: - case IDCANCEL: // From the menu - EndDialog(hDlg, FALSE); - break; - - case TEL_OK: - GetDlgItemText(hDlg, TEL_CONNECT_NAME, szConnectName, 256); + case TEL_OK: + GetDlgItemText(hDlg, TEL_CONNECT_NAME, szConnectName, 256); - n = parse_cmdline (szConnectName); - if (! n) { - MessageBox(hDlg, "You must enter a session name!", - NULL, MB_OK); - break; - } - tmpConfig->title = calloc(lstrlen(szHostName) + 1, 1); - lstrcpy(tmpConfig->title, szConnectName); - EndDialog(hDlg, TRUE); - break; - } - return (FALSE); - } - return(FALSE); - -} /* OpenTelnetDlg */ - - -/*+*************************************************************************** - - FUNCTION: TelnetSend(kstream ks, char *buf, int len, int flags) - - PURPOSE: This is a replacement for the WinSock send() function, to - send a buffer of characters to an output socket. It differs - by retrying endlessly if sending the bytes would cause - the send() to block. observed EWOULDBLOCK - errors when running using TCP Software's PC/TCP 3.0 stack, - even when writing as little as 109 bytes into a socket - that had no more than 9 bytes queued for output. Note also that - a kstream is used during output rather than a socket to facilitate - encryption. - - Eventually, for cleanliness and responsiveness, this - routine should not loop; instead, if the send doesn't - send all the bytes, it should put them into a buffer - and return. Message handling code would send out the - buffer whenever it gets an FD_WRITE message. - -****************************************************************************/ - -int TelnetSend( - kstream ks, - char *buf, - int len, - int flags) + n = parse_cmdline (szConnectName); + if (! n) { + MessageBox(hDlg, "You must enter a session name!", + NULL, MB_OK); + break; + } + tmpConfig->title = calloc(lstrlen(szHostName) + 1, 1); + lstrcpy(tmpConfig->title, szConnectName); + EndDialog(hDlg, TRUE); + break; + } + return (FALSE); + } + return(FALSE); +} + + +/* + * + * FUNCTION: TelnetSend(kstream ks, char *buf, int len, int flags) + * + * PURPOSE: This is a replacement for the WinSock send() function, to + * send a buffer of characters to an output socket. It differs + * by retrying endlessly if sending the bytes would cause + * the send() to block. observed EWOULDBLOCK + * errors when running using TCP Software's PC/TCP 3.0 stack, + * even when writing as little as 109 bytes into a socket + * that had no more than 9 bytes queued for output. Note also + * that a kstream is used during output rather than a socket + * to facilitate encryption. + * + * Eventually, for cleanliness and responsiveness, this + * routine should not loop; instead, if the send doesn't + * send all the bytes, it should put them into a buffer + * and return. Message handling code would send out the + * buffer whenever it gets an FD_WRITE message. + */ +int +TelnetSend(kstream ks, char *buf, int len, int flags) { - int writelen; - int origlen = len; - - while (TRUE) { - writelen = kstream_write(ks, buf, len); + int writelen; + int origlen = len; + + while (TRUE) { + writelen = kstream_write(ks, buf, len); + + if (writelen == len) /* Success, first or Nth time */ + return (origlen); + + if (writelen == SOCKET_ERROR) { + if (WSAGetLastError() != WSAEWOULDBLOCK) + return (SOCKET_ERROR); /* Some error */ + /* For WOULDBLOCK, immediately repeat the send. */ + } + else { + /* Partial write; update the pointers and retry. */ + len -= writelen; + buf += writelen; + } + } +} + + +/* + * Function: Trim leading and trailing white space from a string. + * + * Parameters: + * s - the string to trim. + */ +void +trim(char *s) +{ + int l; + int i; - if (writelen == len) /* Success, first or Nth time */ - return (origlen); + for (i = 0; s[i]; i++) + if (s[i] != ' ' && s[i] != '\t') + break; - if (writelen == SOCKET_ERROR) { - if (WSAGetLastError() != WSAEWOULDBLOCK) - return (SOCKET_ERROR); /* Some error */ - /* For WOULDBLOCK, immediately repeat the send. */ - } - else { - /* Partial write; update the pointers and retry. */ - len -= writelen; - buf += writelen; - } - } + l = strlen(&s[i]); + memmove(s, &s[i], l + 1); -} /* TelnetSend */ + for (l--; l >= 0; l--) { + if (s[l] != ' ' && s[l] != '\t') + break; + } + s[l + 1] = 0; +} -/*+ - * Function: Trim leading and trailing white space from a string. +/* + * + * Parse_cmdline + * + * Reads hostname and port number off the command line. * - * Parameters: - * s - the string to trim. + * Formats: telnet + * telnet + * telnet + * telnet -p + * + * Returns: TRUE if we have a hostname */ -void trim( - char *s) +BOOL +parse_cmdline(char *cmdline) { - int l; - int i; - - for (i = 0; s[i]; i++) - if (s[i] != ' ' && s[i] != '\t') - break; - - l = strlen(&s[i]); - memmove(s, &s[i], l + 1); - - for (l--; l >= 0; l--) { - if (s[l] != ' ' && s[l] != '\t') - break; - } - s[l + 1] = 0; - -} /* trim */ - - -/*+ -** -** Parse_cmdline -** -** Reads hostname and port number off the command line. -** -** Formats: telnet -** telnet -** telnet -** telnet -p -** -** Returns: TRUE if we have a hostname -*/ -BOOL parse_cmdline( - char *cmdline) -{ - char *ptr; + char *ptr; - *szHostName = '\0'; // Nothing yet - if (*cmdline == '\0') // Empty command line? - return(FALSE); + *szHostName = '\0'; /* Nothing yet */ + if (*cmdline == '\0') /* Empty command line? */ + return(FALSE); - trim (cmdline); // Remove excess spaces - ptr = strchr (cmdline, ' '); // Find 2nd token + trim (cmdline); /* Remove excess spaces */ + ptr = strchr (cmdline, ' '); /* Find 2nd token */ - if (ptr != NULL) { // Port number given - *ptr++ = '\0'; // Separate into 2 words - port_no = atoi (ptr); - } + if (ptr != NULL) { /* Port number given */ + *ptr++ = '\0'; /* Separate into 2 words */ + port_no = atoi (ptr); + } - if (*cmdline != '-' && *cmdline != '/') { // Host name given - lstrcpy (szHostName, cmdline); - return(TRUE); - } + if (*cmdline != '-' && *cmdline != '/') { /* Host name given */ + lstrcpy (szHostName, cmdline); + return(TRUE); + } - return(FALSE); + return(FALSE); +} -} /* parse_cmdline */ +#ifdef DEBUG +void +hexdump(char *msg, unsigned char *st, int cnt) +{ + int i; + char strTmp[128]; + + OutputDebugString("\r\n"); + if (msg != NULL) { + OutputDebugString(msg); + OutputDebugString("\r\n"); + } + for(i = 0 ; i < cnt ; i++) { + int j; + + for(j = 0 ; (j < 16) && ((i + j) < cnt) ; j++) { + wsprintf(strTmp,"%02x ", st[i + j]); + if (j == 8) + OutputDebugString("| "); + OutputDebugString(strTmp); + } + i += j - 1; + OutputDebugString("\r\n"); + } /* end for */ +} +#endif diff --git a/src/windows/wintel/telnet.dlg b/src/windows/wintel/telnet.dlg deleted file mode 100644 index 8b73ee842..000000000 --- a/src/windows/wintel/telnet.dlg +++ /dev/null @@ -1,77 +0,0 @@ -DLGINCLUDE RCDATA DISCARDABLE -BEGIN - "DIALOG.H\0" -END - -OPENTELNETDLG DIALOG 63, 65, 175, 51 -STYLE DS_ABSALIGN | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Open New Telnet Connection" -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "To Host:", -1, "STATIC", NOT WS_GROUP, 3, 10, 33, 10 - CONTROL "", TEL_CONNECT_NAME, "COMBOBOX", CBS_DROPDOWN | WS_VSCROLL | WS_GROUP | WS_TABSTOP, 42, 9, 128, 60 - CONTROL "OK", TEL_OK, "BUTTON", WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON, 27, 30, 51, 14 - CONTROL "Cancel", TEL_CANCEL, "BUTTON", WS_TABSTOP, 97, 30, 51, 14 -END - -ABOUTBOX DIALOG 69, 33, 175, 148 -STYLE DS_ABSALIGN | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU -CAPTION "About TCPwin" -BEGIN - ICON "NCSA", -1, 15, 12, 16, 16 - CTEXT "Microsoft Windows", -1, 48, 11, 93, 8 - CTEXT "NCSA TCP/IP Networking Kernel", -1, 38, 21, 120, 8 - CTEXT "Version 1.0b2", -1, 20, 31, 144, 8 - CONTROL "OK", IDOK, "BUTTON", WS_GROUP, 72, 126, 39, 14 - CTEXT "Written By:", 606, 20, 50, 144, 8 - CTEXT "Jon Mittelhauser (jonm@ncsa.uiuc.edu)", 607, 20, 61, 144, 8 - CTEXT "Chris Wilson (cwilson@ncsa.uiuc.edu)", 608, 20, 71, 144, 8 - CTEXT "Special Thanks to:", 609, 21, 97, 143, 8 - CTEXT "Joe Lepore for DPMI interface code", 610, 20, 107, 144, 8 - CTEXT "Keberized by: Cygnus Support", 611, 20, 82, 144, 8 -END - -CONFIG_DLG DIALOG 6, 18, 160, 130 -STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Configure Session" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Session Name:", 301, 1, 5, 54, 8 - LTEXT "Default Session", CON_SESSIONNAME, 55, 5, 105, 8 - LTEXT "Window Title:", 303, 1, 17, 49, 8 - EDITTEXT CON_WINDOWTITLE, 53, 15, 102, 12, ES_AUTOHSCROLL - CONTROL "132", CON_COLUMNS132, "Button", BS_AUTORADIOBUTTON | - WS_GROUP, 53, 33, 39, 10 - CONTROL "80", CON_COLUMNS80, "Button", BS_AUTORADIOBUTTON, 110, - 33, 39, 10 - CONTROL "Backspace", CON_BACKSPACE, "Button", BS_AUTORADIOBUTTON | - WS_GROUP, 53, 46, 49, 10 - CONTROL "Delete", CON_DELETE, "Button", BS_AUTORADIOBUTTON, 110, - 46, 39, 10 - CONTROL "CRLF", CON_CRLF, "Button", BS_AUTORADIOBUTTON | - WS_GROUP, 53, 59, 39, 10 - CONTROL "CR-NUL", CON_CRNUL, "Button", BS_AUTORADIOBUTTON, 110, - 59, 39, 10 - CONTROL "Buffers", CON_BUFFERS, "Button", BS_AUTORADIOBUTTON | - WS_GROUP, 53, 72, 39, 10 - CONTROL "Sends", CON_SENDS, "Button", BS_AUTORADIOBUTTON, 110, - 72, 39, 10 - LTEXT "Columns", 313, 1, 33, 49, 8 - LTEXT "Backspace is", 314, 1, 46, 51, 8 - LTEXT "Return Sends", 315, 1, 59, 49, 8 - LTEXT "Echo Mode", 316, 1, 72, 49, 8 - CONTROL "Scrollback", CON_SCRLBCK, "Button", BS_AUTOCHECKBOX | - WS_TABSTOP, 1, 86, 50, 10 - EDITTEXT CON_NUMLINES, 53, 85, 28, 12, ES_AUTOHSCROLL - LTEXT "lines", 319, 85, 86, 33, 8 - DEFPUSHBUTTON "OK", CON_OK, 20, 108, 50, 14, WS_GROUP - PUSHBUTTON "Use Defaults", CON_USEDEFAULTS, 90, 108, 50, 14 -END - -IDM_PRINTQUEUE DIALOG 69, 25, 160, 80 -STYLE WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | - WS_VSCROLL | WS_HSCROLL | WS_SYSMENU -CAPTION "Print Queue" -FONT 8, "MS Sans Serif" -BEGIN -END diff --git a/src/windows/wintel/telnet.h b/src/windows/wintel/telnet.h index 3a69dd1f2..cd1904a14 100644 --- a/src/windows/wintel/telnet.h +++ b/src/windows/wintel/telnet.h @@ -5,8 +5,8 @@ #include #ifdef KRB5 - #include "krb5.h" - #include "k5stream.h" +#include "krb5.h" +#include "k5stream.h" #endif #include "dialog.h" @@ -22,21 +22,20 @@ extern char szUserName[64]; extern char szHostName[64]; #ifdef KRB5 - extern krb5_context k5_context; +extern krb5_context k5_context; #endif -extern void parse( - CONNECTION *con, - unsigned char *st, - int cnt); +extern void parse(CONNECTION *, unsigned char *, int); -extern void send_naws( - CONNECTION *con); +extern void send_naws(CONNECTION *); extern char strTmp[1024]; #define DEF_WIDTH 80 #define DEF_HEIGHT 24 -#endif /* TELNET_H_INC */ +#ifdef DEBUG +void hexdump(char *, unsigned char *, int); +#endif +#endif /* TELNET_H_INC */ diff --git a/src/windows/wintel/telnet.rc b/src/windows/wintel/telnet.rc index ba0038228..bdd18d973 100644 --- a/src/windows/wintel/telnet.rc +++ b/src/windows/wintel/telnet.rc @@ -1,27 +1,244 @@ -#include +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +#undef APSTUDIO_HIDDEN_SYMBOLS #include "dialog.h" -#include "telnet.dlg" #include "screen.h" -NCSA ICON ncsa.ico -TERMINAL ICON terminal.ico - -ScreenMenu MENU -BEGIN - POPUP "&Configure" - BEGIN - MENUITEM "&Backspace", IDM_BACKSPACE, CHECKED - MENUITEM "&Delete", IDM_DELETE - MENUITEM SEPARATOR - MENUITEM "&Font...", IDM_FONT - MENUITEM "&About...", IDM_ABOUT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Copy Cltr+Ins",IDM_COPY - MENUITEM "&Paste Shift+Ins", IDM_PASTE - #if ! defined(NDEBUG) - MENUITEM "&Debug", IDM_DEBUG - #endif - END +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +OPENTELNETDLG DIALOG DISCARDABLE 63, 65, 175, 129 +#ifdef _WIN32 +STYLE DS_ABSALIGN | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION | + WS_SYSMENU +#else +STYLE DS_ABSALIGN | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +#endif +CAPTION "Open New Telnet Connection" +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "To Host:",IDC_STATIC,3,10,33,10,NOT WS_GROUP + COMBOBOX TEL_CONNECT_NAME,37,9,128,76,CBS_DROPDOWN | WS_VSCROLL | + WS_GROUP | WS_TABSTOP + CONTROL "Forward credentials",IDC_FORWARD,"Button", + BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,37,28,77,10 + CONTROL "Forward remote credentials",IDC_FORWARDFORWARD,"Button", + BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,37,44,101,10 + CONTROL "Enable encryption",IDC_ENCRYPT,"Button",BS_AUTOCHECKBOX | + WS_DISABLED | WS_TABSTOP,37,60,73,10 + CONTROL "Connect as userid",IDC_STATIC,"Static", + SS_LEFTNOWORDWRAP,15,84,58,8 + EDITTEXT TEL_CONNECT_USERID,77,82,80,13,ES_AUTOHSCROLL | + WS_DISABLED + DEFPUSHBUTTON "OK",TEL_OK,20,106,51,14,WS_GROUP + PUSHBUTTON "Cancel",TEL_CANCEL,106,106,51,14 +END + +ABOUTBOX DIALOG DISCARDABLE 69, 33, 175, 148 +STYLE DS_ABSALIGN | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU +CAPTION "About TCPwin" +BEGIN + ICON "NCSA",-1,15,12,16,16 + CTEXT "Microsoft Windows",-1,48,11,93,8 + CTEXT "NCSA TCP/IP Networking Kernel",-1,38,21,120,8 + CTEXT "Version 1.0b2",-1,20,31,144,8 + PUSHBUTTON "OK",IDOK,72,126,39,14,WS_GROUP | NOT WS_TABSTOP + CTEXT "Written By:",606,20,50,144,8 + CTEXT "Jon Mittelhauser (jonm@ncsa.uiuc.edu)",607,20,61,144,8 + CTEXT "Chris Wilson (cwilson@ncsa.uiuc.edu)",608,20,71,144,8 + CTEXT "Special Thanks to:",609,21,97,143,8 + CTEXT "Joe Lepore for DPMI interface code",610,20,107,144,8 + CTEXT "Keberized by: Cygnus Support",611,20,82,144,8 +END + +CONFIG_DLG DIALOG DISCARDABLE 6, 18, 160, 130 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Configure Session" +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "Session Name:",301,1,5,54,8 + LTEXT "Default Session",CON_SESSIONNAME,55,5,105,8 + LTEXT "Window Title:",303,1,17,49,8 + EDITTEXT CON_WINDOWTITLE,53,15,102,12,ES_AUTOHSCROLL + CONTROL "132",CON_COLUMNS132,"Button",BS_AUTORADIOBUTTON | + WS_GROUP,53,33,39,10 + CONTROL "80",CON_COLUMNS80,"Button",BS_AUTORADIOBUTTON,110,33,39, + 10 + CONTROL "Backspace",CON_BACKSPACE,"Button",BS_AUTORADIOBUTTON | + WS_GROUP,53,46,49,10 + CONTROL "Delete",CON_DELETE,"Button",BS_AUTORADIOBUTTON,110,46, + 39,10 + CONTROL "CRLF",CON_CRLF,"Button",BS_AUTORADIOBUTTON | WS_GROUP, + 53,59,39,10 + CONTROL "CR-NUL",CON_CRNUL,"Button",BS_AUTORADIOBUTTON,110,59,39, + 10 + CONTROL "Buffers",CON_BUFFERS,"Button",BS_AUTORADIOBUTTON | + WS_GROUP,53,72,39,10 + CONTROL "Sends",CON_SENDS,"Button",BS_AUTORADIOBUTTON,110,72,39, + 10 + LTEXT "Columns",313,1,33,49,8 + LTEXT "Backspace is",314,1,46,51,8 + LTEXT "Return Sends",315,1,59,49,8 + LTEXT "Echo Mode",316,1,72,49,8 + CONTROL "Scrollback",CON_SCRLBCK,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,1,86,50,10 + EDITTEXT CON_NUMLINES,53,85,28,12,ES_AUTOHSCROLL + LTEXT "lines",319,85,86,33,8 + DEFPUSHBUTTON "OK",CON_OK,20,108,50,14,WS_GROUP + PUSHBUTTON "Use Defaults",CON_USEDEFAULTS,90,108,50,14 +END + +IDM_PRINTQUEUE DIALOG DISCARDABLE 69, 25, 160, 80 +STYLE WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | + WS_VSCROLL | WS_HSCROLL | WS_SYSMENU +CAPTION "Print Queue" +FONT 8, "MS Sans Serif" +BEGIN +END + +IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 183, 92 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Dialog" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,126,7,50,14 + PUSHBUTTON "Cancel",IDCANCEL,126,24,50,14 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +NCSA ICON DISCARDABLE "ncsa.ico" +TERMINAL ICON DISCARDABLE "terminal.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +SCREENMENU MENU DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "E&xit Alt+F4", IDM_EXIT + END + POPUP "&Edit" + BEGIN + MENUITEM "&Copy Cltr+Ins", IDM_COPY + MENUITEM "&Paste Shift+Ins", IDM_PASTE + END + POPUP "&Options" + BEGIN + MENUITEM "&Backspace", IDM_BACKSPACE + MENUITEM "&Delete", IDM_DELETE, CHECKED + MENUITEM SEPARATOR + MENUITEM "&Font...", IDM_FONT + END +#if 0 + POPUP "&Send", GRAYED + BEGIN + MENUITEM "&Interrupt Process", IDM_SEND_IP + MENUITEM "&Are You There?", IDM_SEND_AYT + MENUITEM "A&bort Process", IDM_SEND_ABORT + END +#endif + POPUP "&Help" + BEGIN + MENUITEM "&Index...", IDM_HELP_INDEX + MENUITEM SEPARATOR + MENUITEM "&About...", IDM_ABOUT + END END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""windows.h""\r\n" + "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""dialog.h""\r\n" + "#include ""screen.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_DIALOG1, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 176 + TOPMARGIN, 7 + BOTTOMMARGIN, 85 + END +END +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/src/windows/wintel/telnet_arpa.h b/src/windows/wintel/telnet_arpa.h new file mode 100644 index 000000000..f6d0eb566 --- /dev/null +++ b/src/windows/wintel/telnet_arpa.h @@ -0,0 +1,327 @@ +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)telnet.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _TELNET_H_ +#define _TELNET_H_ + +/* + * Definitions for the TELNET protocol. + */ +#define IAC 255 /* interpret as command: */ +#define DONT 254 /* you are not to use option */ +#define DO 253 /* please, you use option */ +#define WONT 252 /* I won't use option */ +#define WILL 251 /* I will use option */ +#define SB 250 /* interpret as subnegotiation */ +#define GA 249 /* you may reverse the line */ +#define EL 248 /* erase the current line */ +#define EC 247 /* erase the current character */ +#define AYT 246 /* are you there */ +#define AO 245 /* abort output--but let prog finish */ +#define IP 244 /* interrupt process--permanently */ +#define BREAK 243 /* break */ +#define DM 242 /* data mark--for connect. cleaning */ +#define NOP 241 /* nop */ +#define SE 240 /* end sub negotiation */ +#define EOR 239 /* end of record (transparent mode) */ +#define ABORT 238 /* Abort process */ +#define SUSP 237 /* Suspend process */ +#define xEOF 236 /* End of file: EOF is already used... */ + +#define SYNCH 242 /* for telfunc calls */ + +#ifdef TELCMDS +char *telcmds[] = { + "EOF", "SUSP", "ABORT", "EOR", + "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", + "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0, +}; +#else +extern char *telcmds[]; +#endif + +#define TELCMD_FIRST xEOF +#define TELCMD_LAST IAC +#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \ + (unsigned int)(x) >= TELCMD_FIRST) +#define TELCMD(x) telcmds[(x)-TELCMD_FIRST] + +/* telnet options */ +#define TELOPT_BINARY 0 /* 8-bit data path */ +#define TELOPT_ECHO 1 /* echo */ +#define TELOPT_RCP 2 /* prepare to reconnect */ +#define TELOPT_SGA 3 /* suppress go ahead */ +#define TELOPT_NAMS 4 /* approximate message size */ +#define TELOPT_STATUS 5 /* give status */ +#define TELOPT_TM 6 /* timing mark */ +#define TELOPT_RCTE 7 /* remote controlled transmission and echo */ +#define TELOPT_NAOL 8 /* negotiate about output line width */ +#define TELOPT_NAOP 9 /* negotiate about output page size */ +#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */ +#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */ +#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */ +#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */ +#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */ +#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */ +#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */ +#define TELOPT_XASCII 17 /* extended ascic character set */ +#define TELOPT_LOGOUT 18 /* force logout */ +#define TELOPT_BM 19 /* byte macro */ +#define TELOPT_DET 20 /* data entry terminal */ +#define TELOPT_SUPDUP 21 /* supdup protocol */ +#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */ +#define TELOPT_SNDLOC 23 /* send location */ +#define TELOPT_TTYPE 24 /* terminal type */ +#define TELOPT_EOR 25 /* end or record */ +#define TELOPT_TUID 26 /* TACACS user identification */ +#define TELOPT_OUTMRK 27 /* output marking */ +#define TELOPT_TTYLOC 28 /* terminal location number */ +#define TELOPT_3270REGIME 29 /* 3270 regime */ +#define TELOPT_X3PAD 30 /* X.3 PAD */ +#define TELOPT_NAWS 31 /* window size */ +#define TELOPT_TSPEED 32 /* terminal speed */ +#define TELOPT_LFLOW 33 /* remote flow control */ +#define TELOPT_LINEMODE 34 /* Linemode option */ +#define TELOPT_XDISPLOC 35 /* X Display Location */ +#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */ +#define TELOPT_AUTHENTICATION 37/* Authenticate */ +#define TELOPT_ENCRYPT 38 /* Encryption option */ +#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */ +#define TELOPT_EXOPL 255 /* extended-options-list */ + + +#define NTELOPTS (1+TELOPT_NEW_ENVIRON) +#ifdef TELOPTS +char *telopts[NTELOPTS+1] = { + "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", + "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", + "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS", + "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO", + "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT", + "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", + "TACACS UID", "OUTPUT MARKING", "TTYLOC", + "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW", + "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION", + "ENCRYPT", "NEW-ENVIRON", + 0, +}; +#define TELOPT_FIRST TELOPT_BINARY +#define TELOPT_LAST TELOPT_NEW_ENVIRON +#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST) +#define TELOPT(x) telopts[(x)-TELOPT_FIRST] +#endif + +/* sub-option qualifiers */ +#define TELQUAL_IS 0 /* option is... */ +#define TELQUAL_SEND 1 /* send option */ +#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */ +#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */ +#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */ + +#define LFLOW_OFF 0 /* Disable remote flow control */ +#define LFLOW_ON 1 /* Enable remote flow control */ +#define LFLOW_RESTART_ANY 2 /* Restart output on any char */ +#define LFLOW_RESTART_XON 3 /* Restart output only on XON */ + +/* + * LINEMODE suboptions + */ + +#define LM_MODE 1 +#define LM_FORWARDMASK 2 +#define LM_SLC 3 + +#define MODE_EDIT 0x01 +#define MODE_TRAPSIG 0x02 +#define MODE_ACK 0x04 +#define MODE_SOFT_TAB 0x08 +#define MODE_LIT_ECHO 0x10 + +#define MODE_MASK 0x1f + +/* Not part of protocol, but needed to simplify things... */ +#define MODE_FLOW 0x0100 +#define MODE_ECHO 0x0200 +#define MODE_INBIN 0x0400 +#define MODE_OUTBIN 0x0800 +#define MODE_FORCE 0x1000 + +#define SLC_SYNCH 1 +#define SLC_BRK 2 +#define SLC_IP 3 +#define SLC_AO 4 +#define SLC_AYT 5 +#define SLC_EOR 6 +#define SLC_ABORT 7 +#define SLC_EOF 8 +#define SLC_SUSP 9 +#define SLC_EC 10 +#define SLC_EL 11 +#define SLC_EW 12 +#define SLC_RP 13 +#define SLC_LNEXT 14 +#define SLC_XON 15 +#define SLC_XOFF 16 +#define SLC_FORW1 17 +#define SLC_FORW2 18 + +#define NSLC 18 + +/* + * For backwards compatability, we define SLC_NAMES to be the + * list of names if SLC_NAMES is not defined. + */ +#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \ + "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \ + "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0, +#ifdef SLC_NAMES +char *slc_names[] = { + SLC_NAMELIST +}; +#else +extern char *slc_names[]; +#define SLC_NAMES SLC_NAMELIST +#endif + +#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC) +#define SLC_NAME(x) slc_names[x] + +#define SLC_NOSUPPORT 0 +#define SLC_CANTCHANGE 1 +#define SLC_VARIABLE 2 +#define SLC_DEFAULT 3 +#define SLC_LEVELBITS 0x03 + +#define SLC_FUNC 0 +#define SLC_FLAGS 1 +#define SLC_VALUE 2 + +#define SLC_ACK 0x80 +#define SLC_FLUSHIN 0x40 +#define SLC_FLUSHOUT 0x20 + +#define OLD_ENV_VAR 1 +#define OLD_ENV_VALUE 0 +#define NEW_ENV_VAR 0 +#define NEW_ENV_VALUE 1 +#define ENV_ESC 2 +#define ENV_USERVAR 3 + +/* + * AUTHENTICATION suboptions + */ + +/* + * Who is authenticating who ... + */ +#define AUTH_WHO_CLIENT 0 /* Client authenticating server */ +#define AUTH_WHO_SERVER 1 /* Server authenticating client */ +#define AUTH_WHO_MASK 1 + +/* + * amount of authentication done + */ +#define AUTH_HOW_ONE_WAY 0 +#define AUTH_HOW_MUTUAL 2 +#define AUTH_HOW_MASK 2 + +/* + * should we be encrypting? (not yet formally standardized) + */ +#define AUTH_ENCRYPT_OFF 0 +#define AUTH_ENCRYPT_ON 4 +#define AUTH_ENCRYPT_MASK 4 + +#define AUTHTYPE_NULL 0 +#define AUTHTYPE_KERBEROS_V4 1 +#define AUTHTYPE_KERBEROS_V5 2 +#define AUTHTYPE_SPX 3 +#define AUTHTYPE_MINK 4 +#define AUTHTYPE_CNT 5 + +#define AUTHTYPE_TEST 99 + +#ifdef AUTH_NAMES +char *authtype_names[] = { + "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0, +}; +#else +extern char *authtype_names[]; +#endif + +#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT) +#define AUTHTYPE_NAME(x) authtype_names[x] + +/* + * ENCRYPTion suboptions + */ +#define ENCRYPT_IS 0 /* I pick encryption type ... */ +#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */ +#define ENCRYPT_REPLY 2 /* Initial setup response */ +#define ENCRYPT_START 3 /* Am starting to send encrypted */ +#define ENCRYPT_END 4 /* Am ending encrypted */ +#define ENCRYPT_REQSTART 5 /* Request you start encrypting */ +#define ENCRYPT_REQEND 6 /* Request you send encrypting */ +#define ENCRYPT_ENC_KEYID 7 +#define ENCRYPT_DEC_KEYID 8 +#define ENCRYPT_CNT 9 + +#define ENCTYPE_ANY 0 +#define ENCTYPE_DES_CFB64 1 +#define ENCTYPE_DES_OFB64 2 +#define ENCTYPE_CNT 3 + +#ifdef ENCRYPT_NAMES +char *encrypt_names[] = { + "IS", "SUPPORT", "REPLY", "START", "END", + "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID", + 0, +}; +char *enctype_names[] = { + "ANY", "DES_CFB64", "DES_OFB64", 0, +}; +#else +extern char *encrypt_names[]; +extern char *enctype_names[]; +#endif + + +#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT) +#define ENCRYPT_NAME(x) encrypt_names[x] + +#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT) +#define ENCTYPE_NAME(x) enctype_names[x] + +#endif /* !_TELNET_H_ */ diff --git a/src/windows/wintel/telopts.h b/src/windows/wintel/telopts.h index e928a8428..54d67cde3 100644 --- a/src/windows/wintel/telopts.h +++ b/src/windows/wintel/telopts.h @@ -1,22 +1,22 @@ /* -* telopts.h -* Used for telnet options -**************************************************************************** -* * -* * -* NCSA Telnet * -* by Tim Krauskopf, VT100 by Gaige Paulsen, Tek by Aaron Contorer * -* Additions by Kurt Mahan, Heeren Pathak, & Quincey Koziol * -* * -* National Center for Supercomputing Applications * -* 152 Computing Applications Building * -* 605 E. Springfield Ave. * -* Champaign, IL 61820 * -* * -**************************************************************************** -* Quincey Koziol -* Defines for telnet options and related things -*/ + * telopts.h + * Used for telnet options + **************************************************************************** + * * + * * + * NCSA Telnet * + * by Tim Krauskopf, VT100 by Gaige Paulsen, Tek by Aaron Contorer * + * Additions by Kurt Mahan, Heeren Pathak, & Quincey Koziol * + * * + * National Center for Supercomputing Applications * + * 152 Computing Applications Building * + * 605 E. Springfield Ave. * + * Champaign, IL 61820 * + * * + **************************************************************************** + * Quincey Koziol + * Defines for telnet options and related things + */ #ifndef TELOPTS_H #define TELOPTS_H @@ -37,18 +37,18 @@ #define SE 240 #define NOP 241 #define DM 242 -#define BREAK 243 +#define BREAK 243 #define IP 244 #define AO 245 #define AYT 246 #define EC 247 #define EL 248 -#define GOAHEAD 249 +#define GOAHEAD 249 #define SB 250 -#define WILLTEL 251 -#define WONTTEL 252 -#define DOTEL 253 -#define DONTTEL 254 +#define WILLTEL 251 +#define WONTTEL 252 +#define DOTEL 253 +#define DONTTEL 254 #define IAC 255 /* Assigned Telnet Options */ @@ -87,68 +87,74 @@ #define TERMSPEED 32 #define TFLOWCNTRL 33 #define LINEMODE 34 - #define MODE 1 - #define MODE_EDIT 1 - #define MODE_TRAPSIG 2 - #define MODE_ACK 4 - #define MODE_SOFT_TAB 8 - #define MODE_LIT_ECHO 16 - - #define FORWARDMASK 2 - - #define SLC 3 - #define SLC_DEFAULT 3 - #define SLC_VALUE 2 - #define SLC_CANTCHANGE 1 - #define SLC_NOSUPPORT 0 - #define SLC_LEVELBITS 3 - - #define SLC_ACK 128 - #define SLC_FLUSHIN 64 - #define SLC_FLUSHOUT 32 - - #define SLC_SYNCH 1 - #define SLC_BRK 2 - #define SLC_IP 3 - #define SLC_AO 4 - #define SLC_AYT 5 - #define SLC_EOR 6 - #define SLC_ABORT 7 - #define SLC_EOF 8 - #define SLC_SUSP 9 - #define SLC_EC 10 - #define SLC_EL 11 - #define SLC_EW 12 - #define SLC_RP 13 - #define SLC_LNEXT 14 - #define SLC_XON 15 - #define SLC_XOFF 16 - #define SLC_FORW1 17 - #define SLC_FORW2 18 - #define SLC_MCL 19 - #define SLC_MCR 20 - #define SLC_MCWL 21 - #define SLC_MCWR 22 - #define SLC_MCBOL 23 - #define SLC_MCEOL 24 - #define SLC_INSRT 25 - #define SLC_OVER 26 - #define SLC_ECR 27 - #define SLC_EWR 28 - #define SLC_EBOL 29 - #define SLC_EEOL 30 - -#define XDISPLOC 35 -#define ENVIRONMENT 36 + +#define MODE 1 +#define MODE_EDIT 1 +#define MODE_TRAPSIG 2 +#define MODE_ACK 4 +#define MODE_SOFT_TAB 8 +#define MODE_LIT_ECHO 16 + +#define FORWARDMASK 2 + +#define SLC 3 +#define SLC_DEFAULT 3 +#define SLC_VALUE 2 +#define SLC_CANTCHANGE 1 +#define SLC_NOSUPPORT 0 +#define SLC_LEVELBITS 3 + +#define SLC_ACK 128 +#define SLC_FLUSHIN 64 +#define SLC_FLUSHOUT 32 + +#define SLC_SYNCH 1 +#define SLC_BRK 2 +#define SLC_IP 3 +#define SLC_AO 4 +#define SLC_AYT 5 +#define SLC_EOR 6 +#define SLC_ABORT 7 +#define SLC_EOF 8 +#define SLC_SUSP 9 +#define SLC_EC 10 +#define SLC_EL 11 +#define SLC_EW 12 +#define SLC_RP 13 +#define SLC_LNEXT 14 +#define SLC_XON 15 +#define SLC_XOFF 16 +#define SLC_FORW1 17 +#define SLC_FORW2 18 +#define SLC_MCL 19 +#define SLC_MCR 20 +#define SLC_MCWL 21 +#define SLC_MCWR 22 +#define SLC_MCBOL 23 +#define SLC_MCEOL 24 +#define SLC_INSRT 25 +#define SLC_OVER 26 +#define SLC_ECR 27 +#define SLC_EWR 28 +#define SLC_EBOL 29 +#define SLC_EEOL 30 + +#define XDISPLOC 35 +#define ENVIRONMENT 36 #define AUTHENTICATION 37 -#define DATA_ENCRYPTION 38 -#define XOPTIONS 255 +#define TELOPT_AUTHENTICATION AUTHENTICATION +#define DATA_ENCRYPTION 38 +#define XOPTIONS 255 #define LINEMODE_MODES_SUPPORTED 0x1B -/* set this flag for linemode special functions which are supported by Telnet, even though they are not currently active */ -/* This is to allow the other side to negotiate to a "No Support" state for an option */ -/* and then change later to supporting it, so we know it's ok to change our "No Support" */ -/* state to something else ("Can't Change", "Value", whatever) */ +/* + * set this flag for linemode special functions which are supported by + * Telnet, even though they are not currently active. This is to allow + * the other side to negotiate to a "No Support" state for an option + * and then change later to supporting it, so we know it's ok to change + * our "No Support" state to something else ("Can't Change", "Value", + * whatever) + */ #define SLC_SUPPORTED 0x10 #define ESCFOUND 5 @@ -156,4 +162,3 @@ #define NEGOTIATE 1 #endif /* telopts.h */ -