[Z88dk-users] Help needed to compile old ZeddyNet libs again

Bridge to the z88dk-users mailing list
Post Reply
siggi
Well known member
Posts: 343
Joined: Thu Jul 26, 2007 9:06 am

[Z88dk-users] Help needed to compile old ZeddyNet libs again

Post by siggi »

Hi
I tried to compile my old ZeddyNet libs using current Z88DK. Now I get a lot of errors and don't know, where to start to correct them.
What needs to be done? Any hint?

That is the current state when trying to build the HTTP libs.

Code: Select all

D:\PRIVAT\ZX81\DEV\LAN\ZeddyNet\z88dk\libhttp>build

D:\PRIVAT\ZX81\DEV\LAN\ZeddyNet\z88dk\libhttp>zcc +zx81 -I./include -O2 -preserv
e -vn addFormData.c freeFormData.c parseURI.c parseProto.c allocURI.c freeURI.c
base64enc.c request.c readData.c postsize.c getheader.c freeheaders.c readHeader
s.c htrecv.c
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys/socket.h" L:28 Error:Cannot not
declare an instance of incompletely defined struct 'in_addr'
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys/socket.h" L:29 Error:Flexible me
mber needs to be last element of struct
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys/socket.h" L:29 Error:Missing tok
en, expecting } got c
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys/socket.h" L:29 Error:Missing tok
en, expecting = got s
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys/socket.h" L:29 Error:Unknown sym
bol: sin_zero
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys/socket.h" L:29 Error:Missing tok
en, expecting , got 8
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys/socket.h" L:29 Error:Missing tok
en, expecting ; got 8
sccz80:"request.c" L:62 Error:Unknown symbol: sockaddr_in
sccz80:"request.c" L:63 Error:Unknown symbol: sockaddr_in
Errors in source file readData.c:
Error: object file 'readData.o' version 8, expected version 11
Errors in source file postsize.c:
Error: object file 'postsize.o' version 8, expected version 11
Errors in source file getheader.c:
Error: object file 'getheader.o' version 8, expected version 11
Errors in source file freeheaders.c:
Error: object file 'freeheaders.o' version 8, expected version 11
Errors in source file readHeaders.c:
Error: object file 'readHeaders.o' version 8, expected version 11
Errors in source file htrecv.c:
Error: object file 'htrecv.o' version 8, expected version 11

D:\PRIVAT\ZX81\DEV\LAN\ZeddyNet\z88dk\libhttp>rem zcc +zx81 -I./include -O2 -pre
serve -vn -make-lib addFormData.c freeFormData.c parseURI.c parseProto.c allocUR
I.c freeURI.c base64enc.c request.c readData.c postsize.c getheader.c freeheader
s.c readHeaders.c htrecv.c

D:\PRIVAT\ZX81\DEV\LAN\ZeddyNet\z88dk\libhttp>rem z80asm -d -ns -nm -Mo -IXIY -x
libhttp addFormData.o freeFormData.o parseURI.o parseProto.o allocURI.o freeURI.
o base64enc.o request.o readData.o postsize.o getheader.o freeheaders.o readHead
ers.o htrecv.o

D:\PRIVAT\ZX81\DEV\LAN\ZeddyNet\z88dk\libhttp>z80asm -d -IXIY -xlibhttp addFormD
ata.o freeFormData.o parseURI.o parseProto.o allocURI.o freeURI.o base64enc.o re
quest.o readData.o postsize.o getheader.o freeheaders.o readHeaders.o htrecv.o
Error: object file 'addFormData.o' version 8, expected version 11
Error: object file 'freeFormData.o' version 8, expected version 11
Error: object file 'parseURI.o' version 8, expected version 11
Error: object file 'parseProto.o' version 8, expected version 11
Error: object file 'allocURI.o' version 8, expected version 11
Error: object file 'freeURI.o' version 8, expected version 11
Error: object file 'base64enc.o' version 8, expected version 11
Error: object file 'request.o' version 8, expected version 11
Error: object file 'readData.o' version 8, expected version 11
Error: object file 'postsize.o' version 8, expected version 11
Error: object file 'getheader.o' version 8, expected version 11
Error: object file 'freeheaders.o' version 8, expected version 11
Error: object file 'readHeaders.o' version 8, expected version 11
Error: object file 'htrecv.o' version 8, expected version 11
14 errors occurred during assembly

D:\PRIVAT\ZX81\DEV\LAN\ZeddyNet\z88dk\libhttp>call install.bat
Siggi



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
siggi
Well known member
Posts: 343
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Maybe this error must be solved before (when compiling the socket lib).

Code: Select all

D:\PRIVAT\ZX81\DEV\LAN\ZeddyNet\z88dk\socklib>z80asm -d -IXIY -I../../include -x
libsocket @libsocket.lst
Error at file 'mac2string_callee.asm' line 6: symbol 'ASMDISP_MAC2IPSTRING_CALLE
E' not defined
1 errors occurred during assembly
This is the souce causing this error:

Code: Select all

; process
; CALLEE linkage for mac2string
; void mac2string_callee(char *mac, char *str);

XLIB mac2string_callee
XDEF ASMDISP_MAC2IPSTRING_CALLEE
LIB libsocket, F_mac2string
.mac2string_callee
pop bc                ; return addr
pop de                ; char *str
pop hl                ; char *mac
push bc                ; resture ret addr
.asmentry
jp F_mac2string

defc ASMDISP_MAC2STRING_CALLEE = asmentry - mac2string_callee
Siggi



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

The object files are using an older object file format so that's what the complaint is there. The solution is to rebuild those object files which I gather is what the next error is about.

Code: Select all

; process
; CALLEE linkage for mac2string
; void mac2string_callee(char *mac, char *str);

XLIB mac2string_callee
XDEF ASMDISP_MAC2IPSTRING_CALLEE
LIB libsocket, F_mac2string
.mac2string_callee
pop bc        ; return addr
pop de        ; char *str
pop hl        ; char *mac
push bc        ; resture ret addr
.asmentry
jp F_mac2string

defc ASMDISP_MAC2STRING_CALLEE = asmentry - mac2string_callee
This is a very old method for exporting and importing symbols. XLIB, XDEF, LIB are all deprecated now and I'm not sure if they work anymore?

Anyway, there are just three scope directives now:

PUBLIC - export the symbol
EXTERN - import the symbol
GLOBAL - public if the symbol is declared in the file, extern otherwise

So:

Code: Select all

; process
; CALLEE linkage for mac2string
; void mac2string_callee(char *mac, char *str);

PUBLIC mac2string_callee
PUBLIC ASMDISP_MAC2IPSTRING_CALLEE

EXTERN libsocket, F_mac2string

.mac2string_callee
pop bc        ; return addr
pop de        ; char *str
pop hl        ; char *mac
push bc        ; resture ret addr
.asmentry
jp F_mac2string

defc ASMDISP_MAC2STRING_CALLEE = asmentry - mac2string_callee
This ASMDISP method is also gone now. It originated from the time z80asm couldn't export more than one address label from a file at a time. That restriction is long gone so you will see that new c interface code will just export both labels instead of computing a displacement.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
siggi
Well known member
Posts: 343
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Hi Alvin
I were able to rebuild the socket-lib, after I deleted references to ASMDISP_MAC2STRING_CALLEE. The old keywords are still accepted and neither an error nor a warning was shown. So one problem is solved :)

But the other problem still exists when I try to rebuild the HTTP-lib.
I made the old lib in 2 steps: first I compiled the C programs to .O files and then linked them using -IXIY to swap IX to IY (for ZX81!):

Code: Select all

zcc +zx81 -I./include -O2 -preserve -vn -make-lib addFormData.c freeFormData.c parseURI.c parseProto.c allocURI.c freeURI.c base64enc.c request.c readData.c postsize.c getheader.c freeheaders.c readHeaders.c htrecv.c

z80asm -d -ns -nm -Mo -IXIY -xlibhttp addFormData.o freeFormData.o parseURI.o parseProto.o allocURI.o freeURI.o base64enc.o request.o readData.o postsize.o getheader.o freeheaders.o readHeaders.o htrecv.o
This results in error messages as shown in my first post:

Code: Select all

D:\PRIVAT\ZX81\DEV\LAN\ZeddyNet\z88dk\libhttp>zcc +zx81 -I./include -O2 -preserv
e -vn -make-lib addFormData.c freeFormData.c parseURI.c parseProto.c allocURI.c
freeURI.c base64enc.c request.c readData.c postsize.c getheader.c freeheaders.c
readHeaders.c htrecv.c
Unknown option -make-lib
Unknown option -make-lib
Unknown option -make-lib
Unknown option -make-lib
Unknown option -make-lib
Unknown option -make-lib
Unknown option -make-lib
Unknown option -make-lib
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys/socket.h" L:28 Error:Cannot not
declare an instance of incompletely defined struct 'in_addr'
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys/socket.h" L:29 Error:Flexible me
mber needs to be last element of struct
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys/socket.h" L:29 Error:Missing tok
en, expecting } got c
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys/socket.h" L:29 Error:Missing tok
en, expecting = got s
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys/socket.h" L:29 Error:Unknown sym
bol: sin_zero
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys/socket.h" L:29 Error:Missing tok
en, expecting , got 8
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys/socket.h" L:29 Error:Missing tok
en, expecting ; got 8
sccz80:"request.c" L:62 Error:Unknown symbol: sockaddr_in
sccz80:"request.c" L:63 Error:Unknown symbol: sockaddr_in
Errors in source file readData.c:
Error: object file 'readData.o' version 8, expected version 11
Errors in source file postsize.c:
Error: object file 'postsize.o' version 8, expected version 11
Errors in source file getheader.c:
Error: object file 'getheader.o' version 8, expected version 11
Errors in source file freeheaders.c:
Error: object file 'freeheaders.o' version 8, expected version 11
Errors in source file readHeaders.c:
Error: object file 'readHeaders.o' version 8, expected version 11
Errors in source file htrecv.c:
Error: object file 'htrecv.o' version 8, expected version 11

D:\PRIVAT\ZX81\DEV\LAN\ZeddyNet\z88dk\libhttp>z80asm -d -ns -nm -Mo -IXIY -xlibh
ttp addFormData.o freeFormData.o parseURI.o parseProto.o allocURI.o freeURI.o ba
se64enc.o request.o readData.o postsize.o getheader.o freeheaders.o readHeaders.
o htrecv.o
Error: illegal option '-ns'
Error: illegal option '-nm'
Error: illegal option '-Mo'
3 errors occurred during assembly
D:\PRIVAT\ZX81\DEV\LAN\ZeddyNet\z88dk\libhttp>
What is the reason for that errors?

Is
"sccz80:"c:\z88dk\lib\config\\..\..\/include/sys/socket.h" L:28 Error:Cannot not declare an instance of incompletely defined struct 'in_addr'"
again a problem of '\' vs '/'?

Siggi



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
siggi
Well known member
Posts: 343
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Other ZeddyNet project (sendmail), same problem: using my old Z88DK, the project is build without problem. Using the current Z88DK, the same errors occurs:

Code: Select all

D:\PRIVAT\ZX81\DEV\LAN\sendmail>zcc +zx81 -startup=2 -create-app -vn -O3 -o smai
l.bin mini_sendmail-V2.3.c -llibhttp -llibsocket
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys\socket.h" L:28 Error:Cannot not
declare an instance of incompletely defined struct 'in_addr'
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys\socket.h" L:29 Error:Flexible me
mber needs to be last element of struct
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys\socket.h" L:29 Error:Missing tok
en, expecting } got c
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys\socket.h" L:29 Error:Missing tok
en, expecting = got s
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys\socket.h" L:29 Error:Unknown sym
bol: sin_zero
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys\socket.h" L:29 Error:Missing tok
en, expecting , got 8
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys\socket.h" L:29 Error:Missing tok
en, expecting ; got 8
Again the error occurs when "socket.h" is included. What is the problem of the new Z88DK when using this very old source?
This is the file "socket.h":

Code: Select all

#ifndef __SOCKET_H__
#define __SOCKET_H__

/*
* socket.h
*
* Routines that call the Spectranet ROM socket library.
*
* 2008-05-03 Dylan Smith
*/

/* Definitions */
#define AF_INET                0
#define SOCK_STREAM        1
#define SOCK_DGRAM        2
#define SOCK_RAW        3

/* Much of this should ultimately end up in sys/types.h */
#define in_addr_t        unsigned long

/* Structures */

/* As defined in http://tools.ietf.org/html/draft-ietf-sip-bsd-systems-00 */
struct sockaddr_in        /* internet socket address structure */
{
int sin_family;                        /* offset 0 */
unsigned int sin_port;                /* offset 2 */
struct in_addr sin_addr;        /* offset 4 */
char sin_zero[8];                /* offset 8 */
};

struct in_addr
{
in_addr_t s_addr;                /* 32 bits */
};

#define sockaddr sockaddr_in
#define socklen_t int

/* CALLER and FASTCALL linkage calls */
extern int __LIB__        socket(int domain, int type, int protocol);
extern int __LIB__ __FASTCALL__ sockclose(int fd);
extern int __LIB__        bind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
extern int __LIB__        connect(int sockfd, struct sockaddr *serv_addr, socklen_t addrlen);
extern int __LIB__        send(int sockfd, void *buf, int len, int flags);
extern int __LIB__        recv(int sockfd, void *buf, int len, int flags);
extern int __LIB__        accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
extern int __LIB__        listen(int sockfd, int backlog);

/* CALLEE linkage calls */
extern int __LIB__ __CALLEE__        socket_callee(int domain, int type, int proto);
extern int __LIB__ __CALLEE__        bind_callee(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
extern int __LIB__ __CALLEE__        connect_callee(int sockfd, struct sockaddr *serv_addr, socklen_t addrlen);
extern int __LIB__ __CALLEE__        send_callee(int sockfd, void *buf, int len, int flags);
extern int __LIB__ __CALLEE__         sendto_callee(int sockfd, void *buf, int len, int flags, struct sockaddr *to, socklen_t tolen);
extern int __LIB__ __CALLEE__        recv_callee(int sockfd, void *buf, int len, int flags);
extern int __LIB__ __CALLEE__        recvfrom_callee(int sockfd, void *buf, int len, int flags, struct sockaddr *from, socklen_t *fromlen);
extern int __LIB__ __CALLEE__        accept_callee(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
extern int __LIB__ __CALLEE__        listen_callee(int sockfd, int backlog);

/* Make CALLEE default */
#define socket(a,b,c)                socket_callee(a,b,c)
#define bind(a,b,c)                bind_callee(a,b,c)
#define connect(a,b,c)                connect_callee(a,b,c)
#define send(a,b,c,d)                send_callee(a,b,c,d)
#define sendto(a,b,c,d,e,f)        sendto_callee(a,b,c,d,e,f)
#define recv(a,b,c,d)                recv_callee(a,b,c,d)
#define recvfrom(a,b,c,d,e,f)        recvfrom_callee(a,b,c,d,e,f)
#define accept(a,b,c)                accept_callee(a,b,c)
#define listen(a,b)                listen_callee(a,b)

/* htons is a no-op, since all the calls convert machine byte order to
* network byte order. The macro is provided for compatibility */
#define htons(a)                (a)
#define ntohs(a)                (a)

#endif
Any hints?

Siggi



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Ah.

Struct inaddr is defined after its first usage so move that definition up.

Slightly weird error message - I’ll look at it when I get back.
On 7 Aug 2018, at 19:06, siggi (siggi@...) <lists@...> wrote:

Other ZeddyNet project (sendmail), same problem: using my old Z88DK, the project is build without problem. Using the current Z88DK, the same errors occurs:

Code: Select all

D:\PRIVAT\ZX81\DEV\LAN\sendmail>zcc +zx81 -startup=2 -create-app -vn -O3 -o smai
l.bin mini_sendmail-V2.3.c -llibhttp -llibsocket
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys\socket.h" L:28 Error:Cannot not
declare an instance of incompletely defined struct 'in_addr'
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys\socket.h" L:29 Error:Flexible me
mber needs to be last element of struct
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys\socket.h" L:29 Error:Missing tok
en, expecting } got c
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys\socket.h" L:29 Error:Missing tok
en, expecting = got s
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys\socket.h" L:29 Error:Unknown sym
bol: sin_zero
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys\socket.h" L:29 Error:Missing tok
en, expecting , got 8
sccz80:"c:\z88dk\lib\config\\..\..\/include/sys\socket.h" L:29 Error:Missing tok
en, expecting ; got 8
Again the error occurs when "socket.h" is included. What is the problem of the new Z88DK when using this very old source?
This is the file "socket.h":

Code: Select all

#ifndef __SOCKET_H__
#define __SOCKET_H__

/*
* socket.h
*
* Routines that call the Spectranet ROM socket library.
*
* 2008-05-03 Dylan Smith
*/

/* Definitions */
#define AF_INET        0
#define SOCK_STREAM    1
#define SOCK_DGRAM    2
#define SOCK_RAW    3

/* Much of this should ultimately end up in sys/types.h */
#define in_addr_t    unsigned long

/* Structures */

/* As defined in http://tools.ietf.org/html/draft-ietf-sip-bsd-systems-00 */
struct sockaddr_in    /* internet socket address structure */
{
int sin_family;            /* offset 0 */
unsigned int sin_port;        /* offset 2 */
struct in_addr sin_addr;    /* offset 4 */
char sin_zero[8];        /* offset 8 */
};

struct in_addr
{
in_addr_t s_addr;        /* 32 bits */
};

#define sockaddr sockaddr_in
#define socklen_t int

/* CALLER and FASTCALL linkage calls */
extern int __LIB__    socket(int domain, int type, int protocol);
extern int __LIB__ __FASTCALL__ sockclose(int fd);
extern int __LIB__    bind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
extern int __LIB__    connect(int sockfd, struct sockaddr *serv_addr, socklen_t addrlen);
extern int __LIB__    send(int sockfd, void *buf, int len, int flags);
extern int __LIB__    recv(int sockfd, void *buf, int len, int flags);
extern int __LIB__    accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
extern int __LIB__    listen(int sockfd, int backlog);

/* CALLEE linkage calls */
extern int __LIB__ __CALLEE__    socket_callee(int domain, int type, int proto);
extern int __LIB__ __CALLEE__    bind_callee(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
extern int __LIB__ __CALLEE__    connect_callee(int sockfd, struct sockaddr *serv_addr, socklen_t addrlen);
extern int __LIB__ __CALLEE__    send_callee(int sockfd, void *buf, int len, int flags);
extern int __LIB__ __CALLEE__    sendto_callee(int sockfd, void *buf, int len, int flags, struct sockaddr *to, socklen_t tolen);
extern int __LIB__ __CALLEE__    recv_callee(int sockfd, void *buf, int len, int flags);
extern int __LIB__ __CALLEE__    recvfrom_callee(int sockfd, void *buf, int len, int flags, struct sockaddr *from, socklen_t *fromlen);
extern int __LIB__ __CALLEE__    accept_callee(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
extern int __LIB__ __CALLEE__    listen_callee(int sockfd, int backlog);

/* Make CALLEE default */
#define socket(a,b,c)        socket_callee(a,b,c)
#define bind(a,b,c)        bind_callee(a,b,c)
#define connect(a,b,c)        connect_callee(a,b,c)
#define send(a,b,c,d)        send_callee(a,b,c,d)
#define sendto(a,b,c,d,e,f)    sendto_callee(a,b,c,d,e,f)
#define recv(a,b,c,d)        recv_callee(a,b,c,d)
#define recvfrom(a,b,c,d,e,f)    recvfrom_callee(a,b,c,d,e,f)
#define accept(a,b,c)        accept_callee(a,b,c)
#define listen(a,b)        listen_callee(a,b)

/* htons is a no-op, since all the calls convert machine byte order to
* network byte order. The macro is provided for compatibility */
#define htons(a)        (a)
#define ntohs(a)        (a)

#endif
Any hints?

Siggi



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
siggi
Well known member
Posts: 343
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Ah.

Struct inaddr is defined after its first usage so move that definition up.
Done. Now it compiles :)

But the next problem is:

Code: Select all

D:\PRIVAT\ZX81\DEV\LAN\ZeddyNet\z88dk\libhttp>zcc +zx81 -I./include -O2 -preserv
e -vn addFormData.c freeFormData.c parseURI.c parseProto.c allocURI.c freeURI.c
base64enc.c request.c readData.c postsize.c getheader.c freeheaders.c readHeader
s.c htrecv.c
sccz80:"request.c" L:62 Error:Unknown symbol: sockaddr_in
sccz80:"request.c" L:63 Error:Unknown symbol: sockaddr_in
"sockaddr_in" is defined in "socket.h":

Code: Select all

#ifndef __SOCKET_H__
#define __SOCKET_H__

/*
* socket.h
*
* Routines that call the Spectranet ROM socket library.
*
* 2008-05-03 Dylan Smith
*/

/* Definitions */
#define AF_INET                0
#define SOCK_STREAM        1
#define SOCK_DGRAM        2
#define SOCK_RAW        3

/* Much of this should ultimately end up in sys/types.h */
#define in_addr_t        unsigned long

/* Structures */
/* Moved up on 07-08-2018 after a hint of DOM */
struct in_addr
{
in_addr_t s_addr;                /* 32 bits */
};

#define sockaddr sockaddr_in
#define socklen_t int

/* As defined in http://tools.ietf.org/html/draft-ietf-sip-bsd-systems-00 */
/* internet socket address structure */

struct sockaddr_in
{
int sin_family;                        /* offset 0 */
unsigned int sin_port;                /* offset 2 */
struct in_addr sin_addr;        /* offset 4 */
char sin_zero[8];                /* offset 8 */
};

//struct in_addr
//{
//        in_addr_t s_addr;                /* 32 bits */
//};

//#define sockaddr sockaddr_in
//#define socklen_t int

/* CALLER and FASTCALL linkage calls */
extern int __LIB__        socket(int domain, int type, int protocol);
extern int __LIB__ __FASTCALL__ sockclose(int fd);
extern int __LIB__        bind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
extern int __LIB__        connect(int sockfd, struct sockaddr *serv_addr, socklen_t addrlen);
extern int __LIB__        send(int sockfd, void *buf, int len, int flags);
extern int __LIB__        recv(int sockfd, void *buf, int len, int flags);
extern int __LIB__        accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
extern int __LIB__        listen(int sockfd, int backlog);

/* CALLEE linkage calls */
extern int __LIB__ __CALLEE__        socket_callee(int domain, int type, int proto);
extern int __LIB__ __CALLEE__        bind_callee(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
extern int __LIB__ __CALLEE__        connect_callee(int sockfd, struct sockaddr *serv_addr, socklen_t addrlen);
extern int __LIB__ __CALLEE__        send_callee(int sockfd, void *buf, int len, int flags);
extern int __LIB__ __CALLEE__         sendto_callee(int sockfd, void *buf, int len, int flags, struct sockaddr *to, socklen_t tolen);
extern int __LIB__ __CALLEE__        recv_callee(int sockfd, void *buf, int len, int flags);
extern int __LIB__ __CALLEE__        recvfrom_callee(int sockfd, void *buf, int len, int flags, struct sockaddr *from, socklen_t *fromlen);
extern int __LIB__ __CALLEE__        accept_callee(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
extern int __LIB__ __CALLEE__        listen_callee(int sockfd, int backlog);

/* Make CALLEE default */
#define socket(a,b,c)                socket_callee(a,b,c)
#define bind(a,b,c)                bind_callee(a,b,c)
#define connect(a,b,c)                connect_callee(a,b,c)
#define send(a,b,c,d)                send_callee(a,b,c,d)
#define sendto(a,b,c,d,e,f)        sendto_callee(a,b,c,d,e,f)
#define recv(a,b,c,d)                recv_callee(a,b,c,d)
#define recvfrom(a,b,c,d,e,f)        recvfrom_callee(a,b,c,d,e,f)
#define accept(a,b,c)                accept_callee(a,b,c)
#define listen(a,b)                listen_callee(a,b)

/* htons is a no-op, since all the calls convert machine byte order to
* network byte order. The macro is provided for compatibility */
#define htons(a)                (a)
#define ntohs(a)                (a)

#endif
The line 62 of "request.c", where the error occurs, is

Code: Select all

        if(connect(sockfd, &remoteaddr, sizeof(sockaddr_in)) < 0)
{
sockclose(sockfd);
return EHTTP_CONNFAIL;
}
Full source of "request.c":

Code: Select all

/*
* The MIT License
*
* Copyright (c) 2010 Dylan Smith
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/

#include <http.h>
#include <sys/socket.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>

static Formdata *formhead=NULL;
static Formdata *formtail=NULL;

static char headersread=0;

#define HDRBUFSZ        512

int request(int type, URI *uri)
{
int sockfd, bytes;
struct sockaddr_in remoteaddr;
struct hostent *he;
char *authstring;
char hdrbuf[HDRBUFSZ];
char csizebuf[8];
char tmpbuf[120];
Formdata *fptr;

headersread=0;

he=gethostbyname(uri->host);
if(!he) return EHTTP_DNSFAIL;

sockfd=socket(AF_INET, SOCK_STREAM, 0);
if(sockfd < 0) return EHTTP_SOCKFAIL;

/* TODO: implement arbitrary ports for http */
remoteaddr.sin_port=htons(80);
remoteaddr.sin_addr.s_addr=he->h_addr;
if(connect(sockfd, &remoteaddr, sizeof(sockaddr_in)) < 0)
{
sockclose(sockfd);
return EHTTP_CONNFAIL;
}

if(type == GET)
{
sprintf(hdrbuf, "GET %s HTTP/1.1\n\r", uri->location);
addStdHeaders(hdrbuf, uri, HDRBUFSZ);
strlcat(hdrbuf, LINE_END, HDRBUFSZ);
bytes=send(sockfd, hdrbuf, strlen(hdrbuf), 0);
if(bytes < 0)
return EHTTP_WRITEFAIL;
}
else
{
sprintf(hdrbuf, "POST %s HTTP/1.1\n\r", uri->location);
addStdHeaders(hdrbuf, uri, HDRBUFSZ);

/* make up the Content-Length header */
/* TODO: Proper addition of headers, not this hideous
* function */
strlcat(hdrbuf, CONTLEN_HDR, HDRBUFSZ);
strlcat(hdrbuf, ": ", HDRBUFSZ);
sprintf(csizebuf, "%d\n\r", postsize());
strlcat(hdrbuf, csizebuf, HDRBUFSZ);

strlcat(hdrbuf, CONTENT_HDR, HDRBUFSZ);
strlcat(hdrbuf, LINE_END, HDRBUFSZ);

/* send what we have now. The reason being is that
* POST headers can be rather long, with many options */
/*                bytes=send(sockfd, hdrbuf, strlen(hdrbuf), 0);
if(bytes < 0)
return EHTTP_WRITEFAIL; */

/* now the form data */
fptr=formhead;
while(fptr)
{
/*
sprintf(hdrbuf, "%s=%s\n\r",
fptr->param,
fptr->data);
printf("SENDING: %s", hdrbuf);
bytes=send(sockfd, hdrbuf, strlen(hdrbuf), 0);
if(bytes < 0)
return EHTTP_WRITEFAIL;*/
if(fptr->next)
{
sprintf(tmpbuf, "%s=%s&",
fptr->param,
fptr->data);
}
else
{
sprintf(tmpbuf, "%s=%s\n\r",
fptr->param,
fptr->data);
}
strlcat(hdrbuf, tmpbuf, HDRBUFSZ);
fptr=fptr->next;
}
bytes=send(sockfd, hdrbuf, strlen(hdrbuf), 0);
if(bytes < 0)
return EHTTP_WRITEFAIL;
}
return sockfd;
}

int addStdHeaders(char *hdrbuf, URI *uri, int bufsz)
{
char *authstr, *auth64buf;
int authlen;
if(uri->user)
{
authlen=strlen(uri->user)+strlen(uri->passwd)+2;
authstr=(char *)malloc(authlen);
if(!authstr) return ENOMEM;

sprintf(authstr, "%s:%s", uri->user, uri->passwd);
auth64buf=(char *)malloc(authlen+(authlen/2));
if(!auth64buf) return ENOMEM;

base64enc(auth64buf, authstr, authlen-1);
strlcat(hdrbuf, AUTH_HDR, bufsz);
strlcat(hdrbuf, auth64buf, bufsz);
strlcat(hdrbuf, LINE_END, bufsz);
free(authstr);
free(auth64buf);
}

strlcat(hdrbuf, USER_AGENT, bufsz);
strlcat(hdrbuf, ACCEPT_HDR, bufsz);
strlcat(hdrbuf, "Host: ", bufsz);
strlcat(hdrbuf, uri->host, bufsz);
strlcat(hdrbuf, LINE_END, bufsz);
return 0;
}
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

I think the old sccz80 was very casual with structs - and the rewrite last year is a bit more standard.

It looks like the sizeof() is just on the tag - it should be on struct sockaddr_in etc
On 7 Aug 2018, at 21:06, siggi (siggi@...) <lists@...> wrote:

Ah.

Struct inaddr is defined after its first usage so move that definition up.
Done. Now it compiles :)

But the next problem is:

Code: Select all

D:\PRIVAT\ZX81\DEV\LAN\ZeddyNet\z88dk\libhttp>zcc +zx81 -I./include -O2 -preserv
e -vn addFormData.c freeFormData.c parseURI.c parseProto.c allocURI.c freeURI.c
base64enc.c request.c readData.c postsize.c getheader.c freeheaders.c readHeader
s.c htrecv.c
sccz80:"request.c" L:62 Error:Unknown symbol: sockaddr_in
sccz80:"request.c" L:63 Error:Unknown symbol: sockaddr_in
"sockaddr_in" is defined in "socket.h":

Code: Select all

#ifndef __SOCKET_H__
#define __SOCKET_H__

/*
* socket.h
*
* Routines that call the Spectranet ROM socket library.
*
* 2008-05-03 Dylan Smith
*/

/* Definitions */
#define AF_INET        0
#define SOCK_STREAM    1
#define SOCK_DGRAM    2
#define SOCK_RAW    3

/* Much of this should ultimately end up in sys/types.h */
#define in_addr_t    unsigned long

/* Structures */
/* Moved up on 07-08-2018 after a hint of DOM */
struct in_addr
{
in_addr_t s_addr;        /* 32 bits */
};

#define sockaddr sockaddr_in
#define socklen_t int

/* As defined in http://tools.ietf.org/html/draft-ietf-sip-bsd-systems-00 */
/* internet socket address structure */

struct sockaddr_in
{
int sin_family;            /* offset 0 */
unsigned int sin_port;        /* offset 2 */
struct in_addr sin_addr;    /* offset 4 */
char sin_zero[8];        /* offset 8 */
};

//struct in_addr
//{
//    in_addr_t s_addr;        /* 32 bits */
//};

//#define sockaddr sockaddr_in
//#define socklen_t int

/* CALLER and FASTCALL linkage calls */
extern int __LIB__    socket(int domain, int type, int protocol);
extern int __LIB__ __FASTCALL__ sockclose(int fd);
extern int __LIB__    bind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
extern int __LIB__    connect(int sockfd, struct sockaddr *serv_addr, socklen_t addrlen);
extern int __LIB__    send(int sockfd, void *buf, int len, int flags);
extern int __LIB__    recv(int sockfd, void *buf, int len, int flags);
extern int __LIB__    accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
extern int __LIB__    listen(int sockfd, int backlog);

/* CALLEE linkage calls */
extern int __LIB__ __CALLEE__    socket_callee(int domain, int type, int proto);
extern int __LIB__ __CALLEE__    bind_callee(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
extern int __LIB__ __CALLEE__    connect_callee(int sockfd, struct sockaddr *serv_addr, socklen_t addrlen);
extern int __LIB__ __CALLEE__    send_callee(int sockfd, void *buf, int len, int flags);
extern int __LIB__ __CALLEE__    sendto_callee(int sockfd, void *buf, int len, int flags, struct sockaddr *to, socklen_t tolen);
extern int __LIB__ __CALLEE__    recv_callee(int sockfd, void *buf, int len, int flags);
extern int __LIB__ __CALLEE__    recvfrom_callee(int sockfd, void *buf, int len, int flags, struct sockaddr *from, socklen_t *fromlen);
extern int __LIB__ __CALLEE__    accept_callee(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
extern int __LIB__ __CALLEE__    listen_callee(int sockfd, int backlog);

/* Make CALLEE default */
#define socket(a,b,c)        socket_callee(a,b,c)
#define bind(a,b,c)        bind_callee(a,b,c)
#define connect(a,b,c)        connect_callee(a,b,c)
#define send(a,b,c,d)        send_callee(a,b,c,d)
#define sendto(a,b,c,d,e,f)    sendto_callee(a,b,c,d,e,f)
#define recv(a,b,c,d)        recv_callee(a,b,c,d)
#define recvfrom(a,b,c,d,e,f)    recvfrom_callee(a,b,c,d,e,f)
#define accept(a,b,c)        accept_callee(a,b,c)
#define listen(a,b)        listen_callee(a,b)

/* htons is a no-op, since all the calls convert machine byte order to
* network byte order. The macro is provided for compatibility */
#define htons(a)        (a)
#define ntohs(a)        (a)

#endif
The line 62 of "request.c", where the error occurs, is

Code: Select all

    if(connect(sockfd, &remoteaddr, sizeof(sockaddr_in)) < 0)
{
sockclose(sockfd);
return EHTTP_CONNFAIL;
}
Full source of "request.c":

Code: Select all

/*
* The MIT License
*
* Copyright (c) 2010 Dylan Smith
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/

#include <http.h>
#include <sys/socket.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>

static Formdata *formhead=NULL;
static Formdata *formtail=NULL;

static char headersread=0;

#define HDRBUFSZ    512

int request(int type, URI *uri)
{
int sockfd, bytes;
struct sockaddr_in remoteaddr;
struct hostent *he;
char *authstring;
char hdrbuf[HDRBUFSZ];
char csizebuf[8];
char tmpbuf[120];
Formdata *fptr;

headersread=0;

he=gethostbyname(uri->host);
if(!he) return EHTTP_DNSFAIL;

sockfd=socket(AF_INET, SOCK_STREAM, 0);
if(sockfd < 0) return EHTTP_SOCKFAIL;

/* TODO: implement arbitrary ports for http */
remoteaddr.sin_port=htons(80);
remoteaddr.sin_addr.s_addr=he->h_addr;
if(connect(sockfd, &remoteaddr, sizeof(sockaddr_in)) < 0)
{
sockclose(sockfd);
return EHTTP_CONNFAIL;
}

if(type == GET)
{
sprintf(hdrbuf, "GET %s HTTP/1.1\n\r", uri->location);
addStdHeaders(hdrbuf, uri, HDRBUFSZ);
strlcat(hdrbuf, LINE_END, HDRBUFSZ);
bytes=send(sockfd, hdrbuf, strlen(hdrbuf), 0);
if(bytes < 0)
return EHTTP_WRITEFAIL;
}
else
{
sprintf(hdrbuf, "POST %s HTTP/1.1\n\r", uri->location);
addStdHeaders(hdrbuf, uri, HDRBUFSZ);

/* make up the Content-Length header */
/* TODO: Proper addition of headers, not this hideous
* function */
strlcat(hdrbuf, CONTLEN_HDR, HDRBUFSZ);
strlcat(hdrbuf, ": ", HDRBUFSZ);
sprintf(csizebuf, "%d\n\r", postsize());
strlcat(hdrbuf, csizebuf, HDRBUFSZ);

strlcat(hdrbuf, CONTENT_HDR, HDRBUFSZ);
strlcat(hdrbuf, LINE_END, HDRBUFSZ);

/* send what we have now. The reason being is that
* POST headers can be rather long, with many options */
/*        bytes=send(sockfd, hdrbuf, strlen(hdrbuf), 0);
if(bytes < 0)
return EHTTP_WRITEFAIL; */

/* now the form data */
fptr=formhead;
while(fptr)
{
/*
sprintf(hdrbuf, "%s=%s\n\r",
fptr->param,
fptr->data);
printf("SENDING: %s", hdrbuf);
bytes=send(sockfd, hdrbuf, strlen(hdrbuf), 0);
if(bytes < 0)
return EHTTP_WRITEFAIL;*/
if(fptr->next)
{
sprintf(tmpbuf, "%s=%s&",
fptr->param,
fptr->data);
}
else
{
sprintf(tmpbuf, "%s=%s\n\r",
fptr->param,
fptr->data);
}
strlcat(hdrbuf, tmpbuf, HDRBUFSZ);
fptr=fptr->next;
}
bytes=send(sockfd, hdrbuf, strlen(hdrbuf), 0);
if(bytes < 0)
return EHTTP_WRITEFAIL;
}
return sockfd;
}

int addStdHeaders(char *hdrbuf, URI *uri, int bufsz)
{
char *authstr, *auth64buf;
int authlen;
if(uri->user)
{
authlen=strlen(uri->user)+strlen(uri->passwd)+2;
authstr=(char *)malloc(authlen);
if(!authstr) return ENOMEM;

sprintf(authstr, "%s:%s", uri->user, uri->passwd);
auth64buf=(char *)malloc(authlen+(authlen/2));
if(!auth64buf) return ENOMEM;

base64enc(auth64buf, authstr, authlen-1);
strlcat(hdrbuf, AUTH_HDR, bufsz);
strlcat(hdrbuf, auth64buf, bufsz);
strlcat(hdrbuf, LINE_END, bufsz);
free(authstr);
free(auth64buf);
}

strlcat(hdrbuf, USER_AGENT, bufsz);
strlcat(hdrbuf, ACCEPT_HDR, bufsz);
strlcat(hdrbuf, "Host: ", bufsz);
strlcat(hdrbuf, uri->host, bufsz);
strlcat(hdrbuf, LINE_END, bufsz);
return 0;
}
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
siggi
Well known member
Posts: 343
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

I think the old sccz80 was very casual with structs - and the rewrite last year is a bit more standard.

It looks like the sizeof() is just on the tag - it should be on struct sockaddr_in etc
Now it works :)
Thanks a lot ..

Siggi



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
siggi
Well known member
Posts: 343
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Now the real work starts :(

I can build all needed ZeddyNet libs successfully. I have adapted a network program (IRC chat) to the current compiler. I have linked it with the ZeddyNet libs. The program starts successfully and behaves normally. But it crashes, when the first network function is called.

Any hints, where I can start debugging? E. g. create map/assembler files of the libs, using old and current compiler?

Did some standard datatypes change (e. g. in size) between 2015 and now? So maybe this might no more be correct?

Code: Select all

/* Much of this should ultimately end up in sys/types.h */
#define in_addr_t        unsigned long

/* Structures */
/* Moved up on 07-08-2018 after a hint of DOM */
struct in_addr
{
in_addr_t s_addr;                /* 32 bits */
};

#define sockaddr sockaddr_in
#define socklen_t int

/* As defined in http://tools.ietf.org/html/draft-ietf-sip-bsd-systems-00 */
/* internet socket address structure */

struct sockaddr_in
{
int sin_family;                        /* offset 0 */
unsigned int sin_port;                /* offset 2 */
struct in_addr sin_addr;        /* offset 4 */
char sin_zero[8];                /* offset 8 */
};
Siggi



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

Did the standard datatypes change (e. g. in size) between 2015 and now? So maybe this might no more be correct?
No "unsigned long" is still 4 bytes and integer types are 2.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
siggi
Well known member
Posts: 343
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Meanwhile I did more tests and had some success:
when I first started SENDMAIL in standard configuration, it crashed during connecting to the mailserver (gethostbyname). When I entered the mailservers IP instead of its name, I were able to connect to the server, to send and receive messages during login (aborteded due to a wrong password, no crash). When I repeated that, the Zeddy crashed during login at the server.
Crashs are not reproducible, so I think that the ZeddyNet-libraries and their call-interfaces are correct. And I think there might be a problem of ZX81 display/SLOW mode/IXIY/aa' during ZeddyNet calls.

Siggi



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

I won't have time until late today to look myself but it would probably be worthwhile to check the asm implementation of the string functions and/or stdlib functions you are using around the code that is crashing:

string
https://github.com/z88dk/z88dk/tree/mas ... string/z80

stdlib (not the floating point stuff)
https://github.com/z88dk/z88dk/tree/mas ... stdlib/z80

The classic lib is now using much of the implementation here and this is changed from the last time you compiled zeddynet. These functions were written with issues like staying away from exx,af',ix/iy (only one index register used) in mind to keep code most portable but I can tell you there were instances where these rules were broken if it made a difference in code quality. The intent has always been to supply an alternate implementation for targets that can't use the generic one. However, this may have been overlooked when classic took these functions in.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

And to complete the thought, classic's own functions:

string (you can see there is not much left that does not come from newlib):
https://github.com/z88dk/z88dk/tree/mas ... rc/strings

stdlib
https://github.com/z88dk/z88dk/tree/mas ... src/stdlib



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

It seems I am on a roll here...

One less likely issue is any integer (long, int, etc) multiplies / divides your code may be doing. I don't think the classic lib has changed here but it's worthwhile (for me or dom/stef) to check out later that code has not been changed to use registers that can't be touched for the zx81.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
siggi
Well known member
Posts: 343
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Some news: SENDMAIL works as expected, when I run all ZeddyNet calls in FAST-Mode (and switch back to SLOW during other actions)!
I compiled all ZeddyNet libs using -IXIY option. So something else essential for a ZX81 is destroyed ...

Siggi



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
siggi
Well known member
Posts: 343
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Some fuctions used in context of network calls:

Code: Select all

atoi
printk
in_Wait
strlen
sprintf
sizeof
memset
And some calculations:

Code: Select all

    for ( bol = 1, count = 1; count != length; ++data, count++ )
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

Some fuctions used in context of network calls:

Code: Select all

atoi
printk
in_Wait
strlen
sprintf
sizeof
memset
atoi, strlen, memset are ok.

printf was completely changed so a good place to check is sprintf. What % converters are you using?



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Some fuctions used in context of network calls:

Code: Select all

atoi
printk
in_Wait
strlen
sprintf
sizeof
memset
What formats are you using with printk/sprintf? I can see a use of af' when printing numbers with the 0x prefix which I've now replaced.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
siggi
Well known member
Posts: 343
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

What formats are you using with printk/sprintf? I can see a use of af' when printing numbers with the 0x prefix which I've now replaced.
That is, what my editor found:

Code: Select all

Suche "print" im aktiven Dokument

D:\PRIVAT\ZX81\DEV\LAN\sendmail\mini_sendmail-V2.3.c
81: printk("len=%d\n", len);
83: printk("%d,",(int) text[i]);
84: printk("\n");
114: void lprint(unsigned char *text)
118: //                zx_lprintc(*text++);
119:         zx_lprintc5(*text++);
130:     printk(        "\nEDIT/PRINT menu\n"
135:                     "5: print message\n"
140:     printk("\n");
147: printf("enter text (max %d char):\n%s", sizeof(message) - strlen(message), message);
160:                         printk("Using ZEDIT text len %d.\n", strlen(msg_ptr));
167:                         printk("message copied to ZEDIT.\n");
176:                         printk("\nPrinting ...\n");
178:                         lprint(msg_ptr);
180:                         printk("Done\n");
200: printk("sendmail %s for zx81\n\n", VERSION);
203: printk("configure smtp login?(y/n)");
205: printk("\n");
212: printk("enter smtp config:\n(<ret> for default)\n");
213: printk("smtp-server: (%s)\n", server);
218: printf("serverchar = %u\n", (unsigned int) *buf);
219: printf("in_inKey = %u\n", in_Inkey());
223: printk("port (%d):", port);
230: printk("your hostname (%s):\n", hostname);
238: printk("login name (? for (at)):\n");
254: printk("password %s:\n", cap_info);
259: printk("reply-to address (? for (at)):\n");
277: printk("using SMTP-config for:\n%s\n", username);
284: printk("\nsubject %s:\n", cap_info);
291: printk("\nSend? Change? Exit?:");
293: printk("\n");
304: printk("verbose?(y/n):");
312: (void) printk("unexpected socket error %d\n", sockfd1);
327: (void) printk("%s: unexpected initial greeting %d\n", server, status );
331: (void) sprintf( buf, "EHLO %s", hostname );
336: (void) printk(
341: (void) sprintf( buf, "AUTH LOGIN" );
346: (void) printk(
358: (void) printk("%s: ERROR %d: invalid username?\n",server, status );
369: (void) printk("%s: ERROR %d: invalid password?\n",server, status );
373: sprintf( buf, "MAIL FROM:<%s>", username);
378: (void) printk("%s: ERROR %d: invalid sender address?\n",server, status );
389:     printk("\n");
391: printk("enter recipient (use ? as (at))\n");
410: (void) printk("%s: no recipients found\n", server );
419: (void) printk("%s: ERROR %d during send\n",server, status );
423: sprintf(buf, "User-Agent: ZX81 Sendmail %s ", VERSION);
426: sprintf(buf, "From: %s ", username);
431: sprintf(buf, "Reply-to: %s ", reply_to);
436: sprintf(buf, "Subject: %s ", subject);
440:         sprintf(buf, "MIME-Version: 1.0 ");
442:         sprintf(buf, "Content-type: text/plain; charset=UTF-8 ");
444:         sprintf(buf, "Content-Transfer-Encoding: base64 ");
456: (void) printk("%s: ERROR %d after sending message\n",server, status );
463: (void) printk(
474: printk("\nretry SEND?(y/n):");
476: printk("\n");
485: printk("\ndon't forget to SAVE new config.\n");
487: printk("message at %u len %u\n", message, strlen(message));
515: sprintf( mbuf, "RCPT TO:<%s>", recipient );
520: printk("%s: ERROR %d: invalid e-mail addr?\n",server, status );
553: (void) printk("server name lookup of \n\"%s\"\nfailed - %d\n", server, h_errno );
571: printk("%s\n", server);
587: (void) printk("%s: unexpected EOF\n", server );
595: printk("<<< %s\n", resp_buf);
610: printk(">>> %s\n", command );
677: printk("ERROR: %s\n", cause );
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
siggi
Well known member
Posts: 343
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Some news:
I added some checkpoints to SMAIL to find locations of crashes. I found, that (at least) my network functions crash, when running in SLOW:
he = gethostbyname( server );
int rc = recv(sockfd1, resp_buf, sizeof(resp_buf) - 1, 0);

The listing recvfrom_callee.lis shows, that register IX is used:

Code: Select all

6     0000              LIB libsocket, F_recvfrom
7     0000
8     0000              .recvfrom_callee
9     0000  DD 21 02 00         ld ix, 2
10    0004  DD 39               add ix, sp                ; ix = socklen_t *fromlen
11    0006  DD 7E 0A            ld a, (ix+10)                ; get sockfd
12    0009  D1                  pop de                        ; return address
13    000A  21 0C 00            ld hl, 12
I assemble this file using option -IXIY:
z80asm -s -l -m -g -IXIY -I../../include -xlibsocket @libsocket.lst

Is -IXIY still working like in 2015 and is it still passed to all locations, where it is needed??????

Siggi



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Is -IXIY still working like in 2015 and is it still passed to all locations, where it is needed??????
It looks like it's --IXIY now (double dash) - I'll raise an issue regarding the lack of warning/error when a single dash is supplied.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
siggi
Well known member
Posts: 343
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

BINGO!
Now everthing works as usual.

Thanks
Siggi

PS: zcc also does no more have that option and also gives no error or warning.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Post Reply