On Fri, Jul 27, 2018 at 10:07:11AM -0600, Ian Lepore wrote: > I believe pw_scan() was originally a static function in libc used by > getpwent() and related functions. When libutil grew some pw utilties, > it looks like the static pw_scan was renamed to __pw_scan and added to > the private list, so that it could be shared with libutil (and so I > copied that process with pw_init(), but I had to rename it to > pw_initpwd because libutil already has a pw_init()). > > I'm not sure how to make the functions more generic, pw_scan() parses a > line of text in passwd(5) format, optionally warns about errors, and > fills in a struct passwd with what it finds. pw_initpwd() inits a > struct passwd to (well-)known default values. But libutil pw_scan() > allocates the struct and requires the caller to free it, and the > internal __pw_scan() fills in a struct passed in to it and returns an > int, so there's no way to re-unify the functions under a single name. I did not asked to make it more generic. I mean, if the function is exported, its interface should be useful enough for generic consumers. If the current interface is fine, so be it, but see below.
> > It would be strange to me to have one or two of the pw_xxxx() family of > functions in libc and the rest of them in libutil. Libutil seems like a > fine place for password/group file utilities that go beyond the posix > functions. It's just an implementation detail that we'd prefer to share > the source code for a small bit of common functionality around parsing > lines of passwd file data. Would it be a solution to stop exporting these functions at all, and just sompile them twice, once in libc, and second time in libutil ? libutil would add a source file from libc into it SRCS. _______________________________________________ [email protected] mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "[email protected]"
