int ssWriteRELFile(ST_FILE *pstFile, void *pvBuffer, unsigned int uiBuffSize, unsigned int uiRecNo) { char command[40]; char cbm_filename[40]; int siRet=0; int channel, hi, lo; channel=3+96; sprintf(cbm_filename,"0:%s,l,%c", pstFile->szFileName, uiBuffSize); siRet = cbm_open( 15, pstFile->ucDeviceNo, 15, NULL); siRet = cbm_open( 2, pstFile->ucDeviceNo, 3, cbm_filename); hi=(uiRecNo/256); lo=uiRecNo-(hi*256); sprintf(command, "p%c%c%c", channel, lo, hi); siRet=cbm_write( 15, command, strlen(command)); siRet = cbm_write( 2, pvBuffer, uiBuffSize); cbm_close(15); cbm_close(2); return siRet; }
unsigned char getData() { bordercolor(2); //Make sure all devices are closed before opening again cbm_close( 2 ); //If its a local file, use device 8 if(url[0]=='/'){ //remove leading '/' and add a ',s' to allow openning of a seq file memmove(url, url+1, strlen(url)); strcat(url,",s"); cbm_close( 8 ); cbm_open( 2, 8, 2, url ); } //Get local data for an already formated URL else if(url[strlen(url)-2]==',' && url[strlen(url)-1]=='s'){ cbm_close( 8 ); cbm_open( 2, 8, 2, url ); } //For remote files use device 7 (Flyer) else{ cbm_close( 7 ); // if( cbm_open( 7, 7, 15, "" ) != 0 ) { cputs("Flyer not connected!"); } cbm_open( 2, 7, 2, url ); cbm_write( 7, "http-transact:2",15); } //Clear the input buffer: memset(&sRecvBuf[0], 0, sizeof(sRecvBuf)); //Read a chunk (or all if small) of the file: cbm_read( 2, sRecvBuf, sizeof(sRecvBuf)); bordercolor(0); return(1); }
void print_the_buffer(void) { BYTE c; RETRY: c = cbm_open((BYTE)4, (BYTE)4, (BYTE)0, NULL); if (c != 0) { c128_perror(c, "cbm_open(printer)"); if (retry_or_quit() == 'q') exit(1); goto RETRY; } c = cbm_write((BYTE)4, print_buffer, strlen(print_buffer)); if (c != strlen(print_buffer)) { c128_perror(c, "write(printer)"); if (retry_or_quit() == 'q') exit(1); goto RETRY; } cbm_close((BYTE)4); log_file(print_buffer); }
/* * Flushes the current log buffer to disk. Called either by log_file() when one * entire log file is completed or interactively. * */ void log_flush(void) { int c; static char filename[8]; sprintf(filename, "log-%d", log_num); /* If we have written to this logfile before, we need to remove it first */ if (log_heap_flushed > 0) _sysremove(filename); if ((c = cbm_open((BYTE)8, (BYTE)8, (BYTE)1, filename)) != 0) { c128_perror(c, "cbm_open(log)"); exit(1); } c = cbm_write((BYTE)8, log_heap_buf, log_heap_offset); if (c != log_heap_offset) { textcolor(TC_LIGHT_RED); cprintf("\r\nCould not save logfile (wrote %d bytes, wanted %d bytes), please make sure the floppy is not full!\n", c, log_heap_offset); c128_perror(c, "cbm_write"); exit(1); } cbm_close((BYTE)8); log_heap_flushed = log_heap_offset; }
int networkSetup(unsigned short drive) { unsigned char tmp[40]; unsigned short cnt, ret; CTK_CFG_REC mycnf; memset(&mycnf, 0, sizeof(CTK_CFG_REC)); do { /* 1234567890123456789012345678901234567890 */ printf("\n* BBS network Setup\n"); printf("\nHost IP : "); gets(tmp); nibbleIP(tmp, mycnf.srvip); printf("Netmask : "); gets(tmp); nibbleIP(tmp, mycnf.netmask); printf("Gateway IP : "); gets(tmp); nibbleIP(tmp, mycnf.gateway); printf("DNS IP : "); gets(tmp); nibbleIP(tmp, mycnf.nameserv); printf("Mem addr. ($de08) : "); gets(tmp); sscanf(tmp, "%x", &mycnf.mem); printf("Driver (cs8900a.eth): "); gets(tmp); strcpy(mycnf.driver, tmp); printf("Write to drive # (8): "); gets(tmp); sscanf(tmp, "%d", &drive); printf("\nNetwork data correct (y/n)? "); } while (getchar() != 'y'); strcpy(tmp, "@0:contiki.cfg,u,w"); ret = cbm_open(2, drive, CBM_WRITE, tmp); if(! ret) { for(cnt = 0; cnt <= 3; cnt++) cbm_write(2, &mycnf.srvip[cnt], sizeof(unsigned char)); for(cnt = 0; cnt <= 3; cnt++) cbm_write(2, &mycnf.netmask[cnt], sizeof(unsigned char)); for(cnt = 0; cnt <= 3; cnt++) cbm_write(2, &mycnf.gateway[cnt], sizeof(unsigned char)); for(cnt = 0; cnt <= 3; cnt++) cbm_write(2, &mycnf.nameserv[cnt], sizeof(unsigned char)); cbm_write(2, &mycnf.mem, sizeof(&mycnf.mem)); cbm_write(2, mycnf.driver, sizeof(mycnf.driver)); } else { printf("\n\r**error - can't write file: 'contiki.cfg'"); } cbm_close(2); return ret; }