mirror of
https://frontier.innolan.net/rainlance/amiga-tz.git
synced 2026-03-20 18:51:17 +00:00
Version 1.03 changes
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
all: zdump timezone timezoneinfo setclockgmt dstcheck lib
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -O2 -DAROS -Wall
|
||||
CFLAGS = -O2 -DAROS -Iinclude -Wall
|
||||
AR = ar
|
||||
|
||||
PACKAGE = tzcode
|
||||
@ -14,6 +14,7 @@ version.h:
|
||||
echo 'static char const TZVERSION[]="$(VERSION)";' && \
|
||||
echo 'static char const REPORT_BUGS_TO[]="$(BUGEMAIL)";') >$@
|
||||
|
||||
|
||||
private.h:
|
||||
touch private.h
|
||||
|
||||
@ -40,6 +41,8 @@ zic.o: zic.c amiga_tz.h private.h version.h tzfile.h
|
||||
|
||||
zic_amiga.o: zic_amiga.c private.h version.h amiga_tz.h
|
||||
|
||||
strtoll.o: strtoll.c amiga_tz.h
|
||||
|
||||
date_amiga.o: date_amiga.c private.h amiga_tz.h
|
||||
|
||||
date.o: date.c private.h amiga_tz.h version.h
|
||||
@ -55,14 +58,14 @@ dstcheck.o: dstcheck.c amiga_tz.h version.h
|
||||
zic: zic.o zic_amiga.o
|
||||
${CC} ${CFLAGS} -o zic zic.o zic_amiga.o -liberty
|
||||
|
||||
zdump: zdump_amiga.o localtime.o asctime.o amiga_tz.o
|
||||
${CC} ${CFLAGS} -o ZDump zdump_amiga.o localtime.o asctime.o amiga_tz.o
|
||||
zdump: zdump_amiga.o localtime.o asctime.o strtoll.o amiga_tz.o
|
||||
${CC} ${CFLAGS} -o ZDump zdump_amiga.o localtime.o asctime.o strtoll.o amiga_tz.o
|
||||
|
||||
date: date.o localtime.o strftime.o asctime.o date_amiga.o amiga_tz.o
|
||||
${CC} ${CFLAGS} -o DateTZ date.o localtime.o strftime.o asctime.o date_amiga.o amiga_tz.o -lm
|
||||
date: date.o localtime.o strftime.o asctime.o strtoll.o date_amiga.o amiga_tz.o
|
||||
${CC} ${CFLAGS} -o DateTZ date.o localtime.o strftime.o asctime.o strtoll.o date_amiga.o amiga_tz.o -liberty -lsocket -lm
|
||||
|
||||
lib: localtime.o asctime.o difftime.o strftime.o amiga_tz.o
|
||||
${AR} rcs libtz.a localtime.o asctime.o difftime.o strftime.o amiga_tz.o
|
||||
lib: localtime.o asctime.o difftime.o strftime.o strtoll.o
|
||||
${AR} rcs libtz.a localtime.o asctime.o difftime.o strftime.o strtoll.o
|
||||
|
||||
timezone: timezone.o localtime.o asctime.o amiga_tz.o
|
||||
${CC} ${CFLAGS} -o TimeZone timezone.o localtime.o asctime.o amiga_tz.o
|
||||
@ -77,7 +80,7 @@ dstcheck: dstcheck.o localtime.o asctime.o amiga_tz.o
|
||||
${CC} ${CFLAGS} -o DSTCheck dstcheck.o localtime.o asctime.o amiga_tz.o
|
||||
|
||||
clean:
|
||||
rm -f amiga_tz.o asctime.o date.o difftime.o localtime.o strftime.o zdump.o zic.o date_amiga.o timezone.o timezoneinfo.o setclockgmt.o dstcheck.o version.h libtz.a zic ZDump DateTZ TimeZone TimeZoneInfo SetClockGMT DSTCheck
|
||||
rm -f amiga_tz.o asctime.o date.o difftime.o localtime.o strftime.o zdump.o zdump_amiga.o zic.o strtoll.o date_amiga.o timezone.o timezoneinfo.o setclockgmt.o dstcheck.o version.h libtz.a zic ZDump DateTZ TimeZone TimeZoneInfo SetClockGMT DSTCheck
|
||||
|
||||
depend:
|
||||
@echo Dependencies already done
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
all: zdump date timezone timezoneinfo setclockgmt dstcheck lib
|
||||
|
||||
CC = m68k-amigaos-gcc
|
||||
CFLAGS = -O2 -noixemul -DAOS3 -Wall -Werror
|
||||
CFLAGS = -O2 -noixemul -DAOS3 -Iinclude -Wall -Werror
|
||||
AR = m68k-amigaos-ar
|
||||
|
||||
PACKAGE = tzcode
|
||||
@ -9,7 +9,7 @@ VERSION = 2015e
|
||||
BUGEMAIL= carsten.larsen@mail.com
|
||||
|
||||
version.h:
|
||||
(echo '#define AMIGA_VERSION " 1.02 (07.07.2015) $(PACKAGE) $(VERSION)"' && \
|
||||
(echo '#define AMIGA_VERSION " 1.03 (10.07.2015) $(PACKAGE) $(VERSION)"' && \
|
||||
echo 'static char const PKGVERSION[]="($(PACKAGE)) ";' && \
|
||||
echo 'static char const TZVERSION[]="$(VERSION)";' && \
|
||||
echo 'static char const REPORT_BUGS_TO[]="$(BUGEMAIL)";') >$@
|
||||
@ -63,8 +63,8 @@ zdump: zdump_amiga.o localtime.o asctime.o strtoll.o amiga_tz.o
|
||||
date: date.o localtime.o strftime.o asctime.o strtoll.o date_amiga.o amiga_tz.o
|
||||
${CC} ${CFLAGS} -o DateTZ date.o localtime.o strftime.o asctime.o strtoll.o date_amiga.o amiga_tz.o -liberty -lsocket -lm
|
||||
|
||||
lib: localtime.o asctime.o difftime.o strftime.o strtoll.o amiga_tz.o
|
||||
${AR} rcs libtz.a localtime.o asctime.o difftime.o strftime.o strtoll.o amiga_tz.o
|
||||
lib: localtime.o asctime.o difftime.o strftime.o strtoll.o
|
||||
${AR} rcs libtz.a localtime.o asctime.o difftime.o strftime.o strtoll.o
|
||||
|
||||
timezone: timezone.o localtime.o asctime.o amiga_tz.o
|
||||
${CC} ${CFLAGS} -o TimeZone timezone.o localtime.o asctime.o amiga_tz.o
|
||||
@ -79,7 +79,7 @@ dstcheck: dstcheck.o localtime.o asctime.o amiga_tz.o
|
||||
${CC} ${CFLAGS} -o DSTCheck dstcheck.o localtime.o asctime.o amiga_tz.o
|
||||
|
||||
clean:
|
||||
rm -f amiga_tz.o asctime.o date.o difftime.o localtime.o strftime.o zdump.o zic.o strtoll.o date_amiga.o timezone.o timezoneinfo.o setclockgmt.o dstcheck.o version.h libtz.a zic ZDump DateTZ TimeZone TimeZoneInfo SetClockGMT DSTCheck
|
||||
rm -f amiga_tz.o asctime.o date.o difftime.o localtime.o strftime.o zdump.o zdump_amiga.o zic.o strtoll.o date_amiga.o timezone.o timezoneinfo.o setclockgmt.o dstcheck.o version.h libtz.a zic ZDump DateTZ TimeZone TimeZoneInfo SetClockGMT DSTCheck
|
||||
|
||||
depend:
|
||||
@echo Dependencies already done
|
||||
|
||||
11
amiga_tz.c
11
amiga_tz.c
@ -147,7 +147,7 @@ int create_timer()
|
||||
return 1;
|
||||
}
|
||||
|
||||
error = OpenDevice(TIMERNAME, UNIT_MICROHZ, (struct IORequest*)request, 0L);
|
||||
error = OpenDevice((STRPTR)TIMERNAME, UNIT_MICROHZ, (struct IORequest*)request, 0L);
|
||||
if (error != 0)
|
||||
{
|
||||
delete_timer(request);
|
||||
@ -203,7 +203,7 @@ int get_gmtoffset(time_t locale_time)
|
||||
int gmtoffset = 0;
|
||||
|
||||
tzvar = AllocVec(ENVSIZE, MEMF_ANY | MEMF_CLEAR);
|
||||
GetVar(TZVARIABLE, tzvar, ENVSIZE - 1, GVF_GLOBAL_ONLY);
|
||||
GetVar((STRPTR)TZVARIABLE, (STRPTR)tzvar, ENVSIZE - 1, GVF_GLOBAL_ONLY);
|
||||
tz = tzalloc(tzvar);
|
||||
|
||||
if (tz) {
|
||||
@ -213,7 +213,7 @@ int get_gmtoffset(time_t locale_time)
|
||||
gmtoffset = tm.tm_gmtoff;
|
||||
} else {
|
||||
// Localtime defined by AmigaOS
|
||||
localeBase = OpenLibrary(LOCALELIB_NAME, LOCALELIB_REV);
|
||||
localeBase = OpenLibrary((STRPTR)LOCALELIB_NAME, LOCALELIB_REV);
|
||||
if (localeBase == NULL) {
|
||||
return 0;
|
||||
}
|
||||
@ -342,13 +342,13 @@ void copyfile(char *fromname, char *toname)
|
||||
{
|
||||
BPTR fromfile, tofile;
|
||||
|
||||
fromfile = Open(fromname, MODE_OLDFILE);
|
||||
fromfile = Open((STRPTR)fromname, MODE_OLDFILE);
|
||||
if (!fromfile) {
|
||||
fprintf(stderr, "Can't read %s\n", fromname);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
tofile = Open(toname, MODE_NEWFILE);
|
||||
tofile = Open((STRPTR)toname, MODE_NEWFILE);
|
||||
if (!tofile) {
|
||||
Close(fromfile);
|
||||
fprintf(stderr, "Can't create %s\n", toname);
|
||||
@ -362,3 +362,4 @@ void copyfile(char *fromname, char *toname)
|
||||
}
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
|
||||
100
amiga_tz.h
100
amiga_tz.h
@ -57,6 +57,24 @@
|
||||
# endif
|
||||
#endif
|
||||
// --------------------------------------------------------------------------- //
|
||||
#if defined(AOS3)
|
||||
# define HAVE_ADJTIME 0
|
||||
# define HAVE_LINK 0
|
||||
# define HAVE_SYMLINK 0
|
||||
# define HAVE_SYS_STAT_H 0
|
||||
# define HAVE_TIME_T 1
|
||||
# define INITCLEAN 1
|
||||
#endif
|
||||
#if defined(AROS)
|
||||
# define HAVE_ADJTIME 0
|
||||
# define HAVE_STDINT_H 0
|
||||
# define HAVE_LINK 0
|
||||
# define HAVE_SYMLINK 0
|
||||
# define HAVE_STRFTIME_L 0
|
||||
# define HAVE_TIME_T 1
|
||||
# define INITCLEAN 1
|
||||
#endif
|
||||
// --------------------------------------------------------------------------- //
|
||||
#include <exec/io.h>
|
||||
#include <exec/types.h>
|
||||
#include <exec/memory.h>
|
||||
@ -80,82 +98,42 @@
|
||||
// --------------------------------------------------------------------------- //
|
||||
#include <sys/time.h>
|
||||
// --------------------------------------------------------------------------- //
|
||||
#if defined(AOS3) || defined(AOS4)
|
||||
# define ARGPTR STRPTR
|
||||
# define ARGS_FORMAT ARGSFORMAT
|
||||
#endif
|
||||
#if defined(AROS) || defined(MORPHOS)
|
||||
# define ARGPTR CONST_STRPTR
|
||||
# define ARGS_FORMAT (CONST_STRPTR)ARGSFORMAT
|
||||
#endif
|
||||
#ifndef ARGPTR
|
||||
# error Platform must be defined
|
||||
#endif
|
||||
// --------------------------------------------------------------------------- //
|
||||
#define OPEN_ERROR "Cannot open %s.\n"
|
||||
#define OPEN_VER_ERROR "Cannot open %s v%d.\n"
|
||||
#define OPEN_VER_ERROR "Cannot open %s (%ld.0)\n"
|
||||
#define PUBSCREEN_NAME "PubScreen"
|
||||
#define TZVARIABLE "timezone.prefs"
|
||||
#define TZDIR "LOCALE:zoneinfo"
|
||||
#define TZDIR "LOCALE:Zoneinfo"
|
||||
#define TZDEFAULT "localtime"
|
||||
#define TM_GMTOFF tm_gmtoff
|
||||
#define TM_ZONE tm_zone
|
||||
// --------------------------------------------------------------------------- //
|
||||
#define INTUILIB_NAME "intuition.library"
|
||||
#define INTUILIB_REV 37L
|
||||
#define GADTOOLLIB_NAME "gadtools.library"
|
||||
#define GADTOOLLIB_REV 37L
|
||||
#define UTILLIB_NAME "utility.library"
|
||||
#define UTILLIB_REV 37L
|
||||
#define LOCALELIB_NAME "locale.library"
|
||||
#define LOCALELIB_REV 37L
|
||||
#define DOSLIB_NAME "dos.library"
|
||||
#define DOSLIB_REV 37L
|
||||
#define TIMER_NAME TIMERNAME
|
||||
#define BATTCLOCK_NAME BATTCLOCKNAME
|
||||
#ifdef AOS3
|
||||
# define REQ_ERROR "Requires Kickstart 2.04 (37.175) or later.\n"
|
||||
# define INTUILIB_NAME "intuition.library"
|
||||
# define INTUILIB_REV 37L
|
||||
# define GADTOOLLIB_NAME "gadtools.library"
|
||||
# define GADTOOLLIB_REV 37L
|
||||
# define UTILLIB_NAME "utility.library"
|
||||
# define UTILLIB_REV 37L
|
||||
# define LOCALELIB_NAME "locale.library"
|
||||
# define LOCALELIB_REV 37L
|
||||
# define DOSLIB_NAME "dos.library"
|
||||
# define DOSLIB_REV 37L
|
||||
# define TIMER_NAME TIMERNAME
|
||||
# define BATTCLOCK_NAME BATTCLOCKNAME
|
||||
# define REQ_ERROR "Requires Kickstart 2.04 (37.175) or later.\n"
|
||||
# define IPTR APTR
|
||||
#endif
|
||||
#ifdef AROS
|
||||
# define REQ_ERROR "Requires a newer version of AROS.\n"
|
||||
# define _STDC_TIME_H_
|
||||
# include "tz.h"
|
||||
# include <ctype.h>
|
||||
# include <sys/time.h>
|
||||
# define REQ_ERROR "Requires a newer version of AROS.\n"
|
||||
# define INTUILIB_NAME (CONST_STRPTR)"intuition.library"
|
||||
# define INTUILIB_REV 37L
|
||||
# define GADTOOLLIB_NAME (CONST_STRPTR)"gadtools.library"
|
||||
# define GADTOOLLIB_REV 37L
|
||||
# define UTILLIB_NAME (CONST_STRPTR)"utility.library"
|
||||
# define UTILLIB_REV 37L
|
||||
# define LOCALELIB_NAME (CONST_STRPTR)"locale.library"
|
||||
# define LOCALELIB_REV 37L
|
||||
# define DOSLIB_NAME (CONST_STRPTR)"dos.library"
|
||||
# define DOSLIB_REV 37L
|
||||
# define TIMER_NAME (CONST_STRPTR)TIMERNAME
|
||||
# define BATTCLOCK_NAME (CONST_STRPTR)BATTCLOCKNAME
|
||||
#endif
|
||||
// --------------------------------------------------------------------------- //
|
||||
#if defined(AOS3)
|
||||
# define HAVE_ADJTIME 0
|
||||
# define HAVE_LINK 0
|
||||
# define HAVE_SYMLINK 0
|
||||
# define HAVE_SYS_STAT_H 0
|
||||
# define INITCLEAN
|
||||
# ifndef ULONG
|
||||
# define ULONG long unsigned int
|
||||
# endif
|
||||
#endif
|
||||
#if defined(AROS)
|
||||
# define HAVE_ADJTIME 0
|
||||
# define HAVE_STDINT_H 1
|
||||
# define HAVE_STRFTIME_L 1
|
||||
# define HAVE_LINK 0
|
||||
# define HAVE_SYMLINK 0
|
||||
#endif
|
||||
// --------------------------------------------------------------------------- //
|
||||
// 2922 is the number of days between 1.1.1970 and 1.1.1978 (2 leap years and 6 normal)
|
||||
// 2922 * 24 * 60 * 60 = 252460800
|
||||
#define AMIGAOFFSET 252460800
|
||||
#define ENVSIZE 100
|
||||
#define ENVSIZE 256
|
||||
// --------------------------------------------------------------------------- //
|
||||
struct tm *gmtime_r(const time_t *, struct tm *);
|
||||
int get_gmtoffset_now();
|
||||
@ -173,8 +151,6 @@ int isdigit(int c);
|
||||
int ispunct(int c);
|
||||
int isspace(int c);
|
||||
int isupper(int c);
|
||||
// --------------------------------------------------------------------------- //
|
||||
|
||||
// --------------------------------------------------------------------------- //
|
||||
void syslog(int, const char *, ...);
|
||||
// --------------------------------------------------------------------------- //
|
||||
|
||||
@ -36,7 +36,7 @@ int main(const int argc, char *argv[])
|
||||
timezone_t tz = NULL;
|
||||
time_t now = time(NULL);
|
||||
char *ret = (char*)AllocVec(ENVSIZE, MEMF_ANY | MEMF_CLEAR);
|
||||
GetVar(TZVARIABLE, ret, ENVSIZE - 1, GVF_GLOBAL_ONLY);
|
||||
GetVar((STRPTR)TZVARIABLE, (STRPTR)ret, ENVSIZE - 1, GVF_GLOBAL_ONLY);
|
||||
tz = tzalloc(ret);
|
||||
|
||||
if (tz) {
|
||||
|
||||
16
include/tz.h
16
include/tz.h
@ -48,11 +48,16 @@
|
||||
|
||||
extern char *tzname[2];
|
||||
|
||||
#define TZVARIABLE "timezone.prefs"
|
||||
#define TZDIR "LOCALE:zoneinfo"
|
||||
#define TZDEFAULT "localtime"
|
||||
#ifndef TZVARIABLE
|
||||
# define TZVARIABLE "timezone.prefs"
|
||||
#endif
|
||||
#ifndef TZDIR
|
||||
# define TZDIR "LOCALE:Zoneinfo"
|
||||
#endif
|
||||
#ifndef TZDEFAULT
|
||||
# define TZDEFAULT "localtime"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_TIME_TM
|
||||
struct tm {
|
||||
int tm_sec; /* seconds after the minute [0-61] */
|
||||
int tm_min; /* minutes after the hour [0-59] */
|
||||
@ -66,13 +71,14 @@ struct tm {
|
||||
long tm_gmtoff; /* offset from UTC in seconds */
|
||||
char *tm_zone; /* timezone abbreviation */
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_TIME_T
|
||||
typedef long time_t;
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_TIMEZONE_T
|
||||
typedef struct state *timezone_t;
|
||||
#endif
|
||||
|
||||
void tzset(void);
|
||||
void tzfree(const timezone_t);
|
||||
|
||||
@ -410,7 +410,7 @@ tzloadbody(char const *name, struct state *sp, bool doextend,
|
||||
fid = open(name, OPEN_MODE);
|
||||
if (fid < 0)
|
||||
return errno;
|
||||
|
||||
printf("file is open\n");
|
||||
nread = read(fid, up->buf, sizeof up->buf);
|
||||
if (nread < tzheadsize) {
|
||||
int err = nread < 0 ? errno : EINVAL;
|
||||
@ -419,6 +419,7 @@ tzloadbody(char const *name, struct state *sp, bool doextend,
|
||||
}
|
||||
if (close(fid) < 0)
|
||||
return errno;
|
||||
printf("file is still open\n");
|
||||
for (stored = 4; stored <= 8; stored *= 2) {
|
||||
int_fast32_t ttisstdcnt = detzcode(up->tzhead.tzh_ttisstdcnt);
|
||||
int_fast32_t ttisgmtcnt = detzcode(up->tzhead.tzh_ttisgmtcnt);
|
||||
@ -644,6 +645,7 @@ tzloadbody(char const *name, struct state *sp, bool doextend,
|
||||
}
|
||||
}
|
||||
sp->defaulttype = i;
|
||||
printf("File was read.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -663,7 +665,9 @@ tzload(char const *name, struct state *sp, bool doextend)
|
||||
}
|
||||
#else
|
||||
union local_storage ls;
|
||||
return tzloadbody(name, sp, doextend, &ls);
|
||||
int res = tzloadbody(name, sp, doextend, &ls);
|
||||
printf("Body res %d", res);
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -48,18 +48,18 @@ int main(int argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
struct RDArgs *rdargs;
|
||||
struct timeval tv = { 0, 0 };
|
||||
struct timeval tv;
|
||||
struct progargs args = { FALSE, FALSE, FALSE };
|
||||
|
||||
if((result = amiga_open_libs()) != 0) {
|
||||
exit(result);
|
||||
}
|
||||
|
||||
rdargs = ReadArgs(ARGS_FORMAT, (APTR)&args, NULL);
|
||||
|
||||
rdargs = ReadArgs((STRPTR)ARGSFORMAT, (APTR)&args, NULL);
|
||||
|
||||
if (!rdargs)
|
||||
{
|
||||
printf("%s %s\n", argv[0], ARGSFORMAT);
|
||||
PrintFault(IoErr(), (STRPTR)argv[0]);
|
||||
} else if (args.load) {
|
||||
tv.tv_sec = ReadBattClock();
|
||||
settime(&tv);
|
||||
@ -74,7 +74,10 @@ int main(int argc, char **argv)
|
||||
printf("%s %s\n", argv[0], ARGSFORMAT);
|
||||
}
|
||||
|
||||
FreeArgs(rdargs);
|
||||
if(rdargs) {
|
||||
FreeArgs(rdargs);
|
||||
}
|
||||
|
||||
amiga_close_libs();
|
||||
|
||||
return 0;
|
||||
@ -82,28 +85,26 @@ int main(int argc, char **argv)
|
||||
|
||||
void amiga_open_lib_error(char *name, int version)
|
||||
{
|
||||
printf(OPEN_VER_ERROR, name, version);
|
||||
printf(REQ_ERROR);
|
||||
FPrintf(Output(), (STRPTR)OPEN_VER_ERROR, name, version);
|
||||
FPrintf(Output(), (STRPTR)REQ_ERROR, NULL);
|
||||
}
|
||||
|
||||
int amiga_open_libs()
|
||||
{
|
||||
atexit(amiga_close_libs);
|
||||
|
||||
if(!(DOSBase = OpenLibrary(DOSLIB_NAME, DOSLIB_REV))) {
|
||||
if(!(DOSBase = OpenLibrary((STRPTR)DOSLIB_NAME, DOSLIB_REV))) {
|
||||
amiga_open_lib_error(DOSLIB_NAME, DOSLIB_REV);
|
||||
return 5;
|
||||
}
|
||||
|
||||
if(!(UtilityBase = OpenLibrary(UTILLIB_NAME, UTILLIB_REV))) {
|
||||
if(!(UtilityBase = OpenLibrary((STRPTR)UTILLIB_NAME, UTILLIB_REV))) {
|
||||
amiga_open_lib_error(UTILLIB_NAME, UTILLIB_REV);
|
||||
return 5;
|
||||
}
|
||||
|
||||
BattClockBase = OpenResource(BATTCLOCK_NAME);
|
||||
|
||||
if (!(BattClockBase = OpenResource(BATTCLOCK_NAME))) {
|
||||
printf(OPEN_ERROR, BATTCLOCK_NAME);
|
||||
if (!(BattClockBase = OpenResource((STRPTR)BATTCLOCK_NAME))) {
|
||||
FPrintf(Output(), (STRPTR)OPEN_ERROR, BATTCLOCK_NAME);
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
||||
28
timezone.c
28
timezone.c
@ -91,8 +91,8 @@ void amiga_cleanup();
|
||||
|
||||
void amiga_open_lib_error(char *name, int version)
|
||||
{
|
||||
fprintf(stderr, OPEN_VER_ERROR, name, version);
|
||||
fprintf(stderr, REQ_ERROR);
|
||||
FPrintf(Output(), (STRPTR)OPEN_VER_ERROR, name, version);
|
||||
FPrintf(Output(), (STRPTR)REQ_ERROR, NULL);
|
||||
}
|
||||
|
||||
int amiga_open_libs()
|
||||
@ -241,32 +241,32 @@ void amiga_setup_gui()
|
||||
|
||||
ng.ng_TopEdge += ng.ng_Height + 4;
|
||||
ng.ng_Flags = PLACETEXT_RIGHT;
|
||||
ng.ng_GadgetText ="Use TZ variable";
|
||||
ng.ng_GadgetText = (STRPTR)"Use TZ variable";
|
||||
ng.ng_GadgetID = GID_USE_TZ;
|
||||
lastgad = CreateGadget(CHECKBOX_KIND, lastgad, &ng, TAG_END);
|
||||
usetzgad = lastgad;
|
||||
|
||||
ng.ng_TopEdge += ng.ng_Height + 4;
|
||||
ng.ng_LeftEdge = screen->WBorLeft + 4;
|
||||
ng.ng_GadgetText = "Use localtime file";
|
||||
ng.ng_GadgetText = (STRPTR)"Use localtime file";
|
||||
ng.ng_GadgetID = GID_USE_LT;
|
||||
lastgad = CreateGadget(CHECKBOX_KIND, lastgad, &ng, TAG_END);
|
||||
useltgad = lastgad;
|
||||
|
||||
ng.ng_TopEdge += ng.ng_Height + 6;
|
||||
ng.ng_LeftEdge = screen->WBorLeft + 4;
|
||||
ng.ng_GadgetText = "Save";
|
||||
ng.ng_GadgetText = (STRPTR)"Save";
|
||||
ng.ng_GadgetID = GID_SAVE;
|
||||
ng.ng_Flags = 0;
|
||||
lastgad = CreateGadget (BUTTON_KIND,lastgad,&ng,TAG_END);
|
||||
|
||||
ng.ng_LeftEdge += ng.ng_Width + 4;
|
||||
ng.ng_GadgetText = "Use";
|
||||
ng.ng_GadgetText = (STRPTR)"Use";
|
||||
ng.ng_GadgetID = GID_USE;
|
||||
lastgad = CreateGadget (BUTTON_KIND,lastgad,&ng,TAG_END);
|
||||
|
||||
ng.ng_LeftEdge += ng.ng_Width + 4;
|
||||
ng.ng_GadgetText = "Cancel";
|
||||
ng.ng_GadgetText = (STRPTR)"Cancel";
|
||||
ng.ng_GadgetID = GID_CANCEL;
|
||||
lastgad = CreateGadget (BUTTON_KIND,lastgad,&ng,TAG_END);
|
||||
|
||||
@ -284,7 +284,7 @@ void load_tz()
|
||||
}
|
||||
|
||||
tz = AllocVec(ENVSIZE, MEMF_ANY | MEMF_CLEAR);
|
||||
if(GetVar(TZVARIABLE, tz, ENVSIZE - 1, GVF_GLOBAL_ONLY) == -1) {
|
||||
if(GetVar((STRPTR)TZVARIABLE, (STRPTR)tz, ENVSIZE - 1, GVF_GLOBAL_ONLY) == -1) {
|
||||
FreeVec(tz);
|
||||
tz = NULL;
|
||||
} else {
|
||||
@ -311,11 +311,11 @@ void use_tz()
|
||||
|
||||
if (tz != NULL) {
|
||||
underscore_add(tz);
|
||||
SetVar(TZVARIABLE, tz, strlen(tz) + 1, GVF_GLOBAL_ONLY);
|
||||
SetVar((STRPTR)TZVARIABLE, (STRPTR)tz, strlen(tz) + 1, GVF_GLOBAL_ONLY);
|
||||
|
||||
GT_GetGadgetAttrs(usetzgad, window, NULL, GTCB_Checked, &checked, TAG_END);
|
||||
if (checked) {
|
||||
SetVar("TZ", tz, strlen(tz) + 1, GVF_GLOBAL_ONLY);
|
||||
SetVar((STRPTR)"TZ", (STRPTR)tz, strlen(tz) + 1, GVF_GLOBAL_ONLY);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -333,8 +333,8 @@ void save_tz()
|
||||
strcpy(name, "ENVARC:");
|
||||
strcat(name, TZVARIABLE);
|
||||
|
||||
if ((file = Open(name, MODE_NEWFILE))) {
|
||||
FPuts(file, tz);
|
||||
if ((file = Open((STRPTR)name, MODE_NEWFILE))) {
|
||||
FPuts(file, (STRPTR)tz);
|
||||
Close(file);
|
||||
}
|
||||
|
||||
@ -342,7 +342,7 @@ void save_tz()
|
||||
|
||||
GT_GetGadgetAttrs(usetzgad, window, NULL, GTCB_Checked, &checked, TAG_END);
|
||||
if (checked) {
|
||||
SetVar("TZ", tz, strlen(tz) + 1, GVF_GLOBAL_ONLY);
|
||||
SetVar((STRPTR)"TZ", (STRPTR)tz, strlen(tz) + 1, GVF_GLOBAL_ONLY);
|
||||
}
|
||||
|
||||
GT_GetGadgetAttrs(useltgad, window, NULL, GTCB_Checked, &checked, TAG_END);
|
||||
@ -415,7 +415,7 @@ void populate_list()
|
||||
startindex = 0;
|
||||
for (i = 0; i < count; i++) {
|
||||
if ((node = AllocVec(sizeof(struct Node) + strlen(locations[i].tz) + 1, MEMF_CLEAR))) {
|
||||
node->ln_Name = (STRPTR)(node + 1);
|
||||
node->ln_Name = (char*)(node + 1);
|
||||
strcpy(node->ln_Name,locations[i].tz);
|
||||
underscore_remove(node->ln_Name);
|
||||
AddTail(&lvlist, node);
|
||||
|
||||
@ -39,37 +39,34 @@ int main(const int argc, char *argv[])
|
||||
|
||||
timezone_t tz = NULL;
|
||||
time_t now = time(NULL);
|
||||
char *ret = (char*)AllocVec(ENVSIZE, MEMF_ANY | MEMF_CLEAR);
|
||||
|
||||
if (GetVar(TZVARIABLE, ret, ENVSIZE - 1, GVF_GLOBAL_ONLY) == -1) {
|
||||
*ret = '\0';
|
||||
char *ret = (char*)AllocVec(ENVSIZE, MEMF_ANY | MEMF_CLEAR);
|
||||
if(GetVar((STRPTR)TZVARIABLE, (STRPTR)ret, ENVSIZE - 1, GVF_GLOBAL_ONLY) == -1) {
|
||||
strcpy(ret, "unknown");
|
||||
tz = tzalloc(0);
|
||||
} else {
|
||||
tz = tzalloc(ret);
|
||||
underscore_remove(ret);
|
||||
}
|
||||
|
||||
tz = tzalloc(ret);
|
||||
if (tz) {
|
||||
localtime_rz(tz, &now, &tm);
|
||||
tzfree(tz);
|
||||
|
||||
if (*ret == '\0') {
|
||||
underscore_remove(ret);
|
||||
} else {
|
||||
strcpy(ret, "unknown");
|
||||
}
|
||||
offset.hours = tm.tm_gmtoff / 60 / 60;
|
||||
offset.mins = tm.tm_gmtoff / 60 - offset.hours * 60;
|
||||
|
||||
offset.hours = tm.tm_gmtoff / 60;
|
||||
offset.mins = tm.tm_gmtoff - offset.hours * 60;
|
||||
|
||||
VPrintf("Location is %s\n", &ret);
|
||||
VPrintf("Time zone is %s\n", &tm.tm_zone);
|
||||
VPrintf("GMT offset is %d hours and %d minutes.\n", &offset );
|
||||
FPrintf(Output(), (STRPTR)"Location is %s\n", ret);
|
||||
FPrintf(Output(), (STRPTR)"Time zone is %s\n", tm.tm_zone);
|
||||
FPrintf(Output(), (STRPTR)"GMT offset is %ld hours and %ld minutes.\n", offset.hours, offset.mins);
|
||||
|
||||
if (tm.tm_isdst) {
|
||||
VPrintf("It is daylight-saving time.\n", NULL);
|
||||
FPrintf(Output(), (STRPTR)"It is daylight-saving time.\n");
|
||||
} else {
|
||||
VPrintf("It is not daylight-saving time.\n", NULL);
|
||||
FPrintf(Output(), (STRPTR)"It is not daylight-saving time.\n");
|
||||
}
|
||||
} else {
|
||||
VPrintf("Timezone not known.\n", NULL);
|
||||
FPrintf(Output(), (STRPTR)"Timezone not known.\n");
|
||||
}
|
||||
|
||||
FreeVec(ret);
|
||||
|
||||
@ -560,10 +560,10 @@ int main(int argc, char *argv[])
|
||||
NULL
|
||||
};
|
||||
|
||||
rdargs = ReadArgs(ARGS_FORMAT, (APTR)&args, NULL);
|
||||
rdargs = ReadArgs((STRPTR)ARGSFORMAT, (APTR)&args, NULL);
|
||||
if (!rdargs)
|
||||
{
|
||||
PrintFault(IoErr(), (ARGPTR)argv[0]);
|
||||
PrintFault(IoErr(), (APTR)argv[0]);
|
||||
exit(5);
|
||||
}
|
||||
|
||||
@ -585,7 +585,7 @@ int main(int argc, char *argv[])
|
||||
cutloyear = lo;
|
||||
cuthiyear = hi;
|
||||
} else {
|
||||
VPrintf("Wild C argument %s\n", args.cutarg);
|
||||
VPrintf((STRPTR)"Wild C argument %s\n", (IPTR*)args.cutarg);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
@ -618,7 +618,7 @@ int main(int argc, char *argv[])
|
||||
cuthitime = hi;
|
||||
}
|
||||
} else {
|
||||
VPrintf("Wild CTargument %s\n", args.cuttimes);
|
||||
VPrintf((STRPTR)"Wild CTargument %s\n", (IPTR*)args.cuttimes);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user