I am looking for a way to check if a printer exists on a Linux / Unix machine using a C or C ++ program. Something like the following windows program:
BOOL IsPrinterExist(LPTSTR pPrinterName) { HANDLE hPrinter = NULL; if(OpenPrinter(PRINTERNAME,&hPrinter,NULL)) { ClosePrinter(hPrinter); hPrinter = NULL; return TRUE; } return FALSE; }
I think I can do this using the CUPS API, but I need something that will work on each machine without special installations using the OS API. I know that I can also use the lpstat -a command and read its output, but I am looking for a way to do this directly (which does lpstat -a ).
source share