provides samba_lpd version 3.0.34

if (defined(OPT_DNSDHCP))
  then
    depends on fli4l version 3.0.[0-3]
  else
    depends on fli4l version 3.0.[0-1]
  fi

if (opt_sambatools)
then
    stat("opt/files/bin/stty", stty)
    if(stty_res == "OK")
    then
        add_to_opt "files/bin/stty" "mode=555"
    else
        error "SAMBA_LPD: missing binary stty from package SERIAL. Please download package SERIAL from www.fli4l.de and extract it. Activation of SERIAL isn't necessary."
    fi
fi

if (opt_lpd_parport)
then
    stat("opt/files/lib/modules/${KERNEL_VERSION}/kernel/drivers/parport/parport.ko", parport)
    stat("opt/files/lib/modules/${KERNEL_VERSION}/kernel/drivers/parport/parport_pc.ko", parport_pc)
    stat("opt/files/lib/modules/${KERNEL_VERSION}/kernel/drivers/char/lp.ko", lp)

    if(parport_res == "OK")
    then
        add_to_opt "files/lib/modules/${KERNEL_VERSION}/kernel/drivers/parport/parport.ko"
    else
        error "SAMBA_LPD: missing module parport.o from package LPDSRV. Please download package LPDSRV from www.fli4l.de and extract it. Activation of LPDSRV isn't necessary."
    fi

    if(parport_pc_res == "OK")
    then
        add_to_opt "files/lib/modules/${KERNEL_VERSION}/kernel/drivers/parport/parport_pc.ko"
    else
        error "SAMBA_LPD: missing module parport_pc.o from package LPDSRV. Please download package LPDSRV from www.fli4l.de and extract it. Activation of LPDSRV isn't necessary."
    fi

    if(lp_res == "OK")
    then
        add_to_opt "files/lib/modules/${KERNEL_VERSION}/kernel/drivers/char/lp.ko"
    else
        error "SAMBA_LPD: missing module lp.o from package LPDSRV. Please download package LPDSRV from www.fli4l.de and extract it. Activation of LPDSRV isn't necessary."
    fi
fi

if (opt_lpd && opt_lcd)
then
    # is lcd_address a port address ? 
    if (lcd_address =~ "0x[[:xdigit:]]+")
    then
        # convert lcd_address to numerical value
        split (lcd_address, tmp_addr_%, ' ', numeric)
        foreach i in lpd_parport_%_io
        do
          if (i == tmp_addr_%[1])
          then
              error "SAMBA_LPD: You cannot use the same address %i='$i' for lpd and lcd!"
          fi
        done
    fi
fi

if (nmbd_winsserver && nmbd_extwinsip != "")
then
    error "SAMBA_LPD: You cannot use samba as wins server and wins client at the same time!"
fi

if (opt_nmbd && !opt_samba)
then
    error "SAMBA_LPD: You cannot use OPT_NMBD without OPT_SAMBA!"
fi

if (opt_lpdsrv && opt_lpd)
then
    error "SAMBA_LPD: You cannot use OPT_LPD='yes' and OPT_LPDSRV='yes' together!"
fi

if (opt_usblpdsrv && opt_lpd)
then
    error "SAMBA_LPD: You cannot use OPT_LPD='yes' and OPT_USBLPDSRV='yes' together!"
fi

if (opt_lpd_usbport)
then
    set usbprinter = "no"

    foreach i in usb_extra_driver_n
    do
      if (usb_extra_driver_%[i] == "printer")
      then
          set usbprinter = "yes"
      fi
    done

    if (usbprinter == "no")
    then
        error "SAMBA_LPD: OPT_USB and USB_EXTRA_DRIVER_x='printer' is required for OPT_LPD and usb printers!"
    fi
fi

if (opt_lpd_parport)
then
    foreach i in lpd_parport_n
    do
      if (lpd_parport_%_irq[i] == "yes")
      then
          set irqset = "yes"
      else
          set irqset = "no"
      fi

      if (lpd_parport_%_dma[i] == "yes")
      then
          set dmaset = "yes"
      else
          set dmaset = "no"
      fi

      if (dmaset == "yes") && (irqset == "no")
      then
          error "SAMBA_LPD: You cannot use dma without irq! Set LPD_PARPORT_${i}_IRQ to 'yes' or LPD_PARPORT_${i}_DMA to 'no'!"
      fi
    done
fi

if (opt_lpd_remote)
then
    foreach i in lpd_remote_n
    do
      if (lpd_remote_%_port[i] != "")
      then
          set remoteport = "yes"
      else
          set remoteport = "no"
      fi

      if (lpd_remote_%_queuename[i] != "")
      then
          set remotequeuename = "yes"
      else
          set remotequeuename = "no"
      fi

      if (remoteport == "yes") && (remotequeuename == "yes")
      then
          error "SAMBA_LPD: You cannot use port and queuename at the same time! Set LPD_REMOTE_${i}_PORT to '' or LPD_REMOTE_${i}_QUEUENAME to ''!"
      fi

      if (remoteport == "no") && (remotequeuename == "no")
      then
          error "SAMBA_LPD: One of LPD_REMOTE_${i}_PORT and LPD_REMOTE_${i}_QUEUENAME must be filled, read documentation!"
      fi
    done
fi
