function OpenBSD_printing
{
LOOP=0 # Loop Counter - To grab three lines at a time

lpc status all | egrep ':|printing|queuing' | while read LINE
do
    # Load three unique lines at a time
    case $LINE in
    *:) Q=$(echo $LINE | cut -d ':' -f1)
        ;;
    printing*)
        PSTATUS=$(echo $LINE | awk '{print $3}')
        ;;
    queuing*)
        QSTATUS=$(echo $LINE | awk '{print $3}')
        ;;
    esac

    # Increment the LOOP counter
    (( LOOP = LOOP + 1 ))
    if ((LOOP == 3)) # Do we have all three lines of data?
    then
        # Check queuing status
        case $QSTATUS in
        disabled) lpc enable $Q >/dev/null
                  (($? == 0)) && echo "\n$Q queueing re-enabled\n"
                  sleep 1
                  ;;
        enabled|*) : # No-Op - Do Nothing
                  ;;
        esac

        # Check printing status
        case $PSTATUS in
        disabled) lpc up $Q >/dev/null
                  (($? == 0)) && echo "\n$Q printing re-started\n"
                  ;;
        enabled|*) : # No-Op - Do Nothing
                  ;;
        esac
        LOOP=0 # Reset the loop counter to zero
    fi
done
}

