home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / oslib / Examples / p2-638 < prev    next >
Encoding:
Text File  |  1994-03-24  |  950 b   |  42 lines

  1. #include "econet.h"
  2. #include "os.h"
  3.  
  4. #define ERROR_NUMBER_SYNTAX 1
  5. #define ERROR_NUMBER_UNABLE_TO_DEFAULT 2
  6.  
  7. static os_error Error_Get_Regs_Syntax =
  8.       {ERROR_NUMBER_SYNTAX, "Syntax: *Command <station number>"};
  9.  
  10. static os_error Error_Unable_To_Default =
  11.    {  ERROR_NUMBER_UNABLE_TO_DEFAULT,
  12.       "Either a station number or a full network address is required"
  13.    };
  14.  
  15. os_error *command_start (char *buf, byte *station_out, byte *net_out)
  16.  
  17. {  os_error *error = NULL;
  18.    int station, net; /*must be int to detect -1 returns*/
  19.  
  20.    if (EMPTY (buf))
  21.    {  error = &Error_Get_Regs_Syntax;
  22.       goto finish;
  23.    }
  24.  
  25.    if ((error = xeconet_read_station_number (buf, NULL, &station, &net))
  26.          != NULL)
  27.       goto finish;
  28.  
  29.    if (station == -1)
  30.    {  error = &Error_Unable_To_Default;
  31.       goto finish;
  32.    }
  33.  
  34.    if (net == -1) net = 0;
  35.  
  36.    *station_out = (byte) station; /*narrowing cast*/
  37.    *net_out     = (byte) net;
  38.  
  39. finish:
  40.    return error;
  41. }
  42.