]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
update code for mode=2
authornidhijainpnp <12njain06@gmail.com>
Sat, 8 Aug 2020 17:25:25 +0000 (22:55 +0530)
committerTill Kamppeter <till.kamppeter@gmail.com>
Thu, 20 Aug 2020 20:17:57 +0000 (22:17 +0200)
(cherry picked from commit 4414c28108a67cff1ea50e454264de86da30e9e8)

utils/driverless.c

index 9608fdda1e8ea6432266ce4914df87a97fe74617..c996c05c21f942f19b62522285916c381e69b2f4 100644 (file)
@@ -46,10 +46,8 @@ static void          cancel_job(int sig);
 static int                             
 compare_service_uri(char *a,   char *b)                
 {
-  size_t size_a = strlen(a);
-  size_t size_b = strlen(b);
-  size_t size = (size_a>size_b ? size_b+1 :size_a +1);
-  return (memcmp(a,b, size));
+  
+  return (strcmp(a,b));
 }
 void 
 listPrintersInArray(int post_proc_pipe[], cups_array_t *service_uri_list_ipps,  int reg_type_no, int mode){
@@ -335,7 +333,17 @@ listPrintersInArray(int post_proc_pipe[], cups_array_t *service_uri_list_ipps,
            else{
          /* Call without arguments and env variable "SOFTWARE" starting
             with "CUPS" (Backend in discovery mode) */
-        printf("network %s \"%s\" \"%s (%s)\" \"%s\" \"\"\n", copy_service_uri_ipps, make_and_model, make_and_model, driverless_info, device_id);
+        if(reg_type_no < 1){
+          if(cupsArrayFind(service_uri_list_ipps,copy_service_uri_ipps) == NULL){
+        /* IPPS version of IPP printer is not present */
+          printf("network %s \"%s\" \"%s (%s)\" \"%s\" \"\"\n", service_uri, make_and_model, make_and_model, driverless_info, device_id);
+          }
+        }
+        else{
+        cupsArrayAdd(service_uri_list_ipps , service_uri);
+        printf("network %s \"%s\" \"%s (%s)\" \"%s\" \"\"\n", service_uri, make_and_model, make_and_model, driverless_info, device_id);
+        }
+        
       }
 
      read_error:
@@ -773,6 +781,7 @@ int main(int argc, char*argv[]) {
   if ((val = getenv("SOFTWARE")) != NULL &&
       strncasecmp(val, "CUPS", 4) == 0) {
     /* CUPS backend in discovery mode */
+    debug = 1;
     exit(list_printers(2,reg_type_no));
   } else{
     /* Manual call */