Skip to content

Commit

Permalink
Make 'stream' OGR output compatible with FCGI with GDAL >= 2.0 (#4858)
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed May 30, 2014
1 parent de7573c commit 2c5aad9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions mapogroutput.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,17 @@ static int msOGRWriteShape( layerObj *map_layer, OGRLayerH hOGRLayer,

#endif /* def USE_OGR */

/************************************************************************/
/* msOGRStdoutWriteFunction() */
/************************************************************************/

/* Used by /vsistdout/ */
static size_t msOGRStdoutWriteFunction(const void* ptr, size_t size, size_t nmemb, FILE* stream)
{
msIOContext *ioctx = (msIOContext*) stream;
return msIO_contextWrite(ioctx, ptr, size * nmemb ) / size;
}

/************************************************************************/
/* msOGRWriteFromQuery() */
/************************************************************************/
Expand Down Expand Up @@ -538,6 +549,12 @@ int msOGRWriteFromQuery( mapObj *map, outputFormatObj *format, int sendheaders )
/* ==================================================================== */
storage = msGetOutputFormatOption( format, "STORAGE", "filesystem" );
if( EQUAL(storage,"stream") && !msIO_isStdContext() ) {
#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,0,0)
msIOContext *ioctx = msIO_getHandler (stdout);
if( ioctx != NULL )
VSIStdoutSetRedirection( msOGRStdoutWriteFunction, (FILE*)ioctx );
else
#endif
/* bug #4858, streaming output won't work if standard output has been
* redirected, we switch to memory output in this case
*/
Expand Down

0 comments on commit 2c5aad9

Please sign in to comment.