]>
git.ipfire.org Git - thirdparty/cups.git/blob - systemv/lpmove.c
89ea5f3b7e6234e29756e50922bf6ff438a75bbb
2 * "$Id: lpmove.c,v 1.5.2.6 2002/08/22 01:43:40 mike Exp $"
4 * "lpmove" command for the Common UNIX Printing System (CUPS).
6 * Copyright 1997-2002 by Easy Software Products.
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636-3111 USA
20 * Voice: (301) 373-9603
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
26 * main() - Parse options and move jobs.
27 * move_job() - Move a job.
31 * Include necessary headers...
37 #include <cups/cups.h>
38 #include <cups/language.h>
39 #include <cups/debug.h>
40 #include <cups/string.h>
47 static void move_job(http_t
*, int, const char *);
51 * 'main()' - Parse options and show status information.
55 main(int argc
, /* I - Number of command-line arguments */
56 char *argv
[]) /* I - Command-line arguments */
58 int i
; /* Looping var */
59 http_t
*http
; /* Connection to server */
60 const char *job
; /* Job name */
61 int num_dests
; /* Number of destinations */
62 cups_dest_t
*dests
; /* Destinations */
63 const char *dest
; /* New destination */
72 for (i
= 1; i
< argc
; i
++)
73 if (argv
[i
][0] == '-')
76 case 'E' : /* Encrypt */
78 cupsSetEncryption(HTTP_ENCRYPT_REQUIRED
);
81 httpEncryption(http
, HTTP_ENCRYPT_REQUIRED
);
83 fprintf(stderr
, "%s: Sorry, no encryption support compiled in!\n",
85 #endif /* HAVE_LIBSSL */
88 case 'h' : /* Connect to host */
95 if (argv
[i
][2] != '\0')
96 cupsSetServer(argv
[i
] + 2);
103 fputs("Error: need hostname after \'-h\' option!\n", stderr
);
107 cupsSetServer(argv
[i
]);
112 fprintf(stderr
, "lpmove: Unknown option \'%c\'!\n", argv
[i
][1]);
115 else if (job
== NULL
)
118 num_dests
= cupsGetDests(&dests
);
120 if ((job
= strrchr(argv
[i
], '-')) != NULL
&&
121 cupsGetDest(argv
[i
], NULL
, num_dests
, dests
) == NULL
)
126 else if (dest
== NULL
)
130 fprintf(stderr
, "lpmove: Unknown argument \'%s\'!\n", argv
[i
]);
134 if (job
== NULL
|| dest
== NULL
)
136 puts("Usage: lpmove job dest");
142 http
= httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
146 perror("lpmove: Unable to connect to server");
151 move_job(http
, atoi(job
), dest
);
158 * 'move_job()' - Move a job.
162 move_job(http_t
*http
, /* I - HTTP connection to server */
163 int jobid
, /* I - Job ID */
164 const char *dest
) /* I - Destination */
166 ipp_t
*request
, /* IPP Request */
167 *response
; /* IPP Response */
168 cups_lang_t
*language
; /* Default language */
169 char job_uri
[HTTP_MAX_URI
],
171 printer_uri
[HTTP_MAX_URI
];
172 /* job-printer-uri */
179 * Build a CUPS_MOVE_JOB request, which requires the following
183 * attributes-natural-language
190 request
->request
.op
.operation_id
= CUPS_MOVE_JOB
;
191 request
->request
.op
.request_id
= 1;
193 language
= cupsLangDefault();
195 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_CHARSET
,
196 "attributes-charset", NULL
, cupsLangEncoding(language
));
198 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_LANGUAGE
,
199 "attributes-natural-language", NULL
, language
->language
);
201 snprintf(job_uri
, sizeof(job_uri
), "ipp://localhost/jobs/%d", jobid
);
202 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "job-uri", NULL
, job_uri
);
204 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_NAME
, "requesting-user-name",
207 snprintf(printer_uri
, sizeof(printer_uri
), "ipp://localhost/printers/%s", dest
);
208 ippAddString(request
, IPP_TAG_JOB
, IPP_TAG_URI
, "job-printer-uri",
212 * Do the request and get back a response...
215 if ((response
= cupsDoRequest(http
, request
, "/jobs")) != NULL
)
217 if (response
->request
.status
.status_code
> IPP_OK_CONFLICT
)
219 fprintf(stderr
, "lpmove: move-job failed: %s\n",
220 ippErrorString(response
->request
.status
.status_code
));
228 fprintf(stderr
, "lpmove: move-job failed: %s\n",
229 ippErrorString(cupsLastError()));
234 * End of "$Id: lpmove.c,v 1.5.2.6 2002/08/22 01:43:40 mike Exp $".