#!/usr/bin/ruby
#
# goprint-backend
# GoPrint backend invoker for CUPS 1.2+ integration.
#
# Copyright (c) 2007-2008 GoPrint Systems, Inc.  All rights reserved.
#

# Find the real location
begin
  realLocation = File.readlink($0)
  realLocation.reverse!
  fileIndex = realLocation.index("/")
  realLocation = realLocation[fileIndex+1..realLocation.length]
  fileIndex = realLocation.index("/")
  realLocation = realLocation[fileIndex..realLocation.length]
  realLocation.reverse!
  GS4Home = realLocation
rescue => e
  # if the file is not a symlink the call to readlink will throw invalid arg exception 
  GS4Home = '/usr/local/gs4/'
end

# Require the backend
require GS4Home + "lib/gpcupsbackend"

# Create the backend
backend = GoPrintCUPSBackend.new(Configuration)
# Run the backend
backend.runBackend(STDIN, ARGV)
