summaryrefslogtreecommitdiff
path: root/lib/ldb/common
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-04-10 17:29:11 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-04-10 17:37:31 +1000
commit501d6d3dd4e3045e069bb2f7a52cf842dd1dfa67 (patch)
tree4ef9d3f63930a1f228e0e3eb98dcb5736e4c2dd8 /lib/ldb/common
parentc484f259c66ffcf0649dd5ab0d7c86e5c70d31af (diff)
downloadsamba-501d6d3dd4e3045e069bb2f7a52cf842dd1dfa67.tar.gz
samba-501d6d3dd4e3045e069bb2f7a52cf842dd1dfa67.tar.bz2
samba-501d6d3dd4e3045e069bb2f7a52cf842dd1dfa67.zip
ldb: Allow access to the line number while reading ldif from a file
Diffstat (limited to 'lib/ldb/common')
-rw-r--r--lib/ldb/common/ldb_ldif.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/ldb/common/ldb_ldif.c b/lib/ldb/common/ldb_ldif.c
index 63b797c4f3..c083401c6e 100644
--- a/lib/ldb/common/ldb_ldif.c
+++ b/lib/ldb/common/ldb_ldif.c
@@ -893,25 +893,32 @@ failed:
/*
a wrapper around ldif_read() for reading from FILE*
*/
-struct ldif_read_file_state {
- FILE *f;
-};
static int fgetc_file(void *private_data)
{
+ int c;
struct ldif_read_file_state *state =
(struct ldif_read_file_state *)private_data;
- return fgetc(state->f);
+ c = fgetc(state->f);
+ if (c == '\n') {
+ state->line_no++;
+ }
+ return c;
+}
+
+struct ldb_ldif *ldb_ldif_read_file_state(struct ldb_context *ldb,
+ struct ldif_read_file_state *state)
+{
+ return ldb_ldif_read(ldb, fgetc_file, state);
}
struct ldb_ldif *ldb_ldif_read_file(struct ldb_context *ldb, FILE *f)
{
struct ldif_read_file_state state;
state.f = f;
- return ldb_ldif_read(ldb, fgetc_file, &state);
+ return ldb_ldif_read_file_state(ldb, &state);
}
-
/*
a wrapper around ldif_read() for reading from const char*
*/