#include #include #include #include #include #include #include #include "gm.h" #include "rio.h" int rio_write( char *name, void *addr, unsigned bytes, unsigned offset ); int rio_read( char *name, void *addr, unsigned bytes, unsigned offset ); int rio_pint( char *name ); int rio_start(int port,FILE *log); void rio_stop(); void rio_gmserver(); extern int Rio_Loglevel; extern int Rio_Termn8server; __sighandler_t shutdown(int foo, __sighandler_t handler) { Rio_Termn8server= 1; /* rio_stop(); */ } /*---------------------------------------------------------------------------- * Test rio */ int main( int argc, char **argv ) { int ierr; FILE *log=NULL; /* The optional argument is a logfile instead of stderr */ if ( argc > 1 ) { if ( !strcmp(argv[1],"stderr") ) log=stderr; else log= fopen( argv[1],"w" ); } else log=stderr; ierr= fork(); if ( ierr==-1 ) { perror("fork"); exit(1); } else if ( ierr != 0 ) exit(0); /* parent */ /* .. else the child proceeds */ if ( log != NULL ) setbuf(log,NULL); signal( SIGTERM, shutdown ); signal( SIGQUIT, shutdown ); Rio_Loglevel= 1; if ( rio_start(GMSERVERPORT,log) ) rio_gmserver(); return 0; }