Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How would I use CUPS to get the printers in my network in C++?

CUPS seems to now be requiring a http_t* http; variable in cupsGetDests(&dests); method and right now I don’t know what to do since I haven’t found any reference online yet.

I already did some search and got some code:

#include "assets/cups/cups.h"
#include <iostream>

void list_printers(){
    cups_dest_t* dests;
    int num_dests = cupsGetDests(&dests);
   
    for(int i=0; i<num_dests; i++){
        std::cout << dests[i].name << endl;
    }
}

But this code does not include the http variable in the cupsGetDests() method and I wasn’t able to find any other code snippet featuring this. Thanks!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

As explained in CUPS Programming Manual:

  int cupsGetDests2(http_t *http, cups_dest_t **dests);                        
                                                                                
    Parameters                                                                  
                                                                                
   http  Connection to server or CUPS_HTTP_DEFAULT                              
   dests Destinations                                                           

You want to use the cupsGetDests2 function:

auto n_dests=cupsGetDests2(CUPS_HTTP_DEFAULT, &dests);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading