Logo Search packages:      
Sourcecode: cbmlink version File versions  Download package

struct hostinfo* establish ( const char *  name,
const char *  dev,
const struct comm **  comm 
) [read]

Select a communication protocol by name, and initialize the communications

Parameters:
name name of the protocol (NULL=default)
dev name of the communication interface device
comm (output) pointer to the communication primitives
Returns:
pointer to host information, or NULL on error

Definition at line 252 of file commsel.c.

References comm_init(), and commproto::name.

Referenced by main().

{
  const struct commproto* proto;
#ifdef COMM_DEBUG
  int debug = 0;
#endif /* COMM_DEBUG */
  if (!name)
    return comm_init (protocols,
#ifdef COMM_DEBUG
                  debug,
#endif /* COMM_DEBUG */
                  dev, comm);
#ifdef COMM_DEBUG
  if ((debug = !memcmp (name, "debug_", 6)))
    name += 6;
#endif /* COMM_DEBUG */
  for (proto = protocols; proto->name; proto++)
    if (!strcmp (proto->name, name))
      return comm_init (proto,
#ifdef COMM_DEBUG
                  debug,
#endif /* COMM_DEBUG */
                  dev, comm);
  fprintf (stderr, "establish: no driver for '%s' found\n"
         "Try one of the following:\n", name);
  for (proto = protocols; proto->name; proto++)
    fputs (proto->name, stderr), fputc ('\n', stderr);
#ifdef COMM_DEBUG
  fputs ("or one of them prefixed with debug_\n", stderr);
#endif /* COMM_DEBUG */
  return 0;
}


Generated by  Doxygen 1.6.0   Back to index