[vlc-devel] [PATCH 4/9] raop: Implement options for password
remi at remlab.net
Mon Jul 27 11:02:35 CEST 2009
On Mon, 27 Jul 2009 10:37:30 +0200, jpd at videolan.org wrote:
> On Sun, Jul 26, 2009 at 12:01:48AM +0200, Michael Hanselmann wrote:
>> On Fri, Jul 24, 2009 at 11:41 AM, <jpd at videolan.org> wrote:
>> > On Fri, Jul 24, 2009 at 11:24:59AM +0200, Michael Hanselmann wrote:
>> >> So, the strsep(3) call in my patch just replaces the first occurence
>> >> of "\r" or "\n" after the password.
>> > Right. But you would only need "\n" if the file is opened in "text"
>> > mode. And in that case, strlen()-1 would do equally well to find the
>> > newline if it's there.
>> It's not equally well. The function should just return the first line,
>> not just remove the last newline.
> Isn't that, minus the removing of the newline, what fgets() does anyway?
>> + psz_newline = index(ps_buffer, '\n');
>> + if ( psz_newline != NULL )
>> + *psz_newline = '\0';
> That works, too. Now if fgets would return the number of characters read
> you could dispense with the strlen/index entirely, but alas, it doesn't.
I shall hope the file is small enough that this sort of optimization is
non-issue. And note that FILE streams have an internal buffers which
typically involves "extra" memory copying - in exchange for fewer system
I was just wondering why we use POSIX file descriptors when we could use C
FILE streams. For the reference, we need low-level file descriptors in the
access plug-in for input event handling. But whenever we read configuration
files in blocking mode, this is a non-issue.
More information about the vlc-devel