Node:Obstack Streams, Next:Custom Streams, Previous:String Streams, Up:Other Kinds of Streams
You can open an output stream that puts it data in an obstack. See Obstacks.
FILE * open_obstack_stream (struct obstack *obstack) | Function |
This function opens a stream for writing data into the obstack obstack.
This starts an object in the obstack and makes it grow as data is
written (see Growing Objects).
Calling You can move the file position of an obstack stream with To make the object permanent, update the obstack with But how do you find out how long the object is? You can get the length
in bytes by calling obstack_1grow (obstack, 0); Whichever one you do, you must do it before calling
|
Here is a sample function that uses open_obstack_stream
:
char * make_message_string (const char *a, int b) { FILE *stream = open_obstack_stream (&message_obstack); output_task (stream); fprintf (stream, ": "); fprintf (stream, a, b); fprintf (stream, "\n"); fclose (stream); obstack_1grow (&message_obstack, 0); return obstack_finish (&message_obstack); }