Ejemplo n.º 1
0
void list_links(Parse_info * pi, Parse_set * set, int index) {
     Parse_choice *pc;
     int n;

     if (set == NULL || set->first == NULL) return;
     for (pc = set->first; pc != NULL; pc = pc->next) {
	  n = pc->set[0]->count * pc->set[1]->count;
	  if (index < n) break;
	  index -= n;
     }
     assert(pc != NULL, "walked off the end in list_links");
     issue_links_for_choice(pi, pc);
     list_links(pi, pc->set[0], index % pc->set[0]->count);
     list_links(pi, pc->set[1], index / pc->set[0]->count);
}
Ejemplo n.º 2
0
/**
 * Generate the list of all links of the index'th parsing of the
 * sentence.  For this to work, you must have already called parse, and
 * already built the whole_set.
 */
void extract_links(Linkage lkg, Parse_info pi)
{
    int index = lkg->lifo.index;
    if (index < 0) {
        pi->rand_state = index;
        list_random_links(lkg, pi, pi->parse_set);
    }
    else {
        list_links(lkg, pi->parse_set, index);
    }
}
Ejemplo n.º 3
0
/**
 * Generate the list of all links of the index'th parsing of the
 * sentence.  For this to work, you must have already called parse, and
 * already built the whole_set.
 */
void extract_links(int index, int cost, Parse_info pi)
{
	initialize_links(pi);
	pi->rand_state = index;
	if (index < 0) {
		list_random_links(pi, pi->parse_set);
	}
	else {
		list_links(pi, pi->parse_set, index);
	}
}
Ejemplo n.º 4
0
void extract_links(int index, int cost, Parse_info * pi) {
/* Generate the list of all links of the indexth parsing of the
   sentence.  For this to work, you must have already called parse, and
   already built the whole_set. */
    initialize_links(pi);
    if (index < 0) {
	my_random_initialize(index);
	list_random_links(pi, pi->parse_set);
	my_random_finalize();
    }
    else {
	list_links(pi, pi->parse_set, index);
    }
}
Ejemplo n.º 5
0
Archivo: fuse.c Proyecto: spolu/waitfs
static int waitfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
			  off_t offset, struct fuse_file_info *fi)
{ 
  sid_t sid = 0;

  sid_t *sessions = NULL;
  sid_t *links = NULL;

  char *token, *brkt, *path_copy = NULL;

  char str[128];

  (void) offset;
  (void) fi;

  printf ("waitfs_readdir\n");

  path_copy = (char *) malloc (strlen (path) + 1);
  if (path_copy == NULL)
    goto error;

  strncpy (path_copy, path, strlen (path));

  for (token = strtok_r(path_copy, "/", &brkt);
       token;
       token = strtok_r(NULL, "/", &brkt))
    {
      if (sid == 0)
	sid = atoi (token);
      else
	goto error;
    }
  
  filler(buf, ".", NULL, 0);
  filler(buf, "..", NULL, 0);
  
  if (sid == 0) 
    {      
      sessions = list_sessions ();
      
      if (sessions != NULL) {
	for (int i = 0; sessions[i] != 0; i ++) {
	  snprintf (str, 128, "%d", sessions[i]);
	  filler (buf, str, NULL, 0);
	}
      }
    }
  
  else // list links
    {
      links = list_links (sid);

      if (links != NULL) {
	for (int i = 0; links[i] != 0; i ++) {
	  snprintf (str, 128, "%d", links[i]);
	  filler (buf, str, NULL, 0);
	}
      }
    }
  
  return 0;

 error:
  if (path_copy != NULL)
    free (path_copy);
  return -ENOENT;
}