'_dos_getftime'에 해당되는 글 1건

  1. 2021.06.21 Watcom C Library Reference : _dos_getftime, _dos_gettime, _dos_getvect, _dos_keep

 

 

Watcom C Library Reference : _dos_getftime, _dos_gettime, _dos_getvect, _dos_keep

 

 

 

 

_dos_getftime

 

Synopsis : #include <dos.h> 

              unsigned _dos_getftime( int handle, unsigned short *date, unsigned short *time );


Description : The _dos_getftime function uses system call 0x57 to get the date and time that the file associated with handle was last modified. The date consists of the year, month and de packed into 16 bits as follows:

 Bits  Meaning
 bits 0-4  Day (1-31)
 bits 5-8  Month (1-12)
 bits 9-15  Year (0-119 representing 1980-2099)

 

The time consists of the hour, minute and seconds/2 packed into 16 bits as follows:

 Bits  Meaning
 bits 0-4  Seconds/2 (0-29)
 bits 5-10  Minutes (0-59)
 bits 11-15  Hours (0-23)

 

 

Returns : The _dos_getftime function returns zero if successful. Otherwise, it returns an MS-DOS error code and sets errno to one of the following values: 

 Value  Meaning
 EBADF  Invalid file handle

 


See Also : _dos_setftime

 


Example :

#include <stdio.h> 

#include <dos.h> 

#include <fcntl.h>


#define YEAR (t)         (((t & 0xFE00) >> 9) + 1980)

#define MONTH (t)       ((t & 0x01E0) >> 5)

#define DAY (t)           (t & 0x001F)

#define HOUR (t)         ((t & 0xF800) >> 11)

#define MINUTE (t)       ((t & 0x07E0) >> 5)

#define SECOND (t)     ((t & 0x001F) << 1)


void main( )

{
    int handle;

    unsigned short date, time;

 

    if( _dos_open ( "file" O_RDONLY, &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) );

       _dos_close( handle );

    }

}

 


produces the following:
Open succeeded The file was last modified on 12/29/1989 at 14:32:46

 

Classification : DOS
Systems : DOS, Win, OS/2 1.x(all), OS/2 2.x, NT, DOS/PM

 

 

 

 

 

_dos_gettime

 

Synopsis : #include <dos.h> 

              void _dos_gettime ( struct dostime_t *time );
              struct dostime_t {
                      unsigned char hour;        /* 0-23 */

                      unsigned char minute;      /* 0-59 */

                      unsigned char second;     /* 0-59 */

                      unsigned char hsecond;    /* 1/100 second;  0-99 */

              };
   


Description : The _dos_gettime function uses system call 0x2C to get the current system time. The time information is returned in a dostime_t structure pointed to by time.

 

 

Returns : The _dos_gettime function has no return value.

 

 

See Also : _dos_getdate, _dos_setdate, _dos_settime, gmtime, localtime, mktime, time

 


Example :

#include <stdio.h> 

#include <dos.h>


void main( )

{
    struct dosdate_t date;

    struct dostime_t time;


    /* Get and display the current date and time */

    _dos_getdate( &date );

    _dos_gettime ( &time );

 

    printf( "The date (MM-DD-YYYY) is : %d-%d-%d\n", date.month, date.day, date.year ); 

    printf( "The time (HH:MM:SS) is : %.2d:%.2d:%.2d\n", time.hour, time.minute, time.second );

}

 


produces the following:
The date (MM-DD-YYYY) is : 12-31-1999

The time (HH:MM:SS) is: 14:22:22

 

Classification : DOS
Systems : DOS, Win, OS/2 1.x(all), OS/2 2.x, NT, DOS/PM

 

 

 

 

 

_dos_getvect

 

Synopsis : #include <dos.h> 

              void (__interrupt __far *_dos_getvect (unsigned intnum) )( );

 


Description : The _dos_getvect function gets the current value of interrupt vector number intnum.

 

 

Returns : The function returns a far pointer to the current interrupt handler for interrupt number intnum.

 

 

See Also : _chain_intr, _dos_keep, _dos_setvect


Example :

#include <stdio.h> 

#include <dos.h>


volatile int clock_ticks; 

void (__interrupt __far *prev_int_1c) ( );

#define BLIP_COUNT (5*18)     /* 5 seconds */


void __interrupt __far timer_rtn( )

{
    ++clock_ticks;

    _chain_intr( prev_int_1c );

}


int delays = 0;


int compile_a_line( )

{
    if( delays > 15 ) return( 0 );

    delay ( 1000 );     /* delay for 1 second */

 

    printf( "Delayed for 1 second\n" );

    delays++;

    return( 1 );

}

 


void main( )

{
    prev_int_1c = _dos_getvect ( 0xlc );

    _dos_setvect ( 0xlc, timer_rtn);

 

    while ( compile_a_line ( ) ) {

        if( clock_ticks >= BLIP_COUNT ) {
            putchar( '.' );

            clock_ticks -= BLIP_COUNT;

        }

    }
    _dos_setvect( 0xlc, prev_int_1c );

}

 

Classification : WATCOM
Systems : DOS, Win/16, DOS/PM

 

 

 

 

 

_dos_keep

 

Synopsis : #include <dos.h> 

              void _dos_keep ( unsigned retcode, unsigned memsize );

 


Description : The _dos_keep function is used to install terminate-and-stay-resident programs ("TSR's") in memory. The amount of memory kept for the program is memsize paragraphs (a paragraph is 16 bytes) from the Program Segment Prefix which is stored in the variable _psp. The value of retcode is returned to the parent process.

 

 

Returns : The _dos_keep function does not return.

 

 

See Also : _chain_intr, _dos_getvect, _dos_setvect

 


Example :

#include <dos.h>


void permanent( )

{
    /*  .  */

    /*  .  */

    /*  .  */

}


void transient( )

{

    /*  .  */

    /*  .  */

    /*  .  */

}



void main( )

{
    /* initialize our TSR */

    transient( );


    /*  now terminate and keep resident the non-transient portion */

    _dos_keep( 0, (FP_OFF ( transient ) + 15) >> 4 );

}

 

Classification : DOS
Systems : DOS

 

 

 

 

 

 

 

This manual describes the WATCOM C library for DOS, Windows, and OS/2, It includes the Standard C Library (as defined in the ANSI C Standard).

 

WATCOM C Language Reference manual describes the ANSI C Programming language and extensions to it which are supported by WATCOM C/C++ (32bit)

 

 

 

728x90
반응형
Posted by 전화카드
,