[cups.development] notifiers and subscriptions
Jerome Alet
alet at librelogiciel.com
Wed Jun 21 14:58:32 PDT 2006
On Wed, Jun 21, 2006 at 04:36:31PM -0400, Michael Sweet wrote:
> >
> >Any solution, besides rewriting parts of my own parser to have it
> >read and parse at the same time ?
>
> Have your parser stop when it sees the IPP end tag...
Of course, but detecting this tag is not possible without parsing
the datas, and this is why I encounter the problem I exposed
earlier.
My parser can parse a block of binary datas representing an IPP
request, but it can't currently read a file and parse it at the same
time : first it reads the entirety of the file's contents (or
stdin), and then it parses the entire block (simply because that's
the way I wrote it) until the IPP end tag (of course).
But ippReadFile() does it the other way around : it can read and
parse a file at the same time, but can't parse a block of binary
datas (because that's the way you wrote it).
I encounter the problem I mentioned with my parser, but this
is just an artifact. You would encounter the same problem
even without my parser being called : just write a notifier
which does this (it's Python code, but you can
achieve the same result with any language) :
--- CUT ---
#! /usr/bin/env python
import sys
sys.stderr.write("DEBUG: this line will be output\n")
ippdatas = sys.stdin.read()
sys.stderr.write("DEBUG: this line won't be output\n")
--- CUT ---
And you'll see what I mean : the read() never returns, probably
because the input stream is not closed by CUPS.
Beside not using the CUPS' standard API, am I doing something wrong ?
Should I read the input in non-blocking mode, and if yes how can
I be sure I've got all the datas without parsing them first ?
NB : I use the standard CUPS v1.2.1-2 package from Debian.
bye
Jerome Alet
More information about the cups
mailing list