9.6.3.3 User-stream Hook Example

This section contains an example of how to create and install a set of user-streams.

The hook is set by calling SP_set_user_stream_hook() in the main program like this:

     SP_set_user_stream_hook(user_strhook);

Remember: SP_set_user_stream_hook() and SP_set_user_stream_post_hook() must be called before SP_initialize().

The hook user_strhook() is defined like this:

     SP_stream *user_strhook(int which)
     {
       SP_stream *s;
     
       SP_make_stream(NULL, my_getc, my_putc, my_flush, my_eof, my_clrerr,
                      NULL, &s);
     
       return s;
     }

See Installing a New Stream for a description on the parameters to SP_make_stream().