Use a consistent style of returning a new STREAM object from functions
that output data, rather than requiring an existing structure to be
passed in. This generally makes the memory management more straight
forward and allows us to do more proper bounds checking of everything.
This also adds some new STREAM macros to make it easier to manage
them without poking around in the internal structure.
Avoids mistakes by making sure everyone allocates these the same
way.
The smart card code still has manual allocation because it has it's
own magical memory management.