annotate src/tooltalk.c @ 2:ac2d302a0011 r19-15b2

Import from CVS: tag r19-15b2
author cvs
date Mon, 13 Aug 2007 08:46:35 +0200
parents 376386a54a3c
children bcdc7deadc19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Tooltalk support for Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994 Sun Microsystems, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 /* Written by John Rose <john.rose@eng.sun.com>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 Heavily modified and cleaned up by Ben Wing <ben.wing@eng.sun.com>. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 #include <X11/Xlib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #include <tt_c.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #include "buffer.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #include "elhash.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 #include "process.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 #include "tooltalk.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 Lisp_Object Vtooltalk_fd;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 #ifdef TT_DEBUG
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 static FILE *tooltalk_log_file;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 Vtooltalk_message_handler_hook,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 Vtooltalk_pattern_handler_hook,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 Vtooltalk_unprocessed_message_hook;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 Qtooltalk_message_handler_hook,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 Qtooltalk_pattern_handler_hook,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 Qtooltalk_unprocessed_message_hook;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 Qreceive_tooltalk_message,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 Qtt_address,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 Qtt_args_count,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 Qtt_arg_bval,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 Qtt_arg_ival,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 Qtt_arg_mode,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 Qtt_arg_type,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 Qtt_arg_val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 Qtt_class,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 Qtt_category,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 Qtt_disposition,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 Qtt_file,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 Qtt_gid,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 Qtt_handler,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 Qtt_handler_ptype,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 Qtt_object,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 Qtt_op,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 Qtt_opnum,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 Qtt_otype,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 Qtt_scope,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 Qtt_sender,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 Qtt_sender_ptype,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 Qtt_session,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 Qtt_state,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 Qtt_status,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 Qtt_status_string,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 Qtt_uid,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 Qtt_callback,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 Qtt_plist,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 Qtt_prop,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 Qtt_reject, /* return-tooltalk-message */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 Qtt_reply,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 Qtt_fail,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 Q_TT_MODE_UNDEFINED, /* enum Tt_mode */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 Q_TT_IN,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 Q_TT_OUT,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 Q_TT_INOUT,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 Q_TT_MODE_LAST,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 Q_TT_SCOPE_NONE, /* enum Tt_scope */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 Q_TT_SESSION,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 Q_TT_FILE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 Q_TT_BOTH,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 Q_TT_FILE_IN_SESSION,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 Q_TT_CLASS_UNDEFINED, /* enum Tt_class */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 Q_TT_NOTICE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 Q_TT_REQUEST,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 Q_TT_CLASS_LAST,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 Q_TT_CATEGORY_UNDEFINED, /* enum Tt_category */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 Q_TT_OBSERVE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 Q_TT_HANDLE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 Q_TT_CATEGORY_LAST,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 Q_TT_PROCEDURE, /* typedef enum Tt_address */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 Q_TT_OBJECT,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 Q_TT_HANDLER,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 Q_TT_OTYPE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 Q_TT_ADDRESS_LAST,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 Q_TT_CREATED, /* enum Tt_state */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 Q_TT_SENT,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 Q_TT_HANDLED,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 Q_TT_FAILED,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 Q_TT_QUEUED,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 Q_TT_STARTED,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 Q_TT_REJECTED,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 Q_TT_STATE_LAST,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 Q_TT_DISCARD, /* enum Tt_disposition */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 Q_TT_QUEUE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 Q_TT_START;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 static Lisp_Object Tooltalk_Message_plist_str, Tooltalk_Pattern_plist_str;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 Lisp_Object Qtooltalk_error;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 /* Used to GCPRO tooltalk message and pattern objects while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 they're sitting inside of some active tooltalk message or pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 There may not be any other pointers to these objects. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 Lisp_Object Vtooltalk_message_gcpro, Vtooltalk_pattern_gcpro;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 /* */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 /* machinery for tooltalk-message type */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 /* */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 Lisp_Object Qtooltalk_messagep;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 struct Lisp_Tooltalk_Message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 struct lcrecord_header header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 Lisp_Object plist_sym, callback;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 Tt_message m;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 static Lisp_Object mark_tooltalk_message (Lisp_Object, void (*) (Lisp_Object));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 static void print_tooltalk_message (Lisp_Object, Lisp_Object, int);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 DEFINE_LRECORD_IMPLEMENTATION ("tooltalk-message", tooltalk_message,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 mark_tooltalk_message, print_tooltalk_message,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 0, 0, 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 struct Lisp_Tooltalk_Message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 mark_tooltalk_message (Lisp_Object obj, void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (markobj) (XTOOLTALK_MESSAGE (obj)->callback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 return XTOOLTALK_MESSAGE (obj)->plist_sym;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 print_tooltalk_message (Lisp_Object obj, Lisp_Object printcharfun,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 struct Lisp_Tooltalk_Message *p = XTOOLTALK_MESSAGE (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 char buf[200];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 if (print_readably)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 error ("printing unreadable object #<tooltalk_message 0x%x>",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 p->header.uid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 sprintf (buf, "#<tooltalk_message id:%d 0x%x>", (int) p->m, p->header.uid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 make_tooltalk_message (Tt_message m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 struct Lisp_Tooltalk_Message *msg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 = alloc_lcrecord (sizeof (struct Lisp_Tooltalk_Message),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 lrecord_tooltalk_message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 Lisp_Object val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 msg->m = m;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 msg->callback = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 msg->plist_sym = Fmake_symbol (Tooltalk_Message_plist_str);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 XSETTOOLTALK_MESSAGE (val, msg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 return val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 Tt_message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 unbox_tooltalk_message (Lisp_Object message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 CHECK_TOOLTALK_MESSAGE (message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 return XTOOLTALK_MESSAGE (message)->m;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 DEFUN ("tooltalk-message-p", Ftooltalk_message_p, Stooltalk_message_p, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 Return non-nil if OBJECT is a tooltalk message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 Lisp_Object object;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 return (TOOLTALK_MESSAGEP (object) ? Qt : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 /* */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 /* machinery for tooltalk-pattern type */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 /* */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 Lisp_Object Qtooltalk_patternp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 struct Lisp_Tooltalk_Pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 struct lcrecord_header header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 Lisp_Object plist_sym, callback;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 Tt_pattern p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 static Lisp_Object mark_tooltalk_pattern (Lisp_Object, void (*) (Lisp_Object));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 static void print_tooltalk_pattern (Lisp_Object, Lisp_Object, int);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 DEFINE_LRECORD_IMPLEMENTATION ("tooltalk-pattern", tooltalk_pattern,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 mark_tooltalk_pattern, print_tooltalk_pattern,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 0, 0, 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 struct Lisp_Tooltalk_Pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 mark_tooltalk_pattern (Lisp_Object obj, void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (markobj) (XTOOLTALK_PATTERN (obj)->callback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 return XTOOLTALK_PATTERN (obj)->plist_sym;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 print_tooltalk_pattern (Lisp_Object obj, Lisp_Object printcharfun,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 struct Lisp_Tooltalk_Pattern *p = XTOOLTALK_PATTERN (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 char buf[200];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 if (print_readably)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 error ("printing unreadable object #<tooltalk_pattern 0x%x>",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 p->header.uid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 sprintf (buf, "#<tooltalk_pattern id:%d 0x%x>", (int) p->p, p->header.uid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 make_tooltalk_pattern (Tt_pattern p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 struct Lisp_Tooltalk_Pattern *pat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 = alloc_lcrecord (sizeof (struct Lisp_Tooltalk_Pattern),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 lrecord_tooltalk_pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 Lisp_Object val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 pat->p = p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 pat->callback = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 pat->plist_sym = Fmake_symbol (Tooltalk_Pattern_plist_str);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 XSETTOOLTALK_PATTERN (val, pat);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 return val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 static Tt_pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 unbox_tooltalk_pattern (Lisp_Object pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 CHECK_TOOLTALK_PATTERN (pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 return XTOOLTALK_PATTERN (pattern)->p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 DEFUN ("tooltalk-pattern-p", Ftooltalk_pattern_p, Stooltalk_pattern_p, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 Return non-nil if OBJECT is a tooltalk pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 Lisp_Object object;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 return (TOOLTALK_PATTERNP (object) ? Qt : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 tooltalk_constant_value (Lisp_Object s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 if (INTP (s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 return XINT (s);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 else if (SYMBOLP (s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 return XINT (XSYMBOL (s)->value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 return 0; /* should never occur */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 check_status (Tt_status st)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 if (tt_is_err (st))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 signal_error (Qtooltalk_error,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 Fcons (build_string (tt_status_message (st)), Qnil));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 DEFUN ("receive-tooltalk-message",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 Freceive_tooltalk_message,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 Sreceive_tooltalk_message,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 0, 2, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 Run tt_message_receive().
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 This function is the process handler for the ToolTalk connection process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (ignore1, ignore2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 Lisp_Object ignore1, ignore2; /* filters are called with two arguments. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 Tt_message mess = tt_message_receive ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 Lisp_Object message = make_tooltalk_message (mess);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 struct gcpro gcpro1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 GCPRO1 (message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 if (mess != NULL && !NILP (Vtooltalk_unprocessed_message_hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 va_run_hook_with_args (Qtooltalk_unprocessed_message_hook, 1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 /* see comment in event-stream.c about this return value. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 return make_int (0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 static Tt_callback_action
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 tooltalk_message_callback (Tt_message m, Tt_pattern p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 Lisp_Object cb;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 Lisp_Object message;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 Lisp_Object pattern;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 struct gcpro gcpro1, gcpro2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 #ifdef TT_DEBUG
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 int i, j;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 fprintf (tooltalk_log_file, "message_cb: %d\n", m);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 fprintf (tooltalk_log_file, "op: %s (", tt_message_op (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 for (j = tt_message_args_count (m), i = 0; i < j; i++) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 fprintf (tooltalk_log_file, "%s \"%s\"", tt_message_arg_type (m, i),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 tt_message_arg_val (m, i));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 fprintf (tooltalk_log_file, "%s", i == j-1 ? ")" : ", ");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 fprintf (tooltalk_log_file, "\n\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 fflush (tooltalk_log_file);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 VOID_TO_LISP (message, tt_message_user (m, TOOLTALK_MESSAGE_KEY));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 pattern = make_tooltalk_pattern (p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 cb = XTOOLTALK_MESSAGE (message)->callback;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 GCPRO2 (message, pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 if (!NILP (Vtooltalk_message_handler_hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 va_run_hook_with_args (Qtooltalk_message_handler_hook, 2, message,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 if ((SYMBOLP (cb) && EQ (Qt, Ffboundp (cb))) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (CONSP (cb) && EQ (Qlambda, Fcar (cb)) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 !NILP (Flistp (Fcar (Fcdr (cb))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 call2 (cb, message, pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 tt_message_destroy (m);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 Fremhash (message, Vtooltalk_message_gcpro);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 return TT_CALLBACK_PROCESSED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 static Tt_callback_action
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 tooltalk_pattern_callback (Tt_message m, Tt_pattern p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 Lisp_Object cb;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 Lisp_Object message;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 Lisp_Object pattern;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 struct gcpro gcpro1, gcpro2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 #ifdef TT_DEBUG
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 int i, j;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 fprintf (tooltalk_log_file, "pattern_cb: %d\n", m);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 fprintf (tooltalk_log_file, "op: %s (", tt_message_op (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 for (j = tt_message_args_count (m), i = 0; i < j; i++) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 fprintf (tooltalk_log_file, "%s \"%s\"", tt_message_arg_type (m, i),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 tt_message_arg_val (m, i));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 fprintf (tooltalk_log_file, "%s", i == j-1 ? ")" : ", ");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 fprintf (tooltalk_log_file, "\n\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 fflush (tooltalk_log_file);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 message = make_tooltalk_message (m);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 VOID_TO_LISP (pattern, tt_pattern_user (p, TOOLTALK_PATTERN_KEY));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 cb = XTOOLTALK_PATTERN (pattern)->callback;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 GCPRO2 (message, pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 if (!NILP (Vtooltalk_pattern_handler_hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 va_run_hook_with_args (Qtooltalk_pattern_handler_hook, 2, message,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 if (SYMBOLP (cb) && EQ (Qt, Ffboundp (cb)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 call2 (cb, message, pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 tt_message_destroy (m);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 return TT_CALLBACK_PROCESSED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 tt_mode_symbol (Tt_mode n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 switch (n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 case TT_MODE_UNDEFINED: return Q_TT_MODE_UNDEFINED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 case TT_IN: return Q_TT_IN;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 case TT_OUT: return Q_TT_OUT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 case TT_INOUT: return Q_TT_INOUT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 case TT_MODE_LAST: return Q_TT_MODE_LAST;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 default: return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 tt_scope_symbol (Tt_scope n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 switch (n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 case TT_SCOPE_NONE: return Q_TT_SCOPE_NONE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 case TT_SESSION: return Q_TT_SESSION;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 case TT_FILE: return Q_TT_FILE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 case TT_BOTH: return Q_TT_BOTH;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 case TT_FILE_IN_SESSION: return Q_TT_FILE_IN_SESSION;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 default: return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 tt_class_symbol (Tt_class n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 switch (n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 case TT_CLASS_UNDEFINED: return Q_TT_CLASS_UNDEFINED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 case TT_NOTICE: return Q_TT_NOTICE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 case TT_REQUEST: return Q_TT_REQUEST;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 case TT_CLASS_LAST: return Q_TT_CLASS_LAST;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 default: return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 * This is not being used. Is that a mistake or is this function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 * simply not necessary?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 tt_category_symbol (Tt_category n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 switch (n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 case TT_CATEGORY_UNDEFINED: return Q_TT_CATEGORY_UNDEFINED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 case TT_OBSERVE: return Q_TT_OBSERVE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 case TT_HANDLE: return Q_TT_HANDLE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 case TT_CATEGORY_LAST: return Q_TT_CATEGORY_LAST;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 default: return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 #endif /* 0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 tt_address_symbol (Tt_address n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 switch (n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 case TT_PROCEDURE: return Q_TT_PROCEDURE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 case TT_OBJECT: return Q_TT_OBJECT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 case TT_HANDLER: return Q_TT_HANDLER;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 case TT_OTYPE: return Q_TT_OTYPE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 case TT_ADDRESS_LAST: return Q_TT_ADDRESS_LAST;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 default: return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 tt_state_symbol (Tt_state n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 switch (n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 case TT_CREATED: return Q_TT_CREATED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 case TT_SENT: return Q_TT_SENT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 case TT_HANDLED: return Q_TT_HANDLED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 case TT_FAILED: return Q_TT_FAILED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 case TT_QUEUED: return Q_TT_QUEUED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 case TT_STARTED: return Q_TT_STARTED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 case TT_REJECTED: return Q_TT_REJECTED;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 case TT_STATE_LAST: return Q_TT_STATE_LAST;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 default: return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 tt_build_string (char *s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 return build_string ((s) ? s : "");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 tt_opnum_string (int n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 char buf[32];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 sprintf (buf, "%u", n);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 return build_string (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 tt_message_arg_ival_string (Tt_message m, int n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 char buf[32];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 int value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 check_status (tt_message_arg_ival (m, n, &value));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 sprintf (buf, "%d", value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 return build_string (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 tt_message_arg_bval_vector (Tt_message m, int n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 /* !!#### This function has not been Mule-ized */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 Bufbyte *value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 int len = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 check_status (tt_message_arg_bval (m, n, &value, &len));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 return make_string (value, len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 DEFUN ("get-tooltalk-message-attribute",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 Fget_tooltalk_message_attribute,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 Sget_tooltalk_message_attribute,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 2, 3, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 Return the indicated Tooltalk message attribute. Attributes are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 identified by symbols with the same name (underscores and all) as the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 suffix of the Tooltalk tt_message_<attribute> function that extracts the value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 String attribute values are copied, enumerated type values (except disposition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 are converted to symbols - e.g. TT_HANDLER is 'TT_HANDLER, uid and gid are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 represented by fixnums (small integers), opnum is converted to a string,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 and disposition is converted to a fixnum. We convert opnum (a C int) to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 string, e.g. 123 => \"123\" because there's no guarantee that opnums will fit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 within the range of Lisp integers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 Use the 'plist attribute instead of the C API 'user attribute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 for user defined message data. To retrieve the value of a message property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 specify the indicator for argn. For example to get the value of a property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 called 'rflag, use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (get-tooltalk-message-attribute message 'plist 'rflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 To get the value of a message argument use one of the 'arg_val (strings),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 'arg_ival (integers), or 'arg_bval (strings with embedded nulls), attributes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 For example to get the integer value of the third argument:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (get-tooltalk-message-attribute message 'arg_ival 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 As you can see, argument numbers are zero based. The type of each argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 can be retrieved with the 'arg_type attribute; however, Tooltalk doesn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 define any semantics for the string value of 'arg_type. Conventionally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 \"string\" is used for strings and \"int\" for 32 bit integers. Note that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 Emacs Lisp stores the lengths of strings explicitly (unlike C) so treating the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 value returned by 'arg_bval like a string is fine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (message, attribute, argn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 Lisp_Object message;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 Lisp_Object attribute;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 Lisp_Object argn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 Tt_message m = unbox_tooltalk_message (message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 int n = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 CHECK_SYMBOL (attribute);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 if (EQ (attribute, (Qtt_arg_bval)) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 EQ (attribute, (Qtt_arg_ival)) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 EQ (attribute, (Qtt_arg_mode)) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 EQ (attribute, (Qtt_arg_type)) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 EQ (attribute, (Qtt_arg_val)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 CHECK_INT (argn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 n = XINT (argn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 if (!VALID_TOOLTALK_MESSAGEP (m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 else if (EQ (attribute, Qtt_arg_bval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 return tt_message_arg_bval_vector (m, n);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 else if (EQ (attribute, Qtt_arg_ival))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 return tt_message_arg_ival_string (m, n);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 else if (EQ (attribute, Qtt_arg_mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 return tt_mode_symbol (tt_message_arg_mode (m, n));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 else if (EQ (attribute, Qtt_arg_type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 return tt_build_string (tt_message_arg_type (m, n));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 else if (EQ (attribute, Qtt_arg_val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 return tt_message_arg_bval_vector (m, n);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 else if (EQ (attribute, Qtt_args_count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 return make_int (tt_message_args_count (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 else if (EQ (attribute, Qtt_address))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 return tt_address_symbol (tt_message_address (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 else if (EQ (attribute, Qtt_class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 return tt_class_symbol (tt_message_class (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 else if (EQ (attribute, Qtt_disposition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 return make_int (tt_message_disposition (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 else if (EQ (attribute, Qtt_file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 return tt_build_string (tt_message_file (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 else if (EQ (attribute, Qtt_gid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 return make_int (tt_message_gid (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 else if (EQ (attribute, Qtt_handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 return tt_build_string (tt_message_handler (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 else if (EQ (attribute, Qtt_handler_ptype))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 return tt_build_string (tt_message_handler_ptype (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 else if (EQ (attribute, Qtt_object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 return tt_build_string (tt_message_object (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 else if (EQ (attribute, Qtt_op))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 return tt_build_string (tt_message_op (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 else if (EQ (attribute, Qtt_opnum))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 return tt_opnum_string (tt_message_opnum (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 else if (EQ (attribute, Qtt_otype))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 return tt_build_string (tt_message_otype (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 else if (EQ (attribute, Qtt_scope))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 return tt_scope_symbol (tt_message_scope (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 else if (EQ (attribute, Qtt_sender))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 return tt_build_string (tt_message_sender (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 else if (EQ (attribute, Qtt_sender_ptype))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 return tt_build_string (tt_message_sender_ptype (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 else if (EQ (attribute, Qtt_session))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 return tt_build_string (tt_message_session (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 else if (EQ (attribute, Qtt_state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 return tt_state_symbol (tt_message_state (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 else if (EQ (attribute, Qtt_status))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 return make_int (tt_message_status (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 else if (EQ (attribute, Qtt_status_string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 return tt_build_string (tt_message_status_string (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 else if (EQ (attribute, Qtt_uid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 return make_int (tt_message_uid (m));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 else if (EQ (attribute, Qtt_callback))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 return XTOOLTALK_MESSAGE (message)->callback;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 else if (EQ (attribute, Qtt_prop))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 return Fget (XTOOLTALK_MESSAGE (message)->plist_sym, argn, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 else if (EQ (attribute, Qtt_plist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 return Fcopy_sequence (Fsymbol_plist (XTOOLTALK_MESSAGE (message)->
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 plist_sym));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 signal_simple_error ("invalid value for `get-tooltalk-message-attribute'",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 attribute);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 DEFUN ("set-tooltalk-message-attribute",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 Fset_tooltalk_message_attribute,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 Sset_tooltalk_message_attribute,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 3, 4, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 Initialize one Tooltalk message attribute.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 Attribute names and values are the same as for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 `get-tooltalk-message-attribute'. A property list is provided for user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 data (instead of the 'user message attribute); see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 `get-tooltalk-message-attribute'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 The value of callback should be the name of a function of one argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 It will be applied to the message and matching pattern each time the state of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 message changes. This is usually used to notice when the messages state has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 changed to TT_HANDLED (or TT_FAILED), so that reply argument values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 can be used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 If one of the argument attributes is specified, 'arg_val, 'arg_ival, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 'arg_bval then argn must be the number of an already created argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 New arguments can be added to a message with add-tooltalk-message-arg.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (value, message, attribute, argn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 Lisp_Object value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 Lisp_Object message;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 Lisp_Object attribute;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 Lisp_Object argn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 Tt_message m = unbox_tooltalk_message (message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 int n = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 CHECK_SYMBOL (attribute);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 if (EQ (attribute, (Qtt_arg_bval)) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 EQ (attribute, (Qtt_arg_ival)) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 EQ (attribute, (Qtt_arg_val)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 CHECK_INT (argn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 n = XINT (argn);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 if (!VALID_TOOLTALK_MESSAGEP (m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 else if (EQ (attribute, Qtt_address))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 CHECK_TOOLTALK_CONSTANT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 tt_message_address_set (m, tooltalk_constant_value (value));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 else if (EQ (attribute, Qtt_class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 CHECK_TOOLTALK_CONSTANT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 tt_message_class_set (m, tooltalk_constant_value (value));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 else if (EQ (attribute, Qtt_disposition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 CHECK_TOOLTALK_CONSTANT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 tt_message_disposition_set (m, tooltalk_constant_value (value));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 else if (EQ (attribute, Qtt_file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 CONST char *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 CHECK_STRING (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 GET_C_STRING_OS_DATA_ALLOCA (value, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 tt_message_file_set (m, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 else if (EQ (attribute, Qtt_handler_ptype))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 CONST char *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 CHECK_STRING (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 GET_C_STRING_OS_DATA_ALLOCA (value, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 tt_message_handler_ptype_set (m, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 else if (EQ (attribute, Qtt_handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 CONST char *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 CHECK_STRING (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 GET_C_STRING_OS_DATA_ALLOCA (value, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 tt_message_handler_set (m, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 else if (EQ (attribute, Qtt_object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 CONST char *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 CHECK_STRING (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 GET_C_STRING_OS_DATA_ALLOCA (value, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 tt_message_object_set (m, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 else if (EQ (attribute, Qtt_op))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 CONST char *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 CHECK_STRING (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 GET_C_STRING_OS_DATA_ALLOCA (value, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 tt_message_op_set (m, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 else if (EQ (attribute, Qtt_otype))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 CONST char *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 CHECK_STRING (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 GET_C_STRING_OS_DATA_ALLOCA (value, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 tt_message_otype_set (m, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 else if (EQ (attribute, Qtt_scope))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 CHECK_TOOLTALK_CONSTANT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 tt_message_scope_set (m, tooltalk_constant_value (value));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 else if (EQ (attribute, Qtt_sender_ptype))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 CONST char *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 CHECK_STRING (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 GET_C_STRING_OS_DATA_ALLOCA (value, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 tt_message_sender_ptype_set (m, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 else if (EQ (attribute, Qtt_session))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 CONST char *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 CHECK_STRING (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 GET_C_STRING_OS_DATA_ALLOCA (value, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 tt_message_session_set (m, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 else if (EQ (attribute, Qtt_arg_bval))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 Extbyte *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 Extcount value_ext_len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 CHECK_STRING (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 GET_STRING_OS_DATA_ALLOCA (value, value_ext, value_ext_len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 tt_message_arg_bval_set (m, n, value_ext, value_ext_len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 else if (EQ (attribute, Qtt_arg_ival))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 CHECK_INT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 tt_message_arg_ival_set (m, n, XINT (value));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 else if (EQ (attribute, Qtt_arg_val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 CONST char *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 CHECK_STRING (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 GET_C_STRING_OS_DATA_ALLOCA (value, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 tt_message_arg_val_set (m, n, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 else if (EQ (attribute, Qtt_status))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 CHECK_INT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 tt_message_status_set (m, XINT (value));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 else if (EQ (attribute, Qtt_status_string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 CONST char *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 CHECK_STRING (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 GET_C_STRING_OS_DATA_ALLOCA (value, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 tt_message_status_string_set (m, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 else if (EQ (attribute, Qtt_callback))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 CHECK_SYMBOL (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 XTOOLTALK_MESSAGE (message)->callback = value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 else if (EQ (attribute, Qtt_prop))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 return Fput (XTOOLTALK_MESSAGE (message)->plist_sym, argn, value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 signal_simple_error ("invalid value for `set-tooltalk-message-attribute'",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 attribute);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 DEFUN ("return-tooltalk-message",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 Freturn_tooltalk_message,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 Sreturn_tooltalk_message,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 1, 2, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 Send a reply to this message. The second argument can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 'reply, 'reject or 'fail; the default is 'reply. Before sending
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 a reply all message arguments whose mode is TT_INOUT or TT_OUT should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 have been filled in - see set-tooltalk-message-attribute.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (message, mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 Lisp_Object message, mode;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 Tt_message m = unbox_tooltalk_message (message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 if (NILP (mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 mode = Qtt_reply;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 CHECK_SYMBOL (mode);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 if (!VALID_TOOLTALK_MESSAGEP (m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 else if (EQ (mode, Qtt_reply))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 tt_message_reply (m);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 else if (EQ (mode, Qtt_reject))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 tt_message_reject (m);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 else if (EQ (mode, Qtt_fail))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 tt_message_fail (m);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 DEFUN ("create-tooltalk-message",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 Fcreate_tooltalk_message,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 Screate_tooltalk_message,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 0, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 Create a new tooltalk message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 The messages session attribute is initialized to the default session.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 Other attributes can be initialized with `set-tooltalk-message-attribute'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 `make-tooltalk-message' is the preferred to create and initialize a message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 Optional arg NO-CALLBACK says don't add a C-level callback at all.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 Normally don't do that; just don't specify the Lisp callback when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 calling `make-tooltalk-message'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (no_callback)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 Lisp_Object no_callback;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 Tt_message m = tt_message_create ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 Lisp_Object message = make_tooltalk_message (m);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 if (NILP (no_callback))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 tt_message_callback_add (m, tooltalk_message_callback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 tt_message_session_set (m, tt_default_session ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 tt_message_user_set (m, TOOLTALK_MESSAGE_KEY, LISP_TO_VOID (message));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 return message;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 DEFUN ("destroy-tooltalk-message",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 Fdestroy_tooltalk_message,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 Sdestroy_tooltalk_message,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 Apply tt_message_destroy() to the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 It's not necessary to destroy messages after they've been processed by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 a message or pattern callback; the Lisp/Tooltalk callback machinery does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 this for you.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 Lisp_Object message;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 Tt_message m = unbox_tooltalk_message (message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 if (VALID_TOOLTALK_MESSAGEP (m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 /* #### Should we call Fremhash() here? It seems that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 a common paradigm is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (send-tooltalk-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (destroy-tooltalk-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 which would imply that destroying a sent ToolTalk message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 doesn't actually destroy it; when a response is sent back,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 the callback for the message will still be called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 But then maybe not: Maybe it really does destroy it,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 and the reason for that paradigm is that the author
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 of `send-tooltalk-message' didn't really know what he
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 was talking about when he said that it's a good idea
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 to call `destroy-tooltalk-message' after sending it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 tt_message_destroy (m);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 DEFUN ("add-tooltalk-message-arg",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 Fadd_tooltalk_message_arg,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 Sadd_tooltalk_message_arg,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 3, 4, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 Append one new argument to the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 MODE must be one of TT_IN, TT_INOUT, or TT_OUT; VTYPE must be a string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 and VALUE can be a string or an integer. Tooltalk doesn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 define any semantics for VTYPE, so only the participants in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 protocol you're using need to agree what types mean (if anything).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 Conventionally \"string\" is used for strings and \"int\" for 32 bit integers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 Arguments can initialized by providing a value or with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 `set-tooltalk-message-attribute'. The latter is neccessary if you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 want to initialize the argument with a string that can contain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 embedded nulls (use 'arg_bval).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (message, mode, vtype, value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 Lisp_Object message, mode, vtype, value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 Tt_message m = unbox_tooltalk_message (message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 Tt_mode n;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 CHECK_STRING (vtype);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 CHECK_TOOLTALK_CONSTANT (mode);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
982 n = (Tt_mode) tooltalk_constant_value (mode);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 if (!VALID_TOOLTALK_MESSAGEP (m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 CONST char *vtype_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 GET_C_STRING_OS_DATA_ALLOCA (vtype, vtype_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 if (NILP (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 tt_message_arg_add (m, n, vtype_ext, NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 else if (STRINGP (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 CONST char *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 GET_C_STRING_OS_DATA_ALLOCA (value, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 tt_message_arg_add (m, n, vtype_ext, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 else if (INTP (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 tt_message_iarg_add (m, n, vtype_ext, XINT (value));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 DEFUN ("send-tooltalk-message",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 Fsend_tooltalk_message,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 Ssend_tooltalk_message,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 Send the message on its way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 Once the message has been sent it's almost always a good idea to get rid of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 it with `destroy-tooltalk-message'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 Lisp_Object message;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 Tt_message m = unbox_tooltalk_message (message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 if (VALID_TOOLTALK_MESSAGEP (m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 tt_message_send (m);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 Fputhash (message, Qnil, Vtooltalk_message_gcpro);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 DEFUN ("create-tooltalk-pattern",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 Fcreate_tooltalk_pattern,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 Screate_tooltalk_pattern,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 0, 0, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 Create a new Tooltalk pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 Its session attribute is initialized to be the default session.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 Tt_pattern p = tt_pattern_create ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 Lisp_Object pattern = make_tooltalk_pattern (p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 tt_pattern_callback_add (p, tooltalk_pattern_callback);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 tt_pattern_session_add (p, tt_default_session ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 tt_pattern_user_set (p, TOOLTALK_PATTERN_KEY, LISP_TO_VOID (pattern));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 return pattern;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 DEFUN ("destroy-tooltalk-pattern",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 Fdestroy_tooltalk_pattern,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 Sdestroy_tooltalk_pattern,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 Apply tt_pattern_destroy() to the pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 This effectively unregisters the pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 Lisp_Object pattern;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 Tt_pattern p = unbox_tooltalk_pattern (pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 if (VALID_TOOLTALK_PATTERNP (p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 tt_pattern_destroy (p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 Fremhash (pattern, Vtooltalk_pattern_gcpro);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 DEFUN ("add-tooltalk-pattern-attribute",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 Fadd_tooltalk_pattern_attribute,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 Sadd_tooltalk_pattern_attribute,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 3, 3, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 Add one value to the indicated pattern attribute.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 All Tooltalk pattern attributes are supported except 'user. The names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 of attributes are the same as the Tooltalk accessors used to set them
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 less the \"tooltalk_pattern_\" prefix and the \"_add\" ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (value, pattern, attribute)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 Lisp_Object value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 Lisp_Object pattern;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 Lisp_Object attribute;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 Tt_pattern p = unbox_tooltalk_pattern (pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 CHECK_SYMBOL (attribute);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 if (!VALID_TOOLTALK_PATTERNP (p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 else if (EQ (attribute, Qtt_category))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 CHECK_TOOLTALK_CONSTANT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 tt_pattern_category_set (p, tooltalk_constant_value (value));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 else if (EQ (attribute, Qtt_address))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 CHECK_TOOLTALK_CONSTANT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 tt_pattern_address_add (p, tooltalk_constant_value (value));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 else if (EQ (attribute, Qtt_class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 CHECK_TOOLTALK_CONSTANT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 tt_pattern_class_add (p, tooltalk_constant_value (value));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 else if (EQ (attribute, Qtt_disposition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 CHECK_TOOLTALK_CONSTANT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 tt_pattern_disposition_add (p, tooltalk_constant_value (value));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 else if (EQ (attribute, Qtt_file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 CONST char *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 CHECK_STRING (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 GET_C_STRING_OS_DATA_ALLOCA (value, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 tt_pattern_file_add (p, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 else if (EQ (attribute, Qtt_object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 CONST char *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 CHECK_STRING (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 GET_C_STRING_OS_DATA_ALLOCA (value, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 tt_pattern_object_add (p, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 else if (EQ (attribute, Qtt_op))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 CONST char *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 CHECK_STRING (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 GET_C_STRING_OS_DATA_ALLOCA (value, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 tt_pattern_op_add (p, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 else if (EQ (attribute, Qtt_otype))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 CONST char *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 CHECK_STRING (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 GET_C_STRING_OS_DATA_ALLOCA (value, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 tt_pattern_otype_add (p, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 else if (EQ (attribute, Qtt_scope))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 CHECK_TOOLTALK_CONSTANT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 tt_pattern_scope_add (p, tooltalk_constant_value (value));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 else if (EQ (attribute, Qtt_sender))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 CONST char *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 CHECK_STRING (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 GET_C_STRING_OS_DATA_ALLOCA (value, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 tt_pattern_sender_add (p, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 else if (EQ (attribute, Qtt_sender_ptype))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 CONST char *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 CHECK_STRING (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 GET_C_STRING_OS_DATA_ALLOCA (value, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 tt_pattern_sender_ptype_add (p, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 else if (EQ (attribute, Qtt_session))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 CONST char *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 CHECK_STRING (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 GET_C_STRING_OS_DATA_ALLOCA (value, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 tt_pattern_session_add (p, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 else if (EQ (attribute, Qtt_state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 CHECK_TOOLTALK_CONSTANT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 tt_pattern_state_add (p, tooltalk_constant_value (value));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 else if (EQ (attribute, Qtt_callback))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 CHECK_SYMBOL (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 XTOOLTALK_PATTERN (pattern)->callback = value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 DEFUN ("add-tooltalk-pattern-arg",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 Fadd_tooltalk_pattern_arg,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 Sadd_tooltalk_pattern_arg,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 3, 4, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 Add one fully specified argument to a tooltalk pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 Mode must be one of TT_IN, TT_INOUT, or TT_OUT, type must be a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 Value can be an integer, string or nil. If value is an integer then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 an integer argument (tt_pattern_iarg_add) added otherwise a string argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 is added. At present there's no way to add a binary data argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (pattern, mode, vtype, value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 Lisp_Object pattern, mode, vtype, value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 Tt_pattern p = unbox_tooltalk_pattern (pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 Tt_mode n;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 CHECK_STRING (vtype);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 CHECK_TOOLTALK_CONSTANT (mode);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1198 n = (Tt_mode) tooltalk_constant_value (mode);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 if (!VALID_TOOLTALK_PATTERNP (p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 return Qnil;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1202
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 CONST char *vtype_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 GET_C_STRING_OS_DATA_ALLOCA (vtype, vtype_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 if (NILP (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 tt_pattern_arg_add (p, n, vtype_ext, NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 else if (STRINGP (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 CONST char *value_ext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 GET_C_STRING_OS_DATA_ALLOCA (value, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 tt_pattern_arg_add (p, n, vtype_ext, value_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 else if (INTP (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 tt_pattern_iarg_add (p, n, vtype_ext, XINT (value));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 DEFUN ("register-tooltalk-pattern",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 Fregister_tooltalk_pattern,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 Sregister_tooltalk_pattern,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 Emacs will begin receiving messages that match this pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 Lisp_Object pattern;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 Tt_pattern p = unbox_tooltalk_pattern (pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 if (VALID_TOOLTALK_PATTERNP (p) && tt_pattern_register (p) == TT_OK)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 Fputhash (pattern, Qnil, Vtooltalk_pattern_gcpro);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 return Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 DEFUN ("unregister-tooltalk-pattern",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 Funregister_tooltalk_pattern,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 Sunregister_tooltalk_pattern,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 Emacs will stop receiving messages that match this pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 Lisp_Object pattern;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 Tt_pattern p = unbox_tooltalk_pattern (pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 if (VALID_TOOLTALK_PATTERNP (p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 tt_pattern_unregister (p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 Fremhash (pattern, Vtooltalk_pattern_gcpro);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 DEFUN ("tooltalk-pattern-prop-get",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 Ftooltalk_pattern_prop_get,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 Stooltalk_pattern_prop_get,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 2, 2, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 Return the value of PROPERTY in tooltalk pattern PATTERN.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 This is the last value set with `tooltalk-pattern-prop-set'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 (pattern, property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 Lisp_Object pattern, property;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 CHECK_TOOLTALK_PATTERN (pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 return Fget (XTOOLTALK_PATTERN (pattern)->plist_sym, property, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 DEFUN ("tooltalk-pattern-prop-set",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 Ftooltalk_pattern_prop_set,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 Stooltalk_pattern_prop_set,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 3, 3, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 Set the value of PROPERTY to VALUE in tooltalk pattern PATTERN.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 It can be retrieved with `tooltalk-pattern-prop-get'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 (pattern, property, value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 Lisp_Object pattern, property, value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 CHECK_TOOLTALK_PATTERN (pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 return Fput (XTOOLTALK_PATTERN (pattern)->plist_sym, property, value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 DEFUN ("tooltalk-pattern-plist-get",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 Ftooltalk_pattern_plist_get,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 Stooltalk_pattern_plist_get,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 Return the a list of all the properties currently set in PATTERN.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 Lisp_Object pattern;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 CHECK_TOOLTALK_PATTERN (pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 return Fcopy_sequence
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (Fsymbol_plist (XTOOLTALK_PATTERN (pattern)->plist_sym));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 DEFUN ("tooltalk-default-procid",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 Ftooltalk_default_procid,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 Stooltalk_default_procid,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 0, 0, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 Return current default process identifier for your process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 char *procid = tt_default_procid ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 if (!procid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 return build_string (procid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 DEFUN ("tooltalk-default-session",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 Ftooltalk_default_session,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 Stooltalk_default_session,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 0, 0, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 Return current default session identifier for the current default procid.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 char *session = tt_default_session ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 if (!session)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 return build_string (session);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 init_tooltalk (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 char *retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 Lisp_Object lp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 Lisp_Object fil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 retval = tt_open ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 if (tt_ptr_error (retval) != TT_OK)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 Vtooltalk_fd = make_int (tt_fd ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 tt_session_join (tt_default_session ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 lp = connect_to_file_descriptor (build_string ("tooltalk"), Qnil,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 Vtooltalk_fd, Vtooltalk_fd);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 if (!NILP (lp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 /* Don't ask the user for confirmation when exiting Emacs */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 Fprocess_kill_without_query (lp, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 XSETSUBR (fil, &Sreceive_tooltalk_message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 set_process_filter (lp, fil, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 tt_close ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 Vtooltalk_fd = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 #if defined (SOLARIS2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 /* Apparently the tt_message_send_on_exit() function does not exist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 under SunOS 4.x or IRIX 5 or various other non-Solaris-2 systems.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 No big deal if we don't do the following under those systems. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 Tt_message exit_msg = tt_message_create ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 tt_message_op_set (exit_msg, "emacs-aborted");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 tt_message_scope_set (exit_msg, TT_SESSION);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 tt_message_class_set (exit_msg, TT_NOTICE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 tt_message_send_on_exit (exit_msg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 tt_message_destroy (exit_msg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 DEFUN ("tooltalk-open-connection",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 Ftooltalk_open_connection, Stooltalk_open_connection,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 0, 0, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 Opens a connection to the ToolTalk server.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 Returns t if successful, nil otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 if (!NILP (Vtooltalk_fd))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 error ("Already connected to ToolTalk.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 if (noninteractive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 error ("Can't connect to ToolTalk in batch mode.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 init_tooltalk ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 return (NILP (Vtooltalk_fd) ? Qnil : Qt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 syms_of_tooltalk (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 defsymbol (&Qtooltalk_messagep, "tooltalk-message-p");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 defsubr (&Stooltalk_message_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 defsymbol (&Qtooltalk_patternp, "tooltalk-pattern-p");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 defsubr (&Stooltalk_pattern_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 defsymbol (&Qtooltalk_message_handler_hook, "tooltalk-message-handler-hook");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 defsymbol (&Qtooltalk_pattern_handler_hook, "tooltalk-pattern-handler-hook");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 defsymbol (&Qtooltalk_unprocessed_message_hook,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 "tooltalk-unprocessed-message-hook");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 defsubr (&Sreceive_tooltalk_message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 defsubr (&Screate_tooltalk_message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 defsubr (&Sdestroy_tooltalk_message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 defsubr (&Sadd_tooltalk_message_arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 defsubr (&Sget_tooltalk_message_attribute);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 defsubr (&Sset_tooltalk_message_attribute);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 defsubr (&Ssend_tooltalk_message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 defsubr (&Sreturn_tooltalk_message);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 defsubr (&Screate_tooltalk_pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 defsubr (&Sdestroy_tooltalk_pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 defsubr (&Sadd_tooltalk_pattern_attribute);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 defsubr (&Sadd_tooltalk_pattern_arg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 defsubr (&Sregister_tooltalk_pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 defsubr (&Sunregister_tooltalk_pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 defsubr (&Stooltalk_pattern_plist_get);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 defsubr (&Stooltalk_pattern_prop_set);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 defsubr (&Stooltalk_pattern_prop_get);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 defsubr (&Stooltalk_default_procid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 defsubr (&Stooltalk_default_session);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 defsubr (&Stooltalk_open_connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 defsymbol (&Qreceive_tooltalk_message, "receive-tooltalk-message");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 defsymbol (&Qtt_address, "address");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 defsymbol (&Qtt_args_count, "args_count");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 defsymbol (&Qtt_arg_bval, "arg_bval");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 defsymbol (&Qtt_arg_ival, "arg_ival");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 defsymbol (&Qtt_arg_mode, "arg_mode");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 defsymbol (&Qtt_arg_type, "arg_type");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 defsymbol (&Qtt_arg_val, "arg_val");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 defsymbol (&Qtt_class, "class");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 defsymbol (&Qtt_category, "category");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 defsymbol (&Qtt_disposition, "disposition");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 defsymbol (&Qtt_file, "file");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 defsymbol (&Qtt_gid, "gid");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 defsymbol (&Qtt_handler, "handler");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 defsymbol (&Qtt_handler_ptype, "handler_ptype");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 defsymbol (&Qtt_object, "object");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 defsymbol (&Qtt_op, "op");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 defsymbol (&Qtt_opnum, "opnum");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 defsymbol (&Qtt_otype, "otype");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 defsymbol (&Qtt_scope, "scope");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 defsymbol (&Qtt_sender, "sender");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 defsymbol (&Qtt_sender_ptype, "sender_ptype");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 defsymbol (&Qtt_session, "session");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 defsymbol (&Qtt_state, "state");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 defsymbol (&Qtt_status, "status");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 defsymbol (&Qtt_status_string, "status_string");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 defsymbol (&Qtt_uid, "uid");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 defsymbol (&Qtt_callback, "callback");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 defsymbol (&Qtt_prop, "prop");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 defsymbol (&Qtt_plist, "plist");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 defsymbol (&Qtt_reject, "reject");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 defsymbol (&Qtt_reply, "reply");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 defsymbol (&Qtt_fail, "fail");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 deferror (&Qtooltalk_error, "tooltalk-error", "ToolTalk error", Qio_error);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 vars_of_tooltalk (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 Fprovide (intern ("tooltalk"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 DEFVAR_LISP ("tooltalk-fd", &Vtooltalk_fd /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 File descriptor returned by tt_initialize; nil if not connected to ToolTalk.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 Vtooltalk_fd = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 DEFVAR_LISP ("tooltalk-message-handler-hook",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 &Vtooltalk_message_handler_hook /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 List of functions to be applied to each ToolTalk message reply received.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 This will always occur as a result of our sending a request message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 Functions will be called with two arguments, the message and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 corresponding pattern. This hook will not be called if the request
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 message was created without a C-level callback function (see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 `tooltalk-unprocessed-message-hook').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 Vtooltalk_message_handler_hook = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 DEFVAR_LISP ("tooltalk-pattern-handler-hook",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 &Vtooltalk_pattern_handler_hook /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 List of functions to be applied to each pattern-matching ToolTalk message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 This is all messages except those handled by `tooltalk-message-handler-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 Functions will be called with two arguments, the message and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 corresponding pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 Vtooltalk_pattern_handler_hook = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 DEFVAR_LISP ("tooltalk-unprocessed-message-hook",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 &Vtooltalk_unprocessed_message_hook /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 List of functions to be applied to each unprocessed ToolTalk message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 Unprocessed messages are messages that didn't match any patterns.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 Vtooltalk_unprocessed_message_hook = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 Tooltalk_Message_plist_str = build_string ("Tooltalk Message plist");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 Tooltalk_Pattern_plist_str = build_string ("Tooltalk Pattern plist");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 #define MAKE_CONSTANT(name) do { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 defsymbol (&Q_ ## name, #name); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 Fset (Q_ ## name, make_int (name)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 MAKE_CONSTANT (TT_MODE_UNDEFINED);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 MAKE_CONSTANT (TT_IN);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 MAKE_CONSTANT (TT_OUT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 MAKE_CONSTANT (TT_INOUT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 MAKE_CONSTANT (TT_MODE_LAST);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 MAKE_CONSTANT (TT_SCOPE_NONE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 MAKE_CONSTANT (TT_SESSION);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 MAKE_CONSTANT (TT_FILE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 MAKE_CONSTANT (TT_BOTH);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 MAKE_CONSTANT (TT_FILE_IN_SESSION);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 MAKE_CONSTANT (TT_CLASS_UNDEFINED);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 MAKE_CONSTANT (TT_NOTICE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 MAKE_CONSTANT (TT_REQUEST);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 MAKE_CONSTANT (TT_CLASS_LAST);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 MAKE_CONSTANT (TT_CATEGORY_UNDEFINED);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 MAKE_CONSTANT (TT_OBSERVE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 MAKE_CONSTANT (TT_HANDLE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 MAKE_CONSTANT (TT_CATEGORY_LAST);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 MAKE_CONSTANT (TT_PROCEDURE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 MAKE_CONSTANT (TT_OBJECT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 MAKE_CONSTANT (TT_HANDLER);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 MAKE_CONSTANT (TT_OTYPE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 MAKE_CONSTANT (TT_ADDRESS_LAST);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 MAKE_CONSTANT (TT_CREATED);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 MAKE_CONSTANT (TT_SENT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 MAKE_CONSTANT (TT_HANDLED);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 MAKE_CONSTANT (TT_FAILED);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 MAKE_CONSTANT (TT_QUEUED);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 MAKE_CONSTANT (TT_STARTED);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 MAKE_CONSTANT (TT_REJECTED);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 MAKE_CONSTANT (TT_STATE_LAST);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 MAKE_CONSTANT (TT_DISCARD);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 MAKE_CONSTANT (TT_QUEUE);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 MAKE_CONSTANT (TT_START);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 #undef MAKE_CONSTANT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 staticpro (&Vtooltalk_message_gcpro);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 staticpro (&Vtooltalk_pattern_gcpro);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 Vtooltalk_message_gcpro = make_lisp_hashtable (10, HASHTABLE_NONWEAK,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 HASHTABLE_EQ);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 Vtooltalk_pattern_gcpro = make_lisp_hashtable (10, HASHTABLE_NONWEAK,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 HASHTABLE_EQ);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 }