]> code.delx.au - gnu-emacs/blobdiff - src/dbusbind.c
* dbusbind.c (Fdbus_call_method): Unbreak usage line.
[gnu-emacs] / src / dbusbind.c
index 21e3f83a50972ff39155c9fe0b2e3fe8b3e50bb9..7a30cabca2ea5fa989dcb9ca411e8a5ac91d46bb 100644 (file)
@@ -71,7 +71,7 @@ Lisp_Object Vdbus_debug;
 #define XD_ERROR(error)                                                        \
   do {                                                                 \
     char s[1024];                                                      \
-    strcpy (s, error.message);                                         \
+    strncpy (s, error.message, 1023);                                  \
     dbus_error_free (&error);                                          \
     /* Remove the trailing newline.  */                                        \
     if (strchr (s, '\n') != NULL)                                      \
@@ -85,7 +85,7 @@ Lisp_Object Vdbus_debug;
 #define XD_DEBUG_MESSAGE(...)          \
   do {                                 \
     char s[1024];                      \
-    sprintf (s, __VA_ARGS__);          \
+    snprintf (s, 1023, __VA_ARGS__);   \
     printf ("%s: %s\n", __func__, s);  \
     message ("%s: %s", __func__, s);   \
   } while (0)
@@ -104,7 +104,7 @@ Lisp_Object Vdbus_debug;
     if (!NILP (Vdbus_debug))                                           \
       {                                                                        \
        char s[1024];                                                   \
-       sprintf (s, __VA_ARGS__);                                       \
+       snprintf (s, 1023, __VA_ARGS__);                                \
        message ("%s: %s", __func__, s);                                \
       }                                                                        \
   } while (0)
@@ -179,7 +179,7 @@ Lisp_Object Vdbus_debug;
    signature is embedded, or DBUS_TYPE_INVALID.  It is needed for the
    check that DBUS_TYPE_DICT_ENTRY occurs only as array element.  */
 void
-xd_signature(signature, dtype, parent_type, object)
+xd_signature (signature, dtype, parent_type, object)
      char *signature;
      unsigned int dtype, parent_type;
      Lisp_Object object;
@@ -298,7 +298,7 @@ xd_signature(signature, dtype, parent_type, object)
          strcat (signature, x);
          elt = CDR_SAFE (XD_NEXT_VALUE (elt));
        }
-      sprintf (signature, "%s%c", signature, DBUS_STRUCT_END_CHAR);
+      strcat (signature, DBUS_STRUCT_END_CHAR_AS_STRING);
       break;
 
     case DBUS_TYPE_DICT_ENTRY:
@@ -335,7 +335,7 @@ xd_signature(signature, dtype, parent_type, object)
                             CAR_SAFE (CDR_SAFE (XD_NEXT_VALUE (elt))));
 
       /* Closing signature.  */
-      sprintf (signature, "%s%c", signature, DBUS_DICT_ENTRY_END_CHAR);
+      strcat (signature, DBUS_DICT_ENTRY_END_CHAR_AS_STRING);
       break;
 
     default:
@@ -454,7 +454,7 @@ xd_append_arg (dtype, object, iter)
       case DBUS_TYPE_OBJECT_PATH:
       case DBUS_TYPE_SIGNATURE:
        {
-         char *val = SDATA (object);
+         char *val = SDATA (Fstring_make_unibyte (object));
          XD_DEBUG_MESSAGE ("%c %s", dtype, val);
          if (!dbus_message_iter_append_basic (iter, dtype, &val))
            xsignal2 (Qdbus_error,
@@ -785,9 +785,7 @@ object is returned instead of a list containing this single Lisp object.
 
   => "i686"
 
-usage: (dbus-call-method
-         BUS SERVICE PATH INTERFACE METHOD
-         &optional :timeout TIMEOUT &rest ARGS)  */)
+usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &optional :timeout TIMEOUT &rest ARGS)  */)
      (nargs, args)
      int nargs;
      register Lisp_Object *args;
@@ -969,9 +967,7 @@ Example:
 
   -| i686
 
-usage: (dbus-call-method-asynchronously
-         BUS SERVICE PATH INTERFACE METHOD HANDLER
-         &optional :timeout TIMEOUT &rest ARGS)  */)
+usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLER &optional :timeout TIMEOUT &rest ARGS)  */)
      (nargs, args)
      int nargs;
      register Lisp_Object *args;
@@ -1436,29 +1432,32 @@ xd_read_message (bus)
 
   /* Read message type, message serial, unique name, object path,
      interface and member from the message.  */
-  mtype     = dbus_message_get_type (dmessage);
-  serial    = (mtype == DBUS_MESSAGE_TYPE_METHOD_RETURN ?
-              dbus_message_get_reply_serial (dmessage) :
-              dbus_message_get_serial (dmessage));
-  uname     = dbus_message_get_sender (dmessage);
-  path      = dbus_message_get_path (dmessage);
+  mtype = dbus_message_get_type (dmessage);
+  serial =
+    ((mtype == DBUS_MESSAGE_TYPE_METHOD_RETURN)
+     || (mtype == DBUS_MESSAGE_TYPE_ERROR))
+    ? dbus_message_get_reply_serial (dmessage)
+    : dbus_message_get_serial (dmessage);
+  uname = dbus_message_get_sender (dmessage);
+  path = dbus_message_get_path (dmessage);
   interface = dbus_message_get_interface (dmessage);
-  member    = dbus_message_get_member (dmessage);
+  member = dbus_message_get_member (dmessage);
 
   XD_DEBUG_MESSAGE ("Event received: %s %d %s %s %s %s %s",
-                   (mtype == DBUS_MESSAGE_TYPE_INVALID) ?
-                   "DBUS_MESSAGE_TYPE_INVALID" :
-                   (mtype == DBUS_MESSAGE_TYPE_METHOD_CALL) ?
-                   "DBUS_MESSAGE_TYPE_METHOD_CALL" :
-                   (mtype == DBUS_MESSAGE_TYPE_METHOD_RETURN) ?
-                   "DBUS_MESSAGE_TYPE_METHOD_RETURN" :
-                   (mtype == DBUS_MESSAGE_TYPE_ERROR) ?
-                   "DBUS_MESSAGE_TYPE_METHOD_ERROR" :
-                   "DBUS_MESSAGE_TYPE_METHOD_SIGNAL",
+                   (mtype == DBUS_MESSAGE_TYPE_INVALID)
+                   ? "DBUS_MESSAGE_TYPE_INVALID"
+                   : (mtype == DBUS_MESSAGE_TYPE_METHOD_CALL)
+                   ? "DBUS_MESSAGE_TYPE_METHOD_CALL"
+                   : (mtype == DBUS_MESSAGE_TYPE_METHOD_RETURN)
+                   ? "DBUS_MESSAGE_TYPE_METHOD_RETURN"
+                   : (mtype == DBUS_MESSAGE_TYPE_ERROR)
+                   ? "DBUS_MESSAGE_TYPE_ERROR"
+                   : "DBUS_MESSAGE_TYPE_SIGNAL",
                    serial, uname, path, interface, member,
                    SDATA (format2 ("%s", args, Qnil)));
 
-  if (mtype == DBUS_MESSAGE_TYPE_METHOD_RETURN)
+  if ((mtype == DBUS_MESSAGE_TYPE_METHOD_RETURN)
+      || (mtype == DBUS_MESSAGE_TYPE_ERROR))
     {
       /* Search for a registered function of the message.  */
       key = list2 (bus, make_number (serial));