mirror of
https://github.com/bobbimanners/emailler.git
synced 2025-01-04 10:29:24 +00:00
Added central error strings.
This commit is contained in:
parent
773de74bc4
commit
6971e9216f
@ -22,23 +22,7 @@
|
|||||||
|
|
||||||
void error_exit(void)
|
void error_exit(void)
|
||||||
{
|
{
|
||||||
switch (ip65_error)
|
printf("- %s\n", ip65_strerror(ip65_error));
|
||||||
{
|
|
||||||
case IP65_ERROR_DEVICE_FAILURE:
|
|
||||||
printf("- No device found\n");
|
|
||||||
break;
|
|
||||||
case IP65_ERROR_ABORTED_BY_USER:
|
|
||||||
printf("- User abort\n");
|
|
||||||
break;
|
|
||||||
case IP65_ERROR_TIMEOUT_ON_RECEIVE:
|
|
||||||
printf("- Timeout\n");
|
|
||||||
break;
|
|
||||||
case IP65_ERROR_DNS_LOOKUP_FAILED:
|
|
||||||
printf("- Lookup failed\n");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
printf("- Error $%X\n", ip65_error);
|
|
||||||
}
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
apps/hfs65.c
15
apps/hfs65.c
@ -274,20 +274,7 @@ void http_server(uint32_t client, const char* method, const char* path)
|
|||||||
|
|
||||||
void error_exit(void)
|
void error_exit(void)
|
||||||
{
|
{
|
||||||
switch (ip65_error)
|
printf("- %s\n", ip65_strerror(ip65_error));
|
||||||
{
|
|
||||||
case IP65_ERROR_DEVICE_FAILURE:
|
|
||||||
printf("- No device found\n");
|
|
||||||
break;
|
|
||||||
case IP65_ERROR_ABORTED_BY_USER:
|
|
||||||
printf("- User abort\n");
|
|
||||||
break;
|
|
||||||
case IP65_ERROR_TIMEOUT_ON_RECEIVE:
|
|
||||||
printf("- Timeout\n");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
printf("- Error $%X\n", ip65_error);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doesclrscrafterexit())
|
if (doesclrscrafterexit())
|
||||||
{
|
{
|
||||||
|
@ -17,26 +17,7 @@ char text[280 + 1];
|
|||||||
|
|
||||||
void error_exit(void)
|
void error_exit(void)
|
||||||
{
|
{
|
||||||
switch (ip65_error)
|
printf("- %s\n", ip65_strerror(ip65_error));
|
||||||
{
|
|
||||||
case IP65_ERROR_DEVICE_FAILURE:
|
|
||||||
printf("- No device found\n");
|
|
||||||
break;
|
|
||||||
case IP65_ERROR_ABORTED_BY_USER:
|
|
||||||
printf("- User abort\n");
|
|
||||||
break;
|
|
||||||
case IP65_ERROR_TIMEOUT_ON_RECEIVE:
|
|
||||||
printf("- Timeout\n");
|
|
||||||
break;
|
|
||||||
case IP65_ERROR_MALFORMED_URL:
|
|
||||||
printf("- Malformed URL\n");
|
|
||||||
break;
|
|
||||||
case IP65_ERROR_DNS_LOOKUP_FAILED:
|
|
||||||
printf("- Lookup failed\n");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
printf("- Error $%X\n", ip65_error);
|
|
||||||
}
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,26 +26,7 @@ char name[16];
|
|||||||
|
|
||||||
void ip65_error_exit(bool quit)
|
void ip65_error_exit(bool quit)
|
||||||
{
|
{
|
||||||
switch (ip65_error)
|
printf("- %s\n", ip65_strerror(ip65_error));
|
||||||
{
|
|
||||||
case IP65_ERROR_DEVICE_FAILURE:
|
|
||||||
printf("- No Uthernet II found\n");
|
|
||||||
break;
|
|
||||||
case IP65_ERROR_ABORTED_BY_USER:
|
|
||||||
printf("- User abort\n");
|
|
||||||
break;
|
|
||||||
case IP65_ERROR_TIMEOUT_ON_RECEIVE:
|
|
||||||
printf("- Timeout\n");
|
|
||||||
break;
|
|
||||||
case IP65_ERROR_MALFORMED_URL:
|
|
||||||
printf("- Malformed URL\n");
|
|
||||||
break;
|
|
||||||
case IP65_ERROR_DNS_LOOKUP_FAILED:
|
|
||||||
printf("- Lookup failed\n");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
printf("- Error $%X\n", ip65_error);
|
|
||||||
}
|
|
||||||
if (quit)
|
if (quit)
|
||||||
{
|
{
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -2,7 +2,7 @@ IP65_ERROR_PORT_IN_USE = $80
|
|||||||
IP65_ERROR_TIMEOUT_ON_RECEIVE = $81
|
IP65_ERROR_TIMEOUT_ON_RECEIVE = $81
|
||||||
IP65_ERROR_TRANSMIT_FAILED = $82
|
IP65_ERROR_TRANSMIT_FAILED = $82
|
||||||
IP65_ERROR_TRANSMISSION_REJECTED_BY_PEER = $83
|
IP65_ERROR_TRANSMISSION_REJECTED_BY_PEER = $83
|
||||||
IP65_ERROR_INPUT_TOO_LARGE = $84
|
IP65_ERROR_NAME_TOO_LONG = $84
|
||||||
IP65_ERROR_DEVICE_FAILURE = $85
|
IP65_ERROR_DEVICE_FAILURE = $85
|
||||||
IP65_ERROR_ABORTED_BY_USER = $86
|
IP65_ERROR_ABORTED_BY_USER = $86
|
||||||
IP65_ERROR_LISTENER_NOT_AVAILABLE = $87
|
IP65_ERROR_LISTENER_NOT_AVAILABLE = $87
|
||||||
|
47
inc/ip65.h
47
inc/ip65.h
@ -4,25 +4,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
// Error codes
|
|
||||||
//
|
|
||||||
#define IP65_ERROR_PORT_IN_USE 0x80
|
|
||||||
#define IP65_ERROR_TIMEOUT_ON_RECEIVE 0x81
|
|
||||||
#define IP65_ERROR_TRANSMIT_FAILED 0x82
|
|
||||||
#define IP65_ERROR_TRANSMISSION_REJECTED_BY_PEER 0x83
|
|
||||||
#define IP65_ERROR_INPUT_TOO_LARGE 0x84
|
|
||||||
#define IP65_ERROR_DEVICE_FAILURE 0x85
|
|
||||||
#define IP65_ERROR_ABORTED_BY_USER 0x86
|
|
||||||
#define IP65_ERROR_LISTENER_NOT_AVAILABLE 0x87
|
|
||||||
#define IP65_ERROR_CONNECTION_RESET_BY_PEER 0x89
|
|
||||||
#define IP65_ERROR_CONNECTION_CLOSED 0x8A
|
|
||||||
#define IP65_ERROR_MALFORMED_URL 0xA0
|
|
||||||
#define IP65_ERROR_DNS_LOOKUP_FAILED 0xA1
|
|
||||||
|
|
||||||
// Last error code
|
|
||||||
//
|
|
||||||
extern uint8_t ip65_error;
|
|
||||||
|
|
||||||
// Ethernet driver initialization parameter values
|
// Ethernet driver initialization parameter values
|
||||||
//
|
//
|
||||||
#if defined(__APPLE2__)
|
#if defined(__APPLE2__)
|
||||||
@ -52,6 +33,34 @@ bool __fastcall__ ip65_init(uint8_t eth_init);
|
|||||||
extern uint8_t cfg_mac[6]; // MAC address of local machine
|
extern uint8_t cfg_mac[6]; // MAC address of local machine
|
||||||
extern char eth_name[]; // Zero terminated string containing Ethernet driver name
|
extern char eth_name[]; // Zero terminated string containing Ethernet driver name
|
||||||
|
|
||||||
|
// Error codes
|
||||||
|
//
|
||||||
|
#define IP65_ERROR_PORT_IN_USE 0x80
|
||||||
|
#define IP65_ERROR_TIMEOUT_ON_RECEIVE 0x81
|
||||||
|
#define IP65_ERROR_TRANSMIT_FAILED 0x82
|
||||||
|
#define IP65_ERROR_TRANSMISSION_REJECTED_BY_PEER 0x83
|
||||||
|
#define IP65_ERROR_NAME_TOO_LONG 0x84
|
||||||
|
#define IP65_ERROR_DEVICE_FAILURE 0x85
|
||||||
|
#define IP65_ERROR_ABORTED_BY_USER 0x86
|
||||||
|
#define IP65_ERROR_LISTENER_NOT_AVAILABLE 0x87
|
||||||
|
#define IP65_ERROR_CONNECTION_RESET_BY_PEER 0x89
|
||||||
|
#define IP65_ERROR_CONNECTION_CLOSED 0x8A
|
||||||
|
#define IP65_ERROR_MALFORMED_URL 0xA0
|
||||||
|
#define IP65_ERROR_DNS_LOOKUP_FAILED 0xA1
|
||||||
|
|
||||||
|
// Last error code
|
||||||
|
//
|
||||||
|
extern uint8_t ip65_error;
|
||||||
|
|
||||||
|
// Convert error code into a string describing the error
|
||||||
|
//
|
||||||
|
// The pointer returned is a static string, which mustn't be modified.
|
||||||
|
//
|
||||||
|
// Inputs: err_code: Error code
|
||||||
|
// Output: Zero terminated string describing the error
|
||||||
|
//
|
||||||
|
char* __fastcall__ ip65_strerror(uint8_t err_code);
|
||||||
|
|
||||||
// Main IP polling loop
|
// Main IP polling loop
|
||||||
//
|
//
|
||||||
// This routine should be periodically called by an application at any time
|
// This routine should be periodically called by an application at any time
|
||||||
|
@ -23,6 +23,7 @@ IP65OBJS=\
|
|||||||
dottedquad_c.o \
|
dottedquad_c.o \
|
||||||
download.o \
|
download.o \
|
||||||
download_c.o \
|
download_c.o \
|
||||||
|
error.o \
|
||||||
eth.o \
|
eth.o \
|
||||||
eth_c.o \
|
eth_c.o \
|
||||||
http.o \
|
http.o \
|
||||||
|
@ -164,7 +164,7 @@ dns_set_hostname:
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
@hostname_too_long:
|
@hostname_too_long:
|
||||||
lda #IP65_ERROR_INPUT_TOO_LARGE
|
lda #IP65_ERROR_NAME_TOO_LONG
|
||||||
sta ip65_error
|
sta ip65_error
|
||||||
sec
|
sec
|
||||||
rts
|
rts
|
||||||
@ -282,7 +282,7 @@ send_dns_query:
|
|||||||
sta output_buffer+dns_qname,x
|
sta output_buffer+dns_qname,x
|
||||||
inx
|
inx
|
||||||
bpl @hostname_still_ok
|
bpl @hostname_still_ok
|
||||||
lda #IP65_ERROR_INPUT_TOO_LARGE
|
lda #IP65_ERROR_NAME_TOO_LONG
|
||||||
sta ip65_error
|
sta ip65_error
|
||||||
jmp @error_on_send ; if we got past 128 bytes, there's a problem
|
jmp @error_on_send ; if we got past 128 bytes, there's a problem
|
||||||
@hostname_still_ok:
|
@hostname_still_ok:
|
||||||
|
139
ip65/error.s
Normal file
139
ip65/error.s
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
.include "../inc/common.inc"
|
||||||
|
.include "../inc/error.inc"
|
||||||
|
|
||||||
|
.export ip65_strerror
|
||||||
|
|
||||||
|
|
||||||
|
.code
|
||||||
|
|
||||||
|
;convert error code into a string describing the error
|
||||||
|
;inputs:
|
||||||
|
; A = error code
|
||||||
|
;outputs:
|
||||||
|
; AX = pointer to zero terminated string describing the error
|
||||||
|
ip65_strerror:
|
||||||
|
cmp #IP65_ERROR_PORT_IN_USE
|
||||||
|
bne :+
|
||||||
|
ldax #str_port_in_use
|
||||||
|
rts
|
||||||
|
|
||||||
|
: cmp #IP65_ERROR_TIMEOUT_ON_RECEIVE
|
||||||
|
bne :+
|
||||||
|
ldax #str_timeout_on_receive
|
||||||
|
rts
|
||||||
|
|
||||||
|
: cmp #IP65_ERROR_TRANSMIT_FAILED
|
||||||
|
bne :+
|
||||||
|
ldax #str_transmit_failed
|
||||||
|
rts
|
||||||
|
|
||||||
|
: cmp #IP65_ERROR_TRANSMISSION_REJECTED_BY_PEER
|
||||||
|
bne :+
|
||||||
|
ldax #str_transmission_rejected_by_peer
|
||||||
|
rts
|
||||||
|
|
||||||
|
: cmp #IP65_ERROR_NAME_TOO_LONG
|
||||||
|
bne :+
|
||||||
|
ldax #str_name_too_long
|
||||||
|
rts
|
||||||
|
|
||||||
|
: cmp #IP65_ERROR_DEVICE_FAILURE
|
||||||
|
bne :+
|
||||||
|
ldax #str_device_failure
|
||||||
|
rts
|
||||||
|
|
||||||
|
: cmp #IP65_ERROR_ABORTED_BY_USER
|
||||||
|
bne :+
|
||||||
|
ldax #str_aborted_by_user
|
||||||
|
rts
|
||||||
|
|
||||||
|
: cmp #IP65_ERROR_LISTENER_NOT_AVAILABLE
|
||||||
|
bne :+
|
||||||
|
ldax #str_listener_not_available
|
||||||
|
rts
|
||||||
|
|
||||||
|
: cmp #IP65_ERROR_CONNECTION_RESET_BY_PEER
|
||||||
|
bne :+
|
||||||
|
ldax #str_connection_reset_by_peer
|
||||||
|
rts
|
||||||
|
|
||||||
|
: cmp #IP65_ERROR_CONNECTION_CLOSED
|
||||||
|
bne :+
|
||||||
|
ldax #str_connection_closed
|
||||||
|
rts
|
||||||
|
|
||||||
|
: cmp #IP65_ERROR_MALFORMED_URL
|
||||||
|
bne :+
|
||||||
|
ldax #str_malformed_url
|
||||||
|
rts
|
||||||
|
|
||||||
|
: cmp #IP65_ERROR_DNS_LOOKUP_FAILED
|
||||||
|
bne :+
|
||||||
|
ldax #str_dns_lookup_failed
|
||||||
|
rts
|
||||||
|
|
||||||
|
: ldax #str_unknown
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
.rodata
|
||||||
|
|
||||||
|
str_port_in_use:
|
||||||
|
.byte "Port in use",0
|
||||||
|
|
||||||
|
str_timeout_on_receive:
|
||||||
|
.byte "Timeout",0
|
||||||
|
|
||||||
|
str_transmit_failed:
|
||||||
|
.byte "Send failed",0
|
||||||
|
|
||||||
|
str_transmission_rejected_by_peer:
|
||||||
|
.byte "Data rejected",0
|
||||||
|
|
||||||
|
str_name_too_long:
|
||||||
|
.byte "Name too long",0
|
||||||
|
|
||||||
|
str_device_failure:
|
||||||
|
.byte "No device found",0
|
||||||
|
|
||||||
|
str_aborted_by_user:
|
||||||
|
.byte "User abort",0
|
||||||
|
|
||||||
|
str_listener_not_available:
|
||||||
|
.byte "No more listener",0
|
||||||
|
|
||||||
|
str_connection_reset_by_peer:
|
||||||
|
.byte "Connection reset by peer",0
|
||||||
|
|
||||||
|
str_connection_closed:
|
||||||
|
.byte "Connection closed",0
|
||||||
|
|
||||||
|
str_malformed_url:
|
||||||
|
.byte "Malformed URL",0
|
||||||
|
|
||||||
|
str_dns_lookup_failed:
|
||||||
|
.byte "Lookup failed",0
|
||||||
|
|
||||||
|
str_unknown:
|
||||||
|
.byte "Unknown error",0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; -- LICENSE FOR error.s --
|
||||||
|
; The contents of this file are subject to the Mozilla Public License
|
||||||
|
; Version 1.1 (the "License"); you may not use this file except in
|
||||||
|
; compliance with the License. You may obtain a copy of the License at
|
||||||
|
; http://www.mozilla.org/MPL/
|
||||||
|
;
|
||||||
|
; Software distributed under the License is distributed on an "AS IS"
|
||||||
|
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||||
|
; License for the specific language governing rights and limitations
|
||||||
|
; under the License.
|
||||||
|
;
|
||||||
|
; The Original Code is ip65.
|
||||||
|
;
|
||||||
|
; The Initial Developer of the Original Code is Per Olofsson,
|
||||||
|
; MagerValp@gmail.com.
|
||||||
|
; Portions created by the Initial Developer are Copyright (C) 2009
|
||||||
|
; Per Olofsson. All Rights Reserved.
|
||||||
|
; -- LICENSE END --
|
@ -4,11 +4,13 @@
|
|||||||
.export _ip65_process
|
.export _ip65_process
|
||||||
.export _ip65_random_word
|
.export _ip65_random_word
|
||||||
.export _ip65_error
|
.export _ip65_error
|
||||||
|
.export _ip65_strerror
|
||||||
|
|
||||||
.import ip65_init
|
.import ip65_init
|
||||||
.import ip65_process
|
.import ip65_process
|
||||||
.import ip65_random_word
|
.import ip65_random_word
|
||||||
.import ip65_error
|
.import ip65_error
|
||||||
|
.import ip65_strerror
|
||||||
|
|
||||||
_ip65_init:
|
_ip65_init:
|
||||||
jsr ip65_init
|
jsr ip65_init
|
||||||
@ -27,3 +29,5 @@ _ip65_process:
|
|||||||
_ip65_random_word := ip65_random_word
|
_ip65_random_word := ip65_random_word
|
||||||
|
|
||||||
_ip65_error := ip65_error
|
_ip65_error := ip65_error
|
||||||
|
|
||||||
|
_ip65_strerror := ip65_strerror
|
||||||
|
Loading…
Reference in New Issue
Block a user