Lines 98-105
Link Here
|
98 |
ipp_attribute_t *attr; |
98 |
ipp_attribute_t *attr; |
99 |
int bytes; /* Bytes copied */ |
99 |
int bytes; /* Bytes copied */ |
100 |
char uri[HTTP_MAX_URI]; |
100 |
char uri[HTTP_MAX_URI]; |
101 |
char *argv_nt[7]; |
101 |
char *argv_nt[8]; |
102 |
int outbuflen,filefd,exit_status,dup_status; |
102 |
int outbuflen, filefd, savestdout, exit_status, dup_status; |
|
|
103 |
char buf[1024]; |
104 |
const char *serverbin; |
103 |
static const char *pattrs[] = |
105 |
static const char *pattrs[] = |
104 |
{ |
106 |
{ |
105 |
"printer-defaults" |
107 |
"printer-defaults" |
Lines 241-247
Link Here
|
241 |
cups_option_t *options = NULL; |
243 |
cups_option_t *options = NULL; |
242 |
int fd; |
244 |
int fd; |
243 |
char buffer[8192]; |
245 |
char buffer[8192]; |
244 |
|
246 |
|
245 |
fprintf(stderr, "DEBUG: Received destination host name from cups-browsed: printer-uri %s\n", |
247 |
fprintf(stderr, "DEBUG: Received destination host name from cups-browsed: printer-uri %s\n", |
246 |
ptr1); |
248 |
ptr1); |
247 |
|
249 |
|
Lines 249-256
Link Here
|
249 |
job */ |
251 |
job */ |
250 |
cupsSetUser(argv[2]); |
252 |
cupsSetUser(argv[2]); |
251 |
title = argv[3]; |
253 |
title = argv[3]; |
252 |
if (title == NULL) |
254 |
if (title == NULL) { |
253 |
{ |
|
|
254 |
if (argc == 7) { |
255 |
if (argc == 7) { |
255 |
if ((title = strrchr(argv[6], '/')) != NULL) |
256 |
if ((title = strrchr(argv[6], '/')) != NULL) |
256 |
title ++; |
257 |
title ++; |
Lines 299-314
Link Here
|
299 |
bytes = write(fd, buffer, bytes); |
300 |
bytes = write(fd, buffer, bytes); |
300 |
close(fd); |
301 |
close(fd); |
301 |
filename = tempfile; |
302 |
filename = tempfile; |
302 |
} else{ |
303 |
} else { |
303 |
/** Use the filename on the command-line...*/ |
304 |
/* Use the filename on the command-line... */ |
304 |
filename = argv[6]; |
305 |
filename = argv[6]; |
305 |
tempfile[0] = '\0'; |
306 |
tempfile[0] = '\0'; |
306 |
} |
307 |
} |
307 |
|
308 |
|
308 |
/* Copying the argument to a new char** which will be sent to the filter |
309 |
/* Copying the argument to a new char** which will be sent to the filter |
309 |
and the ipp backend*/ |
310 |
and the ipp backend */ |
310 |
argv_nt[0] = calloc(strlen(printer_uri) + 8, sizeof(char)); |
311 |
argv_nt[0] = calloc(strlen(printer_uri) + 8, sizeof(char)); |
311 |
strcpy(argv_nt[0], printer_uri); |
312 |
strcpy(argv_nt[0], printer_uri); |
312 |
for (i = 1; i < 5; i++) |
313 |
for (i = 1; i < 5; i++) |
313 |
argv_nt[i] = argv[i]; |
314 |
argv_nt[i] = argv[i]; |
314 |
|
315 |
|
Lines 319-324
Link Here
|
319 |
|
320 |
|
320 |
/* Filter pdftoippprinter.c will read the input from this file*/ |
321 |
/* Filter pdftoippprinter.c will read the input from this file*/ |
321 |
argv_nt[6] = filename; |
322 |
argv_nt[6] = filename; |
|
|
323 |
argv_nt[7] = NULL; |
322 |
set_option_in_str(argv_nt[5], outbuflen, "output-format", |
324 |
set_option_in_str(argv_nt[5], outbuflen, "output-format", |
323 |
document_format); |
325 |
document_format); |
324 |
set_option_in_str(argv_nt[5], outbuflen, "Resolution",resolution); |
326 |
set_option_in_str(argv_nt[5], outbuflen, "Resolution",resolution); |
Lines 335-351
Link Here
|
335 |
to the backend, but having this temperory file will help us |
337 |
to the backend, but having this temperory file will help us |
336 |
find whether the filter worked correctly and what was the |
338 |
find whether the filter worked correctly and what was the |
337 |
document-format of the filtered output.*/ |
339 |
document-format of the filtered output.*/ |
338 |
close(1); |
340 |
savestdout = dup(1); |
339 |
dup_status = dup(filefd); |
341 |
dup_status = dup2(filefd, 1); |
340 |
if(dup_status < 0) { |
342 |
if(dup_status < 0) { |
341 |
fprintf(stderr, "Could not write the output of pdftoippprinter printer to tmp file\n"); |
343 |
fprintf(stderr, "Could not write the output of pdftoippprinter printer to tmp file\n"); |
342 |
return CUPS_BACKEND_FAILED; |
344 |
return CUPS_BACKEND_FAILED; |
343 |
} |
345 |
} |
|
|
346 |
close(filefd); |
344 |
|
347 |
|
345 |
/* Calling pdftoippprinter.c filter*/ |
348 |
/* Calling pdftoippprinter.c filter*/ |
346 |
apply_filters(7,argv_nt); |
349 |
apply_filters(7,argv_nt); |
347 |
|
350 |
|
348 |
close(filefd); |
351 |
/* Reset stdout to standard */ |
|
|
352 |
dup2(savestdout, 1); |
353 |
close(savestdout); |
349 |
|
354 |
|
350 |
/* We will send the filtered output of the pdftoippprinter.c to |
355 |
/* We will send the filtered output of the pdftoippprinter.c to |
351 |
the IPP Backend*/ |
356 |
the IPP Backend*/ |
Lines 372-389
Link Here
|
372 |
|
377 |
|
373 |
ippDelete(response); |
378 |
ippDelete(response); |
374 |
fprintf(stderr, "Passing the following arguments to the ipp backend\n"); |
379 |
fprintf(stderr, "Passing the following arguments to the ipp backend\n"); |
375 |
/*Arguments sent to the ipp backend*/ |
380 |
/* Arguments sent to the ipp backend */ |
376 |
for( i = 0; i < 7; i++){ |
381 |
for (i = 0; i < 7; i ++) { |
377 |
fprintf(stderr, "argv[%d]: %s\n",i,argv_nt[i]); |
382 |
fprintf(stderr, "argv[%d]: %s\n", i, argv_nt[i]); |
378 |
} |
383 |
} |
379 |
|
384 |
|
380 |
/* The implicitclass backend will send the job directly to the |
385 |
/* The implicitclass backend will send the job directly to the |
381 |
ipp backend*/ |
386 |
ipp backend*/ |
382 |
|
387 |
|
383 |
pid_t pid = fork(); |
388 |
pid_t pid = fork(); |
384 |
if ( pid == 0 ) { |
389 |
if (pid == 0) { |
385 |
fprintf(stderr, "DEBUG: Started IPP Backend with pid: %d\n",getpid()); |
390 |
serverbin = getenv("CUPS_SERVERBIN"); |
386 |
execv("/usr/lib/cups/backend/ipp",argv_nt); |
391 |
if (serverbin == NULL) |
|
|
392 |
serverbin = CUPS_SERVERBIN; |
393 |
snprintf(buf, sizeof(buf) - 1, "%s/backend/ipp", serverbin); |
394 |
fprintf(stderr, "DEBUG: Started IPP Backend (%s) with pid: %d\n", |
395 |
buf, getpid()); |
396 |
execv(buf, argv_nt); |
397 |
fprintf(stderr, "ERROR: Could not start IPP Backend (%s): %d %s\n", |
398 |
buf, errno, strerror(errno)); |
399 |
return CUPS_BACKEND_FAILED; |
387 |
} else { |
400 |
} else { |
388 |
int status; |
401 |
int status; |
389 |
waitpid(pid, &status, 0); |
402 |
waitpid(pid, &status, 0); |