home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* */
- /* MFLTIME Header file */
- /* */
- /* Function prototypes for time-related functions. */
- /* */
- /* Copyright 1989 by Robert B. Stout dba MicroFirm */
- /* All rights reserved */
- /* */
- /* Copyright 1986, 1987 by S.E. Margison */
- /* */
- /* Compiled by QC 2.0 for use with MSC 5.1 or QC 2.0 or later. */
- /* */
- /************************************************************************/
-
- #ifndef MFLTIME_H
- #define MFLTIME_H
-
- #include <stdio.h>
- #include <time.h>
- #include <mfldefs.h>
-
- #ifndef _Cdecl_
- #ifdef NO_EXT_KEYS
- #define _Cdecl_
- #else
- #define _Cdecl_ cdecl
- #endif
- #endif
-
- /************************************************************************/
- /* */
- /* Microsecond accuracy timing operations. */
- /* */
- /************************************************************************/
-
- typedef unsigned long uclock_t;
-
- #define UCLK_TCK 1000000L /* Usec per second - replaces CLK_TCK */
- #define usec_difftime(start,finish) (finish-start)
-
- uclock_t _Cdecl_ usec_clock(void);
- void _Cdecl_ restart_uclock(void);
- uclock_t _Cdecl_ usec_delay(uclock_t);
- LOGICAL _Cdecl_ usec_timeout(uclock_t, uclock_t, uclock_t);
- void _Cdecl_ msec_pause(long);
-
- /************************************************************************/
- /* */
- /* ANSI functions */
- /* */
- /************************************************************************/
-
- size_t _Cdecl_ strftime(char *, size_t, const char *, const struct tm *);
-
- /************************************************************************/
- /* */
- /* Julian (scalar) date functions */
- /* */
- /************************************************************************/
-
- long _Cdecl_ ymd_to_julian (unsigned, unsigned, unsigned);
- void _Cdecl_ julian_to_ymd (long, unsigned *, unsigned *, unsigned *);
- int _Cdecl_ julian_to_wkday(long);
- char * _Cdecl_ julian_to_dayname(long);
- unsigned _Cdecl_ julian_to_yrday(long);
- LOGICAL _Cdecl_ julian_to_time(long, time_t *);
- LOGICAL _Cdecl_ julian_to_tm(long, struct tm *);
- long _Cdecl_ time_to_julian(time_t);
- long _Cdecl_ tm_to_julian(struct tm *);
-
- /************************************************************************/
- /* */
- /* Structures & functions for accessing file dates and times */
- /* */
- /************************************************************************/
-
- #ifndef FTIME_DEF__
- #define FTIME_DEF__
-
- struct ftime {
- unsigned int ft_tsec : 5;
- unsigned int ft_min : 6;
- unsigned int ft_hour : 5;
- unsigned int ft_day : 5;
- unsigned int ft_month : 4;
- unsigned int ft_year : 7;
- } ;
-
- int _Cdecl_ getftime(int, struct ftime *);
- int _Cdecl_ setftime(int, struct ftime *);
- int _Cdecl_ touch(char *);
- void _Cdecl_ get_filetime(struct tm *, int);
-
- #endif /* FTIME_DEF__ */
-
- /************************************************************************/
- /* */
- /* Misc functions */
- /* */
- /************************************************************************/
-
- void _Cdecl_ installtick(int *),
- _Cdecl_ removetick(void),
- _Cdecl_ gtodsub(FILE *),
- _Cdecl_ gtodstr(char *);
-
- int _Cdecl_ daynum(int, int, int),
- _Cdecl_ isleap(unsigned),
- _Cdecl_ weekday(int, int, int);
-
- char * _Cdecl_ monthis(int),
- * _Cdecl_ wkdayname(int);
-
- /************************************************************************/
- /* */
- /* Alternative file date and time functions */
- /* */
- /************************************************************************/
-
- struct DOS_TIME
- {
- unsigned int ss : 5;
- unsigned int mm : 6;
- unsigned int hh : 5;
- } ;
-
- struct DOS_DATE
- {
- unsigned int da : 5;
- unsigned int mo : 4;
- unsigned int yr : 7;
- } ;
-
- #define dos_time(t) (*(struct DOS_TIME *)(&(t)))
- #define dos_date(t) (*(struct DOS_DATE *)(&(t)))
-
- /*
- ** Demo code for using above structures
- */
-
- #if 0
- *************************************************************************
- * *
- * /* Sample file date and time display.*/ *
- * *
- * #include <stdio.h> *
- * #include <dos.h> *
- * *
- * main(int argc, char *argv[]) *
- * { *
- * struct FIND *ffblk; *
- * *
- * if (2 > argc) *
- * { *
- * puts("\aUsage: SHOWDATE filename[.ext]"); *
- * exit(1); *
- * } *
- * if (!(ffblk = findfirst(argv[1], 0xff))) *
- * { *
- * printf("\aCant find %s\n", argv[1]); *
- * exit(2); *
- * } *
- * printf("File date is %d-%d-%d\n", *
- * dos_date(ffblk->date).mo, *
- * dos_date(ffblk->date).da, *
- * (dos_date(ffblk->date).yr + 80) % 100); *
- * printf("File time is %d:%d:%d\n", *
- * dos_time(ffblk->time).hh, *
- * dos_time(ffblk->time).mm, *
- * dos_time(ffblk->time).ss); *
- * } *
- * *
- *************************************************************************
- #endif /* 0 */
-
- #endif /* MFLTIME_H */
-