[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

I'd like to rearrange the stream_t API slightly

From: Sam Roberts
Subject: I'd like to rearrange the stream_t API slightly
Date: Wed, 28 Nov 2001 23:23:51 -0500
User-agent: Mutt/1.3.16i


C'est une semaine de quietude (est'ce que ca francais?) dans la liste, donc
je propose nous faire quel'que chose un peu differente.

Right now you have to know what kind of stream you want to open
in two places, when you create the stream (X_stream_create()),
and when you open the stream (since you have to know what to
stuff into the char* and int that are all you have to specify
the stream to open).

I want to open a STDIO stream, though, so I propose that this would

stream_create() creates a stream_t.

stream_open() dissappears.

stream_open_file(stream_t, const char* file, int flag)
  closes the existing stream (using the existing stream_t.close()),
  then opens a file and resets up the virtual function pointers
  to point to file functions

stream_open_stdio(stream_t, FILE* f, int flag)
  closes the existing stream, and opens a new one with a FILE

  (I need stdio streams in my mailer, so it can create a message
   from stdin, and mailer_send() it).

It will be easier to accomodate new type of streams that can't get
the info that's needed to open them stuffed into a char* and an int.

Attached is something I hacked up in half an hour, just to give a
more concrete example of what I mean. It builds, but won't link.

I did a review of the mailbox/*.c code. Every time that I saw
stream_open() being called, it was known at that point in the code
what kind of stream was being opened, so it would be easy to make the
stream_create more generic, and the open more specific.

I'll make the change and build mailutils against it (if there is no

Maybe it should be done in mailbox2? But I need it so I can commit the
mailer I use to test the expanded mailer API (attached, FYI).

I'm going to Sept Iles for a week, but I'll check my mail before
getting back.

Bon nuit!


ps1 I've implemented the sendmail mailer as described in the docs
I committed, next is smtp, but I wanted some comment on how to
approach this stream issue as I write/test the smtp mailer.

ps2 After I've a mailer, I can implement a sieve redirect, finally!

Sam Roberts <address@hidden> (Vivez sans temps mort!)

Attachment: stream.h
Description: Text document

Attachment: stream0.h
Description: Text document

Attachment: file_stream.c
Description: Text document

Attachment: stream.c
Description: Text document

Attachment: _fopen.diff
Description: Text document

Attachment: mailer.c
Description: Text document

reply via email to

[Prev in Thread] Current Thread [Next in Thread]