aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorKim F. Storm2003-01-12 20:24:06 +0000
committerKim F. Storm2003-01-12 20:24:06 +0000
commitac4a75846bff3dce4996bd97e1eb4325f4a65d34 (patch)
tree8ff51f57df0f7945373e4b90e99958943e732d0e /src/process.c
parent2a061f25b23db073a922bfb69fca9928d84042c9 (diff)
downloademacs-ac4a75846bff3dce4996bd97e1eb4325f4a65d34.tar.gz
emacs-ac4a75846bff3dce4996bd97e1eb4325f4a65d34.zip
(QCvars): New variable.
(syms_of_process): Intern and staticpro it. (Fprocess_variable, Fset_process_variable): New functions. (syms_of_process): Defsubr them. (Fstart_process): Initialize private_vars plist to nil. (Fmake_network_process): New arg :vars to setup the private variables for new network process. (server_accept_connection): Copy server's private variables to client process.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c52
1 files changed, 39 insertions, 13 deletions
diff --git a/src/process.c b/src/process.c
index 70825a54ca0..24782504f05 100644
--- a/src/process.c
+++ b/src/process.c
@@ -132,7 +132,7 @@ Lisp_Object Qlocal, Qdatagram;
132Lisp_Object QCname, QCbuffer, QChost, QCservice, QCtype; 132Lisp_Object QCname, QCbuffer, QChost, QCservice, QCtype;
133Lisp_Object QClocal, QCremote, QCcoding; 133Lisp_Object QClocal, QCremote, QCcoding;
134Lisp_Object QCserver, QCnowait, QCnoquery, QCstop; 134Lisp_Object QCserver, QCnowait, QCnoquery, QCstop;
135Lisp_Object QCsentinel, QClog, QCoptions; 135Lisp_Object QCsentinel, QClog, QCoptions, QCvars;
136Lisp_Object Qlast_nonmenu_event; 136Lisp_Object Qlast_nonmenu_event;
137/* QCfamily is declared and initialized in xfaces.c, 137/* QCfamily is declared and initialized in xfaces.c,
138 QCfilter in keyboard.c. */ 138 QCfilter in keyboard.c. */
@@ -1037,20 +1037,34 @@ See `make-network-process' for a list of keywords. */)
1037 return Fplist_get (contact, key); 1037 return Fplist_get (contact, key);
1038} 1038}
1039 1039
1040DEFUN ("set-process-contact", Fset_process_contact, Sset_process_contact, 1040DEFUN ("process-variable", Fprocess_variable, Sprocess_variable,
1041 3, 3, 0, 1041 1, 2, 0,
1042 doc: /* Change value in PROCESS' contact information list of KEY to VAL. 1042 doc: /* Return the value of PROCESS' private variable VAR.
1043If KEY is already a property on the list, its value is set to VAL, 1043If VARIABLE is omitted or nil, return plist with all PROCESS variables. */)
1044otherwise the new KEY VAL pair is added. Returns VAL. */) 1044 (process, var)
1045 (process, key, val) 1045 register Lisp_Object process, var;
1046 register Lisp_Object process, key, val;
1047{ 1046{
1048 Lisp_Object contact; 1047 CHECK_PROCESS (process);
1048
1049 if (NILP (var))
1050 return XPROCESS (process)->private_vars;
1051
1052 return Fplist_get (XPROCESS (process)->private_vars, var);
1053}
1049 1054
1055DEFUN ("set-process-variable", Fset_process_variable, Sset_process_variable,
1056 3, 3, 0,
1057 doc: /* Change value of PROCESS' private variable VAR to VAL, and return VAL.
1058If VAR is nil, set all PROCESS' private variables according to plist VAL. */)
1059 (process, var, val)
1060 register Lisp_Object process, var, val;
1061{
1050 CHECK_PROCESS (process); 1062 CHECK_PROCESS (process);
1051 1063
1052 if (NETCONN_P (process)) 1064 XPROCESS (process)->private_vars
1053 XPROCESS (process)->childp = Fplist_put (XPROCESS (process)->childp, key, val); 1065 = (NILP (var)
1066 ? val
1067 : Fplist_put (XPROCESS (process)->private_vars, var, val));
1054 1068
1055 return val; 1069 return val;
1056} 1070}
@@ -1420,6 +1434,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1420 record_unwind_protect (start_process_unwind, proc); 1434 record_unwind_protect (start_process_unwind, proc);
1421 1435
1422 XPROCESS (proc)->childp = Qt; 1436 XPROCESS (proc)->childp = Qt;
1437 XPROCESS (proc)->private_vars = Qnil;
1423 XPROCESS (proc)->command_channel_p = Qnil; 1438 XPROCESS (proc)->command_channel_p = Qnil;
1424 XPROCESS (proc)->buffer = buffer; 1439 XPROCESS (proc)->buffer = buffer;
1425 XPROCESS (proc)->sentinel = Qnil; 1440 XPROCESS (proc)->sentinel = Qnil;
@@ -2584,6 +2599,9 @@ client. The arguments are SERVER, CLIENT, and MESSAGE, where SERVER
2584is the server process, CLIENT is the new process for the connection, 2599is the server process, CLIENT is the new process for the connection,
2585and MESSAGE is a string. 2600and MESSAGE is a string.
2586 2601
2602:vars VARS -- Initialize the process' private variables according to
2603a list of variable/value pairs (VAR1 VAL1 VAR2 VAL2...).
2604
2587:server BOOL -- if BOOL is non-nil, create a server process for the 2605:server BOOL -- if BOOL is non-nil, create a server process for the
2588specified FAMILY, SERVICE, and connection type (stream or datagram). 2606specified FAMILY, SERVICE, and connection type (stream or datagram).
2589Default is a client process. 2607Default is a client process.
@@ -2601,6 +2619,8 @@ NAME concatenated with the client identification string.
2601inherited from the server process' TYPE, FILTER and SENTINEL. 2619inherited from the server process' TYPE, FILTER and SENTINEL.
2602- The client process' contact info is set according to the client's 2620- The client process' contact info is set according to the client's
2603addressing information (typically an IP address and a port number). 2621addressing information (typically an IP address and a port number).
2622- The client process' private variables are initialized from the
2623server's private variables.
2604 2624
2605Notice that the FILTER and SENTINEL args are never used directly by 2625Notice that the FILTER and SENTINEL args are never used directly by
2606the server process. Also, the BUFFER argument is not used directly by 2626the server process. Also, the BUFFER argument is not used directly by
@@ -2609,7 +2629,6 @@ failed) connections may be logged in the server process' buffer.
2609 2629
2610The original argument list, modified with the actual connection 2630The original argument list, modified with the actual connection
2611information, is available via the `process-contact' function. 2631information, is available via the `process-contact' function.
2612Additional arguments may be added via `set-process-contact'.
2613 2632
2614usage: (make-network-process &rest ARGS) */) 2633usage: (make-network-process &rest ARGS) */)
2615 (nargs, args) 2634 (nargs, args)
@@ -3164,6 +3183,8 @@ usage: (make-network-process &rest ARGS) */)
3164 p = XPROCESS (proc); 3183 p = XPROCESS (proc);
3165 3184
3166 p->childp = contact; 3185 p->childp = contact;
3186 p->private_vars = Fcopy_sequence (Fplist_get (contact, QCvars));
3187
3167 p->buffer = buffer; 3188 p->buffer = buffer;
3168 p->sentinel = sentinel; 3189 p->sentinel = sentinel;
3169 p->filter = filter; 3190 p->filter = filter;
@@ -3595,6 +3616,8 @@ server_accept_connection (server, channel)
3595#endif 3616#endif
3596 3617
3597 p->childp = contact; 3618 p->childp = contact;
3619 p->private_vars = Fcopy_sequence (ps->private_vars);
3620
3598 p->buffer = buffer; 3621 p->buffer = buffer;
3599 p->sentinel = ps->sentinel; 3622 p->sentinel = ps->sentinel;
3600 p->filter = ps->filter; 3623 p->filter = ps->filter;
@@ -6320,6 +6343,8 @@ syms_of_process ()
6320 staticpro (&QCstop); 6343 staticpro (&QCstop);
6321 QCoptions = intern (":options"); 6344 QCoptions = intern (":options");
6322 staticpro (&QCoptions); 6345 staticpro (&QCoptions);
6346 QCvars = intern (":vars");
6347 staticpro (&QCvars);
6323 6348
6324 Qlast_nonmenu_event = intern ("last-nonmenu-event"); 6349 Qlast_nonmenu_event = intern ("last-nonmenu-event");
6325 staticpro (&Qlast_nonmenu_event); 6350 staticpro (&Qlast_nonmenu_event);
@@ -6363,7 +6388,8 @@ The value takes effect when `start-process' is called. */);
6363 defsubr (&Sset_process_query_on_exit_flag); 6388 defsubr (&Sset_process_query_on_exit_flag);
6364 defsubr (&Sprocess_query_on_exit_flag); 6389 defsubr (&Sprocess_query_on_exit_flag);
6365 defsubr (&Sprocess_contact); 6390 defsubr (&Sprocess_contact);
6366 defsubr (&Sset_process_contact); 6391 defsubr (&Sprocess_variable);
6392 defsubr (&Sset_process_variable);
6367 defsubr (&Slist_processes); 6393 defsubr (&Slist_processes);
6368 defsubr (&Sprocess_list); 6394 defsubr (&Sprocess_list);
6369 defsubr (&Sstart_process); 6395 defsubr (&Sstart_process);