Пример #1
0
void main( void )
{
    int      handle;
    unsigned date, time;

    if( _dos_open( "file", O_RDWR, &handle ) != 0 ) {
        printf( "Unable to open file\n" );
    } else {
        printf( "Open succeeded\n" );
        _dos_getftime( handle, &date, &time );
        printf( "The file was last modified on %d/%d/%d",
                MONTH(date), DAY(date), YEAR(date) );
        printf( " at %.2d:%.2d:%.2d\n",
                HOUR(time), MINUTE(time), SECOND(time) );
        /* set the time to 12 noon */
        time = (12 << 11) + (0 << 5) + 0;
        _dos_setftime( handle, date, time );
        _dos_getftime( handle, &date, &time );
        printf( "The file was last modified on %d/%d/%d",
                MONTH(date), DAY(date), YEAR(date) );
        printf( " at %.2d:%.2d:%.2d\n",
                HOUR(time), MINUTE(time), SECOND(time) );
        _dos_close( handle );
    }
}
Пример #2
0
void main(int argc, char *argv[])
{
    struct Date {
      unsigned int day:5;
      unsigned int month:4;
      unsigned int years:7;
    } date;

    struct Time {
      unsigned seconds:5;
      unsigned minutes:6;
      unsigned hours:5;
    } time;
    
    int handle;

    if (_dos_open(argv[1], O_RDONLY, &handle))
	fprintf(stderr, "Error opening source file\n");
    else
     {
	if (_dos_getftime(handle, &date, &time))
	  printf("Error getting date and time stamp\n");
	else
	  printf("%s last modified %02d-%02d-%d %02d:%02d:%02d\n", 
	       argv[1],
	       date.month,          /* month */
	       date.day,            /* day */
	       date.years + 1980,   /* year */
	       time.hours,          /* hours */
	       time.minutes,        /* minutes */
	       time.seconds * 2);   /* seconds */
	_dos_close(handle);
    }
 }
Пример #3
0
unsigned int ZFileGetFTime()
{
  _dos_open(ZFFTimeFName, 0,&ZFTimeHandle);
  _dos_getftime(ZFTimeHandle,&ZFDate,&ZFTime);
  _dos_close(ZFTimeHandle);
  return(0);
}
Пример #4
0
BOOL FCopy (char *src, char *dst)
{
    HANDLE srcfh, dstfh;
    BOOL result;
    ATTRIBUTE_TYPE Attributes;
    unsigned filedate, filetime;
    GET_ATTRIBUTES(src, Attributes);

    if (Attributes == FILE_ATTRIBUTE_DIRECTORY) {
        fprintf( stderr, "\nUnable to open source");
	return FALSE;
    }

    if (_dos_creatnew( src, _A_RDONLY, &srcfh) != 0)
        if  (_dos_open( src, O_RDONLY, &srcfh) != 0) {
        fprintf( stderr, "\nUnable to open source, error code %d", GetLastError() );
	if (srcfh != INVALID_HANDLE_VALUE) CloseHandle( srcfh );
	return FALSE;
    }

    if (_dos_getftime(srcfh, &filedate, &filetime) != 0) {
        fprintf( stderr, "\nUnable to get time of source");
	if (srcfh != INVALID_HANDLE_VALUE) CloseHandle( srcfh );
	return FALSE;
    }

    if (_dos_creatnew( dst, _A_NORMAL, &dstfh) != 0)
        if (_dos_open( dst,  O_RDWR,   &dstfh) != 0) {
        fprintf( stderr, "\nUnable to create destination, error code %d", GetLastError() );
	if (srcfh != INVALID_HANDLE_VALUE) CloseHandle( srcfh );
	if (dstfh != INVALID_HANDLE_VALUE) CloseHandle( dstfh );
	return FALSE;
    }

    result = fastcopy( srcfh, dstfh );

    if(!result) {
        if (dstfh != INVALID_HANDLE_VALUE) {
            CloseHandle( dstfh );
            dstfh = INVALID_HANDLE_VALUE;
        }

        DeleteFile( dst );
        if (srcfh != INVALID_HANDLE_VALUE) CloseHandle( srcfh );
        fprintf( stderr, "\nUnable to copy file");
        return FALSE;
    }

    if (_dos_setftime(dstfh, filedate, filetime != 0)) {
        fprintf( stderr, "\nUnable to set time of destination");
	if (srcfh != INVALID_HANDLE_VALUE) CloseHandle( srcfh );
	if (dstfh != INVALID_HANDLE_VALUE) CloseHandle( dstfh );
	return FALSE;
    }

    if (srcfh != INVALID_HANDLE_VALUE) CloseHandle( srcfh );
    if (dstfh != INVALID_HANDLE_VALUE) CloseHandle( dstfh );
    return TRUE;

} // FCopy
Пример #5
0
/*
** int CopyDateTimeStamp(int doshFrom, int doshTo);
**
** Copy date and time stamp from one file to another.
**
** Arguments:  doshFrom - date and time stamp source DOS file handle
**             doshTo   - target DOS file handle
**
** Returns:    TRUE if successful.  LZERROR_BADINHANDLE or
**             LZERROR_BADOUTHANDLE if unsuccessful.
**
** Globals:    none
**
** N.b., stream-style I/O routines like fopen() and fclose() may counter the
** intended effect of this function.  fclose() writes the current date to any
** file it's called with which was opened in write "w" or append "a" mode.
** One way to get around this in order to modify the date of a file opened
** for writing or appending by fopen() is to fclose() the file and fopen() it
** again in read "r" mode.  Then set its date and time stamp with
** CopyDateTimeStamp().
*/
INT CopyDateTimeStamp(INT doshFrom, INT doshTo)
{
#ifdef ORGCODE
   // DOS prototypes from <dos.h>
   extern DWORD _dos_getftime(INT dosh, DWORD *puDate, DWORD *puTime);
   extern DWORD _dos_setftime(INT dosh, DWORD uDate, DWORD uTime);

#ifdef LZA_DLL
   static
#endif
   DWORD uFrom_date,    // temporary storage for date
         uFrom_time;    // and time stamps

   if (_dos_getftime(doshFrom, &uFrom_date, &uFrom_time) != 0u)
      return((INT)LZERROR_BADINHANDLE);

   if (_dos_setftime(doshTo, uFrom_date, uFrom_time) != 0u)
      return((INT)LZERROR_BADOUTHANDLE);
#else

    FILETIME lpCreationTime, lpLastAccessTime, lpLastWriteTime;

   if(!GetFileTime((HANDLE) doshFrom, &lpCreationTime, &lpLastAccessTime, 
                    &lpLastWriteTime)){
      return((INT)LZERROR_BADINHANDLE);
   }
   if(!SetFileTime((HANDLE) doshTo, &lpCreationTime, &lpLastAccessTime, 
                    &lpLastWriteTime)){
      return((INT)LZERROR_BADINHANDLE);
   }

#endif
   return(TRUE);
}
Пример #6
0
/*
 * GrabFile - read in a specified file, dump it to destination
 */
int GrabFile( char *src, struct stat *stat_s, char *dest, unsigned srcattr )
{
#if defined( __OS2__ ) && defined( __386__ )
    int                 result;
#else
    ctrl_block          *cb;
#endif
#if !defined(__WATCOMC__) && ( defined( __NT__ ) )
    HANDLE              handle;
#else
    int                 handle;
#endif
    int                 okay=TRUE;
    timedate            td;
    unsigned            t = 0;
    unsigned            d = 0;

    /*
     * file handle
     */
    if( _dos_open( src, O_RDONLY, &handle ) ) {
        DropPrintALine( "Error opening file %s",src );
        IOError( errno );
    }

    /*
     * get time/date stamp of file
     */
    if( npflag || todflag ) {
        _dos_getftime( handle, &d, &t );
        if( todflag ) {
            td.yy = (((d & 0xFE00) >> 9) + 1980);
            td.mm = ((d & 0x01E0 ) >> 5);
            td.dd = (d & 0x001F);
            td.hr = ((t & 0xF800) >> 11);
            td.min = ((t & 0x07E0) >> 5);
            td.sec = ((t & 0x001F) << 1);
            /*
             * see if this file passes the date checks
             */
            if( tflag2 ) {
                if( td.hr <= after_t_d.hr ) {
                    if( td.hr < after_t_d.hr ) {
                        return( FALSE );
                    }
                    if( td.min <= after_t_d.min ) {
                        if( td.min < after_t_d.min ) {
                            return( FALSE );
                        }
                        if( td.sec < after_t_d.sec ) {
                            return( FALSE );
                        }
                    }
                }
            }
            if( Tflag1 ) {
                if( td.hr >= before_t_d.hr ) {
                    if( td.hr > before_t_d.hr ) {
                        return( FALSE );
                    }
                    if( td.min >= before_t_d.min ) {
                        if( td.min > before_t_d.min ) {
                            return( FALSE );
                        }
                        if( td.sec > before_t_d.sec ) {
                            return( FALSE );
                        }
                    }
                }
            }
            if( dflag2 ) {
                if( td.yy <= after_t_d.yy ) {
                    if( td.yy < after_t_d.yy ) {
                        return( FALSE );
                    }
                    if( td.mm <= after_t_d.mm ) {
                        if( td.mm < after_t_d.mm ) {
                            return( FALSE );
                        }
                        if( td.dd < after_t_d.dd ) {
                            return( FALSE );
                        }
                    }
                }
            }
            if( Dflag1 ) {
                if( td.yy >= before_t_d.yy ) {
                    if( td.yy > before_t_d.yy ) {
                        return( FALSE );
                    }
                    if( td.mm >= before_t_d.mm ) {
                        if( td.mm > before_t_d.mm ) {
                            return( FALSE );
                        }
                        if( td.dd > before_t_d.dd ) {
                            return( FALSE );
                        }
                    }
                }
            }
        }
    }
Пример #7
0
int generate_header_macro ( char *filename, long total_lines ) {
     int print_page_break( boolean, boolean );
     unsigned getbits( unsigned, int, int );
     char *long_numstring ( long );
     char *spaces ( int );

     char spaces_string[MAX_LINE_LENGTH];
     int i, j_length;

     /*
     **  Required to get the date and time of last modification of a file.
     */

     struct f_date {
          int day;
          int month;
          int year;
          int hour;
          int minute;
          int second;
     } file_date;

     unsigned fdate, ftime;       /* file date and time packed into integers */
     int file_handle;

#ifdef DIAGNOSTICS
     fprintf(stderr, "entering PRINT_RUNNING_PAGE_HEADER\n");
#endif

     /*
     **  First, send the macro header to the printer.
     */

     /* (IBM Laser Printer macro commands not implemented in this version ) */

     /*
     **  Print today's date at the top of the first page.
     */

     fprintf(fp_output, "%s", bold);
     fprintf(fp_output, "%02d-", startdate.month);

     if (startdate.day < 10)
          fprintf(fp_output, "0%d-", startdate.day);
     else
          fprintf(fp_output, "%d-", startdate.day);

     fprintf(fp_output, "%d", startdate.year);

     /*
     **  The neatly center the filename . . .
     */

     for (i=1; i<=(28 - (strlen(filename) / 2)); i++)
          fprintf(fp_output, " ");
     fprintf(fp_output, "%s", filename);

     if (total_lines < 10)            /* sure it's silly, but it works */
          j_length = 1;
     else if (total_lines < 100)
          j_length = 2;
     else if (total_lines < 1000)
          j_length = 3;
     else if (total_lines < 10000)
          j_length = 4;
     else if (total_lines < 100000)
          j_length = 5;
     else if (total_lines < 1000000)
          j_length = 6;

     for (i=(38+(strlen(filename) / 2)); i<=(80-9-j_length); i++)
          fprintf(fp_output, " ");

     /*
     **  . . . and print the size of the file in lines.
     */

     if (total_lines == 1)
          fprintf(fp_output, " %ld line\n", total_lines);
     else
          fprintf(fp_output, "%ld lines\n", total_lines);

     /*
     **  Print the current time on the next line.
     */

     if (starttime.hour <= 12)
          fprintf(fp_output, "%d:", starttime.hour);
     else
          fprintf(fp_output, "%d:", starttime.hour - 12);

     if (starttime.minute < 10)
          fprintf(fp_output, "0%d:", starttime.minute);
     if (starttime.minute >= 10)
          fprintf(fp_output, "%2d:", starttime.minute);

     if (starttime.second < 10)
          fprintf(fp_output, "0%d ", starttime.second);
     if (starttime.second >= 10)
          fprintf(fp_output, "%2d ", starttime.second);

     if (starttime.hour < 12)
          fprintf(fp_output, "AM");
     if (starttime.hour >= 12)
          fprintf(fp_output, "PM");

     /*
     **  Get the file date and time from DOS.
     */

     file_handle = fileno(fp_input);
     _dos_getftime(file_handle, &fdate, &ftime);

     file_date.day = getbits(fdate, 4, 5);
     file_date.month = getbits(fdate, 8, 4);
     file_date.year = getbits(fdate, 15, 7) + 1980;

     file_date.second = getbits(ftime, 4, 5) * 2;
     file_date.minute = getbits(ftime, 10, 6);
     file_date.hour = getbits(ftime, 15, 5);

     /*
     ** Date and time of last modification:
     */
                                                       /*****************/
     fprintf(fp_output, "          ");                 /*   ten spaces  */
                                                       /* for centering */
     if ( ( starttime.hour < 10 ) ||                   /*****************/
          ( starttime.hour > 12 ) )                    /* another space */
          fprintf(fp_output, " ");                     /*****************/

     fprintf(fp_output, "%sLast modified %02d-", boff, file_date.month);

     if (file_date.day < 10)
          fprintf(fp_output, "0%d-", file_date.day);
     else
          fprintf(fp_output, "%d-", file_date.day);

     fprintf(fp_output, "%d at ", file_date.year);

     if (file_date.hour <= 12)
          fprintf(fp_output, "%d:", file_date.hour);
     else
          fprintf(fp_output, "%d:", file_date.hour - 12);

     if (file_date.minute < 10)
          fprintf(fp_output, "0%d ", file_date.minute);
     if (file_date.minute >= 10)
          fprintf(fp_output, "%2d ", file_date.minute);

     if (file_date.hour < 12)
          fprintf(fp_output, "AM");
     if (file_date.hour >= 12)
          fprintf(fp_output, "PM");

     fprintf(fp_output, "%s", bold);

     /*
     **  Size of the file in bytes.
     */

     strcpy( spaces_string, spaces(22 - strlen(long_numstring(dta.size)) - 6 ));
     fprintf( fp_output, "%s %ld bytes",
              spaces_string,
              dta.size
     );

     /*
     **  end the line.
     */

     fprintf(fp_output, "%s\n\n", boff);

     /*
     **  Now print the first page break and away we go!
     */

     print_page_break(FALSE, FALSE);

#ifdef DIAGNOSTICS
     fprintf(stderr, "Exit PRINT_RUNNING_PAGE_HEADER\n");
#endif

     return(0);
}
Пример #8
0
DWORD FAR PASCAL RepSrcToD (const char *szSrcFil, const char *szDstFil, WORD usRepFlg, 
                 LPSTR lpWrkBuf, WORD usBufSiz, BFRREPFNC pfRepFnc, 
                 void far *lpRepBlk)
{
    short           sSrcHdl;
    short           sDstHdl;
    static  char    szBakFil[FIOMAXNAM];
    static  char    szTmpFil[FIOMAXNAM];
    char          * pbWrkPtr;
    DWORD           ulRepCnt = 0L;
    static   int    file_date;
    static   int    file_time;
    unsigned int    uiErrCod;

    /********************************************************************/
    /********************************************************************/
    sSrcHdl = FilHdlOpn (szSrcFil, O_BINARY | O_RDONLY);
    if (-1 == sSrcHdl) {
        MsgDspUsr ("Cannot Open Source File: %s\n", szSrcFil);
        return (0L);
    }
    if (usRepFlg & BFRDATFLG) _dos_getftime (sSrcHdl, &file_date, &file_time);    

    /********************************************************************/
    /* If null destination, create a temporary file in the current      */
    /* working directory.                                               */
    /* If not null, check for "*" wildcard or drive/dir only spec       */
    /********************************************************************/
    if (!strlen (szDstFil)) {
        _getcwd (szTmpFil, FIOMAXNAM);
        if (NULL == (pbWrkPtr = _tempnam (szTmpFil, "B_"))) {
            FilHdlCls (sSrcHdl);
            MsgDspUsr ("Cannot Create Temporary File: %s\n", szTmpFil);
            return (0L);
        }
        strcpy (szTmpFil, pbWrkPtr);
        free (pbWrkPtr);
    }
    else {
        GetWldNam (szSrcFil, szDstFil, szTmpFil);

        /****************************************************************/
        /****************************************************************/
        if (0 == _stricmp (szSrcFil, szTmpFil)) {
            FilHdlCls (sSrcHdl);
            MsgDspUsr ("Cannot Overwrite Source File: %s\n", szSrcFil);
            return (0L);
        }
    }

    /********************************************************************/
    /* Open a zero length target file                                   */
    /********************************************************************/
    sDstHdl = FilHdlCre (szTmpFil, O_BINARY | O_CREAT | O_TRUNC | O_WRONLY,
        S_IREAD | S_IWRITE);
    if (-1 == sDstHdl) {
        FilHdlCls (sSrcHdl);
        MsgDspUsr ("Cannot Open Target File: %s\n", szTmpFil);
        return (0L);
    }

    /********************************************************************/
    /* Perform replacement                                              */
    /* If save date flag set, set Dst file date and time to equal Src   */
    /********************************************************************/
    ulRepCnt = pfRepFnc (sSrcHdl, sDstHdl, szSrcFil, szDstFil, lpWrkBuf, usBufSiz, lpRepBlk);
    if (usRepFlg & BFRDATFLG) _dos_setftime (sDstHdl, file_date, file_time);    
    FilHdlCls (sSrcHdl);
    FilHdlCls (sDstHdl);

    if (-1L == ulRepCnt) {
        MsgDspUsr ("Cannot replace to target file: %s\n", szTmpFil);
        return (0L);
    }

    /********************************************************************/
    /* If target specified AND no replacements, delete empty dest file  */ 
    /* If no target specified AND no replacements, delete temp file     */ 
    /********************************************************************/
    if (0L == ulRepCnt) {
        remove (szTmpFil);                      /* Delete empty file    */
        return (0L);
    }
    if (*szDstFil != '\0') return (ulRepCnt);   /* Done (explicit dest) */

    /********************************************************************/
    /* If no target specified AND backup requested, save backup         */ 
    /********************************************************************/
    if (!(usRepFlg & BFRBKIFLG)) {
        strcpy (szBakFil, szSrcFil);
        if ((pbWrkPtr = strrchr (szBakFil, '.')) != NULL) strcpy (pbWrkPtr, ".BK1");
            else strcat (szBakFil, ".BK1");
        remove (szBakFil);                          /* Del old backups  */

        if (rename (szSrcFil, szBakFil)) {          /* Rename original  */
            MsgDspUsr ("Cannot create backup: %s\n", szBakFil);
            remove (szTmpFil);                      /* Delete temp file */
            return (0L);
        }
    }

    /********************************************************************/
    /* Rename original, or copy if in different drive/directory         */
    /********************************************************************/
    if (FilMov (szTmpFil, szSrcFil, lpWrkBuf, usBufSiz, usRepFlg & BFRDATFLG, &uiErrCod, NULL, 0L)) {
        MsgDspUsr ("Cannot copy to file: %s, attempting recovery...\n", szSrcFil);
        if (!(usRepFlg & BFRBKIFLG)) {
            remove (szSrcFil);                      /* Delete bad copy  */
            rename (szBakFil, szSrcFil);            /* Un-rename orig   */
        }
        else rename (szTmpFil, szSrcFil);           /* Simple rename    */
        ulRepCnt = 0L;
    }

    /********************************************************************/
    /********************************************************************/
    return (ulRepCnt);

}
Пример #9
0
int SendFile (char *FileName)
{
  WaitLoop (DelayToTransmit);

  int hFile;
  if ((hFile = open (FileName, O_BINARY | O_RDONLY, FILE_ACCESS)) == -1)
   {
    printf ("-Send file %s not found!\n", FileName);
    return hFile;
   }

  dword FileSize = lseek (hFile, 0, SEEK_END), FileOffset = 0;
  lseek (hFile, 0, SEEK_SET);
  byte *ClusterBuffer = new byte [SizeOrigCluster];

  if (!ClusterBuffer)
    return (int)ClusterBuffer;

  LockMemory (ClusterBuffer, SizeOrigCluster, LOCK_MEMORY);
  // Make file header
  FileHdr *filehdr = (FileHdr*)ClusterBuffer;
  filehdr->FileID  = get_time () + FileSize; // Is static parametr

  dword FileHeaderLen = strlen (FileName) + 1 + sizeof (FileAttr);
  dword FileBlockIndex = 0;

  // Insert empty frames
  vint Semaphore = SizeOrigCluster / SizeDataFrame;
  SendAFrames ((word*)ClusterBuffer, &Semaphore, ID_FRAME, NULL);
  while (Semaphore > 4) {}

  while (FileSize && !StopByUser)
   {
    CheckOnFreeComBuffer ();
    BlockHdr *pBH = (BlockHdr*) ((int)ClusterBuffer + sizeof (FileHdr));
    dword BlockIndex = FileBlockIndex, BlockInCluster = 0;
    dword LastBytes = SizeOrigCluster - sizeof (FileHdr);

    // Divide cluster on blocks
    while (LastBytes)
     {
      if (LastBytes <= sizeof (BlockHdr))
	break;

      BlockInCluster++;
      LastBytes -= sizeof (BlockHdr);

      if (BlockIndex)
       {
	if (LastBytes >= BLOCK_LEN)
	  pBH->Len = BLOCK_LEN;
	else
	  pBH->Len = LastBytes;

	LastBytes -= pBH->Len;
       }
      else
      if (FileHeaderLen <= LastBytes)
       {
	pBH->Len = FileHeaderLen;
	LastBytes -= pBH->Len;
       }
      else
       {
	BlockInCluster--;
	LastBytes = 0;
	break;
       }

      BlockIndex++;
      pBH++;
     }

    // Dinamyc part of file header modify
    filehdr->NumBlock = BlockInCluster;
    filehdr->HdrLen = sizeof (FileHdr) + BlockInCluster * sizeof (BlockHdr);
    byte *pClusterData = (byte*)((int)ClusterBuffer + filehdr->HdrLen);
    pBH = (BlockHdr *) ((int)ClusterBuffer + sizeof (FileHdr));
    dword OffsetToData = filehdr->HdrLen;

    BlockIndex = 0;
    // Skeleton of cluster data fill
    while (BlockInCluster && FileSize)
     {
      BlockIndex++;

      if (!FileBlockIndex)
       {
	FileAttr *pFA = (FileAttr *)pClusterData;
	pFA->Size = FileSize;
	_dos_getfileattr (FileName, &pFA->Attr);
#ifdef __GNUC__
	_dos_getftime (hFile, &pFA->Date, &pFA->Time);
#else
	_dos_getftime (hFile, (word*)&pFA->Date, (word*)&pFA->Time);
#endif
	strcpy ((char*) ((int)pClusterData + sizeof (FileAttr)), FileName);
       }
      else
       {
	read (hFile, pClusterData, pBH->Len);
	pBH->FileOffset = FileOffset;
	FileOffset += pBH->Len;

	if (FileSize >= pBH->Len)
	  FileSize -= pBH->Len;
	else
	 {
	  pBH->Len = FileSize; // truncate block
	  FileSize = 0;
	  // Correct file header
	  filehdr->NumBlock = BlockIndex;
	  filehdr->HdrLen = sizeof (FileHdr) + BlockIndex * sizeof (BlockHdr);
	 }
       }

      pBH->Number = FileBlockIndex++;
      pBH->CRC = GetBlockCRC (pClusterData, pBH->Len);
      pBH->ClusterOffset = OffsetToData;

      OffsetToData += pBH->Len;
      pClusterData += pBH->Len;
      BlockInCluster--;
      pBH++;
     }

    printf ("BlockInCluster %d\n", BlockIndex);
    dword CountCluster;
    while ((CountCluster = SendACluster (1, ClusterBuffer, filehdr->FileID + FileBlockIndex)) != 1) {}
   } // end while FileSize

  delete ClusterBuffer;
  LockMemory (ClusterBuffer, SizeOrigCluster, UNLOCK_MEMORY);
  close (hFile);

  while ((SComFlag || RComFlag || StartFlag) && !StopByUser)
    CheckOnFreeComBuffer ();
  return 1;
}
Пример #10
0
int print_list_report( char *file_name, Promptfile prompt,
                       long numlines, boolean extended_report )
{
     unsigned getbits( unsigned, int, int );
     char *long_numstring( long );
     char *spaces( int );

     /*
     **  Required to get the date and time of last modification of a file.
     */

     struct f_date {
          int day;
          int month;
          int year;
          int hour;
          int minute;
          int second;
     } file_date, promptfile_date;

     int i, fprintf_length, prompt_ref_count;
     boolean none_displayed, none_referenced, none_modified;
     Reflist_ptr prompt_ref_pointer, old_pointer;

     unsigned fdate;          /* file date and time (packed into integers) */
     unsigned ftime;
     int file_handle;                      /**********************************/
                                           /* to avoid problems with sending */
     char spaces_line[MAX_LINE_LENGTH];    /* the function spaces() directly */
     char spaces_string[MAX_LINE_LENGTH];  /* to fprintf().  [doesn't work.] */
                                           /**********************************/
#ifdef DIAGNSOTICS
     fprintf(stderr, "entering PRINT_LIST_REPORT\n");
#endif

     /*
     **  All of this stuff should be perfectly centered.
     */

     fprintf( fp_output, "                                  %sLIST Report\n\n",
                        bold );

     strcpy( spaces_line, spaces( 38 - strlen( long_numstring( numlines ) ) - 6 - ( strlen( file_name ) / 2 ) ) );

     if ( numlines != 1 )
     {
          fprintf( fp_output, "%ld lines %s %s %n",
                               numlines,
                               spaces_line,
                               file_name,
                               &fprintf_length       /*********************/
                 );                                  /* NOTE: attributes! */
     }                                               /*********************/
     else
     {
          fprintf( fp_output, "%ld line  %s %s %n",
                               numlines,
                               spaces_line,
                               file_name,
                               &fprintf_length       /*********************/
                 );                                  /* NOTE: attributes! */
     }                                               /*********************/

     strcpy( spaces_line, spaces ( 80 - fprintf_length - strlen ( long_numstring ( dta.size ) ) - 7 ) );

     if ( dta.size != 1 )
     {
          fprintf( fp_output, "%s %ld bytes%s\n\n",
                               spaces_line,
                               dta.size,
                               boff
                 );
     }
     else
     {
          fprintf( fp_output, "%s %ld  byte%s\n\n",
                               spaces_line,
                               dta.size,
                               boff
                 );
     }

     /*
     ** get the file dates and times from DOS.
     */

     file_handle = fileno(fp_input);
     _dos_getftime(file_handle, &fdate, &ftime);

     file_date.day = getbits(fdate, 4, 5);
     file_date.month = getbits(fdate, 8, 4);
     file_date.year = getbits(fdate, 15, 7) + 1980;

     file_date.second = getbits(ftime, 4, 5) * 2;
     file_date.minute = getbits(ftime, 10, 6);
     file_date.hour = getbits(ftime, 15, 5);

     promptfile_date.day = getbits(pdate, 4, 5);
     promptfile_date.month = getbits(pdate, 8, 4);
     promptfile_date.year = getbits(pdate, 15, 7) + 1980;

     promptfile_date.second = getbits(ptime, 4, 5) * 2;
     promptfile_date.minute = getbits(ptime, 10, 6);
     promptfile_date.hour = getbits(ptime, 15, 5);

     /*
     ** Date and time of last modification:
     */

     fprintf(fp_output, "Last modified %02d-",file_date.month);

     if (file_date.day < 10)
          fprintf(fp_output, "0%d-", file_date.day);
     else
          fprintf(fp_output, "%d-", file_date.day);

     fprintf(fp_output, "%d at ", file_date.year);

     if (file_date.hour <= 12)
          fprintf(fp_output, "%d:", file_date.hour);
     else
          fprintf(fp_output, "%d:", file_date.hour - 12);

     if (file_date.minute < 10)
          fprintf(fp_output, "0%d ", file_date.minute);
     if (file_date.minute >= 10)
          fprintf(fp_output, "%2d ", file_date.minute);

     if (file_date.hour < 12)
          fprintf(fp_output, "AM");
     if (file_date.hour >= 12)
          fprintf(fp_output, "PM");

     /*
     ** Date and time when printed:
     */

     if (file_date.hour < 10)                    /**********************/
          fprintf(fp_output, " ");               /*  extra spaces for  */
                                                 /*      right margin  */
     if (file_date.hour > 12)                    /*         alignment  */
          if ( (file_date.hour - 12) < 10 )      /**********************/
               fprintf(fp_output, " ");

     if (starttime.hour < 10)
          fprintf(fp_output, " ");

     if (starttime.hour > 12)
          if ( (starttime.hour - 12) < 10 )
               fprintf(fp_output, " ");

     fprintf(fp_output, "              Printed %02d-", startdate.month);

     if (startdate.day < 10)
          fprintf(fp_output, "0%d-", startdate.day);
     else
          fprintf(fp_output, "%d-", startdate.day);

     fprintf(fp_output, "%d at ", startdate.year);

     if (starttime.hour <= 12)
          fprintf(fp_output, "%d:", starttime.hour);
     else
          fprintf(fp_output, "%d:", starttime.hour - 12);

     if (starttime.minute < 10)
          fprintf(fp_output, "0%d ", starttime.minute);
     if (starttime.minute >= 10)
          fprintf(fp_output, "%2d ", starttime.minute);

     if (starttime.hour < 12)
          fprintf(fp_output, "AM\n");
     if (starttime.hour >= 12)
          fprintf(fp_output, "PM\n");

     /*
     ** Date and time of prompt file:
     */

     fprintf(fp_output, "\nPromptfile %s was last modified %02d-",
             strupr(promptfilename),
             promptfile_date.month);

     if (promptfile_date.day < 10)
          fprintf(fp_output, "0%d-", promptfile_date.day);
     else
          fprintf(fp_output, "%d-", promptfile_date.day);

     fprintf(fp_output, "%d at ", promptfile_date.year);

     if (promptfile_date.hour <= 12)
          fprintf(fp_output, "%d:", promptfile_date.hour);
     else
          fprintf(fp_output, "%d:", promptfile_date.hour - 12);

     if (promptfile_date.minute < 10)
          fprintf(fp_output, "0%d ", promptfile_date.minute);
     if (promptfile_date.minute >= 10)
          fprintf(fp_output, "%2d ", promptfile_date.minute);

     if (promptfile_date.hour < 12)
          fprintf(fp_output, "AM\n");
     if (promptfile_date.hour >= 12)
          fprintf(fp_output, "PM\n");

     /*
     ** External references: (any line with a GOTO in it is reproduced here)
     */

     fprintf(fp_output, "\n---\n");

     fprintf(fp_output, "\n%sLines Containing External References:%s ", bold, boff);

     if (external_references == 0)
          fprintf(fp_output, "(none)\n");
     else
     {
          fprintf(fp_output, "\n\n");
          for (i=0; i<external_references; i++)
          {
               fprintf(fp_output, "%s", external_line[i]);
               free(external_line[i]);
          }

          if ( external_references >= MAX_EXTERNALS )
               fprintf(fp_output, "\n-- more --\n");
     }

     /*
     ** Data Model: (any line beginning with [9200...9401] is reproduced here)
     */

     fprintf(fp_output, "\n---\n");

     fprintf(fp_output, "\n%sLines Containing Data Model Calls:%s ", bold, boff);

     if (data_model_references == 0)
          fprintf(fp_output, "(none)\n");
     else
     {
          fprintf(fp_output, "\n\n");
          for (i=0; i<data_model_references; i++)
          {
               fprintf(fp_output, "%s", data_model_line[i]);
               free(data_model_line[i]);
          }

          if ( data_model_references >= MAX_EXTERNALS )
               fprintf(fp_output, "\n-- more --\n");
     }

     none_displayed = TRUE;        /* so that we can print "none" */
     none_referenced = TRUE;       /* if there aren't any.        */
     none_modified = TRUE;

     for (i=1; i<=MAX_NUM_PROMPTS; i++)
     {
          if (prompt[i].displayed > 0)
               none_displayed = FALSE;

          if (prompt[i].referenced > 0)
               none_referenced = FALSE;

          if (prompt[i].modified > 0)
               none_modified = FALSE;
     }
     fprintf(fp_output, "\n---\n");

     /*
     ** Prompts displayed in this screen:
     */

     _splitpath(longfilename, drive, subdir, file, ext);

     fprintf(fp_output, "\n%sPrompts Displayed in This ", bold);

     if (strcmp(strupr(ext), ".SCN") == 0)
          fprintf(fp_output, "Screen:%s ", boff);
     else if (strcmp(strupr(ext), ".FRM") == 0)
          fprintf(fp_output, "Form:%s ", boff);
     else
          fprintf(fp_output, "File:%s ", boff);

     if (none_displayed)
          fprintf(fp_output, "(none)\n");
     else
     {
          fprintf(fp_output, "\n\n");

          if ( extended_report )
          {
               fprintf( fp_output, "%s NO.  TYPE     LENGTH BORROWER VARIABLES          WHERE               DISPLAYED %s\n\n",
                        ital, itoff );
          }
          else
          {
               fprintf( fp_output, "%s NO.  TYPE     LENGTH BORROWER VARIABLES                              DISPLAYED %s\n\n",
                        ital, itoff );
          }

          for (i=1; i<=MAX_NUM_PROMPTS; i++)
          {
               if(prompt[i].displayed > 0)
               {
                    if (i<10)
                         fprintf(fp_output, "   %d) %s", i,
                                prompt_type[prompt[i].type]);
                    else if (i<100)
                         fprintf(fp_output, "  %d) %s", i,
                                prompt_type[prompt[i].type]);
                    else if (i<1000)
                         fprintf(fp_output, " %d) %s", i,
                                prompt_type[prompt[i].type]);
                    else fprintf(fp_output, "%d) %s", i,
                                prompt_type[prompt[i].type]);

                    fprintf(fp_output, "\t ");

                    if (prompt[i].length < 100)
                         fprintf(fp_output, " ");

                    if (prompt[i].length < 10)
                         fprintf(fp_output, " ");

                    if (prompt[i].length > 0)
                    {
                         strcpy(spaces_line, spaces(47-strlen(prompt[i].name)));

                         fprintf( fp_output, "%d  %s %s%5d\n", prompt[i].length,
                                  prompt[i].name,
                                  spaces_line,
                                  prompt[i].displayed);

                         if ( extended_report )
                         {
                              /* do extended report stuff here */

                              strcpy(spaces_string, spaces(50));
                              fprintf(fp_output, "%s", spaces_string);
                              prompt_ref_count = 0;

                              prompt_ref_pointer = prompt[i].displayed_list;

                              while ( prompt_ref_pointer != NULL )
                              {
                                   ++prompt_ref_count;

                                   fprintf( fp_output, "[%ld] ",
                                            prompt_ref_pointer->linenumber );

                                   old_pointer = prompt_ref_pointer;
                                   prompt_ref_pointer = prompt_ref_pointer->next;
                                   free( old_pointer );

                                   if ( prompt_ref_count > 3 )
                                   {
                                        strcpy(spaces_string, spaces(50));
                                        fprintf(fp_output, "\n%s", spaces_string);
                                        prompt_ref_count = 0;
                                   }
                              }
                              fprintf(fp_output, "\n");
                         }
                    }
                    else
                    {
                         if (strcmp(prompt[i].name, "-->UNDEFINED<--") != 0)
                         {
                              strcpy(spaces_line, spaces(47-strlen(prompt[i].name)));

                              fprintf( fp_output, "   %s %s%5d\n",
                                       prompt[i].name,
                                       spaces_line,
                                       prompt[i].displayed);

                              if ( extended_report )
                              {
                                   /* do extended report stuff here */

                                   strcpy(spaces_string, spaces(50));
                                   fprintf(fp_output, "%s", spaces_string);
                                   prompt_ref_count = 0;

                                   prompt_ref_pointer = prompt[i].displayed_list;

                                   while ( prompt_ref_pointer != NULL )
                                   {
                                        ++prompt_ref_count;

                                        fprintf( fp_output, "[%ld] ",
                                                 prompt_ref_pointer->linenumber );

                                        old_pointer = prompt_ref_pointer;
                                        prompt_ref_pointer = prompt_ref_pointer->next;
                                        free( old_pointer );

                                        if ( prompt_ref_count > 3 )
                                        {
                                             strcpy(spaces_string, spaces(50));
                                             fprintf(fp_output, "\n%s", spaces_string);
                                             prompt_ref_count = 0;
                                        }
                                   }
                                   fprintf(fp_output, "\n");
                              }
                         }
                         else
                         {
                              strcpy(spaces_line, spaces(67));

                                   fprintf( fp_output, "%s %5d\n",
                                            spaces_line,
                                            prompt[i].displayed);

                              if ( extended_report )
                              {
                                   /* do extended report stuff here */

                                   strcpy(spaces_string, spaces(50));
                                   fprintf(fp_output, "%s", spaces_string);
                                   prompt_ref_count = 0;

                                   prompt_ref_pointer = prompt[i].displayed_list;

                                   while ( prompt_ref_pointer != NULL )
                                   {
                                        ++prompt_ref_count;

                                        fprintf( fp_output, "[%ld] ",
                                                 prompt_ref_pointer->linenumber );

                                        old_pointer = prompt_ref_pointer;
                                        prompt_ref_pointer = prompt_ref_pointer->next;
                                        free( old_pointer );

                                        if ( prompt_ref_count > 3 )
                                        {
                                             strcpy(spaces_string, spaces(50));
                                             fprintf(fp_output, "\n%s", spaces_string);
                                             prompt_ref_count = 0;
                                        }
                                   }
                                   fprintf(fp_output, "\n");
                              }
                         }
                    }
               }
          }
     }

     /*
     ** Prompts referenced in this screen:
     */

     fprintf(fp_output, "\n---\n\n%sPrompts Referred To in This ", bold);

     if (strcmp(strupr(ext), ".SCN") == 0)
          fprintf(fp_output, "Screen:%s ", boff);
     else if (strcmp(strupr(ext), ".FRM") == 0)
          fprintf(fp_output, "Form:%s ", boff);
     else
          fprintf(fp_output, "File:%s ", boff);

     if (none_referenced)
          fprintf(fp_output, "(none)\n");
     else
     {
          fprintf(fp_output, "\n\n");

          if ( extended_report )
          {
               fprintf( fp_output, "%s NO.  TYPE     LENGTH BORROWER VARIABLES          WHERE              REFERENCED %s\n\n",
                        ital, itoff );
          }
          else
          {
               fprintf( fp_output, "%s NO.  TYPE     LENGTH BORROWER VARIABLES                             REFERENCED %s\n\n",
                        ital, itoff );
          }

          for (i=1; i<=MAX_NUM_PROMPTS; i++)
          {
               if(prompt[i].referenced > 0)
               {
                    if (i<10)
                         fprintf(fp_output, "   %d) %s", i,
                                prompt_type[prompt[i].type]);
                    else if (i<100)
                         fprintf(fp_output, "  %d) %s", i,
                                prompt_type[prompt[i].type]);
                    else if (i<1000)
                         fprintf(fp_output, " %d) %s", i,
                                prompt_type[prompt[i].type]);
                    else fprintf(fp_output, "%d) %s", i,
                                prompt_type[prompt[i].type]);

                    fprintf(fp_output, "\t ");

                    if (prompt[i].length < 100)
                         fprintf(fp_output, " ");

                    if (prompt[i].length < 10)
                         fprintf(fp_output, " ");

                    if (prompt[i].length > 0)
                    {
                         strcpy(spaces_line, spaces(47-strlen(prompt[i].name)));

                         fprintf( fp_output, "%d  %s %s%5d\n", prompt[i].length,
                                  prompt[i].name,
                                  spaces_line,
                                  prompt[i].referenced);

                         if ( extended_report )
                         {
                              /* do extended report stuff here */

                              strcpy(spaces_string, spaces(50));
                              fprintf(fp_output, "%s", spaces_string);
                              prompt_ref_count = 0;

                              prompt_ref_pointer = prompt[i].referenced_list;

                              while ( prompt_ref_pointer != NULL )
                              {
                                   ++prompt_ref_count;

                                   fprintf( fp_output, "[%ld] ",
                                            prompt_ref_pointer->linenumber );

                                   old_pointer = prompt_ref_pointer;
                                   prompt_ref_pointer = prompt_ref_pointer->next;
                                   free( old_pointer );

                                   if ( prompt_ref_count > 3 )
                                   {
                                        strcpy(spaces_string, spaces(50));
                                        fprintf(fp_output, "\n%s", spaces_string);
                                        prompt_ref_count = 0;
                                   }
                              }
                              fprintf(fp_output, "\n");
                         }
                    }
                    else
                    {
                         if (strcmp(prompt[i].name, "-->UNDEFINED<--") != 0)
                         {
                              strcpy(spaces_line, spaces(47-strlen(prompt[i].name)));

                              fprintf( fp_output, "   %s %s%5d\n",
                                       prompt[i].name,
                                       spaces_line,
                                       prompt[i].referenced);

                              if ( extended_report )
                              {
                                   /* do extended report stuff here */

                                   strcpy(spaces_string, spaces(50));
                                   fprintf(fp_output, "%s", spaces_string);
                                   prompt_ref_count = 0;

                                   prompt_ref_pointer = prompt[i].referenced_list;

                                   while ( prompt_ref_pointer != NULL )
                                   {
                                        ++prompt_ref_count;

                                        fprintf( fp_output, "[%ld] ",
                                                 prompt_ref_pointer->linenumber );

                                        old_pointer = prompt_ref_pointer;
                                        prompt_ref_pointer = prompt_ref_pointer->next;
                                        free( old_pointer );

                                        if ( prompt_ref_count > 3 )
                                        {
                                             strcpy(spaces_string, spaces(50));
                                             fprintf(fp_output, "\n%s", spaces_string);
                                             prompt_ref_count = 0;
                                        }
                                   }
                                   fprintf(fp_output, "\n");
                              }
                         }
                         else
                         {
                              strcpy(spaces_line, spaces(67));

                              fprintf( fp_output, "%s %5d\n",
                                       spaces_line,
                                       prompt[i].referenced);

                              if ( extended_report )
                              {
                                   /* do extended report stuff here */

                                   strcpy(spaces_string, spaces(50));
                                   fprintf(fp_output, "%s", spaces_string);
                                   prompt_ref_count = 0;

                                   prompt_ref_pointer = prompt[i].referenced_list;

                                   while ( prompt_ref_pointer != NULL )
                                   {
                                        ++prompt_ref_count;

                                        fprintf( fp_output, "[%ld] ",
                                                 prompt_ref_pointer->linenumber );

                                        old_pointer = prompt_ref_pointer;
                                        prompt_ref_pointer = prompt_ref_pointer->next;
                                        free( old_pointer );

                                        if ( prompt_ref_count > 3 )
                                        {
                                             strcpy(spaces_string, spaces(50));
                                             fprintf(fp_output, "\n%s", spaces_string);
                                             prompt_ref_count = 0;
                                        }
                                   }
                                   fprintf(fp_output, "\n");
                              }
                         }
                    }
               }
          }
     }

     /*
     ** Prompts modified in this screen:
     */

     fprintf(fp_output, "\n---\n\n%sPrompts Modified in This ", bold);

     if (strcmp(strupr(ext), ".SCN") == 0)
          fprintf(fp_output, "Screen:%s ", boff);
     else if (strcmp(strupr(ext), ".FRM") == 0)
          fprintf(fp_output, "Form:%s ", boff);
     else
          fprintf(fp_output, "File:%s ", boff);

     if (none_modified)
          fprintf(fp_output, "(none)\n");
     else
     {
          fprintf(fp_output, "\n\n");

          if ( extended_report )
          {
               fprintf( fp_output, "%s NO.  TYPE     LENGTH BORROWER VARIABLES          WHERE                MODIFIED %s\n\n",
                        ital, itoff );
          }
          else
          {
               fprintf( fp_output, "%s NO.  TYPE     LENGTH BORROWER VARIABLES                               MODIFIED %s\n\n",
                        ital, itoff );
          }

          for (i=1; i<=MAX_NUM_PROMPTS; i++)
          {
               if(prompt[i].modified > 0)
               {
                    if (i<10)
                         fprintf(fp_output, "   %d) %s", i,
                                prompt_type[prompt[i].type]);
                    else if (i<100)
                         fprintf(fp_output, "  %d) %s", i,
                                prompt_type[prompt[i].type]);
                    else if (i<1000)
                         fprintf(fp_output, " %d) %s", i,
                                prompt_type[prompt[i].type]);
                    else fprintf(fp_output, "%d) %s", i,
                                prompt_type[prompt[i].type]);

                    fprintf(fp_output, "\t ");

                    if (prompt[i].length < 100)
                         fprintf(fp_output, " ");

                    if (prompt[i].length < 10)
                         fprintf(fp_output, " ");

                    if (prompt[i].length > 0)
                    {
                         strcpy(spaces_line, spaces(47-strlen(prompt[i].name)));

                         fprintf( fp_output, "%d  %s %s%5d\n", prompt[i].length,
                                  prompt[i].name,
                                  spaces_line,
                                  prompt[i].modified);

                         if ( extended_report )
                         {
                              /* do extended report stuff here */

                              strcpy(spaces_string, spaces(50));
                              fprintf(fp_output, "%s", spaces_string);
                              prompt_ref_count = 0;

                              prompt_ref_pointer = prompt[i].modified_list;

                              while ( prompt_ref_pointer != NULL )
                              {
                                   ++prompt_ref_count;

                                   fprintf( fp_output, "[%ld] ",
                                            prompt_ref_pointer->linenumber );

                                   old_pointer = prompt_ref_pointer;
                                   prompt_ref_pointer = prompt_ref_pointer->next;
                                   free( old_pointer );

                                   if ( prompt_ref_count > 3 )
                                   {
                                        strcpy(spaces_string, spaces(50));
                                        fprintf(fp_output, "\n%s", spaces_string);
                                        prompt_ref_count = 0;
                                   }
                              }
                              fprintf(fp_output, "\n");
                         }
                    }
                    else
                    {
                         if (strcmp(prompt[i].name, "-->UNDEFINED<--") != 0)
                         {
                              strcpy(spaces_line, spaces(47-strlen(prompt[i].name)));

                              fprintf( fp_output, "   %s %s%5d\n",
                                       prompt[i].name,
                                       spaces_line,
                                       prompt[i].modified);

                              if ( extended_report )
                              {
                                   /* do extended report stuff here */

                                   strcpy(spaces_string, spaces(50));
                                   fprintf(fp_output, "%s", spaces_string);
                                   prompt_ref_count = 0;

                                   prompt_ref_pointer = prompt[i].modified_list;

                                   while ( prompt_ref_pointer != NULL )
                                   {
                                        ++prompt_ref_count;

                                        fprintf( fp_output, "[%ld] ",
                                                 prompt_ref_pointer->linenumber );

                                        old_pointer = prompt_ref_pointer;
                                        prompt_ref_pointer = prompt_ref_pointer->next;
                                        free( old_pointer );

                                        if ( prompt_ref_count > 3 )
                                        {
                                             strcpy(spaces_string, spaces(50));
                                             fprintf(fp_output, "\n%s", spaces_string);
                                             prompt_ref_count = 0;
                                        }
                                   }
                                   fprintf(fp_output, "\n");
                              }
                         }
                         else
                         {
                              strcpy(spaces_line, spaces(67));

                              fprintf( fp_output, "%s %5d\n",
                                       spaces_line,
                                       prompt[i].modified);

                              if ( extended_report )
                              {
                                   /* do extended report stuff here */

                                   strcpy(spaces_string, spaces(50));
                                   fprintf(fp_output, "%s", spaces_string);
                                   prompt_ref_count = 0;

                                   prompt_ref_pointer = prompt[i].modified_list;

                                   while ( prompt_ref_pointer != NULL )
                                   {
                                        ++prompt_ref_count;

                                        fprintf( fp_output, "[%ld] ",
                                                 prompt_ref_pointer->linenumber );

                                        old_pointer = prompt_ref_pointer;
                                        prompt_ref_pointer = prompt_ref_pointer->next;
                                        free( old_pointer );

                                        if ( prompt_ref_count > 3 )
                                        {
                                             strcpy(spaces_string, spaces(50));
                                             fprintf(fp_output, "\n%s", spaces_string);
                                             prompt_ref_count = 0;
                                        }
                                   }
                                   fprintf(fp_output, "\n");
                              }
                         }
                    }
               }
          }
     }

     /*
     ** End of List Report:
     */

     fprintf(fp_output, "\n---\n\n");

     /*
     **  Print the name of this program (LIST).
     */

     fprintf(fp_output, "%s", bold);
     fprintf(fp_output, NAME);
     fprintf(fp_output, " -- File OK %s\n\n", boff);

#ifdef DIAGNOSTICS
     fprintf(stderr, "Exit PRINT_LIST_REPORT\n");
#endif

     return(0);
}