This is the one. Identifies protocol, selects handler, sorts out stdin and
stdout, invokes handler. A job well done. Logging would be nice...
This commit is contained in:
parent
b5415686db
commit
a119a8552b
16
wrapper.c
16
wrapper.c
|
@ -28,22 +28,20 @@ void wrapper( int conversation)
|
||||||
{
|
{
|
||||||
char firstln[ 1024];
|
char firstln[ 1024];
|
||||||
char * command;
|
char * command;
|
||||||
int i, hear, say = conversation;
|
|
||||||
FILE * c_rx, * c_tx;
|
|
||||||
|
|
||||||
printf( "wrapper started with fdes [%d]\n",
|
printf( "wrapper started with fdes [%d]\n",
|
||||||
conversation);
|
conversation);
|
||||||
|
|
||||||
#ifdef glubba
|
recv( conversation, firstln, 80, MSG_PEEK);
|
||||||
hear = dup( conversation); /* creat two handles on conversation */
|
/* get the first thing the client
|
||||||
say = dup( conversation); /* one for reading and one for writing */
|
says, but leave it on the input
|
||||||
#endif
|
stream for the handler. */
|
||||||
|
|
||||||
if ( dup2( conversation, STDIN_FILENO) == -1)
|
if ( dup2( conversation, STDIN_FILENO) == -1)
|
||||||
{
|
{
|
||||||
sprintf( errorBuff,
|
sprintf( errorBuff,
|
||||||
"failed to duplicate conversation [%d] onto stdin: %s",
|
"failed to duplicate conversation [%d] onto stdin: %s",
|
||||||
hear, strerror( errno));
|
conversation, strerror( errno));
|
||||||
error( FATAL_ERROR);
|
error( FATAL_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,12 +49,10 @@ void wrapper( int conversation)
|
||||||
{
|
{
|
||||||
sprintf( errorBuff,
|
sprintf( errorBuff,
|
||||||
"failed to duplicate conversation [%d] onto stdout: %s",
|
"failed to duplicate conversation [%d] onto stdout: %s",
|
||||||
say, strerror( errno));
|
conversation, strerror( errno));
|
||||||
error( FATAL_ERROR);
|
error( FATAL_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
gets( firstln);
|
|
||||||
|
|
||||||
command = get_handler_command( firstln);
|
command = get_handler_command( firstln);
|
||||||
/* and find the appropriate handler */
|
/* and find the appropriate handler */
|
||||||
if ( ! command) /* didn't find one */
|
if ( ! command) /* didn't find one */
|
||||||
|
|
Loading…
Reference in a new issue