ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/AmigaOS/ether_amiga.cpp
(Generate patch)

Comparing BasiliskII/src/AmigaOS/ether_amiga.cpp (file contents):
Revision 1.3 by cebix, 1999-11-03T10:56:18Z vs.
Revision 1.8 by cebix, 2001-07-13T15:39:22Z

# Line 1 | Line 1
1   /*
2   *  ether_amiga.cpp - Ethernet device driver, AmigaOS specific stuff
3   *
4 < *  Basilisk II (C) 1997-1999 Christian Bauer
4 > *  Basilisk II (C) 1997-2001 Christian Bauer
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 116 | Line 116 | static int16 send_to_proc(uint32 what, u
116   *  Initialization
117   */
118  
119 < void EtherInit(void)
119 > bool ether_init(void)
120   {
121          // Do nothing if no Ethernet device specified
122          if (PrefsFindString("ether") == NULL)
123 <                return;
123 >                return false;
124  
125          // Initialize protocol list
126          NewList(&prot_list);
# Line 151 | Line 151 | void EtherInit(void)
151                  goto open_error;
152  
153          // Everything OK
154 <        net_open = true;
155 <        return;
154 >        return true;
155  
156   open_error:
157          net_proc = NULL;
# Line 160 | Line 159 | open_error:
159                  DeleteMsgPort(reply_port);
160                  reply_port = NULL;
161          }
162 +        return false;
163   }
164  
165  
# Line 167 | Line 167 | open_error:
167   *  Deinitialization
168   */
169  
170 < void EtherExit(void)
170 > void ether_exit(void)
171   {
172          // Stop process
173          if (net_proc) {
# Line 188 | Line 188 | void EtherExit(void)
188   *  Reset
189   */
190  
191 < void EtherReset(void)
191 > void ether_reset(void)
192   {
193          // Remove all protocols
194 <        if (net_open)
194 >        if (net_proc)
195                  send_to_proc(MSG_CLEANUP);
196   }
197  
# Line 346 | Line 346 | static __saveds __regargs LONG copy_from
346  
347   static __saveds void net_func(void)
348   {
349 +        const char *str;
350 +        BYTE od_error;
351          struct MsgPort *write_port = NULL, *control_port = NULL;
352          struct IOSana2Req *write_io = NULL, *control_io = NULL;
353          bool opened = false;
# Line 388 | Line 390 | static __saveds void net_func(void)
390          // Parse device name
391          char dev_name[256];
392          ULONG dev_unit;
393 <        if (sscanf(PrefsFindString("ether"), "%[^/]/%ld", dev_name, &dev_unit) < 2)
393 >
394 >        str = PrefsFindString("ether");
395 >        if (str)
396 >                {
397 >                const char *FirstSlash = strchr(str, '/');
398 >                const char *LastSlash = strrchr(str, '/');
399 >
400 >                if (FirstSlash && FirstSlash && FirstSlash != LastSlash)
401 >                        {
402 >                        // Device name contains path, i.e. "Networks/xyzzy.device"
403 >                        const char *lp = str;
404 >                        char *dp = dev_name;
405 >
406 >                        while (lp != LastSlash)
407 >                                *dp++ = *lp++;
408 >                        *dp = '\0';
409 >
410 >                        if (strlen(dev_name) < 1)
411 >                                goto quit;
412 >
413 >                        if (1 != sscanf(LastSlash, "/%ld", &dev_unit))
414 >                                goto quit;
415 >
416 > //                      printf("dev=<%s> unit=%d\n", dev_name, dev_unit);
417 >                        }
418 >                else
419 >                        {
420 >                        if (2 != sscanf(str, "%[^/]/%ld", dev_name, &dev_unit))
421 >                                goto quit;
422 >                        }
423 >                }
424 >        else
425                  goto quit;
426  
427          // Open device
428          control_io->ios2_BufferManagement = buffer_tags;
429 <        if (OpenDevice((UBYTE *)dev_name, dev_unit, (struct IORequest *)control_io, 0) || control_io->ios2_Req.io_Device == 0)
429 >        od_error = OpenDevice((UBYTE *)dev_name, dev_unit, (struct IORequest *)control_io, 0);
430 >        if (0 != od_error || control_io->ios2_Req.io_Device == 0)
431 >                {
432 >                printf("WARNING: OpenDevice(<%s>, unit=%d) returned error %d)\n", (UBYTE *)dev_name, dev_unit, od_error);
433                  goto quit;
434 +                }
435          opened = true;
436  
437          // Is it Ethernet?

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines