print_cups complex versus plain job name

daniel.jarboe at custserv.com daniel.jarboe at custserv.com
Tue Mar 30 21:15:44 GMT 2004


> > in with the .0.1 pre or rc (forget which), I just changed our (CUPS)
> > postscript banner to cut off everything up to the first space in
> > {job-name} if that {job-name} started with "smbprn."; if you need me
> > to look up however I did this in postscript, I can.
> 
> Please do so. I would like to argue to include this to SuSE's CUPS
> package by default.

After volunteering that, I looked at how I had done it and almost wish I hadn't.  Oh well, I'm not familiar with postscriptisms, but found at least that there was a getinterval function that operated on interval length, start index, and string from the stack.  Some postscript aficionado will no doubt find a much cleaner solution.

The short version assumes that your Samba prefix is always going to be something like "smbprn." followed by 8 characters, a space, and the real job title.  If it matches this pattern then the first 16 characters are stripped.


({job-name}) length 16 gt	% "smbprn.???????? "
 {({job-name}) 0 7 getinterval (smbprn.) eq
  ({job-name}) 15 1 getinterval ( ) eq and
   { /Title ({job-name}) 16 ({job-name}) length 16 sub getinterval def }
   { /Title ({job-name}) def }
   ifelse }
 { /Title ({job-name}) def }
 ifelse


Now instead of "({job-name}) show" you should do a "Title show", which works for jobs with or without the samba prefix.

The longer version involves a loop that basically does a strnchr to find the first space after "smbprn." instead of assuming 8 chars, but I think it's overkill.

~ Daniel








-----------------------------------------------------------------------

This message is the property of Time Inc. or its affiliates. It may be
legally privileged and/or confidential and is intended only for the use
of the addressee(s). No addressee should forward, print, copy, or
otherwise reproduce this message in any manner that would allow it to be
viewed by any individual not originally listed as a recipient. If the
reader of this message is not the intended recipient, you are hereby
notified that any unauthorized disclosure, dissemination, distribution,
copying or the taking of any action in reliance on the information
herein is strictly prohibited. If you have received this communication
in error, please immediately notify the sender and delete this message.
Thank you.



More information about the samba-technical mailing list