Esempio n. 1
0
static bool detect(pony_ctx_t* ctx, detector_t* d, view_t* view)
{
  assert(view->perceived == NULL);

  scan_grey(d, view, 0);
  int count = scan_white(view);
  assert(count >= 0);

  if(count == 0)
    return false;

  d->detected++;

  perceived_t* per = (perceived_t*)POOL_ALLOC(perceived_t);
  per->token = d->next_token++;
  per->ack = 0;
  per->last_conf = HASHMAP_BEGIN;
  ponyint_viewmap_init(&per->map, count);
  ponyint_perceivedmap_put(&d->perceived, per);

  int count2 = collect_white(per, view, 0);

  (void)count2;
  assert(count2 == count);
  assert(ponyint_viewmap_size(&per->map) == (size_t)count);

  send_conf(ctx, d, per);
  return true;
}
Esempio n. 2
0
struct ttyent *getttyent(void)
/* Read one entry from the ttytab file. */
{
	/* Open the file if not yet open. */
	if (ttfd < 0 && setttyent() < 0) return nil;

	/* Look for a line with something on it. */
	for (;;) {
		if (!getline()) return nil;	/* EOF or corrupt. */

		if ((entry.ty_name= scan_white(0)) == nil) continue;
		entry.ty_type= scan_white(0);
		entry.ty_getty= scan_quoted();
		entry.ty_init= scan_quoted();

		return &entry;
	}
}