]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/testsub.c
Fix a scheduler crash bug (rdar://42198057)
[thirdparty/cups.git] / scheduler / testsub.c
index 92f6788559385cf9c7db74d78ffa392114263ce5..19d9dffce9aba804d810e9846f0ab558701a0992 100644 (file)
@@ -1,23 +1,10 @@
 /*
- * "$Id: testsub.c 6649 2007-07-11 21:46:42Z mike $"
+ * Scheduler notification tester for CUPS.
  *
- *   Scheduler notification tester for CUPS.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2006-2007 by Easy Software Products.
  *
- *   Copyright 2007-2010 by Apple Inc.
- *   Copyright 2006-2007 by Easy Software Products.
- *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. and are protected by Federal copyright
- *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- *   which should have been included with this file.  If this file is
- *   file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- *   main()             - Subscribe to the .
- *   print_attributes() - Print the attributes in a request...
- *   sigterm_handler()  - Flag when the user hits CTRL-C...
- *   usage()            - Show program usage...
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
  */
 
 /*
@@ -28,6 +15,7 @@
 #include <cups/debug-private.h>
 #include <cups/string-private.h>
 #include <signal.h>
+#include <cups/ipp-private.h>  /* TODO: Update so we don't need this */
 
 
 /*
@@ -43,7 +31,7 @@ static int    terminate = 0;
 
 static void    print_attributes(ipp_t *ipp, int indent);
 static void    sigterm_handler(int sig);
-static void    usage(void);
+static void    usage(void) _CUPS_NORETURN;
 
 
 /*
@@ -250,7 +238,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
       interval = 5;
 
     ippDelete(response);
-    sleep(interval);
+    sleep((unsigned)interval);
   }
 
  /*
@@ -302,7 +290,7 @@ print_attributes(ipp_t *ipp,                /* I - IPP request */
   int                  i;              /* Looping var */
   ipp_tag_t            group;          /* Current group */
   ipp_attribute_t      *attr;          /* Current attribute */
-  ipp_value_t          *val;           /* Current value */
+  _ipp_value_t         *val;           /* Current value */
   static const char * const tags[] =   /* Value/group tag strings */
                        {
                          "reserved-00",
@@ -434,17 +422,10 @@ print_attributes(ipp_t *ipp,              /* I - IPP request */
 
       case IPP_TAG_DATE :
           {
-           time_t      vtime;          /* Date/Time value */
-           struct tm   *vdate;         /* Date info */
            char        vstring[256];   /* Formatted time */
 
            for (i = 0, val = attr->values; i < attr->num_values; i ++, val ++)
-           {
-             vtime = ippDateToTime(val->date);
-             vdate = localtime(&vtime);
-             strftime(vstring, sizeof(vstring), "%c", vdate);
-             printf(" (%s)", vstring);
-           }
+             printf(" (%s)", _cupsStrDate(vstring, sizeof(vstring), ippDateToTime(val->date)));
           }
           putchar('\n');
           break;
@@ -452,7 +433,7 @@ print_attributes(ipp_t *ipp,                /* I - IPP request */
       case IPP_TAG_RESOLUTION :
           for (i = 0, val = attr->values; i < attr->num_values; i ++, val ++)
            printf(" %dx%d%s", val->resolution.xres, val->resolution.yres,
-                  val->resolution.units == IPP_RES_PER_INCH ? "dpi" : "dpc");
+                  val->resolution.units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
           putchar('\n');
           break;
 
@@ -514,9 +495,3 @@ usage(void)
   puts("Usage: testsub [-E] [-e event ... -e eventN] [-h hostname] URI");
   exit(0);
 }
-
-
-
-/*
- * End of "$Id: testsub.c 6649 2007-07-11 21:46:42Z mike $".
- */