summaryrefslogtreecommitdiff
path: root/cups/testgetdests.c
blob: 459998f92020d2cd2d94911fc1dce57a4dcfac33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * CUPS cupsGetDests API test program for CUPS.
 *
 * Copyright 2017 by Apple Inc.
 *
 * 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
 * missing or damaged, see the license at "http://www.cups.org/".
 *
 * This file is subject to the Apple OS-Developed Software exception.
 */

/*
 * Include necessary headers...
 */

#include <stdio.h>
#include "cups.h"
#include <sys/time.h>


/*
 * 'main()' - Loop calling cupsGetDests.
 */

int                                     /* O - Exit status */
main(void)
{
  int           num_dests;              /* Number of destinations */
  cups_dest_t   *dests;                 /* Destinations */
  struct timeval start, end;            /* Start and stop time */
  double        secs;                   /* Total seconds to run cupsGetDests */


  for (;;)
  {
    gettimeofday(&start, NULL);
    num_dests = cupsGetDests(&dests);
    gettimeofday(&end, NULL);
    secs = end.tv_sec - start.tv_sec + 0.000001 * (end.tv_usec - start.tv_usec);

    printf("Found %d printers in %.3f seconds...\n", num_dests, secs);

    cupsFreeDests(num_dests, dests);
    sleep(1);
  }

  return (0);
}