Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Tim Watts Newsgroups: comp.os.linux.misc Subject: Re: How do you access the printer in Linux/C? Date: Tue, 07 Apr 2015 12:24:36 +0100 Lines: 36 Message-ID: References: <87lhi4b5uv.fld@barrow.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net fAQC3J537JLxCLEPytsvsQUGsP+2vLGDBDgB7Kitdw7gcvGSF6 X-Orig-Path: squidward.dionic.net!not-for-mail Cancel-Lock: sha1:c5BdMyirTvmDF/3sRgwKGeFy5zQ= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 In-Reply-To: Xref: csiph.com comp.os.linux.misc:14377 On 07/04/15 11:51, The Natural Philosopher wrote: > On 07/04/15 11:30, Tim Watts wrote: >> I don't know how old the OP is, but it's also worth recalling the days >> of MS-DOS when the "OS" (and I use the term loosely) had no concept of a >> printer beyond presenting a raw character IO type device. >> >> Every application had to have its own bundle of print drivers and it was >> a right PITA if one app did know know about a particular printer. >> >> I'm with you totally in that noone should ever try to replicate that! > > I think we all agree on that, the more relevant question is at what > level should the programmer tap into the whole cups process? On a side note I find it hugely ironic that Android (at least pre Kitkat) did not bother with a printing subsystem either - and neither do the apps. So you have a huge kludge of installing a random app that knows about your printer and understands some random subset of document formats. > The quickest and simplest is to write the file to stdout or a tmp > location and invoke a system() type call to handle it as a separate > process. Personally, I'd stick with this - it's the unix way and it makes it possible to specify the spawned command (and optionally args) in a config file. > Next up from that is to write the file and use the cups API to print it > with no system call needed. > > Finally you can hack the CUPS source to write to a socket connected > CUPSD directly without needing an intermediate file.