Ejemplo n.º 1
0
static int
SDLGL_OpenVideoContext(void *obj, void *ctx, Uint flags)
{
	AG_DriverSDLGL *sgl = obj;
	AG_DriverSw *dsw = obj;
	AG_Driver *drv = obj;
	SDL_Surface *ctxSu = (SDL_Surface *)ctx;

	if (!(ctxSu->flags & SDL_OPENGL)) {
		AG_SetError("Given display surface is not SDL_OPENGL");
		return (-1);
	}

	/* Set the requested display options. */
	if (flags & AG_VIDEO_OVERLAY)
		dsw->flags |= AG_DRIVER_SW_OVERLAY;
	if (flags & AG_VIDEO_BGPOPUPMENU)
		dsw->flags |= AG_DRIVER_SW_BGPOPUP;

	/* Use the given display surface. */
	sgl->s = (SDL_Surface *)ctx;
	if ((drv->videoFmt = AG_SDL_GetPixelFormat(sgl->s)) == NULL) {
		goto fail;
	}
	dsw->w = sgl->s->w;
	dsw->h = sgl->s->h;
	dsw->depth = (Uint)drv->videoFmt->BitsPerPixel;

	Verbose(_("SDLGL: Using existing display (%ux%ux%d bpp)\n"),
	    dsw->w, dsw->h, (int)drv->videoFmt->BitsPerPixel);
	
	/* Initialize our OpenGL context and viewport. */
	if (AG_GL_InitContext(sgl, &sgl->gl) == -1) {
		goto fail;
	}
	AG_GL_SetViewport(&sgl->gl, AG_RECT(0, 0, dsw->w, dsw->h));

	/* Create the cursors. */
	if (AG_SDL_InitDefaultCursor(sgl) == -1 ||
	    AG_InitStockCursors(drv) == -1)
		goto fail;
	
	return (0);
fail:
	if (drv->videoFmt) {
		AG_PixelFormatFree(drv->videoFmt);
		drv->videoFmt = NULL;
	}
	return (-1);
}
Ejemplo n.º 2
0
int withPortFilter(Connection *Conn,PCStr(what),PCStr(proto),PCStr(method),PVStr(filter)){
	if( streq(proto,"starttls") )
	if( streq(what,"FCL") && (AccPort_Flags&(SVP_SSL|SVP_STLS)) ){
		Verbose("----PortFilter[%s] [%s][%s] -P%d/%X\n",
			what,proto,method,
			AccPort_Port,AccPort_Flags);
		strcpy(filter,"sslway");
		return 1;
	}
	if( streq(proto,"starttls") )
	if( streq(what,"FSV") && (ConnectFlags&(COF_SSL_SV)) ){
		/* MASTER=host:port/ssl */
		if( ServerFlags & (PF_SSL_ON) ){
			return 0;
		}else{
			Verbose("----PortFilter[%s] [%s][%s]\n",
				what,proto,method,ConnectFlags);
			strcpy(filter,"sslway");
			return 1;
		}
	}
	return 0;
}
Ejemplo n.º 3
0
RooFitResult * fitTo(RooAbsPdf * pdf, RooDataSet * data, RooArgSet * cons = NULL, string opt = "" )
{
	//freopen ("tmp.txt","w",stdout);

	RooFitResult * res = NULL;
	if(cons!=NULL) 
		res = pdf->fitTo(*data,PrintLevel(-1),Save(),NumCPU(2),
			ExternalConstraints(*cons),Warnings(false), Verbose(kFALSE), Minos(true));
	else
		res = pdf->fitTo(*data,PrintLevel(-1),Save(),Warnings(false),NumCPU(2), Minos(true));
	
	//freopen ("/dev/tty", "a", stdout);
	return res;
}
Ejemplo n.º 4
0
int Tracter::Unframe::ContiguousFetch(
    IndexType iIndex, int iLength, int iOffset
)
{
    assert(iIndex >= 0);

    // Limits
    int inSize = mInput->Frame().size;
    IndexType loIndex = iIndex / inSize;
    IndexType hiIndex = (iIndex + iLength) / inSize;
    int loOffset = iIndex % inSize;
    int hiOffset = (iIndex + iLength) % inSize;

    Verbose(3, "Reading %d from %d of %ld to %d of %ld\n",
            iLength, loOffset, loIndex, hiOffset, hiIndex);

    // First frame
    int nRead = 0;
    const float* ip = mInput->UnaryRead(loIndex);
    if (!ip)
        return nRead;
    float* oData = GetPointer(iOffset);
    int hi = (loIndex == hiIndex) ? hiOffset : inSize;
    for (int i=loOffset; i<hi; i++)
        oData[nRead++] = ip[i];

    // Middle frames
    for (IndexType j=loIndex+1; j<hiIndex; j++)
    {
        ip = mInput->UnaryRead(j);
        if (!ip)
            return nRead;
        for (int i=0; i<inSize; i++)
            oData[nRead++] = ip[i];
    }

    // Last frame
    if (nRead != iLength)
    {
        ip = mInput->UnaryRead(hiIndex);
        if (!ip)
            return nRead;
        for (int i=0; i<hiOffset; i++)
            oData[nRead++] = ip[i];
    }

    // Done
    assert(nRead == iLength);
    return nRead;
}
Ejemplo n.º 5
0
int pollIZ(const char *wh,double timeout,int in,int exsock){
	int rem;
	int tom = 1000;
	int to1;
	int rdy1;
	int nrdy = 0;

	Verbose("---- poll(%s) [%d][%d] %.1f ...\n",wh,in,exsock,timeout);
	if( isWindows() && readyAlways(in) ){ /* 9.9.5 for Windows */
		nrdy = 1;
		if( 0 <= exsock && !IsAlive(exsock) ){
			nrdy |= 2;
		}
	}else
	for( rem = (int)(timeout*1000); 0 < rem; rem -= to1 ){
		if( 0 <= exsock && !IsAlive(exsock) ){
			nrdy |= 2;
			break;
		}
		if( tom < rem )
			to1 = tom;
		else	to1 = rem;
		rdy1 = PollIn(in,to1);
		if( rdy1 != 0 ){
			nrdy |= 1;
		}
		Verbose("---- poll(%s) [%d][%d] %.1f %.1f rdy=%X\n",wh,
			in,exsock,timeout,rem/1000.0,nrdy);
		if( nrdy ){
			break;
		}
	}
	if( LOG_VERBOSE || (nrdy == 0) || (nrdy & 2) )
	sv1log("---- poll(%s) [%d][%d] %.1f (%.1f) rdy=%X\n",wh,
		in,exsock,timeout,rem/1000.0,nrdy);
	return nrdy;
}
Ejemplo n.º 6
0
Archivo: ip.c Proyecto: kbarber/cfng
char *
Hostname2IPString(char *hostname)
{
    static char ipbuffer[65];
    int err;

#if defined(HAVE_GETADDRINFO) && !defined(DARWIN)

    struct addrinfo query, *response, *ap;

    memset(&query,0,sizeof(struct addrinfo));
    query.ai_family = AF_UNSPEC;
    query.ai_socktype = SOCK_STREAM;

    memset(ipbuffer,0,63);

    if ((err = getaddrinfo(hostname,NULL,&query,&response)) != 0) {
        snprintf(g_output,CF_BUFSIZE,
                "Unable to lookup hostname (%s) or cfengine service: %s",
                hostname,gai_strerror(err));
        CfLog(cferror,g_output,"");
        return hostname;
    }

    for (ap = response; ap != NULL; ap = ap->ai_next) {
        strncpy(ipbuffer,sockaddr_ntop(ap->ai_addr),64);
        Debug("Found address (%s) for host %s\n",ipbuffer,hostname);

        freeaddrinfo(response);
        return ipbuffer;
    }
#else
    struct hostent *hp;
    struct sockaddr_in cin;
    memset(&cin,0,sizeof(cin));

    memset(ipbuffer,0,63);

    if ((hp = gethostbyname(hostname)) != NULL) {
        cin.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr;
        strncpy(ipbuffer,inet_ntoa(cin.sin_addr),63);
        Verbose("Found address (%s) for host %s\n",ipbuffer,hostname);
        return ipbuffer;
    }
#endif

    snprintf(ipbuffer,63,"Unknown IP %s",hostname);
    return ipbuffer;
}
Ejemplo n.º 7
0
static int ProcessDeleteOperation(AwaServerDeleteOperation * operation, const char * clientID)
{
    int result = 0;
    if (AwaServerDeleteOperation_Perform(operation, OPERATION_PERFORM_TIMEOUT) != AwaError_Success)
    {
        Error("AwaServerDeleteOperation_Perform failed\n");
        result = 1;
    }

    const AwaServerDeleteResponse * response = AwaServerDeleteOperation_GetResponse(operation, clientID);
    if (response != NULL)
    {
        AwaPathIterator * pathIterator = AwaServerDeleteResponse_NewPathIterator(response);
        if (pathIterator != NULL)
        {
            while(AwaPathIterator_Next(pathIterator))
            {
                const char * path = AwaPathIterator_Get(pathIterator);
                const AwaPathResult * result = AwaServerDeleteResponse_GetPathResult(response, path);
                AwaError error = AwaPathResult_GetError(result);
                if (error == AwaError_Success)
                {
                    Verbose("Target %s deleted\n", path);
                }
                else
                {
                    if (error != AwaError_LWM2MError)
                    {
                        Error("Failed to delete target %s: %s\n", path, AwaError_ToString(error));
                    }
                    else
                    {
                        Error("Failed to delete target %s: %s\n", path, AwaLWM2MError_ToString(AwaPathResult_GetLWM2MError(result)));
                    }
                }
            }
            AwaPathIterator_Free(&pathIterator);
        }
        else
        {
            Error("AwaServerDeleteResponse_NewPathIterator returned NULL");
        }
    }
    else
    {
        Error("AwaServerDeleteOperation_GetResponse returned NULL");
    }
    return result;
}
Ejemplo n.º 8
0
void Optimizer::summarizeTool(DFA* tool){
    std::string dirpath = logger::settings::FULL_DIR_STR;
    std::string toolDirpath = dirpath + "/" + "tool";

    if (mkdir(toolDirpath.c_str(), 0777) < 0)
        if (errno !=EEXIST) ERR("mkdir");
    stringstream ssTool;

    ssTool << "Tool Summary" << std::endl;
    ssTool << *tool;

    std::string toolFileName = toolDirpath + "/" + "dfa_tool";
    //drawing::drawDFA(*tool, toolFileName);
    logger::log(Verbose(OPTIMIZER_V), File("result.txt"), ssTool.str());
}
Ejemplo n.º 9
0
static int threadFilter(Connection *Conn,PCStr(fname),iFUNCP func,FILE *ioin,FILE *out,PCStr(args)){
	int code;
	IStr(buf,1);
	int osock;

	setthreadgid(0,STX_tid);
	osock = ClientSock;
	//ClientSock = dup(ClientSock);
	Verbose("-- F openFilter: %s [%d][%d] [%d]>>[%d]\n",
		fname, osock,ClientSock, FromS,ToC);
	// write(fileno(ioin),"\n",1); /* for sync. of thread_fork */
	PollIn(fileno(ioin),1000);

	clearConnPTR(Conn);
	code = (*func)(Conn,ioin,out,args);
	Verbose("-- F openFilter: DONE %d\n",code);
	fflush(out);
	ShutdownSocket(fileno(ioin));
	/*
	close(fth.f_sync[1]);
	*/
	sv1log("-- F openFilter: EXIT(%d) %s\n",code,fname);
	return 0;
}
Ejemplo n.º 10
0
static bool LoadDllFunctions(dllhandle_t dllhandle, const dllfunction_t *fcts, bool complain, bool has_next)
{
	const dllfunction_t *func;
	if(dllhandle)
	{
		for (func = fcts; func && func->name != NULL; func++)
			if (!(*func->funcvariable = (void *) DllGetProcAddress (dllhandle, func->name)))
			{
				if(complain)
				{
					Verbose (" - missing function \"%s\" - broken library!", func->name);
					if (has_next)
						Verbose("\nContinuing with");
				}
				goto notfound;
			}
		return true;

	notfound:
		for (func = fcts; func && func->name != NULL; func++)
			*func->funcvariable = NULL;
	}
	return false;
}
void ChangeCallback(const AwaChangeSet * changeSet, void * context)
{
    g_notifyCount++;
    Verbose("Notify %d:\n", g_notifyCount);

    const AwaClientSession * session = AwaChangeSet_GetClientSession(changeSet);
    bool quiet = *((bool*)context);

    char * output = ChangeSetToCString((void *)session, changeSet, quiet);
    if (output != NULL)
    {
        printf("%s", output);
    }
    free(output);
    output = NULL;
}
Ejemplo n.º 12
0
LONG
DrvAdvancedDocumentProperties(
    HWND        hwnd,
    HANDLE      hPrinter,
    PWSTR       pDeviceName,
    PDEVMODE    pdmOutput,
    PDEVMODE    pdmInput
    )

/*++

Routine Description:

    Set the private members of a DEVMODE structure.
    In this release, this function is almost identical to
    DrvDocumentProperties above with a few minor exceptions

[Note:]

    Please refer to WinNT DDK/SDK documentation for more details.

    This is the old entry point for the spooler. Even though
    no one should be using this, do it for compatibility.

--*/

{
    Verbose(("Entering DrvAdvancedDocumentProperties...\n"));

    //
    // Return the number of bytes required if pdmOutput is NULL
    //

    if (pdmOutput == NULL)
        return sizeof(XLDEVMODE);

    //
    // Otherwise, call the common routine shared with DrvDocumentProperties
    //

    return PsDocumentProperties(hwnd,
                                hPrinter,
                                pDeviceName,
                                pdmOutput,
                                pdmInput,
                                DM_COPY|DM_PROMPT|DM_ADVANCED) > 0;
}
Ejemplo n.º 13
0
void ObserveCallback(const AwaChangeSet * changeSet, void * context)
{
    Verbose("Notify %d from clientID %s:\n", g_notifyCount, AwaChangeSet_GetClientID(changeSet));
    const AwaServerSession * session = AwaChangeSet_GetServerSession(changeSet);
    ObserveContext * observeContext = (ObserveContext *)context;

    char * output = ChangeSetToCString(session, changeSet, observeContext->targets, observeContext->numTargets, observeContext->quiet);
    if (output != NULL)
    {
        printf("%s", output);
        // Provide output immediately
        fflush(stdout);
    }
    free(output);
    output = NULL;
    g_notifyCount++;
}
Ejemplo n.º 14
0
  void RegionMerger::mergeQueuedRegions(int desiredCount){

    while((int)regionList.size()>desiredCount){
      if(Verbose()>1 && (regionList.size()<100 || currentTime%100==0))
 	cout <<"region count:" << regionList.size() 
	      	     << " queue size: " << queue_vector.size() << endl; 

      if(clearThreshold>0 && queue_vector.size() > 
	 (size_t)clearThreshold*regionList.size())
	fillPriorityQueue();

      mergeTopRegions();


      
    }
  }
Ejemplo n.º 15
0
Tracter::Select::Select(Component<float>* iInput, const char* iObjectName)
{
    mObjectName = iObjectName;
    mInput = iInput;

    mLoIndex = GetEnv("Lo", 0);
    mHiIndex = GetEnv("Hi", iInput->Frame().size-1);

    mFrame.size = mHiIndex - mLoIndex + 1;
    assert(mFrame.size >= 0);
    assert(mHiIndex < iInput->Frame().size);
    assert(mLoIndex >= 0);
    Verbose(1, "passing indexes %d-%d of %d\n",
            mLoIndex, mHiIndex, iInput->Frame().size);

    Connect(iInput, 1);
}
Ejemplo n.º 16
0
/**************************************************************************************************
	DB_CONNECT
	Connect to the database.
**************************************************************************************************/
void
db_connect(void)
{
  const char *user = conf_get(&Conf, "db-user", NULL);
  const char *host = conf_get(&Conf, "db-host", NULL);
  const char *database = conf_get(&Conf, "database", NULL);
  const char *password = conf_get(&Conf, "db-password", NULL);

  /* If db- vars aren't present, try mysql- for backwards compatibility */
  if (!user) user = conf_get(&Conf, "mysql-user", NULL);
  if (!host) host = conf_get(&Conf, "mysql-host", NULL);
  if (!password) password = conf_get(&Conf, "mysql-password", NULL);
  if (!password) password = conf_get(&Conf, "mysql-pass", NULL);

  sql_open(user, password, host, database);
  Verbose(_("connected to %s, database \"%s\""), host, database);
}
Ejemplo n.º 17
0
void
DoSignals(struct Process *pp,struct Item *list)
{
    struct Item *ip;
    pid_t pid;
    int ret;

    Verbose("DoSignals(%s)\n",pp->expr);

    if (list == NULL) {
        return;
    }

    if (pp->signal == cfnosignal) {
        snprintf(g_output,CF_BUFSIZE,"No signal to send for %s\n",pp->expr);
        CfLog(cfinform,g_output,"");
        return;
    }

    for (ip = list; ip != NULL; ip=ip->next) {
        pid = (pid_t)-1;

        sscanf(ip->name,"%d",&pid);

        if (pid == (pid_t)-1) {
            CfLog(cferror,"Software error: Unable to decypher pid list","");
            return;
        }

        if (!g_dontdo) {
            if ((ret = kill((pid_t)pid,pp->signal)) < 0) {
                snprintf(g_output,CF_BUFSIZE*2,
                    "Couldn't send signal to pid %d\n",pid);
                CfLog(cfverbose,g_output,"kill");

                return;
            }

            if ((pp->signal == cfkill || pp->signal == cfterm) && ret >= 0) {
                snprintf(g_output,CF_BUFSIZE*2,"Killed: %s\n",ip->name);
                CfLog(cfinform,g_output,"");
            }
        }
    }
}
Ejemplo n.º 18
0
static void
SDLGL_CaptureOutput(AG_DriverSDLGL *sgl)
{
	char path[AG_PATHNAME_MAX];
	AG_DriverSw *dsw = (AG_DriverSw *)sgl;
	AG_Surface *s;

	Snprintf(path, sizeof(path), sgl->outPath, sgl->outFrame);
	glReadPixels(0, 0, dsw->w, dsw->h, GL_RGBA, GL_UNSIGNED_BYTE,
	    sgl->outBuf);

	if (AG_PackedPixelFlip(sgl->outBuf, dsw->h, dsw->w*4) == -1) {
		goto fail_disable;
	}
	s = AG_SurfaceFromPixelsRGBA(sgl->outBuf,
	    dsw->w, dsw->h, 32,
	    0x000000ff, 0x0000ff00, 0x00ff0000, 0);
	if (s == NULL)
		goto fail;

	switch (sgl->outMode) {
	case AG_SDLGL_OUT_JPEG:
		if (AG_SurfaceExportJPEG(s, path) == -1) {
			goto fail;
		}
		break;
	case AG_SDLGL_OUT_PNG:
		if (AG_SurfaceExportPNG(s, path) == -1) {
			goto fail;
		}
		break;
	}

	if (++sgl->outFrame == sgl->outLast) {
		Verbose("Reached last frame; terminating\n");
		AG_Terminate(0);
	}
	AG_SurfaceFree(s);
	return;
fail:
	AG_SurfaceFree(s);
fail_disable:
	AG_Verbose("%s; disabling capture\n", AG_GetError());
	sgl->outMode = AG_SDLGL_OUT_NONE;
}
Ejemplo n.º 19
0
int willSTLS_CL(Connection *Conn){
	if( Conn->from_myself ){
		Verbose("## STLS ## no client %X [%d/%d/%d] %X %s:%d\n",
			Conn->from_myself,ClientSock,FromC,ToC,
			ClientFlags,Client_Host,Client_Port);
		return 0;
	}
	if( (ClientFlags & PF_STLS_CHECKED) == 0 ){
		CTX_pushClientInfo(Conn);
		checkWithSTLS(Conn,"FCL",CLNT_PROTO,"");

		if( (ClientFlags & PF_STLS_OPT) == 0 )
		if( ClientFlags & PF_STLS_DO )
		if( 0 < STLS_implicit_wait )
		if( STLS_wait_set == 0 )
		if( STLS_implicit_wait < 10 )
		if( strcaseeq(CLNT_PROTO,"tcprelay")
		 || strcaseeq(CLNT_PROTO,"https")
		){
			waitSTLS_CL(Conn,(int)((8-STLS_implicit_wait)*1000));
		}

		if( ClientFlags & PF_STLS_DO )
		if( 0 < STLS_implicit_wait )
			waitSTLS_CL(Conn,(int)(STLS_implicit_wait*1000));
		/*
		if( 0 < PollIn(ClientSock,(int)(STLS_implicit_wait*1000)) )
		if( isinSSL(ClientSock) ){
			int fcl;
			fcl = insertFCLX(Conn,"starttls",CLNT_PROTO,FromC,ToS);
			syslog_ERROR("## STLS ## IMPLICIT SSL ON %d,%d,%d,%d\n",
				ClientSock,FromC,ToC,fcl);
			if( 0 <= fcl ){
				dup2(fcl,FromC);
				close(fcl);
				ClientFlags |= PF_STLS_ON;
			}
		}
		*/
                HL_popClientInfo(); 
	}
	if( ClientFlags & PF_STLS_ON )
		return 0;
	return ClientFlags & PF_STLS_DO;
}
Ejemplo n.º 20
0
LONG
DrvDocumentProperties(
    HWND        hwnd,
    HANDLE      hPrinter,
    PWSTR       pDeviceName,
    PDEVMODE    pdmOutput,
    PDEVMODE    pdmInput,
    DWORD       fMode
    )

/*++

Routine Description:

    Set the public members of a DEVMODE structure for a print document

[Note:]

    Please refer to WinNT DDK/SDK documentation for more details.

    This is the old entry point for the spooler. Even though
    no one should be using this, do it for compatibility.

--*/

{
    LONG    result;

    Verbose(("Entering DrvDocumentProperties...\n"));

    //
    // Check if caller is asking querying for size
    //

    if (fMode == 0 || pdmOutput == NULL)
        return sizeof(XLDEVMODE);

    //
    // Call the common routine shared with DrvAdvancedDocumentProperties
    //

    result = PsDocumentProperties(hwnd, hPrinter, pDeviceName, pdmOutput, pdmInput, fMode);

    return (result > 0) ? IDOK : (result == 0) ? IDCANCEL : result;
}
Ejemplo n.º 21
0
static DECLSPEC_NOINLINE VOID
__DriverParseParameterKey(
    )
{
    NTSTATUS    Status;
    PWCHAR      Options;
    PWCHAR      Value;

    // Set default parameters
    DriverParameters.SynthesizeInquiry = FALSE;
    DriverParameters.PVCDRom           = FALSE;

    // attempt to read registry for system start parameters
    Status = __DriverGetSystemStartParams(&Options);
    if (NT_SUCCESS(Status)) {
        Trace("Options = \"%ws\"\n", Options);

        // check each option
        if (__DriverGetOption(Options, L"XENVBD:SYNTH_INQ=", &Value)) {
            // Value may be NULL (it shouldnt be though!)
            if (Value) {
                if (wcscmp(Value, L"ON") == 0) {
                    DriverParameters.SynthesizeInquiry = TRUE;
                }
                __FreePoolWithTag(Value, XENVBD_POOL_TAG);
            }
        }

        if (__DriverGetOption(Options, L"XENVBD:PVCDROM=", &Value)) {
            // Value may be NULL (it shouldnt be though!)
            if (Value) {
                if (wcscmp(Value, L"ON") == 0) {
                    DriverParameters.PVCDRom = TRUE;
                }
                __FreePoolWithTag(Value, XENVBD_POOL_TAG);
            }
        }

        __FreePoolWithTag(Options, XENVBD_POOL_TAG);
    }

    Verbose("DriverParameters: %s%s\n", 
            DriverParameters.SynthesizeInquiry ? "SYNTH_INQ " : "",
            DriverParameters.PVCDRom ? "PV_CDROM " : "");
}
Ejemplo n.º 22
0
bool Tracter::Energy::UnaryFetch(IndexType iIndex, float* oData)
{
    assert(iIndex >= 0);

    // Read the input frame
    const float* p = mInput->UnaryRead(iIndex);
    if (!p)
        return false;

    // Calculate energy
    *oData = 0.0f;
    for (int i=0; i<mInput->Frame().size; i++)
        *oData += p[i] * p[i];

    // Done
    Verbose(4, "plot %ld %e\n", iIndex, 10.0*log10(*oData));
    return true;
}
Ejemplo n.º 23
0
/**
 * A Fetch() wrapper.  Read() will call this rather blindly.  Here we
 * take care of the EOD flag, preventing unnecessary reads past EOD.
 * This way, components only need to return EOD once.
 *
 * A Read() will never actually pass on a request past EOD to the
 * Fetch() because, in finding out EOD is reached, data up until then
 * should have been read (TODO: unless it's non-contiguous, but we can
 * deal with that with a flag later).  So, if EOD is set, all requests
 * here will be after it.
 */
Tracter::SizeType
Tracter::ComponentBase::FetchWrapper(
    IndexType iIndex, CacheArea& iOutputArea
)
{
    /*
     */
    if ((mEndOfData >= 0) && (iIndex >= mEndOfData))
        return 0;

    SizeType len = Fetch(iIndex, iOutputArea);
    if (len < iOutputArea.Length())
    {
        mEndOfData = iIndex + len;
        Verbose(2, "EOD at index %lld, got %d of %d\n",
                mEndOfData, len, iOutputArea.Length());
    }
    return len;
}
Ejemplo n.º 24
0
void drvPDF::show_path()
{
	// add_to_page(); // is done in drvbase !! 
	endtext();					// close text if open
	const char *setrgbcolor = 0;
	const char *drawingop = 0;
	switch (currentShowType()) {
	case drvbase::stroke:
		// it's a stroke
		drawingop = "S";
		setrgbcolor = "RG";
		break;
	case drvbase::fill:
		drawingop = "f";
		setrgbcolor = "rg";
		break;
	case drvbase::eofill:
		drawingop = "f*";
		setrgbcolor = "rg";
		break;
	default:
		// cannot happen
		errf << "unexpected ShowType " << (int) currentShowType() << endl;
		exit(1);
		break;
	}
//    buffer.precision(3);
//    buffer.setf(ios::fixed);
//    buffer.width(0); // to force minimal width
//    buffer.unsetf(ios::showpoint);

	if (Verbose()) {
		buffer << "% path " << currentNr() << endl;
	}
	buffer << RND3(currentR()) << " " << RND3(currentG()) << " " <<
		RND3(currentB()) << " " << setrgbcolor << endl;
	buffer << currentLineWidth() << " w" << endl;
	buffer << currentLineCap() << " J" << endl;
	buffer << currentLineJoin() << " j" << endl;
	buffer << dashPattern() << " d" << endl;
	print_coords();
	buffer << drawingop << endl;
}
Ejemplo n.º 25
0
	/*
	 *  Load the .MAP file into memory and make the elements available
	 *    for later access
	 */
	void CPlinkMapFile::Load()
	{
		Verbose("                  Loading .MAP file: [%s]", filename.c_str());
		CTimer timer(true);
		MapRecord mr;              // the working storage
		CToken tok;
		CPlinkLexer lex(filename);

		lex.NextToken(tok);
		while (tok.type != tokEOF)        // for each line until EOF
		{
			if (tok.type == tokEOL)        // blank line...or comment line or ???
			{
				lex.NextToken(tok);
				continue;
			}

			lex.ExpectChromosome(tok, mr.snpInfo.idChromosome, mr.snpInfo.iChromosome);
			lex.ExpectId(tok, mr.snpInfo.idSnp, "SNP Id");
			lex.ExpectReal(tok, mr.snpInfo.geneticDistance, "Genetic Distance");
			lex.ExpectInt(tok, mr.snpInfo.basepairPosition, "Basepair Position");
			if (tok.type != tokEOL)
			{
				Fatal("Expecting <EOL> after Basepair Position at line %d:%d.  Found [%s]", tok.line, tok.column, tok.text.c_str());
			}

			lex.NextToken(tok);      // consume the <EOL>
			mr.snpInfo.majorAllele = '\0';
			mr.snpInfo.minorAllele = '\0';

			// Validate we have a unique SNP id and add it to the map
			if (idSnpToSnpInfoIndex.count(mr.snpInfo.idSnp))
			{
				Fatal("Duplicate SNP Id %s found in SNPs %d and %d", mr.snpInfo.idSnp.c_str(), idSnpToSnpInfoIndex[mr.snpInfo.idSnp] + 1, rgMapRecords.size() + 1);
			}

			idSnpToSnpInfoIndex[mr.snpInfo.idSnp] = rgMapRecords.size();
			rgMapRecords.push_back(mr);
		}

		timer.Stop();
		timer.Report(0x02, "     Loading .MAP file elapsed time: %s");
	}
Ejemplo n.º 26
0
Bool OptimizeLoops(Var * proc)
/*
Purpose:
	Find loops in flow graph and call optimization for it.
*/
{
	Loop loop;
	InstrBlock * nb, * header;
	Bool modified = false;

	MarkLoops(proc);

	if (Verbose(proc)) {
		PrintHeader(3, "Optimize loops");
		PrintProc(proc);
	}


	for(nb = proc->instr; nb != NULL; nb = nb->next) {
		header = NULL;

		if (nb->jump_type == JUMP_LOOP) {
			header = nb->cond_to;
			if (header == NULL) header = nb->to;
		}
//		if (nb->cond_to != NULL && nb->cond_to->loop_end == nb) header = nb->cond_to;
//		if (nb->to != NULL && nb->to->loop_end == nb) header = nb->to;

		if (header != NULL) {
//			if (Verbose(proc)) {
//				Print("*** Loop %d..%d\n", header->seq_no, nb->seq_no);
//			}
			loop.header = header;
			loop.end    = nb;
//			OptimizeLoopInvariants(proc, &loop);
			modified |= OptimizeLoop(proc, header, nb);
		}

	}

	return modified;
}
void ExecuteCallback(const AwaExecuteArguments * arguments, void * context)
{
    g_notifyCount++;
    Verbose("Execute %d:\n", g_notifyCount);

    if ((arguments != NULL) && (arguments->Data != NULL) && (arguments->Size > 0))
    {
        int i;
        printf("DATA: length %zu, payload: [", arguments->Size);
        for (i = 0; i < arguments->Size; i++)
        {
            printf("%02x ", ((uint8_t *)arguments->Data)[i]);
        } 
        printf("]\n");
    }
    else
    {
        printf("NO DATA\n");
    }
}
Ejemplo n.º 28
0
/**
 * Connects to the specified IP address/port. 
 * Both port and IP address are in host byte order
 */
Bool SOCKET_Connect(Socket s, IPaddr ipaddr, Port port)
{
    int err;
    struct sockaddr_in sa;

    /* initialize sockaddr_in */
    memset(&sa, 0, sizeof(sa));
    sa.sin_family = AF_INET;
    sa.sin_port = htons(port);
    sa.sin_addr.s_addr = htonl(ipaddr);

    /* connect */
    err = connect(s,(struct sockaddr*)&sa,sizeof(sa));
    if (err) {
        Verbose(TEXT("ERROR: cannot connect to ") TEXT(IPADDR_FORMAT) 
                TEXT(":%hu\n"), HOST_IPADDR_FORMAT_ARG(ipaddr), port);   
        return False;
    } else {
        return True;
    }
}
Ejemplo n.º 29
0
PMPD
LoadMpdFile(
    HANDLE      hPrinter
    )

/*++

Routine Description:

    Load printer description data into memory

Arguments:

    hPrinter - Specifies the printer we're interested in

Return Value:

    Pointer to printer description data, NULL if there is an error

--*/

{
    PMPD            pmpd = NULL;
    PDRIVER_INFO_2  pDriverInfo2 = NULL;

    //
    // Get the name of the driver data file and
    // load printer description data into memory
    //

    if (pDriverInfo2 = MyGetPrinterDriver(hPrinter, 2)) {

        Verbose(("Printer data file: %ws\n", pDriverInfo2->pDataFile));

        pmpd = MpdCreate(pDriverInfo2->pDataFile);
        MemFree(pDriverInfo2);
    }

    return pmpd;
}
Ejemplo n.º 30
0
static void AddTarget(AwaServerExecuteOperation * operation, const char * clientID, const Target * target, AwaExecuteArguments * args)
{
    if (operation != NULL)
    {
        if (target != NULL)
        {
            Verbose("Execute %s\n", target->Path);
            if (AwaServerExecuteOperation_AddPath(operation, clientID, target->Path, args) != AwaError_Success)
            {
                Error("AwaServerGetOperation_AddPath failed\n");
            }
        }
        else
        {
            Error("target is NULL\n");
        }
    }
    else
    {
        Error("operation is NULL\n");
    }
}