lib: Remove global xfile.h includes
[samba.git] / source3 / printing / print_aix.c
index 57590cc39efd7a71bd281086f86431f2a5b2ab5d..7b5a1e3881c58aed07da18637e58748125ba12db 100644 (file)
  */
 
 #include "includes.h"
+#include "system/filesys.h"
+#include "printing/pcap.h"
+#include "lib/util/xfile.h"
 
 #ifdef AIX
-bool aix_cache_reload(void)
+bool aix_cache_reload(struct pcap_cache **_pcache)
 {
        int iEtat;
        XFILE *pfile;
        char *line = NULL, *p;
        char *name = NULL;
+       struct pcap_cache *pcache = NULL;
        TALLOC_CTX *ctx = talloc_init("aix_cache_reload");
 
        if (!ctx) {
@@ -49,7 +53,9 @@ bool aix_cache_reload(void)
 
        iEtat = 0;
        /* scan qconfig file for searching <printername>:       */
-       for (;(line = fgets_slash(NULL, 1024, pfile)); safe_free(line)) {
+       for (;(line = x_fgets_slash(NULL, 1024, pfile)); free(line)) {
+               bool ok;
+
                if (*line == '*' || *line == 0)
                        continue;
 
@@ -65,7 +71,8 @@ bool aix_cache_reload(void)
                                if (strcmp(p, "bsh") != 0) {
                                        name = talloc_strdup(ctx, p);
                                        if (!name) {
-                                               safe_free(line);
+                                               pcap_cache_destroy_specific(&pcache);
+                                               SAFE_FREE(line);
                                                x_fclose(pfile);
                                                TALLOC_FREE(ctx);
                                                return false;
@@ -84,8 +91,11 @@ bool aix_cache_reload(void)
                                /* name is found without stanza device  */
                                /* probably a good printer ???          */
                                iEtat = 0;
-                               if (!pcap_cache_add(name, NULL)) {
-                                       safe_free(line);
+                               ok = pcap_cache_add_specific(&pcache,
+                                                            name, NULL, NULL);
+                               if (!ok) {
+                                       pcap_cache_destroy_specific(&pcache);
+                                       SAFE_FREE(line);
                                        x_fclose(pfile);
                                        TALLOC_FREE(ctx);
                                        return false;
@@ -99,8 +109,11 @@ bool aix_cache_reload(void)
                        } else if (strstr_m(line, "device")) {
                                /* it's a good virtual printer */
                                iEtat = 0;
-                               if (!pcap_cache_add(name, NULL)) {
-                                       safe_free(line);
+                               ok = pcap_cache_add_specific(&pcache,
+                                                            name, NULL, NULL);
+                               if (!ok) {
+                                       pcap_cache_destroy_specific(&pcache);
+                                       SAFE_FREE(line);
                                        x_fclose(pfile);
                                        TALLOC_FREE(ctx);
                                        return false;
@@ -111,6 +124,7 @@ bool aix_cache_reload(void)
                }
        }
 
+       *_pcache = pcache;
        x_fclose(pfile);
        TALLOC_FREE(ctx);
        return true;