1 /*
2 * IEEE-1284 support functions test program for CUPS.
3 *
4 * Copyright 2007-2011 by Apple Inc.
5 * Copyright 1997-2006 by Easy Software Products, all rights reserved.
6 *
7 * These coded instructions, statements, and computer programs are the
8 * property of Apple Inc. and are protected by Federal copyright
9 * law. Distribution and use rights are outlined in the file "COPYING"
10 * which should have been included with this file.
11 *
12 * Contents:
13 *
14 * main() - Test the device-ID functions.
15 */
16
17 /*
18 * Include necessary headers.
19 */
20
21 #include <config.h>
22 #include <string.h>
23 #include <ctype.h>
24 #ifdef WIN32
25 # include <io.h>
26 #else
27 # include <unistd.h>
28 # include <fcntl.h>
29 #endif /* WIN32 */
30
31 #include "backend-private.h"
32
33
34 /*
35 * 'main()' - Test the device-ID functions.
36 */
37
38 int /* O - Exit status */
main(int argc,char * argv[])39 main(int argc, /* I - Number of command-line args */
40 char *argv[]) /* I - Command-line arguments */
41 {
42 int i, /* Looping var */
43 fd; /* File descriptor */
44 char device_id[1024], /* 1284 device ID string */
45 make_model[1024], /* make-and-model string */
46 uri[1024]; /* URI string */
47
48
49 if (argc < 2)
50 {
51 puts("Usage: test1284 device-file [... device-file-N]");
52 exit(1);
53 }
54
55 for (i = 1; i < argc; i ++)
56 {
57 if ((fd = open(argv[i], O_RDWR)) < 0)
58 {
59 perror(argv[i]);
60 return (errno);
61 }
62
63 printf("%s:\n", argv[i]);
64
65 backendGetDeviceID(fd, device_id, sizeof(device_id), make_model,
66 sizeof(make_model), "test", uri, sizeof(uri));
67
68 printf(" device_id=\"%s\"\n", device_id);
69 printf(" make_model=\"%s\"\n", make_model);
70 printf(" uri=\"%s\"\n", uri);
71
72 close(fd);
73 }
74
75 return (0);
76 }
77