Release 1.10

This commit is contained in:
2021-01-12 23:02:29 +01:00
parent 324aeec752
commit 4431f67f75
69 changed files with 8410 additions and 1851 deletions
+18
View File
@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "amiga",
"includePath": [
"/opt/amiga/m68k-amigaos/ndk-include/",
"/opt/amiga/m68k-amigaos/clib2/include/"
],
"defines": [],
"compilerPath": "/opt/amiga/bin/m68k-amigaos-gcc",
"cStandard": "c99",
"cppStandard": "c++98",
"intelliSenseMode": "${default}",
"compilerArgs": []
}
],
"version": 4
}
+23
View File
@@ -0,0 +1,23 @@
// Debug with remote gdbserver for AmigaOS:
// http://aminet.net/package/dev/debug/bgdbserver
// Start in FSUAE with:
// >bgdbserver TimeKeeper
// AmigaOS GCC & GDB:
// https://github.com/bebbo/amiga-gcc
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to gdbserver",
"type": "gdb",
"request": "attach",
"executable": "obj/TimeKeeper",
"target": "localhost:2345",
"remote": true,
"cwd": "${workspaceRoot}",
"gdbpath": "/opt/amiga/bin/m68k-amigaos-gdb",
}
]
}
+19
View File
@@ -0,0 +1,19 @@
{
"cSpell.words": [
"Sonne",
"TZ",
"TZONE"
],
"files.associations": {
"alib_protos.h": "c",
"timer.h": "c",
"timer_protos.h": "c",
"shutdown.h": "c",
"gfxbase.h": "c",
"type_traits": "cpp",
"typeinfo": "c",
"dos.h": "c",
"commodities.h": "c",
"battclock.h": "c"
}
}
+16
View File
@@ -0,0 +1,16 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Logger",
"type": "shell",
"command": "make -f Makefile.m68k",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
+8 -1
View File
@@ -1,5 +1,12 @@
AmiTimeKeeper Change Log
v1.10 20.03.2020
- RTC is no longer required during startup
- When time zone changes it is now recognized
- Several bugs affecting time zone logic fixed
- Documentation updated with POSIX TZ examples
- Compiled with upgraded GCC, version 6.2
v1.09 14.07.2019
- Initial DST support using POSIX TZ and Amiga TZONE variable
- Restart synchronizer processes on DNS lookup failures
@@ -8,7 +15,7 @@ v1.08 18.05.2019
- When using pool server cycle with prefix 0 to 3
- Display of wrong signes in time zone fixed
- Faulty log messages about settings fixed
- Timer bug causing infitive loop fixed
- Timer bug causing infinitive loop fixed
- Memory leak in settings window fixed
v1.07 15.02.2019
+1 -1
View File
@@ -1,7 +1,7 @@
Copyright (c) 2001, 02 Motoyuki Kasahara
Copyright (c) 2007 TANDBERG Telecom AS
Copyright (c) 2008-2009 Dag-Erling Smørgrav <des@des.no>
Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
+56 -25
View File
@@ -1,28 +1,39 @@
all: timekeeper
all: timekeeper timelogger
mkdir -p obj/
mv *.o obj/
CC = /opt/m68k-amigaos/bin/m68k-amigaos-gcc
# GCC 6.x
# https://github.com/bebbo/amiga-gcc
#
CC = /opt/amiga/bin/m68k-amigaos-gcc
CFLAGS = -O0 -DAOS3 -DLIB_HOST -Iinclude -mcrt=clib2 -Wall
LFLAGS1 = -s -Wl,--cref,-M,-Map=TimeKeeper.map
LFLAGS2 = -s -Wl,--cref,-M,-Map=TimeLogger.map
#CFLAGS = -O0 -g -DAOS3 -DLIB_HOST -Iinclude -mcrt=clib2 -Wall
#LFLAGS = -Wl,--cref,-M,-Map=TimeKeeper.map
# clib2
#CFLAGS = -O2 -DAOS3 -Iinclude -mcrt=clib2 -m68020 -fbaserel32 -Wall
#LFALGS = -Wl,--cref,-M,-Map=TimeKeeper.map
#LDLIBS = -lnet
OBJECTS = broker.o global.o library.o log.o locale.o main.o mem.o message.o \
net_getaddrinfo.o net_poll.o net.o notify.o ptz.o setting.o shutdown.o \
sntp.o string.o sync.o timer.o tz.o val.o win_main.o \
win_gad.o
# libnix
#CFLAGS = -O2 -DAOS3 -fomit-frame-pointer -fno-stack-check -Iinclude -noixemul -Wall
CFLAGS = -O2 -DAOS3 -fno-stack-check -Iinclude -noixemul -Wall
LFLAGS = -Wl,--cref,-M,-Map=TimeKeeper.map
LDLIBS =
OBJLOG = logger.o string.o
.PHONY:
broker.o: compiler.h config.h message.h win.h
com.o: compiler.h config.h message.h state.h time.h sntp.h mem.h
global.o: global.h
library.o: compiler.h config.h time.h mem.h
com.o: compiler.h config.h message.h setting.h timer.h sntp.h mem.h
library.o: compiler.h config.h timer.h mem.h
log.o: compiler.h config.h log.h mem.h
main.o: compiler.h config.h state.h time.h mem.h
locale.o: locale.h mem.h
main.o: compiler.h config.h setting.h timer.h mem.h
mem.o: compiler.h config.h mem.h
@@ -34,29 +45,49 @@ net_poll.o: compiler.h config.h mem.h
net.o: compiler.h config.h net_getaddrinfo.h message.h mem.h
notify.o: compiler.h notify.h config.h
ptz.o: compiler.h config.h ptz.h
sntp.o: compiler.h config.h sntp.h time.h net_getaddrinfo.h message.h mem.h
setting.o: compiler.h config.h setting.h mem.h
state.o: compiler.h config.h state.h mem.h
shutdown.o: shutdown.h message.h
sntp.o: compiler.h config.h sntp.h timer.h net_getaddrinfo.h message.h mem.h
string.o: compiler.h config.h string.h mem.h
time.o: compiler.h config.h time.h mem.h
time.o: compiler.h config.h ptz.h timer.h mem.h
val.o: compiler.h config.h state.h message.h log.h
tz.o: compiler.h config.h ptz.h timer.h mem.h
win_main.o: compiler.h config.h message.h state.h time.h mem.h win.h
val.o: compiler.h config.h setting.h message.h log.h
win_gad.o: compiler.h config.h message.h state.h time.h mem.h win.h
win_main.o: compiler.h config.h message.h setting.h timer.h mem.h win.h
timekeeper: broker.o com.o library.o log.o main.o mem.o message.o net_getaddrinfo.o net_poll.o net.o ptz.o sntp.o state.o time.o string.o val.o win_main.o win_gad.o
${CC} ${CFLAGS} ${LFLAGS} -s -o TimeKeeper \
broker.o com.o library.o log.o main.o mem.o message.o net_getaddrinfo.o net_poll.o net.o ptz.o sntp.o state.o time.o string.o val.o win_main.o win_gad.o \
${LDLIBS}
win_gad.o: compiler.h config.h message.h setting.h timer.h mem.h win.h
logger.o: compiler.h
timekeeper: ${OBJECTS}
${CC} ${CFLAGS} ${LFLAGS1} -o TimeKeeper ${OBJECTS} ${LDLIBS}
mkdir -p obj/
mv TimeKeeper obj/
mv TimeKeeper.map obj/
timelogger: ${OBJLOG}
${CC} ${CFLAGS} ${LFLAGS2} -o TimeLogger ${OBJLOG} ${LDLIBS}
mkdir -p obj/
mv TimeLogger obj/
mv TimeLogger.map obj/
clean:
rm -f TimeKeeper broker.o com.o library.o log.o main.o mem.o message.o net_getaddrinfo.o net_poll.o net.o ptz.o settings.o sntp.o state.o time.o string.o val.o win_main.o win_gad.o TimeKeeper.map
rm -Rf *.o
rm -Rf TimeLogger
rm -Rf TimeLogger.map
rm -Rf TimeKeeper
rm -Rf TimeKeeper.map
rm -Rf obj
depend:
@echo Dependencies already done
+518 -37
View File
@@ -1,9 +1,9 @@
@database TimeKeeper.guide
@$VER: TimeKeeper.guide 1.09 (2019-07-14)
@(c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
@$VER: TimeKeeper.guide 1.10 (20.03.2020)
@(c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
@author Carsten Sonne Larsen
@rem Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
@rem Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
@rem All rights reserved.
@rem
@rem Redistribution and use in source and binary forms, with or without
@@ -41,14 +41,17 @@ either directly from the command line or by using the tool types of
an icon. Preferences can also be saved between reboots.
The local time zone needs to be configured using Workbench preferences
or a similar tool. in regular AmigaOS this is available through the
Locale Preferences Editor.
or a similar tool. In AmigaOS 3.1 and 3.9 this is available through
the Locale Preferences Editor. Daylight saving time is only supported
through the POSIX TZ environment variable.
@{"Configuring the client" Link "Configuring the client"}
@{"Using tooltypes of an icon" Link "Using tooltypes of an icon"}
@{"Saving preferences" Link "Saving preferences"}
@{"The POSIX TZ environment variable" Link "The POSIX TZ environment variable"}
@{"Change Log / Change History" Link "Change Log"}
@{"Software License" Link "Software License"}
@{"Credits and donations" Link "Credits and donations"}
@{"Contacting the author" Link "Contacting the author"}
@EndNode
@@ -81,7 +84,7 @@ in order to lower the risk of choosing a none-responsive server.
@{b}Server port@{ub}
NTP servers use port 123 as default. Only under special circumstances
are the NTP server port different from 123.
is the NTP server port different from 123.
@{b}Interval between requests@{ub}
@@ -111,7 +114,7 @@ setup and other time related parameters.
@{b}Expert mode@{ub}
Advanced settings are hidden from the settings windown when expert mode
Advanced settings are hidden from the settings window when expert mode
is not enabled. The advanced settings are server port, interval between
requests, adjustment threshold, connection timeout, verbosity level and
commodity priority.
@@ -124,17 +127,18 @@ response the connection will instead make a time out. The timeout
interval should be specified using milliseconds. One thousand (1.000)
milliseconds are equal to one second.
@{b}Verbosity level@{ub}
The level of logging can be adjusted from none to all. Expressed as a
numeric value verbose can be 0, 1, 2 or 3, where 0 is equal to none and
3 is equal to maximum verbosity.
@{b}Log file@{ub}
It is possible to send log messages to a file instead of sending them to
a console window.
@{b}Caveats@{ub}
AmiTimeKeeper does not start as a background process. When started in the
startup-sequence it will by default block execution. Use the run command
to avoid this behaviour:
> RUN >NIL: TimeKeeper
@EndNode
@Node "Using tooltypes of an icon" "TimeKeeper.guide/Using tooltypes of an icon"
@@ -162,8 +166,6 @@ CX_PRIORITY | Commodity priority
READONLY | Do not set clock
EXPERT | Show advanced options
TIMEOUT | Connection Timeout
VERBOSE | Log verbosity
LOGFILE | Log file location
@{b}Caveats@{ub}
@@ -177,12 +179,16 @@ always override settings from the preference file.
Settings from icon tooltypes are used when starting from Workbench.
Settings from CLI are used only when starting from shell.
When using WBStartup folder or a similar system, remember to add the
mandatory tooltype DONOTWAIT. Otherwise the startup execution will be
blocked.
@EndNode
@Node "Saving preferences" "TimeKeeper.guide/Saving preferences"
@Toc "Main"
@Prev "Using tooltypes of an icon"
@Next "Change Log"
@Next "The POSIX TZ environment variable"
Preferences from the setting window are saved in the file
ENV:timekeeper.prefs
@@ -200,17 +206,470 @@ SERVER=de.pool.ntp.org
PORT=123
TIMEOUT=5000
INTERVAL=17500
VERBOSE=3
READONLY=NO
EXPERT=NO
LOGFILE=RAM:log
The preference file should not be edited under normal circumstances.
@{b}Caveats@{ub}
If LOGFILE is set in the preference file, no messages will be emitted
to screen (unless overridden by CLI or icon tooltype with LOGFILE=NO).
Not only visible settings in the settings window are saved to the
preference file. All setting are saved includes default settings and
settings from CLI and icon tooltype.
@EndNode
@Node "The POSIX TZ environment variable" "TimeKeeper.guide/The POSIX TZ environment variable"
@Toc "Main"
@Prev "Saving preferences"
@Next "Change Log"
This is a list of time zone information for locations around the globe.
Information is represented in the POSIX TZ environment variable format.
The list originates from the IANA time zone database version 2019b.
A formal definition of the POSIX TZ environment variable is available
to the public from The GNU C Library Reference Manual and The Open Group
Library.
The POSIX TZ environment variable is described in dept by for example
The Open Group Base Specifications Issue 7, 2018 edition and The GNU C
Library Reference Manual.
Set the TZ environment variable to Central Europe Time:
> SETENV TZ CET-1
Set the TZ environment variable to Central Europe Summer Time:
> SETENV TZ CET-1CEST
Set the TZ environment variable for Paris:
> SETENV TZ CET-1CEST,M3.5.0,M10.5.0/3
Save the TZ environment to the current system disk:
> COPY ENV:TZ ENVARC:TZ
Africa/Abidjan TZ GMT0
Africa/Accra TZ GMT0
Africa/Addis Ababa TZ EAT-3
Africa/Algiers TZ CET-1
Africa/Asmara TZ EAT-3
Africa/Asmera TZ EAT-3
Africa/Bamako TZ GMT0
Africa/Bangui TZ WAT-1
Africa/Banjul TZ GMT0
Africa/Bissau TZ GMT0
Africa/Blantyre TZ CAT-2
Africa/Brazzaville TZ WAT-1
Africa/Bujumbura TZ CAT-2
Africa/Cairo TZ EET-2
Africa/Casablanca TZ <GMT+1>-1
Africa/Ceuta TZ CET-1CEST,M3.5.0,M10.5.0/3
Africa/Conakry TZ GMT0
Africa/Dakar TZ GMT0
Africa/Dar es Salaam TZ EAT-3
Africa/Djibouti TZ EAT-3
Africa/Douala TZ WAT-1
Africa/El Aaiun TZ <GMT+1>-1
Africa/Freetown TZ GMT0
Africa/Gaborone TZ CAT-2
Africa/Harare TZ CAT-2
Africa/Johannesburg TZ SAST-2
Africa/Juba TZ EAT-3
Africa/Kampala TZ EAT-3
Africa/Khartoum TZ CAT-2
Africa/Kigali TZ CAT-2
Africa/Kinshasa TZ WAT-1
Africa/Lagos TZ WAT-1
Africa/Libreville TZ WAT-1
Africa/Lome TZ GMT0
Africa/Luanda TZ WAT-1
Africa/Lubumbashi TZ CAT-2
Africa/Lusaka TZ CAT-2
Africa/Malabo TZ WAT-1
Africa/Maputo TZ CAT-2
Africa/Maseru TZ SAST-2
Africa/Mbabane TZ SAST-2
Africa/Mogadishu TZ EAT-3
Africa/Monrovia TZ GMT0
Africa/Nairobi TZ EAT-3
Africa/Ndjamena TZ WAT-1
Africa/Niamey TZ WAT-1
Africa/Nouakchott TZ GMT0
Africa/Ouagadougou TZ GMT0
Africa/Porto-Novo TZ WAT-1
Africa/Sao Tome TZ GMT0
Africa/Timbuktu TZ GMT0
Africa/Tripoli TZ EET-2
Africa/Tunis TZ CET-1
Africa/Windhoek TZ CAT-2
America/Adak TZ HST10HDT,M3.2.0,M11.1.0
America/Anchorage TZ AKST9AKDT,M3.2.0,M11.1.0
America/Anguilla TZ AST4
America/Antigua TZ AST4
America/Araguaina TZ <GMT-3>+3
America/Argentina/Buenos Aires TZ <GMT-3>+3
America/Argentina/Catamarca TZ <GMT-3>+3
America/Argentina/Cordoba TZ <GMT-3>+3
America/Argentina/Jujuy TZ <GMT-3>+3
America/Argentina/La Rioja TZ <GMT-3>+3
America/Argentina/Mendoza TZ <GMT-3>+3
America/Argentina/Rio Gallegos TZ <GMT-3>+3
America/Argentina/Salta TZ <GMT-3>+3
America/Argentina/San Juan TZ <GMT-3>+3
America/Argentina/San Luis TZ <GMT-3>+3
America/Argentina/Tucuman TZ <GMT-3>+3
America/Argentina/Ushuaia TZ <GMT-3>+3
America/Aruba TZ AST4
America/Asuncion TZ <GMT-4>+4
America/Atikokan TZ EST5
America/Bahia TZ <GMT-3>+3
America/Bahia Banderas TZ CST6CDT,M4.1.0,M10.5.0
America/Barbados TZ AST4
America/Belem TZ <GMT-3>+3
America/Belize TZ CST6
America/Blanc-Sablon TZ AST4
America/Boa Vista TZ <GMT-4>+4
America/Bogota TZ <GMT-5>+5
America/Boise TZ MST7MDT,M3.2.0,M11.1.0
America/Cambridge Bay TZ MST7MDT,M3.2.0,M11.1.0
America/Campo Grande TZ <GMT-4>+4
America/Cancun TZ EST5
America/Caracas TZ <GMT-4>+4
America/Cayenne TZ <GMT-3>+3
America/Cayman TZ EST5
America/Chicago TZ CST6CDT,M3.2.0,M11.1.0
America/Chihuahua TZ MST7MDT,M4.1.0,M10.5.0
America/Costa Rica TZ CST6
America/Creston TZ MST7
America/Cuiaba TZ <GMT-4>+4
America/Curacao TZ AST4
America/Danmarkshavn TZ GMT0
America/Dawson TZ PST8PDT,M3.2.0,M11.1.0
America/Dawson Creek TZ MST7
America/Denver TZ MST7MDT,M3.2.0,M11.1.0
America/Detroit TZ EST5EDT,M3.2.0,M11.1.0
America/Dominica TZ AST4
America/Edmonton TZ MST7MDT,M3.2.0,M11.1.0
America/Eirunepe TZ <GMT-5>+5
America/El Salvador TZ CST6
America/Fort Nelson TZ MST7
America/Fortaleza TZ <GMT-3>+3
America/Glace Bay TZ AST4ADT,M3.2.0,M11.1.0
America/Goose Bay TZ AST4ADT,M3.2.0,M11.1.0
America/Grand Turk TZ EST5EDT,M3.2.0,M11.1.0
America/Grenada TZ AST4
America/Guadeloupe TZ AST4
America/Guatemala TZ CST6
America/Guayaquil TZ <GMT-5>+5
America/Guyana TZ <GMT-4>+4
America/Halifax TZ AST4ADT,M3.2.0,M11.1.0
America/Havana TZ CST5CDT,M3.2.0/0,M11.1.0/1
America/Hermosillo TZ MST7
America/Indiana/Indianapolis TZ EST5EDT,M3.2.0,M11.1.0
America/Indiana/Knox TZ CST6CDT,M3.2.0,M11.1.0
America/Indiana/Marengo TZ EST5EDT,M3.2.0,M11.1.0
America/Indiana/Petersburg TZ EST5EDT,M3.2.0,M11.1.0
America/Indiana/Tell City TZ CST6CDT,M3.2.0,M11.1.0
America/Indiana/Vevay TZ EST5EDT,M3.2.0,M11.1.0
America/Indiana/Vincennes TZ EST5EDT,M3.2.0,M11.1.0
America/Indiana/Winamac TZ EST5EDT,M3.2.0,M11.1.0
America/Inuvik TZ MST7MDT,M3.2.0,M11.1.0
America/Iqaluit TZ EST5EDT,M3.2.0,M11.1.0
America/Jamaica TZ EST5
America/Juneau TZ AKST9AKDT,M3.2.0,M11.1.0
America/Kentucky/Louisville TZ EST5EDT,M3.2.0,M11.1.0
America/Kentucky/Monticello TZ EST5EDT,M3.2.0,M11.1.0
America/Kralendijk TZ AST4
America/La Paz TZ <GMT-4>+4
America/Lima TZ <GMT-5>+5
America/Los Angeles TZ PST8PDT,M3.2.0,M11.1.0
America/Lower Princes TZ AST4
America/Maceio TZ <GMT-3>+3
America/Managua TZ CST6
America/Manaus TZ <GMT-4>+4
America/Marigot TZ AST4
America/Martinique TZ AST4
America/Matamoros TZ CST6CDT,M3.2.0,M11.1.0
America/Mazatlan TZ MST7MDT,M4.1.0,M10.5.0
America/Menominee TZ CST6CDT,M3.2.0,M11.1.0
America/Merida TZ CST6CDT,M4.1.0,M10.5.0
America/Metlakatla TZ AKST9AKDT,M3.2.0,M11.1.0
America/Mexico City TZ CST6CDT,M4.1.0,M10.5.0
America/Miquelon TZ <GMT-3>+3
America/Moncton TZ AST4ADT,M3.2.0,M11.1.0
America/Monterrey TZ CST6CDT,M4.1.0,M10.5.0
America/Montevideo TZ <GMT-3>+3
America/Montserrat TZ AST4
America/Nassau TZ EST5EDT,M3.2.0,M11.1.0
America/New York TZ EST5EDT,M3.2.0,M11.1.0
America/Nipigon TZ EST5EDT,M3.2.0,M11.1.0
America/Nome TZ AKST9AKDT,M3.2.0,M11.1.0
America/Noronha TZ <GMT-2>+2
America/North Dakota/Beulah TZ CST6CDT,M3.2.0,M11.1.0
America/North Dakota/Center TZ CST6CDT,M3.2.0,M11.1.0
America/North Dakota/New Salem TZ CST6CDT,M3.2.0,M11.1.0
America/Ojinaga TZ MST7MDT,M3.2.0,M11.1.0
America/Panama TZ EST5
America/Pangnirtung TZ EST5EDT,M3.2.0,M11.1.0
America/Paramaribo TZ <GMT-3>+3
America/Phoenix TZ MST7
America/Port-au-Prince TZ EST5EDT,M3.2.0,M11.1.0
America/Port of Spain TZ AST4
America/Porto Velho TZ <GMT-4>+4
America/Puerto Rico TZ AST4
America/Punta Arenas TZ <GMT-3>+3
America/Rainy River TZ CST6CDT,M3.2.0,M11.1.0
America/Rankin Inlet TZ CST6CDT,M3.2.0,M11.1.0
America/Recife TZ <GMT-3>+3
America/Regina TZ CST6
America/Resolute TZ CST6CDT,M3.2.0,M11.1.0
America/Rio Branco TZ <GMT-5>+5
America/Santarem TZ <GMT-3>+3
America/Santo Domingo TZ AST4
America/Sao Paulo TZ <GMT-3>+3
America/Scoresbysund TZ <GMT-1>+1
America/Sitka TZ AKST9AKDT,M3.2.0,M11.1.0
America/St Barthelemy TZ AST4
America/St Johns TZ NST3
America/St Kitts TZ AST4
America/St Lucia TZ AST4
America/St Thomas TZ AST4
America/St Vincent TZ AST4
America/Swift Current TZ CST6
America/Tegucigalpa TZ CST6
America/Thule TZ AST4ADT,M3.2.0,M11.1.0
America/Thunder Bay TZ EST5EDT,M3.2.0,M11.1.0
America/Tijuana TZ PST8PDT,M3.2.0,M11.1.0
America/Toronto TZ EST5EDT,M3.2.0,M11.1.0
America/Tortola TZ AST4
America/Vancouver TZ PST8PDT,M3.2.0,M11.1.0
America/Whitehorse TZ PST8PDT,M3.2.0,M11.1.0
America/Winnipeg TZ CST6CDT,M3.2.0,M11.1.0
America/Yakutat TZ AKST9AKDT,M3.2.0,M11.1.0
America/Yellowknife TZ MST7MDT,M3.2.0,M11.1.0
Antarctica/Casey TZ <GMT+8>-8
Antarctica/Davis TZ <GMT+7>-7
Antarctica/DumontDUrville TZ <GMT+10>-10
Antarctica/Macquarie TZ <GMT+11>-11
Antarctica/Mawson TZ <GMT+5>-5
Antarctica/McMurdo TZ NZST-12NZDT,M9.5.0,M4.1.0/3
Antarctica/Palmer TZ <GMT-3>+3
Antarctica/Rothera TZ <GMT-3>+3
Antarctica/Syowa TZ <GMT+3>-3
Antarctica/Troll TZ 0
Antarctica/Vostok TZ <GMT+6>-6
Arctic/Longyearbyen TZ CET-1CEST,M3.5.0,M10.5.0/3
Asia/Aden TZ <GMT+3>-3
Asia/Almaty TZ <GMT+6>-6
Asia/Amman TZ EET-2EEST,M3.5.4/24,M10.5.5/1
Asia/Anadyr TZ <GMT+12>-12
Asia/Aqtau TZ <GMT+5>-5
Asia/Aqtobe TZ <GMT+5>-5
Asia/Ashgabat TZ <GMT+5>-5
Asia/Atyrau TZ <GMT+5>-5
Asia/Baghdad TZ <GMT+3>-3
Asia/Bahrain TZ <GMT+3>-3
Asia/Baku TZ <GMT+4>-4
Asia/Bangkok TZ <GMT+7>-7
Asia/Barnaul TZ <GMT+7>-7
Asia/Beirut TZ EET-2EEST,M3.5.0/0,M10.5.0/0
Asia/Bishkek TZ <GMT+6>-6
Asia/Brunei TZ <GMT+8>-8
Asia/Chita TZ <GMT+9>-9
Asia/Choibalsan TZ <GMT+8>-8
Asia/Colombo TZ <GMT+5>-5
Asia/Damascus TZ EET-2EEST,M3.5.5/0,M10.5.5/0
Asia/Dhaka TZ <GMT+6>-6
Asia/Dili TZ <GMT+9>-9
Asia/Dubai TZ <GMT+4>-4
Asia/Dushanbe TZ <GMT+5>-5
Asia/Famagusta TZ EET-2EEST,M3.5.0/3,M10.5.0/4
Asia/Gaza TZ EET-2EEST,M3.5.5/0,M10.5.6/1
Asia/Hebron TZ EET-2EEST,M3.5.5/0,M10.5.6/1
Asia/Ho Chi Minh TZ <GMT+7>-7
Asia/Hong Kong TZ HKT-8
Asia/Hovd TZ <GMT+7>-7
Asia/Irkutsk TZ <GMT+8>-8
Asia/Istanbul TZ <GMT+3>-3
Asia/Jakarta TZ WIB-7
Asia/Jayapura TZ WIT-9
Asia/Kabul TZ <GMT+4>-4
Asia/Kamchatka TZ <GMT+12>-12
Asia/Karachi TZ PKT-5
Asia/Kathmandu TZ <GMT+5>-5
Asia/Khandyga TZ <GMT+9>-9
Asia/Kolkata TZ IST-5
Asia/Krasnoyarsk TZ <GMT+7>-7
Asia/Kuala Lumpur TZ <GMT+8>-8
Asia/Kuching TZ <GMT+8>-8
Asia/Kuwait TZ <GMT+3>-3
Asia/Macau TZ CST-8
Asia/Magadan TZ <GMT+11>-11
Asia/Makassar TZ WITA-8
Asia/Manila TZ PST-8
Asia/Muscat TZ <GMT+4>-4
Asia/Nicosia TZ EET-2EEST,M3.5.0/3,M10.5.0/4
Asia/Novokuznetsk TZ <GMT+7>-7
Asia/Novosibirsk TZ <GMT+7>-7
Asia/Omsk TZ <GMT+6>-6
Asia/Oral TZ <GMT+5>-5
Asia/Phnom Penh TZ <GMT+7>-7
Asia/Pontianak TZ WIB-7
Asia/Pyongyang TZ KST-9
Asia/Qatar TZ <GMT+3>-3
Asia/Qostanay TZ <GMT+6>-6
Asia/Qyzylorda TZ <GMT+5>-5
Asia/Riyadh TZ <GMT+3>-3
Asia/Sakhalin TZ <GMT+11>-11
Asia/Samarkand TZ <GMT+5>-5
Asia/Seoul TZ KST-9
Asia/Shanghai TZ CST-8
Asia/Singapore TZ <GMT+8>-8
Asia/Srednekolymsk TZ <GMT+11>-11
Asia/Taipei TZ CST-8
Asia/Tashkent TZ <GMT+5>-5
Asia/Tbilisi TZ <GMT+4>-4
Asia/Tehran TZ <GMT+3>-3
Asia/Thimphu TZ <GMT+6>-6
Asia/Tokyo TZ JST-9
Asia/Tomsk TZ <GMT+7>-7
Asia/Ulaanbaatar TZ <GMT+8>-8
Asia/Urumqi TZ <GMT+6>-6
Asia/Ust-Nera TZ <GMT+10>-10
Asia/Vientiane TZ <GMT+7>-7
Asia/Vladivostok TZ <GMT+10>-10
Asia/Yakutsk TZ <GMT+9>-9
Asia/Yangon TZ <GMT+6>-6
Asia/Yekaterinburg TZ <GMT+5>-5
Asia/Yerevan TZ <GMT+4>-4
Atlantic/Azores TZ <GMT-1>+1
Atlantic/Bermuda TZ AST4ADT,M3.2.0,M11.1.0
Atlantic/Canary TZ WET0WEST,M3.5.0/1,M10.5.0
Atlantic/Cape Verde TZ <GMT-1>+1
Atlantic/Faroe TZ WET0WEST,M3.5.0/1,M10.5.0
Atlantic/Madeira TZ WET0WEST,M3.5.0/1,M10.5.0
Atlantic/Reykjavik TZ GMT0
Atlantic/South Georgia TZ <GMT-2>+2
Atlantic/St Helena TZ GMT0
Atlantic/Stanley TZ <GMT-3>+3
Australia/Adelaide TZ ACST-9
Australia/Brisbane TZ AEST-10
Australia/Broken Hill TZ ACST-9
Australia/Currie TZ AEST-10AEDT,M10.1.0,M4.1.0/3
Australia/Darwin TZ ACST-9
Australia/Eucla TZ <GMT+8>-8
Australia/Hobart TZ AEST-10AEDT,M10.1.0,M4.1.0/3
Australia/Lindeman TZ AEST-10
Australia/Lord Howe TZ <GMT+10>-10
Australia/Melbourne TZ AEST-10AEDT,M10.1.0,M4.1.0/3
Australia/Perth TZ AWST-8
Australia/Sydney TZ AEST-10AEDT,M10.1.0,M4.1.0/3
Europe/Amsterdam TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Andorra TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Astrakhan TZ <GMT+4>-4
Europe/Athens TZ EET-2EEST,M3.5.0/3,M10.5.0/4
Europe/Belgrade TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Berlin TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Bratislava TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Brussels TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Bucharest TZ EET-2EEST,M3.5.0/3,M10.5.0/4
Europe/Budapest TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Busingen TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Chisinau TZ EET-2EEST,M3.5.0,M10.5.0/3
Europe/Copenhagen TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Dublin TZ IST-1GMT0,M10.5.0,M3.5.0/1
Europe/Gibraltar TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Guernsey TZ GMT0BST,M3.5.0/1,M10.5.0
Europe/Helsinki TZ EET-2EEST,M3.5.0/3,M10.5.0/4
Europe/Isle of Man TZ GMT0BST,M3.5.0/1,M10.5.0
Europe/Istanbul TZ <GMT+3>-3
Europe/Jersey TZ GMT0BST,M3.5.0/1,M10.5.0
Europe/Kaliningrad TZ EET-2
Europe/Kiev TZ EET-2EEST,M3.5.0/3,M10.5.0/4
Europe/Kirov TZ <GMT+3>-3
Europe/Lisbon TZ WET0WEST,M3.5.0/1,M10.5.0
Europe/Ljubljana TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/London TZ GMT0BST,M3.5.0/1,M10.5.0
Europe/Luxembourg TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Madrid TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Malta TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Mariehamn TZ EET-2EEST,M3.5.0/3,M10.5.0/4
Europe/Minsk TZ <GMT+3>-3
Europe/Monaco TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Moscow TZ MSK-3
Europe/Nicosia TZ EET-2EEST,M3.5.0/3,M10.5.0/4
Europe/Oslo TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Paris TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Podgorica TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Prague TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Riga TZ EET-2EEST,M3.5.0/3,M10.5.0/4
Europe/Rome TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Samara TZ <GMT+4>-4
Europe/San Marino TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Sarajevo TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Saratov TZ <GMT+4>-4
Europe/Simferopol TZ MSK-3
Europe/Skopje TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Sofia TZ EET-2EEST,M3.5.0/3,M10.5.0/4
Europe/Stockholm TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Tallinn TZ EET-2EEST,M3.5.0/3,M10.5.0/4
Europe/Tirane TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Ulyanovsk TZ <GMT+4>-4
Europe/Uzhgorod TZ EET-2EEST,M3.5.0/3,M10.5.0/4
Europe/Vaduz TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Vatican TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Vienna TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Vilnius TZ EET-2EEST,M3.5.0/3,M10.5.0/4
Europe/Volgograd TZ <GMT+4>-4
Europe/Warsaw TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Zagreb TZ CET-1CEST,M3.5.0,M10.5.0/3
Europe/Zaporozhye TZ EET-2EEST,M3.5.0/3,M10.5.0/4
Europe/Zurich TZ CET-1CEST,M3.5.0,M10.5.0/3
Indian/Antananarivo TZ EAT-3
Indian/Chagos TZ <GMT+6>-6
Indian/Christmas TZ <GMT+7>-7
Indian/Cocos TZ <GMT+6>-6
Indian/Comoro TZ EAT-3
Indian/Kerguelen TZ <GMT+5>-5
Indian/Mahe TZ <GMT+4>-4
Indian/Maldives TZ <GMT+5>-5
Indian/Mauritius TZ <GMT+4>-4
Indian/Mayotte TZ EAT-3
Indian/Reunion TZ <GMT+4>-4
Pacific/Apia TZ <GMT+13>-13
Pacific/Auckland TZ NZST-12NZDT,M9.5.0,M4.1.0/3
Pacific/Bougainville TZ <GMT+11>-11
Pacific/Chatham TZ <GMT+12>-12
Pacific/Chuuk TZ <GMT+10>-10
Pacific/Efate TZ <GMT+11>-11
Pacific/Enderbury TZ <GMT+13>-13
Pacific/Fakaofo TZ <GMT+13>-13
Pacific/Funafuti TZ <GMT+12>-12
Pacific/Galapagos TZ <GMT-6>+6
Pacific/Gambier TZ <GMT-9>+9
Pacific/Guadalcanal TZ <GMT+11>-11
Pacific/Honolulu TZ HST10
Pacific/Kiritimati TZ <GMT+14>-14
Pacific/Kosrae TZ <GMT+11>-11
Pacific/Kwajalein TZ <GMT+12>-12
Pacific/Majuro TZ <GMT+12>-12
Pacific/Marquesas TZ <GMT-9>+9
Pacific/Midway TZ SST11
Pacific/Nauru TZ <GMT+12>-12
Pacific/Niue TZ <GMT-11>+11
Pacific/Norfolk TZ <GMT+11>-11
Pacific/Noumea TZ <GMT+11>-11
Pacific/Pago Pago TZ SST11
Pacific/Palau TZ <GMT+9>-9
Pacific/Pitcairn TZ <GMT-8>+8
Pacific/Pohnpei TZ <GMT+11>-11
Pacific/Port Moresby TZ <GMT+10>-10
Pacific/Rarotonga TZ <GMT-10>+10
Pacific/Tahiti TZ <GMT-10>+10
Pacific/Tarawa TZ <GMT+12>-12
Pacific/Tongatapu TZ <GMT+13>-13
Pacific/Wake TZ <GMT+12>-12
Pacific/Wallis TZ <GMT+12>-12
@EndNode
@@ -219,13 +678,12 @@ to screen (unless overridden by CLI or icon tooltype with LOGFILE=NO).
@Prev "Saving preferences"
@Next "Software License"
Version 1.05, dated 06.08.2018, has proved itself to be a stable version
and has been promoted to Long Term Support. It is distributed along with
the latest version of AmiTimeKeeper.
A custom build version has been integrated into the Icaros Desktop system.
The author encourages all developers with an interest to make their own
build.
@{b}v1.10 20.03.2020@{ub}
- RTC is no longer required during startup
- When time zone changes it is now recognized
- Several bugs affecting time zone logic fixed
- Documentation updated with POSIX TZ examples
- Compiled with upgraded GCC, version 6.2
@{b}v1.09 14.07.2019@{ub}
- Initial DST support using POSIX TZ and Amiga TZONE variable
@@ -235,7 +693,7 @@ build.
- When using pool server cycle with prefix 0 to 3
- Display of wrong signes in time zone fixed
- Faulty log messages about settings fixed
- Timer bug causing infitive loop fixed
- Timer bug causing infinitive loop fixed
- Memory leak in settings window fixed
@{b}v1.07 15.02.2019@{ub}
@@ -281,7 +739,7 @@ build.
@Node "Software License" "TimeKeeper.guide/Software License"
@Prev "Change Log"
@Next "Contacting the author"
@Next "Credits and donations"
@Toc "Main"
@{b}Simplified BSD License / 2-clause BSD license@{ub}
@@ -289,7 +747,7 @@ build.
Copyright (c) 2001, 02 Motoyuki Kasahara
Copyright (c) 2007 TANDBERG Telecom AS
Copyright (c) 2008-2009 Dag-Erling Smørgrav <des@des.no>
Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -314,20 +772,43 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@EndNode
@Node "Contacting the author" "TimeKeeper.guide/Contacting the author"
@Toc "Main"
@Node "Credits and donations" "TimeKeeper.guide/Credits and donations"
@Prev "Software License"
@Next "Contacting the author"
@Toc "Main"
The author of AmiTimeKeeper can be contacted using the following
email addresses: <carsten.larsen@mail.com> or <cs@innolan.net>.
A custom version has been integrated into the Icaros Desktop system.
The author encourages all developers with an interest to make their own
build.
Please notice <cs@innolan.net> is a member of several high volume
mailing lists and should not be used under normal circumstances.
The following people have contributed with bug reports, comments,
suggestions and donations:
* aPEX from a1k.org
* Paolo Besser
* Knut Hansen
* Greg Donner
* Thomas Blatt
* Bartosz Makara
* Benny Damsgaard
* Neil Pearson
If you like this software you can also consider to make a small
donation to the PayPal account <carsten.larsen@mail.com>.
@EndNode
@Node "Contacting the author" "TimeKeeper.guide/Contacting the author"
@Prev "Credits and donations"
@Toc "Main"
The author of AmiTimeKeeper can be contacted using the email address
<carsten.larsen@mail.com>.
Feel free to send suggestions, feature request and bug reports.
General comment and questions are also welcome.
Carsten Sonne Larsen
February 2019
February 2020
@EndNode
+11 -57
View File
@@ -2,7 +2,7 @@ Short: Keep your time right
Author: Carsten Larsen (carsten.larsen@mail.com)
Uploader: Carsten Larsen (carsten.larsen@mail.com)
Type: util/cdity
Version: 1.09
Version: 1.10
Architecture: m68k-amigaos
AmiTimeKeeper is a small program which keeps the time right on your
@@ -18,60 +18,14 @@ The default server address is pool.ntp.org. To find another server
try visiting support.ntp.org or one of the other sites listing time
servers.
Version 1.05 has proved itself to be a stable version and has been
promoted to Long Term Support. It is distributed along with the
latest version.
The local time zone needs to be configured using Workbench preferences
or a similar tool. In AmigaOS 3.1 and 3.9 this is available through
the Locale Preferences Editor. Daylight saving time is only supported
through the POSIX TZ environment variable.
A custom build version has been integrated into the Icaros Desktop
system. The author encourages all developers with an interest to
make their own build.
v1.09 14.07.2019
- Initial DST support using POSIX TZ and Amiga TZONE variable
- Restart synchronizer processes on DNS lookup failures
v1.08 18.05.2019
- When using pool server cycle with prefix 0 to 3
- Display of wrong signes in time zone fixed
- Faulty log messages about settings fixed
- Timer bug causing infitive loop fixed
- Memory leak in settings window fixed
v1.07 15.02.2019
- Support commodity hotkey and popup options
- Hide advanced settings with new expert option
v1.06 08.02.2019
- Adjust layout in settings window
v1.05 06.08.2018 LTS
- Preferences can now be saved from settings window
- Time zone is shown as UTC offset in settings window
- Running multiple instances no longer creates zombie processes
- Low water option renamed to threshold and high water option removed
- New option for sending log messages to file instead of to screen
- Some incorrect NTP log messages no longer appears
- Read-only option is now applied consistently
- Potential race condition in memory allocation fixed
- Other minor enhancements
v1.04 15.12.2017
- Default settings adjusted to comply better with AmigaOS
- Bugs in threshold settings (high/low water) fixed
- Bugs in opening and closing of libraries fixed
- New and more accurate error and log messages
v1.03 09.12.2017
- Settings window
v1.02 29.11.2017
- AROS code compliance
v1.01 28.11.2017
- Handle network disconnection
- Fix infinity timeout problem
- Support hardware clock
- Improved error messages
v1.00 26.11.2017
- First public release
v1.10 20.03.2020
- RTC is no longer required during startup
- When time zone changes it is now recognized
- Several bugs affecting time zone logic fixed
- Documentation updated with POSIX TZ examples
- Compiled with upgraded GCC, version 6.2
+6 -6
View File
@@ -318,9 +318,9 @@ int daylight_c(void)
return daylight;
}
long timezone_c(void)
long Timezone_c(void)
{
return timezone;
return Timezone;
}
long altzone_c(void)
@@ -340,11 +340,11 @@ struct lc_time_T *_current_locale()
}
size_t
_strftime(const timezone_t sp, char *const s, const size_t maxsize,
_strftime(const Timezone_t sp, char *const s, const size_t maxsize,
const char *const format, const struct tm *const t, struct lc_time_T *loc);
size_t
strftime_lz(const timezone_t sp, char *const s, const size_t maxsize,
strftime_lz(const Timezone_t sp, char *const s, const size_t maxsize,
const char *const format, const struct tm *const t, locale_t locale)
{
size_t res;
@@ -422,7 +422,7 @@ void CurrentTimeGmt(ULONG *seconds, ULONG *micros)
{
ULONG sec, mic;
CurrentTime(&sec, &mic);
*seconds = sec + (daylight ? altzone : timezone);
*seconds = sec + (daylight ? altzone : Timezone);
*micros = mic;
}
@@ -446,7 +446,7 @@ struct tm *AmigaLocalTime(ULONG *seconds, struct tm *tm)
return tm;
}
struct tm *AmigaLocalTimeZ(ULONG *seconds, struct tm *tm, const timezone_t tz)
struct tm *AmigaLocalTimeZ(ULONG *seconds, struct tm *tm, const Timezone_t tz)
{
time_t time;
if (tm == NULL)
+3 -3
View File
@@ -50,7 +50,7 @@
"(" DATE_TEXT ")"
#define TZVARIABLE1 "TZ"
#define TZVARIABLE2 "timezone.prefs"
#define TZVARIABLE2 "Timezone.prefs"
#define TZVARIABLE TZVARIABLE1
#define ENVSIZE 128
@@ -110,7 +110,7 @@ struct lc_time_T
/* amiga.c tz functions */
int daylight_c(void);
long timezone_c(void);
long Timezone_c(void);
long altzone_c(void);
char **tzname_c(void);
int getsystime(struct timeval *tv);
@@ -122,7 +122,7 @@ int settimeofday(const struct timeval *tv, void *tz);
struct lc_time_T *openlc(locale_t locale);
void closelc(struct lc_time_T *lc);
extern const struct lc_time_T C_time_locale;
extern long timezone;
extern long Timezone;
extern long altzone;
extern int daylight;
extern struct SignalSemaphore *TimerSemaphore;
BIN
View File
Binary file not shown.
+362 -213
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,16 +25,35 @@
*/
#include "config.h"
#include "global.h"
#include "notify.h"
#include "message.h"
#include "setting.h"
#include "shutdown.h"
#include "sync.h"
#include "mem.h"
#include "win.h"
#include "tz.h"
#include "libraries/screennotify.h"
#include "logmod.h"
#define MODULENAME "Main"
#define EVT_HOTKEY 1L
static void ProcessMsg(void);
static void InitBroker(void);
static void MsgLoop(void);
static void CleanupBroker(void);
struct AppBroker
{
CxObj *Object;
struct MsgPort *BrokerPort;
struct MsgPort *NotifyPort;
struct MsgPort *ScreenPort;
APTR screenNotifyWB;
APTR screenNotifyPub;
};
static struct NewBroker newBroker = {
NB_VERSION,
(STRPTR)APP_SHORT_NAME,
@@ -44,50 +63,68 @@ static struct NewBroker newBroker = {
COF_SHOW_HIDE,
0, 0, 0};
static struct AppBroker Broker;
static volatile bool BrokerRunning = false;
void StartBroker(void)
{
LONG error;
struct Message *msg;
CxObj *filter, *sender, *translate;
InitBroker();
LogTrace("Initializing");
Broker.Object = NULL;
Broker.BrokerPort = NULL;
Broker.NotifyPort = NULL;
Broker.ScreenPort = NULL;
Broker.screenNotifyWB = NULL;
Broker.screenNotifyPub = NULL;
Ports.BrokerPort = NULL;
Ports.MemoryPort = NULL;
Globals->Broker->BrokerPort = CreateMsgPort();
if (Globals->Broker->BrokerPort == NULL)
Broker.BrokerPort = CreateMsgPort();
if (Broker.BrokerPort == NULL)
{
LogError("Could not allocate broker port");
return;
}
Globals->Broker->UserPort = CreateMsgPort();
if (Globals->Broker->UserPort == NULL)
Ports.BrokerPort = CreateMsgPort();
if (Ports.BrokerPort == NULL)
{
LogError("Could not allocate broker user port");
CleanupBroker();
return;
}
Globals->Broker->ReplyPort = CreateMsgPort();
if (Globals->Broker->ReplyPort == NULL)
Broker.NotifyPort = CreateMsgPort();
if (Broker.NotifyPort == NULL)
{
LogError("Could not allocate broker notify port");
CleanupBroker();
return;
}
Broker.ScreenPort = CreateMsgPort();
if (Broker.ScreenPort == NULL)
{
LogError("Could not allocate broker screen port");
CleanupBroker();
return;
}
Ports.MemoryPort = CreateMsgPort();
if (Ports.MemoryPort == NULL)
{
LogError("Could not allocate broker reply port");
CleanupBroker();
return;
}
Globals->Broker->ShutdownSigBit = AllocSignal(-1);
if (Globals->Broker->ShutdownSigBit == -1)
{
SendErrorMessage("Could not allocate signal for broker");
CleanupBroker();
return;
}
newBroker.nb_Port = Broker.BrokerPort;
newBroker.nb_Pri = Settings->Priority;
newBroker.nb_Port = Globals->Broker->BrokerPort;
newBroker.nb_Pri = Globals->Settings->Priority;
Globals->Broker->Object = CxBroker(&newBroker, &error);
if (!Globals->Broker->Object)
Broker.Object = CxBroker(&newBroker, &error);
if (!Broker.Object)
{
switch (error)
{
@@ -95,7 +132,7 @@ void StartBroker(void)
LogError("System problems (CBERR_SYSERR). Could not allocate broker object");
break;
case CBERR_DUP:
LogWarning(APP_SHORT_NAME " is already running");
LogWarn(APP_SHORT_NAME " is already running");
break;
default:
LogError("Could not allocate broker object (error code: %ld)", error);
@@ -106,7 +143,7 @@ void StartBroker(void)
return;
}
filter = CxFilter(Globals->Settings->PopKey);
filter = CxFilter(Settings->PopKey);
if (filter == NULL)
{
LogError("Could not allocate broker filter object");
@@ -114,9 +151,9 @@ void StartBroker(void)
return;
}
AttachCxObj(Globals->Broker->Object, filter);
AttachCxObj(Broker.Object, filter);
sender = CxSender(Globals->Broker->BrokerPort, EVT_HOTKEY);
sender = CxSender(Broker.BrokerPort, EVT_HOTKEY);
if (sender == NULL)
{
LogError("Could not allocate broker sender object");
@@ -142,273 +179,385 @@ void StartBroker(void)
switch (error)
{
case CBERR_SYSERR:
LogWarning("Commodity filter problems (CBERR_SYSERR)");
LogWarn("Commodity filter problems (CBERR_SYSERR)");
break;
case COERR_BADFILTER:
LogWarning("Commodity HOTKEY error");
LogWarn("Commodity HOTKEY error");
break;
default:
LogWarning("Commodity filter error (error code: %ld)", error);
LogWarn("Commodity filter error (error code: %ld)", error);
break;
}
}
Globals->Broker->Task = FindTask(NULL);
if (ScreenNotifyBase != NULL)
{
Broker.screenNotifyWB = AddWorkbenchClient(Broker.ScreenPort, 0);
Broker.screenNotifyPub = AddPubScreenClient(Broker.ScreenPort, 0);
LogTrace("AddWorkbenchClient");
}
StartCom();
ProcessMsg();
ActivateNotifyPort(Broker.NotifyPort);
StartSynchronizer();
while ((msg = GetMsg(Globals->Broker->BrokerPort)))
ReplyMsg(msg);
while ((msg = GetMsg(Globals->Broker->UserPort)))
ReplyMsg(msg);
while ((msg = GetMsg(Globals->Broker->ReplyPort)))
ReplyMsg(msg);
MsgLoop();
CleanupBroker();
}
void ShutdownBroker(void)
bool IsBrokerRunning(void)
{
Signal((struct Task *)Globals->Broker->Task,
(1 << Globals->Broker->ShutdownSigBit));
return BrokerRunning;
}
void SetBrokerPriority(int priority)
{
SetCxObjPri(Globals->Broker->Object, priority);
}
static void Activate(void)
{
LogWarning("ACTIVE changed: 1 -> 0");
ActivateCxObj(Globals->Broker->Object, 0);
Globals->Active = false;
StopComAsync();
while (!CheckComClosed())
Delay(1);
SetCxObjPri(Broker.Object, priority);
}
static void Deactivate(void)
{
LogWarning("ACTIVE changed: 0 -> 1");
ActivateCxObj(Globals->Broker->Object, 1);
Globals->Active = true;
StartCom();
LogDebug("ACTIVE changed: 1 -> 0");
LogWarn("Disabling time synchronization");
SendMessageWait(Ports.SyncerPort, ATK_DISABLE);
ActivateCxObj(Broker.Object, 0);
}
static void StopSubProcesses(void)
static void Activate(void)
{
Forbid();
Globals->ShuttingDown = true;
Permit();
HideSettingWindow();
while (!CheckSettingWindowClosed())
Delay(10);
StopComAsync();
while (!CheckComClosed())
Delay(10);
LogDebug("ACTIVE changed: 0 -> 1");
LogWarn("Enabling time synchronization");
ActivateCxObj(Broker.Object, 1);
StartSynchronizer();
}
static void ProcessMsg(void)
static void ChangeTimezone(void)
{
bool run = true;
ULONG sigmask = SIGBREAKF_CTRL_C |
(1 << Globals->Broker->ShutdownSigBit) |
(1 << Globals->Broker->BrokerPort->mp_SigBit) |
(1 << Globals->Broker->UserPort->mp_SigBit) |
(1 << Globals->Broker->ReplyPort->mp_SigBit);
// TODO: Make thread safe
CleanupTimezone();
InitTimezone();
SendMessageTo(Ports.WindowPort, Ports.MemoryPort, ATK_TZ_CHANGED);
}
ActivateCxObj(Globals->Broker->Object, 1);
Globals->Active = true;
static void ChangeTimezoneDelayedProc(void)
{
// TODO: Make thread safe
Delay(15 * 50);
ReopenLocale();
ChangeTimezone();
SendMessageTo(Ports.WindowPort, Ports.MemoryPort, ATK_TZ_CHANGED);
}
if (Globals->Settings->Popup)
static void ChangeTimezoneDelayed(void)
{
CreateNewProcTags(
NP_Entry, (IPTR)ChangeTimezoneDelayedProc,
NP_StackSize, 16 * 1024,
NP_Name, 0,
NP_Input, 0,
NP_Output, 0,
NP_Error, 0,
NP_CloseInput, FALSE,
NP_CloseOutput, FALSE,
NP_CloseError, FALSE,
NP_WindowPtr, 0,
NP_ConsoleTask, 0,
NP_Cli, FALSE,
TAG_DONE);
}
static bool HandleBrokerMessage(LONG msgid, ULONG msgtype)
{
switch (msgtype)
{
case CXM_IEVENT:
switch (msgid)
{
case EVT_HOTKEY:
LogDebug("Show window");
ShowSettingWindow();
break;
default:
break;
}
break;
case CXM_COMMAND:
switch (msgid)
{
case CXCMD_DISABLE:
Deactivate();
break;
case CXCMD_ENABLE:
Activate();
break;
case CXCMD_KILL:
LogInfo("Received shut down from commodity");
return false;
break;
case CXCMD_UNIQUE:
LogWarn("Commodity duplicate detected");
LogDebug("Show window");
ShowSettingWindow();
break;
case CXCMD_APPEAR:
LogDebug("Show window");
ShowSettingWindow();
break;
case CXCMD_DISAPPEAR:
LogDebug("Hide window");
SendMessageTo(Ports.WindowPort, Ports.MemoryPort, ATK_SHUTDOWN);
break;
default:
break;
}
}
return true;
}
static bool HandleUserMessage(long msg)
{
switch (msg)
{
case ATK_STORE:
SaveSettings(true);
SaveSettings(false);
SendMessageTo(Ports.WindowPort, Ports.MemoryPort, ATK_SHUTDOWN);
break;
case ATK_APPLY:
SaveSettings(false);
SendMessageTo(Ports.WindowPort, Ports.MemoryPort, ATK_SHUTDOWN);
break;
case ATK_UNDO:
ApplyAppSettings(WindowSettings, true);
SendMessageTo(Ports.WindowPort, Ports.MemoryPort, ATK_SHUTDOWN);
break;
case ATK_RESTART:
SendMessageWait(Ports.SyncerPort, ATK_RESTART);
break;
case ATK_DISABLE:
Activate();
break;
case ATK_ENABLE:
Deactivate();
break;
case ATK_READONLY:
LogDebug("READONLY changed: 1 -> 0");
LogWarn("Entering read only mode. Clock is not adjusted in read-only mode");
break;
case ATK_READWRITE:
LogDebug("READONLY changed: 0 -> 1");
LogWarn("Leaving read only mode. Clock is adjusted again");
break;
case ATK_SHUTDOWN:
return false;
break;
default:
break;
}
return true;
}
static void MsgLoop(void)
{
bool reopenWindow = false;
bool loop = true;
long shutdown = LOOP_RUNNING;
ULONG brokerSigMask = (1 << Broker.BrokerPort->mp_SigBit);
ULONG userSigMask = (1 << Ports.BrokerPort->mp_SigBit);
ULONG replySigMask = (1 << Ports.MemoryPort->mp_SigBit);
ULONG notifySigMask = (1 << Broker.NotifyPort->mp_SigBit);
ULONG screenSigMask = (1 << Broker.ScreenPort->mp_SigBit);
ULONG sigMask = brokerSigMask | notifySigMask | userSigMask |
screenSigMask | replySigMask | SIGBREAKF_CTRL_C;
BrokerRunning = true;
LogTrace("Loop started");
ActivateCxObj(Broker.Object, 1);
if (Settings->Popup)
{
ShowSettingWindow();
}
do
{
ULONG sigrcvd = Wait(sigmask);
if (sigrcvd & (1 << Globals->Broker->BrokerPort->mp_SigBit))
ULONG sigrcvd = Wait(sigMask);
if (sigrcvd & brokerSigMask)
{
CxMsg *msg;
while ((msg = (CxMsg *)GetMsg(Globals->Broker->BrokerPort)))
while ((msg = (CxMsg *)GetMsg(Broker.BrokerPort)))
{
LONG msgid = CxMsgID(msg);
ULONG msgtype = CxMsgType(msg);
bool cont;
LONG msgId = CxMsgID(msg);
ULONG msgType = CxMsgType(msg);
ReplyMsg((struct Message *)msg);
switch (msgtype)
cont = HandleBrokerMessage(msgId, msgType);
if (!cont)
{
case CXM_IEVENT:
switch (msgid)
{
case EVT_HOTKEY:
LogTrace("Show window");
ShowSettingWindow();
break;
}
break;
case CXM_COMMAND:
switch (msgid)
{
case CXCMD_DISABLE:
Activate();
break;
case CXCMD_ENABLE:
Deactivate();
break;
case CXCMD_KILL:
LogInfo("Received shut down from commodity");
StopSubProcesses();
run = false;
break;
case CXCMD_UNIQUE:
LogWarning("Commodity duplicate detected");
LogTrace("Show window");
ShowSettingWindow();
break;
case CXCMD_APPEAR:
LogTrace("Show window");
ShowSettingWindow();
break;
case CXCMD_DISAPPEAR:
LogTrace("Hide window");
HideSettingWindow();
break;
}
shutdown = SHUTDOWN_REQUEST;
}
}
}
if (sigrcvd & (1 << Globals->Broker->UserPort->mp_SigBit))
if (sigrcvd & userSigMask)
{
struct AppWindowMessage *msg;
while ((msg = (struct AppWindowMessage *)GetMsg(Globals->Broker->UserPort)))
struct ApplicationMesage *msg;
while ((msg = (struct ApplicationMesage *)GetMsg(Ports.BrokerPort)))
{
switch (msg->Type)
bool cont;
long msgId = msg->MsgId;
ReplyMsg((struct Message *)msg);
cont = HandleUserMessage(msgId);
if (!cont)
{
case ATK_LOGERROR:
LogError(msg->Text);
loop = false;
}
}
}
if (sigrcvd & notifySigMask)
{
struct NotifyMessage *msg;
while ((msg = (struct NotifyMessage *)GetMsg(Broker.NotifyPort)))
{
long msgType = msg->nm_NReq->nr_UserData;
ReplyMsg((struct Message *)msg);
switch (msgType)
{
case ATK_TZ_CHANGED:
LogDebug("TZ changed");
ChangeTimezone();
break;
case ATK_LOGWARN:
LogWarning(msg->Text);
case ATK_TZONE_CHANGED:
LogDebug("TZONE changed");
ChangeTimezone();
break;
case ATK_LOGINFO:
LogInfo(msg->Text);
break;
case ATK_LOGTRACE:
LogTrace(msg->Text);
break;
case ATK_STORE:
SaveSettings(true);
SaveSettings(false);
break;
case ATK_APPLY:
SaveSettings(false);
break;
case ATK_UNDO:
ApplyAppSettings(Globals->Window->Settings, true);
break;
case ATK_RESTART:
RestartSntpAsync();
break;
case ATK_REFRESH:
// Broker cannot refresh
break;
case ATK_DISABLE:
Activate();
break;
case ATK_ENABLE:
Deactivate();
break;
case ATK_READONLY:
LogWarning("READONLY changed: 1 -> 0");
break;
case ATK_READWRITE:
LogWarning("READONLY changed: 0 -> 1");
break;
default:
case ATK_LOCALE_CHANGED:
LogError("Locale changed");
ChangeTimezoneDelayed();
break;
}
break;
}
}
if (sigrcvd & screenSigMask)
{
struct ScreenNotifyMessage *msg;
while ((msg = (struct ScreenNotifyMessage *)GetMsg(Broker.ScreenPort)))
{
LogDebug("ScreenNotifyMessage");
if (msg->snm_Type == SCREENNOTIFY_TYPE_WORKBENCH)
{
if (msg->snm_Value == NULL)
{
LogDebug("WB Close");
LogDebug("Hide window");
SendMessageTo(Ports.WindowPort,
Ports.MemoryPort,
ATK_DISABLE);
reopenWindow = WindowProcRunning;
}
else
{
LogDebug("WB Open");
if (reopenWindow)
{
ShowSettingWindow();
}
ReopenLocale();
ChangeTimezone();
reopenWindow = false;
}
}
ReplyMsg((struct Message *)msg);
}
}
if (sigrcvd & (1 << Globals->Broker->ReplyPort->mp_SigBit))
if (sigrcvd & replySigMask)
{
struct AppWindowMessage *msg;
while ((msg = (struct AppWindowMessage *)GetMsg(Globals->Broker->ReplyPort)))
struct ApplicationMesage *msg;
while ((msg = (struct ApplicationMesage *)GetMsg(Ports.MemoryPort)))
{
if (msg->Text != NULL)
{
FreeMemSafe(msg->Text, __FUNCTION__);
}
FreeMemSafe(msg, __FUNCTION__);
FreeMemSafe(msg);
}
}
if (sigrcvd & (1 << Globals->Broker->ShutdownSigBit))
{
LogInfo("Received shut down from setting window");
StopSubProcesses();
run = false;
}
if (sigrcvd & SIGBREAKF_CTRL_C)
{
LogInfo("Received CTRL + C");
StopSubProcesses();
run = false;
shutdown = SHUTDOWN_REQUEST;
}
} while (run);
}
static void InitBroker(void)
{
Globals->Broker->Object = NULL;
Globals->Broker->ShutdownSigBit = -1;
Globals->Broker->Task = NULL;
Globals->Broker->BrokerPort = NULL;
Globals->Broker->UserPort = NULL;
Globals->Broker->ReplyPort = NULL;
if (shutdown == SHUTDOWN_REQUEST)
{
struct ShutdownInfo si;
si.BrokerPort = Ports.BrokerPort;
si.SynchronizerPort = Ports.SyncerPort;
si.SettingWindowPort = Ports.WindowPort;
si.ShutdownMessage = ATK_SHUTDOWN;
shutdown = SHUTTING_DOWN;
StartShutdown(&si);
}
} while (loop);
BrokerRunning = false;
LogTrace("Loop exited");
}
static void CleanupBroker(void)
{
if (Globals->Broker->Object != NULL)
struct ApplicationMesage *msg;
if (Broker.screenNotifyWB != NULL)
{
DeleteCxObjAll(Globals->Broker->Object);
Globals->Broker->Object = NULL;
LogTrace("ScreenNotify WB cleared");
while (!RemWorkbenchClient(Broker.screenNotifyWB))
{
Delay(10);
}
}
if (Globals->Broker->ShutdownSigBit != -1)
if (Broker.screenNotifyPub != NULL)
{
FreeSignal(Globals->Broker->ShutdownSigBit);
Globals->Broker->ShutdownSigBit = -1;
LogTrace("ScreenNotify PubScreen cleared");
while (!RemPubScreenClient(Broker.screenNotifyPub))
{
Delay(10);
}
}
if (Globals->Broker->BrokerPort != NULL)
CleanupNotifications();
if (Broker.Object != NULL)
{
DeleteMsgPort(Globals->Broker->BrokerPort);
Globals->Broker->BrokerPort = NULL;
DeleteCxObjAll(Broker.Object);
Broker.Object = NULL;
LogTrace("CxObj cleared");
}
if (Globals->Broker->UserPort != NULL)
{
DeleteMsgPort(Globals->Broker->UserPort);
Globals->Broker->UserPort = NULL;
}
CleanupMsgPort(&Broker.BrokerPort);
LogTrace("BrokerPort cleared");
if (Globals->Broker->ReplyPort != NULL)
CleanupMsgPort(&Broker.NotifyPort);
LogTrace("NotifyPort cleared");
CleanupMsgPort(&Broker.ScreenPort);
LogTrace("ScreenPort cleared");
CleanupVolMsgPort(&Ports.BrokerPort);
LogTrace("UserPort cleared");
while ((msg = (struct ApplicationMesage *)GetMsg(Ports.MemoryPort)))
{
DeleteMsgPort(Globals->Broker->ReplyPort);
Globals->Broker->ReplyPort = NULL;
FreeMemSafe(msg);
}
LogTrace("ReplyPort Msg cleared");
CleanupVolMsgPort(&Ports.MemoryPort);
LogTrace("ReplyPort cleared");
}
+7 -2
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2014-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2014-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,17 +21,22 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/
#ifndef COMPILER_H_INCLUDED
#define COMPILER_H_INCLUDED
#include <stddef.h>
#include <stdbool.h>
#ifndef __cplusplus
#ifndef bool
typedef int bool;
#define true 1
#define false 0
#endif
#endif
#ifdef __GNUC__
#ifndef REG
+22 -40
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -50,7 +50,6 @@
#include <proto/intuition.h>
#include <proto/battclock.h>
#include <proto/commodities.h>
#include <clib/graphics_protos.h>
#include <stdio.h>
#include <stdlib.h>
@@ -59,7 +58,7 @@
#include "compiler.h"
//#define DEBUG_BUILD 1
#define DEBUG_BUILD 1
#if defined(AROS) || defined(__CLIB2__)
#include <stdint.h>
@@ -75,15 +74,20 @@ typedef uint32_t uintptr_t;
#if defined(__CLIB2__)
#define __NO_NET_API
#define NO_INLINE_STDARG
//define NO_INLINE_STDARG
//#define MISSING_ADDRINFO
#include <proto/graphics.h>
#include <proto/socket.h>
#endif
#if defined(AROS) || defined(__CLIB2__)
#if defined(AROS)
#include <proto/graphics.h>
#include <proto/socket.h>
#include <bsdsocket/socketbasetags.h>
#endif
#if defined(__libnix__)
#include <clib/graphics_protos.h>
#include <amitcp/socketbasetags.h>
#include "clib/amitcp_protos.h"
#endif
@@ -100,6 +104,9 @@ typedef uint32_t uintptr_t;
#include <netinet/in.h>
#endif
#include "clib/screennotify.h"
#include "proto/screennotify.h"
#ifdef MAXPATHLEN
#undef MAXPATHLEN
#endif
@@ -113,7 +120,7 @@ typedef uint32_t uintptr_t;
#define MAXFILELEN 256
#define MAXFILEPATHLEN MAXPATHLEN + MAXFILELEN
#define MAXDOSERRORLEN 256
#define SETTINGMESSAGELEN 128
#define LOGMESSAGELEN 128
#ifndef HAVE_POLL
#define POLLIN 0x0001
@@ -142,24 +149,23 @@ int poll(struct pollfd *, nfds_t, int);
#define COM_ERROR -1
#ifdef AROS
#define APP_SHORT_NAME "ArosTimeKeeper"
#define APP_SHORT_NAME "TimeKeeper"
#define APP_LONG_NAME "AROS Time Keeper"
#else
#define APP_SHORT_NAME "AmiTimeKeeper"
#define APP_SHORT_NAME "TimeKeeper"
#define APP_LONG_NAME "Amiga Time Keeper"
#endif
#define APP_VERSION "1.09"
#define APP_DATE_VERSION "1.09 (14.07.2019)"
#define APP_VERSION "1.10"
#define APP_DATE_VERSION "1.10 (20.03.2020)"
#define APP_ID APP_SHORT_NAME " " APP_DATE_VERSION
#define APP_TITLE APP_LONG_NAME " " APP_DATE_VERSION
#define APP_TITLE_VERSION APP_LONG_NAME " " APP_VERSION
#include "log.h"
#include "state.h"
#include "string.h"
#define KEYWORD_COUNT 12
#define KEYWORD_COUNT 10
#define KEYWORD_SERVER "SERVER"
#define KEYWORD_PORT "PORT"
#define KEYWORD_THRESHOLD "THRESHOLD"
@@ -170,8 +176,6 @@ int poll(struct pollfd *, nfds_t, int);
#define KEYWORD_READONLY "READONLY"
#define KEYWORD_EXPERT "EXPERT"
#define KEYWORD_TIMEOUT "TIMEOUT"
#define KEYWORD_VERBOSE "VERBOSE"
#define KEYWORD_LOGFILE "LOGFILE"
#define SERVER_DEF "pool.ntp.org"
#define PORT_DEF "123"
@@ -187,47 +191,25 @@ int poll(struct pollfd *, nfds_t, int);
#define TIMEOUT_MIN 100
#define TIMEOUT_DEF 5000
#define TIMEOUT_MAX 30000
#define VERBOSE_MIN 0
#define VERBOSE_DEF 0
#define VERBOSE_MAX 3
#define LOGFILE_DEF NULL
#define POPKEY_DEF "lshift control t"
#define POPUP_DEF 0
#define KEYWORD_TEMPLATE_1 KEYWORD_READONLY "/S," KEYWORD_EXPERT "/S," KEYWORD_SERVER "/K," KEYWORD_PORT "/K," KEYWORD_TIMEOUT "/N/K,"
#define KEYWORD_TEMPLATE_2 KEYWORD_THRESHOLD "/K," KEYWORD_INTERVAL "/N/K," KEYWORD_VERBOSE "/N/K,"
#define KEYWORD_TEMPLATE_3 KEYWORD_PRIORITY "/N/K," KEYWORD_POPKEY "/K," KEYWORD_POPUP "/K," KEYWORD_LOGFILE "/K"
#define KEYWORD_TEMPLATE_2 KEYWORD_THRESHOLD "/K," KEYWORD_INTERVAL "/N/K,"
#define KEYWORD_TEMPLATE_3 KEYWORD_PRIORITY "/N/K," KEYWORD_POPKEY "/K," KEYWORD_POPUP "/K,"
#define KEYWORD_TEMPLATE KEYWORD_TEMPLATE_1 KEYWORD_TEMPLATE_2 KEYWORD_TEMPLATE_3
/* broker.c */
void StartBroker(void);
bool IsBrokerRunning(void);
void SetBrokerPriority(int);
void ShutdownBroker(void);
/* com.c */
void StartCom(void);
void StopComAsync(void);
void RestartSntpAsync(void);
bool CheckComClosed(void);
/* win_main.c */
void ShowSettingWindow(void);
void HideSettingWindow(void);
/* libraries.c */
int OpenLibraries(void);
void CloseLibraries(void);
void ReopenLocale(void);
/* val.c */
void SanitizeSettings(void);
/* net.c */
int OpenSocketLibrary(void);
void CloseSocketLibrary(void);
const char *GetErrorText(void);
const char *GetHostErrorText(void);
int GetErrorNo(void);
int GetHostErrorNo(void);
extern struct Library *SocketBase;
#endif
BIN
View File
Binary file not shown.
+1686
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+935
View File
@@ -0,0 +1,935 @@
Archive member included to satisfy reference by file (symbol)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_dosbase.o)
logger.o (DOSBase)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
/opt/amiga/m68k-amigaos/clib2/lib/ncrt0.o (_main)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_osliberror.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (__minimum_os_lib_error)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_oslibversion.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (__minimum_os_lib_version)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_priority.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (__priority)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_process_name.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (__process_name)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_setjmp.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (setjmp)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_set_process_window.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (__set_process_window)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_showerror.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (__show_error)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_stacksize.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (__stack_size)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (__argv)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_swapstack.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (__swap_stack_and_call)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_sysbase.o)
logger.o (SysBase)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_utilitybase.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (__UtilityBase)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_udivsi3.o)
string.o (__udivsi3)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_udivsi4.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_udivsi3.o) (__udivsi4)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_umodsi3.o)
string.o (__umodsi3)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(string_memmove.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o) (memmove)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(string_strlen.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o) (strlen)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_data.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (__check_abort_enabled)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flush_all_files.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (__flush_all_files)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flushiobwritebuffer.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flush_all_files.o) (__flush_iob_write_buffer)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flush_all_files.o) (__iob)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (__WBenchMsg)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_iobhookentry.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o) (__iob_hook_entry)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_nostdio.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (__no_standard_io)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_checkdetach.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (__check_detach)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_constructor_begin.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (_init)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_destructor.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_constructor_begin.o) (__DTOR_LIST__)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_detach.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (__detach)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_disablerequesters.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (__disable_dos_requesters)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_exit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (exit)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_free.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o) (free)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_getdefstacksize.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (__get_default_stack_size)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_isresident.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o) (__is_resident)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o) (malloc)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_program_name.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o) (__program_name)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_set_errno.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flushiobwritebuffer.o) (__set_errno)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_shell_escape.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o) (__shell_escape_character)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o) (__slab_allocate)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab_max_size.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o) (__slab_max_size)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab_purge_threshold.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab.o) (__slab_purge_threshold)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_stdio_window_spec.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o) (__stdio_window_specification)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_threshold.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o) (__free_memory_threshold)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(string_memset.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab.o) (memset)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(string_strcat.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o) (strcat)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(string_strcpy.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o) (strcpy)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(unistd_chdir_exit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o) (__original_current_directory)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(errno_data.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o) (errno)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(fcntl_close.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o) (close)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_checkabort.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flushiobwritebuffer.o) (__check_abort)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_mask.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_checkabort.o) (__break_signal_mask)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_raise.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_checkabort.o) (raise)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fclose.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o) (fclose)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fdhookentry.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o) (__fd_hook_entry)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_get_file_descriptor.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_iobhookentry.o) (__get_file_descriptor)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_growfdtable.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o) (__grow_fd_table)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_growiobtable.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o) (__grow_iob_table)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_initializefd.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o) (__initialize_fd)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_initializeiob.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o) (__initialize_iob)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_parent_of_fh.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fdhookentry.o) (__safe_parent_of_file_handle)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_remove_fd_alias.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fdhookentry.o) (__remove_fd_alias)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_translateioerror.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fdhookentry.o) (__translate_io_error_to_errno)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_abort.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_raise.o) (abort)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_alloca_cleanup.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_free.o) (__alloca_cleanup)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_atexit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_exit.o) (__exit_trap_trigger)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_constructor.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_constructor_begin.o) (__CTOR_LIST__)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_default_pool_size.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o) (__default_pool_size)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_default_puddle_size.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o) (__default_puddle_size)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_termination_message.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_raise.o) (__print_termination_message)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_examine_fh.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fdhookentry.o) (__safe_examine_file_handle)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputc.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_termination_message.o) (fputc)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputs.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_termination_message.o) (fputs)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_dropiobreadbuffer.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputc.o) (__drop_iob_read_buffer)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flush.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputs.o) (__flush)
/opt/amiga/m68k-amigaos/clib2/lib/libamiga.a(amiga_newlist.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o) (NewList)
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a(_udivdi3.o)
string.o (__udivdi3)
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a(_umoddi3.o)
string.o (__umoddi3)
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a(_clz.o)
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a(_udivdi3.o) (__clz_tab)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_mulsi3.o)
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a(_udivdi3.o) (__mulsi3)
Set Symbol
___EXIT_LIST__ /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o):stdio_init_exit.o:(.text+0x88)
___EXIT_LIST__ ** ABS **
___EXIT_LIST__ /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o):stdio_file_init.o:(.text+0x0)
___EXIT_LIST__ ** ABS **
___EXIT_LIST__ /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o):stdlib_malloc.o:(.text+0x162)
___EXIT_LIST__ ** ABS **
___EXIT_LIST__ /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_program_name.o):stdlib_program_name.o:(.text+0x0)
___EXIT_LIST__ ** ABS **
___EXIT_LIST__ /opt/amiga/m68k-amigaos/clib2/lib/libc.a(unistd_chdir_exit.o):unistd_chdir_exit.o:(.text+0x0)
___EXIT_LIST__ ** ABS **
___INIT_LIST__ /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o):stdlib_arg.o:(.text+0x26)
___INIT_LIST__ ** ABS **
___INIT_LIST__ /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o):stdio_init_exit.o:(.text+0x8e)
___INIT_LIST__ ** ABS **
___INIT_LIST__ /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o):stdio_file_init.o:(.text+0x9c)
___INIT_LIST__ ** ABS **
___INIT_LIST__ /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o):stdlib_malloc.o:(.text+0x1dc)
___INIT_LIST__ ** ABS **
___INIT_LIST__ /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_program_name.o):stdlib_program_name.o:(.text+0x28)
___INIT_LIST__ ** ABS **
Memory Configuration
Name Origin Length Attributes
*default* 0x0000000000000000 0xffffffffffffffff
Linker script and memory map
LOAD /opt/amiga/m68k-amigaos/clib2/lib/ncrt0.o
LOAD logger.o
LOAD string.o
START GROUP
LOAD /opt/amiga/m68k-amigaos/clib2/lib/libc.a
LOAD /opt/amiga/m68k-amigaos/clib2/lib/libdebug.a
LOAD /opt/amiga/m68k-amigaos/clib2/lib/libamiga.a
LOAD /opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a
END GROUP
[!provide] PROVIDE (___machtype = 0x0)
0x0000000000000000 . = 0x0
.text 0x0000000000000000 0x47c8
0x0000000000000000 __stext = .
*(.text)
.text 0x0000000000000000 0x14 /opt/amiga/m68k-amigaos/clib2/lib/ncrt0.o
0x0000000000000006 geta4
0x0000000000000006 __restore_a4
0x0000000000000008 __get_a4
0x000000000000000c __set_a4
.text 0x0000000000000014 0x48c logger.o
0x0000000000000074 main
.text 0x00000000000004a0 0x800 string.o
0x00000000000004b0 StrLen
0x00000000000004e6 StrCopy
0x000000000000052e AppendText
0x0000000000000580 TrimRight
0x000000000000060c StrChr
0x0000000000000656 StrRChr
0x00000000000006a6 StartsWith
0x0000000000000702 EndsWith
0x000000000000078c LongToStr
0x0000000000000888 LongLongToStr
0x00000000000009ce StrToLongLong
0x0000000000000ad6 TryParseLong
0x0000000000000b32 TryParseLongLong
0x0000000000000be4 VSNPrintf
0x0000000000000c6a SNPrintf
.text 0x0000000000000ca0 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_dosbase.o)
.text 0x0000000000000ca0 0x58c /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
0x0000000000000e22 _main
.text 0x000000000000122c 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_osliberror.o)
.text 0x000000000000122c 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_oslibversion.o)
.text 0x000000000000122c 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_priority.o)
.text 0x000000000000122c 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_process_name.o)
.text 0x000000000000122c 0x40 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_setjmp.o)
0x000000000000122c setjmp
0x0000000000001248 longjmp
.text 0x000000000000126c 0x20 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_set_process_window.o)
0x000000000000126c __set_process_window
.text 0x000000000000128c 0x1c4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_showerror.o)
0x00000000000012b8 __show_error
.text 0x0000000000001450 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_stacksize.o)
.text 0x0000000000001450 0x284 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o)
0x0000000000001476 __ctor_arg_init
.text 0x00000000000016d4 0x2c /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_swapstack.o)
0x00000000000016d4 __swap_stack_and_call
.text 0x0000000000001700 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_sysbase.o)
.text 0x0000000000001700 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_utilitybase.o)
.text 0x0000000000001700 0xc /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_udivsi3.o)
0x0000000000001700 __udivsi3
.text 0x000000000000170c 0xc /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_udivsi4.o)
0x000000000000170c __udivsi4
.text 0x0000000000001718 0x10 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_umodsi3.o)
0x0000000000001718 __umodsi3
.text 0x0000000000001728 0x258 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(string_memmove.o)
0x0000000000001728 memmove
.text 0x0000000000001980 0x14 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(string_strlen.o)
0x0000000000001980 strlen
.text 0x0000000000001994 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_data.o)
.text 0x0000000000001994 0x7c /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flush_all_files.o)
0x0000000000001994 __flush_all_files
.text 0x0000000000001a10 0x80 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flushiobwritebuffer.o)
0x0000000000001a10 __flush_iob_write_buffer
.text 0x0000000000001a90 0xbc /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
0x0000000000001a90 __close_all_files
0x0000000000001b18 __dtor_stdio_exit
0x0000000000001b1e __ctor_stdio_init
.text 0x0000000000001b4c 0x458 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
0x0000000000001b4c __dtor_workbench_exit
0x0000000000001be8 __ctor_stdio_file_init
.text 0x0000000000001fa4 0x5c /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_iobhookentry.o)
0x0000000000001fa4 __iob_hook_entry
.text 0x0000000000002000 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_nostdio.o)
.text 0x0000000000002000 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_checkdetach.o)
.text 0x0000000000002000 0x160 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_constructor_begin.o)
0x000000000000204e _init
0x00000000000020d4 _fini
.text 0x0000000000002160 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_destructor.o)
.text 0x0000000000002160 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_detach.o)
.text 0x0000000000002160 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_disablerequesters.o)
.text 0x0000000000002160 0x50 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_exit.o)
0x0000000000002160 _exit
0x0000000000002182 _Exit
0x0000000000002196 exit
.text 0x00000000000021b0 0xd0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_free.o)
0x00000000000021b0 __find_memory_node
0x0000000000002224 __free_memory_node
0x000000000000222e __free_memory
0x0000000000002252 free
.text 0x0000000000002280 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_getdefstacksize.o)
.text 0x0000000000002280 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_isresident.o)
.text 0x0000000000002280 0x230 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
0x0000000000002280 __allocate_memory
0x00000000000023bc malloc
0x00000000000023e2 __dtor_stdlib_memory_exit
0x000000000000245c __ctor_stdlib_memory_init
.text 0x00000000000024b0 0x8c /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_program_name.o)
0x00000000000024b0 __dtor_stdlib_program_name_exit
0x00000000000024d8 __ctor_stdlib_program_name_init
.text 0x000000000000253c 0xc /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_set_errno.o)
0x000000000000253c __set_errno
.text 0x0000000000002548 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_shell_escape.o)
.text 0x0000000000002548 0x43c /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab.o)
0x0000000000002548 __slab_allocate
0x00000000000027b6 __slab_free
0x0000000000002888 __slab_init
0x0000000000002918 __slab_exit
.text 0x0000000000002984 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab_max_size.o)
.text 0x0000000000002984 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab_purge_threshold.o)
.text 0x0000000000002984 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_stdio_window_spec.o)
.text 0x0000000000002984 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_threshold.o)
.text 0x0000000000002984 0xf4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(string_memset.o)
0x0000000000002984 memset
.text 0x0000000000002a78 0x20 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(string_strcat.o)
0x0000000000002a78 strcat
.text 0x0000000000002a98 0x14 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(string_strcpy.o)
0x0000000000002a98 strcpy
.text 0x0000000000002aac 0x40 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(unistd_chdir_exit.o)
0x0000000000002aac __dtor___chdir_exit
.text 0x0000000000002aec 0x8 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(errno_data.o)
0x0000000000002aec __errno
.text 0x0000000000002af4 0x64 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(fcntl_close.o)
0x0000000000002af4 close
.text 0x0000000000002b58 0x3c /opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_checkabort.o)
0x0000000000002b58 __check_abort
.text 0x0000000000002b94 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_mask.o)
.text 0x0000000000002b94 0xc0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_raise.o)
0x0000000000002b94 raise
.text 0x0000000000002c54 0x104 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fclose.o)
0x0000000000002c54 fclose
.text 0x0000000000002d58 0x450 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fdhookentry.o)
0x0000000000002d58 __fd_hook_entry
.text 0x00000000000031a8 0x60 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_get_file_descriptor.o)
0x00000000000031ec __get_file_descriptor
0x00000000000031fa __get_file_descriptor_dont_resolve
.text 0x0000000000003208 0x114 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_growfdtable.o)
0x0000000000003208 __grow_fd_table
.text 0x000000000000331c 0x114 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_growiobtable.o)
0x000000000000331c __grow_iob_table
.text 0x0000000000003430 0x3c /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_initializefd.o)
0x0000000000003430 __initialize_fd
.text 0x000000000000346c 0x4c /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_initializeiob.o)
0x000000000000346c __initialize_iob
.text 0x00000000000034b8 0x34 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_parent_of_fh.o)
0x00000000000034b8 __safe_parent_of_file_handle
.text 0x00000000000034ec 0x74 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_remove_fd_alias.o)
0x00000000000034ec __remove_fd_alias
.text 0x0000000000003560 0x188 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_translateioerror.o)
0x0000000000003560 __translate_io_error_to_errno
0x0000000000003596 __translate_access_io_error_to_errno
.text 0x00000000000036e8 0x28 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_abort.o)
0x00000000000036e8 abort
.text 0x0000000000003710 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_alloca_cleanup.o)
.text 0x0000000000003710 0xe8 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_atexit.o)
0x0000000000003710 atexit
0x00000000000037ac __exit_trap_trigger
.text 0x00000000000037f8 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_constructor.o)
.text 0x00000000000037f8 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_default_pool_size.o)
.text 0x00000000000037f8 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_default_puddle_size.o)
.text 0x00000000000037f8 0x80 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_termination_message.o)
0x0000000000003816 __print_termination_message
.text 0x0000000000003878 0x40 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_examine_fh.o)
0x0000000000003878 __safe_examine_file_handle
.text 0x00000000000038b8 0x11c /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputc.o)
0x00000000000038b8 __fputc_check
0x000000000000391a __fputc
0x0000000000003990 fputc
.text 0x00000000000039d4 0xf4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputs.o)
0x00000000000039d4 fputs
.text 0x0000000000003ac8 0xa8 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_dropiobreadbuffer.o)
0x0000000000003ac8 __drop_iob_read_buffer
.text 0x0000000000003b70 0x44 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flush.o)
0x0000000000003b70 __flush
.text 0x0000000000003bb4 0x14 /opt/amiga/m68k-amigaos/clib2/lib/libamiga.a(amiga_newlist.o)
0x0000000000003bb4 NewList
.text 0x0000000000003bc8 0x5b0 /opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a(_udivdi3.o)
0x0000000000003bc8 __udivdi3
.text 0x0000000000004178 0x540 /opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a(_umoddi3.o)
0x0000000000004178 __umoddi3
.text 0x00000000000046b8 0x100 /opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a(_clz.o)
0x00000000000046b8 __clz_tab
.text 0x00000000000047b8 0x10 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_mulsi3.o)
0x00000000000047b8 __mulsi3
0x00000000000047c8 ___datadata_relocs = .
0x00000000000047c8 __etext = .
0x00000000000047c8 ___text_size = SIZEOF (.text)
0x00000000000047c8 . = ALIGN (0x0)
.data 0x00000000000047c8 0xd8
0x00000000000047c8 __sdata = .
CONSTRUCTORS
0x00000000000047c8 . = ALIGN (0x4)
0x00000000000047c8 ___EXIT_LIST__ = .
0x00000000000047c8 0x4 xLONG 0xa
0x00000000000047cc 0x4 RELOC RELOC32 .text+0x88
0x00000000000047d0 0x4 xLONG 0x7 *ABS*+0x7
0x00000000000047d4 0x4 RELOC RELOC32 .text+0x0
0x00000000000047d8 0x4 xLONG 0x6 *ABS*+0x6
0x00000000000047dc 0x4 RELOC RELOC32 .text+0x162
0x00000000000047e0 0x4 xLONG 0x9 *ABS*+0x9
0x00000000000047e4 0x4 RELOC RELOC32 .text+0x0
0x00000000000047e8 0x4 xLONG 0x9 *ABS*+0x9
0x00000000000047ec 0x4 RELOC RELOC32 .text+0x0
0x00000000000047f0 0x4 xLONG 0x2 *ABS*+0x2
0x00000000000047f4 0x4 xLONG 0x0
0x00000000000047f8 . = ALIGN (0x4)
0x00000000000047f8 ___INIT_LIST__ = .
0x00000000000047f8 0x4 xLONG 0xa
0x00000000000047fc 0x4 RELOC RELOC32 .text+0x26
0x0000000000004800 0x4 xLONG 0x3 *ABS*+0x3
0x0000000000004804 0x4 RELOC RELOC32 .text+0x8e
0x0000000000004808 0x4 xLONG 0x7 *ABS*+0x7
0x000000000000480c 0x4 RELOC RELOC32 .text+0x9c
0x0000000000004810 0x4 xLONG 0x6 *ABS*+0x6
0x0000000000004814 0x4 RELOC RELOC32 .text+0x1dc
0x0000000000004818 0x4 xLONG 0x9 *ABS*+0x9
0x000000000000481c 0x4 RELOC RELOC32 .text+0x28
0x0000000000004820 0x4 xLONG 0x9 *ABS*+0x9
0x0000000000004824 0x4 xLONG 0x0
*(.data)
.data 0x0000000000004828 0x8 logger.o
0x000000000000482c vers
.data 0x0000000000004830 0x4 string.o
.data 0x0000000000004834 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_priority.o)
0x0000000000004834 __priority
.data 0x0000000000004838 0x30 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_showerror.o)
.data 0x0000000000004868 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o)
.data 0x0000000000004868 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_data.o)
0x0000000000004868 __check_abort_enabled
.data 0x000000000000486c 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
.data 0x000000000000486c 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
0x000000000000486c __cache_line_size
.data 0x0000000000004870 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_exit.o)
0x0000000000004870 __exit_value
.data 0x0000000000004874 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
.data 0x0000000000004874 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_program_name.o)
.data 0x0000000000004874 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_shell_escape.o)
0x0000000000004874 __shell_escape_character
.data 0x0000000000004878 0x0 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(unistd_chdir_exit.o)
.data 0x0000000000004878 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(errno_data.o)
0x0000000000004878 _impure_ptr
.data 0x000000000000487c 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_mask.o)
0x000000000000487c __break_signal_mask
.data 0x0000000000004880 0x18 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_raise.o)
0x0000000000004880 __signal_handler_table
.data 0x0000000000004898 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_default_pool_size.o)
0x0000000000004898 __default_pool_size
.data 0x000000000000489c 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_default_puddle_size.o)
0x000000000000489c __default_puddle_size
0x000000000000c7c6 ___a4_init = 0x7ffe
0x00000000000048a0 __edata = .
0x00000000000000d8 ___data_size = SIZEOF (.data)
.bss 0x00000000000048a0 0x40c
0x00000000000048a0 __bss_start = .
*(.bss)
.bss 0x00000000000048a0 0x4 logger.o
.bss 0x00000000000048a4 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_dosbase.o)
0x00000000000048a4 DOSBase
.bss 0x00000000000048a8 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
0x00000000000048a8 __stack_overflow
.bss 0x00000000000048ac 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_osliberror.o)
0x00000000000048ac __minimum_os_lib_error
.bss 0x00000000000048b0 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_oslibversion.o)
0x00000000000048b0 __minimum_os_lib_version
.bss 0x00000000000048b4 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_process_name.o)
0x00000000000048b4 __process_name
.bss 0x00000000000048b8 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_stacksize.o)
0x00000000000048b8 __stack_size
.bss 0x00000000000048bc 0x8 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o)
0x00000000000048bc __argv
0x00000000000048c0 __argc
.bss 0x00000000000048c4 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_sysbase.o)
0x00000000000048c4 SysBase
.bss 0x00000000000048c8 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_utilitybase.o)
0x00000000000048c8 __UtilityBase
.bss 0x00000000000048cc 0x10 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
0x00000000000048cc __iob
0x00000000000048d0 __num_iob
0x00000000000048d4 __fd
0x00000000000048d8 __num_fd
.bss 0x00000000000048dc 0x1c /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
0x00000000000048dc __WBenchMsg
.bss 0x00000000000048f8 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_nostdio.o)
0x00000000000048f8 __no_standard_io
.bss 0x00000000000048fc 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_checkdetach.o)
0x00000000000048fc __check_detach
.bss 0x0000000000004900 0x8 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_constructor_begin.o)
.bss 0x0000000000004908 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_destructor.o)
0x0000000000004908 __DTOR_LIST__
.bss 0x000000000000490c 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_detach.o)
0x000000000000490c __detach
.bss 0x0000000000004910 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_disablerequesters.o)
0x0000000000004910 __disable_dos_requesters
.bss 0x0000000000004914 0xa4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_exit.o)
0x0000000000004914 __exit_jmp_buf
0x00000000000049b4 __exit_blocked
.bss 0x00000000000049b8 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_getdefstacksize.o)
0x00000000000049b8 __get_default_stack_size
.bss 0x00000000000049bc 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_isresident.o)
0x00000000000049bc __is_resident
.bss 0x00000000000049c0 0x20 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
0x00000000000049c0 __maximum_memory_allocated
0x00000000000049c4 __current_memory_allocated
0x00000000000049c8 __maximum_num_memory_chunks_allocated
0x00000000000049cc __current_num_memory_chunks_allocated
0x00000000000049d0 __memory_pool
0x00000000000049d4 __memory_list
.bss 0x00000000000049e0 0x8 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_program_name.o)
0x00000000000049e0 __program_name
.bss 0x00000000000049e8 0xf4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab.o)
0x00000000000049e8 __slab_data
.bss 0x0000000000004adc 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab_max_size.o)
0x0000000000004adc __slab_max_size
.bss 0x0000000000004ae0 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab_purge_threshold.o)
0x0000000000004ae0 __slab_purge_threshold
.bss 0x0000000000004ae4 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_stdio_window_spec.o)
0x0000000000004ae4 __stdio_window_specification
.bss 0x0000000000004ae8 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_threshold.o)
0x0000000000004ae8 __free_memory_threshold
.bss 0x0000000000004aec 0x8 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(unistd_chdir_exit.o)
0x0000000000004aec __original_current_directory
0x0000000000004af0 __current_directory_changed
0x0000000000004af2 __unlock_current_directory
.bss 0x0000000000004af4 0x10 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(errno_data.o)
0x0000000000004af4 errno
.bss 0x0000000000004b04 0x8 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_raise.o)
0x0000000000004b04 __signals_blocked
.bss 0x0000000000004b0c 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_alloca_cleanup.o)
0x0000000000004b0c __alloca_cleanup
.bss 0x0000000000004b10 0x194 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_atexit.o)
.bss 0x0000000000004ca4 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_constructor.o)
0x0000000000004ca4 __CTOR_LIST__
.bss 0x0000000000004ca8 0x4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_termination_message.o)
*(COMMON)
0x0000000000004cac __end = .
0x000000000000040c ___bss_size = SIZEOF (.bss)
.data_chip
*(.data_chip)
.bss_chip
*(.bss_chip)
OUTPUT(TimeLogger amiga)
.stab 0x0000000000000000 0xf0
.stab 0x0000000000000000 0x18 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o)
.stab 0x0000000000000018 0x30 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
.stab 0x0000000000000048 0x30 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
.stab 0x0000000000000078 0x30 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
.stab 0x00000000000000a8 0x30 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_program_name.o)
.stab 0x00000000000000d8 0x18 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(unistd_chdir_exit.o)
.stabstr 0x0000000000000000 0x140
.stabstr 0x0000000000000000 0x20 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o)
.stabstr 0x0000000000000020 0x40 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
.stabstr 0x0000000000000060 0x40 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
.stabstr 0x00000000000000a0 0x40 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
.stabstr 0x00000000000000e0 0x40 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_program_name.o)
.stabstr 0x0000000000000120 0x20 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(unistd_chdir_exit.o)
Cross Reference Table
Symbol File
AppendText string.o
DOSBase /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_dosbase.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_examine_fh.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_parent_of_fh.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fdhookentry.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fclose.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_raise.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(unistd_chdir_exit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_program_name.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
string.o
logger.o
EndsWith string.o
LVOStackSwap /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_swapstack.o)
LongLongToStr string.o
LongToStr string.o
NewList /opt/amiga/m68k-amigaos/clib2/lib/libamiga.a(amiga_newlist.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_atexit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
SNPrintf string.o
logger.o
StartsWith string.o
StrChr string.o
StrCopy string.o
StrLen string.o
StrRChr string.o
StrToLongLong string.o
SysBase /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_sysbase.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_atexit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_checkabort.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_program_name.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_free.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_swapstack.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_showerror.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_set_process_window.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
string.o
logger.o
TrimRight string.o
logger.o
TryParseLong string.o
TryParseLongLong string.o
VSNPrintf string.o
_Exit /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_exit.o)
__CTOR_LIST__ /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_constructor.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_constructor_begin.o)
__DTOR_LIST__ /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_destructor.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_constructor_begin.o)
__EXIT_LIST__ /opt/amiga/m68k-amigaos/clib2/lib/libc.a(unistd_chdir_exit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_program_name.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_constructor_begin.o)
__INIT_LIST__ /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_program_name.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_constructor_begin.o)
__UtilityBase /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_utilitybase.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_mulsi3.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_udivsi4.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__WBenchMsg /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_program_name.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_showerror.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__alloca_cleanup /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_alloca_cleanup.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_free.o)
__allocate_memory /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
__argc /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__argv /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__break_signal_mask /opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_mask.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_checkabort.o)
__cache_line_size /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
__check_abort /opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_checkabort.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flush.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_dropiobreadbuffer.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputs.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputc.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fclose.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(fcntl_close.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flushiobwritebuffer.o)
__check_abort_enabled /opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_data.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flush.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_dropiobreadbuffer.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputs.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputc.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_abort.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fclose.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_raise.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_checkabort.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(fcntl_close.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flushiobwritebuffer.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__check_detach /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_checkdetach.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__close_all_files /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
__clz_tab /opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a(_clz.o)
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a(_umoddi3.o)
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a(_udivdi3.o)
__ctor_arg_init /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o)
__ctor_stdio_file_init /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
__ctor_stdio_init /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
__ctor_stdlib_memory_init /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
__ctor_stdlib_program_name_init /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_program_name.o)
__current_directory_changed /opt/amiga/m68k-amigaos/clib2/lib/libc.a(unistd_chdir_exit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
__current_memory_allocated /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_free.o)
__current_num_memory_chunks_allocated /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_free.o)
__default_pool_size /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_default_pool_size.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
__default_puddle_size /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_default_puddle_size.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
__detach /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_detach.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__disable_dos_requesters /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_disablerequesters.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__drop_iob_read_buffer /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_dropiobreadbuffer.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputc.o)
__dtor___chdir_exit /opt/amiga/m68k-amigaos/clib2/lib/libc.a(unistd_chdir_exit.o)
__dtor_stdio_exit /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
__dtor_stdlib_memory_exit /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
__dtor_stdlib_program_name_exit /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_program_name.o)
__dtor_workbench_exit /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
__errno /opt/amiga/m68k-amigaos/clib2/lib/libc.a(errno_data.o)
__exit_blocked /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_exit.o)
__exit_jmp_buf /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_exit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__exit_trap_trigger /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_atexit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_exit.o)
__exit_value /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_exit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__fd /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_growfdtable.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_get_file_descriptor.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
__fd_hook_entry /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fdhookentry.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
__find_memory_node /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_free.o)
__flush /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flush.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputs.o)
__flush_all_files /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flush_all_files.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__flush_iob_write_buffer /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flushiobwritebuffer.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flush.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputs.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputc.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fclose.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flush_all_files.o)
__fputc /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputc.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputs.o)
__fputc_check /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputc.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputs.o)
__free_memory /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_free.o)
__free_memory_node /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_free.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
__free_memory_threshold /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_threshold.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
__get_a4 /opt/amiga/m68k-amigaos/clib2/lib/ncrt0.o
__get_default_stack_size /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_getdefstacksize.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__get_file_descriptor /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_get_file_descriptor.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_iobhookentry.o)
__get_file_descriptor_dont_resolve /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_get_file_descriptor.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(fcntl_close.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_iobhookentry.o)
__grow_fd_table /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_growfdtable.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
__grow_iob_table /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_growiobtable.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
__initialize_fd /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_initializefd.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
__initialize_iob /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_initializeiob.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
__iob /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_termination_message.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_growiobtable.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flush_all_files.o)
__iob_hook_entry /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_iobhookentry.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
__is_resident /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_isresident.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__maximum_memory_allocated /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
__maximum_num_memory_chunks_allocated /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
__memory_list /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
__memory_pool /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_free.o)
__minimum_os_lib_error /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_osliberror.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__minimum_os_lib_version /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_oslibversion.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__mulsi3 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_mulsi3.o)
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a(_umoddi3.o)
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a(_udivdi3.o)
__no_standard_io /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_nostdio.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_termination_message.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_showerror.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__num_fd /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_growfdtable.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_get_file_descriptor.o)
__num_iob /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_termination_message.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_growiobtable.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flush_all_files.o)
__original_current_directory /opt/amiga/m68k-amigaos/clib2/lib/libc.a(unistd_chdir_exit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
__print_termination_message /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_termination_message.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_abort.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_raise.o)
__priority /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_priority.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__process_name /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_process_name.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__program_name /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_program_name.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o)
__remove_fd_alias /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_remove_fd_alias.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fdhookentry.o)
__restore_a4 /opt/amiga/m68k-amigaos/clib2/lib/ncrt0.o
__safe_examine_file_handle /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_examine_fh.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fdhookentry.o)
__safe_parent_of_file_handle /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_parent_of_fh.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fdhookentry.o)
__set_a4 /opt/amiga/m68k-amigaos/clib2/lib/ncrt0.o
__set_errno /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_set_errno.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_dropiobreadbuffer.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputc.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_atexit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_growiobtable.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_growfdtable.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fclose.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_raise.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(fcntl_close.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_flushiobwritebuffer.o)
__set_process_window /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_set_process_window.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__shell_escape_character /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_shell_escape.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o)
__show_error /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_showerror.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__signal_handler_table /opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_raise.o)
__signals_blocked /opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_raise.o)
__slab_allocate /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
__slab_data /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_free.o)
__slab_exit /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
__slab_free /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_free.o)
__slab_init /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
__slab_max_size /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab_max_size.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
__slab_purge_threshold /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab_purge_threshold.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab.o)
__stack_overflow /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__stack_size /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_stacksize.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__stdio_window_specification /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_stdio_window_spec.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
__swap_stack_and_call /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_swapstack.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
__translate_access_io_error_to_errno /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_translateioerror.o)
__translate_io_error_to_errno /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_translateioerror.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fdhookentry.o)
__udivdi3 /opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a(_udivdi3.o)
string.o
__udivsi3 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_udivsi3.o)
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a(_umoddi3.o)
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a(_udivdi3.o)
string.o
__udivsi4 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_udivsi4.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_umodsi3.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_udivsi3.o)
__umoddi3 /opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a(_umoddi3.o)
string.o
__umodsi3 /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_umodsi3.o)
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a(_umoddi3.o)
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libgcc.a(_udivdi3.o)
string.o
__unlock_current_directory /opt/amiga/m68k-amigaos/clib2/lib/libc.a(unistd_chdir_exit.o)
_exit /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_exit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_abort.o)
_fini /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_constructor_begin.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
_impure_ptr /opt/amiga/m68k-amigaos/clib2/lib/libc.a(errno_data.o)
_init /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_constructor_begin.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
_main /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
/opt/amiga/m68k-amigaos/clib2/lib/ncrt0.o
abort /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_abort.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_raise.o)
atexit /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_atexit.o)
close /opt/amiga/m68k-amigaos/clib2/lib/libc.a(fcntl_close.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
errno /opt/amiga/m68k-amigaos/clib2/lib/libc.a(errno_data.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_set_errno.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
exit /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_exit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_program_name.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
fclose /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fclose.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_init_exit.o)
fputc /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputc.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_termination_message.o)
fputs /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fputs.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_termination_message.o)
free /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_free.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_growiobtable.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_growfdtable.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fclose.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
geta4 /opt/amiga/m68k-amigaos/clib2/lib/ncrt0.o
longjmp /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_setjmp.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_exit.o)
main logger.o
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
malloc /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_malloc.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_atexit.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_growiobtable.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_growfdtable.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o)
memmove /opt/amiga/m68k-amigaos/clib2/lib/libc.a(string_memmove.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o)
memset /opt/amiga/m68k-amigaos/clib2/lib/libc.a(string_memset.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_initializeiob.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_initializefd.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_growiobtable.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_growfdtable.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fdhookentry.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_fclose.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_slab.o)
raise /opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_raise.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_abort.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(signal_checkabort.o)
setjmp /opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_setjmp.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_main.o)
strcat /opt/amiga/m68k-amigaos/clib2/lib/libc.a(string_strcat.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
strcpy /opt/amiga/m68k-amigaos/clib2/lib/libc.a(string_strcpy.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
strlen /opt/amiga/m68k-amigaos/clib2/lib/libc.a(string_strlen.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdio_file_init.o)
/opt/amiga/m68k-amigaos/clib2/lib/libc.a(stdlib_arg.o)
vers logger.o
Vendored
+1
View File
@@ -0,0 +1 @@
SetEnv TZ CET-1CEST,M3.5.0/2,M10.5.0/3
+17
View File
@@ -0,0 +1,17 @@
##base _ScreenNotifyBase
##bias 30
*
* fd/screennotify_lib.fd
*
* Function definitions for screennotify.library
*
* $VER: screennotify_lib.fd 1.0 (26.03.95)
*
##public
AddCloseScreenClient(screen,port,pri)(a0,a1,d0)
RemCloseScreenClient(handle)(a0)
AddPubScreenClient(port,pri)(a0,d0)
RemPubScreenClient(handle)(a0)
AddWorkbenchClient(port,pri)(a0,d0)
RemWorkbenchClient(handle)(a0)
##end
+24
View File
@@ -0,0 +1,24 @@
* This SFD file was automatically generated by fd2sfd from
* fd/screennotify_lib.fd and
* include/clib/screennotify_protos.h.
==base _ScreenNotifyBase
==basetype struct Library *
==libname screennotify.library
==include <exec/types.h>
==include <utility/tagitem.h>
*
* fd/screennotify_lib.fd
*
* Function definitions for screennotify.library
*
* $VER: screennotify_lib.fd 1.0 (26.03.95)
*
==bias 30
==public
APTR AddCloseScreenClient(struct Screen * screen, struct MsgPort * port, BYTE pri) (a0,a1,d0)
BOOL RemCloseScreenClient(APTR handle) (a0)
APTR AddPubScreenClient(struct MsgPort * port, BYTE pri) (a0,d0)
BOOL RemPubScreenClient(APTR handle) (a0)
APTR AddWorkbenchClient(struct MsgPort * port, BYTE pri) (a0,d0)
BOOL RemWorkbenchClient(APTR handle) (a0)
==end
+24
View File
@@ -0,0 +1,24 @@
#ifndef CLIB_SCREENNOTIFY_H
#define CLIB_SCREENNOTIFY_H
/*
* clib/screennotify_protos.h
*
* ANSI C prototypes for screennotify.library functions
*
* $VER: screennotify_protos.h 1.0 (26.03.95)
*
*/
#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif
APTR AddCloseScreenClient(struct Screen *, struct MsgPort *, BYTE);
APTR AddPubScreenClient(struct MsgPort *, BYTE);
APTR AddWorkbenchClient(struct MsgPort *, BYTE);
BOOL RemCloseScreenClient(APTR);
BOOL RemPubScreenClient(APTR);
BOOL RemWorkbenchClient(APTR);
#endif
+36
View File
@@ -0,0 +1,36 @@
/*-
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "global.h"
#include "locale.h"
#include "log.h"
#include "mem.h"
struct AppLocale *AppLocale;
struct PosixTimezone *Timezone;
struct PosixTransitionTime *NextTransition;
volatile struct AppPorts Ports = { NULL, NULL, NULL, NULL };
+47
View File
@@ -0,0 +1,47 @@
/*-
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GLOBAL_H_INCLUDED
#define GLOBAL_H_INCLUDED
#include <exec/ports.h>
#include "locale.h"
struct AppPorts
{
struct MsgPort *BrokerPort;
struct MsgPort *SyncerPort;
struct MsgPort *WindowPort;
struct MsgPort *MemoryPort;
};
extern struct AppLocale *AppLocale;
extern struct PosixTimezone *Timezone;
extern struct PosixTransitionTime *NextTransition;
extern volatile struct AppPorts Ports;
extern struct Library *BattClockBase;
#endif
+47
View File
@@ -0,0 +1,47 @@
/* Automatically generated header (sfdc 1.11)! Do not edit! */
#ifndef CLIB_SCREENNOTIFY_PROTOS_H
#define CLIB_SCREENNOTIFY_PROTOS_H
/*
** $VER: screennotify_protos.h
**
** C prototypes. For use with 32 bit integers only.
**
** Copyright (c) 2001 Amiga, Inc.
** All Rights Reserved
*/
#include <exec/types.h>
#include <utility/tagitem.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* This SFD file was automatically generated by fd2sfd from */
/* fd/screennotify_lib.fd and */
/* include/clib/screennotify_protos.h. */
/*
fd/screennotify_lib.fd
*/
/*
Function definitions for screennotify.library
*/
/*
$VER: screennotify_lib.fd 1.0 (26.03.95)
*/
APTR AddCloseScreenClient(struct Screen * screen, struct MsgPort * port, BYTE pri);
BOOL RemCloseScreenClient(APTR handle);
APTR AddPubScreenClient(struct MsgPort * port, BYTE pri);
BOOL RemPubScreenClient(APTR handle);
APTR AddWorkbenchClient(struct MsgPort * port, BYTE pri);
BOOL RemWorkbenchClient(APTR handle);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* CLIB_SCREENNOTIFY_PROTOS_H */
+47
View File
@@ -0,0 +1,47 @@
/* Automatically generated header (sfdc 1.11)! Do not edit! */
#ifndef _INLINE_SCREENNOTIFY_H
#define _INLINE_SCREENNOTIFY_H
#ifndef _SFDC_VARARG_DEFINED
#define _SFDC_VARARG_DEFINED
#ifdef __HAVE_IPTR_ATTR__
typedef APTR _sfdc_vararg __attribute__((iptr));
#else
typedef ULONG _sfdc_vararg;
#endif /* __HAVE_IPTR_ATTR__ */
#endif /* _SFDC_VARARG_DEFINED */
#ifndef __INLINE_MACROS_H
#include <inline/macros.h>
#endif /* !__INLINE_MACROS_H */
#ifndef SCREENNOTIFY_BASE_NAME
#define SCREENNOTIFY_BASE_NAME ScreenNotifyBase
#endif /* !SCREENNOTIFY_BASE_NAME */
#define AddCloseScreenClient(___screen, ___port, ___pri) \
LP3(0x1e, APTR, AddCloseScreenClient , struct Screen *, ___screen, a0, struct MsgPort *, ___port, a1, BYTE, ___pri, d0,\
, SCREENNOTIFY_BASE_NAME)
#define RemCloseScreenClient(___handle) \
LP1(0x24, BOOL, RemCloseScreenClient , APTR, ___handle, a0,\
, SCREENNOTIFY_BASE_NAME)
#define AddPubScreenClient(___port, ___pri) \
LP2(0x2a, APTR, AddPubScreenClient , struct MsgPort *, ___port, a0, BYTE, ___pri, d0,\
, SCREENNOTIFY_BASE_NAME)
#define RemPubScreenClient(___handle) \
LP1(0x30, BOOL, RemPubScreenClient , APTR, ___handle, a0,\
, SCREENNOTIFY_BASE_NAME)
#define AddWorkbenchClient(___port, ___pri) \
LP2(0x36, APTR, AddWorkbenchClient , struct MsgPort *, ___port, a0, BYTE, ___pri, d0,\
, SCREENNOTIFY_BASE_NAME)
#define RemWorkbenchClient(___handle) \
LP1(0x3c, BOOL, RemWorkbenchClient , APTR, ___handle, a0,\
, SCREENNOTIFY_BASE_NAME)
#endif /* !_INLINE_SCREENNOTIFY_H */
+41
View File
@@ -0,0 +1,41 @@
#ifndef LIBRARIES_SCREENNOTIFY_H
#define LIBRARIES_SCREENNOTIFY_H
/*
* libraries/screennotify_protos.h
*
* Include file for screennotify.library
*
* $VER: screennotify.h 1.0 (26.03.95)
*
*/
#ifndef EXEC_PORTS_H
#include <exec/ports.h>
#endif
/* Name and version */
#define SCREENNOTIFY_NAME "screennotify.library"
#define SCREENNOTIFY_VERSION 1
/* Message sent to clients */
struct ScreenNotifyMessage {
struct Message snm_Message;
ULONG snm_Type; /* READ ONLY!! */
APTR snm_Value; /* READ ONLY!! */
};
/* Values for snm_Type */
#define SCREENNOTIFY_TYPE_CLOSESCREEN 0 /* CloseScreen() called, snm_Value contains */
/* pointer to Screen structure */
#define SCREENNOTIFY_TYPE_PUBLICSCREEN 1 /* PubScreenStatus() called to make screen */
/* public, snm_Value contains pointer to */
/* PubScreenNode structure */
#define SCREENNOTIFY_TYPE_PRIVATESCREEN 2 /* PubScreenStatus() called to make screen */
/* private, snm_Value contains pointer to */
/* PubScreenNode structure */
#define SCREENNOTIFY_TYPE_WORKBENCH 3 /* snm_Value == FALSE (0): CloseWorkBench() */
/* called, please close windows on WB */
/* snm_Value == TRUE (1): OpenWorkBench() */
/* called, windows can be opened again */
#endif
+34
View File
@@ -0,0 +1,34 @@
/* Automatically generated header (sfdc 1.11)! Do not edit! */
#ifndef PROTO_SCREENNOTIFY_H
#define PROTO_SCREENNOTIFY_H
#include <clib/screennotify.h>
#ifndef _NO_INLINE
# if defined(__GNUC__)
# ifdef __AROS__
# include <defines/screennotify.h>
# else
# include <inline/screennotify.h>
# endif
# else
# include <pragmas/screennotify_pragmas.h>
# endif
#endif /* _NO_INLINE */
#ifdef __amigaos4__
# include <interfaces/screennotify.h>
# ifndef __NOGLOBALIFACE__
extern struct ScreenNotifyIFace *IScreenNotify;
# endif /* __NOGLOBALIFACE__*/
#endif /* !__amigaos4__ */
#ifndef __NOLIBBASE__
extern struct Library *
# ifdef __CONSTLIBBASEDECL__
__CONSTLIBBASEDECL__
# endif /* __CONSTLIBBASEDECL__ */
ScreenNotifyBase;
#endif /* !__NOLIBBASE__ */
#endif /* !PROTO_SCREENNOTIFY_H */
+213 -227
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,108 +25,124 @@
*/
#include "config.h"
#include "time.h"
#include "global.h"
#include "timer.h"
#include "ptz.h"
#include "mem.h"
/* Library identifiers */
static const char *dosName = "dos.library";
static const char *aslName = "asl.library";
static const char *gfxName = "graphics.library";
static const char *iconName = "icon.library";
static const char *commoditiesName = "commodities.library";
static const char *localeName = "locale.library";
static const char *utilityName = "utility.library";
static const char *gadgetName = "gadtools.library";
static const char *intuitionName = "intuition.library";
static const char *mathName = "mathieeedoubbas.library";
#include <graphics/gfxbase.h>
#include <libraries/dos.h>
#include <libraries/commodities.h>
#include <intuition/intuitionbase.h>
#include <graphics/gfxbase.h>
#include <utility/utility.h>
#include <workbench/icon.h>
#include <resources/battclock.h>
#if !defined(LIB_HOST)
/* Use fake bases */
#define DOSBase __FX_DOSBase
#define LocaleBase __FX_LocaleBase
#define UtilityBase __FX_UtilityBase
#define IntuitionBase __FX_IntuitionBase
#define CxBase __FX_CxBase
#define GfxBase __FX_GfxBase
#define AslBase __FX_AslBase
#define IconBase __FX_IconBase
#define GadToolsBase __FX_GadToolsBase
#define __MathIeeeDoubBasBase __FX__MathIeeeDoubBasBase
#define __UtilityBase __FX__UtilityBase
#include "libraries/screennotify.h"
#include "logmod.h"
#define MODULENAME "Library"
/* Library and resource identifiers */
#ifndef DOSNAME
#define DOSNAME "dos.library"
#endif
#ifndef UTILITYNAME
#define UTILITYNAME "utility.library"
#endif
#ifndef COMMODITIESNAME
#define COMMODITIESNAME "commodities.library"
#endif
#ifndef INTUITIONNAME
#define INTUITIONNAME "intuition.library"
#endif
#ifndef GADTOOLSNAME
#define GADTOOLSNAME "gadtools.library"
#endif
#ifndef ICONNAME
#define ICONNAME "icon.library"
#endif
#ifndef GRAPHICSNAME
#define GRAPHICSNAME "graphics.library"
#endif
#ifndef LOCALENAME
#define LOCALENAME "locale.library"
#endif
#ifndef BATTCLOCKNAME
#define BATTCLOCKNAME "battclock.resource"
#endif
#ifndef TIMERNAME
#define TIMERNAME "timer.device"
#endif
#ifndef LIBREV
#define LIBREV 38L
#endif
/* Library addresses */
//struct ExecBase *SysBase = (struct ExecBase *)4L;
struct DosLibrary *DOSBase = NULL;
struct LocaleBase *LocaleBase = NULL;
#ifndef CURRENTLOCALE
#define CURRENTLOCALE "Current Locale Info"
#endif
#ifndef NORTCCLOCK
#define NORTCCLOCK "No RTC found"
#endif
struct DosLibrary *DOSBase2 = NULL;
struct UtilityBase *UtilityBase = NULL;
struct IntuitionBase *IntuitionBase = NULL;
struct Library *CxBase = NULL;
struct Library *GfxBase = NULL;
struct Library *AslBase = NULL;
struct Library *IconBase = NULL;
struct IntuitionBase *IntuitionBase = NULL;
struct Library *GadToolsBase = NULL;
struct Library *__MathIeeeDoubBasBase = NULL;
struct UtilityBase *__UtilityBase = NULL;
#define DOSLIB_NAME ((STRPTR)dosName)
#define DOSLIB_REV 36L
#define ASLLIB_NAME ((STRPTR)aslName)
#define ASLLIB_REV 37L
#define GFXLIB_NAME ((STRPTR)gfxName)
#define GFXLIB_REV 37L
#define ICONLIB_NAME ((STRPTR)iconName)
#define ICONLIB_REV 36L
#define COMMODLIB_NAME ((STRPTR)commoditiesName)
#define COMMODLIB_REV 37L
#define INTUITIONLIB_NAME ((STRPTR)intuitionName)
#define INTUITIONLIB_REV 37L
#define LOCALELIB_NAME ((STRPTR)localeName)
#define LOCALELIB_REV 37L
#define UTILLIB_NAME ((STRPTR)utilityName)
#define UTILLIB_REV 37L
#define GADGETLIB_NAME ((STRPTR)gadgetName)
#define GADGETLIB_REV 37L
#define MATHLIB_NAME ((STRPTR)mathName)
#define MATHLIB_REV 34L
// RTC Clock
static const char *batteryClockName = "battclock.resource";
#define BATTCLOCK_NAME ((STRPTR)batteryClockName)
struct Library *IconBase = NULL;
struct GfxBase *GfxBase = NULL;
struct LocaleBase *LocaleBase = NULL;
struct Library *ScreenNotifyBase = NULL;
struct Library *BattClockBase = NULL;
struct Device *TimerDevice = NULL;
static struct Device *TimerDevice = NULL;
static const char *currentLocale = "Current Locale";
static void OpenLibrarySuccess(STRPTR name)
static void OpenLibrarySuccess(char *name, char *ident)
{
LogTrace("Opened %s", name);
if (ident == NULL)
{
LogDebug("Opened %s", name);
}
else
{
LogDebug("Opened %s", ident);
}
}
static void OpenLibraryError(STRPTR name, long version)
static void OpenLibraryError(char *name, long version)
{
LogError("Cannot open %s %ld.0", name, version);
char message[64];
SNPrintf(message, 63, "Cannot open %s %ld.0", name, version);
Printf((STRPTR)message);
LogError(message);
}
static void ClosingLibrary(STRPTR name)
static void ClosingLibrary(char *name, char *ident)
{
LogTrace("Closing %s", name);
if (ident == NULL)
{
LogDebug("Closing %s", name);
}
else
{
LogDebug("Closing %s", ident);
}
}
static void OpenResourceSuccess(const char *name)
static void OpenResourceSuccess(char *name)
{
LogTrace("Opened %s", name);
LogDebug("Opened %s", name);
}
static void OpenResourceError(const char *name)
static void OpenResourceError(char *name)
{
LogError("Cannot open %s", name);
}
static void ClosingResource(const char *name)
static void ClosingResource(char *name)
{
LogTrace("Closing %s", name);
LogDebug("Closing %s", name);
}
int OpenLibraries(void)
@@ -134,123 +150,76 @@ int OpenLibraries(void)
LogInfo("Starting up");
// DOS Library
if (!(DOSBase = (struct DosLibrary *)OpenLibrary((STRPTR)DOSLIB_NAME, DOSLIB_REV)))
if (!(DOSBase2 = (struct DosLibrary *)OpenLibrary((STRPTR)DOSNAME, LIBREV)))
{
OpenLibraryError(DOSLIB_NAME, DOSLIB_REV);
OpenLibraryError(DOSNAME, LIBREV);
return LIB_ERROR;
}
#ifdef AOS3
// Library does not always provide IdString
OpenResourceSuccess(DOSLIB_NAME);
#else
OpenLibrarySuccess(((struct Library *)DOSBase)->lib_IdString);
#endif
// Math Library
if (!(__MathIeeeDoubBasBase = OpenLibrary((STRPTR)MATHLIB_NAME, MATHLIB_REV)))
{
OpenLibraryError(MATHLIB_NAME, MATHLIB_REV);
return LIB_ERROR;
}
#ifdef AOS3
// Library does not always provide IdString
OpenResourceSuccess(MATHLIB_NAME);
#else
OpenLibrarySuccess(((struct Library *)__MathIeeeDoubBasBase)->lib_IdString);
#endif
// Commodities Library
if (!(CxBase = OpenLibrary((STRPTR)COMMODLIB_NAME, COMMODLIB_REV)))
{
OpenLibraryError(COMMODLIB_NAME, COMMODLIB_REV);
return LIB_ERROR;
}
OpenLibrarySuccess(CxBase->lib_IdString);
// Intuition Library
if (!(IntuitionBase = (struct IntuitionBase *)OpenLibrary((STRPTR)INTUITIONLIB_NAME, INTUITIONLIB_REV)))
{
OpenLibraryError(INTUITIONLIB_NAME, INTUITIONLIB_REV);
return LIB_ERROR;
}
OpenLibrarySuccess(((struct Library *)IntuitionBase)->lib_IdString);
// Icon Library
if (!(IconBase = OpenLibrary((STRPTR)ICONLIB_NAME, ICONLIB_REV)))
{
OpenLibraryError(ICONLIB_NAME, ICONLIB_REV);
return LIB_ERROR;
}
OpenLibrarySuccess(IconBase->lib_IdString);
// Icon Library
if (!(AslBase = OpenLibrary((STRPTR)ASLLIB_NAME, ASLLIB_REV)))
{
OpenLibraryError(ASLLIB_NAME, ASLLIB_REV);
return LIB_ERROR;
}
OpenLibrarySuccess(AslBase->lib_IdString);
// Locale Library
if (!(LocaleBase = (struct LocaleBase *)OpenLibrary((STRPTR)LOCALELIB_NAME, LOCALELIB_REV)))
{
OpenLibraryError(LOCALELIB_NAME, LOCALELIB_REV);
return LIB_ERROR;
}
OpenLibrarySuccess(((struct Library *)LocaleBase)->lib_IdString);
OpenLibrarySuccess(DOSNAME, DOSBase2->dl_lib.lib_IdString);
// Utility Library
if (!(UtilityBase = (struct UtilityBase *)OpenLibrary((STRPTR)UTILLIB_NAME, UTILLIB_REV)))
if (!(UtilityBase = (struct UtilityBase *)OpenLibrary((STRPTR)UTILITYNAME, LIBREV)))
{
OpenLibraryError(UTILLIB_NAME, UTILLIB_REV);
OpenLibraryError(UTILITYNAME, LIBREV);
return LIB_ERROR;
}
OpenLibrarySuccess(UTILITYNAME, UtilityBase->ub_LibNode.lib_IdString);
__UtilityBase = UtilityBase;
OpenLibrarySuccess(((struct Library *)UtilityBase)->lib_IdString);
// Commodity Library
if (!(CxBase = OpenLibrary((STRPTR)COMMODITIESNAME, LIBREV)))
{
OpenLibraryError(COMMODITIESNAME, LIBREV);
return LIB_ERROR;
}
OpenLibrarySuccess(COMMODITIESNAME, CxBase->lib_IdString);
// Intuition Library
if (!(IntuitionBase = (struct IntuitionBase *)OpenLibrary((STRPTR)INTUITIONNAME, LIBREV)))
{
OpenLibraryError(INTUITIONNAME, LIBREV);
return LIB_ERROR;
}
OpenLibrarySuccess(INTUITIONNAME, IntuitionBase->LibNode.lib_IdString);
// Gadget Library
if (!(GadToolsBase = OpenLibrary((STRPTR)GADGETLIB_NAME, GADGETLIB_REV)))
if (!(GadToolsBase = OpenLibrary((STRPTR)GADTOOLSNAME, LIBREV)))
{
OpenLibraryError(GADGETLIB_NAME, GADGETLIB_REV);
OpenLibraryError(GADTOOLSNAME, LIBREV);
return LIB_ERROR;
}
OpenLibrarySuccess(GADTOOLSNAME, GadToolsBase->lib_IdString);
OpenLibrarySuccess(GadToolsBase->lib_IdString);
// Icon Library
if (!(IconBase = OpenLibrary((STRPTR)ICONNAME, LIBREV)))
{
OpenLibraryError(ICONNAME, LIBREV);
return LIB_ERROR;
}
OpenLibrarySuccess(ICONNAME, IconBase->lib_IdString);
// Graphics Library
if (!(GfxBase = OpenLibrary((STRPTR)GFXLIB_NAME, GFXLIB_REV)))
if (!(GfxBase = (struct GfxBase *)OpenLibrary((STRPTR)GRAPHICSNAME, LIBREV)))
{
OpenLibraryError(GFXLIB_NAME, GFXLIB_REV);
OpenLibraryError(GRAPHICSNAME, LIBREV);
return LIB_ERROR;
}
OpenLibrarySuccess(GRAPHICSNAME, GfxBase->LibNode.lib_IdString);
OpenLibrarySuccess(GfxBase->lib_IdString);
// Locale Library
if (!(LocaleBase = (struct LocaleBase *)OpenLibrary((STRPTR)LOCALENAME, LIBREV)))
{
OpenLibraryError(LOCALENAME, LIBREV);
return LIB_ERROR;
}
OpenLibrarySuccess(LOCALENAME, LocaleBase->lb_LibNode.lib_IdString);
// Locale
if (!(Globals->Locale = OpenLocale(NULL)))
if (!(AppLocale = OpenAppLocale(NULL)))
{
OpenResourceError(currentLocale);
OpenResourceError(CURRENTLOCALE);
return LIB_ERROR;
}
OpenResourceSuccess((const char *)Globals->Locale->loc_LocaleName);
// RTC Clock
if (!(BattClockBase = OpenResource((STRPTR)BATTCLOCK_NAME)))
{
OpenResourceError((const char *)BATTCLOCK_NAME);
return LIB_ERROR;
}
OpenResourceSuccess((const char *)BATTCLOCK_NAME);
OpenResourceSuccess((char *)AppLocale->AmigaLocale->loc_LocaleName);
// Timer Device
if (!(TimerDevice = OpenTimerBase()))
@@ -258,9 +227,25 @@ int OpenLibraries(void)
OpenResourceError(TIMERNAME);
return LIB_ERROR;
}
OpenResourceSuccess(TIMERNAME);
// RTC Clock
BattClockBase = OpenResource((STRPTR)BATTCLOCKNAME);
if (BattClockBase != NULL)
{
OpenResourceSuccess(BATTCLOCKNAME);
}
else
{
LogDebug(NORTCCLOCK);
}
ScreenNotifyBase = OpenLibrary((STRPTR)SCREENNOTIFY_NAME, SCREENNOTIFY_VERSION);
if (ScreenNotifyBase != NULL)
{
LogDebug("Found %s", SCREENNOTIFY_NAME);
}
SeedRandom();
return LIB_OK;
@@ -268,102 +253,103 @@ int OpenLibraries(void)
void CloseLibraries(void)
{
LogInfo("Shutting down");
CleanupTimezone();
if (TimerDevice != NULL)
{
ClosingResource((const char *)TIMERNAME);
ClosingResource(TIMERNAME);
CloseTimerBase();
TimerDevice = NULL;
}
if (Globals->Locale != NULL)
if (AppLocale != NULL)
{
ClosingResource((const char *)Globals->Locale->loc_LocaleName);
CloseLocale(Globals->Locale);
Globals->Locale = NULL;
ClosingResource((char *)AppLocale->AmigaLocale->loc_LocaleName);
CloseAppLocale(AppLocale);
AppLocale = NULL;
}
if (CxBase != NULL)
if (ScreenNotifyBase != NULL)
{
ClosingLibrary(CxBase->lib_IdString);
CloseLibrary(CxBase);
CxBase = NULL;
}
if (AslBase != NULL)
{
ClosingLibrary(AslBase->lib_IdString);
CloseLibrary(AslBase);
AslBase = NULL;
}
if (IconBase != NULL)
{
ClosingLibrary(IconBase->lib_IdString);
CloseLibrary(IconBase);
IconBase = NULL;
ClosingLibrary(SCREENNOTIFY_NAME, ScreenNotifyBase->lib_IdString);
CloseLibrary(ScreenNotifyBase);
ScreenNotifyBase = NULL;
}
if (LocaleBase != NULL)
{
ClosingLibrary(((struct Library *)LocaleBase)->lib_IdString);
ClosingLibrary(LOCALENAME, LocaleBase->lb_LibNode.lib_IdString);
CloseLibrary((struct Library *)LocaleBase);
LocaleBase = NULL;
}
if (UtilityBase != NULL)
if (GfxBase != NULL)
{
ClosingLibrary(((struct Library *)UtilityBase)->lib_IdString);
CloseLibrary((struct Library *)UtilityBase);
UtilityBase = NULL;
__UtilityBase = NULL;
ClosingLibrary(GRAPHICSNAME, GfxBase->LibNode.lib_IdString);
CloseLibrary((struct Library *)GfxBase);
GfxBase = NULL;
}
if (IconBase != NULL)
{
ClosingLibrary(ICONNAME, IconBase->lib_IdString);
CloseLibrary(IconBase);
IconBase = NULL;
}
if (GadToolsBase != NULL)
{
ClosingLibrary(GadToolsBase->lib_IdString);
ClosingLibrary(GADTOOLSNAME, GadToolsBase->lib_IdString);
CloseLibrary(GadToolsBase);
GadToolsBase = NULL;
}
if (GfxBase != NULL)
{
ClosingLibrary(GfxBase->lib_IdString);
CloseLibrary(GfxBase);
GfxBase = NULL;
}
if (IntuitionBase != NULL)
{
ClosingLibrary(((struct Library *)IntuitionBase)->lib_IdString);
ClosingLibrary(INTUITIONNAME, IntuitionBase->LibNode.lib_IdString);
CloseLibrary((struct Library *)IntuitionBase);
IntuitionBase = NULL;
}
if (DOSBase != NULL)
if (CxBase != NULL)
{
#ifdef AOS3
// Library does not always provide IdString
ClosingResource(DOSLIB_NAME);
#else
ClosingLibrary(((struct Library *)DOSBase)->lib_IdString);
#endif
CloseLibrary((struct Library *)DOSBase);
DOSBase = NULL;
ClosingLibrary(COMMODITIESNAME, CxBase->lib_IdString);
CloseLibrary(CxBase);
CxBase = NULL;
}
if (__MathIeeeDoubBasBase != NULL)
if (UtilityBase != NULL)
{
#ifdef AOS3
// Library does not always provide IdString
ClosingResource(MATHLIB_NAME);
#else
ClosingLibrary(((struct Library *)__MathIeeeDoubBasBase)->lib_IdString);
#endif
CloseLibrary((struct Library *)__MathIeeeDoubBasBase);
__MathIeeeDoubBasBase = NULL;
ClosingLibrary(UTILITYNAME, UtilityBase->ub_LibNode.lib_IdString);
CloseLibrary((struct Library *)UtilityBase);
UtilityBase = NULL;
}
if (DOSBase2 != NULL)
{
ClosingLibrary(DOSNAME, DOSBase2->dl_lib.lib_IdString);
CloseLibrary((struct Library *)DOSBase2);
DOSBase2 = NULL;
}
LogWarn("Shutdown complete");
}
void ReopenLocale(void)
{
struct AppLocale *locale, *temp;
if (!(locale = OpenAppLocale(NULL)))
{
OpenResourceError(CURRENTLOCALE);
}
else
{
temp = AppLocale;
AppLocale = locale;
if (temp != NULL)
{
ClosingResource((char *)temp->AmigaLocale->loc_LocaleName);
CloseAppLocale(temp);
}
}
}
+184
View File
@@ -0,0 +1,184 @@
/*-
* Copyright (c) 2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "locale.h"
#include "global.h"
#include "string.h"
#include "ptz.h"
#include "mem.h"
#include <proto/timer.h>
#include <proto/locale.h>
#include <proto/utility.h>
struct AppLocale *OpenAppLocale(struct Locale *locale)
{
int i, j;
struct AppLocale *l = AllocStructSafe(struct AppLocale);
struct Locale *loc = locale;
if (!loc)
{
loc = OpenLocale(NULL);
}
if (loc == NULL)
{
return NULL;
}
l->X_fmt = (const char *)loc->loc_TimeFormat;
l->x_fmt = (const char *)loc->loc_ShortDateFormat;
l->c_fmt = (const char *)loc->loc_DateTimeFormat;
l->am = (const char *)GetLocaleStr(loc, AM_STR);
l->pm = (const char *)GetLocaleStr(loc, PM_STR);
l->date_fmt = "%a %b %e %H:%M:%S %Z %Y";
j = 0;
for (i = 1; i < 8; i++)
{
l->weekday[j++] = (const char *)GetLocaleStr(loc, i);
}
j = 0;
for (i = 8; i < 15; i++)
{
l->wday[j++] = (const char *)GetLocaleStr(loc, i);
}
j = 0;
for (i = 15; i < 27; i++)
{
l->month[j++] = (const char *)GetLocaleStr(loc, i);
}
j = 0;
for (i = 27; i < 39; i++)
{
l->mon[j++] = (const char *)GetLocaleStr(loc, i);
}
l->AmigaLocale = loc;
return l;
}
void CloseAppLocale(struct AppLocale *lc)
{
if (lc->AmigaLocale)
{
CloseLocale(lc->AmigaLocale);
}
FreeMemSafe(lc);
}
void GetTimezoneText(struct AppLocale *loc, char *text, long parens)
{
if (loc == NULL || text == NULL)
{
return;
}
if (Timezone == NULL)
{
long hoursOffset = (loc->AmigaLocale->loc_GMTOffset / -60L);
long minutsOffset = (loc->AmigaLocale->loc_GMTOffset % -60L);
SNPrintf(text, TIMEZONE_TEXT_LEN, "UTC%s%02ld:%02ld",
(loc->AmigaLocale->loc_GMTOffset < 0L) ? "+" : "",
hoursOffset,
minutsOffset);
}
else if (parens == ZONE_IN_PARENS)
{
SNPrintf(text, TIMEZONE_TEXT_LEN, "UTC%s%02ld:%02ld (%s)",
PosixTimezoneSignChar(&Timezone->current),
Timezone->current.offset.hours,
Timezone->current.offset.minutes,
Timezone->current.abbreviation);
}
else if (parens == OFFSET_IN_PARENS)
{
SNPrintf(text, TIMEZONE_TEXT_LEN, "%s (UTC%s%02ld:%02ld)",
Timezone->current.abbreviation,
PosixTimezoneSignChar(&Timezone->current),
Timezone->current.offset.hours,
Timezone->current.offset.minutes);
}
}
char* GetTimeText(struct AppLocale *loc, ULONG time)
{
char *out;
struct ClockData cd;
struct timeval tv;
ULONG t = time;
out = AllocStringSafe(128);
if (loc == NULL)
{
return out;
}
if (t == LOCAL_TIME_NOW)
{
GetSysTime(&tv);
t = (ULONG)tv.tv_secs;
}
Amiga2Date(t, &cd);
if (Timezone == NULL)
{
long hoursOffset = (loc->AmigaLocale->loc_GMTOffset / -60L);
long minutsOffset = (loc->AmigaLocale->loc_GMTOffset % -60L);
SNPrintf(out, 128, "%s %02ld %s %02ld:%02ld:%02ld%s%02ld%02ld %ld",
loc->weekday[cd.wday],
(long)cd.mday,
loc->month[cd.month - 1],
(long)cd.hour,
(long)cd.min,
(long)cd.sec,
(loc->AmigaLocale->loc_GMTOffset < 0L) ? "+" : "",
hoursOffset,
minutsOffset,
(long)cd.year);
}
else
{
SNPrintf(out, 128, "%s %02ld %s %02ld:%02ld:%02ld %s %ld",
loc->weekday[cd.wday],
(long)cd.mday,
loc->month[cd.month - 1],
(long)cd.hour,
(long)cd.min,
(long)cd.sec,
Timezone->current.abbreviation,
(long)cd.year);
}
return out;
}
+59
View File
@@ -0,0 +1,59 @@
/*-
* Copyright (c) 2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef LOCALE_H_INCLUDED
#define LOCALE_H_INCLUDED
#include <libraries/locale.h>
struct AppLocale
{
const char *mon[12];
const char *month[12];
const char *wday[7];
const char *weekday[7];
const char *X_fmt;
const char *x_fmt;
const char *c_fmt;
const char *t_fmt_ampm;
const char *am;
const char *pm;
const char *am_pm[2];
const char *date_fmt;
struct Locale *AmigaLocale;
};
#define LOCAL_TIME_NOW 0
#define ZONE_IN_PARENS 0
#define OFFSET_IN_PARENS 1
#define TIMEZONE_TEXT_LEN 32
struct AppLocale *OpenAppLocale(struct Locale *);
void CloseAppLocale(struct AppLocale *);
char* GetTimeText(struct AppLocale *, ULONG);
void GetTimezoneText(struct AppLocale *, char *, long);
#endif
+51 -179
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,224 +24,96 @@
*
*/
#include "config.h"
#include "log.h"
#include "mem.h"
#include <exec/ports.h>
#include <exec/nodes.h>
#include <proto/exec.h>
#include <stdarg.h>
#define MAXLOGLINESIZE 255
#include "log.h"
#include "string.h"
#include "logger.h"
enum LogSeverity
static void VLogLine(enum LogSeverity level, const char *module, const char *format, va_list ap)
{
ErrorMessage = 5,
WarningMessage = 10,
InfoMessage = 20,
TraceMessage = 30
};
struct MsgPort *port, *replyPort;
struct LogMessage message;
struct LogEntry
{
enum LogSeverity level;
char *line;
struct LogEntry *next;
};
static bool logDisabled = false;
static bool bufferLog = false;
static BPTR logFile = NULL;
static struct LogEntry *firstEntry = NULL;
static struct LogEntry *lastEntry = NULL;
void OpenLogFile(void)
{
BPTR lock;
bool deleteFirst = false;
if (Globals->Settings->LogFile == NULL)
replyPort = CreateMsgPort();
if (replyPort == NULL)
{
return;
}
lock = Lock((STRPTR)Globals->Settings->LogFile, ACCESS_READ);
if (lock)
message.Msg.mn_Node.ln_Type = NT_MESSAGE;
message.Msg.mn_Length = sizeof(struct LogMessage);
message.Msg.mn_ReplyPort = replyPort;
message.Type = LogMessageText;
message.Severity = level;
StrCopy(message.Module, module);
VSNPrintf(message.Text, MAXLOGLINESIZE - 1, format, ap);
VSNPrintf(message.Text, MAXLOGLINESIZE - 1, format, ap);
Forbid();
port = FindPort((CONST_STRPTR)LOGGER_PORT_NAME);
if (port != NULL)
{
deleteFirst = true;
UnLock(lock);
PutMsg(port, (struct Message *)&message);
}
Permit();
if (port != NULL)
{
WaitPort(replyPort);
GetMsg(replyPort);
}
if (deleteFirst)
{
bool success;
LogWarning("Deleting existing log file %s", Globals->Settings->LogFile);
success = DeleteFile((STRPTR)Globals->Settings->LogFile);
if (!success)
{
char message[MAXDOSERRORLEN];
long error = IoErr();
Fault(error, (STRPTR) "Cannot delete existing log file %s", (STRPTR)message, MAXDOSERRORLEN);
LogWarning(message);
logFile = NULL;
return;
}
}
LogInfo("Opening log file %s", Globals->Settings->LogFile);
logFile = Open((STRPTR)Globals->Settings->LogFile, MODE_READWRITE);
if (!logFile)
{
char message[MAXDOSERRORLEN];
long error = IoErr();
Fault(error, (STRPTR) "Cannot open log file %s", (STRPTR)message, MAXDOSERRORLEN);
LogWarning(message);
logFile = NULL;
return;
}
DeleteMsgPort(replyPort);
}
void CloseLogFile(void)
{
if (logFile == NULL)
{
return;
}
LogTrace("Closing log file %s", Globals->Settings->LogFile);
Close(logFile);
logFile = NULL;
logDisabled = true;
}
bool TraceLogging(void)
{
return Globals->Settings->Verbose * 10 >= (int)TraceMessage
? true
: false;
}
static void VLogLine(enum LogSeverity level, const char *format, va_list ap)
{
struct LogEntry *entry;
char line[MAXLOGLINESIZE + 1];
if (logDisabled)
{
return;
}
if (bufferLog || Globals->Settings->Verbose * 10 >= (int)level)
{
int len;
VSNPrintf(line, MAXLOGLINESIZE - 1, format, ap);
len = TrimRight(line);
if (len != 0)
{
line[len++] = '\n';
line[len] = '\0';
}
}
if (bufferLog)
{
entry = (struct LogEntry *)AllocMemSafe(sizeof(struct LogEntry));
entry->level = level;
entry->line = StrDupSafe(line);
entry->next = NULL;
if (firstEntry == NULL)
{
firstEntry = entry;
lastEntry = entry;
}
else
{
lastEntry->next = entry;
lastEntry = entry;
}
return;
}
if (Globals->Settings->Verbose * 10 >= (int)level)
{
if (logFile != NULL)
{
FPuts(logFile, (STRPTR)line);
Flush(logFile);
}
else
{
Printf((STRPTR)line);
}
}
}
void LogTrace(const char *format, ...)
void LogMemTrace(const char *module, const char *format, ...)
{
va_list args;
va_start(args, format);
VLogLine(TraceMessage, format, args);
VLogLine(MemTraceMessage, module, format, args);
va_end(args);
}
void LogInfo(const char *format, ...)
void LogDebug(const char *module, const char *format, ...)
{
va_list args;
va_start(args, format);
VLogLine(InfoMessage, format, args);
VLogLine(DebugMessage, module, format, args);
va_end(args);
}
void LogWarning(const char *format, ...)
void LogTrace(const char *module, const char *format, ...)
{
va_list args;
va_start(args, format);
VLogLine(WarningMessage, format, args);
VLogLine(TraceMessage, module, format, args);
va_end(args);
}
void LogError(const char *format, ...)
void LogInfo(const char *module, const char *format, ...)
{
va_list args;
va_start(args, format);
VLogLine(ErrorMessage, format, args);
VLogLine(InfoMessage, module, format, args);
va_end(args);
}
void SetLogBuffer(void)
void LogWarn(const char *module, const char *format, ...)
{
bufferLog = true;
va_list args;
va_start(args, format);
VLogLine(WarningMessage, module, format, args);
va_end(args);
}
void FlushLogBuffer(void)
void LogError(const char *module, const char *format, ...)
{
struct LogEntry *current;
if (!bufferLog)
return;
current = firstEntry;
while (current != NULL)
{
struct LogEntry *last;
if (Globals->Settings->Verbose * 10 >= (int)current->level)
{
if (logFile != NULL)
{
FPuts(logFile, (STRPTR)current->line);
}
else
{
Printf((STRPTR)current->line);
}
}
last = current;
current = current->next;
FreeMemSafe(last->line, __FUNCTION__);
FreeMemSafe(last, __FUNCTION__);
}
bufferLog = false;
firstEntry = NULL;
lastEntry = NULL;
va_list args;
va_start(args, format);
VLogLine(ErrorMessage, module, format, args);
va_end(args);
}
+8 -11
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,7 +21,7 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/
#ifndef LOG_H_INCLUDED
@@ -29,14 +29,11 @@
#include "compiler.h"
void LogTrace(const char *format, ...);
void LogInfo(const char *format, ...);
void LogWarning(const char *format, ...);
void LogError(const char *format, ...);
bool TraceLogging(void);
void OpenLogFile(void);
void CloseLogFile(void);
void SetLogBuffer(void);
void FlushLogBuffer(void);
void LogMemTrace(const char *module, const char *format, ...);
void LogDebug(const char *module, const char *format, ...);
void LogTrace(const char *module, const char *format, ...);
void LogInfo(const char *module, const char *format, ...);
void LogWarn(const char *module, const char *format, ...);
void LogError(const char *module, const char *format, ...);
#endif
+158
View File
@@ -0,0 +1,158 @@
/*-
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <stddef.h>
#include <stdarg.h>
#include <stdbool.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include <exec/ports.h>
#include <exec/memory.h>
#include "logger.h"
#include "string.h"
static void MsgLoop(void);
static int VerboseLevel = 10;
static struct MsgPort *LoggerPort;
const char *vers = "\0$VER: TimeLogger 1.10 (20.03.2020)";
/*
struct LogMessage
{
struct timeval time;
enum LogSeverity severity;
const char *module;
const char *message;
struct LogMessage *next;
};
*/
int main(int argc, char **argv)
{
Printf((STRPTR) "Starting TimeLogger.\n");
LoggerPort = CreateMsgPort();
if (LoggerPort == NULL)
{
Printf((STRPTR) "Could not message port\n");
return 10;
}
LoggerPort->mp_Node.ln_Name = LOGGER_PORT_NAME;
LoggerPort->mp_Node.ln_Pri = 0;
AddPort(LoggerPort);
MsgLoop();
RemPort(LoggerPort);
DeleteMsgPort(LoggerPort);
return 0;
}
static const char *SeverityText(enum LogSeverity level)
{
switch (level)
{
case ErrorMessage:
return "[Error]";
case WarningMessage:
return "[Warn ]";
case InfoMessage:
return "[Info ]";
case DebugMessage:
return "[Debug]";
case TraceMessage:
case MemTraceMessage:
return "[Trace]";
default:
return "[Trace]";
}
}
static void LogMessage(enum LogSeverity level, const char *module, const char *log)
{
if (VerboseLevel * 10 >= (int)level)
{
char line[MAXLOGLINESIZE + 32];
const char *severity = SeverityText(level);
SNPrintf(line, MAXLOGLINESIZE + 32, "%s[%s] %s", severity, module, log);
TrimRight(line);
// TODO: Option to log using a file
if (Output() != (BPTR)0)
{
Printf((STRPTR)line);
Printf((STRPTR) "\n");
}
}
}
static void MsgLoop(void)
{
bool loop = true;
ULONG loggerSigMask = (1 << LoggerPort->mp_SigBit);
ULONG sigMask = loggerSigMask | SIGBREAKF_CTRL_C;
Printf((STRPTR) "Waiting for log messages ...\n");
do
{
ULONG sigrcvd = Wait(sigMask);
if (sigrcvd & sigMask)
{
struct LogMessage *msg;
while ((msg = (struct LogMessage *)GetMsg(LoggerPort)))
{
struct LogMessage copy;
CopyMem(msg, &copy, sizeof(struct LogMessage));
ReplyMsg((struct Message *)msg);
switch (copy.Type)
{
case LogMessageText:
LogMessage(copy.Severity, copy.Module, copy.Text);
break;
case LogMessageShutdown:
loop = false;
break;
default:
break;
}
}
}
if (sigrcvd & SIGBREAKF_CTRL_C)
{
Printf((STRPTR) "Shutting down\n");
loop = false;
}
} while (loop);
}
+61
View File
@@ -0,0 +1,61 @@
/*-
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef LOGGER_H_INCLUDED
#define LOGGER_H_INCLUDED
#include <exec/ports.h>
#define LOGGER_PORT_NAME "TimeLoggerIn"
#define MODULENAMESIZE 20
#define MAXLOGLINESIZE 255
enum LogSeverity
{
ErrorMessage = 5,
WarningMessage = 10,
InfoMessage = 20,
DebugMessage = 30,
TraceMessage = 40,
MemTraceMessage = 90
};
enum LogMessageType
{
LogMessageText = 1,
LogMessageShutdown = 2
};
struct LogMessage
{
struct Message Msg;
enum LogMessageType Type;
enum LogSeverity Severity;
char Module[MODULENAMESIZE];
char Text[MAXLOGLINESIZE];
};
#endif
+36
View File
@@ -0,0 +1,36 @@
/*-
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifdef MODULENAME
#undef MODULENAME
#endif
#define LogDebug(...) LogDebug(MODULENAME, __VA_ARGS__)
#define LogTrace(...) LogTrace(MODULENAME, __VA_ARGS__)
#define LogInfo(...) LogInfo(MODULENAME, __VA_ARGS__)
#define LogWarn(...) LogWarn(MODULENAME, __VA_ARGS__)
#define LogError(...) LogError(MODULENAME, __VA_ARGS__)
+27 -33
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,37 +25,48 @@
*/
#include "config.h"
#include "state.h"
#include "time.h"
#include "global.h"
#include "setting.h"
#include "timer.h"
#include "net.h"
#include "mem.h"
#include "ptz.h"
#include "tz.h"
#include <workbench/startup.h>
#include "ptz.h"
#include "logmod.h"
#define MODULENAME "Main"
const char *vers = "\0$VER: " APP_ID;
static const char *template = KEYWORD_TEMPLATE;
static void LogStartMessage(void);
static void LogLocalTime(void);
static void GetCliSettings(void);
static void GetWbSettings(struct WBStartup *);
static void ShowLocalTime(void)
{
char *time = GetTimeText(AppLocale, LOCAL_TIME_NOW);
LogInfo("Local time is %s", time);
FreeMemSafe(time);
}
int main(int argc, char **argv)
{
InitState();
SetLogBuffer();
LogStartMessage();
LogLocalTime();
InitMemSafe();
InitSettings();
LogInfo("%s", APP_TITLE);
if (OpenLibraries() != 0)
{
CloseLibraries();
DestroyState();
CleanupSettings();
FreeAllSafe();
return RETURN_ERROR;
}
InitTimezone();
LoadSettings();
if (argc != 0)
@@ -66,17 +77,14 @@ int main(int argc, char **argv)
ApplySettings();
SanitizeSettings();
ShowSettings();
OpenLogFile();
FlushLogBuffer();
InitUtcOffset();
StartBroker();
LogLocalTime();
ShowLocalTime();
CleanupTimezone();
CloseSocketLibrary();
CloseLibraries();
CloseLogFile();
DestroyState();
CleanupSettings();
FreeAllSafe();
return RETURN_OK;
@@ -93,7 +101,6 @@ static void GetCliSettings(void)
args[i] = 0;
settings = CreateSettings(CliSettingType);
settings->Verbose = 1;
inArgs = ReadArgs((void *)template, (void *)&args, NULL);
if (inArgs)
@@ -120,7 +127,7 @@ static void GetWbSettings(struct WBStartup *wbs)
BPTR oldDir;
int argNo, i;
filename = (STRPTR)AllocMemSafe(MAXFILEPATHLEN);
filename = (STRPTR)AllocStringSafe(MAXFILEPATHLEN);
settings = CreateSettings(WbSettingType);
for (argNo = 0; argNo < wbs->sm_NumArgs; ++argNo)
@@ -146,18 +153,5 @@ static void GetWbSettings(struct WBStartup *wbs)
}
CacheSettings(settings);
FreeMemSafe(filename, __FUNCTION__);
}
static void LogStartMessage(void)
{
LogWarning("%s", APP_TITLE);
}
static void LogLocalTime(void)
{
// TODO
char timeString[10], dateString[10], dayString[10], zoneString[10];
SystemTimeString(timeString, dateString, dayString, zoneString);
LogWarning("Local time is %s %s %s%s", dayString, dateString, timeString, zoneString);
FreeMemSafe(filename);
}
+323 -209
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2014-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2014-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,6 +25,7 @@
*/
#include <stddef.h>
#include <stdbool.h>
#include <exec/types.h>
#include <exec/memory.h>
#include <exec/semaphores.h>
@@ -32,8 +33,15 @@
#define ALLOC_MEM(x) AllocVec(x, MEMF_ANY | MEMF_CLEAR)
#define FREE_MEM(x) FreeVec(x)
#include "mem.h"
#include "compiler.h"
#include "log.h"
#include "logmod.h"
#define MODULENAME "Memory"
#define LogMemTrace(...) LogMemTrace(MODULENAME, __VA_ARGS__)
//#define MEM_TRACE 1
int StrLen(const char *);
#if defined(__x86_64__) || defined(__aarch64__) || \
@@ -42,22 +50,21 @@ int StrLen(const char *);
#define P64BIT
#endif
#ifdef DEBUG_BUILD
#define MEM_TRACE 1
#endif
/**
* @brief Block of allocated memory.
/*
* Block of allocated memory.
*/
struct MemoryBlock
{
struct MemoryBlock *next;
size_t size;
void *address;
char *file;
char *function;
int line;
};
/**
* @brief List of allocated memory. Uses the LIFO principle.
/*
* List of allocated memory. Uses the LIFO principle.
*/
struct MemoryList
{
@@ -67,200 +74,13 @@ struct MemoryList
long count;
};
/**
* @brief Global list of allocated memory.
/*
* Global list of allocated memory.
*/
static struct MemoryList *list = NULL;
volatile static struct MemoryList *list = NULL;
void AllocationError(char *, size_t);
void DeAllocationError(char *, char*, void *);
/**
* @brief Allocate memory and add it to the global memory list.
*/
void *AllocMemSafe(size_t size)
{
struct MemoryBlock *newblock;
size_t allocsize;
Forbid();
if (list == NULL)
{
list = (struct MemoryList *)ALLOC_MEM(sizeof(struct MemoryList));
if (!list)
{
AllocationError("list", sizeof(struct MemoryList));
return 0;
}
list->first = NULL;
list->peak = 0;
list->size = 0;
list->count = 0;
}
#ifdef P64BIT
// Align to bytes of 8
allocsize = (size + 7) & ~0x07;
#else
// Align to bytes of 4
allocsize = (size + 3) & ~0x03;
#endif
newblock = (struct MemoryBlock *)ALLOC_MEM(sizeof(struct MemoryBlock));
if (!newblock)
{
AllocationError("block", sizeof(struct MemoryBlock));
return 0;
}
newblock->address = (struct MemoryBlock *)ALLOC_MEM(allocsize);
if (!newblock->address)
{
FREE_MEM(newblock);
AllocationError("memory", allocsize);
return 0;
}
newblock->size = allocsize;
newblock->next = list->first;
list->first = newblock;
list->size += allocsize;
list->count++;
if (list->size > list->peak)
{
list->peak = list->size;
}
Permit();
#ifdef MEM_TRACE
Printf("Allocated memory block off %ld bytes at 0x%lx\n",
newblock->size, newblock->address);
#endif
// Memory allocated
return newblock->address;
}
void RemoveMemSafe(void *block, char *name, bool deallocate)
{
struct MemoryBlock *current, *previous;
Forbid();
if (list == NULL || block == NULL)
{
DeAllocationError("list", name, 0);
return;
}
if (block == NULL)
{
DeAllocationError("memory", name, 0);
return;
}
previous = NULL;
current = list->first;
while (current != NULL && current->address != block)
{
previous = current;
current = current->next;
}
if (current == NULL)
{
DeAllocationError("address not found", name, block);
return;
}
if (previous == NULL)
{
list->first = current->next;
}
else
{
previous->next = current->next;
}
list->size -= current->size;
list->count--;
if (deallocate)
{
FREE_MEM(current->address);
}
current->address = NULL;
current->next = NULL;
current->size = 0;
FREE_MEM(current);
Permit();
}
/**
* @brief Deallocate memory from the global memory list.
*/
void FreeMemSafe(void *block, char *name)
{
RemoveMemSafe(block, name, true);
}
void *MemDupSafe(const void *s1, size_t len)
{
char *dup;
dup = AllocMemSafe(len);
CopyMem((void *)s1, dup, len);
return dup;
}
char *StrDupSafe(const char *s1)
{
char *s2;
size_t len = s1 != NULL ? StrLen(s1) : 1;
s2 = AllocMemSafe(++len);
if (s2 == NULL)
{
return NULL;
}
CopyMem((void *)s1, s2, --len);
return s2;
}
/**
* @brief Deallocate all memory in the global memory list.
*/
void FreeAllSafe(void)
{
struct MemoryBlock *current, *next;
Forbid();
if (list == NULL)
{
return;
}
current = list->first;
while (current != NULL)
{
LogTrace("Released forgotten memory block on %ld bytes at 0x%lx",
(long)current->size,
(unsigned long)current->address);
next = current->next;
FREE_MEM(current->address);
FREE_MEM(current);
current = next;
}
FREE_MEM(list);
list = NULL;
Permit();
}
/**
* @brief Get memory usage in the global memory list.
/*
* Get memory usage in the global memory list.
*/
void MemUsage(long *blocks, long *size, long *peak)
{
@@ -280,18 +100,312 @@ void MemUsage(long *blocks, long *size, long *peak)
}
}
/**
* @brief Log a memory allocation error.
/*
* Log a memory allocation error.
*/
void AllocationError(char *descr, size_t size)
static void AllocationError(const char *descr, size_t size, const char *file, const char *function, int line)
{
LogTrace("Memory allocation error (%s) with size (%ld)", descr, (long)size);
LogDebug("Memory allocation error (%s) from %s, %s, line %ld, %ld bytes",
descr, function, file, line, (long)size);
}
/**
* @brief Log a memory deallocation error.
/*
* Log a memory deallocation error.
*/
void DeAllocationError(char *descr, char *name, void *p)
static void DeAllocationError(const char *descr, void *p, const char *file, const char *function, int line)
{
LogTrace("Memory deallocation error from %s (%s) at 0x%lx", name, descr, p);
LogDebug("Memory deallocation error (%s) from %s, %s, line %ld at 0x%lx",
descr, function, file, line, p);
}
static char *StrDupRaw(const char *s1)
{
char *s2;
size_t len = s1 != NULL ? StrLen(s1) : 1;
s2 = ALLOC_MEM(++len);
if (s2 == NULL)
{
return NULL;
}
CopyMem((void *)s1, s2, --len);
return s2;
}
static void MemZero(void *address, size_t size)
{
if (address == NULL || size == 0)
{
return;
}
char *c = (char *)address;
int n = size;
do
{
*c++ = '\0';
} while (--n);
}
void InitMemSafe(void)
{
volatile struct MemoryList *m = (volatile struct MemoryList *)ALLOC_MEM(sizeof(struct MemoryList));
bool newList = false;
if (m == NULL)
{
return;
}
Forbid();
if (list == NULL)
{
list = m;
;
list->first = NULL;
list->peak = 0;
list->size = 0;
list->count = 0;
newList = true;
}
Permit();
if (newList && !list)
{
AllocationError("list", sizeof(struct MemoryList), __FILE__, __FUNCTION__, __LINE__);
}
if (!newList)
{
FREE_MEM((void *)m);
}
}
/*
* Allocate memory and add it to the global memory list.
*/
void *AllocMemTraced(size_t size, const char *file, const char *function, int line, bool trace)
{
struct MemoryBlock *newblock;
#ifdef P64BIT // Align to bytes of 8
size_t allocsize = (size + 7) & ~0x07;
#else // Align to bytes of 4
size_t allocsize = (size + 3) & ~0x03;
#endif
newblock = (struct MemoryBlock *)ALLOC_MEM(sizeof(struct MemoryBlock));
if (!newblock)
{
AllocationError("block", sizeof(struct MemoryBlock), file, function, line);
return 0;
}
newblock->address = (struct MemoryBlock *)ALLOC_MEM(allocsize);
if (!newblock->address)
{
FREE_MEM(newblock);
AllocationError("memory", allocsize, file, function, line);
return 0;
}
newblock->size = allocsize;
newblock->file = StrDupRaw(file);
newblock->function = StrDupRaw(function);
newblock->line = line;
Forbid();
newblock->next = list->first;
list->first = newblock;
list->size += allocsize;
list->count++;
if (list->size > list->peak)
{
list->peak = list->size;
}
Permit();
#ifdef MEM_TRACE
if (trace)
{
LogMemTrace("[Memory] Allocated memory block from %s, %s, line %ld, %ld bytes at 0x%lx",
newblock->function, newblock->file, newblock->line,
newblock->size, newblock->address);
}
#endif
// Memory allocated
return newblock->address;
}
static void RemoveMemSafe(void *block, const char *file, const char *function, int line, bool deallocate)
{
struct MemoryBlock *current, *previous;
bool found = true;
if (list == NULL)
{
DeAllocationError("list", 0, file, function, line);
return;
}
if (block == NULL)
{
DeAllocationError("block", 0, file, function, line);
return;
}
Forbid();
previous = NULL;
current = list->first;
while (current != NULL && current->address != block)
{
previous = current;
current = current->next;
}
if (current != NULL)
{
if (previous == NULL)
{
list->first = current->next;
}
else
{
previous->next = current->next;
}
list->size -= current->size;
list->count--;
}
else
{
found = false;
}
Permit();
if (found)
{
#ifdef MEM_TRACE
LogMemTrace("[Memory] Deallocated memory block from %s, %s, line %ld, %ld bytes at 0x%lx",
current->function, current->file, current->line,
current->size, current->address);
#endif
if (deallocate)
{
MemZero(current->address, current->size);
FREE_MEM(current->address);
}
if (current->file != NULL)
{
MemZero(current->file, StrLen(current->file));
FREE_MEM(current->file);
}
if (current->function != NULL)
{
MemZero(current->function, StrLen(current->function));
FREE_MEM(current->function);
}
MemZero(current, sizeof(struct MemoryBlock));
FREE_MEM(current);
}
else
{
DeAllocationError("address not found", block, file, function, line);
}
}
/*
* Deallocate memory from the global memory list.
*/
void FreeMemTraced(void *block, const char *file, const char *function, int line)
{
RemoveMemSafe(block, file, function, line, true);
}
void *MemDupTraced(const void *s1, size_t len, const char *file, const char *function, int line, bool trace)
{
char *dup;
dup = AllocMemTraced(len, file, function, line, trace);
CopyMem((void *)s1, dup, len);
return dup;
}
char *StrDupTraced(const char *s1, const char *file, const char *function, int line, bool trace)
{
char *s2;
size_t len = s1 != NULL ? StrLen(s1) : 1;
s2 = AllocMemTraced(++len, file, function, line, trace);
if (s2 == NULL)
{
return NULL;
}
CopyMem((void *)s1, s2, --len);
return s2;
}
/*
* Deallocate all memory in the global memory list.
*/
void FreeAllSafe(void)
{
volatile struct MemoryList *m;
struct MemoryBlock *current, *next;
Forbid();
m = list;
list = NULL;
Permit();
if (m == NULL)
{
return;
}
current = m->first;
while (current != NULL)
{
if (current->file && current->function)
{
LogDebug("Released forgotten memory block from %s, %s, line %ld, %ld bytes at 0x%lx",
current->function, current->file, current->line,
(long)current->size, current->address);
}
else
{
LogDebug("Released forgotten memory block on %ld bytes at 0x%lx",
(long)current->size,
current->address);
}
next = current->next;
MemZero(current->address, current->size);
FREE_MEM(current->address);
if (current->file != NULL)
{
MemZero(current->file, StrLen(current->file));
FREE_MEM(current->file);
}
if (current->function != NULL)
{
MemZero(current->function, StrLen(current->function));
FREE_MEM(current->function);
}
MemZero(current->file, sizeof(struct MemoryBlock));
FREE_MEM(current);
current = next;
}
FREE_MEM((void *)m);
}
+16 -5
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2014-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2014-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -28,12 +28,23 @@
#define MEM_H_INCLUDED
#include <stddef.h>
#include <stdbool.h>
void *AllocMemSafe(size_t);
char *StrDupSafe(const char *);
void *MemDupSafe(const void *s1, size_t len);
void FreeMemSafe(void *, char*);
void InitMemSafe(void);
void FreeAllSafe(void);
void MemUsage(long *, long *, long *);
void *AllocMemTraced(size_t, const char *, const char *, int, bool);
char *StrDupTraced(const char *, const char *, const char *, int, bool);
void *MemDupTraced(const void *s1, size_t len, const char *, const char *, int, bool);
void FreeMemTraced(void *, const char *, const char *, int);
#define AllocStringSafe(size) (char *)AllocMemTraced(size, __FILE__, __FUNCTION__, __LINE__, true)
#define AllocStructSafe(type) (type *)AllocMemTraced(sizeof(type), __FILE__, __FUNCTION__, __LINE__, true)
#define StrDupSafe(string) StrDupTraced(string, __FILE__, __FUNCTION__, __LINE__, true)
#define MemDupSafe(string, len) MemDupTraced(string, len, __FILE__, __FUNCTION__, __LINE__, true)
#define FreeMemSafe(block) FreeMemTraced(block, __FILE__, __FUNCTION__, __LINE__)
#define AllocStructNoTrace(type) (type *)AllocMemTraced(sizeof(type), __FILE__, __FUNCTION__, __LINE__, false)
#define StrDupNoTrace(string) StrDupTraced(string, __FILE__, __FUNCTION__, __LINE__, false)
#define MemDupNoTrace(string, len) MemDupTraced(string, len, __FILE__, __FUNCTION__, __LINE__, false)
#endif
+78 -55
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,77 +21,100 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/
#include "config.h"
#include "global.h"
#include "message.h"
#include "mem.h"
static void SendTextMessage(char *text, long type)
{
Forbid();
if (!Globals->ShuttingDown)
{
struct AppWindowMessage *message = (struct AppWindowMessage *)AllocMemSafe(sizeof(struct AppWindowMessage));
message->Msg.mn_Node.ln_Type = NT_MESSAGE;
message->Msg.mn_Length = sizeof(struct AppWindowMessage);
message->Msg.mn_ReplyPort = Globals->Broker->ReplyPort;
message->Type = type;
message->Text = StrDupSafe(text);
PutMsg(Globals->Broker->UserPort, (struct Message *)message);
}
Permit();
}
void SendErrorMessage(char *text)
{
SendTextMessage(text, ATK_LOGERROR);
}
void SendWarningMessage(char *text)
{
SendTextMessage(text, ATK_LOGWARN);
}
void SendInfoMessage(char *text)
{
SendTextMessage(text, ATK_LOGINFO);
}
void SendTraceMessage(char *text)
{
SendTextMessage(text, ATK_LOGTRACE);
}
void SendMessage(long type)
{
Forbid();
if (!Globals->ShuttingDown)
{
struct AppWindowMessage *message = (struct AppWindowMessage *)AllocMemSafe(sizeof(struct AppWindowMessage));
message->Msg.mn_Node.ln_Type = NT_MESSAGE;
message->Msg.mn_Length = sizeof(struct AppWindowMessage);
message->Msg.mn_ReplyPort = Globals->Broker->ReplyPort;
message->Type = type;
message->Text = NULL;
PutMsg(Globals->Broker->UserPort, (struct Message *)message);
}
Permit();
SendMessageTo(Ports.BrokerPort, Ports.MemoryPort, type);
}
void SendMessageTo(struct MsgPort *dest, struct MsgPort *reply, long type)
{
Forbid();
if (!Globals->ShuttingDown)
if (dest != NULL && reply != NULL)
{
struct AppWindowMessage *message = (struct AppWindowMessage *)AllocMemSafe(sizeof(struct AppWindowMessage));
struct ApplicationMesage *message = AllocStructSafe(struct ApplicationMesage);
message->Msg.mn_Node.ln_Type = NT_MESSAGE;
message->Msg.mn_Length = sizeof(struct AppWindowMessage);
message->Msg.mn_Length = sizeof(struct ApplicationMesage);
message->Msg.mn_ReplyPort = reply;
message->Type = type;
message->Text = NULL;
message->MsgType = MSGTYPE_APP;
message->MsgId = type;
PutMsg(dest, (struct Message *)message);
}
Permit();
}
void SendMessageWait(struct MsgPort *dest, long type)
{
struct MsgPort *replyPort;
if (dest == NULL)
{
return;
}
replyPort = CreateMsgPort();
if (replyPort)
{
struct Message *msg;
SendMessageTo(dest, replyPort, type);
WaitPort(replyPort);
msg = GetMsg(replyPort);
DeleteMsgPort(replyPort);
FreeMemSafe(msg);
}
}
void CleanupVolMsgPort(struct MsgPort *volatile *port)
{
struct MsgPort *msgPort;
bool exist = true;
Forbid();
if (*port == NULL)
{
exist = false;
}
else
{
msgPort = *port;
*port = NULL;
}
Permit();
if (exist)
{
struct Message *msg;
while ((msg = GetMsg(msgPort)))
{
ReplyMsg(msg);
}
DeleteMsgPort(msgPort);
}
}
void CleanupMsgPort(struct MsgPort **port)
{
struct Message *msg;
struct MsgPort *msgPort = *port;
if (*port == NULL)
{
return;
}
*port = NULL;
while ((msg = GetMsg(msgPort)))
{
ReplyMsg(msg);
}
DeleteMsgPort(msgPort);
}
+22 -14
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,7 +21,7 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/
#ifndef MESSAGE_H_INCLUDED
@@ -29,10 +29,10 @@
#include "config.h"
#define ATK_LOGERROR 1
#define ATK_LOGWARN 2
#define ATK_LOGINFO 3
#define ATK_LOGTRACE 4
#define MSGTYPE_APP 1
#define MSGTYPE_TIMEVAL 2
#define ATK_LASTSYNC 1
#define ATK_RESTART 10
#define ATK_REFRESH 11
#define ATK_STORE 13
@@ -42,19 +42,27 @@
#define ATK_DISABLE 21
#define ATK_READONLY 22
#define ATK_READWRITE 23
#define ATK_SHUTDOWN 30
#define ATK_TZ_CHANGED 40
#define ATK_TZONE_CHANGED 41
#define ATK_LOCALE_CHANGED 42
struct AppWindowMessage
struct ApplicationMesage
{
struct Message Msg;
long Type;
char *Text;
long MsgType;
long MsgId;
};
struct TimeMessage
{
struct ApplicationMesage AppMsg;
struct timeval TimeVal;
};
void SendMessage(long);
void SendErrorMessage(char *);
void SendWarningMessage(char *);
void SendInfoMessage(char *);
void SendTraceMessage(char *);
void SendMessageTo(struct MsgPort *, struct MsgPort *, long);
void SendMessageWait(struct MsgPort *, long);
void CleanupMsgPort(struct MsgPort **);
void CleanupVolMsgPort(struct MsgPort *volatile *);
#endif
+14 -16
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,13 +21,17 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/
#include "config.h"
#include "net.h"
#include "net_getaddrinfo.h"
#include "message.h"
#include "logmod.h"
#define MODULENAME "Network"
int errno;
int gai_h_errno;
@@ -36,7 +40,7 @@ int h_errno;
#endif
static const char *bsdSocketName = "bsdsocket.library";
static const char *openSocketLibraryError = "Cannot open %s %ld.0";
static const char *openSocketLibraryError = "No TCP/IP Stack running!";
static const char *openSocketResourceError = "Cannot open %s";
struct Library *SocketBase = NULL;
@@ -45,8 +49,6 @@ struct Library *SocketBase = NULL;
int OpenSocketLibrary(void)
{
char message[SETTINGMESSAGELEN];
if (SocketBase != NULL)
{
return LIB_OK;
@@ -54,19 +56,17 @@ int OpenSocketLibrary(void)
if (!(SocketBase = OpenLibrary((STRPTR)BSDLIB_NAME, BSDLIB_REV)))
{
SNPrintf(message, SETTINGMESSAGELEN, openSocketLibraryError, BSDLIB_NAME, BSDLIB_REV);
SendErrorMessage(message);
LogError(openSocketLibraryError, BSDLIB_NAME, BSDLIB_REV);
return LIB_ERROR;
}
SNPrintf(message, SETTINGMESSAGELEN, "Opened %s", (char *)SocketBase->lib_IdString);
SendTraceMessage(message);
LogDebug("Opened %s", (char *)SocketBase->lib_IdString);
if (SocketBaseTags(SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (int)&errno,
SBTM_SETVAL(SBTC_LOGTAGPTR), (IPTR)APP_SHORT_NAME,
SBTM_SETVAL(SBTC_HERRNOLONGPTR), (int)&h_errno, TAG_DONE))
{
SNPrintf(message, SETTINGMESSAGELEN, openSocketResourceError, BSDLIB_NAME);
SendErrorMessage(message);
LogError(openSocketResourceError, BSDLIB_NAME);
CloseLibrary(SocketBase);
return LIB_ERROR;
}
@@ -78,9 +78,7 @@ void CloseSocketLibrary(void)
{
if (SocketBase != NULL)
{
char message[SETTINGMESSAGELEN];
SNPrintf(message, SETTINGMESSAGELEN, "Closing %s", (char *)SocketBase->lib_IdString);
SendTraceMessage(message);
LogDebug("Closing %s", (char *)SocketBase->lib_IdString);
CloseLibrary(SocketBase);
SocketBase = NULL;
}
@@ -150,8 +148,8 @@ const char *GetHostErrorText(void)
if (gai_h_errno != 0)
{
return gai_h_errno == EAI_SYSTEM
? GetErrorText()
: gai_strerror(gai_h_errno);
? (const char *)GetErrorText()
: (const char *)gai_strerror(gai_h_errno);
}
switch (h_errno)
+117
View File
@@ -0,0 +1,117 @@
/*-
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef NET_H_INCLUDED
#define NET_H_INCLUDED
#ifndef ENOTSOCK
#define ENOTSOCK 38
#endif
#ifndef EDESTADDRREQ
#define EDESTADDRREQ 39
#endif
#ifndef EMSGSIZE
#define EMSGSIZE 40
#endif
#ifndef EPROTOTYPE
#define EPROTOTYPE 41
#endif
#ifndef ENOPROTOOPT
#define ENOPROTOOPT 42
#endif
#ifndef EPROTONOSUPPORT
#define EPROTONOSUPPORT 43
#endif
#ifndef ESOCKTNOSUPPORT
#define ESOCKTNOSUPPORT 44
#endif
#ifndef EOPNOTSUPP
#define EOPNOTSUPP 45
#endif
#ifndef EPFNOSUPPORT
#define EPFNOSUPPORT 46
#endif
#ifndef EAFNOSUPPORT
#define EAFNOSUPPORT 47
#endif
#ifndef EADDRINUSE
#define EADDRINUSE 48
#endif
#ifndef EADDRNOTAVAIL
#define EADDRNOTAVAIL 49
#endif
#ifndef ENETDOWN
#define ENETDOWN 50
#endif
#ifndef ENETUNREACH
#define ENETUNREACH 51
#endif
#ifndef ENETRESET
#define ENETRESET 52
#endif
#ifndef ECONNABORTED
#define ECONNABORTED 53
#endif
#ifndef ECONNRESET
#define ECONNRESET 54
#endif
#ifndef ENOBUFS
#define ENOBUFS 55
#endif
#ifndef EISCONN
#define EISCONN 56
#endif
#ifndef ENOTCONN
#define ENOTCONN 57
#endif
#ifndef ESHUTDOWN
#define ESHUTDOWN 58
#endif
#ifndef ETOOMANYREFS
#define ETOOMANYREFS 59
#endif
#ifndef ETIMEDOUT
#define ETIMEDOUT 60
#endif
#ifndef ECONNREFUSED
#define ECONNREFUSED 61
#endif
#ifndef EHOSTDOWN
#define EHOSTDOWN 64
#endif
#ifndef EHOSTUNREACH
#define EHOSTUNREACH 65
#endif
int OpenSocketLibrary(void);
void CloseSocketLibrary(void);
const char *GetErrorText(void);
const char *GetHostErrorText(void);
int GetErrorNo(void);
int GetHostErrorNo(void);
extern struct Library *SocketBase;
#endif
+14 -167
View File
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2001, 02 Motoyuki Kasahara
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -52,6 +52,9 @@
#include "net_getaddrinfo.h"
#include "mem.h"
#include "logmod.h"
#define MODULENAME "Network"
#define gettext(string) (string)
#define _(string) (string)
#define N_(string) (string)
@@ -139,11 +142,11 @@ void freeaddrinfo(struct addrinfo *ai)
while (ai != NULL)
{
if (ai->ai_canonname != NULL)
FreeMemSafe(ai->ai_canonname, __FUNCTION__);
FreeMemSafe(ai->ai_canonname);
if (ai->ai_addr != NULL)
FreeMemSafe(ai->ai_addr, __FUNCTION__);
FreeMemSafe(ai->ai_addr);
next_ai = ai->ai_next;
FreeMemSafe(ai, __FUNCTION__);
FreeMemSafe(ai);
ai = next_ai;
}
}
@@ -224,10 +227,6 @@ int getaddrinfo(
int saved_h_errno;
int result = 0;
#ifdef ENABLE_THREAD
ObtainSemaphore(&getaddrinfoSemaphore);
#endif
saved_h_errno = h_errno;
if (nodename == NULL && servname == NULL)
@@ -305,12 +304,11 @@ int getaddrinfo(
if (hints->ai_flags & AI_CANONNAME && !(hints->ai_flags & AI_NUMERICHOST))
{
hostent = gethostbyaddr((char *)&addr_buf,
sizeof(struct in_addr), AF_INET);
hostent = gethostbyaddr((const char *)&addr_buf, sizeof(struct in_addr), AF_INET);
if (hostent != NULL)
canonname = hostent->h_name;
canonname = (const char *)hostent->h_name;
else
canonname = nodename;
canonname = (const char *)nodename;
}
}
else
@@ -357,7 +355,7 @@ int getaddrinfo(
for (ap = addr_list; *ap != NULL; ap++)
{
new_res = (struct addrinfo *)AllocMemSafe(sizeof(struct addrinfo));
new_res = AllocStructSafe(struct addrinfo);
if (new_res == NULL)
{
if (head_res != NULL)
@@ -374,11 +372,10 @@ int getaddrinfo(
new_res->ai_canonname = NULL;
new_res->ai_next = NULL;
new_res->ai_addr = (struct sockaddr *)
AllocMemSafe(sizeof(struct sockaddr_in));
new_res->ai_addr = (struct sockaddr *)AllocStructSafe(struct sockaddr_in);
if (new_res->ai_addr == NULL)
{
FreeMemSafe(new_res, __FUNCTION__);
FreeMemSafe(new_res);
if (head_res != NULL)
freeaddrinfo(head_res);
result = EAI_MEMORY;
@@ -400,7 +397,7 @@ int getaddrinfo(
if (canonname != NULL && head_res != NULL)
{
head_res->ai_canonname = (char *)AllocMemSafe(StrLen(canonname) + 1);
head_res->ai_canonname = AllocStringSafe(StrLen(canonname) + 1);
if (head_res->ai_canonname != NULL)
StrCopy(head_res->ai_canonname, canonname);
}
@@ -410,155 +407,5 @@ int getaddrinfo(
end:
h_errno = saved_h_errno;
gai_h_errno = result;
#ifdef ENABLE_THREAD
ReleaseSemaphore(&getaddrinfoSemaphore);
#endif
return result;
}
#if 0
/*
* Calcurate length of the string `s', where `s' is set by
* sprintf(s, "%d", n).
*/
static int
itoa_length(int n)
{
int result = 1;
if (n < 0)
{
n = -n;
result++;
}
while (n >= 10)
{
result++;
n /= 10;
}
return result;
}
#if defined(__CLIB2__)
LONG getnameinfo(
struct sockaddr *sa,
ULONG salen,
STRPTR node,
ULONG nodelen,
STRPTR serv,
ULONG servlen,
ULONG flags)
#else
int getnameinfo(
const struct sockaddr *sa,
socklen_t salen,
char *node,
socklen_t nodelen,
char *serv,
socklen_t servlen,
int flags)
#endif
{
const struct sockaddr_in *sa_in = (const struct sockaddr_in *)sa;
struct hostent *hostent;
struct servent *servent;
char *ntoa_address;
int saved_h_errno;
int result = 0;
#ifdef ENABLE_PTHREAD
pthread_mutex_lock(&gai_mutex);
#endif
saved_h_errno = h_errno;
if (sa_in->sin_family != PF_INET)
{
result = EAI_FAMILY;
goto end;
}
else if (node == NULL && serv == NULL)
{
result = EAI_NONAME;
goto end;
}
if (serv != NULL && servlen > 0)
{
if (flags & NI_NUMERICSERV)
servent = NULL;
else if (flags & NI_DGRAM)
servent = getservbyport(sa_in->sin_port, "udp");
else
servent = getservbyport(sa_in->sin_port, "tcp");
if (servent != NULL)
{
if (servlen <= StrLen(servent->s_name))
{
result = EAI_OVERFLOW;
goto end;
}
StrCopy(serv, servent->s_name);
}
else
{
if (servlen <= itoa_length(ntohs(sa_in->sin_port)))
{
result = EAI_OVERFLOW;
goto end;
}
LongToStr((long)ntohs(sa_in->sin_port), serv);
}
}
if (node != NULL && nodelen > 0)
{
if (flags & NI_NUMERICHOST)
hostent = NULL;
else
{
hostent = gethostbyaddr((char *)&sa_in->sin_addr,
sizeof(struct in_addr), AF_INET);
}
if (hostent != NULL)
{
if (nodelen <= StrLen(hostent->h_name))
{
result = EAI_OVERFLOW;
goto end;
}
StrCopy(node, hostent->h_name);
}
else
{
if (flags & NI_NAMEREQD)
{
result = EAI_NONAME;
goto end;
}
#ifndef __libnix__
ntoa_address = inet_ntoa(sa_in->sin_addr);
#else
ntoa_address = inet_ntoa((LONG)sa_in->sin_addr.s_addr);
#endif
if (nodelen <= StrLen(ntoa_address))
{
result = EAI_OVERFLOW;
goto end;
}
StrCopy(node, ntoa_address);
}
}
end:
h_errno = saved_h_errno;
gai_h_errno = result;
#ifdef ENABLE_PTHREAD
pthread_mutex_unlock(&gai_mutex);
#endif
return result;
}
#endif
+14 -1
View File
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2001, 02 Motoyuki Kasahara
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -194,6 +194,19 @@
typedef uint16_t in_port_t;
#endif
#if defined(MISSING_ADDRINFO)
struct addrinfo {
int ai_flags; /* input flags */
int ai_family; /* protocol family for socket */
int ai_socktype; /* socket type */
int ai_protocol; /* protocol for socket */
socklen_t ai_addrlen; /* length of socket-address */
struct sockaddr *ai_addr; /* socket-address for socket */
char *ai_canonname; /* canonical name for service location (iff req) */
struct addrinfo *ai_next; /* pointer to next in list */
};
#endif
#if defined(__CLIB2__)
STRPTR gai_strerror(LONG);
LONG getaddrinfo(STRPTR, STRPTR, struct addrinfo *, struct addrinfo **);
+5 -2
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,7 +21,7 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/
#include "config.h"
@@ -31,6 +31,9 @@
#include <sys/select.h>
#endif
#include "logmod.h"
#define MODULENAME "Network"
int poll(struct pollfd *fds, nfds_t nfds, int timeout)
{
unsigned int i;
+142
View File
@@ -0,0 +1,142 @@
/*-
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <dos/dos.h>
#include <dos/notify.h>
#include "config.h"
#include "mem.h"
#include "logmod.h"
#define MODULENAME "Notify"
struct NotifyRequestNode
{
long Registered;
struct NotifyRequest *Request;
volatile struct NotifyRequestNode *Next;
};
volatile static struct NotifyRequestNode *Last = NULL;
static void AddRequest(struct NotifyRequest *request)
{
volatile struct NotifyRequestNode *node;
node = AllocStructSafe(struct NotifyRequestNode);
if (node == NULL)
{
return;
}
node->Request = request;
node->Next = NULL;
// Add to list
Forbid();
if (Last == NULL)
{
Last = node;
}
else
{
node->Next = Last;
Last = node;
}
Permit();
}
void ActivateNotifyPort(struct MsgPort *port)
{
volatile struct NotifyRequestNode *current;
if (port == NULL)
{
return;
}
current = Last;
while (current != NULL)
{
if (current->Registered != DOSTRUE)
{
current->Request->nr_stuff.nr_Msg.nr_Port = port;
current->Registered = StartNotify(current->Request);
if (current->Registered == DOSTRUE)
{
LogInfo("Watching for changes in %s", current->Request->nr_Name);
}
else
{
LogWarn("Could not get notifications from %s", current->Request->nr_Name);
}
}
current = current->Next;
}
}
void WatchFile(char *file, long type)
{
struct NotifyRequest *request;
request = AllocStructSafe(struct NotifyRequest);
if (request == NULL)
{
return;
}
request->nr_Name = (UBYTE *)StrDupSafe(file);
if (request->nr_Name == NULL)
{
return;
}
request->nr_Flags = NRF_SEND_MESSAGE | NRB_WAIT_REPLY;
request->nr_UserData = type;
AddRequest(request);
}
void CleanupNotifications(void)
{
volatile struct NotifyRequestNode *current, *next;
current = Last;
while (current != NULL)
{
if (current->Registered == DOSTRUE)
{
EndNotify(current->Request);
}
FreeMemSafe((void *)current->Request->nr_Name);
FreeMemSafe((void *)current->Request);
next = current->Next;
FreeMemSafe((void *)current);
current = next;
}
}
+34
View File
@@ -0,0 +1,34 @@
/*-
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef NOTIFY_H_INCLUDED
#define NOTIFY_H_INCLUDED
void ActivateNotifyPort(struct MsgPort *port);
void WatchFile(char *file, long type);
void CleanupNotifications(void);
#endif
+99 -72
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,15 +33,18 @@
#include "ptz.h"
#include "string.h"
#include "state.h"
#include "global.h"
#include "mem.h"
#include "logmod.h"
#define MODULENAME "Posix TZ"
/*
* Parse integers in POSIX TZ string.
*/
static const char *ParseInt(const char *p, int min, int max, int *result)
{
char *start = (char *)p;
CONST_STRPTR start = (CONST_STRPTR)p;
LONG c, value;
c = StrToLong(start, &value);
@@ -50,8 +53,7 @@ static const char *ParseInt(const char *p, int min, int max, int *result)
return NULL;
*result = (int)value;
return (start + c);
return (const char *)(start + c);
}
/*
@@ -63,13 +65,14 @@ static const char *ParseAbbr(const char *p, char **result)
if (*p == '<')
{
start++;
while (*++p != '>')
{
if (*p == '\0')
return NULL;
}
*result = (char *)AllocMemSafe(p - start);
*result = AllocStringSafe(p - start);
CopyMem((APTR)start, *result, p - start);
return ++p;
@@ -81,7 +84,7 @@ static const char *ParseAbbr(const char *p, char **result)
if (p - start < 3)
return NULL;
*result = (char *)AllocMemSafe(p - start + 1);
*result = AllocStringSafe(p - start + 1);
CopyMem((APTR)start, *result, p - start);
return p;
@@ -91,7 +94,7 @@ static const char *ParseAbbr(const char *p, char **result)
* Parse time part of POSIX TZ string in format:
* [+|-]hh[:mm[:ss]]
*/
static const char *ParseTime(const char *p, int min_hour, int max_hour, int sign, struct PosixTimeZoneOffset *result)
static const char *ParseTime(const char *p, int min_hour, int max_hour, int sign, struct PosixTimezoneOffset *result)
{
int seconds = 0;
int minutes = 0;
@@ -132,11 +135,6 @@ static const char *ParseTime(const char *p, int min_hour, int max_hour, int sign
result->minutes = minutes;
result->hours = hours;
result->time = seconds;
result->time += minutes * 60;
result->time += hours * 60 * 60;
result->time *= sign;
return p;
}
@@ -197,7 +195,6 @@ static const char *ParseTransition(const char *p, struct PosixTransition *result
result->offset.hours = 2;
result->offset.minutes = 0;
result->offset.seconds = 0;
result->offset.time = 2 * 60 * 60;
if (*p == '/')
{
@@ -212,7 +209,7 @@ static const char *ParseTransition(const char *p, struct PosixTransition *result
* Parse POSIX TZ string in format:
* std offset dst [offset],start[/time],end[/time]
*/
static bool ParsePosixTz(const char *tz, struct PosixTimeZone *result)
static bool ParsePosixTz(const char *tz, struct PosixTimezone *result)
{
const char *p = tz;
if (*p == ':')
@@ -233,10 +230,11 @@ static bool ParsePosixTz(const char *tz, struct PosixTimeZone *result)
// Default is one hour ahead of std
result->dst.offset.sign = result->std.offset.sign;
result->dst.offset.hours = result->std.offset.hours + 1;
result->dst.offset.hours = (result->dst.offset.sign < 0)
? result->std.offset.hours - 1
: result->std.offset.hours + 1;
result->dst.offset.minutes = result->std.offset.minutes;
result->dst.offset.seconds = result->std.offset.seconds;
result->dst.offset.time = result->std.offset.time + 60 * 60;
if (*p == '\0')
return true;
@@ -252,6 +250,29 @@ static bool ParsePosixTz(const char *tz, struct PosixTimeZone *result)
return p != NULL && *p == '\0';
}
char *PosixTimezoneSignChar(struct PosixLocalTimezone *ptz)
{
static char *positive = "+";
static char *negative = "-";
if (ptz == NULL)
{
return positive;
}
if (ptz->offset.hours == 0 && ptz->offset.minutes == 0 && ptz->offset.seconds == 0)
{
return positive;
}
if (ptz->offset.sign >= 0)
{
return positive;
}
return negative;
}
static int FindWeekDay(int year, int month, int day)
{
int h = 0;
@@ -366,7 +387,12 @@ static ULONG FindTransitionTime(int year, struct PosixTransition *transition)
break;
}
transitionTime += transition->offset.time;
// TODO: Validate sign
transitionTime +=
(transition->offset.sign < 0 ? -1 : 1) *
(transition->offset.hours * 60 * 60 +
transition->offset.minutes * 60 +
transition->offset.seconds * 60);
return transitionTime;
}
@@ -375,17 +401,17 @@ struct PosixTransitionTime *FindNextTransition(time_t now)
{
int i = 0;
if (Globals->Timezone->start.type == 0)
if (Timezone->start.type == 0)
{
return NULL;
}
while (Globals->Timezone->transitions[i].time < now)
while (Timezone->transitions[i].time < now)
{
i++;
}
return &Globals->Timezone->transitions[i];
return &Timezone->transitions[i];
}
static char *GetVariable(const char *variable)
@@ -393,7 +419,7 @@ static char *GetVariable(const char *variable)
unsigned long memsize = 256;
STRPTR var = (STRPTR)variable;
STRPTR buf = (char *)AllocMemSafe(memsize);
STRPTR buf = (STRPTR)AllocStringSafe(memsize);
if (!buf)
{
return NULL;
@@ -401,43 +427,43 @@ static char *GetVariable(const char *variable)
if (GetVar(var, buf, memsize - 1, GVF_GLOBAL_ONLY) > 0)
{
return buf;
return (char *)buf;
}
FreeMemSafe(buf, __FUNCTION__);
FreeMemSafe(buf);
return NULL;
}
void CleanupTimezone(void)
void CleanupPosixTimezone(void)
{
if (Globals->Timezone != NULL)
if (Timezone != NULL)
{
if (Globals->Timezone->std.abbreviation != NULL)
if (Timezone->std.abbreviation != NULL)
{
FreeMemSafe(Globals->Timezone->std.abbreviation, __FUNCTION__);
FreeMemSafe(Timezone->std.abbreviation);
}
if (Globals->Timezone->dst.abbreviation != NULL)
if (Timezone->dst.abbreviation != NULL)
{
FreeMemSafe(Globals->Timezone->dst.abbreviation, __FUNCTION__);
FreeMemSafe(Timezone->dst.abbreviation);
}
FreeMemSafe(Globals->Timezone, __FUNCTION__);
Globals->Timezone = NULL;
FreeMemSafe(Timezone);
Timezone = NULL;
}
}
static void InitFromTZone(void)
{
if (Globals->Timezone->dst.abbreviation != NULL)
if (Timezone->dst.abbreviation != NULL)
{
// DST is present
Globals->Timezone->current.abbreviation = Globals->Timezone->dst.abbreviation;
Globals->Timezone->current.offset = Globals->Timezone->dst.offset;
Timezone->current.abbreviation = Timezone->dst.abbreviation;
Timezone->current.offset = Timezone->dst.offset;
}
else
{
Globals->Timezone->current.abbreviation = Globals->Timezone->std.abbreviation;
Globals->Timezone->current.offset = Globals->Timezone->std.offset;
Timezone->current.abbreviation = Timezone->std.abbreviation;
Timezone->current.offset = Timezone->std.offset;
}
}
@@ -447,14 +473,14 @@ static void BuildTransitionMap()
bool isdst = false;
bool north;
switch (Globals->Timezone->start.type)
switch (Timezone->start.type)
{
case JulianDay:
case JulianDayLeap:
isdst = Globals->Timezone->start.day > Globals->Timezone->end.day;
isdst = Timezone->start.day > Timezone->end.day;
break;
case DayWeekMonth:
isdst = Globals->Timezone->start.month > Globals->Timezone->end.month;
isdst = Timezone->start.month > Timezone->end.month;
break;
default:
return;
@@ -463,8 +489,8 @@ static void BuildTransitionMap()
north = isdst ? false : true;
Globals->Timezone->transitions[0].time = 0;
Globals->Timezone->transitions[0].isdst = isdst;
Timezone->transitions[0].time = 0;
Timezone->transitions[0].isdst = isdst;
for (i = 0; i < 138 / 2; i++)
{
@@ -472,37 +498,37 @@ static void BuildTransitionMap()
isdst = isdst ? false : true;
time = north
? FindTransitionTime(i + 1978, &Globals->Timezone->start)
: FindTransitionTime(i + 1978, &Globals->Timezone->end);
? FindTransitionTime(i + 1978, &Timezone->start)
: FindTransitionTime(i + 1978, &Timezone->end);
Globals->Timezone->transitions[i * 2 + 1].time = time;
Globals->Timezone->transitions[i * 2 + 1].isdst = isdst;
Timezone->transitions[i * 2 + 1].time = time;
Timezone->transitions[i * 2 + 1].isdst = isdst;
isdst = isdst ? false : true;
time = north
? FindTransitionTime(i + 1978, &Globals->Timezone->end)
: FindTransitionTime(i + 1978, &Globals->Timezone->start);
? FindTransitionTime(i + 1978, &Timezone->end)
: FindTransitionTime(i + 1978, &Timezone->start);
Globals->Timezone->transitions[i * 2 + 2].time = time;
Globals->Timezone->transitions[i * 2 + 2].isdst = isdst;
Timezone->transitions[i * 2 + 2].time = time;
Timezone->transitions[i * 2 + 2].isdst = isdst;
}
Globals->Timezone->transitions[137].time = 2147483647;
Globals->Timezone->transitions[137].isdst = false;
Timezone->transitions[137].time = 2147483647;
Timezone->transitions[137].isdst = false;
}
int InitTimezone(void)
int InitPosixTimezone(char **variable)
{
int result = 4;
int result = 5;
char *var;
Globals->Timezone = NULL;
Timezone = NULL;
var = GetVariable("TZ");
if (var == NULL)
{
var = GetVariable("TZONE");
result = 3;
result = 4;
}
if (var == NULL)
@@ -510,18 +536,19 @@ int InitTimezone(void)
return 1;
}
Globals->Timezone = AllocMemSafe(sizeof(struct PosixTimeZone));
*variable = StrDupSafe(var);
Timezone = AllocStructSafe(struct PosixTimezone);
if (!ParsePosixTz(var, Globals->Timezone))
if (!ParsePosixTz(var, Timezone))
{
FreeMemSafe(var, __FUNCTION__);
CleanupTimezone();
return 2;
FreeMemSafe(var);
CleanupPosixTimezone();
return result - 2;
}
FreeMemSafe(var, __FUNCTION__);
FreeMemSafe(var);
if (Globals->Timezone->start.type == 0)
if (Timezone->start.type == 0)
{
InitFromTZone();
}
@@ -533,32 +560,32 @@ int InitTimezone(void)
return result;
}
bool SetTimezone(struct timeval *tv)
bool SetPosixTimezone(struct timeval *tv)
{
int i = 0;
if (Globals->Timezone->start.type == 0)
if (Timezone->start.type == 0)
{
return false;
}
while (Globals->Timezone->transitions[i].time <= tv->tv_secs)
while (Timezone->transitions[i].time <= tv->tv_secs)
{
i++;
}
i--;
if (Globals->Timezone->transitions[i].isdst)
if (Timezone->transitions[i].isdst)
{
Globals->Timezone->current.abbreviation = Globals->Timezone->dst.abbreviation;
Globals->Timezone->current.offset = Globals->Timezone->dst.offset;
Timezone->current.abbreviation = Timezone->dst.abbreviation;
Timezone->current.offset = Timezone->dst.offset;
}
else
{
Globals->Timezone->current.abbreviation = Globals->Timezone->std.abbreviation;
Globals->Timezone->current.offset = Globals->Timezone->std.offset;
Timezone->current.abbreviation = Timezone->std.abbreviation;
Timezone->current.offset = Timezone->std.offset;
}
return true;
}
}
+17 -13
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,19 +27,22 @@
#ifndef POSIXTZ_H_INCLUDED
#define POSIXTZ_H_INCLUDED
#include <time.h>
#include <stddef.h>
#include <stdbool.h>
#include <exec/types.h>
#include <devices/timer.h>
#define JulianDay 1
#define JulianDayLeap 2
#define DayWeekMonth 3
struct PosixTimeZoneOffset
struct PosixTimezoneOffset
{
int sign; // before/after 00:00:00, -1 or 1
int hours; // hours before/after 00:00:00 [0:167]
int minutes; // minutes before/after 00:00:00 [0:59]
int seconds; // seconds before/after 00:00:00 [0:59]
time_t time;
};
struct PosixTransition
@@ -49,7 +52,7 @@ struct PosixTransition
int weekday; // day of week [0:6]
int week; // week of month [1:5]
int month; // month of year [1:12]
struct PosixTimeZoneOffset offset;
struct PosixTimezoneOffset offset;
};
struct PosixTransitionTime
@@ -58,25 +61,26 @@ struct PosixTransitionTime
time_t time;
};
struct PosixLocalTimeZone
struct PosixLocalTimezone
{
char *abbreviation;
struct PosixTimeZoneOffset offset;
struct PosixTimezoneOffset offset;
};
struct PosixTimeZone
struct PosixTimezone
{
struct PosixLocalTimeZone current;
struct PosixLocalTimeZone std;
struct PosixLocalTimeZone dst;
struct PosixLocalTimezone current;
struct PosixLocalTimezone std;
struct PosixLocalTimezone dst;
struct PosixTransition start;
struct PosixTransition end;
struct PosixTransitionTime transitions[138];
};
int InitTimezone(void);
void CleanupTimezone(void);
bool SetTimezone(struct timeval *tv);
int InitPosixTimezone(char **);
void CleanupPosixTimezone(void);
bool SetPosixTimezone(struct timeval *tv);
struct PosixTransitionTime *FindNextTransition(time_t);
char* PosixTimezoneSignChar(struct PosixLocalTimezone *);
#endif
+678
View File
@@ -0,0 +1,678 @@
/*-
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "setting.h"
#include "global.h"
#include "mem.h"
#include "logmod.h"
#define MODULENAME "Settings"
struct AppSettings *Settings;
struct AppSettingKeys *SettingKeys;
static const struct AppSettingKeys SettingKeyStruct = {
.DestinationAddress = KEYWORD_SERVER,
.DestinationPort = KEYWORD_PORT,
.Threshold = KEYWORD_THRESHOLD,
.Interval = KEYWORD_INTERVAL,
.Priority = KEYWORD_PRIORITY,
.PopKey = KEYWORD_POPKEY,
.Popup = KEYWORD_POPUP,
.Readonly = KEYWORD_READONLY,
.Expert = KEYWORD_EXPERT,
.Timeout = KEYWORD_TIMEOUT};
const struct AppSettings DefaultSettings = {
.Type = DefaultSettingType,
.DestinationAddress = (char *)SERVER_DEF,
.DestinationPort = (char *)PORT_DEF,
.Timeout = TIMEOUT_DEF,
.Interval = INTERVAL_DEF,
.PopKey = POPKEY_DEF,
.Popup = POPUP_DEF,
.Readonly = READONLY_DEF,
.Expert = EXPERT_DEF,
.Priority = PRIORITY_DEF,
.Threshold = THRESHOLD_DEF,
.Values = 0xFFFF};
static void SetPrioritySetting(struct AppSettings *, void *);
static void SetIntervalSetting(struct AppSettings *, void *);
static void SetTimeoutSetting(struct AppSettings *, void *);
static void SetThresholdSetting(struct AppSettings *, void *);
static void SetDestinationAddressSetting(struct AppSettings *, void *);
static void SetDestinationPortSetting(struct AppSettings *, void *);
static void SetReadOnlySetting(struct AppSettings *, void *);
static void SetExpertSetting(struct AppSettings *, void *);
static void SetPopupSetting(struct AppSettings *, void *);
static void SetPopKeySetting(struct AppSettings *, void *);
// Keyword order in settingFunctions needs to match order in keyword template
const struct SettingFunc settingFunctions[] = {
{KEYWORD_READONLY, SetReadOnlySetting},
{KEYWORD_EXPERT, SetExpertSetting},
{KEYWORD_SERVER, SetDestinationAddressSetting},
{KEYWORD_PORT, SetDestinationPortSetting},
{KEYWORD_TIMEOUT, SetTimeoutSetting},
{KEYWORD_THRESHOLD, SetThresholdSetting},
{KEYWORD_INTERVAL, SetIntervalSetting},
{KEYWORD_PRIORITY, SetPrioritySetting},
{KEYWORD_POPKEY, SetPopKeySetting},
{KEYWORD_POPUP, SetPopupSetting}};
static const char *prefsFile = "ENV:timekeeper.prefs";
static const char *persistentPrefsFile = "ENVARC:timekeeper.prefs";
static const char *prefsFileSearch = "Searching for preference in %s";
static const char *prefsFileFound = "Found preference file";
static const char *prefsFileNotFound = "Preference file not found";
static const char *prefsFileSave = "Saving preferences in %s";
static const char *fileOpenError = "Could not open preference file";
static const char *fileSaveError = "Could not save preference file";
static const char *fileReadError = "Error while reading file";
static const char *fileWriteError = "Error while writing file";
static const char *unknownSetting = "Found unknown setting in preference file: %s";
static const char *foundSetting = "Found %s in preference file";
static const char *foundWbSetting = "Found tooltype from icon: %s";
static const char *foundCliSetting = "Got %s from CLI";
static const char *integerError = "Value should be an integer: %s";
static const char *yesNoError = "Value should be YES or NO: %s";
static const char *applyDefaultSettings = "Applying default values";
static const char *applyFileSettings = "Applying values from preference file";
static const char *applyCliSettings = "Applying values from CLI";
static const char *applyWbSettings = "Applying values from tooltypes";
static const char *effectiveSettings = "Listing runtime values";
static const char *settingChangedLong = "%s changed: %ld -> %ld";
static const char *settingChangedString = "%s changed: %s -> %s";
static const char *settingSetLong = "%s is already set to %ld";
static const char *settingSetString = "%s is already set to %s";
static const char *settingValueLong = "%s=%ld";
static const char *settingValueString = "%s=%s";
static const char *saveValueLong = "%s=%ld\n";
static const char *saveValueString = "%s=%s\n";
static const char *noValueString = "NO";
static const char *yesValueString = "YES";
#define MAXSETTINGLINELEN 256
static struct AppSettings *fileSettings;
static struct AppSettings *cachedSettings;
void InitSettings(void)
{
Settings = CreateSettings(GlobalSettingType);
SettingKeys = (struct AppSettingKeys *)&SettingKeyStruct;
}
void CleanupSettings(void)
{
FreeSettings(Settings);
}
static char *BooleanAsText(bool value)
{
return (char *)(value ? yesValueString : noValueString);
}
void ShowAppSettings(struct AppSettings *settings)
{
char low[MAXLONGLONGCHARSIZE];
LongLongToStr(settings->Threshold, low);
LogDebug(settingValueString, SettingKeys->Popup, BooleanAsText(settings->Popup));
LogDebug(settingValueString, SettingKeys->PopKey, settings->PopKey);
LogDebug(settingValueLong, SettingKeys->Priority, settings->Priority);
LogDebug(settingValueString, SettingKeys->Threshold, low);
LogDebug(settingValueString, SettingKeys->DestinationAddress, settings->DestinationAddress);
LogDebug(settingValueString, SettingKeys->DestinationPort, settings->DestinationPort);
LogDebug(settingValueLong, SettingKeys->Timeout, settings->Timeout);
LogDebug(settingValueLong, SettingKeys->Interval, settings->Interval);
LogDebug(settingValueString, SettingKeys->Readonly, BooleanAsText(settings->Readonly));
LogDebug(settingValueString, SettingKeys->Expert, BooleanAsText(settings->Expert));
}
void ShowSettings(void)
{
LogDebug(effectiveSettings);
ShowAppSettings(Settings);
}
void LogFoundSetting(long type, const char *name)
{
switch (type)
{
case PrefsSettingType:
LogDebug(foundSetting, name);
break;
case CliSettingType:
LogDebug(foundCliSetting, name);
break;
case WbSettingType:
LogDebug(foundWbSetting, name);
break;
default:
break;
}
}
static void ParseLongSetting(
struct AppSettings *settings,
long flag,
const char *keyword,
long *valueField,
void *value)
{
LogFoundSetting(settings->Type, keyword);
if (settings->Type == CliSettingType)
{
*valueField = *(long *)value;
settings->Values |= flag;
return;
}
if (TryParseLong((char *)value, valueField))
{
settings->Values |= flag;
return;
}
LogWarn(integerError, value);
}
static void ParseBooleanSetting(
struct AppSettings *settings,
long flag,
const char *keyword,
long *valueField,
void *value,
bool yesNo)
{
LogFoundSetting(settings->Type, keyword);
// CLI switch is always a long value
if (settings->Type == CliSettingType && !yesNo)
{
*valueField = (*valueField != 0 ? true : false);
settings->Values |= flag;
return;
}
if (value == NULL || *((const char *)value) == '\0')
{
LogWarn(yesNoError, '\0');
return;
}
if (Stricmp((CONST_STRPTR)noValueString, (CONST_STRPTR)value) == 0 ||
Stricmp((CONST_STRPTR) "0", (CONST_STRPTR)value) == 0)
{
*valueField = false;
settings->Values |= flag;
return;
}
if (Stricmp((CONST_STRPTR)yesValueString, (CONST_STRPTR)value) == 0 ||
Stricmp((CONST_STRPTR) "1", (CONST_STRPTR)value) == 0)
{
*valueField = true;
settings->Values |= flag;
return;
}
LogWarn(yesNoError, value);
}
static void SetPrioritySetting(struct AppSettings *settings, void *value)
{
ParseLongSetting(settings, PrioritySet, SettingKeys->Priority,
&settings->Priority, value);
}
static void SetIntervalSetting(struct AppSettings *settings, void *value)
{
ParseLongSetting(settings, IntervalSet, SettingKeys->Interval,
&settings->Interval, value);
}
static void SetTimeoutSetting(struct AppSettings *settings, void *value)
{
ParseLongSetting(settings, TimeoutSet, SettingKeys->Timeout,
&settings->Timeout, value);
}
static void SetThresholdSetting(struct AppSettings *settings, void *value)
{
LogFoundSetting(settings->Type, SettingKeys->Threshold);
if (TryParseLongLong((char *)value, &settings->Threshold))
{
settings->Values |= ThresholdSet;
return;
}
LogWarn(integerError, value);
}
static void SetDestinationAddressSetting(struct AppSettings *settings, void *value)
{
LogFoundSetting(settings->Type, SettingKeys->DestinationAddress);
settings->DestinationAddress = StrDupSafe((const char *)value);
settings->Values |= DestinationAddressSet;
}
static void SetPopKeySetting(struct AppSettings *settings, void *value)
{
LogFoundSetting(settings->Type, SettingKeys->PopKey);
settings->PopKey = StrDupSafe((const char *)value);
settings->Values |= PopKeySet;
}
static void SetDestinationPortSetting(struct AppSettings *settings, void *value)
{
LogFoundSetting(settings->Type, SettingKeys->DestinationPort);
settings->DestinationPort = StrDupSafe((const char *)value);
settings->Values |= DestinationPortSet;
}
static void SetReadOnlySetting(struct AppSettings *settings, void *value)
{
ParseBooleanSetting(settings, ReadonlySet, SettingKeys->Readonly,
&settings->Readonly, value, true);
}
static void SetExpertSetting(struct AppSettings *settings, void *value)
{
ParseBooleanSetting(settings, ExpertSet, SettingKeys->Expert,
&settings->Expert, value, true);
}
static void SetPopupSetting(struct AppSettings *settings, void *value)
{
ParseBooleanSetting(settings, PopUpSet, SettingKeys->Popup,
&settings->Popup, value, false);
}
static void ParseSetting(struct AppSettings *settings, char *line)
{
char *value;
char *end;
int i;
value = StrChr(line, '=', MAXSETTINGLINELEN);
if (value == NULL)
{
LogWarn(unknownSetting, "No assignment");
return;
}
end = StrChr(value, '\n', MAXSETTINGLINELEN);
if (end == NULL)
{
LogWarn(unknownSetting, "No end of line");
return;
}
*value++ = '\0';
*end = '\0';
for (i = 0; i < KEYWORD_COUNT; i++)
{
if (Stricmp((STRPTR)settingFunctions[i].Name, (STRPTR)line) == 0)
{
settingFunctions[i].Function(settings, (void *)value);
return;
}
}
LogWarn(unknownSetting, line);
}
void LoadSettings(void)
{
struct AppSettings *settings;
const int maxLines = 25;
char line[MAXSETTINGLINELEN];
char message[MAXDOSERRORLEN];
bool eof = false;
int count = 0;
long error;
BPTR file;
LogDebug(prefsFileSearch, prefsFile);
file = Open((STRPTR)prefsFile, MODE_OLDFILE);
if (!file)
{
error = IoErr();
if (error == ERROR_OBJECT_NOT_FOUND)
{
LogWarn(prefsFileNotFound);
}
else
{
Fault(error, (STRPTR)fileOpenError, (STRPTR)message, MAXDOSERRORLEN);
LogWarn(message);
}
return;
}
LogInfo(prefsFileFound);
settings = CreateSettings(PrefsSettingType);
do
{
char *c = (char *)FGets(file, (STRPTR)line, MAXSETTINGLINELEN);
eof = (c == NULL);
if (!eof)
{
ParseSetting(settings, line);
count++;
}
} while (!eof && count < maxLines);
// If NULL is returned for an EOF, IoErr() will return 0.
error = IoErr();
if (error != 0)
{
Fault(error, (STRPTR)fileReadError, (STRPTR)message, MAXDOSERRORLEN);
LogError(message);
}
Close(file);
fileSettings = settings;
}
static void WriteSetting(BPTR file, const char *format, ...)
{
long count;
va_list args;
va_start(args, format);
count = VFPrintf(file, (void *)format, (void *)args);
va_end(args);
if (count <= 0)
{
long error = IoErr();
if (error != 0)
{
char message[MAXDOSERRORLEN];
Fault(error, (STRPTR)fileWriteError, (STRPTR)message, MAXDOSERRORLEN);
LogError(message);
}
}
}
void SaveSettings(bool persist)
{
char low[MAXLONGLONGCHARSIZE];
const char *fileName = persist ? persistentPrefsFile : prefsFile;
BPTR file = Open((STRPTR)fileName, MODE_NEWFILE);
if (!file)
{
char message[MAXDOSERRORLEN];
long error = IoErr();
Fault(error, (STRPTR)fileSaveError, (STRPTR)message, MAXDOSERRORLEN);
LogWarn(message);
return;
}
LogInfo(prefsFileSave, fileName);
LongLongToStr(Settings->Threshold, low);
WriteSetting(file, saveValueString, SettingKeys->Popup, BooleanAsText(Settings->Popup));
WriteSetting(file, saveValueString, SettingKeys->PopKey, Settings->PopKey);
WriteSetting(file, saveValueLong, SettingKeys->Priority, Settings->Priority);
WriteSetting(file, saveValueString, SettingKeys->Threshold, low);
WriteSetting(file, saveValueString, SettingKeys->DestinationAddress, Settings->DestinationAddress);
WriteSetting(file, saveValueString, SettingKeys->DestinationPort, Settings->DestinationPort);
WriteSetting(file, saveValueLong, SettingKeys->Timeout, Settings->Timeout);
WriteSetting(file, saveValueLong, SettingKeys->Interval, Settings->Interval);
WriteSetting(file, saveValueString, SettingKeys->Readonly, BooleanAsText(Settings->Readonly));
WriteSetting(file, saveValueString, SettingKeys->Expert, BooleanAsText(Settings->Expert));
Close(file);
}
struct AppSettings *CreateSettings(long type)
{
struct AppSettings *settings;
settings = AllocStructSafe(struct AppSettings);
settings->Type = type;
return settings;
}
struct AppSettings *CopySettings(const struct AppSettings *settings)
{
struct AppSettings *s = CreateSettings(settings->Type);
CopyMem((void *)settings, s, sizeof(struct AppSettings));
s->DestinationAddress = StrDupSafe(settings->DestinationAddress);
s->DestinationPort = StrDupSafe(settings->DestinationPort);
s->PopKey = StrDupSafe(settings->PopKey);
s->Values = 0xFFFF;
return s;
}
void FreeSettings(struct AppSettings *settings)
{
if (settings->DestinationAddress != NULL)
{
FreeMemSafe(settings->DestinationAddress);
}
if (settings->DestinationPort != NULL)
{
FreeMemSafe(settings->DestinationPort);
}
if (settings->PopKey != NULL)
{
FreeMemSafe(settings->PopKey);
}
FreeMemSafe(settings);
}
static void ApplyLongSetting(
struct AppSettings *settings,
long flag,
const char *keyword,
long *curValue,
long *newValue,
bool quiet)
{
if ((settings->Values & flag) == flag)
{
if (settings->Type == DefaultSettingType)
{
LogDebug(settingValueLong, keyword, *newValue);
}
else if (*curValue != *newValue)
{
LogInfo(settingChangedLong, keyword, *curValue, *newValue);
}
else if (!quiet)
{
LogDebug(settingSetLong, keyword, *newValue);
}
*curValue = *newValue;
}
}
static void ApplyBooleanSetting(
struct AppSettings *settings,
long flag,
const char *keyword,
long *curValue,
long *newValue,
bool quiet)
{
if ((settings->Values & flag) == flag)
{
if (settings->Type == DefaultSettingType)
{
LogDebug(settingValueString, keyword, BooleanAsText(*newValue));
}
else if (*curValue != *newValue)
{
LogInfo(settingChangedString, keyword, BooleanAsText(*curValue), BooleanAsText(*newValue));
}
else if (!quiet)
{
LogDebug(settingSetString, keyword, BooleanAsText(*newValue));
}
*curValue = *newValue;
}
}
static void ApplyStringSetting(
struct AppSettings *settings,
long flag,
const char *keyword,
char **curValue,
char *newValue,
bool quiet)
{
if ((settings->Values & flag) == flag)
{
if (settings->Type == DefaultSettingType)
{
LogDebug(settingValueString, keyword, newValue);
}
else if (Stricmp((STRPTR)*curValue, (STRPTR)newValue) != 0)
{
LogInfo(settingChangedString, keyword, *curValue, newValue);
}
else if (!quiet)
{
LogDebug(settingSetString, keyword, newValue);
}
if (*curValue != NULL)
{
FreeMemSafe(*curValue);
}
*curValue = StrDupSafe(newValue);
}
}
void ApplyAppSettings(struct AppSettings *settings, bool quiet)
{
switch (settings->Type)
{
case DefaultSettingType:
LogInfo(applyDefaultSettings);
break;
case PrefsSettingType:
LogInfo(applyFileSettings);
break;
case CliSettingType:
LogInfo(applyCliSettings);
break;
case WbSettingType:
LogInfo(applyWbSettings);
break;
default:
break;
}
ApplyBooleanSetting(settings, PopUpSet, SettingKeys->Popup,
&Settings->Popup, &settings->Popup, quiet);
ApplyStringSetting(settings, PopKeySet, SettingKeys->PopKey,
&Settings->PopKey, settings->PopKey, quiet);
ApplyLongSetting(settings, PrioritySet, SettingKeys->Priority,
&Settings->Priority, &settings->Priority, quiet);
ApplyLongSetting(settings, TimeoutSet, SettingKeys->Timeout,
&Settings->Timeout, &settings->Timeout, quiet);
ApplyLongSetting(settings, IntervalSet, SettingKeys->Interval,
&Settings->Interval, &settings->Interval, quiet);
ApplyBooleanSetting(settings, ReadonlySet, SettingKeys->Readonly,
&Settings->Readonly, &settings->Readonly, quiet);
ApplyBooleanSetting(settings, ExpertSet, SettingKeys->Expert,
&Settings->Expert, &settings->Expert, quiet);
ApplyStringSetting(settings, DestinationAddressSet, SettingKeys->DestinationAddress,
&Settings->DestinationAddress, settings->DestinationAddress, quiet);
ApplyStringSetting(settings, DestinationPortSet, SettingKeys->DestinationPort,
&Settings->DestinationPort, settings->DestinationPort, quiet);
if ((settings->Values & ThresholdSet) == ThresholdSet)
{
char before[MAXLONGLONGCHARSIZE];
char after[MAXLONGLONGCHARSIZE];
if (settings->Type == DefaultSettingType)
{
LongLongToStr(settings->Threshold, after);
LogDebug(settingValueString, SettingKeys->Threshold, after);
}
else if (Settings->Threshold != settings->Threshold)
{
LongLongToStr(Settings->Threshold, before);
LongLongToStr(settings->Threshold, after);
LogInfo(settingChangedString, SettingKeys->Threshold, before, after);
}
else if (!quiet)
{
LongLongToStr(Settings->Threshold, before);
LogDebug(settingSetString, SettingKeys->Threshold, before);
}
Settings->Threshold = settings->Threshold;
}
}
void CacheSettings(struct AppSettings *settings)
{
if (cachedSettings != NULL)
{
FreeSettings(cachedSettings);
}
cachedSettings = settings;
}
void ApplySettings()
{
ApplyAppSettings((struct AppSettings *)&DefaultSettings, false);
if (fileSettings != NULL)
{
ApplyAppSettings(fileSettings, false);
FreeSettings(fileSettings);
}
if (cachedSettings != NULL)
{
ApplyAppSettings(cachedSettings, false);
FreeSettings(cachedSettings);
}
}
+106
View File
@@ -0,0 +1,106 @@
/*-
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef STATE_H_INCLUDED
#define STATE_H_INCLUDED
#include "config.h"
#include "locale.h"
#define PrioritySet 0x001
#define TimeoutSet 0x004
#define IntervalSet 0x008
#define ReadonlySet 0x010
#define ExpertSet 0x020
#define DestinationAddressSet 0x040
#define DestinationPortSet 0x080
#define ThresholdSet 0x100
#define PopKeySet 0x200
#define PopUpSet 0x400
#define DefaultSettingType 0x01
#define PrefsSettingType 0x02
#define CliSettingType 0x03
#define WbSettingType 0x04
#define GlobalSettingType 0x10
struct AppSettings
{
long Priority;
long Timeout;
long Interval;
long Readonly;
long Expert;
long long Threshold;
char *DestinationAddress;
char *DestinationPort;
char *PopKey;
long Popup;
long Values;
long Type;
};
struct AppSettingKeys
{
const char *Priority;
const char *Timeout;
const char *Interval;
const char *Readonly;
const char *Expert;
const char *DestinationAddress;
const char *DestinationPort;
const char *Threshold;
const char *PopKey;
const char *Popup;
};
typedef void (*ParseSettingFunction)(struct AppSettings *, void *);
struct SettingFunc
{
const char *Name;
ParseSettingFunction Function;
};
extern struct AppSettings *Settings;
extern struct AppSettingKeys *SettingKeys;
extern const struct SettingFunc settingFunctions[];
extern const struct AppSettings DefaultSettings;
void InitSettings(void);
void CleanupSettings(void);
void ShowSettings(void);
void LoadSettings(void);
void SaveSettings(bool);
struct AppSettings *CreateSettings(long);
struct AppSettings *CopySettings(const struct AppSettings *);
void ApplyAppSettings(struct AppSettings *, bool);
void FreeSettings(struct AppSettings *);
void CacheSettings(struct AppSettings *);
void ApplySettings(void);
#endif
+126
View File
@@ -0,0 +1,126 @@
/*-
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "config.h"
#include "shutdown.h"
#include "message.h"
#include "sync.h"
#include "win.h"
#include "logmod.h"
#define MODULENAME "Shutdown"
static volatile struct ShutdownInfo *info;
static volatile bool ShutdownInProgress = false;
static void ShutdownSettingsWindow(void)
{
int count = 0;
LogTrace("Requesting settings window to close");
SendMessageWait(info->SettingWindowPort, info->ShutdownMessage);
LogTrace("Waiting for settings window to close ...");
while (WindowProcRunning)
{
count++;
if (count % 10 == 0)
{
LogTrace("Waiting for settings window to close ...");
}
Delay(50);
}
LogTrace("Settings window closed");
}
static void ShutdownSynchronizerProcess(void)
{
int count = 0;
LogTrace("Requesting synchronizer process to stop");
SendMessageWait(info->SynchronizerPort, info->ShutdownMessage);
LogTrace("Waiting for synchronizer process to exit ...");
while (SynchronizerRunning)
{
count++;
if (count % 10 == 0)
{
LogTrace("Waiting for synchronizer process to exit ...");
}
Delay(50);
}
LogTrace("Synchronizer process exited");
}
static void ShutdownProc(void)
{
LogDebug("Waiting for synchronizer process to exit");
ShutdownSettingsWindow();
LogDebug("Waiting for synchronizer process to exit");
ShutdownSynchronizerProcess();
LogTrace("Complete");
SendMessageWait(info->BrokerPort, info->ShutdownMessage);
}
void StartShutdown(struct ShutdownInfo *shutdownInfo)
{
struct Task *task;
if (ShutdownInProgress)
{
LogWarn("Shutdown already in progress");
return;
}
ShutdownInProgress = true;
info = shutdownInfo;
LogWarn("Initiating shutdown");
task = (struct Task *)CreateNewProcTags(
NP_Entry, (IPTR)ShutdownProc,
NP_StackSize, 32 * 1024,
NP_Name, 0,
NP_Input, 0,
NP_Output, 0,
NP_Error, 0,
NP_CloseInput, FALSE,
NP_CloseOutput, FALSE,
NP_CloseError, FALSE,
NP_WindowPtr, 0,
NP_ConsoleTask, 0,
NP_Cli, FALSE,
TAG_DONE);
if (task == NULL)
{
LogError("Could not start shutdown procedure");
}
}
+46
View File
@@ -0,0 +1,46 @@
/*-
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef SHUTDOWN_H_INCLUDED
#define SHUTDOWN_H_INCLUDED
#include <exec/ports.h>
#define LOOP_RUNNING 0
#define SHUTDOWN_REQUEST 1
#define SHUTTING_DOWN 2
struct ShutdownInfo
{
struct MsgPort *BrokerPort;
struct MsgPort *SynchronizerPort;
struct MsgPort *SettingWindowPort;
long ShutdownMessage;
};
void StartShutdown(struct ShutdownInfo *);
#endif
+24 -25
View File
@@ -1,7 +1,7 @@
/*-
* Copyright (c) 2007 TANDBERG Telecom AS
* Copyright (c) 2008-2009 Dag-Erling Smørgrav <des@des.no>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -28,12 +28,15 @@
*/
#include "config.h"
#include "time.h"
#include "timer.h"
#include "sntp.h"
#include "mem.h"
#include "net_getaddrinfo.h"
#include "message.h"
#include "logmod.h"
#define MODULENAME "SNTP"
/*
* Convert a struct timeval to an NTP timestamp
*/
@@ -86,10 +89,10 @@ void h2n_ntp(struct ntptime *nt)
struct sntp
{
/* parameters from sntp_create() */
char *srcaddr;
char *srcport;
char *dstaddr;
char *dstport;
STRPTR srcaddr;
STRPTR srcport;
STRPTR dstaddr;
STRPTR dstport;
/* DNS data */
int family;
@@ -122,13 +125,12 @@ sntp_create(const char *dstaddr, const char *dstport,
const char *srcaddr, const char *srcport)
{
struct sntp *sntp;
sntp = AllocMemSafe(sizeof(struct sntp));
sntp = AllocStructSafe(struct sntp);
sntp->sd = -1;
sntp->srcaddr = srcaddr ? StrDupSafe(srcaddr) : NULL;
sntp->srcport = StrDupSafe(srcport ? srcport : "123");
sntp->dstaddr = StrDupSafe(dstaddr);
sntp->dstport = StrDupSafe(dstport ? dstport : "123");
sntp->srcaddr = (STRPTR)((srcaddr != NULL) ? StrDupSafe(srcaddr) : NULL);
sntp->srcport = (STRPTR)StrDupSafe((srcport != NULL) ? srcport : "123");
sntp->dstaddr = (STRPTR)StrDupSafe(dstaddr);
sntp->dstport = (STRPTR)StrDupSafe((dstport != NULL) ? dstport : "123");
/* good to go */
return (sntp);
@@ -172,7 +174,7 @@ int sntp_open(struct sntp *sntp)
if (sntp->sd == -1)
{
SendWarningMessage("Could not get socket descriptor");
LogWarn("Could not get socket descriptor");
freeaddrinfo(aiv);
return (SNTP_SYSERR);
}
@@ -216,7 +218,7 @@ int sntp_open(struct sntp *sntp)
if (connect(sntp->sd, sntp->raddr, sntp->raddrlen) != 0)
{
SendWarningMessage("Could not connect socket");
LogWarn("Could not connect socket");
sntp_close(sntp);
return (SNTP_SYSERR);
}
@@ -246,11 +248,11 @@ void sntp_close(struct sntp *sntp)
sntp->protocol = 0;
if (sntp->laddr)
FreeMemSafe(sntp->laddr, __FUNCTION__);
FreeMemSafe(sntp->laddr);
sntp->laddrlen = 0;
if (sntp->raddr)
FreeMemSafe(sntp->raddr, __FUNCTION__);
FreeMemSafe(sntp->raddr);
sntp->raddrlen = 0;
if (sntp->sd != -1)
@@ -271,22 +273,22 @@ void sntp_destroy(struct sntp *sntp)
(void)sntp_close(sntp);
if (sntp->srcaddr)
FreeMemSafe(sntp->srcaddr, __FUNCTION__);
FreeMemSafe(sntp->srcaddr);
sntp->srcaddr = 0;
if (sntp->srcport)
FreeMemSafe(sntp->srcport, __FUNCTION__);
FreeMemSafe(sntp->srcport);
sntp->srcport = 0;
if (sntp->dstaddr)
FreeMemSafe(sntp->dstaddr, __FUNCTION__);
FreeMemSafe(sntp->dstaddr);
sntp->dstaddr = 0;
if (sntp->dstport)
FreeMemSafe(sntp->dstport, __FUNCTION__);
FreeMemSafe(sntp->dstport);
sntp->dstport = 0;
FreeMemSafe(sntp, __FUNCTION__);
FreeMemSafe(sntp);
}
/*
@@ -428,10 +430,7 @@ sntp_recv(struct sntp *sntp, struct ntptime *nt, int *statum)
/* look for kiss packet */
if (msg.flags == 0xe4 && msg.stratum == 0)
{
char message[SETTINGMESSAGELEN];
SNPrintf(message, SETTINGMESSAGELEN,
"KoD: %.4s", msg.reference_id);
SendWarningMessage(message);
LogWarn("KoD: %.4s", msg.reference_id);
/* NOTICE: Consider taking a closer look at the kiss code */
return (SNTP_BACKOFF);
}
+2 -1
View File
@@ -1,7 +1,7 @@
/*-
* Copyright (c) 2007 TANDBERG Telecom AS
* Copyright (c) 2008-2009 Dag-Erling Smørgrav <des@des.no>
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,7 @@
#define SNTP_H_INCLUDED
#include "config.h"
#include "tz.h"
struct sntp;
+4 -4
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,7 +21,7 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/
#include "config.h"
@@ -141,7 +141,7 @@ char *StrRChr(const char *start, const char c, int len)
/*
* Determine if a prefix occurs at the start of a string.
*/
*/
bool StartsWith(const char *string, const char *prefix)
{
char *i = (char *)string;
@@ -161,7 +161,7 @@ bool StartsWith(const char *string, const char *prefix)
/*
* Determine if a suffix occurs at the end of a string.
*/
*/
bool EndsWith(const char *string, const char *suffix)
{
int a = 0;
+2 -2
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,7 +21,7 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/
#ifndef STRING_H_INCLUDED
+585
View File
@@ -0,0 +1,585 @@
/*-
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <stddef.h>
#include <stdbool.h>
#include "sync.h"
#include "config.h"
#include "global.h"
#include "setting.h"
#include "message.h"
#include "timer.h"
#include "sntp.h"
#include "ptz.h"
#include "mem.h"
#include "net.h"
#include "tz.h"
#include "logmod.h"
#define MODULENAME "Syncer"
#define SYNCPROCNAME APP_SHORT_NAME " Synchronizer"
#define POOLSUFFIX "pool.ntp.org"
#define POOLPORT "123"
struct AppCom
{
struct TimerInfo *TimerInfo;
struct sntp *Client;
int TimerSigBit;
bool Restart;
bool FirstRun;
bool SocketOpen;
int RunCount;
int FailCount;
int PoolServerNumber;
char *ServerName;
char *ServerPort;
};
static void SyncProc(void);
static void ComOpen(void);
static void ComInit(void);
static int SyncClock(void);
static void ShowStats(void);
static void CheckTimezone(void);
static const char *SntpErrorText(enum sntp_err error);
static struct AppCom Synchronizer;
volatile bool SynchronizerRunning = false;
volatile struct timeval LastSync = {0, 0};
void StartSynchronizer(void)
{
bool running;
struct Task *task;
Forbid();
running = SynchronizerRunning;
if (!running)
{
task = (struct Task *)CreateNewProcTags(
NP_Entry, (IPTR)SyncProc,
NP_Name, (IPTR)SYNCPROCNAME,
NP_StackSize, 64 * 1024,
NP_Input, 0,
NP_Output, 0,
NP_Error, 0,
NP_CloseInput, FALSE,
NP_CloseOutput, FALSE,
NP_CloseError, FALSE,
NP_WindowPtr, 0,
NP_ConsoleTask, 0,
NP_Cli, FALSE,
TAG_DONE);
SynchronizerRunning = (task != NULL);
}
Permit();
if (running)
{
LogDebug("Synchronizer process is already running");
}
else if (task != NULL)
{
LogDebug("Created synchronizer process");
}
else
{
LogError("Failed to create synchronizer process");
}
}
static void ComDestroy(void)
{
if (Synchronizer.Client != NULL)
{
sntp_destroy(Synchronizer.Client);
Synchronizer.Client = NULL;
}
}
static void ShowLocalTime(void)
{
char *time = GetTimeText(AppLocale, LOCAL_TIME_NOW);
LogInfo("Local time is %s", time);
FreeMemSafe(time);
}
static void MsgLoop(void)
{
bool loop = true;
bool restart = false;
ULONG userPortSigMask = (1 << Ports.SyncerPort->mp_SigBit);
ULONG timerSigMask = (1 << Synchronizer.TimerSigBit);
ULONG sigMask = userPortSigMask | timerSigMask;
ComOpen();
do
{
ULONG sigrcvd = Wait(sigMask);
if (sigrcvd & timerSigMask)
{
ComOpen();
ShowStats();
}
if (sigrcvd & userPortSigMask)
{
struct ApplicationMesage *msg;
while ((msg = (struct ApplicationMesage *)GetMsg(Ports.SyncerPort)))
{
switch (msg->MsgId)
{
case ATK_SHUTDOWN:
loop = false;
break;
case ATK_RESTART:
restart = true;
break;
default:
break;
}
ReplyMsg((struct Message *)msg);
}
}
if (loop && restart)
{
struct timeval tv;
tv.tv_secs = Settings->Interval / 1000;
tv.tv_micro = Settings->Interval % 1000;
SetInterruptTimerInterval(Synchronizer.TimerInfo, &tv);
ComDestroy();
Synchronizer.Restart = true;
ComOpen();
ShowStats();
restart = false;
}
} while (loop);
ComDestroy();
}
static void SyncProc(void)
{
struct timeval tv;
Synchronizer.TimerInfo = NULL;
Synchronizer.Client = NULL;
Synchronizer.TimerSigBit = -1;
Synchronizer.Restart = false;
Synchronizer.FirstRun = true;
Synchronizer.SocketOpen = false;
Synchronizer.RunCount = 0;
Synchronizer.FailCount = 0;
Synchronizer.PoolServerNumber = -1;
Synchronizer.ServerName = NULL;
Synchronizer.ServerPort = NULL;
Synchronizer.TimerSigBit = AllocSignal(-1);
if (Synchronizer.TimerSigBit == -1)
{
LogError("Could not allocate signal for synchronizer");
return;
}
Ports.SyncerPort = CreateMsgPort();
if (Ports.SyncerPort == NULL)
{
LogError("Could not allocate port for synchronizer");
FreeSignal(Synchronizer.TimerSigBit);
return;
}
Synchronizer.TimerInfo = CreateInterruptTimer(
FindTask(NULL), Synchronizer.TimerSigBit);
if (Synchronizer.TimerInfo == NULL)
{
LogError("Could not create timer for synchronizer");
FreeSignal(Synchronizer.TimerSigBit);
DeleteMsgPort(Ports.SyncerPort);
Ports.SyncerPort = NULL;
return;
}
tv.tv_secs = Settings->Interval / 1000;
tv.tv_micro = Settings->Interval % 1000;
SetInterruptTimerInterval(Synchronizer.TimerInfo, &tv);
StartInterruptTimer(Synchronizer.TimerInfo);
MsgLoop();
LogTrace("Loop exiting");
DeleteTimer(Synchronizer.TimerInfo);
FreeSignal(Synchronizer.TimerSigBit);
CloseSocketLibrary();
CleanupVolMsgPort(&Ports.SyncerPort);
if (Synchronizer.ServerName != NULL)
{
FreeMemSafe(Synchronizer.ServerName);
Synchronizer.ServerName = NULL;
LogTrace("ServerName cleared");
}
if (Synchronizer.ServerPort != NULL)
{
FreeMemSafe(Synchronizer.ServerPort);
Synchronizer.ServerPort = NULL;
LogTrace("ServerPort cleared");
}
Synchronizer.TimerInfo = NULL;
LogTrace("Loop exited");
SynchronizerRunning = false;
}
static void ComOpen(void)
{
if (OpenSocketLibrary() != LIB_OK)
{
Synchronizer.SocketOpen = false;
return;
}
Synchronizer.SocketOpen = true;
if (Synchronizer.FirstRun)
{
LogInfo("Starting SNTP client");
ComInit();
Synchronizer.FirstRun = false;
}
if (Synchronizer.Restart)
{
LogInfo("Restart SNTP client");
ComInit();
Synchronizer.Restart = false;
}
if (SyncClock() == COM_OK)
{
Synchronizer.FailCount = 0;
}
else
{
Synchronizer.FailCount++;
}
if (Synchronizer.FailCount != 0 && Synchronizer.FailCount % 5 == 0)
{
ComDestroy();
Synchronizer.Restart = true;
}
if (Synchronizer.FailCount == 10)
{
LogInfo("Reinitialize socket library");
ComDestroy();
CloseSocketLibrary();
Synchronizer.FailCount = 0;
}
}
static void ShowStats(void)
{
if (Synchronizer.SocketOpen)
{
LogDebug("Sending next NTP request in %ld milliseconds",
Settings->Interval);
}
else
{
LogDebug("Retry in %ld milliseconds", Settings->Interval);
}
Synchronizer.RunCount++;
if (Synchronizer.RunCount % 10 == 0)
{
ShowLocalTime();
}
if (Synchronizer.RunCount % 25 == 0)
{
long blocks, size;
MemUsage(&blocks, &size, NULL);
LogInfo("Currently using %ld bytes in %ld blocks on heap", size, blocks);
}
}
static void ChooseServer(void)
{
int i;
char *server = Settings->DestinationAddress;
int len = StrLen(server);
bool isPool = EndsWith(server, POOLSUFFIX) &&
!StartsWith(server, "0.") &&
!StartsWith(server, "1.") &&
!StartsWith(server, "2.") &&
!StartsWith(server, "3.");
if (Synchronizer.ServerName != NULL)
{
FreeMemSafe(Synchronizer.ServerName);
}
if (Synchronizer.ServerPort != NULL)
{
FreeMemSafe(Synchronizer.ServerPort);
}
if (!isPool)
{
Synchronizer.ServerName = StrDupSafe(server);
Synchronizer.ServerPort = StrDupSafe(Settings->DestinationPort);
return;
}
Synchronizer.ServerName = AllocStringSafe(len + 3);
Synchronizer.ServerPort = StrDupSafe(POOLPORT);
do
{
i = RandomFast() % 4;
} while (i < 0 || i == Synchronizer.PoolServerNumber);
Synchronizer.PoolServerNumber = i;
SNPrintf(Synchronizer.ServerName, len + 3, "%ld.%s", i, server);
LogWarn("Choosing pool server %s", Synchronizer.ServerName);
}
static void ComInit(void)
{
if (Synchronizer.Client != NULL)
{
sntp_destroy(Synchronizer.Client);
Synchronizer.Client = NULL;
}
ChooseServer();
Synchronizer.Client = sntp_create(
Synchronizer.ServerName,
Synchronizer.ServerPort,
NULL,
NULL);
if (Synchronizer.Client == NULL)
{
LogWarn("Could not create SNTP client");
return;
}
}
static void UpdateWindow(void)
{
bool send = false;
struct TimeMessage *message = AllocStructSafe(struct TimeMessage);
Forbid();
if (Ports.WindowPort != NULL && Ports.MemoryPort != NULL)
{
message->AppMsg.Msg.mn_Node.ln_Type = NT_MESSAGE;
message->AppMsg.Msg.mn_Length = sizeof(struct TimeMessage);
message->AppMsg.Msg.mn_ReplyPort = Ports.MemoryPort;
message->AppMsg.MsgType = MSGTYPE_TIMEVAL;
message->TimeVal = LastSync;
PutMsg(Ports.WindowPort, (struct Message *)message);
send = true;
}
Permit();
if (!send)
{
FreeMemSafe(message);
}
}
static int SyncClock(void)
{
struct timeval rtv, ltv, tv;
long long lt, rt, dt, adt, th;
struct ntptime nt;
bool readOnly;
int ret;
int stratum;
th = Settings->Threshold;
readOnly = Settings->Readonly;
LogInfo("Sending request to %s:%s",
Synchronizer.ServerName,
Synchronizer.ServerPort);
ret = sntp_send(Synchronizer.Client);
if (ret != SNTP_OK)
{
LogInfo("SNTP send failed: %s", SntpErrorText(ret));
if (ret == SNTP_DNSERR || ret == SNTP_SYSERR)
{
Synchronizer.Restart = true;
}
return COM_ERROR;
}
ret = sntp_poll(Synchronizer.Client, Settings->Timeout);
if (ret != SNTP_OK)
{
LogWarn("SNTP poll failed: %s", SntpErrorText(ret));
return COM_ERROR;
}
ret = sntp_recv(Synchronizer.Client, &nt, &stratum);
if (ret != SNTP_OK)
{
LogWarn("SNTP recieve failed: %s", SntpErrorText(ret));
if (ret == SNTP_BACKOFF)
{
LogWarn("Increasing polling interval: %ld -> %ld",
Settings->Interval,
Settings->Interval * 2);
Settings->Interval *= 2;
}
return COM_ERROR;
}
nt2tv(&nt, &rtv);
GetTimeOfDay(&ltv);
lt = 1000000LL * ltv.tv_secs + ltv.tv_micro;
rt = 1000000LL * rtv.tv_secs + rtv.tv_micro;
dt = rt - lt;
adt = dt < 0 ? -dt : dt;
if (!readOnly && adt < th)
{
static char out[MAXLONGLONGCHARSIZE];
static char out2[MAXLONGLONGCHARSIZE];
LogDebug("Stratum %ld server", (unsigned long)stratum);
LongLongToStr(adt, out);
LongLongToStr(th, out2);
LogInfo("%s us < %s us, not setting clock", out, out2);
}
else if (!readOnly)
{
LogDebug("Stratum %ld server", (unsigned long)stratum);
tv.tv_secs = rt / 1000000;
tv.tv_micro = rt % 1000000;
SetTimeOfDay(Synchronizer.TimerInfo, &tv);
{ // Log after setting clock
static char out[MAXLONGLONGCHARSIZE];
static char out2[MAXLONGLONGCHARSIZE];
LongLongToStr(adt, out);
LongLongToStr(th, out2);
LogWarn("%s us > %s us, setting software clock", out, out2);
if (BattClockBase != NULL)
{
LogWarn("Setting hardware clock");
SaveTimeOfDay(&tv);
}
}
}
{
static char out[MAXLONGLONGCHARSIZE];
LongLongToStr(rt, out);
LogDebug("True time %s", out);
LongLongToStr(lt, out);
LogDebug("Kernel time %s", out);
LongLongToStr(dt, out);
LogDebug("Delta %s", out);
}
LastSync = rtv;
UpdateWindow();
CheckTimezone();
return COM_OK;
}
static void CheckTimezone(void)
{
struct timeval tv;
ULONG now;
if (NextTransition == NULL)
{
return;
}
GetSysTime(&tv);
now = (ULONG)(tv.tv_secs);
if (now > NextTransition->time)
{
char Timezone[TIMEZONE_TEXT_LEN];
GetTimezoneText(AppLocale, Timezone, OFFSET_IN_PARENS);
ShowLocalTime();
LogWarn("Current Timezone is %s", Timezone);
LogWarn("Changing Timezone");
// TODO: Make thread safe
ShowLocalTime();
InitTimezoneShift();
SendMessageTo(Ports.WindowPort, Ports.MemoryPort, ATK_TZ_CHANGED);
}
}
static const char *SntpErrorText(enum sntp_err error)
{
switch (error)
{
case SNTP_OK:
return "OK";
case SNTP_SYSERR:
return GetErrorText();
case SNTP_DNSERR:
return GetHostErrorText();
case SNTP_NOREQ:
return "No request sent";
case SNTP_NORESP:
return "No response received";
case SNTP_BADRESP:
return "Invalid response received";
case SNTP_LAME:
return "Server is lame / unsynchronized";
case SNTP_BACKOFF:
return "Polling too frequently";
default:
return "Unknown error";
}
return "Unknown error";
}
+37
View File
@@ -0,0 +1,37 @@
/*-
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef SYNC_H_INCLUDED
#define SYNC_H_INCLUDED
#include <devices/timer.h>
void StartSynchronizer(void);
extern volatile bool SynchronizerRunning;
extern volatile struct timeval LastSync;
#endif
+366
View File
@@ -0,0 +1,366 @@
/*-
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "config.h"
#include "ptz.h"
#include "timer.h"
#include "mem.h"
#include "tz.h"
#include <exec/interrupts.h>
#include <clib/alib_protos.h>
#include <assert.h>
#include "logmod.h"
#define MODULENAME "Timer"
#define TIMER_ERROR 10
#define TIMER_OK 0
#define TIMER_INTERRUPT_ON 1
#define TIMER_INTERRUPT_OFF 2
#define TIMER_INTERRUPT_STOPPED 3
struct TimerInfo
{
bool InterruptTimer;
bool Trigger;
bool Restart;
long TimerFlag;
struct timeval Interval;
long Counter;
struct MsgPort *TimerPort;
struct Interrupt *TimerInterrupt;
struct timerequest *TimerIO;
struct Task *InterruptTask;
ULONG InterruptSigBit;
};
struct Device *TimerBase = NULL;
static struct timerequest *TimerIO = NULL;
// Only one interrupt timer is allowed
struct TimerInfo *InterruptInfo;
/*
* Set up pointer for timer functions.
*/
struct Device *OpenTimerBase(void)
{
LONG error;
TimerIO = AllocStructSafe(struct timerequest);
if (TimerIO == NULL)
{
return NULL;
}
error = OpenDevice((STRPTR)TIMERNAME, UNIT_MICROHZ, (struct IORequest *)TimerIO, 0);
if (error != 0)
{
FreeMemSafe(TimerIO);
TimerIO = NULL;
return NULL;
}
TimerBase = TimerIO->tr_node.io_Device;
return TimerBase;
}
void CloseTimerBase(void)
{
if (TimerBase != NULL && TimerIO != NULL)
{
CloseDevice((struct IORequest *)TimerIO);
}
if (TimerIO != NULL)
{
FreeMemSafe(TimerIO);
}
}
void SetTime(const struct timeval *tv)
{
assert(tv != NULL);
// Notice: Method is not thread safe.
TimerIO->tr_node.io_Command = TR_SETSYSTIME;
TimerIO->tr_time.tv_secs = (long)tv->tv_secs;
TimerIO->tr_time.tv_micro = tv->tv_micro;
DoIO((struct IORequest *)TimerIO);
}
static void TimerInterruptCode(void)
{
struct TimerInfo *info;
struct timerequest *tr;
info = InterruptInfo;
tr = (struct timerequest *)GetMsg(info->TimerPort);
if ((tr) && (info->TimerFlag == TIMER_INTERRUPT_ON))
{
if (info->Restart)
{
info->Counter = 0;
info->Trigger = false;
info->Restart = false;
tr->tr_time.tv_secs = 1;
tr->tr_time.tv_micro = 0;
}
else if (info->Trigger)
{
Signal(info->InterruptTask, info->InterruptSigBit);
info->Counter = 0;
info->Trigger = false;
tr->tr_time.tv_secs = 1;
tr->tr_time.tv_micro = 0;
}
else
{
info->Counter++;
if (info->Counter == info->Interval.tv_secs)
{
tr->tr_time.tv_secs = 0;
tr->tr_time.tv_micro = info->Interval.tv_micro;
info->Trigger = true;
}
else
{
tr->tr_time.tv_secs = 1;
tr->tr_time.tv_micro = 0;
}
}
tr->tr_node.io_Command = TR_ADDREQUEST;
BeginIO((struct IORequest *)tr);
}
else
{
info->TimerFlag = TIMER_INTERRUPT_STOPPED;
}
}
void SetInterruptTimerInterval(struct TimerInfo *info, struct timeval *tv)
{
info->Interval.tv_secs = tv->tv_secs;
info->Interval.tv_micro = tv->tv_micro;
if (info->Interval.tv_micro == 0)
{
info->Interval.tv_micro = 2;
}
info->Restart = true;
}
void StartInterruptTimer(struct TimerInfo *info)
{
assert(info != NULL);
if (!info->InterruptTimer)
{
return;
}
info->TimerFlag = TIMER_INTERRUPT_ON;
info->Trigger = false;
info->Restart = false;
info->TimerIO->tr_node.io_Command = TR_ADDREQUEST;
info->TimerIO->tr_time.tv_secs = 1;
info->TimerIO->tr_time.tv_micro = 0;
BeginIO((struct IORequest *)info->TimerIO);
}
/*
* Create a Timer device software interrupt as described on wiki.amigaos.net:
* https://wiki.amigaos.net/wiki/Exec_Interrupts#Software_Interrupts
* and Amiga Developer Docs 2.1, lib_examples/timersoftint.c
*/
struct TimerInfo *CreateInterruptTimer(struct Task *task, short sigBit)
{
LONG error;
struct TimerInfo *info = AllocStructSafe(struct TimerInfo);
if (info == NULL)
return NULL;
info->InterruptTimer = true;
info->InterruptTask = task;
info->InterruptSigBit = 1 << sigBit;
info->TimerPort = AllocStructSafe(struct MsgPort);
if (info->TimerPort == NULL)
{
DeleteTimer(info);
return NULL;
}
info->TimerInterrupt = AllocStructSafe(struct Interrupt);
if (info->TimerInterrupt == NULL)
{
DeleteTimer(info);
return NULL;
}
NewList(&(info->TimerPort->mp_MsgList));
info->TimerPort->mp_Node.ln_Type = NT_MSGPORT;
info->TimerPort->mp_Flags = PA_SOFTINT;
info->TimerPort->mp_SigTask = (struct Task *)info->TimerInterrupt;
info->TimerInterrupt->is_Code = TimerInterruptCode;
info->TimerInterrupt->is_Data = info;
info->TimerInterrupt->is_Node.ln_Pri = 0;
info->TimerIO = (struct timerequest *)CreateExtIO(info->TimerPort, sizeof(struct timerequest));
if (info->TimerIO == NULL)
{
DeleteTimer(info);
return NULL;
}
error = OpenDevice(
(STRPTR)TIMERNAME, UNIT_MICROHZ,
(struct IORequest *)info->TimerIO, 0);
if (error != 0)
{
DeleteTimer(info);
return NULL;
}
// Only one interrupt timer is supported
InterruptInfo = info;
return info;
}
/*
* Open a timer device with UNIT_MICROHZ.
*/
struct TimerInfo *CreateTimer(void)
{
LONG error;
static const char *name = APP_SHORT_NAME " Timer Message Port";
struct TimerInfo *info = AllocStructSafe(struct TimerInfo);
if (info == NULL)
return NULL;
info->TimerPort = CreateMsgPort();
if (info->TimerPort == NULL)
{
DeleteTimer(info);
return NULL;
}
info->TimerPort->mp_Node.ln_Name = (char *)name;
info->TimerPort->mp_Node.ln_Pri = 0;
info->TimerIO = (struct timerequest *)CreateExtIO(info->TimerPort, sizeof(struct timerequest));
if (info->TimerIO == NULL)
{
DeleteTimer(info);
return NULL;
}
error = OpenDevice(
(STRPTR)TIMERNAME, UNIT_MICROHZ,
(struct IORequest *)info->TimerIO, 0);
if (error != 0)
{
DeleteTimer(info);
return NULL;
}
return info;
}
void DeleteTimer(struct TimerInfo *info)
{
if (info == NULL)
{
return;
}
if (info->TimerIO != NULL)
{
if (info->TimerInterrupt)
{
info->TimerFlag = TIMER_INTERRUPT_OFF;
while (info->TimerFlag != TIMER_INTERRUPT_STOPPED)
{
Delay(10);
}
}
else
{
if (!(CheckIO((struct IORequest *)info->TimerIO)))
{
AbortIO((struct IORequest *)info->TimerIO);
}
WaitIO((struct IORequest *)info->TimerIO);
}
CloseDevice((struct IORequest *)info->TimerIO);
DeleteExtIO((struct IORequest *)info->TimerIO);
info->TimerIO = NULL;
}
if (info->TimerPort != NULL)
{
if (info->InterruptTimer)
{
FreeMemSafe(info->TimerPort);
}
else
{
DeleteMsgPort(info->TimerPort);
}
}
if (info->TimerInterrupt != NULL)
{
FreeMemSafe(info->TimerInterrupt);
}
FreeMemSafe(info);
}
static int seed = 123456789;
void SeedRandom(void)
{
struct timeval tv;
GetLocalTimeOfDay(&tv);
seed = tv.tv_micro;
}
int RandomFast(void)
{
seed = (1103515245 * seed + 12345) % 0x7fffffff;
return seed;
}
+45
View File
@@ -0,0 +1,45 @@
/*-
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef TIME_H_INCLUDED
#define TIME_H_INCLUDED
#include "config.h"
struct TimerInfo;
struct Device *OpenTimerBase(void);
void CloseTimerBase(void);
struct TimerInfo *CreateTimer(void);
struct TimerInfo *CreateInterruptTimer(struct Task *, short);
void StartInterruptTimer(struct TimerInfo *);
void SetInterruptTimerInterval(struct TimerInfo *, struct timeval *);
void DeleteTimer(struct TimerInfo *);
void SetTime(const struct timeval *);
void SeedRandom(void);
int RandomFast(void);
#endif
+297
View File
@@ -0,0 +1,297 @@
/*-
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "config.h"
#include "notify.h"
#include "global.h"
#include "message.h"
#include "ptz.h"
#include "timer.h"
#include "mem.h"
#include "tz.h"
#include <assert.h>
#include "logmod.h"
#define MODULENAME "Timezone"
/*
* 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 AMIGA_OFFSET 252460800
#define SECONDSPERDAY 86400
static long unixEpochOffset = 0;
void LogTzInfo()
{
if (Timezone == NULL)
{
return;
}
if (Timezone->dst.abbreviation != NULL)
{
LogInfo("Standard Timezone is %s (UTC%s%02ld:%02ld)",
Timezone->std.abbreviation,
PosixTimezoneSignChar(&Timezone->std),
(long)Timezone->std.offset.hours,
(long)Timezone->std.offset.minutes);
LogInfo("DST Timezone is %s (UTC%s%02ld:%02ld)",
Timezone->dst.abbreviation,
PosixTimezoneSignChar(&Timezone->dst),
(long)Timezone->dst.offset.hours,
(long)Timezone->dst.offset.minutes);
}
else
{
LogInfo("Timezone is %s (UTC%s%02ld:%02ld)",
Timezone->std.abbreviation,
PosixTimezoneSignChar(&Timezone->std),
(long)Timezone->std.offset.hours,
(long)Timezone->std.offset.minutes);
}
}
void InitTimezone(void)
{
char TimezoneText[TIMEZONE_TEXT_LEN];
char *tz;
int result;
WatchFile("ENV:TZ", ATK_TZ_CHANGED);
WatchFile("ENV:TZONE", ATK_TZONE_CHANGED);
WatchFile("ENV:Sys/locale.prefs", ATK_LOCALE_CHANGED);
tz = NULL;
result = InitPosixTimezone(&tz);
switch (result)
{
case 1:
LogInfo("No TZ or TZONE variable found");
break;
case 2:
LogInfo("Found unknown TZONE variable");
LogDebug("TZONE = %s", tz);
break;
case 3:
LogInfo("Found unknown TZ variable");
LogDebug("TZ = %s", tz);
break;
case 4:
LogInfo("Found valid TZONE variable");
LogDebug("TZONE = %s", tz);
break;
case 5:
LogInfo("Found valid TZ variable");
LogDebug("TZ = %s", tz);
break;
default:
LogWarn("Unknown TZ or TZONE code");
break;
}
if (tz != NULL)
{
FreeMemSafe(tz);
}
if (result == 4 || result == 5)
{
struct timeval tv;
GetSysTime(&tv);
SetPosixTimezone(&tv);
LogTzInfo();
unixEpochOffset =
(Timezone->current.offset.sign < 0 ? +1 : -1) *
(Timezone->current.offset.hours * 60 * 60 +
Timezone->current.offset.minutes * 60 +
Timezone->current.offset.seconds);
unixEpochOffset += AMIGA_OFFSET;
GetTimezoneText(AppLocale, TimezoneText, OFFSET_IN_PARENS);
LogWarn("Current Timezone is %s", TimezoneText);
}
else
{
unixEpochOffset = AppLocale->AmigaLocale->loc_GMTOffset * 60 + AMIGA_OFFSET;
GetTimezoneText(AppLocale, TimezoneText, OFFSET_IN_PARENS);
LogWarn("Current Timezone is %s", TimezoneText);
}
InitTimezoneShift();
}
void Amiga2DateStamp(time_t *time, struct DateStamp *date)
{
long t, d, m, q;
t = *time;
d = t / SECONDSPERDAY;
m = (t - SECONDSPERDAY * d) / 60;
q = (t - SECONDSPERDAY * d - m * 60) * 60;
date->ds_Days = d;
date->ds_Minute = m;
date->ds_Tick = q;
}
void InitTimezoneShift(void)
{
struct PosixTransitionTime *transition;
struct timeval tv;
char *nextTime;
char *nextTrans;
time_t next;
ULONG now;
if (Timezone == NULL || Timezone->start.type == 0)
{
NextTransition = NULL;
return;
}
/*
{
int i;
for (i = 0; i < 138; i++)
{
transition = &Timezone->transitions[i];
next = transition->time;
Amiga2DateStamp(&next, &ds);
DateTimeString(&ds, timeString, dateString, dayString);
LogWarn("XChanging (%ld) to %s time on %s %s at %s %s",
next,
transition->isdst ? "DST" : "standard",
dayString, dateString, timeString,
transition->isdst
? Timezone->std.abbreviation
: Timezone->dst.abbreviation);
}
}
*/
GetSysTime(&tv);
now = (ULONG)(tv.tv_secs);
transition = FindNextTransition(now);
if (transition == NULL)
{
NextTransition = NULL;
return;
}
if (NextTransition != NULL)
{
FreeMemSafe(NextTransition);
}
NextTransition = transition;
next = transition->time;
nextTime = GetTimeText(AppLocale, next);
nextTrans = transition->isdst ? "DST" : "standard time";
LogWarn("Changing to %s on %s", nextTrans, nextTime);
FreeMemSafe(nextTime);
}
void CleanupTimezone(void)
{
CleanupPosixTimezone();
}
void Unix2Amiga(struct timeval *unix, struct timeval *tv)
{
assert(unix != NULL);
assert(tv != NULL);
tv->tv_secs = unix->tv_secs + AMIGA_OFFSET;
tv->tv_micro = unix->tv_micro;
}
void Utc2Local(struct timeval *utc, struct timeval *tv)
{
assert(utc != NULL);
assert(tv != NULL);
// TODO: Validate
tv->tv_secs = utc->tv_secs - (unixEpochOffset - AMIGA_OFFSET);
tv->tv_micro = utc->tv_micro;
}
void GetTimeOfDay(struct timeval *tv)
{
assert(tv != NULL);
GetSysTime(tv);
tv->tv_secs = tv->tv_secs + unixEpochOffset;
}
void GetLocalTimeOfDay(struct timeval *tv)
{
assert(tv != NULL);
GetSysTime(tv);
}
void SetTimeOfDay(const struct TimerInfo *info, const struct timeval *tv)
{
struct timeval t;
assert(tv != NULL);
t.tv_secs = tv->tv_secs - unixEpochOffset;
t.tv_micro = tv->tv_micro;
SetTime(&t);
}
void SaveTimeOfDay(const struct timeval *tv)
{
assert(tv != NULL);
WriteBattClock((long)tv->tv_secs - unixEpochOffset);
}
void DateTimeString(struct DateStamp *ds, char *time, char *date, char *day)
{
struct DateTime dt;
assert(ds != NULL);
assert(time != NULL);
assert(date != NULL);
assert(day != NULL);
dt.dat_Stamp = *ds;
dt.dat_Format = FORMAT_DOS;
dt.dat_Flags = 0;
dt.dat_StrDay = (void *)day;
dt.dat_StrDate = (void *)date;
dt.dat_StrTime = (void *)time;
DateToStr(&dt);
}
+43
View File
@@ -0,0 +1,43 @@
/*-
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef TZ_H_INCLUDED
#define TZ_H_INCLUDED
#include "config.h"
#include "timer.h"
void InitTimezone(void);
void InitTimezoneShift(void);
void CleanupTimezone(void);
void GetTimeOfDay(struct timeval *);
void SetTimeOfDay(const struct TimerInfo *, const struct timeval *);
void SaveTimeOfDay(const struct timeval *);
void GetLocalTimeOfDay(struct timeval *);
void Unix2Amiga(struct timeval *, struct timeval *);
void Utc2Local(struct timeval *, struct timeval *t);
#endif
+69 -118
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,163 +21,115 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/
#include "config.h"
#include "state.h"
#include "message.h"
#include "setting.h"
#include "log.h"
#include <stdarg.h>
#include "logmod.h"
#define MODULENAME "Validation"
static const char *settingChangedLong = "%s changed: %ld -> %ld";
static const char *settingTooLow = "%s < %ld (too low)";
static const char *settingTooHigh = "%s > %ld (too high)";
static const char *settingGreaterThan = "%s * 2 > %s";
static void LogValidationLine(const char *format, va_list ap)
{
char message[SETTINGMESSAGELEN];
VSNPrintf(message, SETTINGMESSAGELEN - 1, format, ap);
if (Globals->Broker->Task == NULL || FindTask(NULL) == Globals->Broker->Task)
{
LogInfo(message);
}
else
{
SendInfoMessage(message);
}
}
static void LogValidation(const char *format, ...)
{
va_list args;
va_start(args, format);
LogValidationLine(format, args);
va_end(args);
}
static void ValidateInterval(void)
{
if (Globals->Settings->Interval < INTERVAL_MIN)
if (Settings->Interval < INTERVAL_MIN)
{
LogValidation(settingTooLow,
SettingKeys->Interval,
INTERVAL_MIN);
LogValidation(settingChangedLong,
SettingKeys->Interval,
Globals->Settings->Interval,
INTERVAL_MIN);
Globals->Settings->Interval = INTERVAL_MIN;
LogInfo(settingTooLow,
SettingKeys->Interval,
INTERVAL_MIN);
LogInfo(settingChangedLong,
SettingKeys->Interval,
Settings->Interval,
INTERVAL_MIN);
Settings->Interval = INTERVAL_MIN;
}
}
static void ValidateTimeout(void)
{
if (Globals->Settings->Timeout < TIMEOUT_MIN)
if (Settings->Timeout < TIMEOUT_MIN)
{
LogValidation(settingTooLow,
SettingKeys->Timeout,
TIMEOUT_MIN);
LogValidation(settingChangedLong,
SettingKeys->Timeout,
Globals->Settings->Timeout,
TIMEOUT_MIN);
Globals->Settings->Timeout = TIMEOUT_MIN;
LogInfo(settingTooLow,
SettingKeys->Timeout,
TIMEOUT_MIN);
LogInfo(settingChangedLong,
SettingKeys->Timeout,
Settings->Timeout,
TIMEOUT_MIN);
Settings->Timeout = TIMEOUT_MIN;
}
if (Globals->Settings->Timeout > Globals->Settings->Interval / 2)
if (Settings->Timeout > Settings->Interval / 2)
{
LogValidation(settingGreaterThan,
SettingKeys->Timeout,
SettingKeys->Interval);
LogValidation(settingChangedLong,
SettingKeys->Timeout,
Globals->Settings->Timeout,
Globals->Settings->Interval / 2);
Globals->Settings->Timeout = Globals->Settings->Interval / 2;
LogInfo(settingGreaterThan,
SettingKeys->Timeout,
SettingKeys->Interval);
LogInfo(settingChangedLong,
SettingKeys->Timeout,
Settings->Timeout,
Settings->Interval / 2);
Settings->Timeout = Settings->Interval / 2;
}
if (Globals->Settings->Timeout > TIMEOUT_MAX)
if (Settings->Timeout > TIMEOUT_MAX)
{
LogValidation(settingTooHigh,
SettingKeys->Timeout,
TIMEOUT_MAX);
LogValidation(settingChangedLong,
SettingKeys->Timeout,
Globals->Settings->Timeout,
TIMEOUT_MAX);
Globals->Settings->Timeout = TIMEOUT_MAX;
LogInfo(settingTooHigh,
SettingKeys->Timeout,
TIMEOUT_MAX);
LogInfo(settingChangedLong,
SettingKeys->Timeout,
Settings->Timeout,
TIMEOUT_MAX);
Settings->Timeout = TIMEOUT_MAX;
}
}
static void ValidatePriority(void)
{
if (Globals->Settings->Priority < PRIORITY_MIN)
if (Settings->Priority < PRIORITY_MIN)
{
LogValidation(settingTooLow,
SettingKeys->Priority,
PRIORITY_MIN);
LogValidation(settingChangedLong,
SettingKeys->Priority,
Globals->Settings->Priority,
PRIORITY_MIN);
Globals->Settings->Priority = PRIORITY_MIN;
LogInfo(settingTooLow,
SettingKeys->Priority,
PRIORITY_MIN);
LogInfo(settingChangedLong,
SettingKeys->Priority,
Settings->Priority,
PRIORITY_MIN);
Settings->Priority = PRIORITY_MIN;
}
if (Globals->Settings->Priority > PRIORITY_MAX)
if (Settings->Priority > PRIORITY_MAX)
{
LogValidation(settingTooHigh,
SettingKeys->Priority,
PRIORITY_MAX);
LogValidation(settingChangedLong,
SettingKeys->Priority,
Globals->Settings->Priority,
PRIORITY_MAX);
Globals->Settings->Priority = PRIORITY_MAX;
LogInfo(settingTooHigh,
SettingKeys->Priority,
PRIORITY_MAX);
LogInfo(settingChangedLong,
SettingKeys->Priority,
Settings->Priority,
PRIORITY_MAX);
Settings->Priority = PRIORITY_MAX;
}
}
static void ValidateThreshold(void)
{
if (Globals->Settings->Threshold < THRESHOLD_MIN)
if (Settings->Threshold < THRESHOLD_MIN)
{
LogValidation(settingTooLow,
SettingKeys->Threshold,
THRESHOLD_MIN);
LogValidation(settingChangedLong,
SettingKeys->Threshold,
Globals->Settings->Threshold,
THRESHOLD_MIN);
Globals->Settings->Threshold = THRESHOLD_MIN;
}
}
static void ValidateVerbose(void)
{
if (Globals->Settings->Verbose < VERBOSE_MIN)
{
LogValidation(settingTooLow,
SettingKeys->Verbose,
VERBOSE_MIN);
LogValidation(settingChangedLong,
SettingKeys->Verbose,
Globals->Settings->Verbose,
VERBOSE_MIN);
Globals->Settings->Verbose = VERBOSE_MIN;
}
if (Globals->Settings->Verbose > VERBOSE_MAX)
{
LogValidation(settingTooHigh,
SettingKeys->Verbose,
VERBOSE_MAX);
LogValidation(settingChangedLong,
SettingKeys->Verbose,
Globals->Settings->Verbose,
VERBOSE_MAX);
Globals->Settings->Verbose = VERBOSE_MAX;
LogInfo(settingTooLow,
SettingKeys->Threshold,
THRESHOLD_MIN);
LogInfo(settingChangedLong,
SettingKeys->Threshold,
Settings->Threshold,
THRESHOLD_MIN);
Settings->Threshold = THRESHOLD_MIN;
}
}
@@ -187,5 +139,4 @@ void SanitizeSettings(void)
ValidateTimeout();
ValidatePriority();
ValidateThreshold();
ValidateVerbose();
}
+28 -13
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,15 +21,15 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/
#ifndef WIN_H_INCLUDED
#define WIN_H_INCLUDED
#include <clib/gadtools_protos.h>
#include <clib/intuition_protos.h>
#include <proto/intuition.h>
#include <clib/gadtools_protos.h>
#include <proto/gadtools.h>
#define GID_SERVER 1001
@@ -37,17 +37,28 @@
#define GID_TIMEOUT 1003
#define GID_INTERVAL 1004
#define GID_THRESHOLD 1005
#define GID_VERBOSE 1006
#define GID_READONLY 1007
#define GID_PRIORITY 1008
#define GID_SAVE 1009
#define GID_USE 1010
#define GID_CANCEL 1011
#define GID_READONLY 1006
#define GID_PRIORITY 1007
#define GID_SAVE 1008
#define GID_USE 1009
#define GID_CANCEL 1010
struct AppSettingWindow
{
struct Screen *Screen;
struct Window *Window;
struct Gadget *GadgetList;
void *VisualInfo;
char *PriorityText;
char *ThresholdText;
char *TimezoneText;
long Width;
long Height;
struct AppSettingWindowGadgets *Gadgets;
};
/* win_main.c */
void ShowSettingWindow(void);
void HideSettingWindow(void);
bool CheckSettingWindowClosed(void);
/* win_gad.c */
bool CreateGadgets(void);
@@ -57,9 +68,13 @@ void SetPort(void);
void SetTimeout(void);
void SetInterval(void);
void SetThreshold(void);
void SetVerbose(void);
void SetCxPriority(void);
void ShowLastSync(void);
void ShowLastSync(struct timeval *tv);
void SetDefaultSettings(void);
void ShowNewTimezone(void);
extern volatile bool WindowProcRunning;
extern struct AppSettings *WindowSettings;
extern struct AppSettingWindow SettingWindow;
#endif
+118 -164
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,11 +25,16 @@
*/
#include "config.h"
#include "global.h"
#include "message.h"
#include "state.h"
#include "time.h"
#include "setting.h"
#include "timer.h"
#include "mem.h"
#include "win.h"
#include "tz.h"
#include "logmod.h"
#define MODULENAME "Window"
struct AppSettingWindowGadgets
{
@@ -38,9 +43,8 @@ struct AppSettingWindowGadgets
struct Gadget *TimeoutGadget;
struct Gadget *IntervalGadget;
struct Gadget *ThresholdGadget;
struct Gadget *VerboseGadget;
struct Gadget *PriorityGadget;
struct Gadget *TimeZoneGadget;
struct Gadget *TimezoneGadget;
struct Gadget *LastSyncGadget;
};
@@ -49,9 +53,8 @@ static const char *portLabel = "Server port";
static const char *timeoutLabel = "Timeout (ms)";
static const char *intervalLabel = "Interval (ms)";
static const char *thresholdLabel = "Threshold (us)";
static const char *verboseLabel = "Verbose level";
static const char *priorityLabel = "CX priority";
static const char *timeZoneLabel = "Time zone";
static const char *TimezoneLabel = "Time zone";
static const char *lastSyncLabel = "Last sync";
static const char *saveLabel = "Save";
static const char *useLabel = "Use";
@@ -63,19 +66,11 @@ static const char **textLabels[] = {
&timeoutLabel,
&intervalLabel,
&thresholdLabel,
&verboseLabel,
&priorityLabel,
&timeZoneLabel,
&TimezoneLabel,
&lastSyncLabel,
NULL};
static char *verboseLevel[] = {
"Show none (0)",
"Show some (1)",
"Show more (2)",
"Show all (3)",
NULL};
int GetLabelWidth(struct RastPort *rp)
{
int len, max = 0;
@@ -85,7 +80,7 @@ int GetLabelWidth(struct RastPort *rp)
while (**label != NULL)
{
c = StrLen(*label);
len = TextLength(rp, *label, c);
len = TextLength(rp, (CONST_STRPTR)*label, c);
if (len > max)
{
max = len;
@@ -108,29 +103,27 @@ bool CreateGadgets(void)
long labelId;
long tmp1, tmp2;
Globals->Window->Gadgets = (struct AppSettingWindowGadgets *)
AllocMemSafe(sizeof(struct AppSettingWindowGadgets));
ng = (struct NewGadget *)AllocMemSafe(sizeof(struct NewGadget));
SettingWindow.Gadgets = AllocStructSafe(struct AppSettingWindowGadgets);
ng = AllocStructSafe(struct NewGadget);
if (!ng)
return false;
gadget = CreateContext(&Globals->Window->GadgetList);
gadget = CreateContext(&SettingWindow.GadgetList);
if (!gadget)
return false;
ng->ng_VisualInfo = Globals->Window->VisualInfo;
ng->ng_TextAttr = Globals->Window->Screen->Font;
ng->ng_VisualInfo = SettingWindow.VisualInfo;
ng->ng_TextAttr = SettingWindow.Screen->Font;
ng->ng_Flags = 0;
h = Globals->Window->Screen->RastPort.TxHeight;
x = Globals->Window->Screen->WBorLeft + 8;
y = Globals->Window->Screen->WBorTop + h + 9;
h = SettingWindow.Screen->RastPort.TxHeight;
x = SettingWindow.Screen->WBorLeft + 8;
y = SettingWindow.Screen->WBorTop + h + 9;
labelWidth = GetLabelWidth(&Globals->Window->Screen->RastPort);
labelWidth = GetLabelWidth(&SettingWindow.Screen->RastPort);
col1 = x;
textWidth = labelWidth + Globals->Window->Screen->RastPort.TxWidth / 2;
textWidth = labelWidth + SettingWindow.Screen->RastPort.TxWidth / 2;
col2 = col1 + textWidth;
boxWidth = labelWidth;
@@ -156,14 +149,14 @@ bool CreateGadgets(void)
ng->ng_GadgetID = GID_SERVER;
gadget = CreateGadget(
STRING_KIND, gadget, ng,
GTST_String, (IPTR)Globals->Settings->DestinationAddress,
GTST_String, (IPTR)Settings->DestinationAddress,
TAG_END);
if (!gadget)
return false;
Globals->Window->Gadgets->ServerGadget = gadget;
SettingWindow.Gadgets->ServerGadget = gadget;
if (Globals->Settings->Expert)
if (Settings->Expert)
{
// Port
ng->ng_LeftEdge = col1;
@@ -182,12 +175,12 @@ bool CreateGadgets(void)
ng->ng_GadgetID = GID_PORT;
gadget = CreateGadget(
STRING_KIND, gadget, ng,
GTST_String, (IPTR)Globals->Settings->DestinationPort,
GTST_String, (IPTR)Settings->DestinationPort,
TAG_END);
if (!gadget)
return false;
Globals->Window->Gadgets->PortGadget = gadget;
SettingWindow.Gadgets->PortGadget = gadget;
// Interval
ng->ng_LeftEdge = col1;
@@ -208,13 +201,13 @@ bool CreateGadgets(void)
gadget = CreateGadget(
INTEGER_KIND, gadget, ng,
GTNM_MaxNumberLen, 8,
GTIN_Number, Globals->Settings->Interval,
GTIN_Number, Settings->Interval,
TAG_END);
if (!gadget)
return false;
gadget->Flags |= GFLG_TABCYCLE;
Globals->Window->Gadgets->IntervalGadget = gadget;
SettingWindow.Gadgets->IntervalGadget = gadget;
// Timeout
ng->ng_LeftEdge = col1;
@@ -234,13 +227,13 @@ bool CreateGadgets(void)
gadget = CreateGadget(
INTEGER_KIND, gadget, ng,
GTNM_MaxNumberLen, 8,
GTIN_Number, Globals->Settings->Timeout,
GTIN_Number, Settings->Timeout,
TAG_END);
if (!gadget)
return false;
gadget->Flags |= GFLG_TABCYCLE;
Globals->Window->Gadgets->TimeoutGadget = gadget;
SettingWindow.Gadgets->TimeoutGadget = gadget;
// Threshold
ng->ng_LeftEdge = col1;
@@ -259,39 +252,13 @@ bool CreateGadgets(void)
ng->ng_GadgetID = GID_THRESHOLD;
gadget = CreateGadget(
STRING_KIND, gadget, ng,
GTST_String, (IPTR)Globals->Window->ThresholdText,
GTST_String, (IPTR)SettingWindow.ThresholdText,
TAG_END);
if (!gadget)
return false;
gadget->Flags |= GFLG_TABCYCLE;
Globals->Window->Gadgets->ThresholdGadget = gadget;
// Verbose
ng->ng_LeftEdge = col1;
ng->ng_TopEdge += ng->ng_Height + 4;
ng->ng_Width = textWidth;
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
GTTX_Text, (IPTR)verboseLabel,
TAG_END);
if (!gadget)
return false;
ng->ng_LeftEdge = col2;
ng->ng_Width = boxWidth + 20;
ng->ng_GadgetID = GID_VERBOSE;
gadget = CreateGadget(
CYCLE_KIND, gadget, ng,
GTCY_Labels, (IPTR)verboseLevel,
GTCY_Active, Globals->Settings->Verbose,
TAG_END);
if (!gadget)
return false;
gadget->Flags |= GFLG_TABCYCLE;
Globals->Window->Gadgets->VerboseGadget = gadget;
SettingWindow.Gadgets->ThresholdGadget = gadget;
// Priority
ng->ng_LeftEdge = col1;
@@ -311,13 +278,13 @@ bool CreateGadgets(void)
gadget = CreateGadget(
STRING_KIND, gadget, ng,
GTST_String, (IPTR)Globals->Window->PriorityText,
GTST_String, (IPTR)SettingWindow.PriorityText,
TAG_END);
if (!gadget)
return false;
gadget->Flags |= GFLG_TABCYCLE;
Globals->Window->Gadgets->PriorityGadget = gadget;
SettingWindow.Gadgets->PriorityGadget = gadget;
}
// Time zone
@@ -327,7 +294,7 @@ bool CreateGadgets(void)
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
GTTX_Text, (IPTR)timeZoneLabel,
GTTX_Text, (IPTR)TimezoneLabel,
TAG_END);
if (!gadget)
return false;
@@ -337,12 +304,12 @@ bool CreateGadgets(void)
ng->ng_GadgetID = labelId++;
gadget = CreateGadget(
TEXT_KIND, gadget, ng,
GTTX_Text, (IPTR)Globals->Window->TimeZoneText,
GTTX_Text, (IPTR)SettingWindow.TimezoneText,
TAG_END);
if (!gadget)
return false;
Globals->Window->Gadgets->TimeZoneGadget = gadget;
SettingWindow.Gadgets->TimezoneGadget = gadget;
// Last sync
ng->ng_LeftEdge = col1;
@@ -365,7 +332,7 @@ bool CreateGadgets(void)
if (!gadget)
return false;
Globals->Window->Gadgets->LastSyncGadget = gadget;
SettingWindow.Gadgets->LastSyncGadget = gadget;
tmp1 = ng->ng_LeftEdge + ng->ng_Width - 18; // Why is this 18?
tmp2 = tmp1 / 3;
@@ -394,10 +361,10 @@ bool CreateGadgets(void)
if (!gadget)
return false;
Globals->Window->Height = ng->ng_TopEdge + ng->ng_Height;
Globals->Window->Width = textWidth + boxWidth;
SettingWindow.Height = ng->ng_TopEdge + ng->ng_Height;
SettingWindow.Width = textWidth + boxWidth;
FreeMemSafe(ng, __FUNCTION__);
FreeMemSafe(ng);
return true;
}
@@ -405,7 +372,7 @@ static char *BuildLogText(const char *setting, char *oldValue, char *newValue)
{
static const char *txt1 = " changed: ";
static const char *txt2 = " -> ";
char *p = AllocMemSafe(SETTINGMESSAGELEN);
char *p = AllocStringSafe(LOGMESSAGELEN);
char *s = p;
p = AppendText(p, (char *)setting);
p = AppendText(p, (char *)txt1);
@@ -417,12 +384,12 @@ static char *BuildLogText(const char *setting, char *oldValue, char *newValue)
void UseSettings(void)
{
LogInfo("Apply new settings");
SetServer();
SetPort();
SetInterval();
SetTimeout();
SetThreshold();
SetVerbose();
SetCxPriority();
}
@@ -431,21 +398,21 @@ void SetServer(void)
char *server, *text;
GT_GetGadgetAttrs(
Globals->Window->Gadgets->ServerGadget,
Globals->Window->SettingWindow, NULL,
SettingWindow.Gadgets->ServerGadget,
SettingWindow.Window, NULL,
GTST_String, (IPTR)&server,
TAG_END);
if (Stricmp((STRPTR)server, (STRPTR)Globals->Settings->DestinationAddress) == 0)
if (Stricmp((STRPTR)server, (STRPTR)Settings->DestinationAddress) == 0)
return;
text = BuildLogText(SettingKeys->DestinationAddress,
Globals->Settings->DestinationAddress,
Settings->DestinationAddress,
server);
FreeMemSafe(Globals->Settings->DestinationAddress, __FUNCTION__);
Globals->Settings->DestinationAddress = StrDupSafe(server);
SendInfoMessage(text);
FreeMemSafe(text, __FUNCTION__);
FreeMemSafe(Settings->DestinationAddress);
Settings->DestinationAddress = StrDupSafe(server);
LogInfo(text);
FreeMemSafe(text);
SendMessage(ATK_RESTART);
}
@@ -453,25 +420,25 @@ void SetPort(void)
{
char *port, *text;
if (Globals->Window->Gadgets->PortGadget == NULL)
if (SettingWindow.Gadgets->PortGadget == NULL)
return;
GT_GetGadgetAttrs(
Globals->Window->Gadgets->PortGadget,
Globals->Window->SettingWindow, NULL,
SettingWindow.Gadgets->PortGadget,
SettingWindow.Window, NULL,
GTST_String, (IPTR)&port,
TAG_END);
if (Stricmp((STRPTR)port, (STRPTR)Globals->Settings->DestinationPort) == 0)
if (Stricmp((STRPTR)port, (STRPTR)Settings->DestinationPort) == 0)
return;
text = BuildLogText(SettingKeys->DestinationPort,
Globals->Settings->DestinationPort,
Settings->DestinationPort,
port);
FreeMemSafe(Globals->Settings->DestinationPort, __FUNCTION__);
Globals->Settings->DestinationPort = StrDupSafe(port);
SendInfoMessage(text);
FreeMemSafe(text, __FUNCTION__);
FreeMemSafe(Settings->DestinationPort);
Settings->DestinationPort = StrDupSafe(port);
LogInfo(text);
FreeMemSafe(text);
SendMessage(ATK_RESTART);
}
@@ -479,27 +446,27 @@ void SetInterval(void)
{
unsigned long value;
if (Globals->Window->Gadgets->IntervalGadget == NULL)
if (SettingWindow.Gadgets->IntervalGadget == NULL)
return;
GT_GetGadgetAttrs(
Globals->Window->Gadgets->IntervalGadget,
Globals->Window->SettingWindow, NULL,
SettingWindow.Gadgets->IntervalGadget,
SettingWindow.Window, NULL,
GTIN_Number, (IPTR)&value,
TAG_END);
if (Globals->Settings->Interval != value)
if (Settings->Interval != value)
{
char *text;
char newValue[MAXLONGCHARSIZE];
char oldValue[MAXLONGCHARSIZE];
LongToStr(Globals->Settings->Interval, oldValue);
LongToStr(Settings->Interval, oldValue);
LongToStr(value, newValue);
Globals->Settings->Interval = value;
Settings->Interval = value;
text = BuildLogText(SettingKeys->Interval, oldValue, newValue);
SendInfoMessage(text);
FreeMemSafe(text, __FUNCTION__);
LogInfo(text);
FreeMemSafe(text);
SendMessage(ATK_RESTART);
SanitizeSettings();
}
@@ -509,27 +476,27 @@ void SetTimeout(void)
{
unsigned long value;
if (Globals->Window->Gadgets->TimeoutGadget == NULL)
if (SettingWindow.Gadgets->TimeoutGadget == NULL)
return;
GT_GetGadgetAttrs(
Globals->Window->Gadgets->TimeoutGadget,
Globals->Window->SettingWindow, NULL,
SettingWindow.Gadgets->TimeoutGadget,
SettingWindow.Window, NULL,
GTIN_Number, (IPTR)&value,
TAG_END);
if (Globals->Settings->Timeout != value)
if (Settings->Timeout != value)
{
char *text;
char newValue[MAXLONGCHARSIZE];
char oldValue[MAXLONGCHARSIZE];
LongToStr(Globals->Settings->Timeout, oldValue);
LongToStr(Settings->Timeout, oldValue);
LongToStr(value, newValue);
Globals->Settings->Timeout = value;
Settings->Timeout = value;
text = BuildLogText(SettingKeys->Timeout, oldValue, newValue);
SendInfoMessage(text);
FreeMemSafe(text, __FUNCTION__);
LogInfo(text);
FreeMemSafe(text);
SendMessage(ATK_RESTART);
SanitizeSettings();
}
@@ -541,74 +508,45 @@ void SetThreshold(void)
char *tempString;
int result;
if (Globals->Window->Gadgets->ThresholdGadget == NULL)
if (SettingWindow.Gadgets->ThresholdGadget == NULL)
return;
GT_GetGadgetAttrs(
Globals->Window->Gadgets->ThresholdGadget,
Globals->Window->SettingWindow, NULL,
SettingWindow.Gadgets->ThresholdGadget,
SettingWindow.Window, NULL,
GTST_String, (IPTR)&tempString,
TAG_END);
result = StrToLongLong(tempString, &value);
if (result != -1 && Globals->Settings->Threshold != value)
if (result != -1 && Settings->Threshold != value)
{
char *text;
char newValue[MAXLONGLONGCHARSIZE];
char oldValue[MAXLONGLONGCHARSIZE];
LongLongToStr(Globals->Settings->Threshold, oldValue);
LongLongToStr(Settings->Threshold, oldValue);
LongLongToStr(value, newValue);
Globals->Settings->Threshold = value;
Settings->Threshold = value;
text = BuildLogText(SettingKeys->Threshold, oldValue, newValue);
SendInfoMessage(text);
FreeMemSafe(text, __FUNCTION__);
LogInfo(text);
FreeMemSafe(text);
SendMessage(ATK_RESTART);
SanitizeSettings();
}
}
void SetVerbose(void)
{
long value;
if (Globals->Window->Gadgets->VerboseGadget == NULL)
return;
GT_GetGadgetAttrs(
Globals->Window->Gadgets->VerboseGadget,
Globals->Window->SettingWindow, NULL,
GTCY_Active, (IPTR)&value,
TAG_END);
if (Globals->Settings->Verbose != value)
{
char *text;
char newValue[MAXLONGCHARSIZE];
char oldValue[MAXLONGCHARSIZE];
LongToStr(Globals->Settings->Verbose, oldValue);
LongToStr(value, newValue);
text = BuildLogText(SettingKeys->Verbose, oldValue, newValue);
SendInfoMessage(text);
FreeMemSafe(text, __FUNCTION__);
Globals->Settings->Verbose = value;
SanitizeSettings();
}
}
void SetCxPriority(void)
{
LONG value;
char *tempString;
int result;
if (Globals->Window->Gadgets->PriorityGadget == NULL)
if (SettingWindow.Gadgets->PriorityGadget == NULL)
return;
GT_GetGadgetAttrs(
Globals->Window->Gadgets->PriorityGadget,
Globals->Window->SettingWindow, NULL,
SettingWindow.Gadgets->PriorityGadget,
SettingWindow.Window, NULL,
GTST_String, (IPTR)&tempString,
TAG_END);
@@ -620,24 +558,24 @@ void SetCxPriority(void)
else if (value > PRIORITY_MAX)
value = PRIORITY_MAX;
if (Globals->Settings->Priority != value)
if (Settings->Priority != value)
{
char *text;
char newValue[MAXLONGCHARSIZE];
char oldValue[MAXLONGCHARSIZE];
LongToStr(Globals->Settings->Priority, oldValue);
LongToStr(Settings->Priority, oldValue);
LongToStr(value, newValue);
Globals->Settings->Priority = value;
Settings->Priority = value;
text = BuildLogText(SettingKeys->Priority, oldValue, newValue);
SetBrokerPriority(value);
SendInfoMessage(text);
FreeMemSafe(text, __FUNCTION__);
LogInfo(text);
FreeMemSafe(text);
}
}
}
void ShowLastSync(void)
void ShowLastSync(struct timeval *tv)
{
static char label[10];
struct timeval nowLocal, last, lastLocal;
@@ -651,12 +589,12 @@ void ShowLastSync(void)
.dat_StrTime = (STRPTR)label};
long seconds;
if (Globals->LastNtpSync.tv_secs == 0)
if (tv->tv_secs == 0)
{
static const char *never = "Not synced yet";
GT_SetGadgetAttrs(
Globals->Window->Gadgets->LastSyncGadget,
Globals->Window->SettingWindow, NULL,
SettingWindow.Gadgets->LastSyncGadget,
SettingWindow.Window, NULL,
GTTX_Text, (IPTR)never,
TAG_END);
@@ -664,7 +602,7 @@ void ShowLastSync(void)
}
GetLocalTimeOfDay(&nowLocal);
Unix2Amiga(&Globals->LastNtpSync, &last);
Unix2Amiga(tv, &last);
Utc2Local(&last, &lastLocal);
seconds = nowLocal.tv_secs - lastLocal.tv_secs;
@@ -672,8 +610,8 @@ void ShowLastSync(void)
{
static const char *tooOld = "> 24 hours";
GT_SetGadgetAttrs(
Globals->Window->Gadgets->LastSyncGadget,
Globals->Window->SettingWindow, NULL,
SettingWindow.Gadgets->LastSyncGadget,
SettingWindow.Window, NULL,
GTTX_Text, (IPTR)tooOld,
TAG_END);
@@ -686,8 +624,24 @@ void ShowLastSync(void)
DateToStr(&dateTime);
GT_SetGadgetAttrs(
Globals->Window->Gadgets->LastSyncGadget,
Globals->Window->SettingWindow, NULL,
SettingWindow.Gadgets->LastSyncGadget,
SettingWindow.Window, NULL,
GTTX_Text, (IPTR)label,
TAG_END);
}
void ShowNewTimezone(void)
{
char *temp = SettingWindow.TimezoneText;
char *new = AllocStringSafe(TIMEZONE_TEXT_LEN);
GetTimezoneText(AppLocale, new, ZONE_IN_PARENS);
GT_SetGadgetAttrs(
SettingWindow.Gadgets->TimezoneGadget,
SettingWindow.Window, NULL,
GTTX_Text, (IPTR) new,
TAG_END);
SettingWindow.TimezoneText = new;
FreeMemSafe(temp);
}
+133 -135
View File
@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2017-2019 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2017-2020 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,41 +25,51 @@
*/
#include "config.h"
#include "global.h"
#include "message.h"
#include "state.h"
#include "time.h"
#include "setting.h"
#include "timer.h"
#include "sync.h"
#include "mem.h"
#include "win.h"
#include "logmod.h"
#define MODULENAME "Window"
#define WINPROCNAME APP_SHORT_NAME " Window"
static void SettingsProc(void);
static void ProcessMsg(void);
static void MsgLoop(void);
static void HandleGadgetUp(struct Gadget *);
volatile bool WindowProcRunning = false;
struct AppSettings *WindowSettings = NULL;
struct AppSettingWindow SettingWindow;
void ShowSettingWindow(void)
{
bool running;
struct Task *task;
Forbid();
running = Globals->Window->Task != NULL;
if (!running)
running = WindowProcRunning;
if (!WindowProcRunning)
{
Globals->Window->Task = CreateNewProcTags(
task = (struct Task *)CreateNewProcTags(
NP_Entry, (IPTR)SettingsProc,
NP_Name, (IPTR)APP_SHORT_NAME " Window",
NP_Name, (IPTR)WINPROCNAME,
NP_StackSize, 64 * 1024,
TAG_DONE);
WindowProcRunning = (task != NULL);
}
Permit();
if (running)
{
LogTrace("Setting process is already running");
return;
LogDebug("Setting process is already running");
}
if (Globals->Window->Task != NULL)
else if (task != NULL)
{
LogTrace("Created setting process");
LogDebug("Created setting process");
}
else
{
@@ -67,129 +77,117 @@ void ShowSettingWindow(void)
}
}
void HideSettingWindow(void)
{
Forbid();
if (Globals->Window->Task != NULL)
{
Signal((void *)Globals->Window->Task, SIGBREAKF_CTRL_C);
}
Permit();
}
bool CheckSettingWindowClosed(void)
{
return (Globals->Window->Task == NULL);
}
static bool InitWindow(void)
{
Globals->Window->Screen = LockPubScreen(NULL);
if (!Globals->Window->Screen)
LogTrace("Initializing");
SettingWindow.Screen = NULL;
SettingWindow.Window = NULL;
SettingWindow.GadgetList = NULL;
SettingWindow.VisualInfo = NULL;
SettingWindow.PriorityText = NULL;
SettingWindow.ThresholdText = NULL;
SettingWindow.TimezoneText = NULL;
SettingWindow.Width = 0;
SettingWindow.Height = 0;
SettingWindow.Gadgets = NULL;
Ports.WindowPort = CreateMsgPort();
if (Ports.WindowPort == NULL)
{
return false;
}
Globals->Window->UserPort = CreateMsgPort();
if (Globals->Window->UserPort == NULL)
SettingWindow.Screen = LockPubScreen(NULL);
if (!SettingWindow.Screen)
{
return false;
}
Globals->Window->VisualInfo = GetVisualInfo(Globals->Window->Screen, NULL);
if (Globals->Window->VisualInfo == NULL)
SettingWindow.VisualInfo = GetVisualInfo(SettingWindow.Screen, NULL);
if (SettingWindow.VisualInfo == NULL)
{
return false;
}
Globals->Window->PriorityText = AllocMemSafe(15);
Globals->Window->TimeZoneText = AllocMemSafe(10);
Globals->Window->ThresholdText = AllocMemSafe(MAXLONGLONGCHARSIZE);
if (Globals->Window->PriorityText == NULL ||
Globals->Window->TimeZoneText == NULL ||
Globals->Window->ThresholdText == NULL)
SettingWindow.PriorityText = AllocStringSafe(15);
SettingWindow.TimezoneText = AllocStringSafe(TIMEZONE_TEXT_LEN);
SettingWindow.ThresholdText = AllocStringSafe(MAXLONGLONGCHARSIZE);
if (SettingWindow.PriorityText == NULL ||
SettingWindow.TimezoneText == NULL ||
SettingWindow.ThresholdText == NULL)
{
return false;
}
LongToStr(Globals->Settings->Priority, Globals->Window->PriorityText);
LongLongToStr(Globals->Settings->Threshold, Globals->Window->ThresholdText);
GetTimeZoneText(Globals->Window->TimeZoneText, true);
LongToStr(Settings->Priority, SettingWindow.PriorityText);
LongLongToStr(Settings->Threshold, SettingWindow.ThresholdText);
GetTimezoneText(AppLocale, SettingWindow.TimezoneText, ZONE_IN_PARENS);
return true;
}
static void DestroyWindow(void)
{
if (Globals->Window->SettingWindow != NULL)
LogTrace("Clean up");
CleanupVolMsgPort(&Ports.WindowPort);
if (SettingWindow.Window != NULL)
{
struct Message *msg;
while ((msg = GetMsg(Globals->Window->SettingWindow->UserPort)))
while ((msg = GetMsg(SettingWindow.Window->UserPort)))
ReplyMsg(msg);
CloseWindow(Globals->Window->SettingWindow);
Globals->Window->SettingWindow = NULL;
CloseWindow(SettingWindow.Window);
SettingWindow.Window = NULL;
}
if (Globals->Window->GadgetList != NULL)
if (SettingWindow.GadgetList != NULL)
{
FreeGadgets(Globals->Window->GadgetList);
Globals->Window->GadgetList = NULL;
FreeGadgets(SettingWindow.GadgetList);
SettingWindow.GadgetList = NULL;
}
if (Globals->Window->VisualInfo != NULL)
if (SettingWindow.VisualInfo != NULL)
{
FreeVisualInfo(Globals->Window->VisualInfo);
Globals->Window->VisualInfo = NULL;
FreeVisualInfo(SettingWindow.VisualInfo);
SettingWindow.VisualInfo = NULL;
}
if (Globals->Window->UserPort != NULL)
if (SettingWindow.Screen != NULL)
{
struct Message *msg;
while ((msg = GetMsg(Globals->Window->UserPort)))
ReplyMsg(msg);
DeleteMsgPort(Globals->Window->UserPort);
Globals->Window->UserPort = NULL;
UnlockPubScreen(NULL, SettingWindow.Screen);
SettingWindow.Screen = NULL;
}
if (Globals->Window->Screen != NULL)
{
UnlockPubScreen(NULL, Globals->Window->Screen);
Globals->Window->Screen = NULL;
}
FreeSettings(WindowSettings);
WindowSettings = NULL;
FreeSettings(Globals->Window->Settings);
FreeMemSafe(Globals->Window->Gadgets, __FUNCTION__);
FreeMemSafe(Globals->Window->PriorityText, __FUNCTION__);
FreeMemSafe(Globals->Window->ThresholdText, __FUNCTION__);
FreeMemSafe(Globals->Window->TimeZoneText, __FUNCTION__);
Globals->Window->Gadgets = NULL;
Globals->Window->PriorityText = NULL;
Globals->Window->ThresholdText = NULL;
Globals->Window->TimeZoneText = NULL;
Forbid();
Globals->Window->Task = NULL;
Permit();
FreeMemSafe(SettingWindow.Gadgets);
FreeMemSafe(SettingWindow.PriorityText);
FreeMemSafe(SettingWindow.ThresholdText);
FreeMemSafe(SettingWindow.TimezoneText);
SettingWindow.Gadgets = NULL;
SettingWindow.PriorityText = NULL;
SettingWindow.ThresholdText = NULL;
SettingWindow.TimezoneText = NULL;
}
static bool CreateWindow(void)
{
long w = Globals->Window->Screen->WBorLeft + Globals->Window->Screen->WBorRight + Globals->Window->Width + 38; // Why is this 38?
long h = Globals->Window->Height + 8 + Globals->Window->Screen->WBorBottom;
long w = SettingWindow.Screen->WBorLeft + SettingWindow.Screen->WBorRight + SettingWindow.Width + 38; // Why is this 38?
long h = SettingWindow.Height + 8 + SettingWindow.Screen->WBorBottom;
struct Window *x = OpenWindowTags(NULL,
WA_Width, w,
WA_Height, h,
WA_Left, (Globals->Window->Screen->Width - w) / 2,
WA_Top, (Globals->Window->Screen->Height - h) / 2,
WA_PubScreen, (IPTR)Globals->Window->Screen,
WA_Left, (SettingWindow.Screen->Width - w) / 2,
WA_Top, (SettingWindow.Screen->Height - h) / 2,
WA_PubScreen, (IPTR)SettingWindow.Screen,
WA_Title, (IPTR)APP_LONG_NAME,
WA_Flags, WFLG_CLOSEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_ACTIVATE | WFLG_SIMPLE_REFRESH,
WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_REFRESHWINDOW | IDCMP_VANILLAKEY | IDCMP_GADGETUP | IDCMP_MENUPICK,
WA_Gadgets, (IPTR)Globals->Window->GadgetList,
WA_Gadgets, (IPTR)SettingWindow.GadgetList,
TAG_END);
Globals->Window->SettingWindow = x;
SettingWindow.Window = x;
if (!x)
{
return false;
@@ -200,26 +198,11 @@ static bool CreateWindow(void)
static void InitWindowSettings()
{
if (Globals->Window->Settings != NULL)
if (WindowSettings != NULL)
{
FreeSettings(Globals->Window->Settings);
}
Globals->Window->Settings = CopySettings(Globals->Settings);
}
static void SyncExit()
{
if (!Globals->ShuttingDown)
{
struct MsgPort *replyPort = CreateMsgPort();
if (replyPort)
{
SendMessageTo(Globals->Broker->UserPort, replyPort, ATK_UNDO);
WaitPort(replyPort);
GetMsg(replyPort);
DeleteMsgPort(replyPort);
}
FreeSettings(WindowSettings);
}
WindowSettings = CopySettings(Settings);
}
static void SettingsProc(void)
@@ -227,75 +210,92 @@ static void SettingsProc(void)
if (!InitWindow() || !CreateGadgets() || !CreateWindow())
{
DestroyWindow();
WindowProcRunning = false;
return;
}
InitWindowSettings();
ShowLastSync();
ProcessMsg();
SyncExit();
ShowLastSync((struct timeval *)&LastSync);
MsgLoop();
SendMessageWait(Ports.BrokerPort, ATK_UNDO);
DestroyWindow();
WindowProcRunning = false;
}
static void ProcessMsg(void)
static void MsgLoop(void)
{
bool loop = true;
ULONG userPortSigMask = (1 << Ports.WindowPort->mp_SigBit);
ULONG windowSigMask = (1 << SettingWindow.Window->UserPort->mp_SigBit);
ULONG sigMask = userPortSigMask | windowSigMask;
GT_RefreshWindow(Globals->Window->SettingWindow, NULL);
GT_RefreshWindow(SettingWindow.Window, NULL);
do
{
ULONG sigrcvd = Wait(SIGBREAKF_CTRL_C |
(1 << Globals->Window->UserPort->mp_SigBit) |
(1 << Globals->Window->SettingWindow->UserPort->mp_SigBit));
if (sigrcvd & (1 << Globals->Window->SettingWindow->UserPort->mp_SigBit))
ULONG sigrcvd = Wait(sigMask);
if (sigrcvd & windowSigMask)
{
struct IntuiMessage *msg;
while ((msg = GT_GetIMsg(Globals->Window->SettingWindow->UserPort)))
while ((msg = GT_GetIMsg(SettingWindow.Window->UserPort)))
{
switch (msg->Class)
{
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh(Globals->Window->SettingWindow);
GT_EndRefresh(Globals->Window->SettingWindow, TRUE);
GT_BeginRefresh(SettingWindow.Window);
GT_EndRefresh(SettingWindow.Window, TRUE);
break;
case IDCMP_GADGETUP:
HandleGadgetUp((struct Gadget *)msg->IAddress);
break;
case IDCMP_VANILLAKEY:
if (msg->Code == 0x1b)
{
loop = false;
}
break;
case IDCMP_CLOSEWINDOW:
loop = false;
break;
}
GT_ReplyIMsg(msg);
}
}
if (sigrcvd & (1 << Globals->Window->UserPort->mp_SigBit))
if (sigrcvd & userPortSigMask)
{
struct AppWindowMessage *msg;
while ((msg = (struct AppWindowMessage *)GetMsg(Globals->Window->UserPort)))
struct ApplicationMesage *msg;
while ((msg = (struct ApplicationMesage *)GetMsg(Ports.WindowPort)))
{
switch (msg->Type)
long msgType = msg->MsgType;
long msgId = msg->MsgId;
struct timeval tv;
if (msgType == MSGTYPE_TIMEVAL)
{
case ATK_REFRESH:
ShowLastSync();
break;
default:
break;
struct TimeMessage *timeMsg = (struct TimeMessage *)msg;
tv = timeMsg->TimeVal;
}
ReplyMsg((struct Message *)msg);
}
}
if (sigrcvd & SIGBREAKF_CTRL_C)
{
loop = false;
if (msgType == MSGTYPE_TIMEVAL)
{
ShowLastSync(&tv);
}
else
{
switch (msgId)
{
case ATK_SHUTDOWN:
loop = false;
break;
case ATK_TZ_CHANGED:
ShowNewTimezone();
default:
break;
}
}
}
}
} while (loop);
}
@@ -319,13 +319,12 @@ static void HandleGadgetUp(struct Gadget *gadget)
case GID_THRESHOLD:
SetThreshold();
break;
case GID_VERBOSE:
SetVerbose();
break;
case GID_PRIORITY:
SetCxPriority();
break;
case GID_SAVE:
UseSettings();
InitWindowSettings();
SendMessage(ATK_STORE);
break;
case GID_USE:
@@ -335,7 +334,6 @@ static void HandleGadgetUp(struct Gadget *gadget)
break;
case GID_CANCEL:
SendMessage(ATK_UNDO);
HideSettingWindow();
break;
default:
break;