home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / languages / c / oslib / Examples / p2-638 < prev    next >
Encoding:
Text File  |  1995-02-16  |  970 b   |  43 lines

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