ipc_t mq_serve(ipcdata_t ipcdata)
{
	int queue_id;
	
	ipc_t newIpc = (ipc_t)malloc(sizeof(struct st_ipc_t));
	newIpc->status = IPCSTAT_DISCONNECTED;
	
	queue_id = init_queue();
	newIpc->status = IPCSTAT_PREPARING;
	
	if(queue_id == -1)
	{
		newIpc->status = IPCERR_MSGGETFAILED;
		return newIpc;
	}
	
	newIpc->inbox = qnew();
	newIpc->outbox = qnew();
	newIpc->stop = 0;
	newIpc->ipcdata = ipcdata;
		
	newIpc->status = IPCSTAT_SERVING;

	newIpc->thread = pthread_create(&(newIpc->thread), NULL, mq_serverLoop, newIpc);
	
	return newIpc;
}
ipc_t mq_connect(ipcdata_t ipcdata)
{
	int queue_id;
	
	ipc_t newIpc = (ipc_t)malloc(sizeof(struct st_ipc_t));
	newIpc->status = IPCSTAT_DISCONNECTED;
	
	queue_id = init_queue();
	newIpc->status = IPCSTAT_CONNECTING;
	
	if(queue_id == -1)
	{
		newIpc->status = IPCERR_MSGGETFAILED;
		return newIpc;
	}
	
	newIpc->id = ipcdata->queuedata.sendPrior;
	newIpc->inbox = qnew();
	newIpc->outbox = qnew();
	newIpc->stop = 0;
	newIpc->ipcdata = ipcdata;
	
	newIpc->status = IPCSTAT_CONNECTED;
	
	newIpc->thread = pthread_create(&(newIpc->thread), NULL, mq_clientLoop, newIpc);
	
	return newIpc;
}
Exemple #3
0
/**
 * @function tryStep
 */
JG_RRT::StepResult JG_RRT::tryStep( const Eigen::VectorXd &qtry, int NNidx )
{
    Eigen::VectorXd qnear( ndim );
    Eigen::VectorXd qnew( ndim );
    qnear = configVector[NNidx];

    Eigen::VectorXd diff = ( qtry - qnear );
    double edist = diff.norm();

    // If the new node is nearer than the stepSize, don't add it

    if( edist < stepSize )
    {
        return STEP_REACHED;
    }

    // Scale it in order to add it
    double scale = stepSize / edist;
    for( int i = 0; i < ndim; i++ )
    {
        qnew[i] = qnear[i] + diff[i]*scale;
    }

    if( !checkCollisions(qnew) )
    {
        addNode( qnew, NNidx );
        return STEP_PROGRESS;
    }
    else
    {
        return STEP_COLLISION;
    }
}
Exemple #4
0
//--------------------------------------------------------------------------
// Make a copy
place_t *ida_export class_place_t__clone(const cp_t *ths)
{
	class_place_t *p = qnew(class_place_t);
	if ( p == NULL )
		nomem("class_place");
	memcpy(p, ths, sizeof(*ths));
	return p;
}
Exemple #5
0
/*
 * NAME:	hls->main()
 * DESCRIPTION:	implement hls command
 */
int hls_main(int argc, char *argv[])
{
  hfsvol *vol;
  int fargc, i;
  char **fargv = 0;
  int result = 0;
  int flags, options, width;
  char *ptr;
  darray *dirs, *files;

  options = T_MOD | S_NAME;

  if (isatty(STDOUT_FILENO))
    {
      options |= F_MANY;
      flags    = HLS_QMARK_CTRL;
    }
  else
    {
      options |= F_ONE;
      flags    = 0;
    }

#ifdef __EMX__
  if (strcmp(bargv0, "hdir") == 0 || strcmp(bargv0, "hdir.exe") == 0)
#else
  if (strcmp(bargv0, "hdir") == 0)
#endif
    options = (options & ~F_MASK) | F_LONG;

  width = 80;
  ptr = getenv("COLUMNS");
  if (ptr)
    width = atoi(ptr);

# ifdef TIOCGWINSZ
  {
    struct winsize ws;

    if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) != -1 &&
	ws.ws_col != 0)
      width = ws.ws_col;
  }
# endif

  while (1)
    {
      int opt;

      opt = getopt(argc, argv, "1abcdfilmqrstxw:CFNQRSU");
      if (opt == EOF)
	break;

      switch (opt)
	{
	case '?':
	  return usage();

	case '1':
	  options = (options & ~F_MASK) | F_ONE;
	  break;

	case 'a':
	  flags |= HLS_ALL_FILES;
	  break;

	case 'b':
	  flags |= HLS_ESCAPE;
	  flags &= ~HLS_QMARK_CTRL;
	  break;

	case 'c':
	  options = (options & ~(T_MASK | S_MASK)) | T_CREATE | S_TIME;
	  break;

	case 'd':
	  flags |= HLS_IMMEDIATE_DIRS;
	  break;

	case 'f':
	  flags |= HLS_ALL_FILES;
	  flags &= ~HLS_SIZE;
	  options &= ~S_MASK;
	  if ((options & F_MASK) == F_LONG)
	    options = (options & ~F_MASK) |
	      (isatty(STDOUT_FILENO) ? F_MANY : F_ONE);
	  break;

	case 'i':
	  flags |= HLS_CATIDS;
	  break;

	case 'l':
	  options = (options & ~F_MASK) | F_LONG;
	  break;

	case 'm':
	  options = (options & ~F_MASK) | F_COMMAS;
	  break;

	case 'q':
	  flags |= HLS_QMARK_CTRL;
	  flags &= ~HLS_ESCAPE;
	  break;

	case 'r':
	  flags |= HLS_REVERSE;
	  break;

	case 's':
	  flags |= HLS_SIZE;
	  break;

	case 't':
	  options = (options & ~S_MASK) | S_TIME;
	  break;

	case 'x':
	  options = (options & ~F_MASK) | F_HORIZ;
	  break;

	case 'w':
	  width = atoi(optarg);
	  break;

	case 'C':
	  options = (options & ~F_MASK) | F_MANY;
	  break;

	case 'F':
	  flags |= HLS_INDICATOR;
	  break;

	case 'N':
	  flags &= ~(HLS_ESCAPE | HLS_QMARK_CTRL);
	  break;

	case 'Q':
	  flags |= HLS_QUOTE | HLS_ESCAPE;
	  flags &= ~HLS_QMARK_CTRL;
	  break;

	case 'R':
	  flags |= HLS_RECURSIVE;
	  break;

	case 'S':
	  options = (options & ~S_MASK) | S_SIZE;
	  break;

	case 'U':
	  options &= ~S_MASK;
	  break;
	}
    }

  vol = hfsutil_remount(hcwd_getvol(-1), HFS_MODE_RDONLY);
  if (vol == 0)
    return 1;

  fargv = hfsutil_glob(vol, argc - optind, &argv[optind], &fargc, &result);

  dirs  = qnew();
  files = qnew();
  if (result == 0 && (dirs == 0 || files == 0))
    {
      fprintf(stderr, "%s: not enough memory\n", argv0);
      result = 1;
    }

  if (result == 0)
    {
      if (fargc == 0)
	{
	  if (queuepath(vol, ":", dirs, files, flags) == -1)
	    result = 1;
	}
      else
	{
	  for (i = 0; i < fargc; ++i)
	    {
	      if (queuepath(vol, fargv[i], dirs, files, flags) == -1)
		{
		  result = 1;
		  break;
		}
	    }
	}
    }

  if (result == 0 && process(vol, dirs, files, flags, options, width) == -1)
    result = 1;

  if (files)
    qfree(files);
  if (dirs)
    qfree(dirs);

  hfsutil_unmount(vol, &result);

  if (fargv)
    free(fargv);

  return result;
}