RFC PS Rasterizer Library API
Based on these two lines…


xpost_create("bgr", 
        XPOST_OUTPUT_BUFFEROUT, 
        &amp;buffer_type_object, 
        XPOST_SHOWPAGE_RETURN, 
        1); 
xpost_run(XPOST_INPUT_STRING, prog);



I am puzzled by the interaction between xpost_create() and xpost_run().  Is it possible to create and use multiple xpost contexts at once?  If so, shouldn't xpost_create() return some kind of handle that would be passed as a parameter to xpost_run()?  Or, if not, then why should I need to call xpost_create() and xpost_destroy() at all?

I would expect the library to behave more like a printer, in that it would produce an image for every showpage command.  One way to make that work would be to register a callback, which would be called whenever showpage is encountered.  Perhaps it could pass some information about the bounding box as parameters to the callback, since it's unreasonable to have to guess or hard-code that information.

It's odd that the color model is called "bgr", but the pixel values are arranged in the opposite order (red, green, blue) in the output buffer.  I would also consider treating the buffer as an array of

typedef {
    int red;
    int green;
    int blue;
} struct pixel;


… instead of separate red, green, and blue integers.

Your example client doesn't seem to demonstrate any error-handling capability.  What happens, for example, if the PostScript interpreter has a stack underflow?