Esempio n. 1
0
static int
flash_char_write(struct inode *inode, struct file *filp,
		 const char *buf, int count)
{
	int wlen;
	struct flashpartition *part = (struct flashpartition *)filp->private_data;

	FDEBUG(printk("flash_char_write\n"));
	wlen = flash_safe_write(part,
				(unsigned char *)part->start + filp->f_pos,
				(unsigned char *)buf, count);

	/* advance file position pointer */

	if(wlen >= 0)
		filp->f_pos += wlen;

	return wlen;
}
void OSGQGLManagedWidget::wheelEvent ( QWheelEvent* we)
{
    int button;

     FDEBUG (("OSGQGLManagedWidget::wheelEvent()\n"));

    if(we->delta() > 0)
    {
        button = SimpleSceneManager::MouseUp;
    }
    else
    {
        button = SimpleSceneManager::MouseDown;
    }

    _manager->mouseButtonPress(button, we->x(), we->y());

    paintGL();
}
Esempio n. 3
0
int main(int argc, char *argv[]) {
    int socket;
    // 서버의 주소와 포트 번호는 입력받지 않고 기본값만 사용하도록 합니다.
    char address[] = "localhost";
    int portno = 10000;

    // shell 모드인지를 판별합니다.
    if (argc == 2 && !strcmp(argv[1], "shell") ) {
        // shell 모드로 소켓을 엽니다.
        socket = init(portno, address, true);
        FDEBUG(("shell mode enabled.\n"));
        doShellMode(socket);
    } else {
        // 일반 모드로 소켓을 엽니다.
        socket = init(portno, address, false);
        doNormalMode(socket);
    }

    return 0;
}
OSG_USING_NAMESPACE

/***************************************************************************\
 *                           Instance methods                              *
\***************************************************************************/

/*-------------------------------------------------------------------------*\
 -  public                                                                 -
\*-------------------------------------------------------------------------*/

/*------------- constructors & destructors --------------------------------*/

/*! Constructor
*/

OSGQGLManagedWidget::OSGQGLManagedWidget ( QWidget *parent, 
                                           const char *name,
                                           SimpleSceneManager *manager ) 
  : Inherited(parent,name)
{
    FDEBUG(("OSGQGLManagedWidget constructor called\n"));

    OSG::QTWindowPtr qtWinPtr = OSG::QTWindow::create();

    OSG::beginEditCP(qtWinPtr);
    {
        qtWinPtr->setGlWidget(this);
    }
    OSG::endEditCP(qtWinPtr);

    if(manager != NULL)
    {
        _manager = manager;
    }
    else
    {
        _manager = new SimpleSceneManager; // mem leak here
    }
  
    _manager->setWindow ( qtWinPtr );
}
void ChunkMaterial::rebuildState(void)
{
    FDEBUG(("ChunkMat::rebuild state\n"));

    if(_pState != NULL)
    {
        _pState->clearChunks();
    }
    else
    {
        _pState = State::createLocal();

        _pState->setDefaultSortKey(this->getId());

    }

    _pState->setCoreGLChunkLimit(_sfCoreGLChunkLimit.getValue());
    _pState->setTransparencyMode(_sfTransparencyMode.getValue());

    addChunks(_pState);
}
void SharedObjectHandler::terminate(void)
{
    FDEBUG(("terminate SharedObjectHandler\n"));

    //this->dump();

    SharedObjectMapIt soIt  = _mSharedObjects.begin();
    SharedObjectMapIt soEnd = _mSharedObjects.end  ();

    while(soIt != soEnd)
    {
        soIt->second->close();

        OSG::subRef(soIt->second);

        ++soIt;
    }

    _the = NULL;
    delete this;
}
ImageFileHandlerBase::ImageBlockAccessorPtr 
    ImageFileHandlerBase::open(const Char8       *fileName,
                               const Char8       *mimeType)
{
    ImageBlockAccessorPtr returnValue;
    std::string           fullFilePath;

    if(_pPathHandler != NULL)
    {
        fullFilePath = _pPathHandler->findFile(fileName);
    }
    else
    {
        fullFilePath = fileName;
    }

    if(fullFilePath.empty())
    {
        SWARNING << "couldn't find image file " << fileName << std::endl;
        return returnValue;
    }
    
    ImageFileType *type = getFileType(mimeType, fullFilePath.c_str(), true);
    
    if(type != NULL)
    {
        FDEBUG(("try to image read %s as %s\n", 
                fullFilePath.c_str(), 
                type->getMimeType()));
        
        returnValue = type->open(fullFilePath.c_str());
    }
    else
    {
        SWARNING << "could not read " << fullFilePath
                 << "; unknown image format" << std::endl;
    }

    return returnValue;
}
Esempio n. 8
0
void filter_setup_super_ops(struct filter_fs *cache, struct super_operations *cache_sops, struct super_operations *filter_sops)
{
        /* Get ptr to the shared struct snapfs_ops structure. */
        struct filter_ops *props = &cache->o_fops;
        /* Get ptr to the shared struct cache_ops structure. */
        struct cache_ops *caops = &cache->o_caops;

        FENTRY;

        if ( cache->o_flags & FILTER_DID_SUPER_OPS ) {
                FEXIT;
                return;
        }
        cache->o_flags |= FILTER_DID_SUPER_OPS;

        /* Set the cache superblock operations to point to the
           superblock operations of the underlying file system.  */
        caops->cache_sops = cache_sops;

        /*
         * Copy the cache (real fs) superblock ops to the "filter"
         * superblock ops as defaults. Some will be changed below
         */
        memcpy(&props->filter_sops, cache_sops, sizeof(*cache_sops));

        /* 'put_super' unconditionally is that of filter */
        if (filter_sops->put_super) { 
                props->filter_sops.put_super = filter_sops->put_super;
        }

        if (cache_sops->read_inode) {
                props->filter_sops.read_inode = filter_sops->read_inode;
                FDEBUG(D_INODE, "setting filter_read_inode, cache_ops %p, cache %p, ri at %p\n",
                      cache, cache, props->filter_sops.read_inode);
        }

        if (cache_sops->remount_fs)
                props->filter_sops.remount_fs = filter_sops->remount_fs;
        FEXIT;
}
Esempio n. 9
0
void NFIOBase::skipFCFields(void)
{
    // skip all fields
    std::string fieldName;
    std::string fieldType;
    UInt32 size;
    while(true)
    {
        _in->getValue(fieldName);
        // check for fieldcontainer end marker.
        if(fieldName.empty())
        {
            FDEBUG(("NFIOBase::skipFCFields: found fieldcontainer end marker.\n"));
            break;
        }
        
        _in->getValue(fieldType);
        _in->getValue(size);

        _in->skip(size);
    }
}
Esempio n. 10
0
/* find the cache for this FS */
struct filter_fs *filter_get_filter_fs(const char *cache_type)
{
        struct filter_fs *ops = NULL;
        FENTRY;

        if ( strlen(cache_type) == strlen("ext2") &&
             memcmp(cache_type, "ext2", strlen("ext2")) == 0 ) {
                ops = &filter_oppar[FILTER_FS_EXT2];
                FDEBUG(D_SUPER, "ops at %p\n", ops);
        }

        if ( strlen(cache_type) == strlen("xfs") &&
             memcmp(cache_type, "xfs", strlen("xfs")) == 0 ) {
                ops = &filter_oppar[FILTER_FS_XFS];
                FDEBUG(D_SUPER, "ops at %p\n", ops);
        }

        if ( strlen(cache_type) == strlen("ext3") &&
             memcmp(cache_type, "ext3", strlen("ext3")) == 0 ) {
                ops = &filter_oppar[FILTER_FS_EXT3];
                FDEBUG(D_SUPER, "ops at %p\n", ops);
        }

        if ( strlen(cache_type) == strlen("tmpfs") &&
             memcmp(cache_type, "tmpfs", strlen("tmpfs")) == 0 ) {
                ops = &filter_oppar[FILTER_FS_TMPFS];
                FDEBUG(D_SUPER, "ops at %p\n", ops);
        }

        if ( strlen(cache_type) == strlen("reiserfs") &&
             memcmp(cache_type, "reiserfs", strlen("reiserfs")) == 0 ) {
                ops = &filter_oppar[FILTER_FS_REISERFS];
                FDEBUG(D_SUPER, "ops at %p\n", ops);
        }
        if ( strlen(cache_type) == strlen("obdfs") &&
             memcmp(cache_type, "obdfs", strlen("obdfs")) == 0 ) {
                ops = &filter_oppar[FILTER_FS_OBDFS];
                FDEBUG(D_SUPER, "ops at %p\n", ops);
        }

        if (ops == NULL) {
                CERROR("prepare to die: unrecognized cache type for Filter\n");
        }
        FEXIT;
        return ops;
}
Esempio n. 11
0
void OSGQGLManagedWidget::mouseReleaseEvent(QMouseEvent *me)
{
    FDEBUG(("OSGQGLManagedWidget::mouseReleaseEvent()\n"));
  
    switch(me->button()) 
    {
    case LeftButton:
        _manager->mouseButtonRelease(SimpleSceneManager::MouseLeft, 
                                        me->x(), me->y()); 
        break;
    case MidButton:
        _manager->mouseButtonRelease(SimpleSceneManager::MouseMiddle, 
                                        me->x(), me->y()); 
        break;
    case RightButton:
        _manager->mouseButtonRelease(SimpleSceneManager::MouseRight, 
                                        me->x(), me->y()); 
        break;
    default:
        break;
    }
   
    paintGL();
}
Esempio n. 12
0
//*************************
//  Main
//
int main(int argc, char *argv[])
{
	int sckt;
	pthread_t recvThread;
	char sendBuffer[BUFFER_SIZE];
	int indexBuffer;
	int sharedRecs;
	RTDBconf_var rec[MAX_RECS];
	unsigned int frameCounter = 0;
	int i, j;
	int life;

	struct sched_param proc_sched;
	pthread_attr_t thread_attr;

	struct itimerval it;
	struct _frameHeader frameHeader;

	struct timeval tempTimeStamp;

  nosend = 0;
	if ((argc < 2) || (argc > 3))
	{
		printUsage();
		return (-1);
	}
	if (argc == 3)
	{
		if(strcmp(argv[2], "nosend") == 0)
		{
			printf("\n*** Running in listing only mode ***\n\n");
			nosend = 1;
		}
		else
		{
			printUsage();
			return (-1);
		}
	}

	/* initializations */
	delay = 0;
	timer = 0;
	end = 0;
	RUNNING_AGENTS = 1;

	/* Assign a real-time priority to process */
	proc_sched.sched_priority=60;
	if ((sched_setscheduler(getpid(), SCHED_FIFO, &proc_sched)) < 0)
	{
		PERRNO("setscheduler");
		return -1;
	}

	if(signal(SIGALRM, signal_catch) == SIG_ERR)
	{
		PERRNO("signal");
		return -1;
	}

	if(signal(SIGINT, signal_catch) == SIG_ERR)
	{
		PERRNO("signal");
		return -1;
	}

	if((sckt = openSocket(argv[1])) == -1)
	{
		PERR("openMulticastSocket");
		printf("\nUsage: comm <interface_name>\n\n");
		return -1;
	}

	if(DB_init() == -1)
	{
		PERR("DB_init");
		closeSocket(sckt);
		return -1;
	}
	
	if((sharedRecs = DB_comm_ini(rec)) < 1)
	{
		PERR("DB_comm_ini");
		DB_free();
		closeSocket(sckt);
		return -1;
	}

#ifdef FILEDEBUG
	if ((filedebug = fopen("log.txt", "w")) == NULL)
	{
		PERRNO("fopen");
		DB_free();
		closeSocket(sckt);
		return -1;
	}
#endif

	/* initializations */
	for (i=0; i<MAX_AGENTS; i++)
	{
		lostPackets[i]=0;
		agent[i].lastFrameCounter = 0;
		agent[i].state = NOT_RUNNING;
		agent[i].removeCounter = 0;
	}
	myNumber = Whoami();
	agent[myNumber].state = RUNNING;

	/* receive thread */
	pthread_attr_init (&thread_attr);
	pthread_attr_setinheritsched (&thread_attr, PTHREAD_INHERIT_SCHED);
	if ((pthread_create(&recvThread, &thread_attr, receiveDataThread, (void *)&sckt)) != 0)
	{
		PERRNO("pthread_create");
		DB_free();
		closeSocket(sckt);
		return -1;
	}

	/* Set itimer to reactivate the program */
	it.it_value.tv_usec=(__suseconds_t)(TTUP_US);
	it.it_value.tv_sec=0;
	it.it_interval.tv_usec=(__suseconds_t)(TTUP_US);
	it.it_interval.tv_sec=0;
	setitimer (ITIMER_REAL, &it, NULL);

	printf("communication: STARTED in ");
#ifdef UNSYNC
	printf("unsync mode...\n");
#else
	printf("sync mode...\n");
#endif 


	MTRand randomGenerator;
	while (!end)
	{
		//pause();
		double waitTime = randomGenerator.randNorm(0,1) * TTUP_US * 0.05 + TTUP_US;
		usleep(waitTime);

		// not timer event
		if (timer == 0)
			continue;

#ifndef UNSYNC
		// dynamic agent 0
		if ((delay > (int)MIN_UPDATE_DELAY_US) && (agent[myNumber].dynamicID == 0) && timer == 1)
		{
			it.it_value.tv_usec = (__suseconds_t)(delay - (int)MIN_UPDATE_DELAY_US/2);
			it.it_value.tv_sec = 0;
			setitimer (ITIMER_REAL, &it, NULL);
			delay = 0;
			continue;
		}
#endif

		timer = 0;

		indexBuffer = 0;
		bzero(sendBuffer, BUFFER_SIZE);

		update_stateTable();

		// update dynamicID
		j = 0;	
		for (i = 0; i < MAX_AGENTS; i++)
		{
			if ((agent[i].state == RUNNING) || (agent[i].state == REMOVE))
			{
				agent[i].dynamicID = j;
				j++;
			}
			agent[myNumber].stateTable[i] = agent[i].state;
		}
		RUNNING_AGENTS = j;

		MAX_DELTA = (int)(TTUP_US/RUNNING_AGENTS * 2/3);

		// frame header
		frameHeader.number = myNumber;
		frameHeader.counter = frameCounter;
		frameCounter ++;
		for (i = 0; i < MAX_AGENTS; i++)
			frameHeader.stateTable[i] = agent[myNumber].stateTable[i];
		frameHeader.noRecs = sharedRecs;
		memcpy(sendBuffer + indexBuffer, &frameHeader, sizeof(frameHeader));
		indexBuffer += sizeof(frameHeader);

		for(i = 0; i < sharedRecs; i++)
		{
			// id
			memcpy(sendBuffer + indexBuffer, &rec[i].id, sizeof(rec[i].id));
			indexBuffer += sizeof(rec[i].id);

			// size
			memcpy(sendBuffer + indexBuffer, &rec[i].size, sizeof(rec[i].size));
			indexBuffer += sizeof(rec[i].size);

			// life and data
			life = DB_get(myNumber, rec[i].id, sendBuffer + indexBuffer + sizeof(life));
			memcpy(sendBuffer + indexBuffer, &life, sizeof(life));
			indexBuffer = indexBuffer + sizeof(life) + rec[i].size;
		}

		if (indexBuffer > BUFFER_SIZE)
		{
			PERR("Pretended frame is bigger that the available buffer.");
			PERR("Please increase the buffer size or reduce the number of disseminated records");
			break;
		}
	
		if (nosend == 0) 
		{
			if (sendData(sckt, sendBuffer, indexBuffer) != indexBuffer)
				PERRNO("Error sending data");
		}

		gettimeofday (&tempTimeStamp, NULL);
		lastSendTimeStamp.tv_sec = tempTimeStamp.tv_sec;
		lastSendTimeStamp.tv_usec = tempTimeStamp.tv_usec;

		// reset values for next round
		for (i=0; i<MAX_AGENTS; i++)
		{
			agent[i].delta = 0;
			agent[i].received = NO;
		}
	}

	FDEBUG (filedebug, "\nLost Packets:\n");
	for (i=0; i<MAX_AGENTS; i++)
		FDEBUG (filedebug, "%d\t", lostPackets[i]);
	FDEBUG (filedebug, "\n");
	
	printf("communication: STOPED.\nCleaning process...\n");

#ifdef FILEDEBUG
	fclose (filedebug);
#endif

	closeSocket(sckt);

	pthread_join(recvThread, NULL);

	DB_free();

	printf("communication: FINISHED.\n");

	return 0;
}
void RenderPartition::doExecution   (void)
{
    if(_bDone == true)
        return;

#ifdef OSG_TRACE_PARTITION
    FDEBUG(("RenderPartition::doExecution '%s'\n",
            _szDebugString.c_str()));
#endif

    if(_eMode == SimpleCallback)
    {
        _oSimpleDrawCallback(&_oDrawEnv);
    }
    else
    {
        BuildKeyMapIt      mapIt  = _mMatTrees.begin();
        BuildKeyMapConstIt mapEnd = _mMatTrees.end  ();

        _uiNumMatrixChanges = 0;

        while(mapIt != mapEnd)
        {
            if(mapIt->second != NULL)
            {
                mapIt->second->draw(_oDrawEnv, this);
            }

            ++mapIt;
        }

        mapIt  = _mTransMatTrees.begin();
        mapEnd = _mTransMatTrees.end  ();

        _oDrawEnv.deactivateState();

        if(!_bZWriteTrans)
            glDepthMask(false);

        while(mapIt != mapEnd)
        {
            if(mapIt->second != NULL)
            {
                mapIt->second->draw(_oDrawEnv, this);
            }

            ++mapIt;
        }

        if(!_bZWriteTrans)
            glDepthMask(true);
    }

    RenderCallbackStore::const_iterator cbIt  = _vPostRenderCallbacks.begin();
    RenderCallbackStore::const_iterator cbEnd = _vPostRenderCallbacks.end  ();

    while(cbIt != cbEnd)
    {
        (*cbIt)(&_oDrawEnv);
        ++cbIt;
    }

    if(0x0000 != (_uiSetupMode & ProjectionSetup))
    {
        glMatrixMode (GL_PROJECTION);
        glPopMatrix();
        glMatrixMode(GL_MODELVIEW);
    }

    // We always push/pop so stages with callback can modify the values
    // as needed

    glPopAttrib();

    if(_pRenderTarget != NULL)
        _pRenderTarget->deactivate(&_oDrawEnv);

    this->exit();
}
void RenderPartition::setupExecution(bool bUpdateGlobalViewport)
{
    if(_bDone == true)
        return;

#ifdef OSG_RENPART_DUMP_PAR
    fprintf(stderr, "setupexecute %p %d\n", this, UInt32(_ubState));
    fflush(stderr);
#endif

#ifdef OSG_TRACE_PARTITION
    FDEBUG(("RenderPartition::setupExecution: '%s'\n",
            _szDebugString.c_str()));
#endif

    if(_pRenderTarget != NULL)
        _pRenderTarget->activate(&_oDrawEnv, _eDrawBuffer);

    // We always push so stages with callbacks can modify the values
    // as needed

    if(bUpdateGlobalViewport == false)
        glPushAttrib(GL_VIEWPORT_BIT | GL_SCISSOR_BIT);

    if(0x0000 != (_uiSetupMode & ViewportSetup))
    {
        if(0x0000 == (_uiSetupMode & PassiveBit))
        {
            glViewport(_oDrawEnv.getPixelLeft  (),
                       _oDrawEnv.getPixelBottom(),
                       _oDrawEnv.getPixelWidth (),
                       _oDrawEnv.getPixelHeight());

            if(_oDrawEnv.getFull() == false)
            {
                glScissor (_oDrawEnv.getPixelLeft  (),
                           _oDrawEnv.getPixelBottom(),
                           _oDrawEnv.getPixelWidth (),
                           _oDrawEnv.getPixelHeight());

                glEnable(GL_SCISSOR_TEST);
            }
            else
            {
                glDisable(GL_SCISSOR_TEST);
            }
        }
    }
    else
    {
        glDisable(GL_SCISSOR_TEST);
    }

    if(bUpdateGlobalViewport == true)
        glPushAttrib(GL_VIEWPORT_BIT | GL_SCISSOR_BIT);

    if(0x0000 != (_uiSetupMode & ProjectionSetup))
    {
        glMatrixMode (GL_PROJECTION);
        glPushMatrix();

        glLoadMatrixf(_oDrawEnv.getCameraFullProjection().getValues());

        glMatrixMode(GL_MODELVIEW);
    }

    RenderCallbackStore::const_iterator cbIt  = _vPreRenderCallbacks.begin();
    RenderCallbackStore::const_iterator cbEnd = _vPreRenderCallbacks.end  ();

    while(cbIt != cbEnd)
    {
        (*cbIt)(&_oDrawEnv);
        ++cbIt;
    }

    if(0x0000 != (_uiSetupMode & BackgroundSetup))
    {
        if(_pBackground != NULL)
        {
            _pBackground->clear(&_oDrawEnv); //, _oDrawEnv.getViewport());
        }
    }
}
/*
 - shortest - shortest-preferred matching engine
 ^ static chr *shortest(struct vars *, struct dfa *, chr *, chr *, chr *,
 ^ 	chr **, int *);
 */
static chr *			/* endpoint, or NULL */
shortest(
    struct vars *v,
    struct dfa *d,
    chr *start,			/* where the match should start */
    chr *min,			/* match must end at or after here */
    chr *max,			/* match must end at or before here */
    chr **coldp,		/* store coldstart pointer here, if nonNULL */
    int *hitstopp)		/* record whether hit v->stop, if non-NULL */
{
    chr *cp;
    chr *realmin = (min == v->stop) ? min : min + 1;
    chr *realmax = (max == v->stop) ? max : max + 1;
    color co;
    struct sset *css;
    struct sset *ss;
    struct colormap *cm = d->cm;

    /*
     * Initialize.
     */

    css = initialize(v, d, start);
    cp = start;
    if (hitstopp != NULL) {
	*hitstopp = 0;
    }

    /*
     * Startup.
     */

    FDEBUG(("--- startup ---\n"));
    if (cp == v->start) {
	co = d->cnfa->bos[(v->eflags&REG_NOTBOL) ? 0 : 1];
	FDEBUG(("color %ld\n", (long)co));
    } else {
	co = GETCOLOR(cm, *(cp - 1));
	FDEBUG(("char %c, color %ld\n", (char)*(cp-1), (long)co));
    }
    css = miss(v, d, css, co, cp, start);
    if (css == NULL) {
	return NULL;
    }
    css->lastseen = cp;
    ss = css;

    /*
     * Main loop.
     */

    if (v->eflags&REG_FTRACE) {
	while (cp < realmax) {
	    FDEBUG(("--- at c%d ---\n", css - d->ssets));
	    co = GETCOLOR(cm, *cp);
	    FDEBUG(("char %c, color %ld\n", (char)*cp, (long)co));
	    ss = css->outs[co];
	    if (ss == NULL) {
		ss = miss(v, d, css, co, cp+1, start);
		if (ss == NULL) {
		    break;	/* NOTE BREAK OUT */
		}
	    }
	    cp++;
	    ss->lastseen = cp;
	    css = ss;
	    if ((ss->flags&POSTSTATE) && cp >= realmin) {
		break;		/* NOTE BREAK OUT */
	    }
	}
    } else {
	while (cp < realmax) {
	    co = GETCOLOR(cm, *cp);
	    ss = css->outs[co];
	    if (ss == NULL) {
		ss = miss(v, d, css, co, cp+1, start);
		if (ss == NULL) {
		    break;	/* NOTE BREAK OUT */
		}
	    }
	    cp++;
	    ss->lastseen = cp;
	    css = ss;
	    if ((ss->flags&POSTSTATE) && cp >= realmin) {
		break;		/* NOTE BREAK OUT */
	    }
	}
    }

    if (ss == NULL) {
	return NULL;
    }

    if (coldp != NULL) {	/* report last no-progress state set, if any */
	*coldp = lastcold(v, d);
    }

    if ((ss->flags&POSTSTATE) && cp > min) {
	assert(cp >= realmin);
	cp--;
    } else if (cp == v->stop && max == v->stop) {
	co = d->cnfa->eos[(v->eflags&REG_NOTEOL) ? 0 : 1];
	FDEBUG(("color %ld\n", (long)co));
	ss = miss(v, d, css, co, cp, start);

	/*
	 * Match might have ended at eol.
	 */

	if ((ss == NULL || !(ss->flags&POSTSTATE)) && hitstopp != NULL) {
	    *hitstopp = 1;
	}
    }

    if (ss == NULL || !(ss->flags&POSTSTATE)) {
	return NULL;
    }

    return cp;
}
SharedObjectHandler::~SharedObjectHandler(void)
{
    FDEBUG(("destroy SharedObjectHandler\n"));
}
/*
 - getvacant - get a vacant state set
 * This routine clears out the inarcs and outarcs, but does not otherwise
 * clear the innards of the state set -- that's up to the caller.
 ^ static struct sset *getvacant(struct vars *, struct dfa *, chr *, chr *);
 */
static struct sset *
getvacant(
    struct vars *v,		/* used only for debug flags */
    struct dfa *d,
    chr *cp,
    chr *start)
{
    int i;
    struct sset *ss;
    struct sset *p;
    struct arcp ap;
    struct arcp lastap = {NULL, 0}; /* silence gcc 4 warning */
    color co;

    ss = pickss(v, d, cp, start);
    assert(!(ss->flags&LOCKED));

    /*
     * Clear out its inarcs, including self-referential ones.
     */

    ap = ss->ins;
    while ((p = ap.ss) != NULL) {
	co = ap.co;
	FDEBUG(("zapping c%d's %ld outarc\n", p - d->ssets, (long)co));
	p->outs[co] = NULL;
	ap = p->inchain[co];
	p->inchain[co].ss = NULL; /* paranoia */
    }
    ss->ins.ss = NULL;

    /*
     * Take it off the inarc chains of the ssets reached by its outarcs.
     */

    for (i = 0; i < d->ncolors; i++) {
	p = ss->outs[i];
	assert(p != ss);	/* not self-referential */
	if (p == NULL) {
	    continue;		/* NOTE CONTINUE */
	}
	FDEBUG(("del outarc %d from c%d's in chn\n", i, p - d->ssets));
	if (p->ins.ss == ss && p->ins.co == i) {
	    p->ins = ss->inchain[i];
	} else {
	    assert(p->ins.ss != NULL);
	    for (ap = p->ins; ap.ss != NULL &&
		    !(ap.ss == ss && ap.co == i);
		    ap = ap.ss->inchain[ap.co]) {
		lastap = ap;
	    }
	    assert(ap.ss != NULL);
	    lastap.ss->inchain[lastap.co] = ss->inchain[i];
	}
	ss->outs[i] = NULL;
	ss->inchain[i].ss = NULL;
    }

    /*
     * If ss was a success state, may need to remember location.
     */

    if ((ss->flags&POSTSTATE) && ss->lastseen != d->lastpost &&
	    (d->lastpost == NULL || d->lastpost < ss->lastseen)) {
	d->lastpost = ss->lastseen;
    }

    /*
     * Likewise for a no-progress state.
     */

    if ((ss->flags&NOPROGRESS) && ss->lastseen != d->lastnopr &&
	    (d->lastnopr == NULL || d->lastnopr < ss->lastseen)) {
	d->lastnopr = ss->lastseen;
    }

    return ss;
}
Esempio n. 18
0
//! low-level OpenGL calls, ignoring materials  
Action::ResultE DVRVolume::draw(DrawActionBase *action)
{
    FINFO(("DVRVolume::draw\n"));

    Window *window = action->getWindow();

    if(getShader() != NullFC) 
    {
        // determine texture mode
        TextureManager::TextureMode mode = getTextureMode(window);
        
        FDEBUG(("DVRVolume::draw - using Shader: %s\n",
                //getShader()->getClassname()));
                getShader()->getType().getCName()));

        // initialization
        if(shadingInitialized == false) 
        {     
            // clear old texture chunks 
            textureManager.clearTextures( getTextureStorage() );

            // initialize shader 
            bool result = getShader()->initialize( this, action );

            if(result != true)
            {
                SFATAL << "DVRVolume::draw - error initializing shader" 
                       << std::endl;
            }

            //!! Shader::initialize may change the useMTSlabs() flag
            if(getShader()->useMTSlabs())
                mode = TextureManager::TM_2D_Multi;
            
            // create texture chunks
            SINFO << "TextureMode = " << mode << std::endl;

            textureManager.buildTextures(getTextureStorage(), this, mode);
            
            // initialize slice clipper
            clipper.initialize(this);
            
            shadingInitialized = true;
        }

        // sort bricks
        Pnt3f eyePointWorld(0.f, 0.f, 0.f);
        action->getCameraToWorld().mult(eyePointWorld, eyePointWorld);

        Matrix modelMat = action->getActNode()->getToWorld();
      
        // SINFO << "DVRVolume::draw - modelMat " << modelMat << std::endl;
        // SINFO << "DVRVolume::draw - eyePoint " << eyePointWorld << std::endl;
        //Brick * first = textureManager.sortBricks(
        //    action,modelMat, eyePointWorld, this, mode);

        Brick *first = textureManager.sortBricks(
            action, modelMat, eyePointWorld.subZero(), this, mode);

        // render brick boundaries

        if(getShowBricks())
        {
            for(Brick *current  = first; 
                current != NULL; 
                current  = current->getNext())
            {
                current->renderBrick();
            }
        }
        
        // initialize clipping
        initializeClipObjects(action, modelMat);
        
        // Texture_3D bricks need per brick clipping setup
        // whereas for Texture_2D bricks the clipper has to be initialized 
        // only once in that case the reset is done in Brick::render3DSlices(..)
        
        if(mode != TextureManager::TM_3D) 
            clipper.reset(this);
        
        //!! Rendering
        if(first != NULL)
        {
            getShader()->activate(this, action);
            
            // for all bricks
            Brick *prev = NULL;

            for(Brick *current  = first;
                       current != NULL;
                       prev     = current, current = current->getNext())
            {
                //FDEBUG(("DVRVolume::draw - render Brick: %d\n" i++));
                
                // switch to texture chunk
                if(getDoTextures()) 
                {
                    if (prev == NULL)
                    {
                        current->activateTexture(action);
                    }
                    else
                    {
                        current->changeFromTexture(action, prev);
                    }
                }
                
                // activate shader
                getShader()->brickActivate(this, action, current);
                
                // render slices
                current->renderSlices(this, 
                                      action, 
                                      getShader(), 
                                      &clipper, 
                                      mode);
            }
            
            // deactivate last texture chunk
            prev->deactivateTexture(action);
            
            getShader()->deactivate(this, action);
        }
    }
    else
    {
        // Show some slices anyway
        Vec3f min, max;

        action->getActNode()->getVolume().getBounds(min, max);
        
        FDEBUG(("DVRVolume::draw dummy geometry - %f %f %f -> %f %f %f\n",
                min[0], min[1], min[2], max[0], max[1], max[2]));
        
        // resolution of volume in voxel
        UInt32 res[3] = {64, 64, 64};

        // offset for slices
        Real32 offset[3] = {(max[0] - min[0]) / 2 / res[0],
                            (max[1] - min[1]) / 2 / res[1],
                            (max[2] - min[2]) / 2 / res[2]};
        // increment for slices
        Real32 inc[3] = {(max[0] - min[0]) / res[0],
                         (max[1] - min[1]) / res[1],
                         (max[2] - min[2]) / res[2]};
        
        // slices perpenticular to Z-axis
        Real32 value = min[2] + offset[2];

        for(UInt32 i = 0; i < res[2]; i++, value += inc[2])
        {
            
            glBegin(GL_LINE_LOOP); 
            {
                glVertex3f(min[0] + offset[0], min[1] + offset[1], value);
                glTexCoord2f(0.0f + offset[0],  0.0f + offset[1]);
                
                glVertex3f(max[0] - offset[0], min[1] + offset[1], value);
                glTexCoord2f(1.0f - offset[0],  0.0f + offset[1]);
                
                glVertex3f(min[0] + offset[0],  max[1] - offset[1], value);
                glTexCoord2f(0.0f + offset[0],  1.0f - offset[1]);
                
                glVertex3f(max[0] - offset[0],  max[1] - offset[1], value);
                glTexCoord2f(1.0f - offset[0],  1.0f - offset[1]);
            } 
            glEnd();
        }
    }
    
    return Action::Skip;

    //return Geometry::draw(action);
}
/*
 - longest - longest-preferred matching engine
 ^ static chr *longest(struct vars *, struct dfa *, chr *, chr *, int *);
 */
static chr *			/* endpoint, or NULL */
longest(
    struct vars *v,		/* used only for debug and exec flags */
    struct dfa *d,
    chr *start,			/* where the match should start */
    chr *stop,			/* match must end at or before here */
    int *hitstopp)		/* record whether hit v->stop, if non-NULL */
{
    chr *cp;
    chr *realstop = (stop == v->stop) ? stop : stop + 1;
    color co;
    struct sset *css;
    struct sset *ss;
    chr *post;
    int i;
    struct colormap *cm = d->cm;

    /*
     * Initialize.
     */

    css = initialize(v, d, start);
    cp = start;
    if (hitstopp != NULL) {
	*hitstopp = 0;
    }

    /*
     * Startup.
     */

    FDEBUG(("+++ startup +++\n"));
    if (cp == v->start) {
	co = d->cnfa->bos[(v->eflags&REG_NOTBOL) ? 0 : 1];
	FDEBUG(("color %ld\n", (long)co));
    } else {
	co = GETCOLOR(cm, *(cp - 1));
	FDEBUG(("char %c, color %ld\n", (char)*(cp-1), (long)co));
    }
    css = miss(v, d, css, co, cp, start);
    if (css == NULL) {
	return NULL;
    }
    css->lastseen = cp;

    /*
     * Main loop.
     */

    if (v->eflags&REG_FTRACE) {
	while (cp < realstop) {
	    FDEBUG(("+++ at c%d +++\n", css - d->ssets));
	    co = GETCOLOR(cm, *cp);
	    FDEBUG(("char %c, color %ld\n", (char)*cp, (long)co));
	    ss = css->outs[co];
	    if (ss == NULL) {
		ss = miss(v, d, css, co, cp+1, start);
		if (ss == NULL) {
		    break;	/* NOTE BREAK OUT */
		}
	    }
	    cp++;
	    ss->lastseen = cp;
	    css = ss;
	}
    } else {
	while (cp < realstop) {
	    co = GETCOLOR(cm, *cp);
	    ss = css->outs[co];
	    if (ss == NULL) {
		ss = miss(v, d, css, co, cp+1, start);
		if (ss == NULL) {
		    break;	/* NOTE BREAK OUT */
		}
	    }
	    cp++;
	    ss->lastseen = cp;
	    css = ss;
	}
    }

    /*
     * Shutdown.
     */

    FDEBUG(("+++ shutdown at c%d +++\n", css - d->ssets));
    if (cp == v->stop && stop == v->stop) {
	if (hitstopp != NULL) {
	    *hitstopp = 1;
	}
	co = d->cnfa->eos[(v->eflags&REG_NOTEOL) ? 0 : 1];
	FDEBUG(("color %ld\n", (long)co));
	ss = miss(v, d, css, co, cp, start);

	/*
	 * Special case: match ended at eol?
	 */

	if (ss != NULL && (ss->flags&POSTSTATE)) {
	    return cp;
	} else if (ss != NULL) {
	    ss->lastseen = cp;	/* to be tidy */
	}
    }

    /*
     * Find last match, if any.
     */

    post = d->lastpost;
    for (ss = d->ssets, i = d->nssused; i > 0; ss++, i--) {
	if ((ss->flags&POSTSTATE) && (post != ss->lastseen) &&
		(post == NULL || post < ss->lastseen)) {
	    post = ss->lastseen;
	}
    }
    if (post != NULL) {		/* found one */
	return post - 1;
    }

    return NULL;
}
Esempio n. 20
0
void filter_setup_dir_ops(struct filter_fs *cache, struct inode *inode, struct inode_operations *filter_iops, struct file_operations *filter_fops)
{
        struct inode_operations *cache_filter_iops;
        struct inode_operations *cache_iops = inode->i_op;
        struct file_operations *cache_fops = inode->i_fop;
        FENTRY;

        if ( cache->o_flags & FILTER_DID_DIR_OPS ) {
                FEXIT;
                return;
        }
        cache->o_flags |= FILTER_DID_DIR_OPS;

        /* former ops become cache_ops */
        cache->o_caops.cache_dir_iops = cache_iops;
        cache->o_caops.cache_dir_fops = cache_fops;
        FDEBUG(D_SUPER, "filter at %p, cache iops %p, iops %p\n",
               cache, cache_iops, filter_c2udiops(cache));

        /* setup our dir iops: copy and modify */
        memcpy(filter_c2udiops(cache), cache_iops, sizeof(*cache_iops));

        /* abbreviate */
        cache_filter_iops = filter_c2udiops(cache);

        /* methods that filter if cache filesystem has these ops */
        if (cache_iops->lookup && filter_iops->lookup)
                cache_filter_iops->lookup = filter_iops->lookup;
        if (cache_iops->create && filter_iops->create)
                cache_filter_iops->create = filter_iops->create;
        if (cache_iops->link && filter_iops->link)
                cache_filter_iops->link = filter_iops->link;
        if (cache_iops->unlink && filter_iops->unlink)
                cache_filter_iops->unlink = filter_iops->unlink;
        if (cache_iops->mkdir && filter_iops->mkdir)
                cache_filter_iops->mkdir = filter_iops->mkdir;
        if (cache_iops->rmdir && filter_iops->rmdir)
                cache_filter_iops->rmdir = filter_iops->rmdir;
        if (cache_iops->symlink && filter_iops->symlink)
                cache_filter_iops->symlink = filter_iops->symlink;
        if (cache_iops->rename && filter_iops->rename)
                cache_filter_iops->rename = filter_iops->rename;
        if (cache_iops->mknod && filter_iops->mknod)
                cache_filter_iops->mknod = filter_iops->mknod;
        if (cache_iops->permission && filter_iops->permission)
                cache_filter_iops->permission = filter_iops->permission;
        if (cache_iops->getattr)
                cache_filter_iops->getattr = filter_iops->getattr;
        /* Some filesystems do not use a setattr method of their own
           instead relying on inode_setattr/write_inode. We still need to
           journal these so we make setattr an unconditional operation. 
           XXX: we should probably check for write_inode. SHP
        */
        /*if (cache_iops->setattr)*/
                cache_filter_iops->setattr = filter_iops->setattr;
#ifdef CONFIG_FS_EXT_ATTR
	/* For now we assume that posix acls are handled through extended
	* attributes. If this is not the case, we must explicitly trap 
	* posix_set_acl. SHP
	*/
	if (cache_iops->set_ext_attr && filter_iops->set_ext_attr)
		cache_filter_iops->set_ext_attr = filter_iops->set_ext_attr;
#endif


        /* copy dir fops */
        memcpy(filter_c2udfops(cache), cache_fops, sizeof(*cache_fops));

        /* unconditional filtering operations */
        filter_c2udfops(cache)->ioctl = filter_fops->ioctl;

        FEXIT;
}
Esempio n. 21
0
OSGQGLManagedWidget::~OSGQGLManagedWidget(void)
{
    FDEBUG(("OSGQGLManagedWidget destructor called\n"));
}
/*
 - pickss - pick the next stateset to be used
 ^ static struct sset *pickss(struct vars *, struct dfa *, chr *, chr *);
 */
static struct sset *
pickss(
    struct vars *v,		/* used only for debug flags */
    struct dfa *d,
    chr *cp,
    chr *start)
{
    int i;
    struct sset *ss;
    struct sset *end;
    chr *ancient;

    /*
     * Shortcut for cases where cache isn't full.
     */

    if (d->nssused < d->nssets) {
	i = d->nssused;
	d->nssused++;
	ss = &d->ssets[i];
	FDEBUG(("new c%d\n", i));

	/*
	 * Set up innards.
	 */

	ss->states = &d->statesarea[i * d->wordsper];
	ss->flags = 0;
	ss->ins.ss = NULL;
	ss->ins.co = WHITE;	/* give it some value */
	ss->outs = &d->outsarea[i * d->ncolors];
	ss->inchain = &d->incarea[i * d->ncolors];
	for (i = 0; i < d->ncolors; i++) {
	    ss->outs[i] = NULL;
	    ss->inchain[i].ss = NULL;
	}
	return ss;
    }

    /*
     * Look for oldest, or old enough anyway.
     */

    if (cp - start > d->nssets*2/3) {	/* oldest 33% are expendable */
	ancient = cp - d->nssets*2/3;
    } else {
	ancient = start;
    }
    for (ss = d->search, end = &d->ssets[d->nssets]; ss < end; ss++) {
	if ((ss->lastseen == NULL || ss->lastseen < ancient)
		&& !(ss->flags&LOCKED)) {
	    d->search = ss + 1;
	    FDEBUG(("replacing c%d\n", ss - d->ssets));
	    return ss;
	}
    }
    for (ss = d->ssets, end = d->search; ss < end; ss++) {
	if ((ss->lastseen == NULL || ss->lastseen < ancient)
		&& !(ss->flags&LOCKED)) {
	    d->search = ss + 1;
	    FDEBUG(("replacing c%d\n", ss - d->ssets));
	    return ss;
	}
    }

    /*
     * Nobody's old enough?!? -- something's really wrong.
     */

    FDEBUG(("can't find victim to replace!\n"));
    assert(NOTREACHED);
    ERR(REG_ASSERT);
    return d->ssets;
}
// setup state for shading with fragment program
void DVRIsoShader::activate_FragmentProgramShading(DVRVolume      *volume, 
                                                   DrawActionBase *action)
{
    // Initialize the fragment program 
    if(m_pFragProg == NullFC) 
    {
        FDEBUG(("Initializing fragment program "));
        m_pFragProg = FragmentProgramChunk::create();

        addRefCP( m_pFragProg );

        FDEBUG((" - DONE\n"));

        // Load the appropriate program
        switch(m_shadingMode) 
        {
            case SM_FRAGMENT_PROGRAM_3D:
                // SLOG << "Loading ... isoFragProg3D.asm" << std::endl;

                beginEditCP(m_pFragProg);
                {
                    m_pFragProg->setProgram(_fragProg3D);
                    // m_pFragProg->read( "isoFragProg3D.asm" );
                }
                endEditCP  (m_pFragProg);

                break;

            case SM_FRAGMENT_PROGRAM_2D:

                // SLOG << "Loading ... isoFragProg2D.asm" << std::endl;
                
                beginEditCP(m_pFragProg);
                {
                    m_pFragProg->setProgram(_fragProg2D);
                    // m_pFragProg->read( "isoFragProg2D.asm" );
                }
                endEditCP(m_pFragProg);

                break;

            default:
                FFATAL(("Texture mode for fragment programs not supported "
                        "by DVRSimpleLUTShader"));
                return;
                // break;
        }
    }
    
    // get parameters from isosurface attachment if available
    Real32 isoValue;
    UInt32 alphaMode;
    bool   doSpecular;

    DVRIsoSurfacePtr isoParam = DVRVOLUME_PARAMETER(volume, DVRIsoSurface);

    if(isoParam != NullFC)
    {
        isoValue   = isoParam->getIsoValue        ();
        alphaMode  = isoParam->getAlphaMode       ();
        doSpecular = isoParam->getSpecularLighting();
    }
    else
    {
        isoValue   = 1.0;
        alphaMode  = GL_GREATER;
        doSpecular = false;
    }

    unsigned int maxDiffuseLights  = 6; // Hard-coded in the fragment program
    unsigned int maxSpecularLights = 6;
    
    // Set light parameters
    DirLightList diffuseLights;
    DirLightList specularLights;
    Color4f      ambientLight;

    getLightSources(diffuseLights, specularLights, ambientLight);

    beginEditCP(m_pFragProg, ProgramChunk::ParamValuesFieldMask);
    {
        m_pFragProg->setParameter(static_cast<short int>(0), 
                                  cToV(ambientLight)); // ambient color

        // Diffuse lights
        unsigned int i;

        DirLightList::iterator l = diffuseLights.begin();

        for(i = 0; i < maxDiffuseLights && l != diffuseLights.end(); i++)
        { 
            Vec3f tmp;

            Slicer::rotateToLocal(action,l->dir,tmp);

            tmp.normalize();

            // diffuse direction
            m_pFragProg->setParameter(1 + 2 * i,     Vec4f(tmp));

            // diffuse color
            m_pFragProg->setParameter(1 + 2 * i + 1, cToV(l->color)); 

            ++l;
        }

        for(; i < maxDiffuseLights; i++) 
        {
            // diffuse direction
            m_pFragProg->setParameter(1 + 2 * i,     Vec4f(0, 0, 0, 0));

            // diffuse color
            m_pFragProg->setParameter(1 + 2 * i + 1, Vec4f(0, 0, 0, 0)); 
        }
        
        // Specular lights
        unsigned int firstSpecId = 1 + 2 * maxDiffuseLights;

        i = 0;

        if(doSpecular) 
        {
            // get and classify the slicing direction
            Vec3f  viewDir;

            Slicer::getSlicingDirection(action, &viewDir);

            viewDir.normalize();
            
            DirLightList::iterator ls = specularLights.begin();

            for(i = 0; 
                i < maxSpecularLights && ls != specularLights.end(); 
                i++)
            { 
                Vec3f tmp;

                Slicer::rotateToLocal(action,ls->dir,tmp);

                tmp.normalize();

                // calc halfway
                tmp += viewDir;
                tmp.normalize();

                // halfway vector
                m_pFragProg->setParameter(firstSpecId + 2 * i,     
                                          Vec4f(tmp));
                // specular color
                m_pFragProg->setParameter(firstSpecId + 2 * i + 1, 
                                          cToV(ls->color));  

                ++ls;
            }
        }

        for(; i < maxSpecularLights; i++) 
        {
            // specular direction
            m_pFragProg->setParameter(firstSpecId + 2 * i,     
                                      Vec4f(0, 0, 0, 0)); 

            // specular color
            m_pFragProg->setParameter(firstSpecId + 2 * i + 1, 
                                      Vec4f(0, 0, 0, 0)); 
        }
    }
    endEditCP(m_pFragProg, ProgramChunk::ParamValuesFieldMask);

    
    glPushAttrib(GL_ENABLE_BIT);

    // activate fragment program chunk
    m_pFragProg->activate(action);

    // no blending and lighting
    glDisable(GL_BLEND   );
    glDisable(GL_LIGHTING);
    
    // Enable Alpha Test for isosurface
    glEnable   (GL_ALPHA_TEST      ); 
    glAlphaFunc(alphaMode, isoValue);
}
Esempio n. 24
0
void doShell(Client* shellClient) {
    Client* p;
    char head[HEAD_SIZE], value[VALUE_SIZE];

    char fileBuffer[FILE_BUFFER_SIZE + 1];
    char fileChunk[FILE_CHUNK_SIZE];
    char filename[256];
    unsigned long fileSize;
    int fd;
    FILE* fp;

    FDEBUG(("shell start\n"));
    while (1) {
        // shell 담당 서버는 shell 클라이언트로부터 신호를 받아야만 일합니다.
        readMsg(shellClient->socket, head, value);

        if ( !strcmp(head, ADD) ) {
            // 파일 추가
            FDEBUG(("get ADD message\n"));
            fileSize = 0;

            // 우선 해당 이름으로 파일을 엽니다.
            strcpy(filename, value);
            fd = open(filename, O_WRONLY | O_CREAT, 0644);
            if (fd == -1) {
                writeMsg(shellClient->socket, ERR, "fileopen_err");
                continue;
            }

            // 다른 일반 클라이언트들에게도 이 사실을 알립니다.
            writeMsg(shellClient->socket, ACCEPT, "fileadd");
            p = front;
            while (p) {
                writeMsg(p->pipe[1], ADD, filename);
                p = p->nextClient;
            }

            // 파일 구분자를 입력받습니다.
            readMsg(shellClient->socket, head, fileChunk);
            writeMsg(shellClient->socket, ACCEPT, "filechunk");
            p = front;
            while (p) {
                writeMsg(p->pipe[1], CHUNK, fileChunk);
                p = p->nextClient;
            }

            // 파일을 읽어서 클라이언트에게 전달합니다. 서버에도 한 부 저장합니다.
            FDEBUG(("start reading file\n"));
            while (true) {
                memset(fileBuffer, 0, sizeof(fileBuffer));
                readData(shellClient->socket, fileBuffer);

                p = front;
                while (p) {
                    writeData(p->pipe[1], fileBuffer);
                    p = p->nextClient;
                }

                // 파일 전송이 끝나면 끝냅니다.
                if ( !strcmp(fileBuffer, fileChunk) ) break;
                // 아니라면 서버에 저장하고 다음 부분을 보내달라고 요청합니다.
                else writeData(fd, fileBuffer);
                writeMsg(shellClient->socket, CHUNK, fileChunk);
                fileSize += strlen(fileBuffer);
            }
            // 파일을 전부 기록했습니다. 닫고 EOF 메시지를 전달합니다.
            close(fd);
            writeMsg(shellClient->socket, ACCEPT, "eof");
            p = front;
            while (p) {
                writeMsg(p->pipe[1], ACCEPT, "eof");
                p = p->nextClient;
            }

            // 결과를 출력합니다.
            Notice("ADD ");
            printf("[%s][%ldbyte] from Client(%d)\n", filename, fileSize, shellClient->clientNo);

        } else
        if ( !strcmp(head, DEL) ) {
            // 삭제할 파일의 크기를 구합니다.
            fp = fopen(value, "r");
            fseek(fp, 0L, SEEK_END);
            fileSize = ftell(fp);
            fclose(fp);

            // 결과를 출력합니다.
            Notice ("DELETE ");
            printf("[%s][%ldbyte] from Client(%d)\n", value, fileSize, shellClient->clientNo);

            // 파일을 삭제하고 다른 클라이언트에게 알립니다.
            remove( value );

            p = front;
            while (p) {
                writeMsg(p->pipe[1], head, value);
                p = p->nextClient;
            }

        }
    }
}
Esempio n. 25
0
void filter_setup_journal_ops(struct filter_fs *ops, char *cache_type)
{
        if ( strlen(cache_type) == strlen("ext2") &&
             memcmp(cache_type, "ext2", strlen("ext2")) == 0 ) {
#ifdef CONFIG_EXT2_FS
                ops->o_trops = &presto_ext2_journal_ops;
#else
                ops->o_trops = NULL;
#endif
                FDEBUG(D_SUPER, "ops at %p\n", ops);
        }

        if ( strlen(cache_type) == strlen("ext3") &&
             memcmp(cache_type, "ext3", strlen("ext3")) == 0 ) {
#if defined(CONFIG_EXT3_FS) || defined (CONFIG_EXT3_FS_MODULE)
                ops->o_trops = &presto_ext3_journal_ops;
#else
                ops->o_trops = NULL;
#endif
                FDEBUG(D_SUPER, "ops at %p\n", ops);
        }

        if ( strlen(cache_type) == strlen("tmpfs") &&
             memcmp(cache_type, "tmpfs", strlen("tmpfs")) == 0 ) {
#if defined(CONFIG_TMPFS)
                ops->o_trops = &presto_tmpfs_journal_ops;
#else
                ops->o_trops = NULL;
#endif
                FDEBUG(D_SUPER, "ops at %p\n", ops);
        }

        if ( strlen(cache_type) == strlen("reiserfs") &&
             memcmp(cache_type, "reiserfs", strlen("reiserfs")) == 0 ) {
#if 0
		/* #if defined(CONFIG_REISERFS_FS) || defined(CONFIG_REISERFS_FS_MODULE) */
                ops->o_trops = &presto_reiserfs_journal_ops;
#else
                ops->o_trops = NULL;
#endif
                FDEBUG(D_SUPER, "ops at %p\n", ops);
        }

        if ( strlen(cache_type) == strlen("xfs") &&
             memcmp(cache_type, "xfs", strlen("xfs")) == 0 ) {
#if 0
/*#if defined(CONFIG_XFS_FS) || defined (CONFIG_XFS_FS_MODULE) */
                ops->o_trops = &presto_xfs_journal_ops;
#else
                ops->o_trops = NULL;
#endif
                FDEBUG(D_SUPER, "ops at %p\n", ops);
        }

        if ( strlen(cache_type) == strlen("obdfs") &&
             memcmp(cache_type, "obdfs", strlen("obdfs")) == 0 ) {
#if defined(CONFIG_OBDFS_FS) || defined (CONFIG_OBDFS_FS_MODULE)
                ops->o_trops = presto_obdfs_journal_ops;
#else
                ops->o_trops = NULL;
#endif
                FDEBUG(D_SUPER, "ops at %p\n", ops);
        }
}
SharedObjectHandler::SharedObjectHandler(void) :
    _mSharedObjects(),
    _vLoadedNames  ()
{
    FDEBUG(("create SharedObjectHandler\n"));
}
Esempio n. 27
0
static int
flash_ioctl(struct inode *inode, struct file *file,
	    unsigned int cmd, unsigned long arg)
{
	int minor;
	struct flashpartition *part;
	struct flashchipinfo *finfo;

	if (!inode || !inode->i_rdev)
		return -EINVAL;

	minor = MINOR(inode->i_rdev);

	if(minor < FLASH_MINOR)
		return -EINVAL; /* only ioctl's for flash devices */

	part = &partitions[minor - FLASH_MINOR];

	switch(cmd) {
	case FLASHIO_CHIPINFO:

		if(!suser())
			return -EACCES;

		if(arg == 0)
			return -EINVAL;

		finfo = (struct flashchipinfo *)arg;

		/* TODO: verify arg */

		finfo->isValid = chips[0].isValid;
		finfo->manufacturer_id = chips[0].manufacturer_id;
		finfo->device_id = chips[0].device_id;
		finfo->size = chips[0].size;
		finfo->sectorsize = chips[0].sectorsize;

		return 0;

	case FLASHIO_ERASEALL:
		FDEBUG(printk("flash_ioctl(): Got FLASHIO_ERASEALL request.\n"));

		if(!part->start)
			return -EINVAL;

		if(!suser())
			return -EACCES;

		/* Invalidate all pages and buffers */

		invalidate_inodes(inode->i_rdev);
		invalidate_buffers(inode->i_rdev);

		/*
		 * Start the erasure, then sleep and wake up now and
		 * then to see if it's done. We use the waitqueue to
		 * make sure we don't start erasing in the middle of
		 * a write, or that nobody start using the flash while
		 * we're erasing.
		 *
		 * TODO: break up partition erases that spans more than one
		 *       chip.
		 */

		flash_safe_acquire(part);

		flash_init_erase(part->start, part->size);
#if 1
		flash_finalize_erase(part->start, part->size);
#else
		while (flash_is_busy(part->start)
		       || !flash_pos_is_clean(part->start)) {
			current->state = TASK_INTERRUPTIBLE;
			current->timeout = jiffies + HZ / 2;
			schedule();
		}
#endif

		flash_safe_release(part);

		return 0;

	default:
		return -EPERM;
	}

	return -EPERM;
}
/*
 - miss - handle a cache miss
 ^ static struct sset *miss(struct vars *, struct dfa *, struct sset *,
 ^ 	pcolor, chr *, chr *);
 */
static struct sset *		/* NULL if goes to empty set */
miss(
    struct vars *v,		/* used only for debug flags */
    struct dfa *d,
    struct sset *css,
    pcolor co,
    chr *cp,			/* next chr */
    chr *start)			/* where the attempt got started */
{
    struct cnfa *cnfa = d->cnfa;
    int i;
    unsigned h;
    struct carc *ca;
    struct sset *p;
    int ispost;
    int noprogress;
    int gotstate;
    int dolacons;
    int sawlacons;

    /*
     * For convenience, we can be called even if it might not be a miss.
     */

    if (css->outs[co] != NULL) {
	FDEBUG(("hit\n"));
	return css->outs[co];
    }
    FDEBUG(("miss\n"));

    /*
     * First, what set of states would we end up in?
     */

    for (i = 0; i < d->wordsper; i++) {
	d->work[i] = 0;
    }
    ispost = 0;
    noprogress = 1;
    gotstate = 0;
    for (i = 0; i < d->nstates; i++) {
	if (ISBSET(css->states, i)) {
	    for (ca = cnfa->states[i]+1; ca->co != COLORLESS; ca++) {
		if (ca->co == co) {
		    BSET(d->work, ca->to);
		    gotstate = 1;
		    if (ca->to == cnfa->post) {
			ispost = 1;
		    }
		    if (!cnfa->states[ca->to]->co) {
			noprogress = 0;
		    }
		    FDEBUG(("%d -> %d\n", i, ca->to));
		}
	    }
	}
    }
    dolacons = (gotstate) ? (cnfa->flags&HASLACONS) : 0;
    sawlacons = 0;
    while (dolacons) {		/* transitive closure */
	dolacons = 0;
	for (i = 0; i < d->nstates; i++) {
	    if (ISBSET(d->work, i)) {
		for (ca = cnfa->states[i]+1; ca->co != COLORLESS; ca++) {
		    if (ca->co <= cnfa->ncolors) {
			continue; /* NOTE CONTINUE */
		    }
		    sawlacons = 1;
		    if (ISBSET(d->work, ca->to)) {
			continue; /* NOTE CONTINUE */
		    }
		    if (!lacon(v, cnfa, cp, ca->co)) {
			continue; /* NOTE CONTINUE */
		    }
		    BSET(d->work, ca->to);
		    dolacons = 1;
		    if (ca->to == cnfa->post) {
			ispost = 1;
		    }
		    if (!cnfa->states[ca->to]->co) {
			noprogress = 0;
		    }
		    FDEBUG(("%d :> %d\n", i, ca->to));
		}
	    }
	}
    }
    if (!gotstate) {
	return NULL;
    }
    h = HASH(d->work, d->wordsper);

    /*
     * Next, is that in the cache?
     */

    for (p = d->ssets, i = d->nssused; i > 0; p++, i--) {
	 if (HIT(h, d->work, p, d->wordsper)) {
	     FDEBUG(("cached c%d\n", p - d->ssets));
	     break;			/* NOTE BREAK OUT */
	 }
    }
    if (i == 0) {		/* nope, need a new cache entry */
	p = getvacant(v, d, cp, start);
	assert(p != css);
	for (i = 0; i < d->wordsper; i++) {
	    p->states[i] = d->work[i];
	}
	p->hash = h;
	p->flags = (ispost) ? POSTSTATE : 0;
	if (noprogress) {
	    p->flags |= NOPROGRESS;
	}

	/*
	 * lastseen to be dealt with by caller
	 */
    }

    if (!sawlacons) {		/* lookahead conds. always cache miss */
	FDEBUG(("c%d[%d]->c%d\n", css - d->ssets, co, p - d->ssets));
	css->outs[co] = p;
	css->inchain[co] = p->ins;
	p->ins.ss = css;
	p->ins.co = (color)co;
    }
    return p;
}
Esempio n. 29
0
/*! Create LineChunk from fetched data.
 *  The DXF line pattern description is mapped to a 16 bit stipple pattern
 *  suitable for OpenGL line stippling. This mapping only approximately
 *  resembles the DXF line pattern.
 *
 *  \todo 
 *	Currently it's not checked, whether the fetched data is consistent!
 */
DXFResult DXFLtype::endEntity(void)
{
	if(_linetypeMapP->find(_name) != _linetypeMapP->end())
	{
		FWARNING(("DXF Loader: before line %d: "
				  "LTYPE entity '%s' already exists. "
				  "Overwriting with new one!\n",
				  DXFRecord::getLineNumber(),
				  _name.c_str()
				 ));
	}

	// Do consistency checks
	Real32 checkedPatternLen = 0.0;
	for(std::vector<Real64>::iterator itr = _elementLen.begin();
		itr != _elementLen.end();
		++ itr)
	{
		checkedPatternLen += osgabs(*itr);
	}
	
	if(osgabs(checkedPatternLen - _patternLen) > Eps)
	{
		FWARNING(("DXF Loader: before line %d: "
				  "LTYPE entity defines inconsistent pattern lenght!\n",
				  DXFRecord::getLineNumber()
				 ));
		// we go on, but will use consistent data: checkedPatternLen
	}

	if(_nElements != _elementLen.size())
	{
		FWARNING(("DXF Loader: before line %d: "
				  "LTYPE entity declares %d pattern elements but provides %d!\n",
				  DXFRecord::getLineNumber(),
				  _nElements,
				  _elementLen.size()
				 ));
		// we go on, but will use consistent data: _elementLen.size()
	}

	UInt16 pattern = 0;
	LineChunkPtr linetype = LineChunk::create();	
	beginEditCP(linetype);
	{		
//		linetype->setWidth(1);
		if(_elementLen.size() != 0)
		{
			// Build OpenGL 16 bit stipple pattern: for each bit calculate, which
			// pattern element it belongs to and set it if the pattern element is
			// positive, otherwise leave it unset.
			Real32 s = checkedPatternLen/16.0;
			UInt8 j = 0;
			Real32 elementLenSum = osgabs(_elementLen[j]);
			for(UInt8 i = 0;
				i < 16;
				++ i)
			{
				if(elementLenSum < (0.5 + i) * s && j < _elementLen.size())
				{
					++ j;
					elementLenSum += osgabs( _elementLen[j] );
				}
				if( _elementLen[j] > 0.0)
					pattern |= 1<<i;
			}
			linetype->setStippleRepeat(1);
			linetype->setStipplePattern(pattern);	
		}
		linetype->setSmooth(true);  //TODO: make this configurable by an option?
	}
	endEditCP(linetype);
	
#if 1 // DEBUG TODO: raus?!?!
	std::string pstr("");
	for(UInt8 i=0; i<16; ++i)
		pstr += (pattern & (1<<i)) ? "1" : "0";
	FDEBUG(("DXFLtype::endEntity(): pattern '%s' = %s\n",
			_name.c_str(),
			pstr.c_str()));
#endif // DEBUG
	(*_linetypeMapP)[_name] = linetype;

	return DXFStateContinue;
}
Esempio n. 30
0
void OSGQGLManagedWidget::keyPressEvent(QKeyEvent *OSG_CHECK_ARG(ke))
{
    FDEBUG(("OSGQGLManagedWidget::keyPressEvent()\n"));
}