home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 28
/
amigaformatcd28.iso
/
-seriously_amiga-
/
archivers
/
arcppc
/
src
/
rcs
/
arcdos.c,v
< prev
next >
Wrap
Text File
|
1998-04-23
|
9KB
|
527 lines
head 1.8;
branch ;
access ;
symbols patch2:1.8 patch1:1.6;
locks ; strict;
comment @ * @;
1.8
date 88.08.01.15.07.15; author hyc; state Exp;
branches ;
next 1.7;
1.7
date 88.08.01.14.32.06; author hyc; state Exp;
branches ;
next 1.6;
1.6
date 88.07.31.18.48.09; author hyc; state Exp;
branches ;
next 1.5;
1.5
date 88.06.13.00.40.49; author hyc; state Exp;
branches ;
next 1.4;
1.4
date 88.06.01.19.17.43; author hyc; state Exp;
branches ;
next 1.3;
1.3
date 88.06.01.15.27.01; author hyc; state Exp;
branches ;
next 1.2;
1.2
date 88.06.01.15.21.53; author hyc; state Exp;
branches ;
next 1.1;
1.1
date 88.04.11.17.53.31; author hyc; state Exp;
branches ;
next ;
desc
@@
1.8
log
@Stick timeval definition into UNIX conditionals
@
text
@/*
* $Header: arcdos.c,v 1.7 88/08/01 14:32:06 hyc Locked $
*/
/*
* ARC - Archive utility - ARCDOS
*
* Version 1.44, created on 07/25/86 at 14:17:38
*
* (C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
*
* By: Thom Henderson
*
* Description: This file contains certain DOS level routines that assist in
* doing fancy things with an archive, primarily reading and setting the date
* and time last modified.
*
* These are, by nature, system dependant functions. But they are also, by
* nature, very expendable.
*
* Language: Computer Innovations Optimizing C86
*/
#include <stdio.h>
#include "arc.h"
#if MSDOS
#include "fileio2.h" /* needed for filehand */
#endif
#if UNIX
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
struct timeval { /* man page said <sys/types.h>, but it */
long tv_sec; /* really seems to be in <sys/time.h>, */
long tv_usec; /* but why bother... */
};
#endif
#if GEMDOS
#include <osbind.h>
#endif
char *strcpy(), *strcat(), *malloc();
void
getstamp(f, date, time) /* get a file's date/time stamp */
#if !MTS
FILE *f; /* file to get stamp from */
#else
char *f; /* filename "" "" */
#endif
unsigned short *date, *time; /* storage for the stamp */
{
#if MSDOS
struct {
int ax, bx, cx, dx, si, di, ds, es;
} reg;
reg.ax = 0x5700; /* get date/time */
reg.bx = filehand(f); /* file handle */
if (sysint21(®, ®) & 1) /* DOS call */
printf("Get timestamp fail (%d)\n", reg.ax);
*date = reg.dx; /* save date/time */
*time = reg.cx;
#endif
#if GEMDOS
int fd, ret[2];
fd = fileno(f);
Fdatime(ret, fd, 0);
*date = ret[1];
*time = ret[0];
#endif
#if UNIX
struct stat buf;
struct tm *localtime(), *t;
fstat(fileno(f), &buf);
t=localtime(&(buf.st_mtime));
*date = (unsigned short) (((t->tm_year - 80) << 9) +
((t->tm_mon + 1) << 5) + t->tm_mday);
*time = (unsigned short) ((t->tm_hour << 11) +
(t->tm_min << 5) + t->tm_sec / 2);
#endif
#if MTS
fortran timein(),
#if USEGFINFO
gfinfo();
#else
fileinfo();
#endif
int stclk[2];
char name[24];
struct bigtime {
int greg;
int year;
int mon;
int day;
int hour;
int min;
int sec;
int usec;
int week;
int toff;
int tzn1;
int tzn2;
} tvec;
#if USEGFINFO
static int gfflag = 0x0009, gfdummy[2] = {
0, 0
};
int gfcinfo[18];
#else
static int cattype = 2;
#endif
strcpy(name, f);
strcat(name, " ");
#if USEGFINFO
gfcinfo[0] = 18;
gfinfo(name, name, &gfflag, gfcinfo, gfdummy, gfdummy);
timein("*IBM MICROSECONDS*", &gfcinfo[16], &tvec);
#else
fileinfo(name, &cattype, "CILCCT ", stclk);
timein("*IBM MICROSECONDS*", stclk, &tvec);
#endif
*date = (unsigned short) (((tvec.year - 1980) << 9) + ((tvec.mon) << 5) + tvec.day);
*time = (unsigned short) ((tvec.hour << 11) + (tvec.min << 5) + tvec.sec / 2);
#endif
}
void
setstamp(f, date, time) /* set a file's date/time stamp */
char *f; /* filename to stamp */
unsigned short date, time; /* desired date, time */
{
#if MSDOS
FILE *ff;
struct {
int ax, bx, cx, dx, si, di, ds, es;
} reg;
ff = fopen(f, "w+"); /* How else can I get a handle? */
reg.ax = 0x5701; /* set date/time */
reg.bx = filehand(f); /* file handle */
reg.cx = time; /* desired time */
reg.dx = date; /* desired date */
if (sysint21(®, ®) & 1) /* DOS call */
printf("Set timestamp fail (%d)\n", reg.ax);
fclose(ff);
#endif
#if GEMDOS
int fd, set[2];
fd = Fopen(f, 0);
set[0] = time;
set[1] = date;
Fdatime(set, fd, 1);
Fclose(fd);
#endif
#if UNIX
struct tm tm;
struct timeval tvp[2];
int utimes();
tm.tm_sec = (time & 31) * 2;
tm.tm_min = (time >> 5) & 63;
tm.tm_hour = (time >> 11);
tm.tm_mday = date & 31;
tm.tm_mon = ((date >> 5) & 15) - 1;
tm.tm_year = (date >> 9) + 80;
tvp[0].tv_sec = tmclock(&tm);
tvp[1].tv_sec = tvp[0].tv_sec;
tvp[0].tv_usec = tvp[1].tv_usec = 0;
utimes(f, tvp);
#endif
}
#if MSDOS
int
filehand(stream) /* find handle on a file */
struct bufstr *stream; /* file to grab onto */
{
return stream->bufhand; /* return DOS 2.0 file handle */
}
#endif
#if UNIX
int
izadir(filename) /* Is filename a directory? */
char *filename;
{
struct stat buf;
if (stat(filename, &buf) != 0)
return (0); /* Ignore if stat fails since */
else
return (buf.st_mode & S_IFDIR); /* bad files trapped later */
}
#endif
@
1.7
log
@Fix up include file dependency, use tmclock() instead of twsclock().
@
text
@d2 1
a2 1
* $Header: arcdos.c,v 1.6 88/07/31 18:48:09 hyc Locked $
a33 1
#endif
d39 1
@
1.6
log
@Fixup time processing, fix a typo in declarations, fix args
to fopen...
@
text
@d2 1
a2 1
* $Header: arcdos.c,v 1.5 88/06/13 00:40:49 hyc Locked $
d33 1
a33 2
#include <sys/time.h>
#include "tws.h"
d36 3
a38 5
#if SYSV
#include <sys/times.h>
struct timeval {
long tv_sec;
long tv_usec;
a39 1
#endif
d167 1
a167 1
struct tws tms;
d170 7
a176 10
twscopy(&tms, dtwstime());
tms.tw_sec = (time & 31) * 2;
tms.tw_min = (time >> 5) & 63;
tms.tw_hour = (time >> 11);
tms.tw_mday = date & 31;
tms.tw_mon = ((date >> 5) & 15) - 1;
tms.tw_year = (date >> 9) + 80;
tms.tw_clock = 0L;
tms.tw_flags = TW_NULL;
tvp[0].tv_sec = twclock(&tms);
@
1.5
log
@Changed setstamp's mechanics a little bit...
Uses a filename now, instead of a descriptor.
@
text
@d2 1
a2 1
* $Header: arcdos.c,v 1.4 88/06/01 19:17:43 hyc Locked $
d38 1
d82 2
a83 6
struct stat *buf;
int day, hr, min, sec, yr, imon;
static char mon[4], *mons[12] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
d85 6
a90 9
buf = (struct stat *) malloc(sizeof(struct stat));
fstat(fileno(f), buf);
sscanf(ctime(&(buf->st_mtime)), "%*4s%3s%d%d:%d:%d%d", mon, &day, &hr, &min,
&sec, &yr);
for (imon = 0; imon < 12 && strcmp(mon, mons[imon]); imon++);
*date = (unsigned short) (((yr - 1980) << 9) + ((imon + 1) << 5) + day);
*time = (unsigned short) ((hr << 11) + (min << 5) + sec / 2);
d173 1
@
1.4
log
@Change compilation conditionals
@
text
@d2 1
a2 1
* $Header: arcdos.c,v 1.3 88/06/01 15:27:01 hyc Locked $
a147 1
#if !MSDOS
a148 3
#else
FILE *f; /* file to set stamp on */
#endif
d152 1
d157 1
a157 1
fflush(f); /* force any pending output */
d165 1
d187 1
@
1.3
log
@Merge Atari ST code
@
text
@d2 1
a2 1
* $Header: arcdos.c,v 1.2 88/06/01 15:21:53 hyc Locked $
d26 1
a26 1
#ifdef MSDOS
d30 1
a30 1
#ifdef BSD
d37 1
a37 1
#ifdef SYSV
d44 1
a44 1
#ifdef GEMDOS
d52 1
a52 1
#ifndef MTS
d59 1
a59 1
#ifdef MSDOS
d72 1
a72 1
#ifdef GEMDOS
d80 1
a80 1
#ifdef BSD
d98 1
a98 1
#ifdef MTS
d100 1
a100 1
#ifdef USEGFINFO
d121 1
a121 1
#ifdef USEGFINFO
d132 1
a132 1
#ifdef USEGFINFO
d148 1
a148 1
#ifndef MSDOS
d155 1
a155 1
#ifdef MSDOS
d169 1
a169 1
#ifdef GEMDOS
d178 1
a178 1
#ifdef BSD
d196 1
a196 1
#ifdef MSDOS
d205 1
a205 1
#ifdef BSD
@
1.2
log
@Fixed declarations
@
text
@d2 1
a2 1
* $Header: arcdos.c,v 1.8 88/04/19 01:39:36 hyc Exp $
d44 4
d72 8
d148 1
a148 1
#ifdef BSD
d169 9
d205 1
a209 3
#ifndef BSD
return (0);
#else
d216 1
a217 1
}
@
1.1
log
@Initial revision
@
text
@d2 1
a2 14
* $Log: arcdos.c,v $
* Revision 1.2 87/12/19 04:20:26 hyc
* Replace reference to f->_file with fileno(f)
*
* Revision 1.1 87/12/19 04:19:40 hyc
* Initial revision
*
* Revision 1.4 87/08/13 17:03:16 hyc
* Run thru the indent program...
* Revision 1.3 87/07/21 11:40:35 hyc *** empty
* log message ***
*
* Revision 1.2 87/07/21 07:22:17 hyc added BSD goodies
*
d25 1
d29 1
d37 10
a46 1
INT
d48 1
a48 1
# ifndef MTS
d53 1
a53 1
unsigned INT *date, *time; /* storage for the stamp */
d83 2
a84 2
*date = (unsigned INT) (((yr - 1980) << 9) + ((imon + 1) << 5) + day);
*time = (unsigned INT) ((hr << 11) + (min << 5) + sec / 2);
d129 2
a130 2
*date = (unsigned INT) (((tvec.year - 1980) << 9) + ((tvec.mon) << 5) + tvec.day);
*time = (unsigned INT) ((tvec.hour << 11) + (tvec.min << 5) + tvec.sec / 2);
d134 1
a134 1
INT
d136 1
a136 1
# ifdef BSD
d141 1
a141 1
unsigned INT date, time; /* desired date, time */
d175 2
a176 1
INT
a179 1
#ifdef MSDOS
d181 1
a182 1
}
d184 1
a184 1
INT
@