diff options
| author | Kim F. Storm | 2002-03-21 12:20:24 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2002-03-21 12:20:24 +0000 |
| commit | 9057ff80bc70af618d8b199f498165c30b088d24 (patch) | |
| tree | 51a6c2e633a4d197a77b4cbf356d8d9304c79815 /src/process.c | |
| parent | 37ebddef957500e7990c72786505a92e3bf17816 (diff) | |
| download | emacs-9057ff80bc70af618d8b199f498165c30b088d24.tar.gz emacs-9057ff80bc70af618d8b199f498165c30b088d24.zip | |
(QCfeature, QCdatagram): Removed variables.
(QCtype, Qdatagram): New variables.
(network_process_featurep): Removed function.
(Fmake_network_process): Removed :feature check.
Use :type 'datagram instead of :datagram t to create a datagram
socket. This allows us to add other connection types (e.g. raw
sockets) later in a consistent manner.
(init_process) [subprocess]: Provide list of supported subfeatures
for feature make-network-process.
(syms_of_process) [subprocess]: Remove QCfeature and QCdatagram.
Intern and staticpro QCtype and Qdatagram.
(syms_of_process) [!subprocess]: Intern and staticpro QCtype.
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 193 |
1 files changed, 72 insertions, 121 deletions
diff --git a/src/process.c b/src/process.c index 00bc4b2f0a3..33a4c2109d7 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -125,11 +125,11 @@ Boston, MA 02111-1307, USA. */ | |||
| 125 | Lisp_Object Qprocessp; | 125 | Lisp_Object Qprocessp; |
| 126 | Lisp_Object Qrun, Qstop, Qsignal; | 126 | Lisp_Object Qrun, Qstop, Qsignal; |
| 127 | Lisp_Object Qopen, Qclosed, Qconnect, Qfailed, Qlisten; | 127 | Lisp_Object Qopen, Qclosed, Qconnect, Qfailed, Qlisten; |
| 128 | Lisp_Object Qlocal; | 128 | Lisp_Object Qlocal, Qdatagram; |
| 129 | Lisp_Object QCname, QCbuffer, QChost, QCservice; | 129 | Lisp_Object QCname, QCbuffer, QChost, QCservice, QCtype; |
| 130 | Lisp_Object QClocal, QCremote, QCcoding; | 130 | Lisp_Object QClocal, QCremote, QCcoding; |
| 131 | Lisp_Object QCserver, QCdatagram, QCnowait, QCnoquery, QCstop; | 131 | Lisp_Object QCserver, QCnowait, QCnoquery, QCstop; |
| 132 | Lisp_Object QCsentinel, QClog, QCoptions, QCfeature; | 132 | Lisp_Object QCsentinel, QClog, QCoptions; |
| 133 | Lisp_Object Qlast_nonmenu_event; | 133 | Lisp_Object Qlast_nonmenu_event; |
| 134 | /* QCfamily is declared and initialized in xfaces.c, | 134 | /* QCfamily is declared and initialized in xfaces.c, |
| 135 | QCfilter in keyboard.c. */ | 135 | QCfilter in keyboard.c. */ |
| @@ -2380,94 +2380,6 @@ reuseaddr=BOOL -- Allow reusing a recently used address. */) | |||
| 2380 | return process; | 2380 | return process; |
| 2381 | } | 2381 | } |
| 2382 | 2382 | ||
| 2383 | /* Check whether a given KEY VALUE pair is supported on this system. */ | ||
| 2384 | |||
| 2385 | static int | ||
| 2386 | network_process_featurep (key, value) | ||
| 2387 | Lisp_Object key, value; | ||
| 2388 | { | ||
| 2389 | |||
| 2390 | if (EQ (key, QCnowait)) | ||
| 2391 | { | ||
| 2392 | #ifdef NON_BLOCKING_CONNECT | ||
| 2393 | return 1; | ||
| 2394 | #else | ||
| 2395 | return NILP (value); | ||
| 2396 | #endif | ||
| 2397 | } | ||
| 2398 | |||
| 2399 | if (EQ (key, QCdatagram)) | ||
| 2400 | { | ||
| 2401 | #ifdef DATAGRAM_SOCKETS | ||
| 2402 | return 1; | ||
| 2403 | #else | ||
| 2404 | return NILP (value); | ||
| 2405 | #endif | ||
| 2406 | } | ||
| 2407 | |||
| 2408 | if (EQ (key, QCfamily)) | ||
| 2409 | { | ||
| 2410 | if (NILP (value)) | ||
| 2411 | return 1; | ||
| 2412 | #ifdef HAVE_LOCAL_SOCKETS | ||
| 2413 | if (EQ (key, Qlocal)) | ||
| 2414 | return 1; | ||
| 2415 | #endif | ||
| 2416 | return 0; | ||
| 2417 | } | ||
| 2418 | |||
| 2419 | if (EQ (key, QCname)) | ||
| 2420 | return STRINGP (value); | ||
| 2421 | |||
| 2422 | if (EQ (key, QCbuffer)) | ||
| 2423 | return (NILP (value) || STRINGP (value) || BUFFERP (value)); | ||
| 2424 | |||
| 2425 | if (EQ (key, QClocal) || EQ (key, QCremote)) | ||
| 2426 | { | ||
| 2427 | int family; | ||
| 2428 | return get_lisp_to_sockaddr_size (value, &family); | ||
| 2429 | } | ||
| 2430 | |||
| 2431 | if (EQ (key, QChost)) | ||
| 2432 | return (NILP (value) || STRINGP (value)); | ||
| 2433 | |||
| 2434 | if (EQ (key, QCservice)) | ||
| 2435 | { | ||
| 2436 | #ifdef HAVE_GETSOCKNAME | ||
| 2437 | if (EQ (value, Qt)) | ||
| 2438 | return 1; | ||
| 2439 | #endif | ||
| 2440 | return (INTEGERP (value) || STRINGP (value)); | ||
| 2441 | } | ||
| 2442 | |||
| 2443 | if (EQ (key, QCserver)) | ||
| 2444 | { | ||
| 2445 | #ifndef TERM | ||
| 2446 | return 1; | ||
| 2447 | #else | ||
| 2448 | return NILP (value); | ||
| 2449 | #endif | ||
| 2450 | } | ||
| 2451 | |||
| 2452 | if (EQ (key, QCoptions)) | ||
| 2453 | return set_socket_options (-1, value, 0); | ||
| 2454 | |||
| 2455 | if (EQ (key, QCcoding)) | ||
| 2456 | return 1; | ||
| 2457 | if (EQ (key, QCsentinel)) | ||
| 2458 | return 1; | ||
| 2459 | if (EQ (key, QCfilter)) | ||
| 2460 | return 1; | ||
| 2461 | if (EQ (key, QClog)) | ||
| 2462 | return 1; | ||
| 2463 | if (EQ (key, QCnoquery)) | ||
| 2464 | return 1; | ||
| 2465 | if (EQ (key, QCstop)) | ||
| 2466 | return 1; | ||
| 2467 | |||
| 2468 | return 0; | ||
| 2469 | } | ||
| 2470 | |||
| 2471 | /* A version of request_sigio suitable for a record_unwind_protect. */ | 2383 | /* A version of request_sigio suitable for a record_unwind_protect. */ |
| 2472 | 2384 | ||
| 2473 | Lisp_Object | 2385 | Lisp_Object |
| @@ -2516,6 +2428,9 @@ host, and only clients connecting to that address will be accepted. | |||
| 2516 | integer specifying a port number to connect to. If SERVICE is t, | 2428 | integer specifying a port number to connect to. If SERVICE is t, |
| 2517 | a random port number is selected for the server. | 2429 | a random port number is selected for the server. |
| 2518 | 2430 | ||
| 2431 | :type TYPE -- TYPE is the type of connection. The default (nil) is a | ||
| 2432 | stream type connection, `datagram' creates a datagram type connection. | ||
| 2433 | |||
| 2519 | :family FAMILY -- FAMILY is the address (and protocol) family for the | 2434 | :family FAMILY -- FAMILY is the address (and protocol) family for the |
| 2520 | service specified by HOST and SERVICE. The default address family is | 2435 | service specified by HOST and SERVICE. The default address family is |
| 2521 | Inet (or IPv4) for the host and port number specified by HOST and | 2436 | Inet (or IPv4) for the host and port number specified by HOST and |
| @@ -2545,9 +2460,6 @@ defined constants, data sizes, and data structure alignment. | |||
| 2545 | 2460 | ||
| 2546 | :coding CODING -- CODING is coding system for this process. | 2461 | :coding CODING -- CODING is coding system for this process. |
| 2547 | 2462 | ||
| 2548 | :datagram BOOL -- Create a datagram type connection if BOOL is | ||
| 2549 | non-nil. Default is a stream type connection. | ||
| 2550 | |||
| 2551 | :options OPTIONS -- Set the specified options for the network process. | 2463 | :options OPTIONS -- Set the specified options for the network process. |
| 2552 | See `set-process-options' for details. | 2464 | See `set-process-options' for details. |
| 2553 | 2465 | ||
| @@ -2600,10 +2512,6 @@ the server process, but via `network-server-log-function' hook, a log | |||
| 2600 | of the accepted (and failed) connections may be recorded in the server | 2512 | of the accepted (and failed) connections may be recorded in the server |
| 2601 | process' buffer. | 2513 | process' buffer. |
| 2602 | 2514 | ||
| 2603 | The following special call returns t iff a given KEY VALUE | ||
| 2604 | pair is supported on this system: | ||
| 2605 | (make-network-process :feature KEY VALUE) | ||
| 2606 | |||
| 2607 | usage: (make-network-process &rest ARGS) */) | 2515 | usage: (make-network-process &rest ARGS) */) |
| 2608 | (nargs, args) | 2516 | (nargs, args) |
| 2609 | int nargs; | 2517 | int nargs; |
| @@ -2645,20 +2553,12 @@ usage: (make-network-process &rest ARGS) */) | |||
| 2645 | Lisp_Object filter, sentinel; | 2553 | Lisp_Object filter, sentinel; |
| 2646 | int is_non_blocking_client = 0; | 2554 | int is_non_blocking_client = 0; |
| 2647 | int is_server = 0; | 2555 | int is_server = 0; |
| 2648 | int socktype = SOCK_STREAM; | 2556 | int socktype; |
| 2649 | int family = -1; | 2557 | int family = -1; |
| 2650 | 2558 | ||
| 2651 | if (nargs == 0) | 2559 | if (nargs == 0) |
| 2652 | return Qnil; | 2560 | return Qnil; |
| 2653 | 2561 | ||
| 2654 | /* Handle :feature KEY VALUE query. */ | ||
| 2655 | if (EQ (args[0], QCfeature)) | ||
| 2656 | { | ||
| 2657 | if (nargs != 3) | ||
| 2658 | return Qnil; | ||
| 2659 | return network_process_featurep (args[1], args[2]) ? Qt : Qnil; | ||
| 2660 | } | ||
| 2661 | |||
| 2662 | /* Save arguments for process-contact and clone-process. */ | 2562 | /* Save arguments for process-contact and clone-process. */ |
| 2663 | contact = Flist (nargs, args); | 2563 | contact = Flist (nargs, args); |
| 2664 | GCPRO1 (contact); | 2564 | GCPRO1 (contact); |
| @@ -2668,16 +2568,16 @@ usage: (make-network-process &rest ARGS) */) | |||
| 2668 | init_winsock (TRUE); | 2568 | init_winsock (TRUE); |
| 2669 | #endif | 2569 | #endif |
| 2670 | 2570 | ||
| 2671 | /* :datagram BOOL */ | 2571 | /* :type TYPE (nil: stream, datagram */ |
| 2672 | tem = Fplist_get (contact, QCdatagram); | 2572 | tem = Fplist_get (contact, QCtype); |
| 2673 | if (!NILP (tem)) | 2573 | if (NILP (tem)) |
| 2674 | { | 2574 | socktype = SOCK_STREAM; |
| 2675 | #ifndef DATAGRAM_SOCKETS | 2575 | #ifdef DATAGRAM_SOCKETS |
| 2676 | error ("Datagram connections not supported"); | 2576 | else if (EQ (tem, Qdatagram)) |
| 2677 | #else | 2577 | socktype = SOCK_DGRAM; |
| 2678 | socktype = SOCK_DGRAM; | ||
| 2679 | #endif | 2578 | #endif |
| 2680 | } | 2579 | else |
| 2580 | error ("Unsupported connection type"); | ||
| 2681 | 2581 | ||
| 2682 | /* :server BOOL */ | 2582 | /* :server BOOL */ |
| 2683 | tem = Fplist_get (contact, QCserver); | 2583 | tem = Fplist_get (contact, QCserver); |
| @@ -6111,6 +6011,7 @@ void | |||
| 6111 | init_process () | 6011 | init_process () |
| 6112 | { | 6012 | { |
| 6113 | register int i; | 6013 | register int i; |
| 6014 | Lisp_Object subfeatures; | ||
| 6114 | 6015 | ||
| 6115 | #ifdef SIGCHLD | 6016 | #ifdef SIGCHLD |
| 6116 | #ifndef CANNOT_DUMP | 6017 | #ifndef CANNOT_DUMP |
| @@ -6137,6 +6038,51 @@ init_process () | |||
| 6137 | #ifdef DATAGRAM_SOCKETS | 6038 | #ifdef DATAGRAM_SOCKETS |
| 6138 | bzero (datagram_address, sizeof datagram_address); | 6039 | bzero (datagram_address, sizeof datagram_address); |
| 6139 | #endif | 6040 | #endif |
| 6041 | |||
| 6042 | #define ADD_SUBFEATURE(key, val) \ | ||
| 6043 | subfeatures = Fcons (Fcons (key, Fcons (val, Qnil)), subfeatures) | ||
| 6044 | |||
| 6045 | subfeatures = Qnil; | ||
| 6046 | #ifdef NON_BLOCKING_CONNECT | ||
| 6047 | ADD_SUBFEATURE (QCnowait, Qt); | ||
| 6048 | #endif | ||
| 6049 | #ifdef DATAGRAM_SOCKETS | ||
| 6050 | ADD_SUBFEATURE (QCtype, Qdatagram); | ||
| 6051 | #endif | ||
| 6052 | #ifdef HAVE_LOCAL_SOCKETS | ||
| 6053 | ADD_SUBFEATURE (QCfamily, Qlocal); | ||
| 6054 | #endif | ||
| 6055 | #ifdef HAVE_GETSOCKNAME | ||
| 6056 | ADD_SUBFEATURE (QCservice, Qt); | ||
| 6057 | #endif | ||
| 6058 | #ifndef TERM | ||
| 6059 | ADD_SUBFEATURE (QCserver, Qt); | ||
| 6060 | #endif | ||
| 6061 | #ifdef SO_BINDTODEVICE | ||
| 6062 | ADD_SUBFEATURE (QCoptions, intern ("bindtodevice")); | ||
| 6063 | #endif | ||
| 6064 | #ifdef SO_BROADCAST | ||
| 6065 | ADD_SUBFEATURE (QCoptions, intern ("broadcast")); | ||
| 6066 | #endif | ||
| 6067 | #ifdef SO_DONTROUTE | ||
| 6068 | ADD_SUBFEATURE (QCoptions, intern ("dontroute")); | ||
| 6069 | #endif | ||
| 6070 | #ifdef SO_KEEPALIVE | ||
| 6071 | ADD_SUBFEATURE (QCoptions, intern ("keepalive")); | ||
| 6072 | #endif | ||
| 6073 | #ifdef SO_LINGER | ||
| 6074 | ADD_SUBFEATURE (QCoptions, intern ("linger")); | ||
| 6075 | #endif | ||
| 6076 | #ifdef SO_OOBINLINE | ||
| 6077 | ADD_SUBFEATURE (QCoptions, intern ("oobinline")); | ||
| 6078 | #endif | ||
| 6079 | #ifdef SO_PRIORITY | ||
| 6080 | ADD_SUBFEATURE (QCoptions, intern ("priority")); | ||
| 6081 | #endif | ||
| 6082 | #ifdef SO_REUSEADDR | ||
| 6083 | ADD_SUBFEATURE (QCoptions, intern ("reuseaddr")); | ||
| 6084 | #endif | ||
| 6085 | Fprovide (intern ("make-network-process"), subfeatures); | ||
| 6140 | } | 6086 | } |
| 6141 | 6087 | ||
| 6142 | void | 6088 | void |
| @@ -6169,6 +6115,8 @@ syms_of_process () | |||
| 6169 | staticpro (&Qlisten); | 6115 | staticpro (&Qlisten); |
| 6170 | Qlocal = intern ("local"); | 6116 | Qlocal = intern ("local"); |
| 6171 | staticpro (&Qlocal); | 6117 | staticpro (&Qlocal); |
| 6118 | Qdatagram = intern ("datagram"); | ||
| 6119 | staticpro (&Qdatagram); | ||
| 6172 | 6120 | ||
| 6173 | QCname = intern (":name"); | 6121 | QCname = intern (":name"); |
| 6174 | staticpro (&QCname); | 6122 | staticpro (&QCname); |
| @@ -6178,6 +6126,8 @@ syms_of_process () | |||
| 6178 | staticpro (&QChost); | 6126 | staticpro (&QChost); |
| 6179 | QCservice = intern (":service"); | 6127 | QCservice = intern (":service"); |
| 6180 | staticpro (&QCservice); | 6128 | staticpro (&QCservice); |
| 6129 | QCtype = intern (":type"); | ||
| 6130 | staticpro (&QCtype); | ||
| 6181 | QClocal = intern (":local"); | 6131 | QClocal = intern (":local"); |
| 6182 | staticpro (&QClocal); | 6132 | staticpro (&QClocal); |
| 6183 | QCremote = intern (":remote"); | 6133 | QCremote = intern (":remote"); |
| @@ -6186,8 +6136,6 @@ syms_of_process () | |||
| 6186 | staticpro (&QCcoding); | 6136 | staticpro (&QCcoding); |
| 6187 | QCserver = intern (":server"); | 6137 | QCserver = intern (":server"); |
| 6188 | staticpro (&QCserver); | 6138 | staticpro (&QCserver); |
| 6189 | QCdatagram = intern (":datagram"); | ||
| 6190 | staticpro (&QCdatagram); | ||
| 6191 | QCnowait = intern (":nowait"); | 6139 | QCnowait = intern (":nowait"); |
| 6192 | staticpro (&QCnowait); | 6140 | staticpro (&QCnowait); |
| 6193 | QCsentinel = intern (":sentinel"); | 6141 | QCsentinel = intern (":sentinel"); |
| @@ -6200,8 +6148,6 @@ syms_of_process () | |||
| 6200 | staticpro (&QCstop); | 6148 | staticpro (&QCstop); |
| 6201 | QCoptions = intern (":options"); | 6149 | QCoptions = intern (":options"); |
| 6202 | staticpro (&QCoptions); | 6150 | staticpro (&QCoptions); |
| 6203 | QCfeature = intern (":feature"); | ||
| 6204 | staticpro (&QCfeature); | ||
| 6205 | 6151 | ||
| 6206 | Qlast_nonmenu_event = intern ("last-nonmenu-event"); | 6152 | Qlast_nonmenu_event = intern ("last-nonmenu-event"); |
| 6207 | staticpro (&Qlast_nonmenu_event); | 6153 | staticpro (&Qlast_nonmenu_event); |
| @@ -6291,6 +6237,8 @@ extern int frame_garbaged; | |||
| 6291 | extern EMACS_TIME timer_check (); | 6237 | extern EMACS_TIME timer_check (); |
| 6292 | extern int timers_run; | 6238 | extern int timers_run; |
| 6293 | 6239 | ||
| 6240 | Lisp_Object QCtype; | ||
| 6241 | |||
| 6294 | /* As described above, except assuming that there are no subprocesses: | 6242 | /* As described above, except assuming that there are no subprocesses: |
| 6295 | 6243 | ||
| 6296 | Wait for timeout to elapse and/or keyboard input to be available. | 6244 | Wait for timeout to elapse and/or keyboard input to be available. |
| @@ -6566,6 +6514,9 @@ init_process () | |||
| 6566 | void | 6514 | void |
| 6567 | syms_of_process () | 6515 | syms_of_process () |
| 6568 | { | 6516 | { |
| 6517 | QCtype = intern (":type"); | ||
| 6518 | staticpro (&QCtype); | ||
| 6519 | |||
| 6569 | defsubr (&Sget_buffer_process); | 6520 | defsubr (&Sget_buffer_process); |
| 6570 | defsubr (&Sprocess_inherit_coding_system_flag); | 6521 | defsubr (&Sprocess_inherit_coding_system_flag); |
| 6571 | } | 6522 | } |