Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 702592 | Differences between
and this patch

Collapse All | Expand All

(-)cups-filters-1.25.13/backend/implicitclass.c.orig (-19 / +31 lines)
Lines 99-105 Link Here
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[7];
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 335-351 Link Here
335
         to the backend, but having this temperory file will help us
336
         to the backend, but having this temperory file will help us
336
         find whether the filter worked correctly and what was the
337
         find whether the filter worked correctly and what was the
337
         document-format of the filtered output.*/
338
         document-format of the filtered output.*/
338
      close(1);
339
      savestdout = dup(1);
339
      dup_status = dup(filefd);
340
      dup_status = dup2(filefd, 1);
340
      if(dup_status < 0) {
341
      if(dup_status < 0) {
341
        fprintf(stderr, "Could not write the output of pdftoippprinter printer to tmp file\n");
342
        fprintf(stderr, "Could not write the output of pdftoippprinter printer to tmp file\n");
342
        return CUPS_BACKEND_FAILED;
343
        return CUPS_BACKEND_FAILED;
343
      }
344
      }
345
      close(filefd);
344
346
345
      /* Calling pdftoippprinter.c filter*/
347
      /* Calling pdftoippprinter.c filter*/
346
      apply_filters(7,argv_nt);
348
      apply_filters(7,argv_nt);
347
349
348
      close(filefd);
350
      /* Reset stdout to standard */
351
      dup2(savestdout, 1);
352
      close(savestdout);
349
353
350
      /* We will send the filtered output of the pdftoippprinter.c to
354
      /* We will send the filtered output of the pdftoippprinter.c to
351
	 the IPP Backend*/
355
	 the IPP Backend*/
Lines 372-389 Link Here
372
376
373
      ippDelete(response);
377
      ippDelete(response);
374
      fprintf(stderr, "Passing the following arguments to the ipp backend\n");
378
      fprintf(stderr, "Passing the following arguments to the ipp backend\n");
375
       /*Arguments sent to the ipp backend*/
379
      /* Arguments sent to the ipp backend */
376
      for( i = 0; i < 7; i++){
380
      for (i = 0; i < 7; i ++) {
377
         fprintf(stderr, "argv[%d]: %s\n",i,argv_nt[i]);
381
	fprintf(stderr, "argv[%d]: %s\n", i, argv_nt[i]);
378
       }
382
      }
379
383
380
      /* The implicitclass backend will send the job directly to the
384
      /* The implicitclass backend will send the job directly to the
381
	 ipp backend*/
385
	 ipp backend*/
382
386
383
      pid_t pid = fork();
387
      pid_t pid = fork();
384
      if ( pid == 0 ) {
388
      if (pid == 0) {
385
	fprintf(stderr, "DEBUG: Started IPP Backend with pid: %d\n",getpid());
389
	serverbin = getenv("CUPS_SERVERBIN");
386
	execv("/usr/lib/cups/backend/ipp",argv_nt);
390
	if (serverbin == NULL)
391
	  serverbin = CUPS_SERVERBIN;
392
	snprintf(buf, sizeof(buf) - 1, "%s/backend/ipp", serverbin);
393
	fprintf(stderr, "DEBUG: Started IPP Backend (%s) with pid: %d\n",
394
		buf, getpid());
395
	execv(buf, argv_nt);
396
	fprintf(stderr, "ERROR: Could not start IPP Backend (%s): %d %s\n",
397
		buf, errno, strerror(errno));
398
	return CUPS_BACKEND_FAILED;
387
      } else {
399
      } else {
388
	int status;
400
	int status;
389
	waitpid(pid, &status, 0);
401
	waitpid(pid, &status, 0);

Return to bug 702592