comparison src/tooltalk.c @ 4990:8f0cf4fd3d2c

Automatic merge
author Ben Wing <ben@xemacs.org>
date Sat, 06 Feb 2010 04:01:46 -0600
parents 4aebb0131297
children ae48681c47fa
comparison
equal deleted inserted replaced
4989:d2ec55325515 4990:8f0cf4fd3d2c
310 { 310 {
311 if (tt_is_err (st)) 311 if (tt_is_err (st))
312 { 312 {
313 CIbyte *err; 313 CIbyte *err;
314 314
315 EXTERNAL_TO_C_STRING (tt_status_message (st), err, Qtooltalk_encoding); 315 err = EXTERNAL_TO_ITEXT (tt_status_message (st), Qtooltalk_encoding);
316 signal_error (Qtooltalk_error, err, Qunbound); 316 signal_error (Qtooltalk_error, err, Qunbound);
317 } 317 }
318 } 318 }
319 319
320 DEFUN ("receive-tooltalk-message", Freceive_tooltalk_message, 0, 2, 0, /* 320 DEFUN ("receive-tooltalk-message", Freceive_tooltalk_message, 0, 2, 0, /*
512 } 512 }
513 513
514 static Lisp_Object 514 static Lisp_Object
515 tt_build_c_string (char *s) 515 tt_build_c_string (char *s)
516 { 516 {
517 return build_string (s ? s : ""); 517 return build_cistring (s ? s : "");
518 } 518 }
519 519
520 static Lisp_Object 520 static Lisp_Object
521 tt_opnum_string (int n) 521 tt_opnum_string (int n)
522 { 522 {
523 char buf[32]; 523 Ascbyte buf[32];
524 524
525 sprintf (buf, "%u", n); 525 sprintf (buf, "%u", n);
526 return build_string (buf); 526 return build_ascstring (buf);
527 } 527 }
528 528
529 static Lisp_Object 529 static Lisp_Object
530 tt_message_arg_ival_string (Tt_message m, int n) 530 tt_message_arg_ival_string (Tt_message m, int n)
531 { 531 {
532 char buf[DECIMAL_PRINT_SIZE (long)]; 532 Ascbyte buf[DECIMAL_PRINT_SIZE (long)];
533 int value; 533 int value;
534 534
535 check_status (tt_message_arg_ival (m, n, &value)); 535 check_status (tt_message_arg_ival (m, n, &value));
536 long_to_string (buf, value); 536 long_to_string (buf, value);
537 return build_string (buf); 537 return build_ascstring (buf);
538 } 538 }
539 539
540 static Lisp_Object 540 static Lisp_Object
541 tt_message_arg_bval_vector (Tt_message m, int n) 541 tt_message_arg_bval_vector (Tt_message m, int n)
542 { 542 {
771 else if (EQ (attribute, Qtt_arg_bval)) 771 else if (EQ (attribute, Qtt_arg_bval))
772 { 772 {
773 Extbyte *value_ext; 773 Extbyte *value_ext;
774 Bytecount value_ext_len; 774 Bytecount value_ext_len;
775 CHECK_STRING (value); 775 CHECK_STRING (value);
776 TO_EXTERNAL_FORMAT (LISP_STRING, value, 776 LISP_STRING_TO_SIZED_EXTERNAL (value, value_ext, value_ext_len,
777 ALLOCA, (value_ext, value_ext_len), 777 Qtooltalk_encoding);
778 Qtooltalk_encoding);
779 tt_message_arg_bval_set (m, n, (unsigned char *) value_ext, value_ext_len); 778 tt_message_arg_bval_set (m, n, (unsigned char *) value_ext, value_ext_len);
780 } 779 }
781 else if (EQ (attribute, Qtt_arg_ival)) 780 else if (EQ (attribute, Qtt_arg_ival))
782 { 781 {
783 CHECK_INT (value); 782 CHECK_INT (value);
785 } 784 }
786 else if (EQ (attribute, Qtt_arg_val)) 785 else if (EQ (attribute, Qtt_arg_val))
787 { 786 {
788 const char *value_ext; 787 const char *value_ext;
789 CHECK_STRING (value); 788 CHECK_STRING (value);
790 LISP_STRING_TO_EXTERNAL (value, value_ext, Qtooltalk_encoding); 789 value_ext = LISP_STRING_TO_EXTERNAL (value, Qtooltalk_encoding);
791 tt_message_arg_val_set (m, n, value_ext); 790 tt_message_arg_val_set (m, n, value_ext);
792 } 791 }
793 else if (EQ (attribute, Qtt_status)) 792 else if (EQ (attribute, Qtt_status))
794 { 793 {
795 CHECK_INT (value); 794 CHECK_INT (value);
810 809
811 if (fun_str) 810 if (fun_str)
812 { 811 {
813 const char *value_ext; 812 const char *value_ext;
814 CHECK_STRING (value); 813 CHECK_STRING (value);
815 LISP_STRING_TO_EXTERNAL (value, value_ext, Qtooltalk_encoding); 814 value_ext = LISP_STRING_TO_EXTERNAL (value, Qtooltalk_encoding);
816 (*fun_str) (m, value_ext); 815 (*fun_str) (m, value_ext);
817 } 816 }
818 817
819 return Qnil; 818 return Qnil;
820 } 819 }
926 if (!VALID_TOOLTALK_MESSAGEP (m)) 925 if (!VALID_TOOLTALK_MESSAGEP (m))
927 return Qnil; 926 return Qnil;
928 { 927 {
929 const char *vtype_ext; 928 const char *vtype_ext;
930 929
931 LISP_STRING_TO_EXTERNAL (vtype, vtype_ext, Qtooltalk_encoding); 930 vtype_ext = LISP_STRING_TO_EXTERNAL (vtype, Qtooltalk_encoding);
932 if (NILP (value)) 931 if (NILP (value))
933 tt_message_arg_add (m, n, vtype_ext, NULL); 932 tt_message_arg_add (m, n, vtype_ext, NULL);
934 else if (STRINGP (value)) 933 else if (STRINGP (value))
935 { 934 {
936 const char *value_ext; 935 const char *value_ext;
937 LISP_STRING_TO_EXTERNAL (value, value_ext, Qtooltalk_encoding); 936 value_ext = LISP_STRING_TO_EXTERNAL (value, Qtooltalk_encoding);
938 tt_message_arg_add (m, n, vtype_ext, value_ext); 937 tt_message_arg_add (m, n, vtype_ext, value_ext);
939 } 938 }
940 else if (INTP (value)) 939 else if (INTP (value))
941 tt_message_iarg_add (m, n, vtype_ext, XINT (value)); 940 tt_message_iarg_add (m, n, vtype_ext, XINT (value));
942 } 941 }
1037 } 1036 }
1038 else if (EQ (attribute, Qtt_file)) 1037 else if (EQ (attribute, Qtt_file))
1039 { 1038 {
1040 const char *value_ext; 1039 const char *value_ext;
1041 CHECK_STRING (value); 1040 CHECK_STRING (value);
1042 LISP_STRING_TO_EXTERNAL (value, value_ext, Qtooltalk_encoding); 1041 value_ext = LISP_STRING_TO_EXTERNAL (value, Qtooltalk_encoding);
1043 tt_pattern_file_add (p, value_ext); 1042 tt_pattern_file_add (p, value_ext);
1044 } 1043 }
1045 else if (EQ (attribute, Qtt_object)) 1044 else if (EQ (attribute, Qtt_object))
1046 { 1045 {
1047 const char *value_ext; 1046 const char *value_ext;
1048 CHECK_STRING (value); 1047 CHECK_STRING (value);
1049 LISP_STRING_TO_EXTERNAL (value, value_ext, Qtooltalk_encoding); 1048 value_ext = LISP_STRING_TO_EXTERNAL (value, Qtooltalk_encoding);
1050 tt_pattern_object_add (p, value_ext); 1049 tt_pattern_object_add (p, value_ext);
1051 } 1050 }
1052 else if (EQ (attribute, Qtt_op)) 1051 else if (EQ (attribute, Qtt_op))
1053 { 1052 {
1054 const char *value_ext; 1053 const char *value_ext;
1055 CHECK_STRING (value); 1054 CHECK_STRING (value);
1056 LISP_STRING_TO_EXTERNAL (value, value_ext, Qtooltalk_encoding); 1055 value_ext = LISP_STRING_TO_EXTERNAL (value, Qtooltalk_encoding);
1057 tt_pattern_op_add (p, value_ext); 1056 tt_pattern_op_add (p, value_ext);
1058 } 1057 }
1059 else if (EQ (attribute, Qtt_otype)) 1058 else if (EQ (attribute, Qtt_otype))
1060 { 1059 {
1061 const char *value_ext; 1060 const char *value_ext;
1062 CHECK_STRING (value); 1061 CHECK_STRING (value);
1063 LISP_STRING_TO_EXTERNAL (value, value_ext, Qtooltalk_encoding); 1062 value_ext = LISP_STRING_TO_EXTERNAL (value, Qtooltalk_encoding);
1064 tt_pattern_otype_add (p, value_ext); 1063 tt_pattern_otype_add (p, value_ext);
1065 } 1064 }
1066 else if (EQ (attribute, Qtt_scope)) 1065 else if (EQ (attribute, Qtt_scope))
1067 { 1066 {
1068 CHECK_TOOLTALK_CONSTANT (value); 1067 CHECK_TOOLTALK_CONSTANT (value);
1070 } 1069 }
1071 else if (EQ (attribute, Qtt_sender)) 1070 else if (EQ (attribute, Qtt_sender))
1072 { 1071 {
1073 const char *value_ext; 1072 const char *value_ext;
1074 CHECK_STRING (value); 1073 CHECK_STRING (value);
1075 LISP_STRING_TO_EXTERNAL (value, value_ext, Qtooltalk_encoding); 1074 value_ext = LISP_STRING_TO_EXTERNAL (value, Qtooltalk_encoding);
1076 tt_pattern_sender_add (p, value_ext); 1075 tt_pattern_sender_add (p, value_ext);
1077 } 1076 }
1078 else if (EQ (attribute, Qtt_sender_ptype)) 1077 else if (EQ (attribute, Qtt_sender_ptype))
1079 { 1078 {
1080 const char *value_ext; 1079 const char *value_ext;
1081 CHECK_STRING (value); 1080 CHECK_STRING (value);
1082 LISP_STRING_TO_EXTERNAL (value, value_ext, Qtooltalk_encoding); 1081 value_ext = LISP_STRING_TO_EXTERNAL (value, Qtooltalk_encoding);
1083 tt_pattern_sender_ptype_add (p, value_ext); 1082 tt_pattern_sender_ptype_add (p, value_ext);
1084 } 1083 }
1085 else if (EQ (attribute, Qtt_session)) 1084 else if (EQ (attribute, Qtt_session))
1086 { 1085 {
1087 const char *value_ext; 1086 const char *value_ext;
1088 CHECK_STRING (value); 1087 CHECK_STRING (value);
1089 LISP_STRING_TO_EXTERNAL (value, value_ext, Qtooltalk_encoding); 1088 value_ext = LISP_STRING_TO_EXTERNAL (value, Qtooltalk_encoding);
1090 tt_pattern_session_add (p, value_ext); 1089 tt_pattern_session_add (p, value_ext);
1091 } 1090 }
1092 else if (EQ (attribute, Qtt_state)) 1091 else if (EQ (attribute, Qtt_state))
1093 { 1092 {
1094 CHECK_TOOLTALK_CONSTANT (value); 1093 CHECK_TOOLTALK_CONSTANT (value);
1125 return Qnil; 1124 return Qnil;
1126 1125
1127 { 1126 {
1128 const char *vtype_ext; 1127 const char *vtype_ext;
1129 1128
1130 LISP_STRING_TO_EXTERNAL (vtype, vtype_ext, Qtooltalk_encoding); 1129 vtype_ext = LISP_STRING_TO_EXTERNAL (vtype, Qtooltalk_encoding);
1131 if (NILP (value)) 1130 if (NILP (value))
1132 tt_pattern_arg_add (p, n, vtype_ext, NULL); 1131 tt_pattern_arg_add (p, n, vtype_ext, NULL);
1133 else if (STRINGP (value)) 1132 else if (STRINGP (value))
1134 { 1133 {
1135 const char *value_ext; 1134 const char *value_ext;
1136 LISP_STRING_TO_EXTERNAL (value, value_ext, Qtooltalk_encoding); 1135 value_ext = LISP_STRING_TO_EXTERNAL (value, Qtooltalk_encoding);
1137 tt_pattern_arg_add (p, n, vtype_ext, value_ext); 1136 tt_pattern_arg_add (p, n, vtype_ext, value_ext);
1138 } 1137 }
1139 else if (INTP (value)) 1138 else if (INTP (value))
1140 tt_pattern_iarg_add (p, n, vtype_ext, XINT (value)); 1139 tt_pattern_iarg_add (p, n, vtype_ext, XINT (value));
1141 } 1140 }
1213 DEFUN ("tooltalk-default-procid", Ftooltalk_default_procid, 0, 0, 0, /* 1212 DEFUN ("tooltalk-default-procid", Ftooltalk_default_procid, 0, 0, 0, /*
1214 Return current default process identifier for your process. 1213 Return current default process identifier for your process.
1215 */ 1214 */
1216 ()) 1215 ())
1217 { 1216 {
1218 char *procid = tt_default_procid (); 1217 Extbyte *procid = tt_default_procid ();
1219 return procid ? build_string (procid) : Qnil; 1218 return procid ? build_extstring (procid, Qtooltalk_encoding) : Qnil;
1220 } 1219 }
1221 1220
1222 DEFUN ("tooltalk-default-session", Ftooltalk_default_session, 0, 0, 0, /* 1221 DEFUN ("tooltalk-default-session", Ftooltalk_default_session, 0, 0, 0, /*
1223 Return current default session identifier for the current default procid. 1222 Return current default session identifier for the current default procid.
1224 */ 1223 */
1225 ()) 1224 ())
1226 { 1225 {
1227 char *session = tt_default_session (); 1226 Extbyte *session = tt_default_session ();
1228 return session ? build_string (session) : Qnil; 1227 return session ? build_extstring (session, Qtooltalk_encoding) : Qnil;
1229 } 1228 }
1230 1229
1231 static void 1230 static void
1232 init_tooltalk (void) 1231 init_tooltalk (void)
1233 { 1232 {
1263 1262
1264 Vtooltalk_fd = make_int (tt_fd ()); 1263 Vtooltalk_fd = make_int (tt_fd ());
1265 1264
1266 tt_session_join (tt_default_session ()); 1265 tt_session_join (tt_default_session ());
1267 1266
1268 lp = connect_to_file_descriptor (build_string ("tooltalk"), Qnil, 1267 lp = connect_to_file_descriptor (build_ascstring ("tooltalk"), Qnil,
1269 Vtooltalk_fd, Vtooltalk_fd); 1268 Vtooltalk_fd, Vtooltalk_fd);
1270 if (!NILP (lp)) 1269 if (!NILP (lp))
1271 { 1270 {
1272 /* Don't ask the user for confirmation when exiting Emacs */ 1271 /* Don't ask the user for confirmation when exiting Emacs */
1273 Fprocess_kill_without_query (lp, Qnil); 1272 Fprocess_kill_without_query (lp, Qnil);
1419 List of functions to be applied to each unprocessed ToolTalk message. 1418 List of functions to be applied to each unprocessed ToolTalk message.
1420 Unprocessed messages are messages that didn't match any patterns. 1419 Unprocessed messages are messages that didn't match any patterns.
1421 */ ); 1420 */ );
1422 Vtooltalk_unprocessed_message_hook = Qnil; 1421 Vtooltalk_unprocessed_message_hook = Qnil;
1423 1422
1424 Tooltalk_Message_plist_str = build_msg_string ("Tooltalk Message plist"); 1423 Tooltalk_Message_plist_str = build_defer_string ("Tooltalk Message plist");
1425 Tooltalk_Pattern_plist_str = build_msg_string ("Tooltalk Pattern plist"); 1424 Tooltalk_Pattern_plist_str = build_defer_string ("Tooltalk Pattern plist");
1426 1425
1427 staticpro(&Tooltalk_Message_plist_str); 1426 staticpro(&Tooltalk_Message_plist_str);
1428 staticpro(&Tooltalk_Pattern_plist_str); 1427 staticpro(&Tooltalk_Pattern_plist_str);
1429 1428
1430 #define MAKE_CONSTANT(name) do { \ 1429 #define MAKE_CONSTANT(name) do { \