home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
comm
/
jmodem.zip
/
JMODEM_B.C
< prev
next >
Wrap
Text File
|
1990-06-20
|
5KB
|
88 lines
/****************************************************************************/
/* FILE JMODEM_B.C */
/* Created 11-JAN-1990 Richard B. Johnson */
/* 405 Brougton Drive */
/* Beverly, Massachusetts 01915 */
/* BBS (508) 922-3166 */
/* */
/* allocate_memory(); (All memory allocation ) */
/* get port(); (Parse, get ASCII port) */
/* get_inp(); (Parse, get filename) */
/* get_fun(); (Parse, get function S,R ) */
/* get_prt(); (Convert ASCII port to numeric offset) */
/* */
/****************************************************************************/
#include <stdio.h> /* Used for _puts(); */
#if defined (TURBOC)
#include <alloc.h>
#else
#include <malloc.h> /* Used for _malloc(); */
#endif
#include <string.h> /* Used for _strcpy(), etc */
#include "jmodem.h" /* JMODEM primatives */
/****************************************************************************/
/* Allocate memory */
/****************************************************************************/
unsigned char *allocate_memory(buf_len)
unsigned short buf_len;
{
register unsigned char *memory;
memory = (unsigned char *) malloc( buf_len );
if (!memory)
puts(malfail);
return memory;
}
/****************************************************************************/
/* Get filename */
/****************************************************************************/
unsigned char *get_inp (argc, argv)
unsigned short argc;
register char *argv[];
{
register char *name; /* Filename string pointer */
if (argc > 2) /* Check command-line parameters */
{
name = argv[2]; /* Copy the file name pointer */
do
{ /* Cheap _toupper() */
if ( ( *name < 0x7B ) /* Check upper limit */
&& ( *name > 0x60 ) ) /* Check lower limit */
*name &= 0x5F; /* Map to upper case */
} while (*(++name)); /* Until the NULL character */
return argv[2]; /* Return a pointer to the name */
}
return NULL;
}
/****************************************************************************/
/* Get function (S or R) */
/****************************************************************************/
unsigned char get_fun(argc,argv)
unsigned short argc;
register char *argv[];
{
if (argc > 2) /* Command-line parameters */
{
*argv[1] &= 0x5F; /* Map to upper case */
if (*argv[1] == 'S' || *argv[1] == 'R') /* Check valid parameters */
return *argv[1]; /* Either 'R' or 'S' */
}
return NULL; /* Else NULL */
}
/****************************************************************************/
/* Get port ASCII number (1 - 4) */
/****************************************************************************/
unsigned short get_port(argc,argv)
unsigned short argc;
register char *argv[];
{
if (argc > 2) /* Command-line parameters */
{
if (*(++argv[1]) > '0' && *argv[1] < '5') /* Check for valid ports */
return ((unsigned short)
*argv[1] - '0'); /* Return binary port value */
}
return NULL;
}
/****************************************************************************/
/************************ E N D O F M O D U L E **************************/