Subject: multiple printer in papd.conf?

From: "Douglas Harvey" <[email-masked]>
Date: Sat, 16 Sep 1995 19:17:05 -0500 (CDT)

Is it possible to have more than one printer defined in papd.conf?
I set up three printers in mine, but only the last one shows up in
the Mac's chooser.

Thanks in advance for any help,

Doug Harvey
--
[email-masked]

---

From: [email-masked]
Date: Mon, 02 Oct 1995 16:23:27 -0400

> From:    "Douglas Harvey" <[email-masked]>
> To:      [email-masked]

> Is it possible to have more than one printer defined in papd.conf?

This is a (known) bug in the 1.3.3b2 version of papd.  Please find a
fix attached.

:wes
*** etc/papd/main.c-	1995/06/05 19:28:22
--- etc/papd/main.c	1995/08/23 21:14:33
***************
*** 49,59 ****
  
      for ( pr = printers; pr; pr = pr->p_next ) {
  	if ( pr->p_flags & P_REGISTERED ) {
! 	    if ( nbp_unrgstr( pr->p_name, "LaserWriter", "*" ) < 0 ) {
! 		syslog( LOG_ERR, "can't unregister %s\n", pr->p_name );
  		exit( n + 1 );
  	    }
! 	    syslog( LOG_ERR, "unregister %s:LaserWriter\n", pr->p_name );
  	}
      }
      exit( n );
--- 49,61 ----
  
      for ( pr = printers; pr; pr = pr->p_next ) {
  	if ( pr->p_flags & P_REGISTERED ) {
! 	    if ( nbp_unrgstr( pr->p_name, pr->p_type, pr->p_zone ) < 0 ) {
! 		syslog( LOG_ERR, "can't unregister %s:%s@%s\n", pr->p_name,
! 			pr->p_type, pr->p_zone );
  		exit( n + 1 );
  	    }
! 	    syslog( LOG_ERR, "unregister %s:%s@%s\n", pr->p_name, pr->p_type,
! 		    pr->p_zone );
  	}
      }
      exit( n );
***************
*** 119,124 ****
--- 121,128 ----
  	exit( 1 );
      }
      strcpy( defprinter.p_name, hostname );
+     defprinter.p_type = "LaserWriter";
+     defprinter.p_zone = "*";
      defprinter.p_ppdfile = _PATH_PAPDPPDFILE;
      defprinter.p_flags = P_SPOOLED;
      defprinter.p_printer = "lp";
***************
*** 209,220 ****
  	    syslog( LOG_ERR, "atp_open: %m" );
  	    exit( 1 );
  	}
! 	if ( nbp_rgstr( atp_sockaddr( pr->p_atp ),
! 		pr->p_name, "LaserWriter", "*" ) < 0 ) {
! 	    syslog( LOG_ERR, "can't register %s", pr->p_name );
  	    die( 1 );
  	}
! 	syslog( LOG_INFO, "register %s:LaserWriter", pr->p_name );
  	pr->p_flags |= P_REGISTERED;
      }
  
--- 213,226 ----
  	    syslog( LOG_ERR, "atp_open: %m" );
  	    exit( 1 );
  	}
! 	if ( nbp_rgstr( atp_sockaddr( pr->p_atp ), pr->p_name, pr->p_type,
! 		pr->p_zone ) < 0 ) {
! 	    syslog( LOG_ERR, "can't register %s:%s@%s", pr->p_name, pr->p_type,
! 		    pr->p_zone );
  	    die( 1 );
  	}
! 	syslog( LOG_INFO, "register %s:%s@%s", pr->p_name, pr->p_type,
! 		pr->p_zone );
  	pr->p_flags |= P_REGISTERED;
      }
  
***************
*** 434,440 ****
  getprinters( cf )
      char	*cf;
  {
!     char		buf[ 1024 ], area[ 1024 ], *a, *p;
      struct printer	*pr;
      int			c;
  
--- 440,446 ----
  getprinters( cf )
      char	*cf;
  {
!     char		buf[ 1024 ], area[ 1024 ], *a, *p, *name, *type, *zone;
      struct printer	*pr;
      int			c;
  
***************
*** 454,464 ****
  	    exit( 1 );
  	}
  	bzero( pr, sizeof( struct printer ));
! 	if (( pr->p_name = (char *)malloc( strlen( p ) + 1 )) == NULL ) {
! 	    perror( "malloc" );
  	    exit( 1 );
  	}
! 	strcpy( pr->p_name, p );
  
  	if ( pnchktc( cf ) != 1 ) {
  	    fprintf( stderr, "Bad papcap entry\n" );
--- 460,500 ----
  	    exit( 1 );
  	}
  	bzero( pr, sizeof( struct printer ));
! 
! 	name = defprinter.p_name;
! 	type = defprinter.p_type;
! 	zone = defprinter.p_zone;
! 	if ( nbp_name( p, &name, &type, &zone )) {
! 	    fprintf( stderr, "Can't parse \"%s\"\n", name );
  	    exit( 1 );
  	}
! 	if ( name != defprinter.p_name ) {
! 	    if (( pr->p_name = (char *)malloc( strlen( name ) + 1 )) == NULL ) {
! 		perror( "malloc" );
! 		exit( 1 );
! 	    }
! 	    strcpy( pr->p_name, name );
! 	} else {
! 	    pr->p_name = name;
! 	}
! 	if ( type != defprinter.p_type ) {
! 	    if (( pr->p_type = (char *)malloc( strlen( type ) + 1 )) == NULL ) {
! 		perror( "malloc" );
! 		exit( 1 );
! 	    }
! 	    strcpy( pr->p_type, type );
! 	} else {
! 	    pr->p_type = type;
! 	}
! 	if ( zone != defprinter.p_zone ) {
! 	    if (( pr->p_zone = (char *)malloc( strlen( zone ) + 1 )) == NULL ) {
! 		perror( "malloc" );
! 		exit( 1 );
! 	    }
! 	    strcpy( pr->p_zone, zone );
! 	} else {
! 	    pr->p_zone = zone;
! 	}
  
  	if ( pnchktc( cf ) != 1 ) {
  	    fprintf( stderr, "Bad papcap entry\n" );

---

From: "Jin S. Choi" <[email-masked]>
Date: Mon, 2 Oct 1995 16:58:26 -0400

Applying that papd patch gives several errors of the type:

main.c: In function `die':
main.c:52: structure has no member named `p_type'
main.c:52: structure has no member named `p_zone'
main.c:54: structure has no member named `p_type'
main.c:54: structure has no member named `p_zone'
main.c:57: structure has no member named `p_type'
main.c:58: structure has no member named `p_zone'

---

From: [email-masked]
Date: Mon, 02 Oct 1995 17:11:49 -0400

> From:    "Jin S. Choi" <[email-masked]>
> To:      [email-masked]

> main.c:52: structure has no member named `p_zone'

I should have included a patch to printer.h as well...

:wes
*** etc/papd/printer.h-	1995/03/13 19:25:26
--- etc/papd/printer.h	1995/06/30 15:00:01
***************
*** 5,10 ****
--- 5,12 ----
  
  struct printer {
      char		*p_name;
+     char		*p_type;
+     char		*p_zone;
  #ifdef notdef
      char		*p_fonts;
      char		*p_psetdir;