*/
#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) {
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;
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;
/* 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;
} 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;
}
}
+ *_pcache = pcache;
x_fclose(pfile);
TALLOC_FREE(ctx);
return true;