comparison src/dbusbind.c @ 97797:14fccbb34a16

* dbusbind.c (XD_ERROR, XD_DEBUG_MESSAGE): Use strncpy and snprintf, respectively. (xd_append_arg): Convert strings with Fstring_make_unibyte.
author Michael Albinus <michael.albinus@gmx.de>
date Thu, 28 Aug 2008 20:28:12 +0000
parents 194ecdbbd8a3
children e5f33aa05b97
comparison
equal deleted inserted replaced
97796:5d474cdb19f8 97797:14fccbb34a16
69 69
70 /* Raise a Lisp error from a D-Bus ERROR. */ 70 /* Raise a Lisp error from a D-Bus ERROR. */
71 #define XD_ERROR(error) \ 71 #define XD_ERROR(error) \
72 do { \ 72 do { \
73 char s[1024]; \ 73 char s[1024]; \
74 strcpy (s, error.message); \ 74 strncpy (s, error.message, 1023); \
75 dbus_error_free (&error); \ 75 dbus_error_free (&error); \
76 /* Remove the trailing newline. */ \ 76 /* Remove the trailing newline. */ \
77 if (strchr (s, '\n') != NULL) \ 77 if (strchr (s, '\n') != NULL) \
78 s[strlen (s) - 1] = '\0'; \ 78 s[strlen (s) - 1] = '\0'; \
79 xsignal1 (Qdbus_error, build_string (s)); \ 79 xsignal1 (Qdbus_error, build_string (s)); \
83 "make MYCPPFLAGS='-DDBUS_DEBUG -Wall'". */ 83 "make MYCPPFLAGS='-DDBUS_DEBUG -Wall'". */
84 #ifdef DBUS_DEBUG 84 #ifdef DBUS_DEBUG
85 #define XD_DEBUG_MESSAGE(...) \ 85 #define XD_DEBUG_MESSAGE(...) \
86 do { \ 86 do { \
87 char s[1024]; \ 87 char s[1024]; \
88 sprintf (s, __VA_ARGS__); \ 88 snprintf (s, 1023, __VA_ARGS__); \
89 printf ("%s: %s\n", __func__, s); \ 89 printf ("%s: %s\n", __func__, s); \
90 message ("%s: %s", __func__, s); \ 90 message ("%s: %s", __func__, s); \
91 } while (0) 91 } while (0)
92 #define XD_DEBUG_VALID_LISP_OBJECT_P(object) \ 92 #define XD_DEBUG_VALID_LISP_OBJECT_P(object) \
93 do { \ 93 do { \
102 #define XD_DEBUG_MESSAGE(...) \ 102 #define XD_DEBUG_MESSAGE(...) \
103 do { \ 103 do { \
104 if (!NILP (Vdbus_debug)) \ 104 if (!NILP (Vdbus_debug)) \
105 { \ 105 { \
106 char s[1024]; \ 106 char s[1024]; \
107 sprintf (s, __VA_ARGS__); \ 107 snprintf (s, 1023, __VA_ARGS__); \
108 message ("%s: %s", __func__, s); \ 108 message ("%s: %s", __func__, s); \
109 } \ 109 } \
110 } while (0) 110 } while (0)
111 #define XD_DEBUG_VALID_LISP_OBJECT_P(object) 111 #define XD_DEBUG_VALID_LISP_OBJECT_P(object)
112 #endif 112 #endif
177 cannot be detected in basic type objects, when they are preceded by 177 cannot be detected in basic type objects, when they are preceded by
178 a type symbol. PARENT_TYPE is the DBusType of a container this 178 a type symbol. PARENT_TYPE is the DBusType of a container this
179 signature is embedded, or DBUS_TYPE_INVALID. It is needed for the 179 signature is embedded, or DBUS_TYPE_INVALID. It is needed for the
180 check that DBUS_TYPE_DICT_ENTRY occurs only as array element. */ 180 check that DBUS_TYPE_DICT_ENTRY occurs only as array element. */
181 void 181 void
182 xd_signature(signature, dtype, parent_type, object) 182 xd_signature (signature, dtype, parent_type, object)
183 char *signature; 183 char *signature;
184 unsigned int dtype, parent_type; 184 unsigned int dtype, parent_type;
185 Lisp_Object object; 185 Lisp_Object object;
186 { 186 {
187 unsigned int subtype; 187 unsigned int subtype;
452 452
453 case DBUS_TYPE_STRING: 453 case DBUS_TYPE_STRING:
454 case DBUS_TYPE_OBJECT_PATH: 454 case DBUS_TYPE_OBJECT_PATH:
455 case DBUS_TYPE_SIGNATURE: 455 case DBUS_TYPE_SIGNATURE:
456 { 456 {
457 char *val = SDATA (object); 457 char *val = SDATA (Fstring_make_unibyte (object));
458 XD_DEBUG_MESSAGE ("%c %s", dtype, val); 458 XD_DEBUG_MESSAGE ("%c %s", dtype, val);
459 if (!dbus_message_iter_append_basic (iter, dtype, &val)) 459 if (!dbus_message_iter_append_basic (iter, dtype, &val))
460 xsignal2 (Qdbus_error, 460 xsignal2 (Qdbus_error,
461 build_string ("Unable to append argument"), object); 461 build_string ("Unable to append argument"), object);
462 return; 462 return;