aboutsummaryrefslogtreecommitdiffstats
path: root/src/dbusbind.c
diff options
context:
space:
mode:
authorPaul Eggert2011-08-30 09:27:26 -0700
committerPaul Eggert2011-08-30 09:27:26 -0700
commit2be7d7020619ebbdfb3df2bc2c3fcc3123bcedc0 (patch)
tree736577aecc3a735025e43a4173e9961206e5ecb0 /src/dbusbind.c
parentf00b626d886d32b08aa6fb47e1cee124c1926897 (diff)
downloademacs-2be7d7020619ebbdfb3df2bc2c3fcc3123bcedc0.tar.gz
emacs-2be7d7020619ebbdfb3df2bc2c3fcc3123bcedc0.zip
* dbusbind.c (signature_cat): New function.
Diffstat (limited to 'src/dbusbind.c')
-rw-r--r--src/dbusbind.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 005d521c1db..f7422ca2ddc 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -259,6 +259,18 @@ xd_symbol_to_dbus_type (Lisp_Object object)
259 } \ 259 } \
260 while (0) 260 while (0)
261 261
262/* Append to SIGNATURE the a copy of X, making sure SIGNATURE does
263 not become too long. */
264static void
265signature_cat (char *signature, char const *x)
266{
267 ptrdiff_t siglen = strlen (signature);
268 ptrdiff_t xlen = strlen (x);
269 if (DBUS_MAXIMUM_SIGNATURE_LENGTH - xlen <= siglen)
270 string_overflow ();
271 strcat (signature, x);
272}
273
262/* Compute SIGNATURE of OBJECT. It must have a form that it can be 274/* Compute SIGNATURE of OBJECT. It must have a form that it can be
263 used in dbus_message_iter_open_container. DTYPE is the DBusType 275 used in dbus_message_iter_open_container. DTYPE is the DBusType
264 the object is related to. It is passed as argument, because it 276 the object is related to. It is passed as argument, because it
@@ -388,10 +400,10 @@ xd_signature (char *signature, unsigned int dtype, unsigned int parent_type, Lis
388 { 400 {
389 subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt)); 401 subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt));
390 xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt))); 402 xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt)));
391 strcat (signature, x); 403 signature_cat (signature, x);
392 elt = CDR_SAFE (XD_NEXT_VALUE (elt)); 404 elt = CDR_SAFE (XD_NEXT_VALUE (elt));
393 } 405 }
394 strcat (signature, DBUS_STRUCT_END_CHAR_AS_STRING); 406 signature_cat (signature, DBUS_STRUCT_END_CHAR_AS_STRING);
395 break; 407 break;
396 408
397 case DBUS_TYPE_DICT_ENTRY: 409 case DBUS_TYPE_DICT_ENTRY:
@@ -412,7 +424,7 @@ xd_signature (char *signature, unsigned int dtype, unsigned int parent_type, Lis
412 elt = XD_NEXT_VALUE (elt); 424 elt = XD_NEXT_VALUE (elt);
413 subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt)); 425 subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt));
414 xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt))); 426 xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt)));
415 strcat (signature, x); 427 signature_cat (signature, x);
416 428
417 if (!XD_BASIC_DBUS_TYPE (subtype)) 429 if (!XD_BASIC_DBUS_TYPE (subtype))
418 wrong_type_argument (intern ("D-Bus"), CAR_SAFE (XD_NEXT_VALUE (elt))); 430 wrong_type_argument (intern ("D-Bus"), CAR_SAFE (XD_NEXT_VALUE (elt)));
@@ -421,14 +433,14 @@ xd_signature (char *signature, unsigned int dtype, unsigned int parent_type, Lis
421 elt = CDR_SAFE (XD_NEXT_VALUE (elt)); 433 elt = CDR_SAFE (XD_NEXT_VALUE (elt));
422 subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt)); 434 subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt));
423 xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt))); 435 xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt)));
424 strcat (signature, x); 436 signature_cat (signature, x);
425 437
426 if (!NILP (CDR_SAFE (XD_NEXT_VALUE (elt)))) 438 if (!NILP (CDR_SAFE (XD_NEXT_VALUE (elt))))
427 wrong_type_argument (intern ("D-Bus"), 439 wrong_type_argument (intern ("D-Bus"),
428 CAR_SAFE (CDR_SAFE (XD_NEXT_VALUE (elt)))); 440 CAR_SAFE (CDR_SAFE (XD_NEXT_VALUE (elt))));
429 441
430 /* Closing signature. */ 442 /* Closing signature. */
431 strcat (signature, DBUS_DICT_ENTRY_END_CHAR_AS_STRING); 443 signature_cat (signature, DBUS_DICT_ENTRY_END_CHAR_AS_STRING);
432 break; 444 break;
433 445
434 default: 446 default: