Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use time_t in bootlib #405

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions unix/boot/bootProto.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
*/

#include <time.h>

#define import_spp
#define import_knames
#include <iraf.h>
Expand Down Expand Up @@ -36,14 +38,14 @@ void os_putenv (char *name, char *value);
int os_read (int fd, char *buf, int nbytes);
int os_setfmode (char *fname, int mode);
int os_setowner (char *fname, int uid, int gid);
int os_setmtime (char *fname, long mtime);
int os_setmtime (char *fname, time_t mtime);
char *os_strpak (XCHAR *sppstr, char *cstr, int maxch);
XCHAR *os_strupk (char *str, XCHAR *outstr, int maxch);
char *os_subdir (char *dir, char *subdir);
int os_symlink (char *fname, char *valbuf, int maxch);
int os_sysfile (char *sysfile, char *fname, int maxch);
char *os_irafpath (char *sysfile);
long os_utime (long iraf_time);
long os_itime (long unix_time);
time_t os_utime (time_t iraf_time);
time_t os_itime (time_t unix_time);
int os_write (int fd, char *buf, int nbytes);
char *vfn2osfn (char *vfn, int new);
13 changes: 6 additions & 7 deletions unix/boot/bootlib/ossettime.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
*/

#include <unistd.h>
#include <utime.h>
#include "bootlib.h"


Expand All @@ -12,13 +12,12 @@
int
os_setmtime (
char *fname,
long mtime
time_t mtime
)
{
struct timeval tvp[2];
struct utimbuf times;

tvp[0].tv_sec = tvp[1].tv_sec = mtime;
tvp[0].tv_usec = tvp[1].tv_usec = 0L;

return (utimes (vfn2osfn(fname,0), tvp));
times.actime = mtime;
times.modtime = mtime;
return (utime (vfn2osfn(fname, 0), &times));
}
16 changes: 8 additions & 8 deletions unix/boot/bootlib/ostime.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ static long os_timezone(void);
* daylight savings time (1 hour), and file times will come out a bit off
* but it probably won't matter.
*/
long
os_utime (long iraf_time)
time_t
os_utime (time_t iraf_time)
{
time_t time_var, lst;

lst = (time_t)iraf_time;
lst = iraf_time;

/* Add minutes westward from GMT */
time_var = lst + os_timezone();
Expand All @@ -32,20 +32,20 @@ os_utime (long iraf_time)
if (localtime(&lst)->tm_isdst)
time_var += 60L * 60L;

return ((long)time_var + SECONDS_1970_TO_1980);
return (time_var + SECONDS_1970_TO_1980);
}


/* OS_ITIME -- Convert UNIX time (gmt, epoch 1970) to IRAF time (lst, epoch
* 1980). [MACHDEP]
*/
long
os_itime (long unix_time)
time_t
os_itime (time_t unix_time)
{
struct tm *localtime(const time_t *);
time_t time_var, gmt;

gmt = (time_t)unix_time;
gmt = unix_time;

/* Subtract minutes westward from GMT */
time_var = gmt - os_timezone();
Expand All @@ -54,7 +54,7 @@ os_itime (long unix_time)
if (localtime(&gmt)->tm_isdst)
time_var -= 60L * 60L;

return ((long)time_var - SECONDS_1970_TO_1980);
return time_var - SECONDS_1970_TO_1980;
}


Expand Down
2 changes: 1 addition & 1 deletion unix/boot/rtar/rtar.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ struct fheader {
int gid;
int isdir;
long size;
long mtime;
time_t mtime;
long chksum;
int linkflag;
char linkname[NAMSIZ];
Expand Down
2 changes: 1 addition & 1 deletion unix/boot/wtar/wtar.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct fheader {
int gid;
int isdir;
long size;
long mtime;
time_t mtime;
long chksum;
int linkflag;
char linkname[NAMSIZ];
Expand Down