diff options
| author | Richard M. Stallman | 1996-06-08 00:15:00 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-06-08 00:15:00 +0000 |
| commit | a11e68d017e1dd8a8759c0f63fa601fd92eb5d66 (patch) | |
| tree | 7e12de44a16a30a8f877c0690866a9793bc22698 /src/w32proc.c | |
| parent | bff3ed0ac3598b3eafda5ca3a44ac9db102dcfb1 (diff) | |
| download | emacs-a11e68d017e1dd8a8759c0f63fa601fd92eb5d66.tar.gz emacs-a11e68d017e1dd8a8759c0f63fa601fd92eb5d66.zip | |
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
(syms_of_ntproc) [HAVE_SOCKETS]: defsubr them.
Diffstat (limited to 'src/w32proc.c')
| -rw-r--r-- | src/w32proc.c | 73 |
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 */ | ||
| 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\ |