Hello,I have this C program which is equivalent to the com port.Useful for data logging from the sensors.It consists of the .c file and two header files cport.h and xmodem.h .The code compiles fine but there are lot of linker errors.I tried a lot ,pulled my hair but no use.Can anyone help me solve this out.Thanks in advance

comdemo.c

/* 
// COMDEMO.C
//
// Serial communications demo program for the Cport communications library.
// 
// Copyright (c) 1993 Bri Productions
//
*/

//#include "E:\robotics\CPORT20\cport.h"
//#include "E:\robotics\CPORT20\xmodem.h"
#include <cport.h>
#include <xmodem.h>
#include <conio.h>
#include <stdlib.h>      
#include <dos.h>
#include <bios.h>
#include <ctype.h>
#include <stdio.h>


/*
//-------------------------------------
//
// Microsoft portability
//
//-------------------------------------
*/
#if M_I86

#include <stdarg.h>
#include <time.h>
#include <graph.h>

#define	BLUE		 1
#define  LIGHTGRAY 7

#define 	bioskey(a)		 _bios_keybrd(a)
#define	gotoxy(x,y)		 _settextposition((short)(y), (short)(x))
#define	clrscr()			 _clearscreen(_GWINDOW)
#define	textattr(a)		 _settextcolor((short)((a)&0xf)); _setbkcolor((short)((a)>>4))
#define	window(a,b,c,d) _settextwindow((short)(b),(short)(a),(short)(d),(short)(c))
#define  cputs(s)			 _outtext(s)

int  wherex (void);
int  wherey (void);
void delay  (clock_t milliseconds);
void clreol (void);

#endif

/* 
//-------------------------------------
//
// Queue sizes and thresholds
//
//-------------------------------------
*/
#define  TXQ      4096
#define  RCVQ     4096
#define  THRESH   (RCVQ * 3 / 4)


/*
//-------------------------------------
// 
// numbers of parameters
//
//-------------------------------------
*/
#define  NUM_COM     4             
#define  NUM_BAUD    9
#define  NUM_MODE    2
#define  NUM_HND     4


/*
//-------------------------------------
// 
// scan codes
//
//-------------------------------------
*/
#define  A     0x1E00
#define  B     0x3000
#define  C     0x2E00
#define  D     0x2000
#define  E     0x1200
#define  F     0x2100
#define  G     0x2200
#define  H     0x2300
#define  I     0x1700
#define  M     0x3200
#define  N     0x3100
#define  O     0x1800
#define  P     0x1900
#define  R     0x1300
#define  S     0x1F00
#define  W     0x1100
#define  X     0x2D00
#define  PGDN  0x5100
#define  PGUP  0x4900


#define COM3A  PORT2|IRQ5


/*
//-------------------------------------
//
// text attributes
//
//-------------------------------------
*/
#define  NORM  0x07
#define  BOLD  0x08
#define  FAINT 0xF7
#ifndef  BLINK
#define  BLINK 0x80
#endif
#define  REVRS 0x77
#define  ESC   0x1b


/*
//-------------------------------------
//
// parameter constants
//
//-------------------------------------
*/
const unsigned id[]    = { COM1, COM2, COM3A, COM4 };
const int      baud[]   = { B115200, B57600, B38400, B19200, 
                            B9600, B4800, B2400, B1200, B300 };
const byte     mode[]   = { W8|S1|NONE, W7|S1|EVEN };
const byte     hndshk[] = { OFF ,SOFT, HARD, HARD|SOFT };

/*
//-------------------------------------
//
// parameter indexes
//
//-------------------------------------
*/
struct indx{
   byte id;
   byte baud;
   byte mode;
   byte ansi;
   byte hndshk;
   byte lf;
 byte echo;
   }indx = { 0, 3, 0, 1, 0, 0, 0 };


/*
//-------------------------------------
//
// parameter messages
//
//-------------------------------------
*/
struct{
   char *id    [NUM_COM ];    
   char *baud  [NUM_BAUD];   
   char *mode  [NUM_MODE];     
   char *ansi  [2];
   char *hndshk[NUM_HND];
   char *lf    [2];
   }msg={   
            { "COM1", "COM2", "COM3", "COM4" },
            { "115k", "57600", "38400", "19200", "9600", 
              "4800", "2400", "1200", "300" },
            { "8-1-N", "7-1-E" }, 
            { "TTY", "ANSI" },
            { "NONE", "SOFT", "HARD", "BOTH" },
            { "  ", "LF" }
        };


/*
//-------------------------------------
//
// screen coordinates
//
//-------------------------------------
*/
static int x = 1;                      /* cursor location               */
static int y = 1;
static byte attrib = NORM;             /* present text attribute        */
#define  ERR_X    41                   /* error message x coordinate    */
#define  STAT_X   60                   /* status message x coordinate   */


/*
//-------------------------------------
//
// function prototypes
//
//-------------------------------------
*/
static void     Init        (void);
static void     Uninit      (void);
static void     NewParam    (void);
static void     Ansi        (void);
static void     CheckError  (void);
static void     CheckStatus (void);
static void     Upload      (void);
static void     Download    (void);
static int      callback   (int msg, unsigned param);
static void     put_ch  (char c);



char  *Xmsg[] = { "\r\ntransfer successful",
                  "\r\nfile error",
                  "\r\ntransfer canceled",
                  "\r\nmemory error"
               };

struct C_param param;
COM com;

/*
//-------------------------------------
//
// main()
//
//-------------------------------------
*/
void main(void)  
{     
char c;
unsigned key;
byte dtr = ON;


      /* initialize  */

   Init();   

   while(1)
   {
      
         /* Poll the keyboard buffer for available keystrokes.       */
         /* Meanwhile, the receive queue is checked for available    */
         /* characters, check for errors and check the modem status  */

      while(!bioskey(1))         
      {

            /* If a character(s) is available in the receive queue,  */
            /* fetch it. If it is and escape character, it must be   */
            /* check to see if it is the start of an ansi sequence.  */
            /* Otherwise the cursor position is updated, and the     */
            /* character is printed.                                 */
         
         if(ComLenRx(com))        
         {
            c = ComGetc(com);      

            if(c == ESC && indx.ansi)        
            {
               Ansi();  
               gotoxy(x, y);
               continue;
            }

          put_ch(c);            

         }


            /* Check for errors and changes in the modem status   */

         CheckError();       
         CheckStatus();      
      }
   

         /* When a key is pressed, the key is fetched, and the    */
         /* keyboard flags are checked to see if the alt key was  */
         /* also pressed. If the alt key was pressed, we must     */
         /* check if the key is a valid command, and if so        */
         /* process it accordingly                                */

      key = bioskey(0);                   
      if(!(key & 0x00ff))  
      {
         switch(key)                      
         {

               /* exit  */

            case X:                  
               Uninit();


               /* Next com port  */

            case C:                  
               ComParam(com, &param);
               ComClose(com);
               do
               {
                  indx.id++;             
                  indx.id %= NUM_COM;    
                  param.id = id[indx.id];
               }
               while((com = ComOpenS(&param)) == NULL);
               NewParam(); 
               break;


               /* Next baud rate */

            case B:                  
               indx.baud++;            
               indx.baud %= NUM_BAUD;  
               ComBaud(com, baud[indx.baud]);
               NewParam(); 
               break;


               /* Next word length  */

            case M:                    
               indx.mode++;            
               indx.mode %= NUM_MODE;  
               ComMode(com, mode[indx.mode]);
               NewParam(); 
               break;


               /* Toggle ansi terminal */

            case A:
               indx.ansi ^= 1;
               NewParam();
               break;


               /* Next handshake scheme   */

            case H:
               indx.hndshk++;
               indx.hndshk %= NUM_HND;
               ComHandshake(com, hndshk[indx.hndshk], THRESH);
               NewParam();
               break;


              /* Echo */

            case E:
               indx.echo ^= 1;
               break;


               /* Toggle LF append  */

            case N:
               indx.lf ^= 1;
               NewParam();
               break;

               /* Initialize hayes modem  */

            case I:                    
               ComPuts(com, "ATZ\r\n");         
               break;


               /* Hayes modem dial command   */

            case D:                    
               ComPuts(com, "ATDT");           
               break;


               /* Hayes modem hang up command   */

            case G:                    
               ComPuts(com, "+++");
               delay(3000);
               ComPuts(com, "ATH0\r\n");
               break;

            case PGUP:
               Upload();
               break;

            case PGDN:
               Download();
               break;

            case R:
               dtr ^= 1;
               ComDtr(com, dtr);
               break;

            default:                   
               continue;
         }
      }


         /* If the key was not a command, put the character in the   */
         /* transmit queue. If the character is a carriage return,   */
         /* append a line feed to it just in case.                   */

      else
      {
         ComPutc(com, (char)key);       
   if(indx.echo)
    put_ch((char)key);
         CheckStatus();      
         CheckError();       
      }
   }
}


/*
//-------------------------------------
//
// Modified putch()
//
//-------------------------------------
*/
void put_ch(char c)
{

 	gotoxy(x, y);
	putch(c);

   if(c == '\r' && indx.lf)
         putch('\n');

   if(c == '\b')
      printf(" \b");

   x = wherex();        
   y = wherey();

#ifdef M_I86
	if(x == 1 && y == 25)
		_scrolltextwindow(1);
#endif
}


/*
//-------------------------------------
//
// Initialize
//
//-------------------------------------
*/
void Init(void)
{
FILE *fp;



      /* If an initialization file exists, load it.   */

   fp = fopen("comdemo.ini", "rb");
   if(fp)
      fread(&indx, sizeof(struct indx), 1, fp);



      /* Set up the screen */

   clrscr();                        
   textattr(BLUE|(LIGHTGRAY<<4));   
   gotoxy(1,25);                    
   cprintf(" %4s ³%5s %s ³ %-4s ³ %-4s ³ %2s ³"
           " no errors    ³ CTS=  DSR=   RI=  DCD=  ",
                                    msg.id[indx.id],
                                    msg.baud[indx.baud],
                                    msg.mode[indx.mode],
                                    msg.ansi[indx.ansi],
                                    msg.hndshk[indx.hndshk],
                                    msg.lf[indx.lf]);


      /* Initialize the serial port to the default parameters,    */
      /* set the timeout and set the DTR and RTS lines.           */

   com = ComOpen(id[indx.id], baud[indx.baud], mode[indx.mode], RCVQ, TXQ);


      /* restore the normal screen  */

   textattr(LIGHTGRAY);               
   window(1,1,80,24);                 
}


/*
//-------------------------------------
//
// terminate
//
//-------------------------------------
*/
void Uninit(void)
{
FILE *fp;


      /* Store the present parameters in an .ini file so the program */
      /* will remember next time it is executed.                     */

   fp = fopen("comdemo.ini", "wb");
   if(fp)
      fwrite(&indx, sizeof(struct indx), 1, fp);


   ComClose(com);             
   system("cls");     
   puts("\nÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸"
        "\n³             Cport v2.0  -  Copyright (c) 1993 Bri Productions               ³"
        "\nÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´"
        "\n³ Bri Productions, P.O. Box 7121, Fremont, CA 94537-7121, USA, (510) 794-0616 ³"
        "\nÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ;"
        );  
   exit(0);                
}


/*
//-------------------------------------
//
// new parameter
//
//-------------------------------------
*/
void NewParam(void)
{

      /* Update the status line with the new parameters  */

   window(1,25, 80, 25);            
   textattr(BLUE|(LIGHTGRAY<<4));   
   cprintf(" %4s ³%5s %s ³ %-4s ³ %-4s ³ %s ³", 
                                    msg.id[indx.id],
                                    msg.baud[indx.baud],
                                    msg.mode[indx.mode],
                                    msg.ansi[indx.ansi],
                                    msg.hndshk[indx.hndshk],
                                    msg.lf[indx.lf]);


      /* restore the normal screen  */

   textattr(attrib);                
   window(1,1,80,24);               
 gotoxy(x, y);
}


/*
//-------------------------------------
//
// ansi control sequence 
//
//-------------------------------------
*/
void Ansi(void)
{
unsigned key;
char c;
char str[10];
int Pn[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int i=0,p=0;
static int oldx=1;
static int oldy=1;
   

      /* While we are waiting for the next character, keep   */
      /* checking for keys.                                  */


   while((c = ComGetc(com)) == 0) 

   if(bioskey(1))            
   {
      key = bioskey(0);      
      ComPutc(com, (char)key);   
   }


      /* If the next character is a '[' it is probably an ansi    */
      /* sequence. If the next character is not a '[', print the  */
      /* previous escape character followed by the new character. */

   if(c != '[')                  
   {
      cprintf("\x1b%c",c);       
      return;
   }

   while(1)                            
   {

      /* Read the rest of the ansi sequence, while also checking  */
      /* for keys.                                                */

      while((c = ComGetc(com)) == 0) 
   
         if(bioskey(1))         
         {
            key = bioskey(0);           
            ComPutc(com, (char)key);        
         }


         /* If the character is numeric, store it still it it's   */
         /* ascii form                                            */

      if(isdigit(c))                      
      {
         *(str+i++) = c;                  
         continue;
      }


         /* When no more numeric characters are received, terminate  */
         /* the string and convert it to an integer, storing it in   */
         /* the parameter queue.                                     */

      *(str+i) = '\0';                
      i=0;                            
      Pn[p++] = atoi(str);            


         /* Check for the ';' delimiter   */

      if(c == ';')                    
         continue;   


         /* When no more numeric parameters are received, the     */
         /* command should be next. Now we can actually process   */
         /* the command using the stores parameters               */

      else
      {
         switch(c)              
         {


               /* (CUP) set cursor position  */
         
            case 'H':            
            case 'F':
               y = Pn[0] ? Pn[0] : 1;        
               x = Pn[1] ? Pn[1] : 1;
               return;


               /* (CUU) cursor up   */
   
            case 'A':            
               y -= Pn[0];       
               if(y < 1)         
                  y = 1;
               return;


               /* (CUD) cursor down */

            case 'B':            
               y += Pn[0];       
               if(y > 24)        
                  y = 24;
               return;


               /* (CUF) cursor forward */

            case 'C':            
               x += Pn[0];       
               if(x >80)         
                  x = 80;
               return;


               /* (CUB) cursor backward   */

            case 'D':             
               x -= Pn[0];       
               if(x < 1)
                  x = 1;
               return;
               

               /* (SCP) save cursor position */

            case 's':            
               oldx = x;         
               oldy = y;
               return;


               /* (RCP) restore cursor position */

            case 'u':            
               x = oldx;
               y = oldy;
               return;


               /* clear screen   */

            case 'J':            
               if(Pn[0] == 2)
               {
                  clrscr();
                  x=1;
                  y=1;
               }
               else 
               {
                  window(1,wherey(),80,24);                 
                  clrscr();
                  window(1,1,80,24);                 
                  gotoxy(x, y);
               }
               return;


               /* (EL) erase line   */

            case 'K':            
               clreol();
               return;
         

               /* An attribute command is more elaborate than the    */
               /* others because it may have many numeric parameters */

            case 'm':                        
               for(i=0; i<p; i++)            
               {


                     /* values from 30 to 37 define the foreground color   */

                  if(Pn[i] >= 30 && Pn[i] <= 37)  
                  {
                     attrib &= 0xf8;
                     attrib |= (Pn[i] - 30);
                  }


                     /* values from 40 to 47 define the background color   */

                  if(Pn[i] >= 40 && Pn[i] <= 47)  
                  {
                     attrib &= 0x8f;
                     attrib |= ((Pn[i] - 40) << 4);
                  }


                     /* values from 0 to 7 define the other attributes   */

                  if(Pn[i] >= 0 && Pn[i] <= 7)    
                     switch(Pn[i])
                     {

                        case 0:              
                           attrib = NORM;
                           break;

                        case 1:              
                           attrib |= BOLD;
                           break;

                        case 2:              
                           attrib &= FAINT;
                           break;

                        case 5:              
                        case 6:
                           attrib |= BLINK;
                           break;

                        case 7:                    
                           attrib ^= REVRS;
                           break;

                        default:
                           attrib = NORM;
                     }
               }


               /* The red and blue bits in the ansi standard are     */
               /* reversed relative to the IBM. Therefore, before we */
               /* set the new attributes, if these bits are in       */
               /* opposite states toggled. This must be done for     */
               /* both the foreground and background.                */
                                            
               if((attrib & 0x05) == 0x04 || (attrib & 0x05) == 0x01)
                  attrib ^= 0x05;
                                            
               if((attrib & 0x50) == 0x40 || (attrib & 0x50) == 0x10)
                  attrib ^= 0x50;

               textattr(attrib);           

            default:
               return;
         }
      }
   }
}


/* 
//-------------------------------------         
//
// check for errors
//
//-------------------------------------         
*/
void CheckError(void)
{
unsigned comerror;         
static unsigned last_error = 0;
static int err_flg = 0;
char *errmsg[]= { { "no errors    " },
                  { "break detect " }, 
                  { "frame error  " },
                  { "parity error " },
                  { "overrun      " },
                  { "rx overflow " }, 
                  { "tx overflow  " } 
                  };

   comerror = ComError(com);      


      /* Check if the error code has changed since the last call.    */
      /* if it has not, there is no need to update the status line.  */
      /* If the error code has changed, the error conditions are     */
      /* checked in the order of their priority                      */

   if(comerror != last_error)       
   {
      last_error = comerror;        

      if(comerror & BREAK)              
         err_flg = 1;                     
      
      else if(comerror & FRAMING)       
         err_flg = 2;                     

      else if(comerror & PARITY)        
         err_flg = 3;                     

      else if(comerror & OVERUN)       
         err_flg = 4;                     

      else if(comerror & RXFULL)      
         err_flg = 5;                     

      else if(comerror & TXFULL)       
         err_flg = 6;                     
   
      else                             
         err_flg = 0;


         /* Update the status line with the new information   */

      window(1,25, 80, 25);          
      textattr(BLUE|(LIGHTGRAY<<4)); 
      gotoxy(ERR_X,1);
      cprintf(errmsg[err_flg]);


         /* restore the normal screen  */

      textattr(attrib);              
      window(1,1,80,24);              
    gotoxy(x, y);
   }
}


/* 
//-------------------------------------
//
// check modem status
//
//-------------------------------------
*/
void CheckStatus(void)
{
unsigned status;
static unsigned last_status = 1;   
int i;

   status = ComStatus(com);


      /* Check if the modem status has changed since the last call.  */
      /* if it has not, there is no need to update the status line.  */
      /* If the modem status has changed, each bit is checked for    */
      /* it's condition and printed on the status line               */

   if(status != last_status)
   {
      last_status = status;
      window(1,25, 80, 25);                  
      textattr(BLUE|(LIGHTGRAY<<4));         


         /* On each iteration, i = the x coordinate in the status */
         /* line. The bits are checked for left to right. The     */
         /* statement !!(status & 0x10) resolves to 1 if the bit  */
         /* is set or 0 if the bit is clear. By adding 0x30 the   */
         /* 1 or 0 is converted to an ascii character             */

      for(i=STAT_X; i<STAT_X+6*4; i+=6)
      {
         gotoxy(i,1);                       
         cprintf("%c", !!(status & 0x10) + 0x30);   
         status >>= 1;                      
      }


         /* restore the normal screen  */

      textattr(attrib);      
      window(1,1,80,24);     
    gotoxy(x, y);
   }
}


/* 
//-------------------------------------
//
// Upload a file
//
//-------------------------------------
*/
void Upload(void)
{
char  filename[83];
int   rv;

   cputs("\r\n");
   x = wherex();
   y = wherey();

   *filename = 80;
   cputs("File name > ");
   cgets(filename);
   
   rv = XmodemTx(com, filename + 2, callback);

   clreol();
   cputs(*(Xmsg + rv));

   cputs("\r\n");
   x = wherex();
   y = wherey();
}


/* 
//-------------------------------------
//
// Download a file
//
//-------------------------------------
*/
void Download(void)
{
char  filename[83];
int   rv;


   cputs("\r\n");
   x = wherex();
   y = wherey();

   *filename = 80;
   cputs("File name for your computer > ");
   cgets(filename);
   
   rv = XmodemRx(com, filename + 2, callback);

   clreol();
   cputs(*(Xmsg + rv));

   cputs("\r\n");
   x = wherex();
   y = wherey();

}


/*
//-------------------------------------
//
// Xmodem callback function
//
//-------------------------------------
*/
int callback(int msg, XPARAM param)
{
static retry = 10;
const char *_err_txt;
static const char *err_txt[] =   {  
                                    "OVER RUN",
                                    "BAD BLOCK",
                                    "BAD BLOCK CHECK",
                                    "TIME OUT",
                                    "TRANSFER CANCELED"
                                 };

   switch(msg)
   {
      case XM_IDLE:
         break;

      case XM_START:
         cprintf("\r\nWaiting...");
         break;

      case XM_BLOCKCHECK:
         cprintf("\r\nblock check:%s\r\n", param == 0 ? "CHECKSUM" : "CRC");
         break;

      case XM_BLOCK:
         if(retry < 10)
         {
            retry = 10;
            putchar('\n');
         }
         cprintf("\rblock:%d bytes: %ld", param, ((long)param) << 7);
         break;

      case XM_EOT:
         cprintf("\r\nEOT");
         break;

      case XM_DONE:
         break;

      case XM_ERROR:
         if(param & OVERUN)
            _err_txt = err_txt[0];
         else
            _err_txt = err_txt[param >> 12];
         cprintf("\r\nERROR:%s", _err_txt);
         if(retry-- == 0)
            return(1);
   }

   if(kbhit())
   {
      if(getch() == 0x1b)
         return(1);
   }
   return(0);
}



/*
//-------------------------------------
//
// Microsoft portability
//
//-------------------------------------
*/
#if M_I86


int wherex(void)
{
byte	rv;

	_asm	{
				mov	bh,0
				mov	ah,3
				int	10h
				inc	dl
				mov	rv,dl
			}
	return(rv);
}

int wherey(void)
{
byte	rv;

	_asm	{
				mov	bh,0
				mov	ah,3
				int	10h
				inc	dh
				mov	rv,dh
			}
	return(rv);
}

void delay  (clock_t milliseconds)
{
	milliseconds += clock();
	while(clock() < milliseconds);
}

void clreol(void)
{
	cprintf("%*c", 80 - wherex() - 1, ' ');
}

int cprintf(const char *fmt, ...)
{
va_list list;
int rv;
char buf[129];

   va_start(list, fmt);
   rv = vsprintf(buf, fmt, list);
   va_end(list);
	_outtext(buf);
   return(rv);
}

#endif

And the header files are

cport.h

/*
// CPORT.H
//
// Header file for Cport Communications Library
//
// Copyright (c) 1993 Bri Productions
//
*/

#ifndef _CPORT_H_
#define _CPORT_H_

#include "stddef.h"

#if defined  __TURBOC__
# if  __STDC__
#  define  _Cdecl
# else
#  define  _Cdecl  cdecl
# endif
#elif defined  __ZTC__
# define  _Cdecl
#elif defined  M_I86 && !defined  __ZTC__
# if !defined NO_EXT_KEYS
#  define  _Cdecl  cdecl
# else
#  define  _Cdecl
# endif
#else
#define  _Cdecl
#endif



/*
//-------------------------------------
//
// com port id's
//
//-------------------------------------
*/

#define  PORT0 0x03F8                  /* hard port addresses  */
#define  PORT1 0x02F8
#define  PORT2 0x03E8
#define  PORT3 0x02E8

#define  BIOS0 (*(int far *)0x400000l) /* bios port addresses  */
#define  BIOS1 (*(int far *)0x400002l)
#define  BIOS2 (*(int far *)0x400004l)
#define  BIOS3 (*(int far *)0x400006l)

#define  IRQ2  0x2000                  /* irq's                */
#define  IRQ3  0x3000
#define  IRQ4  0x4000
#define  IRQ5  0x5000
#define  IRQ6  0x6000
#define  IRQ7  0x7000

#define  COM1  (PORT0 | IRQ4)          /* hard 'com' ports     */
#define  COM2  (PORT1 | IRQ3)
#define  COM3  (PORT2 | IRQ4)
#define  COM4  (PORT3 | IRQ3)
                                       /* bios 'com' ports     */

#define  BCOM1 ((BIOS0 | 0x1000) + ((BIOS0 << 4) & 0xf000))
#define  BCOM2 ((BIOS1 | 0x1000) + ((BIOS1 << 4) & 0xf000))
#define  BCOM3 ((BIOS2 | 0x1000) + ((BIOS2 << 4) & 0xf000))
#define  BCOM4 ((BIOS3 | 0x1000) + ((BIOS3 << 4) & 0xf000))


/*
//-------------------------------------
//
// baud rate divisors
//
//-------------------------------------
*/

#define  B115200  1
#define  B57600   2
#define  B38400   3
#define  B19200   6
#define  B9600    12
#define  B7200    16
#define  B4800    24
#define  B3600    32
#define  B2400    48
#define  B2000    58
#define  B1800    64
#define  B1200    96
#define  B600     192
#define  B300     384
#define  B150     768
#define  B110     1047
#define  B75      1536
#define  B50      2304


/*
//-------------------------------------
//
// word lengths
//
//-------------------------------------
*/

#define  W8    3
#define  W7    2
#define  W6    1
#define  W5    0
#define  WMASK 3


/*
//-------------------------------------
//
// stop bits
//
//-------------------------------------
*/

#define  S1    0
#define  S2    4
#define  SMASK 4


/*
//-------------------------------------
//
// parity
//
//-------------------------------------
*/

#define  NONE     0x00
#define  ODD      0x08
#define  EVEN     0x18
#define  MARK     0x28
#define  SPACE    0x38
#define  PMASK    0x38


/*
//-------------------------------------
//
// handshaking
//
//-------------------------------------
*/

#define  DTR      0x001
#define  RTS      0x002
#define  S_RX     0x004
#define  S_TX     0x008
#define  CTS      0x010
#define  DSR      0x020
#define  DCD      0x080

#define  SOFT     ((S_RX) | (S_TX))
#define  HARD     ((RTS)| (CTS))
#define  HARD1    ((DTR)| (DSR))
#define  HARD2    ((RTS)| (CTS))


/*
//-------------------------------------
//
// error codes
//
//-------------------------------------
*/

#define  OVERUN    0x002         /* overrun error           */
#define  PARITY    0x004         /* parity error            */
#define  FRAMING   0x008         /* framing error           */
#define  BREAK     0x010         /* break detect            */
#define  RX_FIFO   0x080         /* error in recieve fifo   */
#define  TXFULL    0x100         /* transmit queue overflow */
#define  RXFULL    0x200         /* receive queue overflow  */


/*
//-------------------------------------
//
// status codes
//
//-------------------------------------
*/

#define  DCTS        0x001       /* delta clear to send           */
#define  DDSR        0x002       /* delta data set ready          */
#define  TERI        0x004       /* trailing edge ring  indicator */
#define  DDCD        0x008       /* delta data carrier detect     */
#define  CTS         0x010       /* clear to send                 */
#define  DSR         0x020       /* data set ready                */
#define  RI          0x040       /* ring indicator                */
#define  DCD         0x080       /* data carrier detect           */

#define  S_TX_OFF    0x0100      /* software transmit off         */
#define  U_TX_OFF    0x0200      /* user transmit off             */
#define  S_RX_OFF    0x0400      /* software receive off          */
#define  X_REQST     0x0800      /* send XON/XOFF request         */
#define  X_SENT      0x1000      /* X character send (TX_DIRECT)  */
#define  U_TX_DIR    0x2000      /* In direct transmit mode       */

/*
//-------------------------------------
// 
// Uart types ComUart
//
//-------------------------------------
*/
                                                                        
#define  INS8250   1             /* INS8250/INS8250-B                   */
#define  NS16450   2             /* INS8250A/NS16450/NS16C450/NS16C450A */
#define  NS16550   3             /* NS16550                             */
#define  I82510    4             /* 82510 (Intel)                       */


/*
//-------------------------------------
//
// ComTurbo options
//
//-------------------------------------
*/

#define  TIMER       0x01     /* timer bit (irq0)              */
#define  KEYBOARD    0x02     /* keyboard bit (irq1)           */
#define  CASCADE     0x04     /* cascade/reserved bit (irq2)   */


/*
//-------------------------------------
//
// NS16550 rx FIFO trigger levels
//
//-------------------------------------
*/

#define  T550_1      0x00
#define  T550_4      0x40
#define  T550_8      0x80
#define  T550_14     0xC0


/*
//-------------------------------------
//
//
//
//-------------------------------------
*/

/*
//-------------------------------------
//
// typedefs and structures
//
//-------------------------------------
*/

#ifndef _BYTE_
#define _BYTE_
typedef unsigned char byte;
#endif

	/* Make sure this structure is byte packed
	*/

#ifdef M_I86
#pragma pack(1) 
#endif

   /** Do not change this structure **/

struct C_param{
   unsigned id;               /* com port id                      */
   int      baud;             /* baud rate                        */
   byte     mode;             /* word length, stop bits, parity   */
   unsigned rxQ;              /* receive queue size               */
   unsigned txQ;              /* transmit queue size              */
   byte     htype;            /* handshaking type                 */
   unsigned thresh;           /* handshaking threshold (rx queue) */
   };

typedef struct C_param CPARAM;
typedef void* COM;

#ifdef M_I86
#pragma pack() 
#endif

/*
//-------------------------------------
//
// Misc
//
//-------------------------------------
*/

enum { OFF  , ON   };
#define TX_DIRECT    0x20


/*
//-------------------------------------
//
// comopen_errno
//
//-------------------------------------
*/

#define  NO_ERR   0        /* no error                         */
#define  OPENED   1        /* port already opened              */
#define  BAD_ID   2        /* bad id parameter                 */
#define  NO_UART  3        /* no uart chip found               */
#define  RX_ALC   4        /* receive queue allocation error   */
#define  TX_ALC   5        /* transmit queue allocation error  */
#define  MAX_PORT 6        /* max number of com ports opened   */
#define  IRQ_CTN  7        /* interrupt contention             */
#define  GEN_ALC  8        /* general allocation error         */


/*
//-------------------------------------
//
// function macros
//
//-------------------------------------
*/

#define  ComOut1(c,a)         ComMcr(c,a, 0x04)
#define  ComRts(c,a)          ComMcr(c,a, 0x02)
#define  ComDtr(c,a)          ComMcr(c,a, 0x01)


/*
//-------------------------------------
//
// function prototypes
//
//-------------------------------------
*/

#ifdef __cplusplus
extern "C" {
#endif

   /* control functions */

COM      _Cdecl   ComOpen        (unsigned id, int baud, byte mode, unsigned rxQ, unsigned txQ);
COM      _Cdecl   ComOpenS       (const CPARAM* param);
COM      _Cdecl   ComClose       (COM com);
void     _Cdecl   ComHandshake   (COM com, byte htype, unsigned thresh);
void     _Cdecl   ComParam       (COM com, CPARAM* param);
void     _Cdecl   ComBaud        (COM com, int baud);
void     _Cdecl   ComMode        (COM com, byte mode);
int      _Cdecl   ComTx          (COM com, int cmnd);
void     _Cdecl   ComTurbo       (int options);
void     _Cdecl   ComCloseAll    (void);
void     _Cdecl   ComNS550       (COM com, int trigger);
unsigned _Cdecl   ComRxQ         (COM com, unsigned size);
unsigned _Cdecl   ComTxQ         (COM com, unsigned size);


   /* input functions    */

char     _Cdecl   ComGetc        (COM com);
unsigned _Cdecl   ComLenRx       (COM com);
char    *_Cdecl   ComGets        (COM com, char *str, int maxc, char termc);
unsigned _Cdecl   ComIn          (COM com, void *abyte, unsigned nbyte);
void     _Cdecl   ComFlushRx     (COM com);
char     _Cdecl   ComPeek        (COM com);
unsigned _Cdecl   ComRxScan      (COM com, char c);


   /* output functions  */

int      _Cdecl   ComPutc        (COM com, char c);
unsigned _Cdecl   ComLenTx       (COM com);
int      _Cdecl   ComPuts        (COM com, const char *str);
unsigned _Cdecl   ComOut         (COM com, const void *abyte, unsigned nbyte);
void     _Cdecl   ComFlushTx     (COM com);
void     _Cdecl   ComTxWait      (COM com);


   /* status functions  */

void     _Cdecl   ComMcr         (COM com, byte on_off, byte bits);
unsigned _Cdecl   ComError       (COM com);
unsigned _Cdecl   ComStatus      (COM com);
int      _Cdecl   ComUart        (COM com);


   /* misc fuctions  */

void     _Cdecl   ComSetBreak    (COM com);
void     _Cdecl   ComClrBreak    (COM com);
void     _Cdecl   ComPutScrtch   (COM com, byte abyte);
byte     _Cdecl   ComGetScrtch   (COM com);


   /* data integrity functions   */

byte          _Cdecl ComChecksum (const void *abyte, unsigned nbyte);
unsigned      _Cdecl ComCrc16    (const void *abyte, unsigned nbyte);
unsigned long _Cdecl ComCrc32    (const void *abyte, unsigned nbyte);


   /* debug */

COM      _Cdecl   ComHandle      (COM com);


#ifdef __cplusplus
}           /* extern "C" */
#endif



/*
//-------------------------------------
//
// comopen_errno 
//
//-------------------------------------
*/


#ifdef __cplusplus
extern "C" int   comopen_errno;
#else
extern   int   comopen_errno;
#endif



/*
//-------------------------------------
//
// Other header files
//
//-------------------------------------
*/

   /* Implicit and explicit C++ inclusion
   */
#ifdef __cplusplus
#include   "cport.hpp"
#endif


   /* Xmodem inclusion
   */
#ifdef Uses_Xmodem
#include "xmodem.h"
#endif

   /* Zmodem inclusion
   */
#ifdef Uses_Zmodem
#include "zmodem.h"     /* Not yet implemented  */
#endif


#endif      /* CPORT.H */

xmodem.h header file

/*
// XMODEM.H
//
// Header file for Xmodem file transfer protocol
//
// Copyright (c) 1993 Bri Productions
//
*/


#ifndef  _XMODEM_H_
#define  _XMODEM_H_

/*
//-------------------------------------
//
// additional callback() error codes 
//
// ( lower 12 bits == ComError() )
//
//-------------------------------------
*/
#define  XE_BADBLOCK    0x1000   /* Bad block            */
#define  XE_BADCHECK    0x2000   /* Bad block check      */
#define  XE_TIMEOUT     0x3000   /* Timeout              */
#define  XE_CANCEL      0x4000   /* Canceled             */


/*
//-------------------------------------
//
// Return codes
//
//-------------------------------------
*/
enum  {  
         XR_NOERR,         /* No error                   */
         XR_FILEERR,       /* File error                 */
         XR_CANCEL,        /* Transfer canceled          */
         XR_ALLOC,         /* Memory allocation          */
         XR_USER           /* Start of user return codes */
      };

/* 
//-------------------------------------
//
// callback messages
//
//-------------------------------------
*/
enum  {  
         XM_IDLE,          /* Idle time               */
         XM_START,         /* Starting transfer       */
         XM_BLOCKCHECK,    /* Type of block check     */
         XM_BLOCK,         /* New block               */
         XM_EOT,           /* End of transmission     */
         XM_DONE,          /* Transmission complete   */
         XM_ERROR          /* Error                   */
      };

/*
//-------------------------------------
//
// callback messages parameter
//
//-------------------------------------
*/
typedef unsigned XPARAM;




/*
//-------------------------------------
//
// Function prototypes
//
//-------------------------------------
*/

#ifdef __cplusplus
extern "C" {
#endif

int _Cdecl XmodemTx(COM com, const char* file, int (*cb)(int msg, XPARAM param));
int _Cdecl XmodemRx(COM com, const char* file, int (*cb)(int msg, XPARAM param));
int _Cdecl Xcallback(int msg, XPARAM param);

#ifdef __cplusplus
}
#endif

#endif   /* XMODEM.H */

I am getting the following linker errors (I compiled this in turbo c++ windows)
Linker error : Undefined symbol _ComOpenS
Linker error : Undefined symbol _ComGets
.....
and 16 such errors.What is the problem with the code ..I am n ot able to understand

what compiler and os?

Also ancient dragon could you please re-format the first post .I mean you there are two header files cport.h and xmodem.h along with the comdemo.c file

Also ancient dragon could you please re-format the first post .I mean you there are two header files cport.h and xmodem.h along with the comdemo.c file

done

I don't have your compiler so I probably can't help very much. Link errors means that you have not include one or more libraries in your project.

the following is the link to download the files.What I understand is that the cports.lib should be linked .How shall I like this to the comdemo.c file .Also how shall I create project file in Turbo C++ 3.0

Solved now...It was with linking the lib file...Problem is different compilers have different ways of linking

This article has been dead for over six months. Start a new discussion instead.