]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Update USB backend to use new API.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 15 Oct 2012 21:11:29 +0000 (21:11 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 15 Oct 2012 21:11:29 +0000 (21:11 +0000)
Fix indentation in cupstestppd.

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10644 7a7537e8-13f0-0310-91df-b6672ffda945

backend/usb-darwin.c
systemv/cupstestppd.c

index 49d773d53296851658abfff901b4298dcc49dfaf..b312efabfefdbdb8b99bc31f8490441a3a71f262 100644 (file)
@@ -96,6 +96,7 @@
 #include <CoreFoundation/CoreFoundation.h>
 #include <IOKit/usb/IOUSBLib.h>
 #include <IOKit/IOCFPlugIn.h>
+#include <libproc.h>
 
 #include <spawn.h>
 #include <pthread.h>
@@ -134,6 +135,26 @@ extern char **environ;
 #define kUSBGenericTOPrinterClassDriver        CFSTR("/System/Library/Printers/Libraries/USBGenericPrintingClass.plugin")
 #define kUSBPrinterClassDeviceNotOpen  -9664   /*kPMInvalidIOMContext*/
 
+#define CRSetCrashLogMessage(m) _crc_make_setter(message, m)
+#define _crc_make_setter(attr, arg) (gCRAnnotations.attr = (uint64_t)(unsigned long)(arg))
+#define CRASH_REPORTER_CLIENT_HIDDEN __attribute__((visibility("hidden")))
+#define CRASHREPORTER_ANNOTATIONS_VERSION 4
+#define CRASHREPORTER_ANNOTATIONS_SECTION "__crash_info"
+
+struct crashreporter_annotations_t {
+       uint64_t version;               // unsigned long
+       uint64_t message;               // char *
+       uint64_t signature_string;      // char *
+       uint64_t backtrace;             // char *
+       uint64_t message2;              // char *
+       uint64_t thread;                // uint64_t
+       uint64_t dialog_mode;           // unsigned int
+};
+
+CRASH_REPORTER_CLIENT_HIDDEN 
+struct crashreporter_annotations_t gCRAnnotations 
+       __attribute__((section("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION))) 
+       = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0 };
 
 /*
  * Section 5.3 USB Printing Class spec
@@ -179,7 +200,7 @@ typedef struct classdriver_s                /**** g.classdriver context ****/
   UInt16               vendorID;               /* Vendor id */
   UInt16               productID;              /* Product id */
   printer_interface_t  interface;              /* identify the device to IOKit */
-  UInt8                        outpipe;                /* mandatory bulkOut pipe */
+  UInt8                        outpipe;                /* mandatory bulkOut pipe */
   UInt8                        inpipe;                 /* optional bulkIn pipe */
 
   /* general class requests */
@@ -293,6 +314,7 @@ static pid_t        child_pid;              /* Child PID */
 static void run_legacy_backend(int argc, char *argv[], int fd);        /* Starts child backend process running as a ppc executable */
 #endif /* __i386__ || __x86_64__ */
 static void sigterm_handler(int sig);  /* SIGTERM handler */
+static void sigquit_handler(int sig, siginfo_t *si, void *unused);
 
 #ifdef PARSE_PS_ERRORS
 static const char *next_line (const char *buffer);
@@ -344,10 +366,20 @@ print_device(const char *uri,             /* I - Device URI */
   struct timeval  *timeout,            /* Timeout pointer */
                  tv;                   /* Time value */
   struct timespec cond_timeout;                /* pthread condition timeout */
+  struct sigaction action;             /* Actions for POSIX signals */
 
 
   (void)uri;
 
+ /*
+  * Catch SIGQUIT to determine who is sending it...
+  */
+
+  memset(&action, 0, sizeof(action));
+  action.sa_sigaction = sigquit_handler;
+  action.sa_flags = SA_SIGINFO;
+  sigaction(SIGQUIT, &action, NULL);
+
  /*
   * See if the side-channel descriptor is valid...
   */
@@ -472,9 +504,6 @@ print_device(const char *uri,               /* I - Device URI */
 
   if (!print_fd)
   {
-    struct sigaction   action;         /* POSIX signal action */
-
-
     memset(&action, 0, sizeof(action));
 
     sigemptyset(&action.sa_mask);
@@ -2094,6 +2123,28 @@ sigterm_handler(int sig)         /* I - Signal */
 }
 
 
+/*
+ * 'sigquit_handler()' - SIGQUIT handler.
+ */
+
+static void sigquit_handler(int sig, siginfo_t *si, void *unused)
+{
+  char  *path;
+  char pathbuf[PROC_PIDPATHINFO_MAXSIZE];
+  static char msgbuf[256] = "";
+
+  if (proc_pidpath(si->si_pid, pathbuf, sizeof(pathbuf)) > 0 && 
+      (path = basename(pathbuf)) != NULL)
+    snprintf(msgbuf, sizeof(msgbuf), "SIGQUIT sent by %s(%d)", path, (int)si->si_pid);
+  else
+    snprintf(msgbuf, sizeof(msgbuf), "SIGQUIT sent by PID %d", (int)si->si_pid);
+
+  CRSetCrashLogMessage(msgbuf);
+
+  abort();
+}
+
+
 #ifdef PARSE_PS_ERRORS
 /*
  * 'next_line()' - Find the next line in a buffer.
index 4ae53d49012e66a7a296c5f53a5bfe7d593b5c4a..02b47a02176be9f115e09e608e61caad4c43cd1c 100644 (file)
@@ -3217,7 +3217,8 @@ check_sizes(ppd_file_t *ppd,              /* I - PPD file */
                           _PWG_FROMPTS(size->width);
       pwg_media      = _pwgMediaForSize(width_2540ths, length_2540ths);
 
-      if (pwg_media && pwg_media->ppd && (pwg_media->ppd[0] < 'a' || pwg_media->ppd[0] > 'z'))
+      if (pwg_media && pwg_media->ppd &&
+          (pwg_media->ppd[0] < 'a' || pwg_media->ppd[0] > 'z'))
       {
         size_t ppdlen = strlen(pwg_media->ppd);
                                        /* Length of standard PPD name */
@@ -3279,8 +3280,8 @@ check_sizes(ppd_file_t *ppd,              /* I - PPD file */
          * Check for EnvSizeName as well...
          */
 
-      if (strncmp(pwg_media->ppd, "Env", 3) &&
-          !strncmp(size->name, "Env", 3))
+         if (strncmp(pwg_media->ppd, "Env", 3) &&
+             !strncmp(size->name, "Env", 3))
             snprintf(buf, sizeof(buf), "Env%s", pwg_media->ppd);
 
          if (strcmp(size->name, buf))