summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2016-11-26 09:27:19 +0100
committerVolker Lendecke <vl@samba.org>2016-12-11 11:17:23 +0100
commita366463ff9ad7c51734bc977e087f4f18095250b (patch)
treed1812c660943e614b11f41325adc6916e3fa0c35 /source3/printing
parent2d9409341f63564b94797c0dc22e924a0a596985 (diff)
downloadsamba-a366463ff9ad7c51734bc977e087f4f18095250b.tar.gz
printing: std_pcap_cache_reload xfile->stdio
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/print_standard.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/source3/printing/print_standard.c b/source3/printing/print_standard.c
index 4404aeb681d..7cbdac7b257 100644
--- a/source3/printing/print_standard.c
+++ b/source3/printing/print_standard.c
@@ -57,31 +57,32 @@
#include "includes.h"
#include "system/filesys.h"
#include "printing/pcap.h"
-#include "lib/util/xfile.h"
/* handle standard printcap - moved from pcap_printer_fn() */
bool std_pcap_cache_reload(const char *pcap_name, struct pcap_cache **_pcache)
{
TALLOC_CTX *frame = talloc_stackframe();
- XFILE *pcap_file;
+ FILE *pcap_file;
char *pcap_line;
struct pcap_cache *pcache = NULL;
bool print_warning = false;
- if ((pcap_file = x_fopen(pcap_name, O_RDONLY, 0)) == NULL) {
+ if ((pcap_file = fopen(pcap_name, "r")) == NULL) {
DEBUG(0, ("Unable to open printcap file %s for read!\n", pcap_name));
talloc_free(frame);
return false;
}
- for (; (pcap_line = x_fgets_slash(NULL, 1024, pcap_file)) != NULL;
- free(pcap_line)) {
+ while ((pcap_line = fgets_slash(frame, NULL, 1024,
+ pcap_file)) != NULL) {
char *name = NULL;
char *comment = NULL;
char *p, *q;
- if (*pcap_line == '#' || *pcap_line == 0)
+ if (*pcap_line == '#' || *pcap_line == 0) {
+ TALLOC_FREE(pcap_line);
continue;
+ }
/* now we have a real printer line - cut at the first : */
if ((p = strchr_m(pcap_line, ':')) != NULL)
@@ -108,11 +109,13 @@ bool std_pcap_cache_reload(const char *pcap_name, struct pcap_cache **_pcache)
if (name == NULL && !has_punctuation) {
name = talloc_strdup(frame, p);
+ TALLOC_FREE(pcap_line);
continue;
}
if (has_punctuation) {
comment = talloc_strdup(frame, p);
+ TALLOC_FREE(pcap_line);
continue;
}
}
@@ -129,7 +132,7 @@ bool std_pcap_cache_reload(const char *pcap_name, struct pcap_cache **_pcache)
comment,
NULL);
if (!ok) {
- x_fclose(pcap_file);
+ fclose(pcap_file);
pcap_cache_destroy_specific(&pcache);
talloc_free(frame);
return false;
@@ -137,6 +140,7 @@ bool std_pcap_cache_reload(const char *pcap_name, struct pcap_cache **_pcache)
}
TALLOC_FREE(name);
TALLOC_FREE(comment);
+ TALLOC_FREE(pcap_line);
}
if (print_warning) {
@@ -146,7 +150,7 @@ bool std_pcap_cache_reload(const char *pcap_name, struct pcap_cache **_pcache)
(unsigned int)MAXPRINTERLEN);
}
- x_fclose(pcap_file);
+ fclose(pcap_file);
*_pcache = pcache;
talloc_free(frame);
return true;