lprint-default.c
char *					// O - Default printer or `NULL` for none
lprintGetDefaultPrinter(
    http_t *http,			// I - HTTP connection
    char   *buffer,			// I - Buffer for printer name
    size_t bufsize)			// I - Size of buffer
{
  ipp_t		*request,		// IPP request
		*response;		// IPP response
  const char	*printer_name;		// Printer name


  // Ask the server for its default printer; can't use cupsGetDefault2
  // because it will return a default printer for CUPS...
  request = ippNewRequest(IPP_OP_CUPS_GET_DEFAULT);
  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", NULL, "printer-name");

  response = cupsDoRequest(http, request, "/ipp/system");

  if ((printer_name = ippGetString(ippFindAttribute(response, "printer-name", IPP_TAG_NAME), 0, NULL)) != NULL)
    strlcpy(buffer, printer_name, bufsize);
  else
    *buffer = '\0';

  ippDelete(response);

  return (*buffer ? buffer : NULL);
}
//
// 'lprintGetDefaultPrinter()' - Get the default printer.
//
// Note: We can't use cupsGetDefault2() because it uses the defaults set via
// CUPS environment variables and the lpoptions command, too.
//
'lprintGetDefaultPrinter()' - Get the default printer.
Note: We can't use cupsGetDefault2() because it uses the defaults set via
CUPS environment variables and the lpoptions command, too.
' lprintGetDefaultPrinter () ' - Get the default printer . Note : We can ' t use cupsGetDefault2 () because it uses the defaults set via CUPS environment variables and the lpoptions command too .
char *					
lprintGetDefaultPrinter(
    http_t *http,			
    char   *buffer,			
    size_t bufsize)			
{
  ipp_t		*request,		
		*response;		
  const char	*printer_name;		
  request = ippNewRequest(IPP_OP_CUPS_GET_DEFAULT);
  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", NULL, "printer-name");
  response = cupsDoRequest(http, request, "/ipp/system");
  if ((printer_name = ippGetString(ippFindAttribute(response, "printer-name", IPP_TAG_NAME), 0, NULL)) != NULL)
    strlcpy(buffer, printer_name, bufsize);
  else
    *buffer = '\0';
  ippDelete(response);
  return (*buffer ? buffer : NULL);
}
char * lprintGetDefaultPrinter ( http_t * http , char * buffer , size_t bufsize ) { ipp_t * request , * response ; const char * printer_name ; request = ippNewRequest ( IPP_OP_CUPS_GET_DEFAULT ) ; ippAddString ( request , IPP_TAG_OPERATION , IPP_TAG_NAME , " " , NULL , cupsUser ( ) ) ; ippAddString ( request , IPP_TAG_OPERATION , IPP_TAG_KEYWORD , " " , NULL , " " ) ; response = cupsDoRequest ( http , request , " " ) ; if ( ( printer_name = ippGetString ( ippFindAttribute ( response , " " , IPP_TAG_NAME ) , 0 , NULL ) ) != NULL ) strlcpy ( buffer , printer_name , bufsize ) ; else * buffer = ' \0 ' ; ippDelete ( response ) ; return ( * buffer ? buffer : NULL ) ; }
'lprintGetDefaultPrinter()' - Get the default printer.
' lprintGetDefaultPrinter () ' - Get the default printer .
// O - Default printer or `NULL` for none // I - HTTP connection // I - Buffer for printer name // I - Size of buffer // IPP request // IPP response // Printer name // Ask the server for its default printer; can't use cupsGetDefault2 // because it will return a default printer for CUPS...