////////////////////////////////////////////////////////////////////////// // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BOOL SBBSExec::OnCreateVM(VMHANDLE hVM) { DBTRACExd(0,"CreateVM, handle, time",hVM,Get_System_Time()); DBTRACEx(0,"Current Thread Handle",Get_Cur_Thread_Handle()); if(start.event) { new_vm=find_vm(NULL); if(new_vm==NULL) { DBTRACE(0,"!NO AVAILABLE VM structures"); return(FALSE); } new_vm->handle=hVM; new_vm->mode=start.mode; new_vm->online = true; new_vm->overrun = false; new_vm->input_sem = NULL; new_vm->output_sem = NULL; if(RingBufInit(&new_vm->in, RINGBUF_SIZE_IN)!=0 || RingBufInit(&new_vm->out, RINGBUF_SIZE_OUT)!=0) { DBTRACE(0,"!FAILED to create I/O buffers"); return(FALSE); } if(!VWIN32_SetWin32Event(start.event)) { DBTRACEx(0,"!FAILED TO SET EVENT handle", start.event); return(FALSE); } if(!VWIN32_CloseVxDHandle(start.event)) { DBTRACEx(0,"!FAILED TO CLOSE EVENT handle", start.event); return(FALSE); } start.event=0; } return(TRUE); }
//***************************************************************************** // // Initializes the RemoTI UART driver interface to a remote network processor. // // \param ui32Base is the base address of the UART peripheral to be used. // Caller must call SysCtlPeripheralEnable for this UART peripheral prior to // calling this init funciton. // // This function will initialize the ring buffers used for transmit and receive // of data to and from the RNP. It also configures the UART peripheral for a // default setting. Enables receive interrupts. Transmit interrupts are // enabled when a transmit is in progress. Master interrupt enable must be // turned on by the application. // // \note Users of this driver are also responsible to assign // RemoTIUARTIntHandler() as the interrupt routine associated with the UART // peripheral of choice. // // \return None. // //***************************************************************************** void RemoTIUARTInit(uint32_t ui32Base) { // // Save the UART peripheral base address for later use. // g_ui32UARTBase = ui32Base; // // Initialize the TX and RX ring buffers for storage of our data. // RingBufInit(&g_rbRemoTIRxRingBuf, g_pui8RxBuf, REMOTI_UART_TX_BUF_SIZE); RingBufInit(&g_rbRemoTITxRingBuf, g_pui8TxBuf, REMOTI_UART_TX_BUF_SIZE); // // Configure UART clock settings. // UARTConfigSetExpClk(ui32Base, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE | UART_FLOWCONTROL_NONE)); // // Configure the UART FIFO. Enable the UART and Enable RX interrupts. // UARTFIFOLevelSet(ui32Base, UART_FIFO_TX1_8, UART_FIFO_RX1_8); UARTEnable(ui32Base); UARTFIFODisable(ui32Base); UARTIntEnable(ui32Base, UART_INT_RX); }
//--------------------------------------------------------------------------- void __fastcall TSpyForm::FormShow(TObject *Sender) { if((*outbuf=(RingBuf*)malloc(sizeof(RingBuf)))==NULL) { Terminal->WriteStr("Malloc failure!"); return; } RingBufInit(*outbuf,SPYBUF_LEN); Timer->Enabled=true; Terminal->Font=MainForm->SpyTerminalFont; Terminal->Clear(); Terminal->WriteStr("*** Synchronet Local Spy ***\r\n\r\n"); Terminal->WriteStr("ANSI Terminal Emulation:"+CopyRight+"\r\n\r\n"); KeyboardActive->Checked=!MainForm->SpyTerminalKeyboardActive; KeyboardActiveClick(Sender); }
int main(int argc, char **argv) { char str[MAX_PATH+1]; char fname[MAX_PATH+1]; char ini_fname[MAX_PATH+1]; char* p; char* arg; int i; int retval; uint fnames=0; FILE* fp; BOOL tcp_nodelay; char compiler[32]; str_list_t fname_list; fname_list=strListInit(); DESCRIBE_COMPILER(compiler); errfp=stderr; #ifdef __unix__ statfp=stderr; #else statfp=stdout; #endif sscanf("$Revision: 1.77 $", "%*s %s", revision); fprintf(statfp,"\nSynchronet External X/Y/Zmodem v%s-%s" " Copyright %s Rob Swindell\n\n" ,revision ,PLATFORM_DESC ,__DATE__+7 ); xmodem_init(&xm,NULL,&mode,lputs,xmodem_progress,send_byte,recv_byte,is_connected,NULL); zmodem_init(&zm,NULL,lputs,zmodem_progress,send_byte,recv_byte,is_connected,NULL,data_waiting); /* Generate path/sexyz[.host].ini from path/sexyz[.exe] */ SAFECOPY(str,argv[0]); p=getfname(str); SAFECOPY(fname,p); *p=0; if((p=getfext(fname))!=NULL) *p=0; strcat(fname,".ini"); iniFileName(ini_fname,sizeof(ini_fname),str,fname); if((fp=fopen(ini_fname,"r"))!=NULL) fprintf(statfp,"Reading %s\n",ini_fname); tcp_nodelay =iniReadBool(fp,ROOT_SECTION,"TCP_NODELAY",TRUE); telnet =iniReadBool(fp,ROOT_SECTION,"Telnet",TRUE); debug_tx =iniReadBool(fp,ROOT_SECTION,"DebugTx",FALSE); debug_rx =iniReadBool(fp,ROOT_SECTION,"DebugRx",FALSE); debug_telnet =iniReadBool(fp,ROOT_SECTION,"DebugTelnet",FALSE); pause_on_exit =iniReadBool(fp,ROOT_SECTION,"PauseOnExit",FALSE); pause_on_abend =iniReadBool(fp,ROOT_SECTION,"PauseOnAbend",FALSE); log_level =iniReadLogLevel(fp,ROOT_SECTION,"LogLevel",log_level); outbuf.highwater_mark =iniReadInteger(fp,ROOT_SECTION,"OutbufHighwaterMark",1100); outbuf_drain_timeout =iniReadInteger(fp,ROOT_SECTION,"OutbufDrainTimeout",10); outbuf_size =iniReadInteger(fp,ROOT_SECTION,"OutbufSize",16*1024); progress_interval =iniReadInteger(fp,ROOT_SECTION,"ProgressInterval",1); if(iniReadBool(fp,ROOT_SECTION,"Debug",FALSE)) log_level=LOG_DEBUG; xm.send_timeout =iniReadInteger(fp,"Xmodem","SendTimeout",xm.send_timeout); /* seconds */ xm.recv_timeout =iniReadInteger(fp,"Xmodem","RecvTimeout",xm.recv_timeout); /* seconds */ xm.byte_timeout =iniReadInteger(fp,"Xmodem","ByteTimeout",xm.byte_timeout); /* seconds */ xm.ack_timeout =iniReadInteger(fp,"Xmodem","AckTimeout",xm.ack_timeout); /* seconds */ xm.block_size =iniReadInteger(fp,"Xmodem","BlockSize",xm.block_size); /* 128 or 1024 */ xm.max_errors =iniReadInteger(fp,"Xmodem","MaxErrors",xm.max_errors); xm.g_delay =iniReadInteger(fp,"Xmodem","G_Delay",xm.g_delay); zm.init_timeout =iniReadInteger(fp,"Zmodem","InitTimeout",zm.init_timeout); /* seconds */ zm.send_timeout =iniReadInteger(fp,"Zmodem","SendTimeout",zm.send_timeout); /* seconds */ zm.recv_timeout =iniReadInteger(fp,"Zmodem","RecvTimeout",zm.recv_timeout); /* seconds */ zm.crc_timeout =iniReadInteger(fp,"Zmodem","CrcTimeout",zm.crc_timeout); /* seconds */ zm.block_size =iniReadInteger(fp,"Zmodem","BlockSize",zm.block_size); /* 1024 */ zm.max_block_size =iniReadInteger(fp,"Zmodem","MaxBlockSize",zm.max_block_size); /* 1024 or 8192 */ zm.max_errors =iniReadInteger(fp,"Zmodem","MaxErrors",zm.max_errors); zm.recv_bufsize =iniReadInteger(fp,"Zmodem","RecvBufSize",0); zm.no_streaming =!iniReadBool(fp,"Zmodem","Streaming",TRUE); zm.want_fcs_16 =!iniReadBool(fp,"Zmodem","CRC32",TRUE); zm.escape_telnet_iac =iniReadBool(fp,"Zmodem","EscapeTelnetIAC",TRUE); zm.escape_8th_bit =iniReadBool(fp,"Zmodem","Escape8thBit",FALSE); zm.escape_ctrl_chars =iniReadBool(fp,"Zmodem","EscapeCtrlChars",FALSE); dszlog_path =iniReadBool(fp,"DSZLOG","Path",TRUE); dszlog_short =iniReadBool(fp,"DSZLOG","Short",FALSE); dszlog_quotes =iniReadBool(fp,"DSZLOG","Quotes",FALSE); if(fp!=NULL) fclose(fp); if(zm.recv_bufsize > 0xffff) zm.recv_bufsize = 0xffff; if(outbuf_size < MIN_OUTBUF_SIZE) outbuf_size = MIN_OUTBUF_SIZE; else if(outbuf_size > MAX_OUTBUF_SIZE) outbuf_size = MAX_OUTBUF_SIZE; fprintf(statfp,"Output buffer size: %u\n", outbuf_size); RingBufInit(&outbuf, outbuf_size); #if !defined(RINGBUF_EVENT) outbuf_empty=CreateEvent(NULL,/* ManualReset */TRUE, /*InitialState */TRUE,NULL); #endif #if 0 if(argc>1) { fprintf(statfp,"Command line: "); for(i=1;i<argc;i++) fprintf(statfp,"%s ",argv[i]); fprintf(statfp,"\n",statfp); } #endif for(i=1;i<argc;i++) { if(sock==INVALID_SOCKET && isdigit(argv[i][0])) { sock=atoi(argv[i]); continue; } if(!(mode&(SEND|RECV))) { if(toupper(argv[i][0])=='S' || toupper(argv[i][0])=='R') { /* cmd */ if(toupper(argv[i][0])=='R') mode|=RECV; else mode|=SEND; switch(argv[i][1]) { case 'c': case 'C': mode|=XMODEM|CRC; break; case 'x': xm.block_size=128; case 'X': mode|=XMODEM; break; case 'b': /* sz/rz compatible */ case 'B': case 'y': xm.block_size=128; case 'Y': mode|=(YMODEM|CRC); break; case 'g': case 'G': mode|=(YMODEM|CRC|GMODE); break; case 'z': case 'Z': mode|=(ZMODEM|CRC); break; default: fprintf(statfp,"Unrecognized command '%s'\n\n",argv[i]); fprintf(statfp,usage); bail(1); } continue; } if(toupper(argv[i][0])=='V') { fprintf(statfp,"%-8s %s\n",getfname(__FILE__) ,revision); fprintf(statfp,"%-8s %s\n",getfname(xmodem_source()),xmodem_ver(str)); fprintf(statfp,"%-8s %s\n",getfname(zmodem_source()),zmodem_ver(str)); #ifdef _DEBUG fprintf(statfp,"Debug\n"); #endif fprintf(statfp,"Compiled %s %.5s with %s\n",__DATE__,__TIME__,compiler); fprintf(statfp,"%s\n",os_version(str)); bail(0); } arg=argv[i]; if(*arg=='-') { while(*arg=='-') arg++; if(stricmp(arg,"telnet")==0) { telnet=TRUE; continue; } if(stricmp(arg,"rlogin")==0 || stricmp(arg,"ssh")==0 || stricmp(arg,"raw")==0) { telnet=FALSE; continue; } if(stricmp(arg,"debug")==0) { log_level=LOG_DEBUG; continue; } if(stricmp(arg,"quotes")==0) { dszlog_quotes=TRUE; continue; } switch(toupper(*arg)) { case 'K': /* sz/rz compatible */ xm.block_size=1024; break; case 'C': /* sz/rz compatible */ mode|=CRC; break; case '2': zm.max_block_size=2048; break; case '4': zm.max_block_size=4096; break; case '8': /* ZedZap */ zm.max_block_size=8192; break; case 'O': /* disable Zmodem CRC-32 */ zm.want_fcs_16=TRUE; break; case 'S': /* disable Zmodem streaming */ zm.no_streaming=TRUE; break; case 'G': /* Ymodem-G */ mode|=GMODE; break; case 'Y': mode|=OVERWRITE; break; case '!': pause_on_abend=TRUE; break; } } } else if((argv[i][0]=='+' || argv[i][0]=='@') && fexist(argv[i]+1)) { if(mode&RECVDIR) { fprintf(statfp,"!Cannot specify both directory and filename\n"); bail(1); } sprintf(str,"%s",argv[i]+1); if((fp=fopen(str,"r"))==NULL) { fprintf(statfp,"!Error %d opening filelist: %s\n",errno,str); bail(1); } while(!feof(fp) && !ferror(fp)) { if(!fgets(str,sizeof(str),fp)) break; truncsp(str); strListAppend(&fname_list,strdup(str),fnames++); } fclose(fp); } else if(mode&(SEND|RECV)){ if(isdir(argv[i])) { /* is a directory */ if(mode&RECVDIR) { fprintf(statfp,"!Only one directory can be specified\n"); bail(1); } if(fnames) { fprintf(statfp,"!Cannot specify both directory and filename\n"); bail(1); } if(mode&SEND) { fprintf(statfp,"!Cannot send directory '%s'\n",argv[i]); bail(1); } mode|=RECVDIR; } strListAppend(&fname_list,argv[i],fnames++); } } if(!telnet) zm.escape_telnet_iac = FALSE; if(sock==INVALID_SOCKET || sock<1) { #ifdef __unix__ if(STDOUT_FILENO > STDIN_FILENO) sock=STDOUT_FILENO; else sock=STDIN_FILENO; stdio=TRUE; fprintf(statfp,"No socket descriptor specified, using STDIO\n"); telnet=FALSE; #else fprintf(statfp,"!No socket descriptor specified\n\n"); fprintf(errfp,usage); bail(1); #endif } #ifdef __unix__ else statfp=stdout; #endif if(!(mode&(SEND|RECV))) { fprintf(statfp,"!No command specified\n\n"); fprintf(statfp,usage); bail(1); } if(mode&(SEND|XMODEM) && !fnames) { /* Sending with any or recv w/Xmodem */ fprintf(statfp,"!Must specify filename or filelist\n\n"); fprintf(statfp,usage); bail(1); } #ifdef __unix__ if(stdio) { struct termios term; memset(&term,0,sizeof(term)); cfsetispeed(&term,B19200); cfsetospeed(&term,B19200); term.c_iflag &= ~(IMAXBEL|IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); term.c_oflag &= ~OPOST; term.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); term.c_cflag &= ~(CSIZE|PARENB); term.c_cflag |= CS8; atexit(resetterm); tcgetattr(STDOUT_FILENO, &origterm); tcsetattr(STDOUT_FILENO, TCSADRAIN, &term); } #endif /* Code disabled. Why? ToDo */ /* if(mode&RECVDIR) backslash(fname[0]); */ if(!winsock_startup()) bail(-1); /* Enable the Nagle Algorithm */ #ifdef __unix__ if(!stdio) { #endif lprintf(LOG_DEBUG,"Setting TCP_NODELAY to %d",tcp_nodelay); setsockopt(sock,IPPROTO_TCP,TCP_NODELAY,(char*)&tcp_nodelay,sizeof(tcp_nodelay)); #ifdef __unix__ } #endif if(!socket_check(sock, NULL, NULL, 0)) { lprintf(LOG_WARNING,"No socket connection"); bail(-1); } if((dszlog=getenv("DSZLOG"))!=NULL) { if((logfp=fopen(dszlog,"w"))==NULL) { lprintf(LOG_WARNING,"Error %d opening DSZLOG file: %s",errno,dszlog); bail(-1); } } /* Install Ctrl-C/Break signal handler here */ #if defined(_WIN32) SetConsoleCtrlHandler(ControlHandler, TRUE /* Add */); #elif defined(__unix__) signal(SIGQUIT,break_handler); signal(SIGINT,break_handler); signal(SIGTERM,break_handler); signal(SIGHUP,SIG_IGN); /* Don't die on SIGPIPE */ signal(SIGPIPE,SIG_IGN); #endif #if !SINGLE_THREADED _beginthread(output_thread,0,NULL); #endif if(mode&RECV) retval=receive_files(fname_list, fnames); else retval=send_files(fname_list, fnames); #if !SINGLE_THREADED lprintf(LOG_DEBUG,"Waiting for output buffer to empty... "); if(WaitForEvent(outbuf_empty,5000)!=WAIT_OBJECT_0) lprintf(LOG_DEBUG,"FAILURE"); #endif terminate=TRUE; /* stop output thread */ /* Code disabled. Why? ToDo */ /* sem_post(outbuf.sem); sem_post(outbuf.highwater_sem); */ fprintf(statfp,"Exiting - Error level: %d, flows: %u, select_errors=%u" ,retval, flows, select_errors); fprintf(statfp,"\n"); bail(retval); }
__declspec(dllexport) void __cdecl VDDDispatch(void) { char str[512]; DWORD count; DWORD msgs; int retval; int node_num; BYTE* p; vdd_status_t* status; static DWORD writes; static DWORD bytes_written; static DWORD reads; static DWORD bytes_read; static DWORD inbuf_poll; static DWORD online_poll; static DWORD status_poll; static DWORD vdd_yields; static DWORD vdd_calls; VDD_IO_HANDLERS IOHandlers = { NULL }; static VDD_IO_PORTRANGE PortRange; retval=0; node_num=getBH(); lprintf(LOG_DEBUG,"VDD_OP: (handle=%d) %d (arg=%X)", getAX(),getBL(),getCX()); vdd_calls++; switch(getBL()) { case VDD_OPEN: sscanf("$Revision: 1.40 $", "%*s %s", revision); lprintf(LOG_INFO,"Synchronet Virtual Device Driver, rev %s %s %s" ,revision, __DATE__, __TIME__); #if 0 sprintf(str,"sbbsexec%d.log",node_num); fp=fopen(str,"wb"); #endif sprintf(str,"\\\\.\\mailslot\\sbbsexec\\wr%d",node_num); rdslot=CreateMailslot(str ,0 //LINEAR_RX_BUFLEN /* Max message size (0=any) */ ,MAILSLOT_WAIT_FOREVER /* Read timeout */ ,NULL); if(rdslot==INVALID_HANDLE_VALUE) { lprintf(LOG_ERR,"!VDD_OPEN: Error %d opening %s" ,GetLastError(),str); retval=1; break; } sprintf(str,"\\\\.\\mailslot\\sbbsexec\\rd%d",node_num); wrslot=CreateFile(str ,GENERIC_WRITE ,FILE_SHARE_READ ,NULL ,OPEN_EXISTING ,FILE_ATTRIBUTE_NORMAL ,(HANDLE) NULL); if(wrslot==INVALID_HANDLE_VALUE) { lprintf(LOG_ERR,"!VDD_OPEN: Error %d opening %s" ,GetLastError(),str); retval=2; break; } if(RingBufInit(&rdbuf, RINGBUF_SIZE_IN)!=0) { retval=3; break; } sprintf(str,"sbbsexec_hungup%d",node_num); hungup_event=OpenEvent( EVENT_ALL_ACCESS, /* access flag */ FALSE, /* inherit flag */ str); /* pointer to event-object name */ if(hungup_event==NULL) { lprintf(LOG_ERR,"!VDD_OPEN: Error %d opening %s" ,GetLastError(),str); retval=4; break; } sprintf(str,"sbbsexec_hangup%d",node_num); hangup_event=OpenEvent( EVENT_ALL_ACCESS, /* access flag */ FALSE, /* inherit flag */ str); /* pointer to event-object name */ if(hangup_event==NULL) { lprintf(LOG_WARNING,"!VDD_OPEN: Error %d opening %s" ,GetLastError(),str); } status_poll=0; inbuf_poll=0; online_poll=0; yields=0; lprintf(LOG_INFO,"Yield interval: %f milliseconds", yield_interval); if(virtualize_uart) { lprintf(LOG_INFO,"Virtualizing UART (0x%x, IRQ %u)" ,uart_io_base, uart_irq); IOHandlers.inb_handler = uart_rdport; IOHandlers.outb_handler = uart_wrport; PortRange.First=uart_io_base; PortRange.Last=uart_io_base + UART_IO_RANGE; VDDInstallIOHook((HANDLE)getAX(), 1, &PortRange, &IOHandlers); interrupt_event=CreateEvent(NULL,FALSE,FALSE,NULL); InitializeCriticalSection(&interrupt_mutex); _beginthread(interrupt_thread, 0, NULL); } lprintf(LOG_DEBUG,"VDD_OPEN: Opened successfully (wrslot=%p)", wrslot); _beginthread(input_thread, 0, NULL); retval=0; break; case VDD_CLOSE: lprintf(LOG_INFO,"VDD_CLOSE: rdbuf=%u " "status_poll=%u inbuf_poll=%u online_poll=%u yields=%u vdd_yields=%u vdd_calls=%u" ,RingBufFull(&rdbuf),status_poll,inbuf_poll,online_poll ,yields,vdd_yields,vdd_calls); lprintf(LOG_INFO," read=%u bytes (in %u calls)",bytes_read,reads); lprintf(LOG_INFO," wrote=%u bytes (in %u calls)",bytes_written,writes); if(virtualize_uart) { lprintf(LOG_INFO,"Uninstalling Virtualizaed UART IO Hook"); VDDDeInstallIOHook((HANDLE)getAX(), 1, &PortRange); } CloseHandle(rdslot); CloseHandle(wrslot); if(hungup_event!=NULL) CloseHandle(hungup_event); if(hangup_event!=NULL) CloseHandle(hangup_event); #if 0 /* This isn't strictly necessary... and possibly the cause of a NULL dereference in the input_thread */ RingBufDispose(&rdbuf); #endif status_poll=0; retval=0; break; case VDD_READ: count = getCX(); if(count != 1) lprintf(LOG_DEBUG,"VDD_READ of %d",count); p = (BYTE*) GetVDMPointer((ULONG)((getES() << 16)|getDI()) ,count,FALSE); retval=vdd_read(p, count); reads++; bytes_read+=retval; reset_yield(); break; case VDD_PEEK: count = getCX(); if(count != 1) lprintf(LOG_DEBUG,"VDD_PEEK of %d",count); p = (BYTE*) GetVDMPointer((ULONG)((getES() << 16)|getDI()) ,count,FALSE); retval=RingBufPeek(&rdbuf,p,count); reset_yield(); break; case VDD_WRITE: count = getCX(); if(count != 1) lprintf(LOG_DEBUG,"VDD_WRITE of %d",count); p = (BYTE*) GetVDMPointer((ULONG)((getES() << 16)|getDI()) ,count,FALSE); if(!WriteFile(wrslot,p,count,&retval,NULL)) { lprintf(LOG_ERR,"!VDD_WRITE: WriteFile Error %d (size=%d)" ,GetLastError(),retval); retval=0; } else { writes++; bytes_written+=retval; reset_yield(); } break; case VDD_STATUS: status_poll++; count = getCX(); if(count != sizeof(vdd_status_t)) { lprintf(LOG_DEBUG,"!VDD_STATUS: wrong size (%d!=%d)",count,sizeof(vdd_status_t)); retval=sizeof(vdd_status_t); break; } status = (vdd_status_t*) GetVDMPointer((ULONG)((getES() << 16)|getDI()) ,count,FALSE); status->inbuf_size=RINGBUF_SIZE_IN; status->inbuf_full=RingBufFull(&rdbuf); msgs=0; /* OUTBUF FULL/SIZE */ if(!GetMailslotInfo( wrslot, /* mailslot handle */ &status->outbuf_size, /* address of maximum message size */ &status->outbuf_full, /* address of size of next message */ &msgs, /* address of number of messages */ NULL /* address of read time-out */ )) { lprintf(LOG_ERR,"!VDD_STATUS: GetMailSlotInfo(%p) failed, error %u (msgs=%u, inbuf_full=%u, inbuf_size=%u)" ,wrslot ,GetLastError(), msgs, status->inbuf_full, status->inbuf_size); status->outbuf_full=0; status->outbuf_size=DEFAULT_MAX_MSG_SIZE; } else lprintf(LOG_DEBUG,"VDD_STATUS: MailSlot maxmsgsize=%u, nextmsgsize=%u, msgs=%u" ,status->outbuf_size ,status->outbuf_full ,msgs); if(status->outbuf_full==MAILSLOT_NO_MESSAGE) status->outbuf_full=0; status->outbuf_full*=msgs; /* ONLINE */ if(WaitForSingleObject(hungup_event,0)==WAIT_OBJECT_0) status->online=0; else status->online=1; retval=0; /* success */ break; case VDD_INBUF_PURGE: RingBufReInit(&rdbuf); retval=0; break; case VDD_OUTBUF_PURGE: lprintf(LOG_WARNING,"!VDD_OUTBUF_PURGE: NOT IMPLEMENTED"); retval=0; break; case VDD_INBUF_FULL: retval=RingBufFull(&rdbuf); inbuf_poll++; break; case VDD_INBUF_SIZE: retval=RINGBUF_SIZE_IN; break; case VDD_OUTBUF_FULL: if(!GetMailslotInfo( wrslot, /* mailslot handle */ NULL, /* address of maximum message size */ &retval, /* address of size of next message */ &msgs, /* address of number of messages */ NULL /* address of read time-out */ )) retval=0; if(retval==MAILSLOT_NO_MESSAGE) retval=0; retval*=msgs; break; case VDD_OUTBUF_SIZE: if(!GetMailslotInfo( wrslot, /* mailslot handle */ &retval, /* address of maximum message size */ NULL, /* address of size of next message */ NULL, /* address of number of messages */ NULL /* address of read time-out */ )) retval=DEFAULT_MAX_MSG_SIZE; break; case VDD_ONLINE: if(WaitForSingleObject(hungup_event,0)==WAIT_OBJECT_0) retval=0; else retval=1; online_poll++; break; case VDD_YIELD: /* forced yield */ vdd_yields++; yield(); break; case VDD_MAYBE_YIELD: /* yield if YieldInterval is enabled and expired */ maybe_yield(); break; case VDD_LOAD_INI_FILE: /* Load and parse settings file */ { FILE* fp; char cwd[MAX_PATH+1]; /* Load exec/sbbsexec.ini first (setting default values) */ count = getCX(); p = (BYTE*)GetVDMPointer((ULONG)((getES() << 16)|getDI()) ,count,FALSE); iniFileName(ini_fname, sizeof(ini_fname), p, INI_FILENAME); if((fp=fopen(ini_fname,"r"))!=NULL) { ini=iniReadFile(fp); fclose(fp); parse_ini(ROOT_SECTION); } /* Load cwd/sbbsexec.ini second (over-riding default values) */ GetCurrentDirectory(sizeof(cwd),cwd); iniFileName(ini_fname, sizeof(ini_fname), cwd, INI_FILENAME); if((fp=fopen(ini_fname,"r"))!=NULL) { ini=iniReadFile(fp); fclose(fp); parse_ini(ROOT_SECTION); } } break; case VDD_LOAD_INI_SECTION: /* Parse (program-specific) sub-section of settings file */ count = getCX(); p = (BYTE*)GetVDMPointer((ULONG)((getES() << 16)|getDI()) ,count,FALSE); parse_ini(p); break; case VDD_DEBUG_OUTPUT: /* Send string to debug output */ count = getCX(); p = (BYTE*)GetVDMPointer((ULONG)((getES() << 16)|getDI()) ,count,FALSE); lputs(LOG_INFO, p); break; case VDD_HANGUP: hangup(); break; default: lprintf(LOG_ERR,"!UNKNOWN VDD_OP: %d",getBL()); break; } setAX((WORD)retval); }
//***************************************************************************** // // Provides a scribble pad using the display on the Intelligent Display Module. // //***************************************************************************** int main(void) { uint32_t ui32SysClock; // // Run from the PLL at 120 MHz. // ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); // // Configure the device pins. // PinoutSet(); // // Initialize the display driver. // Kentec320x240x16_SSD2119Init(ui32SysClock); // // Initialize the graphics context. // GrContextInit(&g_sContext, &g_sKentec320x240x16_SSD2119); // // Draw the application frame. // FrameDraw(&g_sContext, "scribble"); // // Print the instructions across the top of the screen in white with a 20 // point san-serif font. // GrContextForegroundSet(&g_sContext, ClrWhite); GrContextFontSet(&g_sContext, g_psFontCmss20); GrStringDrawCentered(&g_sContext, "Touch the screen to draw", -1, GrContextDpyWidthGet(&g_sContext) / 2, ((GrContextDpyHeightGet(&g_sContext) - 32) / 2) + 14, 0); // // Flush any cached drawing operations. // GrFlush(&g_sContext); // // Set the color index to zero. // g_ui32ColorIdx = 0; // // Initialize the message queue we use to pass messages from the touch // interrupt handler context to the main loop for processing. // RingBufInit(&g_sMsgQueue, (uint8_t *)g_psMsgQueueBuffer, (MSG_QUEUE_SIZE * sizeof(tScribbleMessage))); // // Initialize the touch screen driver. // TouchScreenInit(ui32SysClock); // // Set the touch screen event handler. // TouchScreenCallbackSet(TSHandler); // // Loop forever. All the drawing is done in the touch screen event // handler. // while(1) { // // Process any new touchscreen messages. // ProcessTouchMessages(); } }