//---------------------------------------------------------------------
	Page::Page(PageID pageID, PagedWorldSection* parent)
		: mID(pageID)
		, mParent(parent)
		, mDeferredProcessInProgress(false)
		, mModified(false)
		, mDebugNode(0)
	{
		WorkQueue* wq = Root::getSingleton().getWorkQueue();
		mWorkQueueChannel = wq->getChannel("Ogre/Page");
		wq->addRequestHandler(mWorkQueueChannel, this);
		wq->addResponseHandler(mWorkQueueChannel, this);
		touch();
	}
Exemple #2
0
void camera::set(GLfloat x, GLfloat y, GLfloat z, GLfloat lookatX, GLfloat lookatY, GLfloat lookatZ, bool t){
	setPos(x, y, z);
	toPos.lookatX = lookatX;
	toPos.lookatY = lookatY;
	toPos.lookatZ = lookatZ;
	if (framesLeft <= 0) {
		currentPos.lookatX = lookatX;
		currentPos.lookatY = lookatY;
		currentPos.lookatZ = lookatZ;
	}
	if (t) touch();
}
Exemple #3
0
void camera::setPos(GLfloat x, GLfloat y, GLfloat z, bool t){
	toPos.x = x;
	toPos.y = y;
	toPos.z = z;
	if (framesLeft <= 0) {
		currentPos.x = x;
		currentPos.y = y;
		currentPos.z = z;
	}
	changed = true;
	if (t) touch();
}
Exemple #4
0
 void set(int key, int value) {
     auto it = cache.find(key);
     if (it != cache.end()) touch(it);
     else {
         if (cache.size() == _capacity) {
             cache.erase(used.back());
             used.pop_back();
         }
         used.push_front(key);
     }
     cache[key] = {value, used.begin()};
 }
Exemple #5
0
    boost::optional<value_type> find( const key_type& key)
	{
		map_iterator it( items_.find( key));
		
		if( it != items_.end())
		{
			touch( it);
			return it->second;
		}
	
		return boost::optional<value_type>();
	}
Exemple #6
0
    void insert( const key_type& k, const value_type& v)
	{
		map_iterator it( items_.find( key));
		
		if( it != items_.end())
			touch( it);
		else
		{
			map_iterator result( items_.insert( map_type::value_type( key, v)));
			use_list_.push_front( result);
		}
	}
Exemple #7
0
void camera::setPos(cameraPos position, bool t){
	toPos.x = position.x;
	toPos.y = position.y;
	toPos.z = position.z;
	if (framesLeft <= 0) {
		currentPos.x = position.x;
		currentPos.y = position.y;
		currentPos.z = position.z;
	}
	changed = true;
	if (t) touch();
}
Exemple #8
0
int main(int argc, char *argv[])
{
	struct sigaction action;
	memset(&action, 0, sizeof(action));
	action.sa_handler = sigterm;
	sigaction(SIGTERM, &action, NULL);
	sigaction(SIGINT, &action, NULL);

	int verbose = 0;
	for (int i = 1; i < argc; i++) {
		if (strcmp(argv[i], "-v") == 0) {
			verbose = 1;
		}
	}

	size_t total = 0;
	unsigned long attempted = 0;
	unsigned long loaded = 0;

	char line[linebuf];
	while (!end && fgets(line, linebuf, stdin)) {
		/* \n -> 0 */
		line[strlen(line) - 1] = 0;
		size_t size;
		if (preload(line, &size) == 0) {
			if (verbose) {
				fprintf(stderr, "Preloaded '%s'\n", line);
			}
			total += size;
			loaded++;
		}
		attempted++;
		/*
		 * In case the active IO scheduler doesn't already make us yield
		 * to other processes
		 */
		usleep(1000);
	}

	touch();

	fprintf(stderr, "Done, preloaded %lu/%lu files (%lluMB)\n", loaded, attempted, (long long unsigned int) (total >> 20));

	while (!end) {
		sleep(-1);
	}

	fprintf(stderr, "Unloading\n");
	unload();
	fprintf(stderr, "Unloaded\n");

	return 0;
}
static void experiment1(char *path) {
  touch(path);

  int fd = open(path, O_RDONLY);
  if (rename(path, "hoge") < 0) {
    perror(path);
    printf("ex1: failed to rename\n");
  } else {
    close(fd);
    printf("ex1: succeed\n");
  }
}
Exemple #10
0
void perceptron::train(const common::sfv_t& sfv, const std::string& label) {
  check_touchable(label);

  labels_.get_model()->increment(label);

  std::string predicted_label = classify(sfv);
  if (label == predicted_label) {
    return;
  }
  update_weight(sfv, 1.0, label, predicted_label);
  touch(label);
}
static void experiment2(char *path) {
  touch(path);

  int fd = open(path, O_RDONLY);
  if (unlink(path) < 0) {
    perror(path);
    printf("ex2: failed to unlink\n");
  } else {
    close(fd);
    printf("ex2: succeed\n");
  }
}
Exemple #12
0
static void walk_social_type(struct social_type *s)
{

    if (!s)
        return;
    touch( s->name );
    touch(s->char_no_arg);
    touch(s->others_no_arg);
    touch(s->char_found);
    touch(s->others_found);
    touch(s->vict_found);
    touch(s->char_auto);
    touch(s->others_auto);
}
Exemple #13
0
Fichier : run.c Projet : 8l/cmm
static void
sched(void)
{
	char *flags;
	Job *j;
	Bufblock *buf;
	int slot;
	Node *n;
	Envy *e;

	if(jobs == 0){
		usage();
		return;
	}
	j = jobs;
	jobs = j->next;
	if(DEBUG(D_EXEC))
		printf("firing up job for target %s\n", wtos(j->t, ' '));
	slot = nextslot();
	events[slot].job = j;
	buf = newbuf();
	e = buildenv(j, slot);
	shprint(j->r->recipe, e, buf);
	if(!tflag && (nflag || !(j->r->attr&QUIET)))
		Bwrite(&bout, buf->start, (long)strlen(buf->start));
	freebuf(buf);
	if(nflag||tflag){
		for(n = j->n; n; n = n->next){
			if(tflag){
				if(!(n->flags&VIRTUAL))
					touch(n->name);
				else if(explain)
					Bprint(&bout, "no touch of virtual '%s'\n", n->name);
			}
			n->time = time((long *)0);
			MADESET(n, MADE);
		}
	} else {
		if(DEBUG(D_EXEC))
			printf("recipe='%s'", j->r->recipe);/**/
		Bflush(&bout);
		if(j->r->attr&NOMINUSE)
			flags = 0;
		else
			flags = "-e";
		events[slot].pid = execsh(flags, j->r->recipe, 0, e);
		usage();
		nrunning++;
		if(DEBUG(D_EXEC))
			printf("pid for target %s = %d\n", wtos(j->t, ' '), events[slot].pid);
	}
}
Exemple #14
0
/*
 * Save/copy the indicated messages at the end of the passed file name.
 * If mark is true, mark the message "saved."
 */
int
save1(char str[], int mark, const char *cmd, struct ignoretab *ignore)
{
	struct message *mp;
	char *file;
	const char *disp;
	int f, *msgvec, *ip;
	FILE *obuf;

	msgvec = (int *)salloc((msgCount + 2) * sizeof(*msgvec));
	if ((file = snarf(str, &f)) == NULL)
		return (1);
	if (!f) {
		*msgvec = first(0, MMNORM);
		if (*msgvec == 0) {
			printf("No messages to %s.\n", cmd);
			return (1);
		}
		msgvec[1] = 0;
	}
	if (f && getmsglist(str, msgvec, 0) < 0)
		return (1);
	if ((file = expand(file)) == NULL)
		return (1);
	printf("\"%s\" ", file);
	(void)fflush(stdout);
	if (access(file, 0) >= 0)
		disp = "[Appended]";
	else
		disp = "[New file]";
	if ((obuf = Fopen(file, "a")) == NULL) {
		warn((char *)NULL);
		return (1);
	}
	for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) {
		mp = &message[*ip - 1];
		touch(mp);
		if (sendmessage(mp, obuf, ignore, NULL) < 0) {
			warnx("%s", file);
			(void)Fclose(obuf);
			return (1);
		}
		if (mark)
			mp->m_flag |= MSAVED;
	}
	(void)fflush(obuf);
	if (ferror(obuf))
		warn("%s", file);
	(void)Fclose(obuf);
	printf("%s\n", disp);
	return (0);
}
Exemple #15
0
char *mv(int argc, char**argv,char *output){
    char **arg = (char **) malloc(sizeof(char*)*4);
    arg[0] = argv[0];
    arg[1] = argv[1];
    arg[2] = argv[3];
    char *contendio = cat(3, arg);
    rm(3, arg, output);
    if (!strcmp(output, "")){
        arg[1] = argv[2];
        touch(2, arg, contendio, output);
    }
    return "";
}
void EditableMap::resize_map(int new_width, int new_height) {
    touch();

    /* create new map/decoration */
    short **new_map = create_new_array(map, new_width, new_height);
    short **new_decoration = create_new_array(decoration, new_width, new_height);
    cleanup();
    map = new_map;
    decoration = new_decoration;

    width = new_width;
    height = new_height;
}
Exemple #17
0
void net::nstream_proactor::conn_nstream::read()
{
	touch();
	buffer buf;
	int n_bytes = N->recv(buf);
	if(n_bytes <= 0){
		//assume connection reset (may not be)
		error = connection_reset_error;
		Conn_Container.remove(_info->conn_ID);
	}else{
		Dispatcher.recv(recv_event(_info, buf));
	}
}
Exemple #18
0
//-----------------------------------------------------------------------------
// LLJoint()
// Class Constructor
//-----------------------------------------------------------------------------
LLJoint::LLJoint(const std::string &name, LLJoint *parent) :
	mJointNum(0)
{
	init();
	mUpdateXform = FALSE;

	setName(name);
	if (parent)
	{
		parent->addChild( this );
	}
	touch();
}
Exemple #19
0
static void set_war(fdja_value *node, char *key, fdja_value *val)
{
  fdja_value *par = parent(node);

  if (par == NULL) return;

  fdja_value *wars = fdja_l(par, "wars");
  if (wars == NULL) wars = fdja_set(par, "wars", fdja_object_malloc());

  fdja_set(wars, key, val);

  touch(node);
}
Exemple #20
0
const char *http_request_line(int fd, char *reqpath, char *env, size_t *env_len)
{
    static char buf[8192];      /* static variables are not on the stack */
    char *sp1, *sp2, *qp, *envp = env;

    /* For lab 2: don't remove this line. */
    touch("http_request_line");

    if (http_read_line(fd, buf, sizeof(buf)) < 0)
        return "Socket IO error";

    /* Parse request like "GET /foo.html HTTP/1.0" */
    sp1 = strchr(buf, ' ');
    if (!sp1)
        return "Cannot parse HTTP request (1)";
    *sp1 = '\0';
    sp1++;
    if (*sp1 != '/')
        return "Bad request path";

    sp2 = strchr(sp1, ' ');
    if (!sp2)
        return "Cannot parse HTTP request (2)";
    *sp2 = '\0';
    sp2++;

    /* We only support GET and POST requests */
    if (strcmp(buf, "GET") && strcmp(buf, "POST"))
        return "Unsupported request (not GET or POST)";

    envp += sprintf(envp, "REQUEST_METHOD=%s", buf) + 1;
    envp += sprintf(envp, "SERVER_PROTOCOL=%s", sp2) + 1;

    /* parse out query string, e.g. "foo.py?user=bob" */
    if ((qp = strchr(sp1, '?')))
    {
        *qp = '\0';
        envp += sprintf(envp, "QUERY_STRING=%s", qp + 1) + 1;
    }

    /* decode URL escape sequences in the requested path into reqpath */
    url_decode(reqpath, sp1);

    envp += sprintf(envp, "REQUEST_URI=%s", reqpath) + 1;

    envp += sprintf(envp, "SERVER_NAME=zoobar.org") + 1;

    *envp = 0;
    *env_len = envp - env + 1;
    return NULL;
}
Exemple #21
0
static int
verify(char* path, char* old, char* processor, int must)
{
	char*	ns;
	char*	os;
	int	nz;
	int	oz;
	int	r;
	Sfio_t*	nf;
	Sfio_t*	of;

	r = 0;
	if (nf = sfopen(NiL, path, "r"))
	{
		if ((ns = sfgetr(nf, '\n', 1)) && (nz = sfvalue(nf) - 1) > 0)
		{
			ns += nz;
			if ((oz = strlen(processor)) <= nz && !strcmp(processor, ns - oz))
				r = 1;
			else
				error(2, "%s: %s clashes with %s", path, processor, ns - nz);
		}
		if (r && old && sfseek(nf, 0L, 0) == 0 && (of = sfopen(NiL, old, "r")))
		{
			for (;;)
			{
				ns = sfreserve(nf, 0, 0);
				nz = sfvalue(nf);
				os = sfreserve(of, 0, 0);
				oz = sfvalue(nf);
				if (nz <= 0 || oz <= 0)
					break;
				if (nz > oz)
					nz = oz;
				if (memcmp(ns, os, nz))
					break;
				nz = sfread(nf, ns, nz);
				oz = sfread(of, os, nz);
				if (!nz || !oz)
					break;
			}
			sfclose(of);
			if (!nz && !oz && !touch(old, (time_t)-1, (time_t)-1, 0))
				r = 0;
		}
		sfclose(nf);
	}
	else if (must)
		error(ERROR_SYSTEM|2, "%s: cannot read", path);
	return r;
}
Exemple #22
0
//-----------------------------------------------------------------------------
// LLJoint()
// Class Constructor
//-----------------------------------------------------------------------------
LLJoint::LLJoint()
{
	mName = "unnamed";
	mParent = NULL;
	mXform.setScaleChildOffset(TRUE);
	mXform.setScale(LLVector3(1.0f, 1.0f, 1.0f));
	mDirtyFlags = MATRIX_DIRTY | ROTATION_DIRTY | POSITION_DIRTY;
	mUpdateXform = TRUE;
	mJointNum = -1;
	touch();
#if MESH_ENABLED
	mResetAfterRestoreOldXform = false;
#endif //MESH_ENABLED
}
Exemple #23
0
int
ranlib(char **argv)
{
	int rv;

	archive = *argv;
	do {
		rv = options & AR_T? touch() : do_ranlib();
		if (!rv && *argv)
			archive = *argv;
	} while (rv && *argv++);

	return rv;
}
Exemple #24
0
static void push_error_value(fdja_value *node, fdja_value *error)
{
  fdja_value *errors = fdja_l(node, "errors");
  if (errors == NULL) errors = fdja_set(node, "errors", fdja_array_malloc());

  if (fdja_l(error, "ctime") == NULL)
  {
    fdja_set(error, "ctime", fdja_sym(flu_tstamp(NULL, 1, 'u')));
  }

  fdja_push(errors, error);

  touch(node);
}
//-----------------------------------------------------------------------------
// LLJoint()
// Class Constructor
//-----------------------------------------------------------------------------
LLJoint::LLJoint(const std::string &name, LLJoint *parent) :
	mJointNum(0)
{
	init();
	mUpdateXform = FALSE;
	// *TODO: mResetAfterRestoreOldXform is not initialized!!!

	setName(name);
	if (parent)
	{
		parent->addChild( this );
	}
	touch();
}
//*********************************************************************************************************
void CDisplayerVisualActivitySequence::setActive(bool active)
{
	//H_AUTO(R2_CDisplayerVisualActivitySequence_setActive)
	if (active == _Active) return;
	if (!active)
	{
		clear();
	}
	else
	{
		touch();
	}
	_Active = active;
}
Exemple #27
0
void Term__source_location(VM* vm)
{
    Term* t = as_term_ref(vm->input(0));
    if (t == NULL)
        return vm->throw_str("NULL reference");

    Value* out = vm->output();
    touch(out);
    set_list(out, 4);
    set_int(list_get(out, 0), t->sourceLoc.col);
    set_int(list_get(out, 1), t->sourceLoc.line);
    set_int(list_get(out, 2), t->sourceLoc.colEnd);
    set_int(list_get(out, 3), t->sourceLoc.lineEnd);
}
Exemple #28
0
/*
 * Undelete the indicated messages.
 */
int
undeletecmd(void *v)
{
	int *msgvec = v;
	int *ip;
	struct message *mp;

	for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) {
		mp = &message[*ip - 1];
		touch(mp);
		dot = mp;
		mp->m_flag &= ~MDELETED;
	}
	return(0);
}
Exemple #29
0
char *
getNull(void)
{
#ifdef WIN32
	static char *fname = 0;

	if (fname) return (fname); /* already created */
	/*
	 * Since "nul" only works for write operation,
	 * for read, we have to make our own null file
	 */
	fname = aprintf("%s/BitKeeper_nul", TMP_PATH);
	unless (exists(fname)) {
		touch(fname, 0666);
	} else {
	//-----------------------------------------------------------------------
	void PagingLandScapePage::preloadInBackground()
	{
		touch();

		if (mPageState == STATE_INITED) {
			// set new state
			mPageState = STATE_PRELOADING;

			S_LOG_VERBOSE("Preloading PagingLandScapePage at (" << mTableX << ", " << mTableZ << ")");
			mPageMgr.getSceneManager()->getData2DManager()->load(mTableX, mTableZ);

		} else {
			S_LOG_WARNING("PagingLandScapePage at (" << mTableX << ", " << mTableZ << ") already preloaded (or not inited), ignoring request");
		}
	}