unpack zips in src to better compression

This commit is contained in:
2022-10-20 13:28:49 +02:00
parent e25403bd5f
commit 87eb27f562
447 changed files with 55306 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
ifeq ($(CROSS),yes)
LIBXML = /usr/m68k-atari-mint/include/libxml2
else
LIBXML = /usr/include/libxml2
endif
STACKSIZE = 64k
OPTIMISATION = -O2 -fomit-frame-pointer -finline-functions
CPU = -m68020-60
LIB = -lwindom -lzcodec -lldg -lgem -lxml2 -lm -lmem -lz
CFLAGS = $(CPU) $(OPTIMISATION) -Wall -Wshadow -I$(LIBXML)
ifeq ($(CROSS),no)
CFLAGS += -I/usr/local/include
LDFLAGS += -L/usr/local/lib/m68020-60
endif
OBJ = inet.o http_client.o parsers.o get_data.o \
debug.o zstring.o dialog.o prefs.o zaes.o icon.o main.o
PROGRAM = zweather.app
include ../common.mak

View File

@@ -0,0 +1,30 @@
#include "general.h"
#ifdef DEBUG
#include <windom/wout.h>
#endif
/*==================================================================================*
* void zdebug: *
* print debug information in 'wout' window. *
*----------------------------------------------------------------------------------*
* input: *
* ... -> text and parameter are the same that sandard "printf" function. *
*----------------------------------------------------------------------------------*
* returns: *
* -- *
*==================================================================================*/
void zdebug( const char *format, ...)
{
#ifdef DEBUG
va_list args;
char fo_buff[255], *p;
va_start( args, format);
vsprintf( fo_buff, format, args);
p = fo_buff;
va_end( args);
wout_printf("%s\n", p);
#endif
}

View File

@@ -0,0 +1,115 @@
#include "general.h"
#include "icon.h"
#include "parsers.h"
extern struct xml_weather *zweatherdata;
extern int8 wind_direction[8];
extern void init_stik (void);
WINDOW *windialog = NULL;
int8 icon_temp[8] = "";
static void force_update( WINDOW *win, int obj, int mode, void *data)
{
OBJECT *weather_form = get_tree( WEATHER);
int time_minute;
graf_mouse( BUSYBEE, NULL);
if( EvntFind( NULL, WM_XTIMER))
EvntDelete( NULL, WM_XTIMER);
if( zweatherdata)
xml_weather_free( zweatherdata);
strcpy( location_code, ObjcString( weather_form, WEATHER_CODE, NULL));
zweatherdata = update_weatherdata( location_code);
time_minute = atoi( ( const char*)ObjcString( weather_form, WEATHER_UPDATE_TIME, NULL));
update_time = ( clock_t)( ( int32)time_minute * 12000L);
ObjcChange( OC_FORM, windialog, WEATHER_UPDATE, NORMAL, 0);
snd_rdw( windialog);
EvntAttach( NULL, WM_XTIMER, timer_function);
graf_mouse( ARROW, NULL);
}
static void weather_dialog_quit( WINDOW *win, int obj, int mode, void *data)
{
ObjcChange( OC_FORM, win, obj, NORMAL, TRUE);
ApplWrite( _AESapid, AP_TERM, 0, 0, 0, 0, 0);
}
static void CDECL continent_popup( WINDOW *win, int obj, int mode, void *data)
{
OBJECT *pop;
int16 x, y;
static int last_choice = -1;
int choice;
rsrc_gaddr( 0, CONTINENT, &pop);
objc_offset( FORM( win), obj, &x, &y);
choice = MenuPopUp ( pop, x, y, -1, -1, last_choice, P_WNDW + P_CHCK);
last_choice = choice;
ObjcChange( OC_FORM, win, obj, NORMAL, TRUE);
}
void weather_dialog( void)
{
OBJECT *weather_form = get_tree( WEATHER);
int frms[] = { WEATHER_PANEL1, WEATHER_PANEL2, WEATHER_PANEL3, WEATHER_PANEL4};
int buts[] = { WEATHER_MAIN, WEATHER_FORECAST, WEATHER_MAP, WEATHER_PREF};
int time_minute = ( int)( update_time / 12000L);
strcpy( ObjcString( weather_form, WEATHER_CONTINENT, NULL), "--");
strcpy( ObjcString( weather_form, WEATHER_STATE, NULL), "--");
strcpy( ObjcString( weather_form, WEATHER_CODE, NULL), location_code);
sprintf( ObjcString( weather_form, WEATHER_UPDATE_TIME, NULL), "%d", time_minute);
windialog = FormCreate( weather_form, NAME|MOVER, NULL, " zWeather ", NULL, TRUE, FALSE);
// RsrcUserDraw( OC_FORM, windialog, WEATHER_ROOT, draw_root_dial, NULL);
RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON, draw_weather_icon, NULL);
RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON1, draw_forecast1_icon, NULL);
RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON2, draw_forecast2_icon, NULL);
RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON3, draw_forecast3_icon, NULL);
RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON4, draw_forecast4_icon, NULL);
RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON5, draw_forecast5_icon, NULL);
RsrcUserDraw( OC_FORM, windialog, WEATHER_ICON6, draw_forecast6_icon, NULL);
RsrcUserDraw( OC_FORM, windialog, WEATHER_WICON, draw_boussole_icon, NULL);
FormThumb( windialog, frms, buts, 4);
if( main_icon == NULL)
main_icon = &icons[25];
if( forecast_icon[0] == NULL)
forecast_icon[0] = &icons[25];
if( forecast_icon[1] == NULL)
forecast_icon[1] = &icons[25];
if( forecast_icon[2] == NULL)
forecast_icon[2] = &icons[25];
if( forecast_icon[3] == NULL)
forecast_icon[3] = &icons[25];
if( forecast_icon[4] == NULL)
forecast_icon[4] = &icons[25];
ObjcAttachVar( OC_FORM, windialog, WEATHER_METRIC, &unit, WEATHER_METRIC);
ObjcAttachVar( OC_FORM, windialog, WEATHER_IMPERIAL, &unit, WEATHER_IMPERIAL);
ObjcAttachFormFunc( windialog, WEATHER_UPDATE, force_update, NULL);
ObjcAttachFormFunc( windialog, WEATHER_QUIT, weather_dialog_quit, NULL);
ObjcAttachFormFunc( windialog, WEATHER_CONTINENT, continent_popup, NULL);
vswr_mode( windialog->graf->handle, MD_TRANS);
vsl_color( windialog->graf->handle, RED);
}

View File

@@ -0,0 +1,67 @@
/*
* zWeather.
* Copyright (c) 2004 Zorro ( zorro270@yahoo.fr)
*
* This application is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <osbind.h>
#include <mintbind.h>
#include <dirent.h>
#include <errno.h>
#include <sys/stat.h>
#include <unistd.h>
#include <time.h>
#include <windom.h>
#include <scancode.h>
#include <ldg.h>
#include <libxml/parser.h>
#include <types2b.h>
#include <zcodec.h>
#include "zstring.h"
#include "zaes.h"
#include "prefs.h"
#include "zweather.rsh"
/* Custom message code */
#define E_RSC 10002
#define E_OK 0
/* Option */
// #define DEBUG
#ifndef MAXNAMLEN
#define MAXNAMLEN 255
#endif
#ifndef MAX_PATH
#define MAX_PATH 1024
#endif
extern int use_sting;
extern WINDOW *windialog;
extern void timer_function( WINDOW *win, short buff[8]);
extern void snd_rdw( WINDOW *win);
extern struct xml_weather *update_weatherdata( int8 *location);
extern void snd_msg( WINDOW *win, int msg, int par1, int par2, int par3, int par4);
extern void zdebug( const char *format, ...);

View File

@@ -0,0 +1,206 @@
#include "general.h"
#include "get_data.h"
int8 dummy[2] = "0";
int8 *get_data_uv(struct xml_uv *data, enum datas_uv type)
{
int8 *str = dummy;
if ( !data)
return str;
switch(type)
{
case _UV_INDEX: str = data->i; break;
case _UV_TRANS: str = data->t; break;
default: break;
}
return str;
}
int8 *get_data_bar(struct xml_bar *data, enum datas_bar type)
{
int8 *str = dummy;
if ( !data)
return str;
switch(type)
{
case _BAR_R: str = data->r; break;
case _BAR_D: str = data->d; break;
default: break;
}
return str;
}
int8 *get_data_wind(struct xml_wind *data, enum datas_wind type)
{
int8 *str = dummy;
if ( !data)
return str;
switch(type)
{
case _WIND_SPEED: str = data->s; break;
case _WIND_GUST: str = data->gust; break;
case _WIND_DIRECTION: str = data->t; break;
case _WIND_TRANS: str = data->d; break;
default: break;
}
return str;
}
int8 *get_data_cc( struct xml_cc *data, enum datas type)
{
int8 *str = dummy;
if ( !data)
return str;
switch(type)
{
case LSUP: str = data->lsup; break;
case OBST: str = data->obst; break;
case FLIK: str = data->flik; break;
case TRANS: str = data->t; break;
case TEMP: str = data->tmp; break;
case HMID: str = data->hmid; break;
case VIS: str = data->vis; break;
case UV_INDEX: return get_data_uv(data->uv, _UV_INDEX);
case UV_TRANS: return get_data_uv(data->uv, _UV_TRANS);
case WIND_SPEED: return get_data_wind(data->wind, _WIND_SPEED);
case WIND_GUST: return get_data_wind(data->wind, _WIND_GUST);
case WIND_DIRECTION: return get_data_wind(data->wind, _WIND_DIRECTION);
case WIND_TRANS: return get_data_wind(data->wind, _WIND_TRANS);
case BAR_R: return get_data_bar(data->bar, _BAR_R);
case BAR_D: return get_data_bar(data->bar, _BAR_D);
case DEWP: str = data->dewp; break;
case WICON: str = data->icon; break;
default: break;
}
return str;
}
int8 *get_data_loc(struct xml_loc *data, enum datas_loc type)
{
int8 *str = dummy;
if ( !data)
return str;
switch(type)
{
case DNAM: str = data->dnam; break;
case SUNR: str = data->sunr; break;
case SUNS: str = data->suns; break;
default: break;
}
return str;
}
const int8 *get_data(struct xml_weather *data, enum datas type)
{
int8 *str = dummy;
if( data)
{
switch (type & 0xFF00)
{
case DATAS_CC: str = get_data_cc(data->cc, type); break;
case DATAS_LOC: str = get_data_loc(data->loc, type); break;
default: break;
}
}
return str;
}
int8 *get_data_part(struct xml_part *data, enum forecast type)
{
int8 *str = dummy;
if ( !data)
return str;
switch (type & 0x000F)
{
case F_ICON: str = data->icon; break;
case F_TRANS: str = data->t; break;
case F_PPCP: str = data->ppcp; break;
case F_W_SPEED: str = get_data_wind(data->wind, _WIND_SPEED); break;
case F_W_DIRECTION: str = get_data_wind(data->wind, _WIND_DIRECTION); break;
default: break;
}
return str;
}
const int8 *get_data_f(struct xml_dayf *data, enum forecast type)
{
int8 *str = dummy;
if (data)
{
switch (type & 0x0F00)
{
case ITEMS:
switch(type)
{
case WDAY: str = data->day; break;
case TEMP_MIN: str = data->low; break;
case TEMP_MAX: str = data->hi; break;
default: break;
}
break;
case NPART: str = get_data_part(data->part[1], type); break;
case DPART: str = get_data_part(data->part[0], type); break;
}
}
return str;
}
const int8 *get_unit( int myunit, enum datas type)
{
int8 *str = dummy;
switch (type & 0x00F0)
{
case 0x0020: str = (myunit == WEATHER_METRIC ? "<EFBFBD> C" : "<EFBFBD> F"); break;
case 0x0030: str = "%"; break;
case 0x0040: str = (myunit == WEATHER_METRIC ? "km/h" : "mph"); break;
case 0x0050: str = (myunit == WEATHER_METRIC ? "mb" : "in"); break;
default: break;
}
return str;
}
const int8 *get_lnks(struct xml_lnks *lnks, enum link type, int num)
{
int8* str = "";
if( !lnks || num >= XML_WEATHER_LINK_N)
return str;
switch (type)
{
case LINK:
str = lnks->l[num];
case TEXT:
str = lnks->t[num];
default:
break;
}
return str;
}

View File

@@ -0,0 +1,98 @@
#ifndef GET_DATA_H
#define GET_DATA_H
#include "parsers.h"
#define DATAS_CC 0x0100
#define DATAS_LOC 0x0200
#define DATAS_DAYF 0x0300
enum datas_wind {
_WIND_SPEED,
_WIND_GUST,
_WIND_DIRECTION,
_WIND_TRANS
};
enum datas_bar {
_BAR_R,
_BAR_D
};
enum datas_uv {
_UV_INDEX,
_UV_TRANS
};
enum datas {
/* cc */
LSUP = 0x0101,
OBST = 0x0102,
TRANS = 0x0103,
VIS = 0x0104,
UV_INDEX = 0x0105,
UV_TRANS = 0x0106,
WIND_DIRECTION = 0x0107,
BAR_D = 0x0108,
WIND_TRANS = 0x0109,
WICON = 0x0110,
FLIK = 0x0120,
TEMP = 0x0121,
DEWP = 0x0122,
HMID = 0x0130,
WIND_SPEED = 0x0140,
WIND_GUST = 0x0141,
BAR_R = 0x0150
};
enum datas_loc {
DNAM = 0x0201,
SUNR = 0x0202,
SUNS = 0x0203
};
enum forecast {
ITEMS = 0x0100,
WDAY = 0x0101,
TEMP_MIN = 0x0102,
TEMP_MAX = 0x0103,
F_ICON = 0x0001,
F_PPCP = 0x0002,
F_W_DIRECTION = 0x0003,
F_W_SPEED = 0x0004,
F_TRANS = 0x0005,
NPART = 0x0200,
ICON_N = 0x0201,
PPCP_N = 0x0202,
W_DIRECTION_N = 0x0203,
W_SPEED_N = 0x0204,
TRANS_N = 0x0205,
DPART = 0x0300,
ICON_D = 0x0301,
PPCP_D = 0x0302,
W_DIRECTION_D = 0x0303,
W_SPEED_D = 0x0304,
TRANS_D = 0x0305
};
enum link {
LINK,
TEXT
};
const int8 *get_data(struct xml_weather *data, enum datas type);
const int8 *get_data_f(struct xml_dayf * , enum forecast type);
const int8 *get_unit( int myunit, enum datas type);
const int8 *get_lnks(struct xml_lnks *lnks, enum link type, int num);
#endif

View File

@@ -0,0 +1,52 @@
xxxxxxxxxxxxxxxxx
=================
News:
-----
- Automatic TCP/IP layer detection( MiNTNet or Sting/StiK).
- Launch time 2X faster.
- smaller memory requirement.
- Compiled with latest Windom 2.x
Bugs fixes:
-----------
- Now, the keyboard's shortcut to the "preference" tab works.
- Look better under Xaaes.
- corrected a little memory leak.
27 January 2010: 1.02
=====================
- Fixed issues with memory protection
- Updated for correct cooperation with zweather.com
8 August 2005: 1.01
===================
- Updated to use the news zview codecs.
14 march 2005: FINAL 1.0
========================
- STing compatibility layer added.
- Now, zweather works on old 8+3 partitions.
- A very bad bug was present in "icon" code.. it caused a memory leak.
- Minor bugs fixes about text alignment.
- Some code clean up.
- 'O.png' had an incorrect size.
3 march 2005: BETA1
===================
- First public release.

View File

@@ -0,0 +1,155 @@
#include "general.h"
#include "inet.h"
long http_recv( int32 fd, int8 **buffer)
{
long n = 0L; /* 1 = good, 0 = conn terminated, -1 = error */
int8 thisbuffer[1024];
clock_t time_out = 0;
for(;;)
{
n = inet_recv ( fd, thisbuffer, 1023L);
if( n < 0L)
{
*buffer = NULL;
break;
}
else if( n == 0)
{
clock_t clk = clock();
if ( !time_out)
{
time_out = clk;
continue;
}
else if (( clk -= time_out) < 3000)
{
continue;
}
else break;
}
else
{
thisbuffer[n] = '\0';
*buffer = strdup(( const int8 *)thisbuffer);
break;
}
}
return n;
}
boolean http_get_header( int32 fd, int8 **buffer)
{
int8 lastchar = 0, *thisbuffer;
int32 l;
while((l = http_recv( fd, &thisbuffer)) > 0)
{
boolean found = FALSE;
int8 *where = NULL, *p;
if (lastchar == '\r' && ( p = strstr_len( thisbuffer, 3, "\n\r\n")))
{
where = p + 3;
found = TRUE;
}
else if (( p = strstr(thisbuffer, "\r\n\r\n")))
{
where = p + 4;
found = TRUE;
}
if( found)
{
/*TODO check if at end*/
*buffer = strdup(where);
}
else
lastchar = thisbuffer[l];
free(thisbuffer);
if( found)
return TRUE;
}
return FALSE;
}
int16 http_get_file( int8 *url, int8 *hostname, int8 *filename)
{
int32 addr, fd = -1, error;
FILE *file = NULL;
int8 *buffer= NULL, *request = NULL;
if( inet_host_addr ( hostname, &addr) != E_OK)
{
return FALSE;
}
if( !( fd = inet_connect( addr, 80, 10)))
{
return FALSE;
}
request = strdup_printf( "GET %s HTTP/1.0\r\n""HOST: %s\r\n\r\n", url, hostname);
if( request == NULL)
{
inet_close(fd);
return FALSE;
}
error = inet_send( fd, request, strlen(request));
free( request);
if ( error <= 0)
{
inet_close(fd);
return FALSE;
}
file = fopen( filename, "w");
if ( !file)
{
inet_close(fd);
return FALSE;
}
if( http_get_header( fd, &buffer) == FALSE)
{
inet_close(fd);
fclose(file);
return FALSE;
}
if( buffer)
{
int l = strlen(buffer);
fwrite(buffer, sizeof(char), l, file);
free(buffer);
}
while(( error = http_recv(fd, &buffer)) > 0)
{
int l = strlen( buffer);
fwrite( buffer, sizeof(char), l, file);
free(buffer);
}
fclose(file);
inet_close(fd);
if( error != -316)
return FALSE;
return TRUE;
}

View File

@@ -0,0 +1 @@
extern int16 http_get_file( int8 *url, int8 *hostname, int8 *filename);

View File

@@ -0,0 +1,593 @@
#include "general.h"
IMAGE *weather_icons = { NULL };
MFDB *main_icon = NULL;
MFDB boussole;
IMAGE *logo = NULL;
MFDB *forecast_icon[5] = { NULL };
MFDB icons[48];
int16 codec_load = 0;
int16 register_icons( void)
{
MFDB *bm;
uint8 *data;
uint32 icon_buffer_size = 288 * app.nplanes;
if( !( codec_load = codecs_init( "png.ldg")))
return 0;
if( !( weather_icons = load_img( "icons\\weather.png", -1, -1, 1)))
return 0;
if( !( logo = load_img( "icons\\logo.png", -1, -1, 1)))
return 0;
bm = &icons[1]; // why 1 ???
data = weather_icons->image->fd_addr;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[2];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[3];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[4];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[5];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[6];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[7];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[8];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[9];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[10];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = icons[8].fd_addr;
bm = &icons[11];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = icons[6].fd_addr;
bm = &icons[12];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[13];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[14];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[15];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = icons[5].fd_addr;
bm = &icons[16];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = icons[5].fd_addr;
bm = &icons[17];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = icons[3].fd_addr;
bm = &icons[18];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = icons[12].fd_addr;
bm = &icons[19];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[20];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[21];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = icons[19].fd_addr;
bm = &icons[22];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[23];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = icons[1].fd_addr;
bm = &icons[24];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = icons[1].fd_addr;
bm = &icons[25];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[26];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[27];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[28];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[29];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[30];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[31];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[32];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[33];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[34];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[35];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = icons[3].fd_addr;
bm = &icons[36];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = icons[25].fd_addr;
bm = &icons[37];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = icons[3].fd_addr;
bm = &icons[38];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = icons[3].fd_addr;
bm = &icons[39];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = icons[12].fd_addr;
bm = &icons[40];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = icons[12].fd_addr;
bm = &icons[41];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = icons[5].fd_addr;
bm = &icons[42];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = icons[5].fd_addr;
bm = &icons[43];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[44];
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = icons[30].fd_addr;
bm = &icons[45];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[46];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &icons[47];
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
bm = &boussole;
data += icon_buffer_size;
bm->fd_w = 48;
bm->fd_h = 48;
bm->fd_wdwidth = 3;
bm->fd_stand = 0;
bm->fd_nplanes = app.nplanes;
bm->fd_r1 = 0;
bm->fd_r2 = 0;
bm->fd_r3 = 0;
bm->fd_addr = data;
return 1;
}
void unregister_icons( void)
{
if( codec_load == 0)
return;
delete_img( logo);
delete_img( weather_icons);
codecs_quit();
}

View File

@@ -0,0 +1,8 @@
IMAGE *logo;
IMAGE *weather_icons;
MFDB boussole;
MFDB *forecast_icon[6];
MFDB icons[48];
MFDB *main_icon;
extern int16 register_icons( void);
extern void unregister_icons( void);

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View File

@@ -0,0 +1,202 @@
#include "general.h"
#include <transprt.h>
static boolean timeout = FALSE;
TPL *tpl = NULL;
DRV_LIST *drivers = NULL;
static void sig_alrm (long sig)
{
(void)sig;
timeout = TRUE;
}
void init_stik (void)
{
if ( !tpl)
{
struct {
long cktag;
long ckvalue;
} * jar = (void*)Setexc (0x5A0 /4, (void (*)())-1);
long tag = 'STiK';
while (jar->cktag) {
if (jar->cktag == tag) {
drivers = (DRV_LIST*)jar->ckvalue;
if (strcmp (MAGIC, drivers->magic) == 0) {
tpl = (TPL*)get_dftab(TRANSPORT_DRIVER);
}
break;
}
jar++;
}
}
}
void inet_close (long fh)
{
if( fh >= 0)
{
if ( tpl && use_sting)
TCP_close ((int16)fh, 0, NULL);
else
close (fh);
}
}
short inet_host_addr ( const char * name, long * addr)
{
short ret = -1;
if ( tpl && use_sting)
{
// zdebug( "STING");
if ( resolve ((char*)name, NULL, ( uint32*)addr, 1) > 0)
ret = E_OK;
}
else
{
// zdebug( "MintNet");
struct hostent *host = gethostbyname (name);
if (host)
{
*addr = *(long*)host->h_addr;
ret = E_OK;
}
else
ret = -errno;
}
return ret;
}
long inet_connect (long addr, long port, long tout_sec)
{
long fh = -1;
if ( tpl && use_sting)
{
long alrm = Psignal (14/*SIGALRM*/, (long)sig_alrm);
if (alrm >= 0) {
timeout = FALSE;
Talarm (tout_sec);
}
if ((fh = TCP_open (addr, (int16)port, 0, 1024)) < 0) {
fh = -( fh == -1001L ? ETIMEDOUT : 1);
}
if (alrm >= 0) {
Talarm (0);
Psignal (14/*SIGALRM*/, alrm);
}
}
else
{
struct sockaddr_in s_in;
s_in.sin_family = AF_INET;
s_in.sin_port = htons ((short)port);
s_in.sin_addr = *(struct in_addr *)&addr;
if ((fh = socket( PF_INET, SOCK_STREAM, 0)) < 0) {
fh = -errno;
} else {
long alrm = Psignal (14/*SIGALRM*/, (long)sig_alrm);
if (alrm >= 0) {
timeout = FALSE;
Talarm (tout_sec);
}
if (connect (fh, (struct sockaddr *)&s_in, sizeof (s_in)) < 0) {
close (fh);
fh = -( timeout && errno == EINTR ? ETIMEDOUT : errno);
}
if (alrm >= 0) {
Talarm (0);
Psignal (14/*SIGALRM*/, alrm);
}
}
}
return fh;
}
long inet_send( long fh, const char * buf, size_t len)
{
long ret = -1;
if ( tpl && use_sting)
{
if ((ret = TCP_send ((int16)fh, (char*)buf, (int16)len)) == 0)
ret = len;
}
else
ret = Fwrite( fh, len, buf);
return ret;
}
long inet_recv (long fh, char *buf, size_t len)
{
long ret = 0;
if ( tpl && use_sting)
{
while (len)
{
short n = CNbyte_count ((int16)fh);
if (n < E_NODATA)
{
if ( !ret) ret = (n == E_EOF || n == E_RRESET ? -316 : -1);
break;
}
else if (n > 0)
{
if (n > len) n = len;
if ((n = CNget_block ((int16)fh, buf, n)) < 0)
{
if (!ret) ret = -1;
break;
}
else
{
ret += n;
buf += n;
len -= n;
}
} else break;
}
}
else
{
while (len)
{
long n = Finstat (fh);
if (n < 0) {
if (!ret) ret = n;
break;
} else if (n == 0x7FFFFFFF) { /* connection closed */
if ( !ret) ret = -316;
break;
} else if (n && (n = Fread (fh, ( n < len ? n : len), buf)) < 0) {
if (!ret) ret = -errno;
break;
} else if (n) {
ret += n;
buf += n;
len -= n;
} else break;
}
}
return ret;
}

View File

@@ -0,0 +1,6 @@
extern void inet_close (long fh);
extern short inet_host_addr (const char * name, long * addr);
extern long inet_connect (long addr, long port, long tout_sec);
extern long inet_send( long fh, const char * buf, size_t len);
extern long inet_recv (long fh, char *buf, size_t len);

View File

@@ -0,0 +1,266 @@
#include "general.h"
#include "http_client.h"
#include "parsers.h"
#include "icon.h"
#include "get_data.h"
#include <mint/cookie.h>
static clock_t chrono_value;
struct xml_weather *zweatherdata = NULL;
int use_sting = 0;
extern void init_stik (void);
extern void weather_dialog( void);
extern int8 wind_direction[8];
extern int8 icon_temp[8];
struct xml_weather *update_weatherdata( int8 *location)
{
OBJECT *weather_form = get_tree( WEATHER);
xmlNode *cur_node = NULL;
xmlDoc *doc = NULL;
struct xml_weather *weather = NULL;
struct stat attrs;
int icon_to_draw;
int8 fullfilename[256], url[1024];
sprintf( fullfilename, "cache\\%s.xml", location);
sprintf( url, "/weather/local/%s?cc=*&dayf=%d&unit=%c", location, XML_WEATHER_DAYF_N, unit == WEATHER_METRIC ? 'm' : 's');
strcat( url, "&link=xoap&prod=xoap&par=1160181056&key=1031965b2f676b1b" );
if( !http_get_file( url, "xoap.weather.com", fullfilename))
return NULL;
stat( fullfilename, &attrs);
if( attrs.st_size < 1024)
{
errshow( "", BADDATA);
return NULL;
}
if( !( doc = xmlParseFile( fullfilename)))
return NULL;
cur_node = xmlDocGetRootElement( doc);
if( cur_node)
{
const int8 *sTmp;
weather = parse_weather( cur_node);
sprintf( weather_form[WEATHER_REPORT].ob_spec.tedinfo->te_ptext, "%s", get_data(weather, DNAM));
sprintf( weather_form[WEATHER_TIME].ob_spec.tedinfo->te_ptext, "Last update: %s", get_data(weather, LSUP));
sprintf( weather_form[WEATHER_TEMP].ob_spec.tedinfo->te_ptext, "%s%s", get_data(weather, TEMP), get_unit(unit, TEMP));
sprintf( weather_form[WEATHER_FEEL].ob_spec.tedinfo->te_ptext, "%s%s", get_data(weather, FLIK), get_unit(unit, FLIK));
zstrncpy( weather_form[WEATHER_DESCRIPTION].ob_spec.tedinfo->te_ptext, get_data(weather, TRANS), 26L);
sprintf( weather_form[WEATHER_DEW].ob_spec.tedinfo->te_ptext, "%s%s", get_data(weather, DEWP), get_unit(unit, DEWP));
sprintf( weather_form[WEATHER_WSPEED].ob_spec.tedinfo->te_ptext, "%s %s", get_data(weather, WIND_SPEED), get_unit(unit, WIND_SPEED));
sprintf( weather_form[WEATHER_SUNRISE].ob_spec.tedinfo->te_ptext, "%s", get_data(weather, SUNR));
sprintf( weather_form[WEATHER_SUNSET].ob_spec.tedinfo->te_ptext, "%s", get_data(weather, SUNS));
sprintf( weather_form[WEATHER_UV].ob_spec.tedinfo->te_ptext, "%s %s", get_data(weather, UV_INDEX), get_data(weather, UV_TRANS));
sprintf( weather_form[WEATHER_HUMIDITY].ob_spec.tedinfo->te_ptext, "%s%s", get_data(weather, HMID), get_unit(unit, HMID));
sprintf( weather_form[WEATHER_VISIBILITY].ob_spec.tedinfo->te_ptext, "%s", get_data(weather, VIS));
sprintf( weather_form[WEATHER_PRESSURE].ob_spec.tedinfo->te_ptext, "%s %s and %s.", get_data(weather, BAR_R), get_unit(unit, BAR_R), get_data(weather, BAR_D));
sprintf( ObjcString( weather_form, WEATHER_FORECAST1, NULL), " %s ", get_data_f(weather->dayf[0], WDAY));
// today data may be outdated afternoon
sTmp = get_data_f(weather->dayf[0], TEMP_MAX);
strcpy( weather_form[WEATHER_DAY1].ob_spec.tedinfo->te_ptext, sTmp);
if( strcmp( sTmp, "N/A") != 0)
{
strcat( weather_form[WEATHER_DAY1].ob_spec.tedinfo->te_ptext, get_unit(unit, TEMP));
}
sTmp = get_data_f(weather->dayf[0], TEMP_MIN);
strcpy( weather_form[WEATHER_NIGHT1].ob_spec.tedinfo->te_ptext, sTmp);
if( strcmp( sTmp, "N/A") != 0)
{
strcat( weather_form[WEATHER_NIGHT1].ob_spec.tedinfo->te_ptext, get_unit(unit, TEMP));
}
sTmp = get_data_f(weather->dayf[0], W_SPEED_D);
strcpy( weather_form[WEATHER_WIND1].ob_spec.tedinfo->te_ptext, sTmp);
if( strcmp( sTmp, "N/A") != 0)
{
strcat( weather_form[WEATHER_WIND1].ob_spec.tedinfo->te_ptext, " ");
strcat( weather_form[WEATHER_WIND1].ob_spec.tedinfo->te_ptext, get_unit(unit, WIND_SPEED));
}
zstrncpy( weather_form[WEATHER_DESCRIPTION1].ob_spec.tedinfo->te_ptext, get_data_f(weather->dayf[0], TRANS_D), 18L);
sprintf( ObjcString( weather_form, WEATHER_FORECAST2, NULL), " %s ", get_data_f(weather->dayf[1], WDAY));
sprintf( weather_form[WEATHER_DAY2].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[1], TEMP_MAX), get_unit(unit, TEMP));
sprintf( weather_form[WEATHER_NIGHT2].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[1], TEMP_MIN), get_unit(unit, TEMP));
sprintf( weather_form[WEATHER_WIND2].ob_spec.tedinfo->te_ptext, "%s %s",get_data_f(weather->dayf[1], W_SPEED_D), get_unit(unit, WIND_SPEED));
zstrncpy( weather_form[WEATHER_DESCRIPTION2].ob_spec.tedinfo->te_ptext, get_data_f(weather->dayf[1], TRANS_D), 18L);
sprintf( ObjcString( weather_form, WEATHER_FORECAST3, NULL), " %s ", get_data_f(weather->dayf[2], WDAY));
sprintf( weather_form[WEATHER_DAY3].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[2], TEMP_MAX), get_unit(unit, TEMP));
sprintf( weather_form[WEATHER_NIGHT3].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[2], TEMP_MIN), get_unit(unit, TEMP));
sprintf( weather_form[WEATHER_WIND3].ob_spec.tedinfo->te_ptext, "%s %s",get_data_f(weather->dayf[2], W_SPEED_D), get_unit(unit, WIND_SPEED));
zstrncpy( weather_form[WEATHER_DESCRIPTION3].ob_spec.tedinfo->te_ptext, get_data_f(weather->dayf[2], TRANS_D), 18L);
sprintf( ObjcString( weather_form, WEATHER_FORECAST4, NULL), " %s ", get_data_f(weather->dayf[3], WDAY));
sprintf( weather_form[WEATHER_DAY4].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[3], TEMP_MAX), get_unit(unit, TEMP));
sprintf( weather_form[WEATHER_NIGHT4].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[3], TEMP_MIN), get_unit(unit, TEMP));
sprintf( weather_form[WEATHER_WIND4].ob_spec.tedinfo->te_ptext, "%s %s",get_data_f(weather->dayf[3], W_SPEED_D), get_unit(unit, WIND_SPEED));
zstrncpy( weather_form[WEATHER_DESCRIPTION4].ob_spec.tedinfo->te_ptext, get_data_f(weather->dayf[3], TRANS_D), 18L);
sprintf( ObjcString( weather_form, WEATHER_FORECAST5, NULL), " %s ", get_data_f(weather->dayf[4], WDAY));
sprintf( weather_form[WEATHER_DAY5].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[4], TEMP_MAX), get_unit(unit, TEMP));
sprintf( weather_form[WEATHER_NIGHT5].ob_spec.tedinfo->te_ptext, "%s%s",get_data_f(weather->dayf[4], TEMP_MIN), get_unit(unit, TEMP));
sprintf( weather_form[WEATHER_WIND5].ob_spec.tedinfo->te_ptext, "%s %s",get_data_f(weather->dayf[4], W_SPEED_D), get_unit(unit, WIND_SPEED));
zstrncpy( weather_form[WEATHER_DESCRIPTION5].ob_spec.tedinfo->te_ptext, get_data_f(weather->dayf[4], TRANS_D), 18L);
zstrncpy( weather_form[WEATHER_LINK1].ob_spec.tedinfo->te_ptext, get_lnks(weather->lnks, TEXT, 0), 20L);
zstrncpy( weather_form[WEATHER_LINK2].ob_spec.tedinfo->te_ptext, get_lnks(weather->lnks, TEXT, 1), 20L);
zstrncpy( weather_form[WEATHER_LINK3].ob_spec.tedinfo->te_ptext, get_lnks(weather->lnks, TEXT, 2), 20L);
zstrncpy( weather_form[WEATHER_LINK4].ob_spec.tedinfo->te_ptext, get_lnks(weather->lnks, TEXT, 3), 20L);
icon_to_draw = atoi( ( const char*)get_data(weather, WICON));
main_icon = &icons[icon_to_draw];
icon_to_draw = atoi( ( const char*)get_data_f(weather->dayf[0], ICON_D));
forecast_icon[0] = &icons[icon_to_draw];
icon_to_draw = atoi( ( const char*)get_data_f(weather->dayf[1], ICON_D));
forecast_icon[1] = &icons[icon_to_draw];
icon_to_draw = atoi( ( const char*)get_data_f(weather->dayf[2], ICON_D));
forecast_icon[2] = &icons[icon_to_draw];
icon_to_draw = atoi( ( const char*)get_data_f(weather->dayf[3], ICON_D));
forecast_icon[3] = &icons[icon_to_draw];
icon_to_draw = atoi( ( const char*)get_data_f(weather->dayf[4], ICON_D));
forecast_icon[4] = &icons[icon_to_draw];
sprintf( icon_temp, "%s<>", get_data( weather, TEMP));
sprintf( wind_direction, "%s", get_data( weather, WIND_DIRECTION));
}
xmlFreeDoc( doc);
return weather;
}
void timer_function( WINDOW *win, short buff[8])
{
#ifdef DEBUG
char tmp[15];
struct tm *tmt;
time_t tim;
#endif
clock_t current_t = clock();
clock_t relative_t;
relative_t = current_t - chrono_value;
if( relative_t < update_time)
return;
chrono_value = current_t;
#ifdef DEBUG
tim = time( NULL);
tmt = localtime( &tim);
strftime( tmp, 12, "%H:%M:%S", tmt);
zdebug( "update: %s", tmp);
#endif
if( zweatherdata)
xml_weather_free( zweatherdata);
zweatherdata = update_weatherdata( location_code);
if( windialog)
snd_rdw( windialog);
}
void applexit( WINDOW *w, short buff[8])
{
WINDOW *last_closed = NULL;
if( EvntFind( NULL, WM_XTIMER))
EvntDelete( NULL, WM_XTIMER);
while( wglb.first)
{
if (last_closed != wglb.first)
{
ApplWrite( _AESapid, WM_DESTROY, wglb.first->handle, 0, 0, 0, 0);
last_closed = wglb.first; /* to prevent sending toons of WM_CLOSED messages to each window */
}
if( EvntWindom( MU_MESAG | MU_TIMER) & MU_TIMER) /* MU_TIMER event catched ? */
last_closed = NULL; /* then WM_CLOSED message has been lost ! it should be resent */
}
if( zweatherdata)
xml_weather_free( zweatherdata);
xmlCleanupParser();
prefs_write();
unregister_icons();
RsrcXtype( 0, NULL, 0);
RsrcFree();
ApplExit();
exit( 0);
}
int main( int argc, char *argv[])
{
int32 sting = 0;
ApplInit();
if( !RsrcLoad( "zweather.rsc"))
{
errshow( "", E_RSC);
ApplExit();
return 0;
}
RsrcXtype( RSRC_XTYPE, NULL, 0);
if( !register_icons())
{
errshow( "", NOZCODECS);
unregister_icons();
RsrcXtype( 0, NULL, 0);
RsrcFree();
ApplExit();
return 0;
}
if( _AESnumapps == -1)
menu_register( _AESapid, "zWeather");
prefs_read();
if( Getcookie( C_STiK, ( long*)&sting) != 0)
{
use_sting = 1;
init_stik();
}
zweatherdata = update_weatherdata( location_code);
evnt.timer = 1000L;
weather_dialog();
chrono_value = clock();
EvntAttach( NULL, WM_XTIMER, timer_function);
EvntAttach( NULL, AP_TERM, applexit);
for(;;)
EvntWindom( MU_MESAG|MU_TIMER|MU_KEYBD|MU_BUTTON);
return 0;
}

View File

@@ -0,0 +1,391 @@
#include "general.h"
#include "parsers.h"
struct xml_weather *parse_weather( xmlNode *cur_node)
{
struct xml_weather *ret;
if( !NODE_IS_TYPE(cur_node, "weather"))
return NULL;
if(( ret = malloc( sizeof( struct xml_weather))) == NULL)
return NULL;
for( cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
{
if(cur_node->type != XML_ELEMENT_NODE)
continue;
if( NODE_IS_TYPE( cur_node, "cc"))
ret->cc = parse_cc(cur_node);
else if( NODE_IS_TYPE(cur_node, "loc"))
ret->loc = parse_loc(cur_node);
else if( NODE_IS_TYPE(cur_node, "lnks"))
ret->lnks = parse_lnks(cur_node);
else if( NODE_IS_TYPE(cur_node, "dayf"))
{
xmlNode *child_node;
int i = 0;
for( child_node = cur_node->children; child_node; child_node = child_node->next)
{
if( NODE_IS_TYPE(child_node, "day"))
{
if( i >= XML_WEATHER_DAYF_N)
break;
ret->dayf[i] = parse_dayf( child_node);
i++;
}
}
}
}
return ret;
}
struct xml_loc *parse_loc(xmlNode *cur_node)
{
struct xml_loc *ret;
if(( ret = malloc( sizeof( struct xml_loc))) == NULL)
return NULL;
for( cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
{
if( cur_node->type != XML_ELEMENT_NODE)
continue;
if( NODE_IS_TYPE(cur_node, "dnam"))
ret->dnam = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "sunr"))
ret->sunr = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "suns"))
ret->suns = DATA(cur_node);
}
return ret;
}
struct xml_lnks *parse_lnks(xmlNode *cur_node)
{
struct xml_lnks *ret;
int i = 0;
if ((ret = malloc( sizeof(struct xml_lnks))) == NULL)
return NULL;
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
{
if (cur_node->type != XML_ELEMENT_NODE)
continue;
if (NODE_IS_TYPE(cur_node, "link"))
{
xmlNode *child_node;
if( i >= XML_WEATHER_LINK_N)
break;
for( child_node = cur_node->children; child_node; child_node = child_node->next)
{
if (NODE_IS_TYPE(child_node, "l"))
{
ret->l[i] = DATA(child_node);
}
else if (NODE_IS_TYPE(child_node, "t"))
{
ret->t[i] = DATA(child_node);
}
}
i++;
}
}
return ret;
}
struct xml_uv *parse_uv (xmlNode *cur_node)
{
struct xml_uv *ret;
if(( ret = malloc( sizeof( struct xml_uv))) == NULL)
return NULL;
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
{
if (cur_node->type != XML_ELEMENT_NODE)
continue;
if (NODE_IS_TYPE(cur_node, "i"))
ret->i = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "t"))
ret->t = DATA(cur_node);
}
return ret;
}
struct xml_bar *parse_bar (xmlNode *cur_node)
{
struct xml_bar *ret;
if ((ret = malloc(sizeof( struct xml_bar))) == NULL)
return NULL;
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
{
if (cur_node->type != XML_ELEMENT_NODE)
continue;
if (NODE_IS_TYPE(cur_node, "r"))
ret->r = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "d"))
ret->d = DATA(cur_node);
}
return ret;
}
struct xml_wind *parse_wind (xmlNode *cur_node)
{
struct xml_wind *ret;
if ((ret = malloc(sizeof( struct xml_wind))) == NULL)
return NULL;
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
{
if (cur_node->type != XML_ELEMENT_NODE)
continue;
if (NODE_IS_TYPE(cur_node, "s"))
ret->s = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "gust"))
ret->gust = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "d"))
ret->d = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "t"))
ret->t = DATA(cur_node);
}
return ret;
}
struct xml_cc *parse_cc(xmlNode *cur_node)
{
struct xml_cc *ret;
if ((ret = malloc( sizeof(struct xml_cc))) == NULL)
return NULL;
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
{
if (cur_node->type != XML_ELEMENT_NODE)
continue;
if (NODE_IS_TYPE(cur_node, "tmp"))
ret->tmp = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "icon"))
ret->icon = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "t"))
ret->t = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "flik"))
ret->flik = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "bar"))
ret->bar = parse_bar(cur_node);
else if (NODE_IS_TYPE(cur_node, "wind"))
ret->wind = parse_wind(cur_node);
else if (NODE_IS_TYPE(cur_node, "hmid"))
ret->hmid = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "vis"))
ret->vis = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "uv"))
ret->uv = parse_uv(cur_node);
else if (NODE_IS_TYPE(cur_node, "dewp"))
ret->dewp = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "lsup"))
ret->lsup = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "obst"))
ret->obst = DATA(cur_node);
}
return ret;
}
struct xml_part *parse_part(xmlNode *cur_node)
{
struct xml_part *ret;
if (( ret = malloc( sizeof( struct xml_part))) == NULL)
return NULL;
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
{
if (cur_node->type != XML_ELEMENT_NODE)
continue;
if (NODE_IS_TYPE(cur_node, "icon"))
ret->icon = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "t"))
ret->t = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "wind"))
ret->wind = parse_wind(cur_node);
else if (NODE_IS_TYPE(cur_node, "ppcp"))
ret->ppcp = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "hmid"))
ret->hmid = DATA(cur_node);
}
return ret;
}
struct xml_dayf *parse_dayf(xmlNode *cur_node)
{
struct xml_dayf *ret;
int8 *value;
if ((ret = malloc(sizeof(struct xml_dayf))) == NULL)
return NULL;
ret->day = xmlGetProp (cur_node, (const xmlChar *) "t");
ret->date = xmlGetProp (cur_node, (const xmlChar *) "dt");
for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
{
if (cur_node->type != XML_ELEMENT_NODE)
continue;
if (NODE_IS_TYPE(cur_node, "hi"))
ret->hi = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "low"))
ret->low = DATA(cur_node);
else if (NODE_IS_TYPE(cur_node, "part"))
{
value = xmlGetProp (cur_node, (const xmlChar *) "p");
if (xmlStrEqual ((const xmlChar *)value, "d"))
ret->part[0] = parse_part(cur_node);
else if (xmlStrEqual ((const xmlChar *)value, "n"))
ret->part[1] = parse_part(cur_node);
free(value);
}
}
return ret;
}
#define CHK_FREE(this) if (this) free(this);
void xml_uv_free(struct xml_uv *data)
{
CHK_FREE(data->i);
CHK_FREE(data->t);
}
void xml_wind_free(struct xml_wind *data)
{
CHK_FREE(data->s);
CHK_FREE(data->gust);
CHK_FREE(data->d);
CHK_FREE(data->t);
}
void xml_bar_free(struct xml_bar *data)
{
CHK_FREE(data->r);
CHK_FREE(data->d);
}
void xml_cc_free(struct xml_cc *data)
{
CHK_FREE(data->obst);
CHK_FREE(data->lsup);
CHK_FREE(data->flik);
CHK_FREE(data->t);
CHK_FREE(data->icon);
CHK_FREE(data->tmp);
CHK_FREE(data->hmid);
CHK_FREE(data->vis);
CHK_FREE(data->dewp);
if (data->uv)
xml_uv_free(data->uv);
if (data->wind)
xml_wind_free(data->wind);
if (data->bar)
xml_bar_free(data->bar);
}
void xml_loc_free(struct xml_loc *data)
{
CHK_FREE(data->dnam);
CHK_FREE(data->sunr);
CHK_FREE(data->suns);
}
void xml_part_free(struct xml_part *data)
{
if( !data)
return;
CHK_FREE(data->icon);
CHK_FREE(data->t);
CHK_FREE(data->ppcp);
CHK_FREE(data->hmid);
if (data->wind)
xml_wind_free(data->wind);
}
void xml_dayf_free(struct xml_dayf *data)
{
if (!data)
return;
CHK_FREE(data->day);
CHK_FREE(data->date);
CHK_FREE(data->hi);
CHK_FREE(data->low);
if (data->part[0])
xml_part_free(data->part[0]);
if (data->part[1])
xml_part_free(data->part[1]);
}
void xml_weather_free(struct xml_weather *data)
{
if (data->cc)
xml_cc_free( data->cc);
if (data->loc)
xml_loc_free( data->loc);
if( data->lnks)
{
int i;
for (i = 0; i < XML_WEATHER_LINK_N; i++)
{
CHK_FREE(data->lnks->l[i]);
CHK_FREE(data->lnks->t[i]);
}
}
if (data->dayf)
{
int i;
for (i = 0; i < XML_WEATHER_DAYF_N; i++)
{
if (!data->dayf[i])
break;
xml_dayf_free(data->dayf[i]);
}
}
free(data);
}

View File

@@ -0,0 +1,99 @@
#ifndef PARSERS_H
#define PARSERS_H
#define DATA(node) xmlNodeListGetString(node->doc, node->children, 1)
#define NODE_IS_TYPE(node, type) xmlStrEqual (node->name, (const xmlChar *) type)
#define XML_WEATHER_DAYF_N 5
#define XML_WEATHER_LINK_N 4
struct xml_weather
{
struct xml_loc *loc;
struct xml_lnks *lnks;
struct xml_cc *cc;
struct xml_dayf *dayf[XML_WEATHER_DAYF_N];
};
struct xml_loc
{
int8 *dnam;
int8 *sunr;
int8 *suns;
};
struct xml_lnks
{
int8 *l[XML_WEATHER_LINK_N];
int8 *t[XML_WEATHER_LINK_N];
};
struct xml_uv
{
int8 *i;
int8 *t;
};
struct xml_wind
{
int8 *s;
int8 *gust;
int8 *d;
int8 *t;
};
struct xml_bar
{
int8 *r;
int8 *d;
};
struct xml_cc
{
int8 *lsup;
int8 *obst;
int8 *flik;
int8 *t;
int8 *icon;
int8 *tmp;
int8 *hmid;
int8 *vis;
struct xml_uv *uv;
struct xml_wind *wind;
struct xml_bar *bar;
int8 *dewp;
};
struct xml_part
{
int8 *icon;
int8 *t;
int8 *ppcp;
int8 *hmid;
struct xml_wind *wind;
};
struct xml_dayf
{
int8 *day;
int8 *date;
int8 *hi;
int8 *low;
struct xml_part *part[2];
};
struct xml_weather *parse_weather(xmlNode *cur_node);
struct xml_loc *parse_loc(xmlNode *cur_node);
struct xml_lnks *parse_lnks(xmlNode *cur_node);
struct xml_cc *parse_cc(xmlNode *cur_node);
struct xml_dayf *parse_dayf(xmlNode *cur_node);
void xml_weather_free(struct xml_weather *);
#endif

View File

@@ -0,0 +1,160 @@
#include "general.h"
int unit = WEATHER_METRIC;
int iconify_at_start = 1;
char location_code[9] = "BEXX0006";
clock_t update_time = 360000L;
/* Prototype */
int prefs_read( void);
int prefs_write( void);
/*==================================================================================*
* prefs_read: *
* Reads the content of the INF file an put it in the preference global variables. *
*----------------------------------------------------------------------------------*
* returns: 0 if error *
*==================================================================================*/
int prefs_read( void)
{
char filename[256] = "";
char unknown_s[256] = "";
FILE *inffile;
int time_minute;
int32 filepos;
char *env_home;
int16 len;
boolean valid_entry_found;
shel_envrn( &env_home, "HOME=");
/* Home directory exist? */
if ( env_home != NULL)
{
strcpy( filename, env_home);
len = ( int16)strlen( filename);
if ((filename[len - 1] != '\\') && (filename[len - 1] != '/'))
{
strcat( filename, "\\");
}
strcat( filename, "zweather.inf");
if (( inffile = fopen( filename, "rb+")) != NULL)
goto loop;
}
/* With ftell, we MUST open the file in binary mode and not in text mode !!! */
if (( inffile = fopen( "zweather.inf", "rb+")) == NULL)
return( 0);
loop:
do
{
valid_entry_found = FALSE;
filepos = ftell( inffile);
if ( fscanf( inffile, "unit=%d ", &unit) == 1)
{
valid_entry_found = TRUE;
continue;
}
else
fseek( inffile, filepos, SEEK_SET);
if (fscanf( inffile, "iconify_at_start=%d ", &iconify_at_start) == 1)
{
valid_entry_found = TRUE;
continue;
}
else
fseek( inffile, filepos, SEEK_SET);
if ( fscanf( inffile, "update_time=%d ", &time_minute) == 1)
{
update_time = ( clock_t)( ( int32)time_minute * 12000L);
valid_entry_found = TRUE;
continue;
}
else
fseek( inffile, filepos, SEEK_SET);
if ( fscanf( inffile, "location_code=%s ", location_code) == 1)
{
valid_entry_found = TRUE;
continue;
}
else
fseek( inffile, filepos, SEEK_SET);
if ( fscanf( inffile, "%s ", unknown_s) == 1)
{
valid_entry_found = TRUE;
continue;
}
else
fseek( inffile, filepos, SEEK_SET);
} while ( valid_entry_found);
fclose( inffile);
return( 1);
}
/*==================================================================================*
* prefs_write: *
* Writes the preference variables in the preference file. *
*----------------------------------------------------------------------------------*
* returns: 0 if error *
*==================================================================================*/
int prefs_write( void)
{
char filename[256] = "";
FILE *inffile;
char *env_home;
int time_minute;
int16 len;
shel_envrn( &env_home, "HOME=");
/* Home directory exist? */
if ( env_home)
{
strcpy( filename, env_home);
len = ( int16)strlen( filename);
if ((filename[len - 1] != '\\') && (filename[len - 1] != '/'))
strcat( filename, "\\");
strcat( filename, "zweather.inf");
}
else
strcpy( filename, "zweather.inf");
/* With ftell, we MUST open the file in binary mode and not in text mode !!! */
if (( inffile = fopen( filename, "wb+")) == NULL)
return( 0);
time_minute = ( int)( update_time / 12000L);
fprintf( inffile, "unit=%d\r\n", unit);
fprintf( inffile, "iconify_at_start=%d\r\n", iconify_at_start);
fprintf( inffile, "update_time=%d\r\n", time_minute);
fprintf( inffile, "location_code=%s\r\n", location_code);
fclose( inffile);
return( 1);
}

View File

@@ -0,0 +1,11 @@
/* Global variable */
extern int unit;
extern int iconify_at_start;
extern char location_code[9];
extern clock_t update_time;
/* Function */
extern int prefs_read( void);
extern int prefs_write( void);

View File

@@ -0,0 +1,286 @@
#include "general.h"
#include "icon.h"
#include "get_data.h"
/* the variable need to be global because this function is done by */
/* the AES in supervisor mode.. it's safe. */
static int16 xy[8];
static MFDB screen = {0};
int8 wind_direction[8] = "";
extern struct xml_weather *zweatherdata;
OBJECT *get_tree( int16 obj_index)
{
OBJECT *tree;
RsrcGaddr( NULL, 0, obj_index, &tree);
return tree;
}
/* Return a string from resource file */
int8 *get_string( int16 str_index)
{
int8 *txt;
rsrc_gaddr( 5, str_index, &txt);
return txt;
}
void CDECL draw_boussole_icon( WINDOW *win, PARMBLK *pblk, void *data)
{
xy[0] = xy[1] = 0;
xy[2] = 47;
xy[3] = 47;
xy[4] = pblk->pb_x;
xy[5] = pblk->pb_y;
xy[6] = xy[4] + 47;
xy[7] = xy[5] + 47;
vro_cpyfm( win->graf->handle, S_ONLY, xy, &boussole, &screen);
xy[2] = pblk->pb_x + 23;
xy[3] = pblk->pb_y + 23;
switch( wind_direction[0])
{
case 'N':
if( strcmp( wind_direction, "NNE") == 0)
{
xy[0] = pblk->pb_x + 27;
xy[1] = pblk->pb_y + 9;
break;
}
if( strcmp( wind_direction, "NNW") == 0)
{
xy[0] = pblk->pb_x + 18;
xy[1] = pblk->pb_y + 9;
break;
}
if( strcmp( wind_direction, "NW") == 0)
{
xy[0] = pblk->pb_x + 12;
xy[1] = pblk->pb_y + 12;
break;
}
if( strcmp( wind_direction, "NE") == 0)
{
xy[0] = pblk->pb_x + 34;
xy[1] = pblk->pb_y + 12;
break;
}
/* default 'N'*/
xy[0] = pblk->pb_x + 23;
xy[1] = pblk->pb_y + 8;
break;
case 'E':
if( strcmp( wind_direction, "ENE") == 0)
{
xy[0] = pblk->pb_x + 36;
xy[1] = pblk->pb_y + 17;
break;
}
if( strcmp( wind_direction, "ESE") == 0)
{
xy[0] = pblk->pb_x + 36;
xy[1] = pblk->pb_y + 28;
break;
}
/* default 'E'*/
xy[0] = pblk->pb_x + 38;
xy[1] = pblk->pb_y + 23;
break;
case 'W':
if( strcmp( wind_direction, "WSW") == 0)
{
xy[0] = pblk->pb_x + 9;
xy[1] = pblk->pb_y + 28;
break;
}
if( strcmp( wind_direction, "WNW") == 0)
{
xy[0] = pblk->pb_x + 9;
xy[1] = pblk->pb_y + 17;
break;
}
/* default 'W'*/
xy[0] = pblk->pb_x + 8;
xy[1] = pblk->pb_y + 23;
break;
case 'S':
if( strcmp( wind_direction, "SSE") == 0)
{
xy[0] = pblk->pb_x + 28;
xy[1] = pblk->pb_y + 36;
break;
}
if( strcmp( wind_direction, "SSW") == 0)
{
xy[0] = pblk->pb_x + 18;
xy[1] = pblk->pb_y + 36;
break;
}
if( strcmp( wind_direction, "SW") == 0)
{
xy[0] = pblk->pb_x + 12;
xy[1] = pblk->pb_y + 33;
break;
}
if( strcmp( wind_direction, "SE") == 0)
{
xy[0] = pblk->pb_x + 34;
xy[1] = pblk->pb_y + 33;;
break;
}
default:
/* default 'S'*/
xy[0] = pblk->pb_x + 23;
xy[1] = pblk->pb_y + 38;
break;
}
v_pline( win->graf->handle, 2, xy);
}
void CDECL draw_weather_icon( WINDOW *win, PARMBLK *pblk, void *data)
{
xy[0] = xy[1] = 0;
xy[2] = 47;
xy[3] = 47;
xy[4] = pblk->pb_x;
xy[5] = pblk->pb_y;
xy[6] = xy[4] + 47;
xy[7] = xy[5] + 47;
vro_cpyfm( win->graf->handle, S_ONLY, xy, main_icon, &screen);
}
void CDECL draw_forecast1_icon( WINDOW *win, PARMBLK *pblk, void *data)
{
xy[0] = xy[1] = 0;
xy[2] = 47;
xy[3] = 47;
xy[4] = pblk->pb_x;
xy[5] = pblk->pb_y;
xy[6] = xy[4] + 47;
xy[7] = xy[5] + 47;
vro_cpyfm( win->graf->handle, S_ONLY, xy, forecast_icon[0], &screen);
}
void CDECL draw_forecast2_icon( WINDOW *win, PARMBLK *pblk, void *data)
{
xy[0] = xy[1] = 0;
xy[2] = 47;
xy[3] = 47;
xy[4] = pblk->pb_x;
xy[5] = pblk->pb_y;
xy[6] = xy[4] + 47;
xy[7] = xy[5] + 47;
vro_cpyfm( win->graf->handle, S_ONLY, xy, forecast_icon[1], &screen);
}
void CDECL draw_forecast3_icon( WINDOW *win, PARMBLK *pblk, void *data)
{
xy[0] = xy[1] = 0;
xy[2] = 47;
xy[3] = 47;
xy[4] = pblk->pb_x;
xy[5] = pblk->pb_y;
xy[6] = xy[4] + 47;
xy[7] = xy[5] + 47;
vro_cpyfm( win->graf->handle, S_ONLY, xy, forecast_icon[2], &screen);
}
void CDECL draw_forecast4_icon( WINDOW *win, PARMBLK *pblk, void *data)
{
xy[0] = xy[1] = 0;
xy[2] = 47;
xy[3] = 47;
xy[4] = pblk->pb_x;
xy[5] = pblk->pb_y;
xy[6] = xy[4] + 47;
xy[7] = xy[5] + 47;
vro_cpyfm( win->graf->handle, S_ONLY, xy, forecast_icon[3], &screen);
}
void CDECL draw_forecast5_icon( WINDOW *win, PARMBLK *pblk, void *data)
{
xy[0] = xy[1] = 0;
xy[2] = 47;
xy[3] = 47;
xy[4] = pblk->pb_x;
xy[5] = pblk->pb_y;
xy[6] = xy[4] + 47;
xy[7] = xy[5] + 47;
vro_cpyfm( win->graf->handle, S_ONLY, xy, forecast_icon[4], &screen);
}
void CDECL draw_forecast6_icon( WINDOW *win, PARMBLK *pblk, void *data)
{
xy[0] = xy[1] = 0;
xy[2] = 60;
xy[3] = 60;
xy[4] = pblk->pb_x;
xy[5] = pblk->pb_y;
xy[6] = xy[4] + 60;
xy[7] = xy[5] + 60;
vro_cpyfm( win->graf->handle, S_ONLY, xy, &logo->image[0], &screen);
}
void errshow( const char *name, int16 error)
{
switch( error)
{
case ALERT_WINDOW:
( void)FormAlert( 1 , get_string( ALERT_WINDOW));
break;
case ENOMEM:
( void)FormAlert( 1 , get_string( NOMEM));
break;
case E_RSC:
( void)FormAlert( 1 , "[1][zweather.rsc not found!][Abort]");
break;
case CANT_LOAD_IMG:
( void)FormAlert( 1 , get_string( CANT_LOAD_IMG), name);
break;
case NOZCODECS:
( void)FormAlert( 1 , get_string( NOZCODECS));
break;
case BADDATA:
( void)FormAlert( 1 , get_string( BADDATA));
break;
default:
( void)FormAlert( 1 , get_string( GENERIC));
break;
}
}

View File

@@ -0,0 +1,13 @@
extern OBJECT *get_tree( int16 obj_index);
extern int8 *get_string( int16 str_index);
extern void errshow( const char *name, int16 error);
extern void generic_form_event( WINDOW *win);
extern void CDECL draw_weather_icon( WINDOW *win, PARMBLK *pblk, void *data);
extern void CDECL draw_forecast1_icon( WINDOW *win, PARMBLK *pblk, void *data);
extern void CDECL draw_forecast2_icon( WINDOW *win, PARMBLK *pblk, void *data);
extern void CDECL draw_forecast3_icon( WINDOW *win, PARMBLK *pblk, void *data);
extern void CDECL draw_forecast4_icon( WINDOW *win, PARMBLK *pblk, void *data);
extern void CDECL draw_forecast5_icon( WINDOW *win, PARMBLK *pblk, void *data);
extern void CDECL draw_forecast6_icon( WINDOW *win, PARMBLK *pblk, void *data);
extern void CDECL draw_boussole_icon( WINDOW *win, PARMBLK *pblk, void *data);

View File

@@ -0,0 +1,131 @@
#include "general.h"
extern int vasprintf( int8 **strp, const int8 *fmt, va_list ap);
char *zstrncpy( char *dst, const char *src, size_t n)
{
register const char *source = src;
register char *dest = dst;
register size_t count = n;
if( dest && !source && count)
*dest = '\0';
else if( dest && source && (count >= 1))
{
for( count--; count > 0 && *source != '\0'; count--)
*dest++ = *source++;
*dest = '\0';
}
return dst;
}
int8 *stpcpy( int8 *dest, const int8 *src)
{
register int8 *d = dest;
register const int8 *s = src;
if( dest == NULL || src == NULL)
return NULL;
do
*d++ = *s;
while (*s++ != '\0');
return d - 1;
}
int8 *strstr_len( const int8 *haystack, int32 haystack_len, const int8 *needle)
{
if( haystack == NULL || needle == NULL)
return NULL;
if (haystack_len < 0)
return strstr (haystack, needle);
else
{
const int8 *end, *p = haystack;
int32 i, needle_len = strlen ( needle);
if (needle_len == 0)
return (int8 *)haystack;
if (haystack_len < needle_len)
return NULL;
end = haystack + haystack_len - needle_len;
while (*p && p <= end)
{
for (i = 0; i < needle_len; i++)
if (p[i] != needle[i])
goto next;
return (int8 *)p;
next:
p++;
}
return NULL;
}
}
int8 *strdup_printf( const int8 *format, ...)
{
int8 *buffer;
int len;
va_list args;
va_start( args, format);
len = vasprintf( &buffer, format, args);
if( len < 0)
buffer = NULL;
va_end( args);
return buffer;
}
int8* strconcat( const int8 *string1, ...)
{
int32 l;
int8 *s, *concat, *ptr;
va_list args;
if( !string1)
return NULL;
l = 1 + strlen( string1);
va_start( args, string1);
s = va_arg( args, int8*);
while( s)
{
l += strlen (s);
s = va_arg ( args, int8*);
}
va_end (args);
concat = malloc( sizeof( int8) * l);
ptr = concat;
ptr = stpcpy ( ptr, string1);
va_start (args, string1);
s = va_arg (args, int8*);
while (s)
{
ptr = stpcpy( ptr, s);
s = va_arg (args, int8*);
}
va_end (args);
return concat;
}

View File

@@ -0,0 +1,6 @@
extern int8 *stpcpy( int8 *dest, const int8 *src);
extern int8 *strstr_len( const int8 *haystack, int32 haystack_len, const int8 *needle);
extern int8 *strdup_printf( const int8 *format, ...);
extern int8 *strconcat( const int8 *string1, ...);
extern char *zstrncpy( char *dst, const char *src, size_t n);

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,93 @@
/* Resource C-Header-file v1.95 for ResourceMaster v2.06&up by ARDISOFT */
#define WEATHER 0 /* form/dial */
#define WEATHER_PANEL4 1 /* BUTTON in tree WEATHER */
#define WEATHER_CODE 2 /* FBOXTEXT in tree WEATHER */
#define WEATHER_UPDATE_TIME 10 /* FBOXTEXT in tree WEATHER */
#define WEATHER_METRIC 13 /* BUTTON in tree WEATHER */
#define WEATHER_IMPERIAL 14 /* BUTTON in tree WEATHER */
#define WEATHER_DATE 16 /* TEXT in tree WEATHER */
#define WEATHER_UPDATE 107 /* BUTTON in tree WEATHER */
#define WEATHER_PANEL2 22 /* BUTTON in tree WEATHER */
#define WEATHER_FORECAST1 23 /* BUTTON in tree WEATHER */
#define WEATHER_DESCRIPTION1 24 /* TEXT in tree WEATHER */
#define WEATHER_DAY1 25 /* TEXT in tree WEATHER */
#define WEATHER_ICON1 26 /* BOX in tree WEATHER */
#define WEATHER_NIGHT1 29 /* TEXT in tree WEATHER */
#define WEATHER_WIND1 31 /* TEXT in tree WEATHER */
#define WEATHER_FORECAST3 32 /* BUTTON in tree WEATHER */
#define WEATHER_DESCRIPTION3 33 /* TEXT in tree WEATHER */
#define WEATHER_DAY3 34 /* TEXT in tree WEATHER */
#define WEATHER_ICON3 35 /* BOX in tree WEATHER */
#define WEATHER_NIGHT3 38 /* TEXT in tree WEATHER */
#define WEATHER_WIND3 40 /* TEXT in tree WEATHER */
#define WEATHER_FORECAST5 41 /* BUTTON in tree WEATHER */
#define WEATHER_DESCRIPTION5 42 /* TEXT in tree WEATHER */
#define WEATHER_DAY5 43 /* TEXT in tree WEATHER */
#define WEATHER_ICON5 44 /* BOX in tree WEATHER */
#define WEATHER_NIGHT5 47 /* TEXT in tree WEATHER */
#define WEATHER_WIND5 49 /* TEXT in tree WEATHER */
#define WEATHER_FORECAST2 50 /* BUTTON in tree WEATHER */
#define WEATHER_DESCRIPTION2 51 /* TEXT in tree WEATHER */
#define WEATHER_DAY2 52 /* TEXT in tree WEATHER */
#define WEATHER_ICON2 53 /* BOX in tree WEATHER */
#define WEATHER_NIGHT2 56 /* TEXT in tree WEATHER */
#define WEATHER_WIND2 58 /* TEXT in tree WEATHER */
#define WEATHER_FORECAST4 59 /* BUTTON in tree WEATHER */
#define WEATHER_DESCRIPTION4 60 /* TEXT in tree WEATHER */
#define WEATHER_DAY4 61 /* TEXT in tree WEATHER */
#define WEATHER_ICON4 62 /* BOX in tree WEATHER */
#define WEATHER_NIGHT4 65 /* TEXT in tree WEATHER */
#define WEATHER_WIND4 67 /* TEXT in tree WEATHER */
#define WEATHER_ICON6 68 /* BOX in tree WEATHER */
#define WEATHER_LINK1 69 /* TEXT in tree WEATHER */
#define WEATHER_LINK2 70 /* TEXT in tree WEATHER */
#define WEATHER_LINK3 71 /* TEXT in tree WEATHER */
#define WEATHER_LINK4 72 /* TEXT in tree WEATHER */
#define WEATHER_FORECAST 73 /* BUTTON in tree WEATHER */
#define WEATHER_PREF 74 /* BUTTON in tree WEATHER */
#define WEATHER_QUIT 75 /* BUTTON in tree WEATHER */
#define WEATHER_PANEL1 76 /* BUTTON in tree WEATHER */
#define WEATHER_DESCRIPTION 78 /* TEXT in tree WEATHER */
#define WEATHER_TEMP 80 /* TEXT in tree WEATHER */
#define WEATHER_FEEL 82 /* TEXT in tree WEATHER */
#define WEATHER_DEW 84 /* TEXT in tree WEATHER */
#define WEATHER_ICON 85 /* BOX in tree WEATHER */
#define WEATHER_SUNSET 88 /* TEXT in tree WEATHER */
#define WEATHER_SUNRISE 90 /* TEXT in tree WEATHER */
#define WEATHER_UV 92 /* TEXT in tree WEATHER */
#define WEATHER_PRESSURE 95 /* TEXT in tree WEATHER */
#define WEATHER_WSPEED 97 /* TEXT in tree WEATHER */
#define WEATHER_WICON 98 /* BOX in tree WEATHER */
#define WEATHER_HUMIDITY 101 /* TEXT in tree WEATHER */
#define WEATHER_VISIBILITY 103 /* TEXT in tree WEATHER */
#define WEATHER_TIME 104 /* TEXT in tree WEATHER */
#define WEATHER_REPORT 105 /* TEXT in tree WEATHER */
#define WEATHER_MAIN 106 /* BUTTON in tree WEATHER */
#define WEATHER_MAP 108 /* BUTTON in tree WEATHER */
#define WEATHER_PANEL3 109 /* BUTTON in tree WEATHER */
#define WEATHER_MAP_BOX 111 /* BOX in tree WEATHER */
#define WEATHER_CONTINENT 112 /* BUTTON in tree WEATHER */
#define WEATHER_STATE 113 /* BUTTON in tree WEATHER */
#define CONTINENT 1 /* form/dial */
#define CONTINENT_EUROPE 1 /* STRING in tree CONTINENT */
#define CONTINENT_OCEANIA 2 /* STRING in tree CONTINENT */
#define CONTINENT_ASIA 3 /* STRING in tree CONTINENT */
#define CONTINENT_NORTHA 4 /* STRING in tree CONTINENT */
#define CONTINENT_CENTRALA 5 /* STRING in tree CONTINENT */
#define CONTINENT_SOUTHA 6 /* STRING in tree CONTINENT */
#define CONTINENT_AFRICA 7 /* STRING in tree CONTINENT */
#define CONTINENT_OCEAN 8 /* STRING in tree CONTINENT */
#define NOMEM 0 /* Alert string */
#define ALERT_WINDOW 1 /* Alert string */
#define GENERIC 2 /* Alert string */
#define CANT_LOAD_IMG 3 /* Alert string */
#define NOZCODECS 4 /* Alert string */
#define BADDATA 5 /* Alert string */

View File

@@ -0,0 +1,92 @@
ResourceMaster v3.65
#C 2@6@0@0@
#N 99@32@AZAaza___ _@AZAaza090___ _@@_@
#FoHRD@rsm2out@HRD@hrd@@@[HRD-File@0@
#FoC-Header@rsm2out@C-Header@rsh@@@[C-Header@0@
#R 0@0@3@1@4@1@
#M 01010100@0@7728@723@
#T 0@2@WEATHER@@114@@
#O 1@26@PANEL4@@
#O 2@30@CODE@@
#O 10@30@UPDATE_TIME@@
#O 13@26@METRIC@@
#O 14@26@IMPERIAL@@
#O 16@21@DATE@@
#O 107@26@UPDATE@@
#O 22@26@PANEL2@@
#O 23@26@FORECAST1@@
#O 24@21@DESCRIPTION1@@
#O 25@21@DAY1@@
#O 26@20@ICON1@@
#O 29@21@NIGHT1@@
#O 31@21@WIND1@@
#O 32@26@FORECAST3@@
#O 33@21@DESCRIPTION3@@
#O 34@21@DAY3@@
#O 35@20@ICON3@@
#O 38@21@NIGHT3@@
#O 40@21@WIND3@@
#O 41@26@FORECAST5@@
#O 42@21@DESCRIPTION5@@
#O 43@21@DAY5@@
#O 44@20@ICON5@@
#O 47@21@NIGHT5@@
#O 49@21@WIND5@@
#O 50@26@FORECAST2@@
#O 51@21@DESCRIPTION2@@
#O 52@21@DAY2@@
#O 53@20@ICON2@@
#O 56@21@NIGHT2@@
#O 58@21@WIND2@@
#O 59@26@FORECAST4@@
#O 60@21@DESCRIPTION4@@
#O 61@21@DAY4@@
#O 62@20@ICON4@@
#O 65@21@NIGHT4@@
#O 67@21@WIND4@@
#O 68@20@ICON6@@
#O 69@21@LINK1@@
#O 70@21@LINK2@@
#O 71@21@LINK3@@
#O 72@21@LINK4@@
#O 73@26@FORECAST@@
#O 74@26@PREF@@
#O 75@26@QUIT@@
#O 76@26@PANEL1@@
#O 78@21@DESCRIPTION@@
#O 80@21@TEMP@@
#O 82@21@FEEL@@
#O 84@21@DEW@@
#O 85@20@ICON@@
#O 88@21@SUNSET@@
#O 90@21@SUNRISE@@
#O 92@21@UV@@
#O 95@21@PRESSURE@@
#O 97@21@WSPEED@@
#O 98@20@WICON@@
#O 101@21@HUMIDITY@@
#O 103@21@VISIBILITY@@
#O 104@21@TIME@@
#O 105@21@REPORT@@
#O 106@26@MAIN@@
#O 108@26@MAP@@
#O 109@26@PANEL3@@
#O 111@20@MAP_BOX@@
#O 112@26@CONTINENT@@
#O 113@26@STATE@@
#T 1@2@CONTINENT@@9@@
#O 1@28@EUROPE@@
#O 2@28@OCEANIA@@
#O 3@28@ASIA@@
#O 4@28@NORTHA@@
#O 5@28@CENTRALA@@
#O 6@28@SOUTHA@@
#O 7@28@AFRICA@@
#O 8@28@OCEAN@@
#S 0@4@NOMEM@@
#S 1@4@ALERT_WINDOW@@
#S 2@4@GENERIC@@
#S 3@4@CANT_LOAD_IMG@@
#S 4@4@NOZCODECS@@
#S 5@4@BADDATA@@
#c 26537@