void msIO_resetHandlers() { msIOContextGroup *group = msIO_GetContextGroup(); if( group == NULL ) return; if( strcmp(group->stdin_context.label,"buffer") == 0 ) { msIOBuffer *buf = (msIOBuffer *) group->stdin_context.cbData; if( buf->data != NULL ) free( buf->data ); free( buf ); } if( strcmp(group->stdout_context.label,"buffer") == 0 ) { msIOBuffer *buf = (msIOBuffer *) group->stdout_context.cbData; if( buf->data != NULL ) free( buf->data ); free( buf ); } if( strcmp(group->stderr_context.label,"buffer") == 0 ) { msIOBuffer *buf = (msIOBuffer *) group->stderr_context.cbData; if( buf->data != NULL ) free( buf->data ); free( buf ); } msIO_installHandlers( NULL, NULL, NULL ); }
void msCleanupOnSignal( int nInData ) { /* For some reason, the fastcgi message code does not seem to work */ /* from within the signal handler on Unix. So we force output through */ /* normal stdio functions. */ msIO_installHandlers( NULL, NULL, NULL ); msIO_fprintf( stderr, "In msCleanupOnSignal.\n" ); exitSignal = 1; }
void msIO_installStdinFromBuffer() { msIOContextGroup *group = msIO_GetContextGroup(); msIOContext context; context.label = "buffer"; context.write_channel = MS_FALSE; context.readWriteFunc = msIO_bufferRead; context.cbData = calloc(sizeof(msIOBuffer),1); msIO_installHandlers( &context, &group->stdout_context, &group->stderr_context ); }
int msIO_installApacheRedirect (request_rec *r) { msIOContext stdout_ctx, stderr_ctx; stdout_ctx.label = "apache"; stdout_ctx.write_channel = MS_TRUE; stdout_ctx.readWriteFunc = msIO_apacheWrite; stdout_ctx.cbData = (void*) r; stderr_ctx.label = "apache"; stderr_ctx.write_channel = MS_TRUE; stderr_ctx.readWriteFunc = msIO_apacheError; stderr_ctx.cbData = (void*) r; msIO_installHandlers (NULL, &stdout_ctx, &stderr_ctx); return MS_TRUE; }
void msIO_restoreOldStdoutContext(msIOContext *context_to_restore) { msIOContextGroup *group = msIO_GetContextGroup(); msIOContext *prev_context = &group->stdout_context; msIOBuffer* buffer; /* Free memory associated to our temporary context */ assert( strcmp(prev_context->label, "buffer") == 0 ); buffer = (msIOBuffer* )prev_context->cbData; msFree(buffer->data); msFree(buffer); /* Restore old context */ msIO_installHandlers( &group->stdin_context, context_to_restore, &group->stderr_context ); msFree(context_to_restore); }
int msIO_installFastCGIRedirect() { msIOContext stdin_ctx, stdout_ctx, stderr_ctx; stdin_ctx.label = "fcgi"; stdin_ctx.write_channel = MS_FALSE; stdin_ctx.readWriteFunc = msIO_fcgiRead; stdin_ctx.cbData = (void *) FCGI_stdin; stdout_ctx.label = "fcgi"; stdout_ctx.write_channel = MS_TRUE; stdout_ctx.readWriteFunc = msIO_fcgiWrite; stdout_ctx.cbData = (void *) FCGI_stdout; stderr_ctx.label = "fcgi"; stderr_ctx.write_channel = MS_TRUE; stderr_ctx.readWriteFunc = msIO_fcgiWrite; stderr_ctx.cbData = (void *) FCGI_stderr; msIO_installHandlers( &stdin_ctx, &stdout_ctx, &stderr_ctx ); return MS_TRUE; }