HttpFileServer65 is inspired by "HFS ~ Http File Server" (http://www.rejetto.com/hfs/). It features an intuitive mapping of local disks and directories to HTTP paths. This allows to not only navigate to some file but to directly enter some file URL. This is especially usefull for downloads via wget, curl or alike.
However, in contrast to HFS it doesn't allow file uploads, only file downloads. On targets with complete DIO support it additionally allows disk image downloads.
Note: The Atari build currently fails as there's so far no getdevicedir() in the Atari C library.
This is just for the "C" interface of IP65. clk_timer.s replaces
atr_timer.s (on Atari) and is new for the C64 (there wasn't an
implementation for the "C" interface before).
The C library allows us manage de-initializations via atext() so we can avoid the explict timer_exit call necessary in atrtimer.s (used for assembler programs).
The HTTP callback is explicitly allowed to send the HTTP response on its own and set the carry to signal that. Therefore it seems reasonable to export httpd_send_response to allow the HTTP callback to make use of the given infrastructure to send the HTTP response.
Given that Telnet65's 80 column display requires an enhanced Apple //e anyway it seems reasonable to have the C applications benefit from building for that target too.
The date application isn't of much actual use. But it shows
- how easy to use the IP65 C API is
- the power of combining IP65 with the C library
(going from SNTP time format to a date string in two lines of code)
I don't have plans to support C programs on the VIC20. So now that there are C test programs the simplest solution is to not (try to) build VIC20 test programs as part of the default recipe.
Together with the recent change to provide the inbound data buffer address and length to the TCP callback function as C parameters this change allows the TCP API to get along without any global variable :-)
In contrast to the multiple UDP callbacks there's only one TCP callback so it easy to provide a wrapper for the C callback that pushes C parameters on the stack.
Now that we process incoming data from the main loop - and use 'buf' both for incoming and outgoing data we should of course make sure that we never trash the incoming data with outgoing data.
The C test program may serve as copy & paste templates so it should make clear that ip65_process() is supposed to be called pretty regularly. Additionally it isn't supposed to be called recursively meaning that recv callbacks need to return quickly and defer longer processing.
The IP5 usage of ld65 segments and zeropage variables was made compatible with cc65 C programs already a while ago. This commit is the next logical step which is to introduce the actual C interface to IP65.
IP65 for C programs shares the the ip65.lib / ip65_tcp.lib with IP65 for assembler programs. However the various libraries from the 'drivers' are not reused. Instead there's exactly one library for every target named ip65_<target>.lib. Those libraries contain only functions used by ip65.lib / ip65_tcp.lib.
TODOs:
- Introduce c64_timer.s and atr_timer.s.
- Add a C interface to the rest of the IP65 functionality (especially TCP).