|
DataMuseum.dkPresents historical artifacts from the history of: Regnecentalen RC-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Regnecentalen RC-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 2121 (0x849) Types: TextFile Notes: UNIX file Names: »uchan.c«
└─⟦0cfe73749⟧ Bits:30004154/config.imd SW95707I VP/ix MS-DOS emulator Rel. 1.1 └─⟦0cfe73749⟧ UNIX Filesystem └─⟦this⟧ »vc/new/usr/vpix/src/channels/uchan.c«
/* * uchan.c - Sample user emulation module * To see the results from this end, do a tail -f of DEBUGFILE * */ #include "gdi.h" #include <stdio.h> #define CHANNAME "test" #define DEBUGFILE "/tmp/debug.out" #define DEBUG 1 extern int uchan_emu_rout(); #ifdef DEBUG FILE *dbg; #endif CHANNEL_ID chanid; char *dosbuf = 0; long doslen = 0; int seq=0; /* init_uchan */ /* This routine is called as part of the initialization at startup of */ /* the "vpix" process. */ init_uchan() { #ifdef DEBUG /* open the debug file for output */ if( (dbg=fopen(DEBUGFILE, "w" )) == NULL ) { gdi_err_print(VERR_FATAL, "init_uchan: Couldn't open debug file %s", DEBUGFILE); return; } #endif /* open the channel - pass it the pointer to our handler */ if ((chanid=gdi_ch_open(CHANNAME, uchan_emu_rout)) == -1) { gdi_err_print(VERR_FATAL, "init_uchan: Channel connection failed."); return; } } /* uchan_emu_rout */ /* User emulation routine that is called whenever a channel communica- */ /* tion request happens. */ uchan_emu_rout(id, action, bufptr, buflen) CHANNEL_ID id; char action; char *bufptr; long buflen; { #ifdef DEBUG fprintf(dbg,"uchan_emu_rout() called with arg = %d\n", action); fflush(dbg); #endif switch (action) { case DOS_OPEN: if( id == chanid ) { /* save the buffers to write to */ dosbuf = bufptr; doslen = buflen; } else gdi_err_print(VERR_FATAL, "uchan_emu_rout: open ID mistmatch."); break; case DOS_CLOSE: if( id != chanid ) gdi_err_print(VERR_FATAL, "uchan_emu_rout: close ID mistmatch."); else { dosbuf = 0; doslen = 0; } break; case DOS_SEND: #ifdef DEBUG fprintf(dbg,"Got '%s' from dos\n", bufptr); fflush(dbg); #endif if( !dosbuf ) { gdi_err_print(VERR_WARNING, "Attemptimg to send to an unopened channel"); return; } sprintf(dosbuf, "Unix message number %d\n", seq++); if (id == chanid ) { if (gdi_ch_send(chanid)) gdi_err_print(VERR_WARNING, "user_emu_rout: Channel to DOS busy"); return; } break; } }