Category : Files from Magazines
Archive   : DDJ0389.ZIP
Filename : TINYCO.C

 
Output of file : TINYCO.C contained in archive : DDJ0389.ZIP

#: 25 S0/EasyPlex
02-Mar-89 14:49 EST
Sb: tinycomm.c
Fm: Al Stevens [71101,1262]


#include
#include
#include
#include
#include
#include
#include "serial.h"
#include "modem.h"

#if COMPILER==MSOFT
#define getch mscgetch
#define putch mscputch
#define gets mscgets
static void mscgets(char *);
static int mscgetch(void);
static void mscputch(int);
static void gotoxy(int,int);
static void clrscr(void);
#endif
int keyhit(void);

#define TMSG "\r\n\r\nTINYCOMM: << %s >>\r\n"
#define LOGFILE "tinycomm.log"
#define ESC 27
extern char PHONENO[];
extern int COMPORT;
static FILE *logfp;
static FILE *uploadfp;
static int running=1;
static int connected,answering;
static int forcekey, forcecom, forcemenu;
static union REGS rg;
static void tinymenu(void);
static void log(int);
static void upload(void);

void main(int argc, char *argv[])
{
int c;
if (argc > 1)
COMPORT = atoi(argv[1]);
if (argc > 2)
strcpy(PHONENO, argv[2]);
initmodem();
while (running) {
if (!connected || forcemenu) {
forcemenu = 0;
tinymenu(); /* display and process the menu */
}
/* ------ poll for a keystroke --------- */
if (keyhit() || forcekey) {
c = forcekey ? forcekey : getch();
forcekey = (answering && c == '\r') ? '\n' : 0;
if (c == ESC)
tinymenu();
else if (connected) {
if (answering)
log(c); /* answerer echos his own key */
writecomm(c); /* transmit the keystroke */
}
}
/* ------- poll for serial input ---------- */
if (input_char_ready() || forcecom) {
c = forcecom ? forcecom : readcomm();
forcecom = (answering && c == '\r') ? '\n' : 0;
log(c); /* display the serial input */
if (answering)
writecomm(c); /* answerer echos serial input */
}
}
release_modem();
}

static void tinymenu(void)
{
int c;
clrscr();
gotoxy(20,5), cprintf("------ TINYCOMM Menu ------");
gotoxy(20,7), cprintf("P-lace Call");
gotoxy(20,8), cprintf("A-nswer Call");
gotoxy(20,9), cprintf("H-ang Up");
gotoxy(20,10), cprintf("L-og Input %s",
logfp == NULL ? "[OFF]" : "[ON]");
gotoxy(20,11), cprintf("S-end Message File");
gotoxy(20,12), cprintf("T-elephone Number (%s)",
PHONENO[0] ? PHONENO : "???-????");
gotoxy(20,13), cprintf("E-xit to DOS");
gotoxy(20,14), cprintf(connected ?
"Esc to return to session" : "");
gotoxy(20,16), cprintf("Enter Selection > ");
c = getch();
putch(toupper(c));
switch (toupper(c)) {
case 'P': /* Place a call */
if (!connected) {
cprintf(TMSG, "Dialing");
initmodem(); /* initialize the modem */
placecall(); /* dial the phone number */
connected = 1;
cprintf(TMSG, "Esc for the menu");
}
break;
case 'A': /* Answer a call */
if (!connected) {
cprintf(TMSG, "Waiting");
initmodem(); /* initialize the modem */
answercall(); /* wait for an incoming call */
answering = connected = 1;
cprintf(TMSG, "Esc for the menu");
}
break;
case ESC: /* Return to the session */
if (connected)
cprintf(TMSG, "Esc for the menu");
break;
case 'L': /* Log input on/off*/
if (logfp == NULL)
logfp = fopen(LOGFILE, "a");
else {
fclose(logfp);
logfp = NULL;
}
forcemenu++;
break;
case 'E': /* Exit to DOS */
cprintf(TMSG, "Exiting");
running = 0;
case 'H': /* Hang up */
if (connected) {
cprintf(TMSG, "Hanging up");
disconnect();
connected = answering = 0;
}
break;
case 'S': /* Send a message file */
upload();
break;
case 'T': /* Change the phone number */
cprintf(TMSG, "Enter Telephone Number: ");
gets(PHONENO);
forcemenu++;
break;
default:
putch(7);
break;
}
}

static void upload(void)
{
char filename[65];
int c = 0;
if (uploadfp == NULL && connected) {
cprintf(TMSG, "Enter file drive:path\\name > ");
gets(filename);
if ((uploadfp = fopen(filename, "r")) == NULL)
cprintf(TMSG, "Cannot open file");
else {
cprintf(TMSG, "Press Esc to stop sending file");
while ((c = fgetc(uploadfp)) != EOF) {
if (c == '\n') {
writecomm('\r');
log(answering ? '\r' : readcomm());
}
writecomm(c);
log(answering ? c : readcomm());
if (keyhit())
if (getch() == ESC) {
cprintf(TMSG, "Abandoning file");
break;
}
}
fclose(uploadfp);
uploadfp = NULL;
}
}
}

static void log(int c)
{
putch(c);
if (logfp)
fputc(c, logfp);
}

Clone functions to keep Ctrl-Break from crashing the
system by aborting before interrupt vectors get restored
-------------------------------------------------------- */
#if COMPILER==TURBOC
int keyhit()
{
rg.h.ah = 1;
int86(0x16, &rg, &rg);
return ((rg.x.flags & 0x40) == 0);
}
#else
static int mscgetch(void)
{
rg.h.ah = 0;
int86(0x16, &rg, &rg);
return rg.h.al;
}

static void mscputch(int c)
{
rg.x.ax = 0x0e00 | (c & 255);
rg.x.bx = 0;
int86(0x10, &rg, &rg);
}

static void gotoxy(int x, int y)
{
rg.h.ah = 2;
rg.x.bx = 0;
rg.h.dh = (char) y-1;
rg.h.dl = (char) x-1;
int86(0x10, &rg, &rg);
}

static void clrscr(void)
{
rg.x.ax = 0x0600;
rg.h.bh = 7;
rg.x.cx = 0;
rg.x.dx = (24 << 8) + 79;
int86(0x10, &rg, &rg);
}

static void mscgets(char *s)
{
int c;
while (1) {
if ((c = mscgetch()) == '\r')
break;
mscputch(c);
*s++ = (char) c;
}
*s = '\0';
}
#endif



Action!
ÿ



  3 Responses to “Category : Files from Magazines
Archive   : DDJ0389.ZIP
Filename : TINYCO.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/