comparison src/w32proc.c @ 15356:1a917c5d944c

(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions. (syms_of_ntproc) [HAVE_SOCKETS]: defsubr them.
author Richard M. Stallman <rms@gnu.org>
date Sat, 08 Jun 1996 00:15:00 +0000
parents 6deee3a18ba8
children 68887d34a610
comparison
equal deleted inserted replaced
15355:6bb377ef707f 15356:1a917c5d944c
1156 SetStdHandle (STD_INPUT_HANDLE, handles[0]); 1156 SetStdHandle (STD_INPUT_HANDLE, handles[0]);
1157 SetStdHandle (STD_OUTPUT_HANDLE, handles[1]); 1157 SetStdHandle (STD_OUTPUT_HANDLE, handles[1]);
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 */
1175 extern HANDLE winsock_lib;
1176 extern BOOL term_winsock (void);
1177 extern BOOL init_winsock (int load_now);
1178
1179 extern Lisp_Object Vsystem_name;
1180
1181 DEFUN ("win32-has-winsock", Fwin32_has_winsock, Swin32_has_winsock, 0, 1, 0,
1182 "Test for presence of the Windows socket library `winsock'.\n\
1183 Returns non-nil if winsock support is present, nil otherwise.\n\
1184 \n\
1185 If the optional argument LOAD-NOW is non-nil, the winsock library is\n\
1186 also loaded immediately if not already loaded. If winsock is loaded,\n\
1187 the winsock local hostname is returned (since this may be different from\n\
1188 the value of `system-name' and should supplant it), otherwise t is\n\
1189 returned 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
1216 DEFUN ("win32-unload-winsock", Fwin32_unload_winsock, Swin32_unload_winsock,
1217 0, 0, 0,
1218 "Unload the Windows socket library `winsock' if loaded.\n\
1219 This is provided to allow dial-up socket connections to be disconnected\n\
1220 when no longer needed. Returns nil without unloading winsock if any\n\
1221 socket connections still exist.")
1222 ()
1223 {
1224 return term_winsock () ? Qt : Qnil;
1225 }
1226
1227 #endif /* HAVE_SOCKETS */
1228
1161 1229
1162 syms_of_ntproc () 1230 syms_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\
1166 Because Windows does not directly pass argv arrays to child processes,\n\ 1239 Because Windows does not directly pass argv arrays to child processes,\n\
1167 programs have to reconstruct the argv array by parsing the command\n\ 1240 programs have to reconstruct the argv array by parsing the command\n\
1168 line string. For an argument to contain a space, it must be enclosed\n\ 1241 line string. For an argument to contain a space, it must be enclosed\n\