aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1996-06-08 00:15:00 +0000
committerRichard M. Stallman1996-06-08 00:15:00 +0000
commita11e68d017e1dd8a8759c0f63fa601fd92eb5d66 (patch)
tree7e12de44a16a30a8f877c0690866a9793bc22698
parentbff3ed0ac3598b3eafda5ca3a44ac9db102dcfb1 (diff)
downloademacs-a11e68d017e1dd8a8759c0f63fa601fd92eb5d66.tar.gz
emacs-a11e68d017e1dd8a8759c0f63fa601fd92eb5d66.zip
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
(syms_of_ntproc) [HAVE_SOCKETS]: defsubr them.
-rw-r--r--src/w32proc.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/w32proc.c b/src/w32proc.c
index 1f8e8353238..89167148854 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -1158,9 +1158,82 @@ reset_standard_handles (int in, int out, int err, HANDLE handles[3])
1158 SetStdHandle (STD_ERROR_HANDLE, handles[2]); 1158 SetStdHandle (STD_ERROR_HANDLE, handles[2]);
1159} 1159}
1160 1160
1161#ifdef HAVE_SOCKETS
1162
1163/* To avoid problems with winsock implementations that work over dial-up
1164 connections causing or requiring a connection to exist while Emacs is
1165 running, Emacs no longer automatically loads winsock on startup if it
1166 is present. Instead, it will be loaded when open-network-stream is
1167 first called.
1168
1169 To allow full control over when winsock is loaded, we provide these
1170 two functions to dynamically load and unload winsock. This allows
1171 dial-up users to only be connected when they actually need to use
1172 socket services. */
1173
1174/* From nt.c */
1175extern HANDLE winsock_lib;
1176extern BOOL term_winsock (void);
1177extern BOOL init_winsock (int load_now);
1178
1179extern Lisp_Object Vsystem_name;
1180
1181DEFUN ("win32-has-winsock", Fwin32_has_winsock, Swin32_has_winsock, 0, 1, 0,
1182 "Test for presence of the Windows socket library `winsock'.\n\
1183Returns non-nil if winsock support is present, nil otherwise.\n\
1184\n\
1185If the optional argument LOAD-NOW is non-nil, the winsock library is\n\
1186also loaded immediately if not already loaded. If winsock is loaded,\n\
1187the winsock local hostname is returned (since this may be different from\n\
1188the value of `system-name' and should supplant it), otherwise t is\n\
1189returned to indicate winsock support is present.")
1190 (load_now)
1191 Lisp_Object load_now;
1192{
1193 int have_winsock;
1194
1195 have_winsock = init_winsock (!NILP (load_now));
1196 if (have_winsock)
1197 {
1198 if (winsock_lib != NULL)
1199 {
1200 /* Return new value for system-name. The best way to do this
1201 is to call init_system_name, saving and restoring the
1202 original value to avoid side-effects. */
1203 Lisp_Object orig_hostname = Vsystem_name;
1204 Lisp_Object hostname;
1205
1206 init_system_name ();
1207 hostname = Vsystem_name;
1208 Vsystem_name = orig_hostname;
1209 return hostname;
1210 }
1211 return Qt;
1212 }
1213 return Qnil;
1214}
1215
1216DEFUN ("win32-unload-winsock", Fwin32_unload_winsock, Swin32_unload_winsock,
1217 0, 0, 0,
1218 "Unload the Windows socket library `winsock' if loaded.\n\
1219This is provided to allow dial-up socket connections to be disconnected\n\
1220when no longer needed. Returns nil without unloading winsock if any\n\
1221socket connections still exist.")
1222 ()
1223{
1224 return term_winsock () ? Qt : Qnil;
1225}
1226
1227#endif /* HAVE_SOCKETS */
1228
1161 1229
1162syms_of_ntproc () 1230syms_of_ntproc ()
1163{ 1231{
1232#ifdef HAVE_SOCKETS
1233 defsubr (&Swin32_has_winsock);
1234 defsubr (&Swin32_unload_winsock);
1235#endif
1236
1164 DEFVAR_LISP ("win32-quote-process-args", &Vwin32_quote_process_args, 1237 DEFVAR_LISP ("win32-quote-process-args", &Vwin32_quote_process_args,
1165 "Non-nil enables quoting of process arguments to ensure correct parsing.\n\ 1238 "Non-nil enables quoting of process arguments to ensure correct parsing.\n\
1166Because Windows does not directly pass argv arrays to child processes,\n\ 1239Because Windows does not directly pass argv arrays to child processes,\n\