Macintosh using CWGUSI changes and patches

Henrick,

Thank you for getting me onboard with the w3 alpha group.

Greetings everyone!

These were the changes I found necessary to the wwwlib 4.1 and w3 mini-server
source, in order to compile & execute under 68K and PPC macintosh platform
using Metrowerks CodeWarrior IDE, and the CWGUSI 1.7.0 sockets library by
Matthias Neeracher. In the process, I also found and fixed a bug in the GUSI
socket library's, socket destructor method, that caused premature socket
closures (i.e., broken pipe errors in browsers). I have passed this fix on to
Matthias, but in the meantime if anyone wants the patch, please drop me a line.

I did not include wais support, as HTWAIS.c references a #include <ui.h> that I
do not have. If someone could supply me with this header, I would see what I
could do about added WAIS support for macintosh in the future. sinc, -j

//
// LIBRARY CHANGES
//

// Created a new file called MacPaths.c and added to the library for
// Macintosh specific methods. To the file  I have added the following
// function definition:
//
void unixPathToMacPath(char *thepath)
{
// translate unix delimiter to mac path delimiters
short i;
for (i = 0; i <= strlen(thepath); ++i)
        if (thepath[i] == '/') thepath[i] = ':';
}

// Added the following line to the #ifdef __MWERKS__  section of tcp.h
#define NO_GETPID /* getpid() does not exist */

//
// Addition to beginning of the file HTMulti.c
//
#ifdef macintosh
#include "MacPaths.h"   // for prototypes
#endif
//
// Change to HTMulti.c for macintosh support
//
PUBLIC char * HTMulti (HTRequest *      req,
                       char *           path,
                       struct stat *    stat_info)
{
    char * new_path = NULL;
    int stat_status = -1;

    if (!req || !path || !*path || !stat_info)
        return NULL;

#ifdef GOT_READ_DIR
#ifdef macintosh
        unixPathToMacPath(path);        // added JTD:2/14/96
    if (*(path+strlen(path)-1) == ':') {        /* Find welcome page */
#else
    if (*(path+strlen(path)-1) == '/') {        /* Find welcome page */
#endif
// ... balance of function unchanged

//
// Addition to beginning of the file HTWWWStr.c
//
#ifdef macintosh
#include "MacPaths.h"   // for prototypes
#endif
//
// Change to HTWWWStr.c for macintosh support
//
// In the function HTWWWToLocal(), after the comment line:
            /*
            ** Do whatever translation is required here in order to fit your
            ** platform _before_ the path is unescaped.
            */
// add the following
#ifdef macintosh        // added JTD:2/20/96
            unixPathToMacPath(path);
#endif
//
// also in the function HTLocalToWWW(), add the very end of the function,
// just before the return statement...
//
#ifdef macintosh // added JTD:2/20/96
        unixPathToMacPath(result);
#endif
    return result;
}

// I have also macintized HTHome.c and get_best_welcome(), but I will pass
// this on later, since it does not yet come into play with the current state
// of the mini-server.

//
// SERVER CHANGES
//
// Added to the beginning of HTServer.c
#ifdef __MWERKS__
#include <console.h> // added JTD - added for 'ccommand'
#endif

#define LISTEN_SOCKET_CNT 6 // how many sockets to listen on. One is *NOT*
enuf (:

// Original version of main() would cause mac to buss error as the
// MiniServ_new() call executed *BEFORE* the GUSI sockets were initialized.
// Also added a standard init section to properly initialize the mac toolbox.
//
int main (int argc, char ** argv)
{
    int         arg;
    MiniServ *  ms;

#ifdef __MWERKS__
        // init common mac toolbox managers - JTD
        InitGraf(&qd.thePort);
        InitFonts();
        InitWindows();
        InitMenus();
        TEInit();
        InitDialogs(0L);
        InitCursor();
        MaxApplZone();
        MoreMasters();
        MoreMasters();
        MoreMasters();
        argc = ccommand(&argv); // present arg query dialog - JTD
#endif

    /* Starts Mac GUSI socket library */
#ifdef GUSI
    GUSISetup(GUSIwithSIOUXSockets);
    GUSISetup(GUSIwithInternetSockets);
#endif

        // moved down since this allocates memory, and we can't
        //   do that 'til we init the mac toolbox stuff.
        ms = MiniServ_new();

// ... the balance of main here ...

    /* Set up a server to listen on this port */
    if (ms->port >= 0) {
    int theSocket;      // added the opening of multiple sockets JTD:2/27/96
    for (theSocket = 0; theSocket < LISTEN_SOCKET_CNT; ++theSocket)
        {
                HTNet * net = HTNet_new(ms->request, ms->port);

                /* Start listening on the socket */
                if (net && HTDoListen(net, ms->port, INVSOC, ms->backlog)
== HT_OK)
                        {
                    /* Register a callback function for handling a request */
                    HTEvent_Register(HTNet_socket(net), ms->request,
(SockOps) FD_READ,
                                     server_handler, HT_PRIORITY_MAX);
                        }
                else
                        {
                    if (WWWTRACE) HTTrace("Can't listen on port %d\n",ms->port);
                    Cleanup(ms, -1);
                        }
                }
    }

// ... the balance of main here ...
// end of changes

Received on Friday, 1 March 1996 10:11:28 UTC