|
|
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 - downloadIndex: T U c
Length: 3568 (0xdf0)
Types: TextFile
Notes: UNIX file
Names: »chantest.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/chantest.c«
/*\r
* DOS program to test channel manager routines.\r
*\r
* This program has been compiled and tested in both small and large models\r
* with MSC 5.0.\r
*/\r
\r
\r
/*\r
* include the standard stuff\r
*/\r
\r
#include <stdio.h>\r
#include <string.h>\r
#include <signal.h>\r
\r
\r
/*\r
* include the channel-library definitions\r
*/\r
\r
#include "doschan.h"\r
\r
\r
/*\r
* function prototypes\r
*/\r
\r
void main(void);\r
void exit_program(void);\r
void sighandler(void);\r
void exit(int exitval);\r
\r
\r
/*\r
* declare the assmbly-language interrupt handler\r
*/\r
\r
void far inthdl();\r
\r
\r
/*\r
* communication buffers\r
*/\r
\r
#define COMBUFSIZE 256 /* size of the buffers */\r
char dosbuff[COMBUFSIZE]; /* DOS->UNIX buffer */\r
char unixbuff[COMBUFSIZE]; /* UNIX->DOS buffer */\r
\r
\r
/*\r
* other globals\r
*/\r
\r
int errors = 0; /* number of errors encountered */\r
CHANNEL_ID id; /* channel-ID */\r
\r
\r
/*\r
* The test program opens a channel called "test". It then loops\r
* (until the Control-Break key is pressed), sending messages to the\r
* associated Emulation Module, which responds to each message with a\r
* reply. The interrupt handler linked into this program (see\r
* "int.asm") prints these replies to the screen as they are received.\r
*/\r
\r
void main()\r
{\r
CH_OPEN openstruct; /* channel-open structure */\r
CH_OPEN far *optr = &openstruct; /* pointer to ch-open struct */\r
int msgcount = 1; /* number of messages sent */\r
int retcode; /* return code */\r
\r
/*\r
* fill-in the channel-open structure\r
*/\r
\r
openstruct.dosbuff = (FPTR)dosbuff; /* DOS->UNIX buffer */\r
openstruct.dbufflen = (long)COMBUFSIZE; /* and length */\r
openstruct.unixbuff = (FPTR)unixbuff; /* UNIX->DOS buffer */\r
openstruct.ubufflen = (long)COMBUFSIZE; /* and length */\r
openstruct.funcptr = (FPFV)inthdl; /* interrupt-handler */\r
strcpy(openstruct.chname, "test"); /* channel name */\r
\r
/*\r
* open the channel\r
*/\r
\r
id = dos_ch_open(optr);\r
if(id < 0)\r
{\r
errors++;\r
printf("Failed to open channel: Error code: %d\n", ch_errno);\r
exit_program();\r
}\r
\r
/*\r
* set up a Control-Break handler function\r
* (this is how we'll exit the program)\r
*/\r
\r
signal(SIGINT, sighandler);\r
\r
/*\r
* loop, sending messages\r
*/\r
\r
while(1)\r
{\r
/*\r
* put a message in the DOS->UNIX buffer\r
*/\r
\r
sprintf(dosbuff, "This is message #%d from DOS", msgcount++);\r
\r
/*\r
* call the channel-send routine\r
*/\r
\r
retcode = dos_ch_send(id);\r
if(retcode != ERR_NONE)\r
{\r
printf("SEND failed at message #%d with error code %d\n",\r
msgcount - 1, ch_errno);\r
errors++;\r
}\r
}\r
}\r
\r
\r
/*\r
* signal-handler -- close channel and exit\r
*/\r
\r
void sighandler()\r
{\r
int retcode;\r
\r
retcode = dos_ch_close(id);\r
if(retcode != ERR_NONE)\r
{\r
errors++;\r
printf("Failed to close channel: Error code: %d\n", ch_errno);\r
}\r
exit_program();\r
}\r
\r
\r
/*\r
* display the error-count and exit\r
*/\r
\r
void exit_program()\r
{\r
printf("Total number of errors: %d\n", errors);\r
exit(0);\r
}\r
\r
\r