jstedfast / gmime

A C/C++ MIME creation and parser library with support for S/MIME, PGP, and Unix mbox spools.
GNU Lesser General Public License v2.1
113 stars 36 forks source link

Parsing stdin #83

Closed moko-als closed 4 years ago

moko-als commented 4 years ago

After this commit it is no longer possible to parse emails from stdin, as a seek on stdin returns error 29. Using stdin is necessary for use with .forward, where the syntax allows you to specify a program to pipe email to (|/receive_mail.sh). Am I right that the easiest workaround is to replace the read function? The code demonstrates the issue and workaround. Note that without patching ./test-parser empty2.msg works, while cat empty2.msg | ./test-parser does not work.

jstedfast commented 4 years ago

I can see why that commit would break reading from a pipe.

That said, GMime does have a GMimeStreamPipe which is what I specifically designed for this purpose. Unfortunately, it uses int file descriptors rather than FILE* pointers, so it's not a drop-in replacement for your purpose.

Is it possible for you to use GMimeStreamPipe? If so, we can close this. Otherwise we might want a gboolean option on GMimeStreamFIle that toggles it in/out of "PIPE" mode.

moko-als commented 4 years ago

Thanks, we can use GMimeStreamPipe, so let's close this.