From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13607 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: function: fgetspent_r Date: Wed, 16 Jan 2019 15:50:46 -0500 Message-ID: <20190116205046.GK23599@brightrain.aerifal.cx> References: <4ac5ac1b-217f-442f-fc35-bfbf015287bb@adelielinux.org> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1547671735 29905 195.159.176.226 (16 Jan 2019 20:48:55 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 16 Jan 2019 20:48:55 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-13623-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jan 16 21:48:50 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1gjs7G-0007bC-Aq for gllmg-musl@m.gmane.org; Wed, 16 Jan 2019 21:48:50 +0100 Original-Received: (qmail 1035 invoked by uid 550); 16 Jan 2019 20:50:59 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 32747 invoked from network); 16 Jan 2019 20:50:58 -0000 Content-Disposition: inline In-Reply-To: <4ac5ac1b-217f-442f-fc35-bfbf015287bb@adelielinux.org> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:13607 Archived-At: On Wed, Jan 16, 2019 at 01:21:39PM -0600, A. Wilcox wrote: > Hi muslers, > > fgetspent_r[1] is a re-entrant version of fgetspent which stores all > strings in a caller-provided buffer to ensure that the memory is owned > by the caller instead of by the system. > > It is present in Solaris 9[2] and higher, and glibc[3] Linux. It is > used by AccountsService[4]. > > Is it possible to add this API to musl? I could try to write it, if so. > > Best, > --arw > > > [1]: https://docs.oracle.com/cd/E88353_01/html/E37843/getspent-r-3c.html > > [2]: https://docs.oracle.com/cd/E19683-01/816-5214/6mbcfdl0v/index.html > > [3]: https://linux.die.net/man/3/getspnam_r > > [4]: https://cgit.freedesktop.org/accountsservice/commit/?id=14ca4245 I don't see any good reason why it couldn't be added, but it doesn't look like a direct refactoring of the existing function since it uses the messy char[] buffer idiom like a bunch of other _r functions in this family. I'm also not sure what should happen if the next entry does not fit in the buffer. Should it discard the rest of the line and move on (not retryable) or attempt to seek back? Rich