]> git.ipfire.org Git - thirdparty/cups.git/blob - backend/test1284.c
2d58450eae23c21f49a333ced7aeb62b6149e45f
[thirdparty/cups.git] / backend / test1284.c
1 /*
2 * IEEE-1284 support functions test program for CUPS.
3 *
4 * Copyright © 2020-2024 by OpenPrinting.
5 * Copyright © 2007-2010 by Apple Inc.
6 * Copyright © 1997-2006 by Easy Software Products, all rights reserved.
7 *
8 * Licensed under Apache License v2.0. See the file "LICENSE" for more
9 * information.
10 */
11
12 /*
13 * Include necessary headers.
14 */
15
16 #include <cups/string-private.h>
17 #ifdef _WIN32
18 # include <io.h>
19 #else
20 # include <unistd.h>
21 # include <fcntl.h>
22 #endif /* _WIN32 */
23
24 #include "ieee1284.c"
25
26
27 /*
28 * 'main()' - Test the device-ID functions.
29 */
30
31 int /* O - Exit status */
32 main(int argc, /* I - Number of command-line args */
33 char *argv[]) /* I - Command-line arguments */
34 {
35 int i, /* Looping var */
36 fd; /* File descriptor */
37 char device_id[1024], /* 1284 device ID string */
38 make_model[1024], /* make-and-model string */
39 uri[1024]; /* URI string */
40
41
42 if (argc < 2)
43 {
44 puts("Usage: test1284 device-file [... device-file-N]");
45 exit(1);
46 }
47
48 for (i = 1; i < argc; i ++)
49 {
50 if ((fd = open(argv[i], O_RDWR)) < 0)
51 {
52 perror(argv[i]);
53 return (errno);
54 }
55
56 printf("%s:\n", argv[i]);
57
58 backendGetDeviceID(fd, device_id, sizeof(device_id), make_model,
59 sizeof(make_model), "test", uri, sizeof(uri));
60
61 printf(" device_id=\"%s\"\n", device_id);
62 printf(" make_model=\"%s\"\n", make_model);
63 printf(" uri=\"%s\"\n", uri);
64
65 close(fd);
66 }
67
68 return (0);
69 }