ldb: Allow access to the line number while reading ldif from a file

Andrew Bartlett abartlet at samba.org
Tue Apr 10 21:13:33 MDT 2012


On Tue, 2012-04-10 at 07:48 -0400, simo wrote:
> On Tue, 2012-04-10 at 11:15 +0200, Andrew Bartlett wrote:
> > index cafc020..f07bbc9 100644
> > --- a/lib/ldb/include/ldb_private.h
> > +++ b/lib/ldb/include/ldb_private.h
> > @@ -181,4 +181,12 @@ struct ldb_val ldb_binary_decode(TALLOC_CTX
> > *mem_ctx, const char *str);
> >  const char *ldb_options_find(struct ldb_context *ldb, const char
> > *options[],
> >                              const char *option_name);
> >  
> > +struct ldif_read_file_state {
> > +       FILE *f;
> > +       size_t line_no;
> > +};
> 
> Andrew,
> can you put this back in ldb_ldif.c and provide a getter function for
> the line number instead ?
> Let's avoid keeping spreading structures all over.

This is only defined in ldb_private.h, not ldb.h.  The reason that a
getter function (which was my original prototype design) doesn't work is
that the counter needs to be maintained in the caller (as it must count
lines for the whole time the file is open, not just during one
ldb_ldif_read_file_state() call).  

As it would have required both the getter function and an allocator, I
decided it was reasonable to declare the private structure in the
private header. 

> > +struct ldb_ldif *ldb_ldif_read_file_state(struct ldb_context *ldb, 
> > +                                         struct ldif_read_file_state
> > *state);
> > + 

I hope this clarifies things,

Andrew Bartlett

-- 
Andrew Bartlett                                http://samba.org/~abartlet/
Authentication Developer, Samba Team           http://samba.org



More information about the samba-technical mailing list