302 lines
7.7 KiB
C
302 lines
7.7 KiB
C
/*-
|
|
* Copyright (c) 2017-2021 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 CONFIG_H_INCLUDED
|
|
#define CONFIG_H_INCLUDED
|
|
|
|
#include <exec/io.h>
|
|
#include <exec/types.h>
|
|
#include <exec/memory.h>
|
|
#include <exec/devices.h>
|
|
#include <exec/libraries.h>
|
|
#include <resources/battclock.h>
|
|
#include <libraries/asl.h>
|
|
#include <libraries/commodities.h>
|
|
#include <graphics/text.h>
|
|
#include <graphics/rastport.h>
|
|
#include <dos/dos.h>
|
|
#include <dos/dostags.h>
|
|
#include <proto/dos.h>
|
|
#include <proto/asl.h>
|
|
#include <proto/exec.h>
|
|
#include <proto/icon.h>
|
|
#include <proto/timer.h>
|
|
#include <proto/locale.h>
|
|
#include <proto/utility.h>
|
|
#include <proto/gadtools.h>
|
|
#include <proto/intuition.h>
|
|
#include <proto/battclock.h>
|
|
#include <proto/commodities.h>
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
|
|
#include "compiler.h"
|
|
|
|
#if defined(AROS) || defined(__CLIB2__)
|
|
#include <stdint.h>
|
|
#endif
|
|
|
|
#if defined(AOS3)
|
|
#define SCREENNOTIFY
|
|
#endif
|
|
|
|
#if defined(__libnix__)
|
|
typedef u_int8_t uint8_t;
|
|
typedef u_int16_t uint16_t;
|
|
typedef u_int32_t uint32_t;
|
|
typedef u_int64_t uint64_t;
|
|
typedef uint32_t uintptr_t;
|
|
#endif
|
|
|
|
#if defined(__CLIB2__)
|
|
#define __NO_NET_API
|
|
//define NO_INLINE_STDARG
|
|
//#define MISSING_ADDRINFO
|
|
#include <proto/graphics.h>
|
|
#include <proto/socket.h>
|
|
#endif
|
|
|
|
#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
|
|
|
|
#if defined(__libnix__) || defined(__CLIB2__)
|
|
#include "netdb.h"
|
|
#include "sys/errno.h"
|
|
#include "sys/socket.h"
|
|
#include "netinet/in.h"
|
|
#else
|
|
#include <netdb.h>
|
|
#include <sys/errno.h>
|
|
#include <sys/socket.h>
|
|
#include <netinet/in.h>
|
|
#endif
|
|
|
|
#if defined(SCREENNOTIFY)
|
|
#include "clib/screennotify.h"
|
|
#include "proto/screennotify.h"
|
|
#endif
|
|
|
|
#ifdef MAXPATHLEN
|
|
#undef MAXPATHLEN
|
|
#endif
|
|
#ifdef MAXFILELEN
|
|
#undef MAXFILELEN
|
|
#endif
|
|
#ifdef MAXFILEPATHLEN
|
|
#undef MAXFILEPATHLEN
|
|
#endif
|
|
#define MAXPATHLEN 1792
|
|
#define MAXFILELEN 256
|
|
#define MAXFILEPATHLEN MAXPATHLEN + MAXFILELEN
|
|
#define MAXDOSERRORLEN 256
|
|
#define LOGMESSAGELEN 128
|
|
|
|
#ifndef HAVE_POLL
|
|
#define POLLIN 0x0001
|
|
struct pollfd
|
|
{
|
|
int fd;
|
|
short events;
|
|
short revents;
|
|
};
|
|
typedef unsigned int nfds_t;
|
|
int poll(struct pollfd *, nfds_t, int);
|
|
#endif
|
|
|
|
#if AOS3
|
|
#define IPTR ULONG
|
|
#endif
|
|
|
|
#ifdef AROS
|
|
#define VSNPrintf(str, n, format, args) vsnprintf(str, n, format, args)
|
|
#define SNPrintf(str, n, format, ...) snprintf(str, n, format, __VA_ARGS__)
|
|
#endif
|
|
|
|
#define LIB_OK 0
|
|
#define COM_OK 0
|
|
#define LIB_ERROR -1
|
|
#define COM_ERROR -1
|
|
|
|
#ifdef AROS
|
|
#define APP_SHORT_NAME "TimeKeeper"
|
|
#define APP_LONG_NAME "AROS Time Keeper"
|
|
#else
|
|
#define APP_SHORT_NAME "TimeKeeper"
|
|
#define APP_LONG_NAME "Amiga Time Keeper"
|
|
#endif
|
|
|
|
#define APP_VERSION "1.12"
|
|
#define APP_DATE_VERSION "1.12 (31.01.2021)"
|
|
#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 "string.h"
|
|
|
|
#define KEYWORD_COUNT 18
|
|
#define KEYWORD_SERVER "SERVER"
|
|
#define KEYWORD_PORT "PORT"
|
|
#define KEYWORD_THRESHOLD "THRESHOLD"
|
|
#define KEYWORD_INTERVAL "INTERVAL"
|
|
#define KEYWORD_PRIORITY "CX_PRIORITY"
|
|
#define KEYWORD_POPKEY "CX_POPKEY"
|
|
#define KEYWORD_POPUP "CX_POPUP"
|
|
#define KEYWORD_READONLY "READONLY"
|
|
#define KEYWORD_EXPERT "EXPERT"
|
|
#define KEYWORD_TIMEOUT "TIMEOUT"
|
|
#define KEYWORD_ACTIVE "ACTIVE"
|
|
#define KEYWORD_NOLOG "NOLOG"
|
|
#define KEYWORD_TZ "TZ"
|
|
#define KEYWORD_TZD "TZD"
|
|
#define KEYWORD_TZNAME "TZNAME"
|
|
#define KEYWORD_TZVALUE "TZVALUE"
|
|
#define KEYWORD_TZDST "TZDST"
|
|
#define KEYWORD_POPUP2 "POPUP"
|
|
|
|
#define KEYWORD_FROM "FROM"
|
|
|
|
#define KEYWORD_TZ_ALIAS "TIMEZONE"
|
|
#define KEYWORD_TZD_ALIAS "TIMEZONEDISPLAY"
|
|
#define KEYWORD_TZNAME_ALIAS "TIMEZONEABBREVIATION"
|
|
#define KEYWORD_TZVALUE_ALIAS "TIMEZONEVALUE"
|
|
#define KEYWORD_TZDST_ALIAS "DST"
|
|
|
|
#define KEYWORD_NUMBER "NUMBER"
|
|
#define KEYWORD_DATE "DATE"
|
|
#define KEYWORD_TIME "TIME"
|
|
#define KEYWORD_DOS "DOS"
|
|
#define KEYWORD_ASCII "ASCII"
|
|
#define KEYWORD_RFC850 "RFC850"
|
|
#define KEYWORD_RFC1123 "RFC1123"
|
|
#define KEYWORD_RFC2822 "RFC2822"
|
|
#define KEYWORD_RFC3339 "RFC3339"
|
|
#define KEYWORD_ISO8601 "ISO8601"
|
|
#define KEYWORD_LOCAL "LOCAL"
|
|
#define KEYWORD_UTC "UTC"
|
|
|
|
#define SERVER_DEF "pool.ntp.org"
|
|
#define PORT_DEF "123"
|
|
#define THRESHOLD_MIN 1000LL
|
|
#define THRESHOLD_DEF 1000000LL
|
|
#define INTERVAL_MIN 500
|
|
#define INTERVAL_DEF 17500
|
|
#define INTERVAL_MAX 2 * 24 * 60 * 60 * 1000
|
|
#define PRIORITY_MIN -128
|
|
#define PRIORITY_DEF 25
|
|
#define PRIORITY_MAX 127
|
|
#define READONLY_DEF 0
|
|
#define EXPERT_DEF 0
|
|
#define ACTIVE_DEF 0
|
|
#define NOLOG_DEF 0
|
|
#define TIMEOUT_MIN 100
|
|
#define TIMEOUT_DEF 5000
|
|
#define TIMEOUT_MAX 30000
|
|
#define POPKEY_DEF "lshift control t"
|
|
#define POPUP_DEF 0
|
|
#define TZ_DEF ""
|
|
#define TZD_MIN 1
|
|
#define TZD_DEF 9
|
|
#define TZD_MAX 10
|
|
#define TZNAME_DEF ""
|
|
#define TZVALUE_MIN -2400
|
|
#define TZVALUE_DEF 16800
|
|
#define TZVALUE_MAX 2400
|
|
#define TZDST_DEF -1
|
|
|
|
#define KWD_TMPL_01 KEYWORD_READONLY "/S,"
|
|
#define KWD_TMPL_02 KEYWORD_EXPERT "/S,"
|
|
#define KWD_TMPL_03 KEYWORD_ACTIVE "/S,"
|
|
#define KWD_TMPL_04 KEYWORD_NOLOG "/S,"
|
|
#define KWD_TMPL_05 KEYWORD_SERVER "/K,"
|
|
#define KWD_TMPL_06 KEYWORD_PORT "/K,"
|
|
#define KWD_TMPL_07 KEYWORD_TIMEOUT "/N/K,"
|
|
#define KWD_TMPL_08 KEYWORD_THRESHOLD "/K,"
|
|
#define KWD_TMPL_09 KEYWORD_INTERVAL "/N/K,"
|
|
#define KWD_TMPL_10 KEYWORD_PRIORITY "/N/K,"
|
|
#define KWD_TMPL_11 KEYWORD_POPKEY "/K,"
|
|
#define KWD_TMPL_12 KEYWORD_POPUP "/K,"
|
|
#define KWD_TMPL_13 KEYWORD_TZ_ALIAS "=" KEYWORD_TZ "/K,"
|
|
#define KWD_TMPL_14 KEYWORD_TZD_ALIAS "=" KEYWORD_TZD "/N/K,"
|
|
#define KWD_TMPL_15 KEYWORD_TZNAME_ALIAS "=" KEYWORD_TZNAME "/K,"
|
|
#define KWD_TMPL_16 KEYWORD_TZVALUE_ALIAS "=" KEYWORD_TZVALUE "/N/K,"
|
|
#define KWD_TMPL_17 KEYWORD_TZDST_ALIAS "=" KEYWORD_TZDST "/N/K,"
|
|
#define KWD_TMPL_18 KEYWORD_POPUP2 "/S"
|
|
|
|
#define KWD_TMPL \
|
|
KWD_TMPL_01 \
|
|
KWD_TMPL_02 \
|
|
KWD_TMPL_03 \
|
|
KWD_TMPL_04 \
|
|
KWD_TMPL_05 \
|
|
KWD_TMPL_06 \
|
|
KWD_TMPL_07 \
|
|
KWD_TMPL_08 \
|
|
KWD_TMPL_09 \
|
|
KWD_TMPL_10 \
|
|
KWD_TMPL_11 \
|
|
KWD_TMPL_12 \
|
|
KWD_TMPL_13 \
|
|
KWD_TMPL_14 \
|
|
KWD_TMPL_15 \
|
|
KWD_TMPL_16 \
|
|
KWD_TMPL_17 \
|
|
KWD_TMPL_18
|
|
|
|
struct ControlMesage;
|
|
|
|
/* arexx.c */
|
|
bool HandleARexxMessages(void);
|
|
void CleanupARexx(void);
|
|
|
|
/* broker.c */
|
|
void StartBroker(void);
|
|
void Activate(void);
|
|
void Deactivate(void);
|
|
bool IsBrokerRunning(void);
|
|
void SetBrokerPriority(int);
|
|
|
|
/* ctrlmsg.c */
|
|
bool HandleControlMessages(void);
|
|
|
|
/* libraries.c */
|
|
int OpenLibraries(void);
|
|
void CloseLibraries(void);
|
|
|
|
#endif
|