Example #1
0
bool QXmppClient::setReconnectionManager(QXmppReconnectionManager*
                                         reconnectionManager)
{
    if(!reconnectionManager)
        return false;

    if(d->reconnectionManager)
        delete d->reconnectionManager;

    d->reconnectionManager = reconnectionManager;

    bool check = connect(this, SIGNAL(connected()), d->reconnectionManager,
                         SLOT(connected()));
    Q_ASSERT(check);
    if(!check)
        return false;

    check = connect(this, SIGNAL(error(QXmppClient::Error)),
                    d->reconnectionManager, SLOT(error(QXmppClient::Error)));
    Q_ASSERT(check);
    if(!check)
        return false;

    return true;
}
Example #2
0
/* This function searches whether one of the states in the list of statepool id's
 * of a symbol exists in any other statepool id's of the same function; it also
 * verifies that all definitions of the symbol are in the same automaton.
 */
SC_FUNC void state_conflict(symbol *root)
{
  statepool *psrc,*ptgt;
  statelist *srcptr,*tgtptr;
  symbol *sym;

  assert(root!=NULL);
  for (sym=root->next; sym!=NULL; sym=sym->next) {
    if (sym->parent!=NULL || sym->ident!=iFUNCTN)
      continue;                 /* hierarchical data type or no function */
    if (sym->states==NULL)
      continue;                 /* this function has no states */
    for (srcptr=sym->states->next; srcptr!=NULL; srcptr=srcptr->next) {
      if (srcptr->id==-1)
        continue;               /* state list id -1 is a special case */
      psrc=state_getlist_ptr(srcptr->id);
      assert(psrc!=NULL);
      for (tgtptr=srcptr->next; tgtptr!=NULL; tgtptr=tgtptr->next) {
        if (tgtptr->id==-1)
          continue;             /* state list id -1 is a special case */
        ptgt=state_getlist_ptr(tgtptr->id);
        assert(ptgt!=NULL);
        if (psrc->fsa!=ptgt->fsa && strcmp(sym->name,uENTRYFUNC)!=0)
          error(83,sym->name);  /* this function is part of another machine */
        if (checkconflict(psrc,ptgt))
          error(84,sym->name);  /* state conflict */
      } /* for (tgtptr) */
    } /* for (srcptr) */
  } /* for (sym) */
}
Example #3
0
void	init_wave_meshes(t_mod *mod)
{
	t_vertx	*lm;
	int		k;
	int		i;
	int		j;

	i = 0;
	k = 0;
	if (!mod || !mod->wave)
		error(NUL, "init_wave_tools.c", "mod || mod->wave", TXT_YELLOW);
	lm = mod->wave->l_mesh;
	if (!lm)
		error(NUL, "init_wave_tools.c", "lm", TXT_YELLOW);
	while (i < (int)mod->scale)
	{
		j = 0;
		while (j < (int)mod->scale)
		{
			lm[k].x = (float)i;
			lm[k].y = (float)j;
			lm[k].z = mod->z_bot;
			lm[k].end = 0;
			k++;
			j++;
		}
		i++;
	}
}
Example #4
0
/*
 * forward_msg        - logic to forward a message which has been received and
 *                      accumulate the return codes from processes getting the
 *                      the forwarded message
 *
 * IN: forward_struct - forward_struct_t *   - holds information about message
 *                                             that needs to be forwarded to
 *                                             children processes
 * IN: header         - header_t             - header from message that came in
 *                                             needing to be forwarded.
 * RET: SLURM_SUCCESS - int
 */
extern int forward_msg(forward_struct_t *forward_struct, header_t *header)
{
	hostlist_t hl = NULL;
	hostlist_t* sp_hl;
	int hl_count = 0;

	if (!forward_struct->ret_list) {
		error("didn't get a ret_list from forward_struct");
		return SLURM_ERROR;
	}
	hl = hostlist_create(header->forward.nodelist);
	hostlist_uniq(hl);

	if (route_g_split_hostlist(
		    hl, &sp_hl, &hl_count, header->forward.tree_width)) {
		error("unable to split forward hostlist");
		hostlist_destroy(hl);
		return SLURM_ERROR;
	}

	_forward_msg_internal(NULL, sp_hl, forward_struct, header,
			      forward_struct->timeout, hl_count);

	xfree(sp_hl);
	hostlist_destroy(hl);
	return SLURM_SUCCESS;
}
Example #5
0
SEXP attribute_hidden do_sysbrowser(SEXP call, SEXP op, SEXP args, SEXP rho)
{
    SEXP rval=R_NilValue;
    RCNTXT *cptr;
    int n;

    checkArity(op, args);
    n = asInteger(CAR(args));
    if(n < 1 ) error(_("number of contexts must be positive"));

    /* first find the closest  browser context */
    cptr = R_GlobalContext;
    while (cptr != R_ToplevelContext) {
        if (cptr->callflag == CTXT_BROWSER) {
            break;
        }
        cptr = cptr->nextcontext;
    }
    /* error if not a browser context */

    if( !(cptr->callflag == CTXT_BROWSER) )
        error(_("no browser context to query"));

    switch (PRIMVAL(op)) {
    case 1: /* text */
    case 2: /* condition */
        /* first rewind to the right place if needed */
        /* note we want n>1, as we have already      */
        /* rewound to the first context              */
        if( n > 1 ) {
            while (cptr != R_ToplevelContext && n > 0 ) {
                if (cptr->callflag == CTXT_BROWSER) {
                    n--;
                    break;
                }
                cptr = cptr->nextcontext;
            }
        }
        if( !(cptr->callflag == CTXT_BROWSER) )
            error(_("not that many calls to browser are active"));

        if( PRIMVAL(op) == 1 )
            rval = CAR(cptr->promargs);
        else
            rval = CADR(cptr->promargs);
        break;
    case 3: /* turn on debugging n levels up */
        while ( (cptr != R_ToplevelContext) && n > 0 ) {
            if (cptr->callflag & CTXT_FUNCTION)
                n--;
            cptr = cptr->nextcontext;
        }
        if( !(cptr->callflag & CTXT_FUNCTION) )
            error(_("not that many functions on the call stack"));
        else
            SET_RDEBUG(cptr->cloenv, 1);
        break;
    }
    return(rval);
}
Example #6
0
SEXP realhrr_ramdbx1_setraw(SEXP ptr, SEXP veclen, SEXP memsize, SEXP vecidx, SEXP vec) {
    SEXP ans;
    int intbytes = sizeof(int);
    int intbits = sizeof(int) * 8;
    unsigned int *mem = (unsigned int*) R_ExternalPtrAddr(ptr);
    unsigned char *memb;
    unsigned char *x;
    int nup = ceil(INTEGER(veclen)[0] / (intbytes * 8.0)) * intbits;
    int m = INTEGER(memsize)[0];
    int k = INTEGER(vecidx)[0] - 1; /* vecidx is 1-based, k is 0-based */
    int i, nbytes;
    if (k >= m)
        error("vecidx too large");
    if (k < 0)
        error("vecidx must be +ve (is 1-based)");
    nbytes = nup / 8;
    ans = allocVector(INTSXP, 1);
    x = RAW(vec);
    mem += k * nup / intbits;
    memb = (unsigned char *) mem;
    if (length(vec) < nbytes)
        nbytes = length(vec);
    for (i = 0; i<nbytes; i++)
        *(memb++) = *(x++);
    INTEGER(ans)[0] = nbytes;
    return ans;
}
Example #7
0
SEXP realhrr_ramdbx1_get(SEXP ptr, SEXP veclen, SEXP memsize, SEXP vecidx) {
    int intbytes = sizeof(int);
    int intbits = sizeof(int) * 8;
    SEXP ans;
    unsigned int *mem = (unsigned int*) R_ExternalPtrAddr(ptr);
    double *x;
    int n = INTEGER(veclen)[0];
    int nup = ceil(INTEGER(veclen)[0] / (intbytes * 8.0)) * intbits;
    int m = INTEGER(memsize)[0];
    int k = INTEGER(vecidx)[0] - 1; /* vecidx is 1-based, k is 0-based */
    int i, j;
    unsigned int z;
    /* want scale st n * scale^2 = 1 */
    double scale = 1.0 / sqrt((double) n);
    if (k >= m)
        error("vecidx too large");
    if (k < 0)
        error("vecidx must be +ve (is 1-based)");
    ans = allocVector(REALSXP, n);
    x = REAL(ans);
    mem += k * nup / intbits;
    z = *mem;
    j = 0;
    for (i = 0; i<n; i++) {
        *(x++) = (z & 0x1) ? scale : -scale;
        if (++j >= intbits) {
            j = 0;
            z = *(++mem);
        } else {
            z >>= 1;
        }
    }
    return ans;
}
Example #8
0
static void DumpFD(int fd)
{
	struct timeval timeout = { 1, 0 };
	fd_set readfds;
	char buf[500];
	int len;

	FD_ZERO(&readfds);
	FD_SET(fd, &readfds);

	debug(0, "DumpFD: select on fd %d", fd);
	/* wait for something to do */
	if (select(fd + 1, &readfds, 0, 0, &timeout) == -1)
		error("select: %m");

	else if (FD_ISSET(fd, &readfds))
	{
		if ((len = read(fd, buf, sizeof buf)) == -1)
			error("Iowait: read: %m");
		else if (len == 0)
			debug(0, "eof on %d", fd);
		else
			dump(fd, "dump...", buf, len);
	}
}
Example #9
0
    // ppcoin: reset synchronized checkpoint to last hardened checkpoint
    bool ResetSyncCheckpoint()
    {
        printf("ResetSyncCheckpoint\n");
        LOCK(cs_hashSyncCheckpoint);
        const uint256& hash = Checkpoints::GetLatestHardenedCheckpoint();
        if (mapBlockIndex.count(hash) && !mapBlockIndex[hash]->IsInMainChain())
        {
            // checkpoint block accepted but not yet in main chain
            printf("ResetSyncCheckpoint: SetBestChain to hardened checkpoint %s\n", hash.ToString().c_str());
            
            CBlock block;
            if (!block.ReadFromDisk(mapBlockIndex[hash]))
                return error("ResetSyncCheckpoint: ReadFromDisk failed for hardened checkpoint %s", hash.ToString().c_str());
            CValidationState state;
            if (!SetBestChain(state, mapBlockIndex[hash]))
            {
                return error("ResetSyncCheckpoint: SetBestChain failed for hardened checkpoint %s", hash.ToString().c_str());
            }
        }
        else if(!mapBlockIndex.count(hash))
        {
            // checkpoint block not yet accepted
            hashPendingCheckpoint = hash;
            checkpointMessagePending.SetNull();
            printf("ResetSyncCheckpoint: pending for sync-checkpoint %s\n", hashPendingCheckpoint.ToString().c_str());
        }

        if (!WriteSyncCheckpoint((mapBlockIndex.count(hash) && mapBlockIndex[hash]->IsInMainChain())? hash : hashGenesisBlock))
            return error("ResetSyncCheckpoint: failed to write sync checkpoint %s", hash.ToString().c_str());
        printf("ResetSyncCheckpoint: sync-checkpoint reset to %s\n", hashSyncCheckpoint.ToString().c_str());
        return true;
    }
Example #10
0
struct node* insert(struct node *list, int k, int a) {
    if (a == 0) {
        static const char *err = "Multipliers must be nonzero";
        error(err);
    }
    if (!list) {
        struct node *foo = (struct node *) malloc(sizeof(struct node));
        foo->a = a;
        foo->k = k;
        foo->next = 0;
        return foo;
    }
    if (k > list->k) {
        struct node *foo = (struct node *) malloc(sizeof(struct node));
        foo->a = a;
        foo->k = k;
        foo->next = list;
        return foo;
    } else if (k == list->k) {
        char err[100];
        sprintf(err, "At least two monominals with power %d", k);
        error(err);
    } else {
        list->next = insert(list->next, k, a);
        return list;
    }
}
Example #11
0
SEXP attribute_hidden do_rapply(SEXP call, SEXP op, SEXP args, SEXP rho)
{
    SEXP X, FUN, classes, deflt, how, ans, names;
    int i, n;
    Rboolean replace;

    checkArity(op, args);
    X = CAR(args); args = CDR(args);
    FUN = CAR(args); args = CDR(args);
    if(!isFunction(FUN)) error(_("invalid '%s' argument"), "f");
    classes = CAR(args); args = CDR(args);
    if(!isString(classes)) error(_("invalid '%s' argument"), "classes");
    deflt = CAR(args); args = CDR(args);
    how = CAR(args);
    if(!isString(how)) error(_("invalid '%s' argument"), "how");
    replace = strcmp(CHAR(STRING_ELT(how, 0)), "replace") == 0; /* ASCII */
    n = length(X);
    if (replace) {
      PROTECT(ans = shallow_duplicate(X));
    } else {
      PROTECT(ans = allocVector(VECSXP, n));
      names = getAttrib(X, R_NamesSymbol);
      if(!isNull(names)) setAttrib(ans, R_NamesSymbol, names);
    }
    for(i = 0; i < n; i++)
	SET_VECTOR_ELT(ans, i, do_one(VECTOR_ELT(X, i), FUN, classes, deflt,
				      replace, rho));
    UNPROTECT(1);
    return ans;
}
Example #12
0
int
search_in_netrc (struct netrc_entry * entry_ptr, char * filename)
{
  int filename_alloc = 0;
  if (filename == NULL)
    {
      filename       = default_path ();
      filename_alloc = 1;
    }
  check_permission (filename);

  FILE * in;
  int encoded = suffix (".gpg", filename);
  int status;
  if (encoded) in = decode (filename);
  else         in = fopen (filename, "r");
  if (in == NULL)
    {
      error (0, 0, "failed to open file: %s", filename);
      status = NETRC_FAILURE;
    }
  else
    {
      status = parse (entry_ptr, in);
      if ((encoded ? pclose (in) : fclose (in)) != 0)
        {
          error (0, 0, "error closing netrc file");
          status = NETRC_FAILURE;
        }
    }

  if (filename_alloc) free (filename);
  return status;
}
Example #13
0
/* creates a reference to an R object on the Java side 
   1) lock down the object in R
   2) call new Rengine(eng,robj) {or any other class such as REXPReference for REngine API}
 */
REPC SEXP PushToREXP(SEXP clname, SEXP eng, SEXP engCl, SEXP robj, SEXP doConv) {
  char sig[128];
  jvalue jpar[4];
  jobject o;
  int convert = (doConv == R_NilValue) ? -1 : asInteger(doConv);
  JNIEnv *env=getJNIEnv();
  const char *cName;
  
  if (!isString(clname) || LENGTH(clname)!=1) error("invalid class name");
  if (!isString(engCl) || LENGTH(engCl)!=1) error("invalid engine class name");
  if (TYPEOF(eng)!=EXTPTRSXP) error("invalid engine object");
  R_PreserveObject(robj);
  sig[127]=0;
  cName = CHAR(STRING_ELT(clname,0));
  jpar[0].l = (jobject)EXTPTR_PTR(eng);
  jpar[1].j = (jlong) robj;
  if (convert == -1)
    snprintf(sig,127,"(L%s;J)V",CHAR(STRING_ELT(engCl,0)));
  else {
    snprintf(sig,127,"(L%s;JZ)V",CHAR(STRING_ELT(engCl,0)));
    jpar[2].z = (jboolean) convert;
  }
  o = createObject(env, cName, sig, jpar, 1);
  if (!o) error("Unable to create Java object");
  return j2SEXP(env, o, 1);
  /* ok, some thoughts on mem mgmt - j2SEXP registers a finalizer. But I believe that is ok, because the pushed reference is useless until it is passed as an argument to some Java method. And then, it will have another reference which will prevent the Java side from being collected. The R-side reference may be gone, but that's ok, because it's the Java finalizer that needs to clean up the pushed R object and for that it doesn't need the proxy object at all. This is the reason why RReleaseREXP uses EXTPTR - all the Java finalizaer has to do is to call RReleaseREXP(self). For that it can create a fresh proxy object containing the REXP. But here comes he crux - this proxy cannot again create a reference - it must be plain pass-through, so this part needs to be verified.

Note: as of REngine API the references assume protected objects and use rniRelease to clean up, so RReleaseREXP won't be called and is not needed. That is good, because RReleaseREXP assumes JRI objects whereas REngine will create REXPReference (no xp there). However, if we ever change that REXPReference assumption we will be in trouble.
 */
}
Example #14
0
int
do_test (int argc, char *argv[])
{
  char buf[1000];
  char res[1000];
  int i;

  memset (buf, '\0', sizeof (buf));
  memset (res, '\xff', sizeof (res));

  if (write (fd, buf, sizeof (buf)) != sizeof (buf))
    error (EXIT_FAILURE, errno, "during write");

  for (i = 100; i < 200; ++i)
    buf[i] = i;
  if (PWRITE (fd, buf + 100, 100, 100) != 100)
    error (EXIT_FAILURE, errno, "during %s", STRINGIFY (PWRITE));

  for (i = 450; i < 600; ++i)
    buf[i] = i;
  if (PWRITE (fd, buf + 450, 150, 450) != 150)
    error (EXIT_FAILURE, errno, "during %s", STRINGIFY (PWRITE));

  if (PREAD (fd, res, sizeof (buf) - 50, 50) != sizeof (buf) - 50)
    error (EXIT_FAILURE, errno, "during %s", STRINGIFY (PREAD));

  close (fd);
  unlink (name);

  return memcmp (buf + 50, res, sizeof (buf) - 50);
}
Example #15
0
int
setresgid(gid_t rgid, gid_t egid, gid_t sgid)
{
	int ret = 0, saved_errno;

	if (rgid != sgid) {
		errno = ENOSYS;
		return -1;
	}
#if defined(HAVE_SETREGID) && !defined(BROKEN_SETREGID)
	if (setregid(rgid, egid) < 0) {
		saved_errno = errno;
		error("setregid %u: %.100s", rgid, strerror(errno));
		errno = saved_errno;
		ret = -1;
	}
#else
	if (setegid(egid) < 0) {
		saved_errno = errno;
		error("setegid %u: %.100s", (u_int)egid, strerror(errno));
		errno = saved_errno;
		ret = -1;
	}
	if (setgid(rgid) < 0) {
		saved_errno = errno;
		error("setgid %u: %.100s", rgid, strerror(errno));
		errno = saved_errno;
		ret = -1;
	}
#endif
	return ret;
}
Example #16
0
int			check_map(t_map *map)
{
  int			y;
  int			x;

  y = 0;
  x = 0;
  while (x != map->size_column)
    {
      if (map->map[y][x] != WALL)
	return (error(MAP_WALL));
      x++;
    }
  while (y != map->size_line)
    {
      if (map->map[y][0] != WALL || map->map[y][map->size_column - 1] != WALL)
	return (error(MAP_WALL));
      y++;
    }
  x = 0;
  while (x != map->size_column)
    {
      if (map->map[y - 1][x] != WALL)
	return (error(MAP_WALL));
      x++;
    }
  return (EXIT_SUCCESS);
}
Example #17
0
int
setresuid(uid_t ruid, uid_t euid, uid_t suid)
{
	int ret = 0, saved_errno;

	if (ruid != suid) {
		errno = ENOSYS;
		return -1;
	}
#if defined(HAVE_SETREUID) && !defined(BROKEN_SETREUID)
	if (setreuid(ruid, euid) < 0) {
		saved_errno = errno;
		error("setreuid %u: %.100s", ruid, strerror(errno));
		errno = saved_errno;
		ret = -1;
	}
#else

# ifndef SETEUID_BREAKS_SETUID
	if (seteuid(euid) < 0) {
		saved_errno = errno;
		error("seteuid %u: %.100s", euid, strerror(errno));
		errno = saved_errno;
		ret = -1;
	}
# endif
	if (setuid(ruid) < 0) {
		saved_errno = errno;
		error("setuid %u: %.100s", ruid, strerror(errno));
		errno = saved_errno;
		ret = -1;
	}
#endif
	return ret;
}
Example #18
0
static int tegra_xusb_padctl_parse_dt(struct tegra_xusb_padctl *padctl,
				      const void *fdt, int node)
{
	int subnode, err;

	err = fdt_get_resource(fdt, node, "reg", 0, &padctl->regs);
	if (err < 0) {
		error("tegra-xusb-padctl: registers not found");
		return err;
	}

	fdt_for_each_subnode(fdt, subnode, node) {
		struct tegra_xusb_padctl_config *config = &padctl->config;

		err = tegra_xusb_padctl_config_parse_dt(padctl, config, fdt,
							subnode);
		if (err < 0) {
			error("tegra-xusb-padctl: failed to parse entry %s: %d",
			      config->name, err);
			continue;
		}
	}

	return 0;
}
Example #19
0
SEXP realhrr_ramdbx1_set(SEXP ptr, SEXP veclen, SEXP memsize, SEXP vecidx, SEXP vec) {
    int intbytes = sizeof(int);
    int intbits = sizeof(int) * 8;
    unsigned int *mem = (unsigned int*) R_ExternalPtrAddr(ptr);
    unsigned int hibit = (0x1 << (intbits - 1));
    double *x;
    int n = INTEGER(veclen)[0];
    int nup = ceil(INTEGER(veclen)[0] / (intbytes * 8.0)) * intbits;
    int m = INTEGER(memsize)[0];
    int k = INTEGER(vecidx)[0] - 1; /* vecidx is 1-based, k is 0-based */
    int i, j;
    unsigned int z;
    SEXP ans;
    if (k >= m)
        error("vecidx too large");
    if (k < 0)
        error("vecidx must be +ve (is 1-based)");
    x = REAL(vec);
    /* vecidx is 0-based */
    mem += k * nup / intbits;
    z = *mem;
    j = 0;
    z = 0;
    for (i = 0; i<n; i++) {
        if (*(x++) > 0)
            z |= hibit;
        j++;
        if (i == n-1) {
            z >>= (intbits - j);
            *(mem++) = z;
        } else if (j >= intbits) {
Example #20
0
bool MjpegClient::connectTo(const QString& host, int port, QString url, const QString& user, const QString& pass)
{
    if(url.isEmpty())
        url = "/";

    m_host = host;
    m_port = port > 0 ? port : 80;
    m_url = url;
    m_user = user;
    m_pass = pass;

    if(m_socket)
    {
        m_socket->abort();
        delete m_socket;
        m_socket = 0;
    }

    m_socket = new QTcpSocket(this);
    connect(m_socket, SIGNAL(readyRead()),    this,   SLOT(dataReady()));
    connect(m_socket, SIGNAL(disconnected()), this,   SLOT(lostConnection()));
    connect(m_socket, SIGNAL(disconnected()), this, SIGNAL(socketDisconnected()));
    connect(m_socket, SIGNAL(connected()),    this, SIGNAL(socketConnected()));
    connect(m_socket, SIGNAL(connected()),    this,   SLOT(connectionReady()));
    connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SIGNAL(socketError(QAbstractSocket::SocketError)));
    connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(lostConnection(QAbstractSocket::SocketError)));

    m_socket->connectToHost(host,port);
    m_socket->setReadBufferSize(1024 * 1024);

    return true;
}
Example #21
0
File: main.c Project: dzruyk/spam
void
read_file_into_buf(const char *fname, struct buf *buf)
{
    FILE *f;
    uint32_t sz;

    f = fopen(fname, "rb");
    if (f == NULL)
        error(1, "can't open %s", fname);

    sz = get_file_size(f);
    if (sz > FSIZE_MAX)
        sz = FSIZE_MAX;

    if (buf->allocated < sz) {
        buf->ptr = xrealloc(buf->ptr, sz);
        buf->allocated = sz;
    }

    buf->sz = sz;

    DEBUG(LOG_DEFAULT, "file size %d\n", buf->sz);

    if (fread_all(f, buf->ptr, buf->sz) != 0)
        error(1, "can't read file %s", fname);

    fclose(f);
}
Example #22
0
int
main (int argc, char **argv)
{
    error_t err;
    mach_port_t bootstrap;
    struct trivfs_control *fsys;

    fifo_pipe_class = stream_pipe_class;

    argp_parse (&argp, argc, argv, 0, 0, 0);

    task_get_bootstrap_port (mach_task_self (), &bootstrap);
    if (bootstrap == MACH_PORT_NULL)
        error (1, 0, "must be started as a translator");

    /* Reply to our parent */
    err = trivfs_startup (bootstrap, 0, 0, 0, 0, 0, &fsys);
    mach_port_deallocate (mach_task_self (), bootstrap);
    if (err)
        error (3, err, "Contacting parent");

    /* Launch. */
    do
    {
        ports_enable_class (fsys->protid_class);
        ports_manage_port_operations_multithread (fsys->pi.bucket,
                trivfs_demuxer,
                30*1000, 5*60*1000, 0);
    }
    while (ports_count_class (fsys->protid_class) > 0);

    return 0;
}
Example #23
0
void invokeSelector(EngineState *s, reg_t object, int selectorId,
	int k_argc, StackPtr k_argp, int argc, const reg_t *argv) {
	int i;
	int framesize = 2 + 1 * argc;
	int slc_type;
	StackPtr stackframe = k_argp + k_argc;

	stackframe[0] = make_reg(0, selectorId);  // The selector we want to call
	stackframe[1] = make_reg(0, argc); // Argument count

	slc_type = lookupSelector(s->_segMan, object, selectorId, NULL, NULL);

	if (slc_type == kSelectorNone) {
		error("Selector '%s' of object at %04x:%04x could not be invoked",
		         g_sci->getKernel()->getSelectorName(selectorId).c_str(), PRINT_REG(object));
	}
	if (slc_type == kSelectorVariable) {
		error("Attempting to invoke variable selector %s of object %04x:%04x",
			g_sci->getKernel()->getSelectorName(selectorId).c_str(), PRINT_REG(object));
	}

	for (i = 0; i < argc; i++)
		stackframe[2 + i] = argv[i]; // Write each argument

	ExecStack *xstack;

	// Now commit the actual function:
	xstack = send_selector(s, object, object, stackframe, framesize, stackframe);

	xstack->sp += argc + 2;
	xstack->fp += argc + 2;

	run_vm(s); // Start a new vm
}
Example #24
0
static int _get_select_jobinfo(select_jobinfo_t *jobinfo,
			       enum select_jobdata_type data_type, void *data)
{
	uint64_t *uint64 = (uint64_t *) data;
	uint32_t *uint32 = (uint32_t *) data;

	if (jobinfo == NULL) {
		error("cray/get_select_jobinfo: jobinfo not set");
		return SLURM_ERROR;
	}
	if (jobinfo->magic != JOBINFO_MAGIC) {
		error("cray/get_select_jobinfo: jobinfo magic bad");
		return SLURM_ERROR;
	}

	switch (data_type) {
	case SELECT_JOBDATA_RESV_ID:
		*uint32 = jobinfo->reservation_id;
		break;
	case SELECT_JOBDATA_PAGG_ID:
		*uint64 = jobinfo->confirm_cookie;
		break;
	default:
		error("cray/get_select_jobinfo: data_type %d invalid",
		      data_type);
	}

	return SLURM_SUCCESS;
}
Example #25
0
SC_FUNC int state_addlist(int *list,int count,int fsa)
{
  statepool *ptr;
  int last;

  assert(list!=NULL);
  assert(count>0);
  ptr=state_findlist(list,count,fsa,&last);
  if (ptr==NULL) {
    if ((ptr=(statepool*)malloc(sizeof(statepool)))==NULL)
      error(103);       /* insufficient memory */
    if ((ptr->states=(int*)malloc(count*sizeof(int)))==NULL) {
      free(ptr);
      error(103);       /* insufficient memory */
    } /* if */
    memcpy(ptr->states,list,count*sizeof(int));
    ptr->numstates=count;
    ptr->fsa=fsa;
    ptr->listid=last+1;
    ptr->next=statepool_tab.next;
    statepool_tab.next=ptr;
  } /* if */
  assert(ptr!=NULL);
  return ptr->listid;
}
Example #26
0
int module_init(moduleoption *opt)
{
    fitnessfunc *f;

    dummy=restype_find(RESTYPE);
    if(dummy==NULL) {
        error(_("Resource type '%s' not found"), RESTYPE);
        return -1;
    }

    fixed_tuples=malloc(sizeof(*fixed_tuples)*dat_tuplenum);
    fixed_num=0;

    if(fixed_tuples==NULL) {
        error(_("Can't allocate memory"));
        return -1;
    }

    if(handler_tup_new("fixed-" RESTYPE, handler)==NULL) return -1;

    f=fitness_new("fixed-" RESTYPE,
                  option_int(opt, "weight"),
                  option_int(opt, "mandatory"),
                  fitness);

    if(f==NULL) return -1;

    fitness_request_chromo(f, RESTYPE);

    return(0);
}
Example #27
0
void		init_wave_bases(t_mod *mod)
{
	t_base	*base;

	base = NULL;
	base = &(mod->obj->g_base);
	if (!base)
		error(NUL, "base", "init_wave_tools.c", TXT_YELLOW);
	if (!mod || !mod->wave)
		error(NUL, " mod || mod->wave", "init_wave_tools.c", TXT_YELLOW);
	if (mod->wave)
	{
		mod->wave->g_base.o.x = base->o.x;
		mod->wave->g_base.o.y = base->o.y;
		mod->wave->g_base.o.z = base->o.z;

		mod->wave->g_base.i.x = base->i.x;
		mod->wave->g_base.i.y = base->i.y;
		mod->wave->g_base.i.z = base->i.z;
		
		mod->wave->g_base.j.x = base->j.x;
		mod->wave->g_base.j.y = base->j.y;
		mod->wave->g_base.j.z = base->j.z;
		
		mod->wave->g_base.k.x = base->k.x;
		mod->wave->g_base.k.y = base->k.y;
		mod->wave->g_base.k.z = base->k.z;
	}
}
    bool SendSyncCheckpoint(uint256 hashCheckpoint)
    {
        CSyncCheckpoint checkpoint;
        checkpoint.hashCheckpoint = hashCheckpoint;
        CDataStream sMsg(SER_NETWORK, PROTOCOL_VERSION);
        sMsg << (CUnsignedSyncCheckpoint)checkpoint;
        checkpoint.vchMsg = std::vector<unsigned char>(sMsg.begin(), sMsg.end());

        if (CSyncCheckpoint::strMasterPrivKey.empty())
            return error("SendSyncCheckpoint: Checkpoint master key unavailable.");
        std::vector<unsigned char> vchPrivKey = ParseHex(CSyncCheckpoint::strMasterPrivKey);
        CKey key;
        key.SetPrivKey(CPrivKey(vchPrivKey.begin(), vchPrivKey.end())); // if key is not correct openssl may crash
        if (!key.Sign(Hash(checkpoint.vchMsg.begin(), checkpoint.vchMsg.end()), checkpoint.vchSig))
            return error("SendSyncCheckpoint: Unable to sign checkpoint, check private key?");

        if(!checkpoint.ProcessSyncCheckpoint(NULL))
        {
            printf("WARNING: SendSyncCheckpoint: Failed to process checkpoint.\n");
            return false;
        }

        // Relay checkpoint
        {
            LOCK(cs_vNodes);
            BOOST_FOREACH(CNode* pnode, vNodes)
                checkpoint.RelayTo(pnode);
        }
        return true;
    }
Example #29
0
JNIEXPORT jlong JNICALL Java_com4j_Native_getErrorInfo(
	JNIEnv* env, jclass __unused__, jlong pComObject, jlong iid1, jlong iid2) {

	MyGUID iid(iid1,iid2);

  try {
	  ISupportErrorInfoPtr p(reinterpret_cast<IUnknown*>(pComObject));
	  if(p==NULL)
		  return 0;	// not supported

	  HRESULT hr = p->InterfaceSupportsErrorInfo(iid);
	  if(FAILED(hr)) {
		  error(env,__FILE__,__LINE__,hr,"ISupportErrorInfo::InterfaceSupportsErrorInfo failed");
		  return 0;
	  }

	  if(hr!=S_OK)	return 0; // not supported

	  IErrorInfo* pError;
	  hr = GetErrorInfo(0,&pError);
	  if(FAILED(hr)) {
		  error(env,__FILE__,__LINE__,hr,"GetErrorInfo failed");
		  return 0;
	  }

	  // return the pointer
	  return reinterpret_cast<jlong>(pError);
  } catch (...) {
    // an exception occured. This might happen, if the automation server is not available due to a crash.
    return 0;
  }
  return 0;
}
Example #30
0
static inline void tractive_loop(void)
{
	static unsigned int tmp = 0;
	if( relai_state != (RELAI_PD_EN | RELAI_PD_CL | RELAI_M_EN | RELAI_M_CL | RELAI_P_EN | RELAI_P_CL | RELAI_40V | RELAI_PRECH) )
	{
		error("EMERGENC");
	}
	
	
	if( relai_volt < VCC_RELAI_MIN )
	{
		error("RELA MIN");
	}
	
	if( vcc_volt < VCC_MIN )
	{
		error("VCC  MIN");
	}
	
	// hv active
	if( (tmp = mcan_check()) )
	{
		switch(tmp)
		{
			case CAN_TRACTIVE_DISABLE: // CAN_CHARGE_ENABLE == 0x2FB
			{
				// disable hv
				standby();
			}
			break;
		}
	}
}