Revision 02c1fbdd

View differences:

nest/proto.c
499 499
    }
500 500
  cli_msg(0, "");
501 501
}
502

  
503
struct proto *
504
proto_get_named(struct symbol *sym, struct protocol *pr)
505
{
506
  struct proto *p, *q;
507

  
508
  if (sym)
509
    {
510
      if (sym->class != SYM_PROTO)
511
	cf_error("%s: Not a protocol", sym->name);
512
      p = ((struct proto_config *)sym->def)->proto;
513
      if (!p || p->proto != pr)
514
	cf_error("%s: Not a %s protocol", sym->name, pr->name);
515
    }
516
  else
517
    {
518
      p = NULL;
519
      WALK_LIST(q, proto_list)
520
	if (q->proto == pr)
521
	  {
522
	    if (p)
523
	      cf_error("There are multiple %s protocols running", pr->name);
524
	    p = q;
525
	  }
526
      if (!p)
527
	cf_error("There is no %s protocol running", pr->name);
528
    }
529
  return p;
530
}
nest/protocol.h
151 151
void *proto_new(struct proto_config *, unsigned size);
152 152
void *proto_config_new(struct protocol *, unsigned size);
153 153
void proto_show(struct symbol *, int);
154
struct proto *proto_get_named(struct symbol *, struct protocol *);
154 155

  
155 156
extern list proto_list;
156 157

  

Also available in: Unified diff