Print this page
Correctly merge "2991 Allow building without SMB printing support"


  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
  24  */
  25 
  26 /*
  27  * CUPS support for the SMB and SPOOLSS print services.
  28  */
  29 
  30 #ifndef HAVE_CUPS
  31 void smbd_load_printers(void) { return; }
  32 void smbd_cups_init(void) { return; }
  33 void smbd_cups_fini(void) { return; }
  34 void smbd_spool_start(void) { return; }
  35 void smbd_spool_stop(void) { return; }
  36 #else
  37 
  38 #include <sys/types.h>
  39 #include <sys/stat.h>
  40 #include <strings.h>
  41 #include <syslog.h>
  42 #include <signal.h>
  43 #include <pthread.h>
  44 #include <synch.h>
  45 #include <dlfcn.h>
  46 #include <errno.h>
  47 #include <smbsrv/smb.h>
  48 #include <smbsrv/smb_share.h>
  49 #include "smbd.h"
  50 

  51 #include <cups/cups.h>
  52 
  53 #define SMB_SPOOL_WAIT                  2
  54 #define SMBD_PJOBLEN                    256
  55 #define SMBD_PRINTER                    "Postscript"
  56 #define SMBD_FN_PREFIX                  "cifsprintjob-"
  57 #define SMBD_CUPS_SPOOL_DIR             "//var//spool//cups"
  58 #define SMBD_CUPS_DOCNAME               "generic_doc"
  59 
  60 typedef struct smbd_printjob {
  61         pid_t           pj_pid;
  62         int             pj_sysjob;
  63         int             pj_fd;
  64         time_t          pj_start_time;
  65         int             pj_status;
  66         size_t          pj_size;
  67         int             pj_page_count;
  68         boolean_t       pj_isspooled;
  69         boolean_t       pj_jobnum;
  70         char            pj_filename[SMBD_PJOBLEN];


 504                 (void) strlcpy(si->shr_cmnt, comment, SMB_SHARE_CMNT_MAX);
 505                 return;
 506         }
 507 
 508         for (i = 0; i < dest->num_options; ++i) {
 509                 name = options[i].name;
 510                 value = options[i].value;
 511 
 512                 if (name == NULL || value == NULL ||
 513                     *name == '\0' || *value == '\0')
 514                         continue;
 515 
 516                 if (strcasecmp(name, "printer-info") == 0) {
 517                         comment = value;
 518                         break;
 519                 }
 520         }
 521 
 522         (void) strlcpy(si->shr_cmnt, comment, SMB_SHARE_CMNT_MAX);
 523 }
 524 #endif













































  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
  24  */
  25 
  26 /*
  27  * CUPS support for the SMB and SPOOLSS print services.
  28  */
  29 








  30 #include <sys/types.h>
  31 #include <sys/stat.h>
  32 #include <strings.h>
  33 #include <syslog.h>
  34 #include <signal.h>
  35 #include <pthread.h>
  36 #include <synch.h>
  37 #include <dlfcn.h>
  38 #include <errno.h>
  39 #include <smbsrv/smb.h>
  40 #include <smbsrv/smb_share.h>
  41 #include "smbd.h"
  42 
  43 #ifdef  HAVE_CUPS
  44 #include <cups/cups.h>
  45 
  46 #define SMB_SPOOL_WAIT                  2
  47 #define SMBD_PJOBLEN                    256
  48 #define SMBD_PRINTER                    "Postscript"
  49 #define SMBD_FN_PREFIX                  "cifsprintjob-"
  50 #define SMBD_CUPS_SPOOL_DIR             "//var//spool//cups"
  51 #define SMBD_CUPS_DOCNAME               "generic_doc"
  52 
  53 typedef struct smbd_printjob {
  54         pid_t           pj_pid;
  55         int             pj_sysjob;
  56         int             pj_fd;
  57         time_t          pj_start_time;
  58         int             pj_status;
  59         size_t          pj_size;
  60         int             pj_page_count;
  61         boolean_t       pj_isspooled;
  62         boolean_t       pj_jobnum;
  63         char            pj_filename[SMBD_PJOBLEN];


 497                 (void) strlcpy(si->shr_cmnt, comment, SMB_SHARE_CMNT_MAX);
 498                 return;
 499         }
 500 
 501         for (i = 0; i < dest->num_options; ++i) {
 502                 name = options[i].name;
 503                 value = options[i].value;
 504 
 505                 if (name == NULL || value == NULL ||
 506                     *name == '\0' || *value == '\0')
 507                         continue;
 508 
 509                 if (strcasecmp(name, "printer-info") == 0) {
 510                         comment = value;
 511                         break;
 512                 }
 513         }
 514 
 515         (void) strlcpy(si->shr_cmnt, comment, SMB_SHARE_CMNT_MAX);
 516 }
 517 
 518 #else   /* HAVE_CUPS */
 519 
 520 /*
 521  * If not HAVE_CUPS, just provide a few "stubs".
 522  */
 523 
 524 int
 525 smbd_cups_init(void)
 526 {
 527         return (ENOENT);
 528 }
 529 
 530 void
 531 smbd_cups_fini(void)
 532 {
 533 }
 534 
 535 void
 536 smbd_load_printers(void)
 537 {
 538 }
 539 
 540 void
 541 smbd_spool_init(void)
 542 {
 543 }
 544 
 545 void
 546 smbd_spool_fini(void)
 547 {
 548 }
 549 
 550 void
 551 smbd_spool_start(void)
 552 {
 553 }
 554 
 555 void
 556 smbd_spool_stop(void)
 557 {
 558 }
 559 
 560 #endif  /* HAVE_CUPS */