コード例 #1
0
ファイル: gbucket.c プロジェクト: DevSlashNull/GameSpy
void *BucketAdd(bucketset_t set, char *name, void *value)
{
	bucket_t *pbucket = DoFind(set, name);	
	if (!pbucket)
		return NULL;

	if (pbucket->type == bt_int)
		return DoSet(pbucket, bint( (*(int *)DoGet(pbucket)) + (*(int *)value)));
	if (pbucket->type == bt_float)
		return DoSet(pbucket, bfloat( (*(double *)DoGet(pbucket)) + (*(double *)value)));
	//else, string -- just concat
	return BucketConcat(set, name, value);
}
コード例 #2
0
ファイル: gbucket.c プロジェクト: DevSlashNull/GameSpy
void *BucketAvg(bucketset_t set, char *name, void *value)
{
	bucket_t *pbucket = DoFind(set, name);	
	if (!pbucket)
		return NULL;
	
	if (pbucket->type == bt_int)
		return DoSet(pbucket, bint( AVG((*(int *)DoGet(pbucket)), (*(int *)value), pbucket->nvals)));
	if (pbucket->type == bt_float)
		return DoSet(pbucket, bfloat( AVG((*(double *)DoGet(pbucket)), (*(double *)value), pbucket->nvals)));
	//else, string -- just  ignore
	return DoGet(pbucket);
}
コード例 #3
0
ファイル: Get.c プロジェクト: aosm/ncftp
int DoGetWithGlobbingAndRecursion(GetOptionsPtr gopt)
{
	int err;
	LineList globFiles;
	LinePtr globFile;
	char *cp;
	int fType;
	int result;
	longstring rcwd;
		
	err = 0;
	InitLineList(&globFiles);
	RemoteGlob(&globFiles, gopt->rName, kListNoFlags);
	
	for (globFile = globFiles.first; globFile != NULL;
		globFile = globFile->next)
	{
		if (gXferAbortFlag == SIGINT)
			break;	/* Don't get rest of files if you interrupted. */
		if (gopt->recursive) {
			fType = RemoteFileType(globFile->line);
			if (fType == 'd') {
				if ((cp = strrchr(globFile->line, '/')) != NULL) {
					/* If the user said something like
					 * "get -R /pub/a/b/c/d" we want to just write the
					 * contents of the 'd' as a subdirectory of the local
					 * directory, and not create ./pub, ./pub/a, etc.
					 */
					STRNCPY(rcwd, gRemoteCWD);
					*cp++ = '\0';
					if (DoChdir(globFile->line) == 0) {
						GetDir(gopt, cp, gRemoteCWD, gLocalCWD);
					}
					/* Restore the directory we were in before. */
					(void) DoChdir(rcwd);
				} else {
					/* Otherwise, the user gave a simple path, so it was
					 * something like "get -R pub"
					 */
					GetDir(gopt, globFile->line, gRemoteCWD, gLocalCWD);
				}
			} else if (fType == 'l') {
				EPrintF("Ignoring symbolic link '%s'\n",
					globFile->line);
			} else if (fType == '-') {
				goto regFile;
			}
		} else {
regFile:
			gopt->rName = globFile->line;
			gopt->lName = NULL;	/* Make it later. */
			result = DoGet(gopt);
			if (result < 0)
				err = -1;
		}
	}
	DisposeLineListContents(&globFiles);
	
	return (err);
}	/* DoGetWithGlobbingAndRecursion */
コード例 #4
0
ファイル: lunxun.c プロジェクト: jsvisa/apue
int DealRequest(int sock, char *buf) {
	int ret = 0;
	printf("Deal Request\n");
	if(strncasecmp(buf, "login", 5) != 0 && logined != 1) {
		msend(sock, "401 Please login first\r\n");
		return -1;
	}

	if(strncasecmp(buf, "list", 4) == 0) {
		ret = DoList(sock, buf);
	}
	else if(strncasecmp(buf, "cd", 2) == 0) {
		ret = DoChdir(sock, buf);
	}
	else if(strncasecmp(buf, "login", 5) == 0) {
		ret = DoLogin(sock, buf);
	}
	else if(strncasecmp(buf, "get", 3) == 0) {
		ret = DoGet(sock, buf);
	}
	else if(strncasecmp(buf, "quit", 4) == 0) {
		ret = DoQuit(sock, buf);
	}
	else {
		printf("Unknown Request:%s\n", buf);
		msend(sock, "400 Unknown command\r\n");
	}
	return ret;

}
コード例 #5
0
ファイル: processmanager.cpp プロジェクト: wuqiong4945/memu
void MyPipeFrame::OnBtnSendFile(wxCommandEvent& WXUNUSED(event))
{
#if wxUSE_FILEDLG
	wxFileDialog filedlg(this, wxT("Select file to send"));
	if ( filedlg.ShowModal() != wxID_OK )
		return;

	wxFFile file(filedlg.GetFilename(), wxT("r"));
	wxString data;
	if ( !file.IsOpened() || !file.ReadAll(&data) )
		return;

	// can't write the entire string at once, this risk overflowing the pipe
	// and we would dead lock
	size_t len = data.length();
	const wxChar *pc = data.c_str();
	while ( len )
	{
		const size_t CHUNK_SIZE = 4096;
		m_out.Write(pc, len > CHUNK_SIZE ? CHUNK_SIZE : len);

		// note that not all data could have been written as we don't block on
		// the write end of the pipe
		const size_t lenChunk = m_out.LastWrite();

		pc += lenChunk;
		len -= lenChunk;

		DoGet();
	}
#endif // wxUSE_FILEDLG
}
コード例 #6
0
void
BuildingListPriv::Delete (void)
{
  NS_LOG_FUNCTION_NOARGS ();
  Config::UnregisterRootNamespaceObject (Get ());
  (*DoGet ()) = 0;
}
コード例 #7
0
ファイル: gbucket.c プロジェクト: DevSlashNull/GameSpy
void *BucketConcat(bucketset_t set, char *name, void *value)
{
	bucket_t *pbucket = DoFind(set, name);	
	char *temp, *s;
	if (!pbucket)
		return NULL;

	assert(pbucket->type == bt_string);
	s = DoGet(pbucket);
	temp = (char *)gsimalloc(strlen(s) + strlen(value) + 1);
	strcpy(temp,s);
	strcat(temp, value);

	DoSet(pbucket, temp);
	gsifree(temp);
	
	return DoGet(pbucket);
}
コード例 #8
0
ファイル: processmanager.cpp プロジェクト: wuqiong4945/memu
void MyPipeFrame::OnProcessTerm(wxProcessEvent& WXUNUSED(event))
{
	DoGet();

	wxDELETE(m_process);

	wxLogWarning(wxT("The other process has terminated, closing"));

	DisableInput();
	DisableOutput();
}
コード例 #9
0
/**
Searches the cache for the particular recognition result. If the file was not modified since the
file was recognized, the stored recognition result is returned.

N.B. The returned value is reference counted!
@internalComponent
*/
CRecognitionResult* CApsRecognitionCache::Get(const RFile& aFile, const TDesC& aDirectory, const TDesC& aFileName)
	{	
	TTime lastModified;
	const TInt error = aFile.Modified(lastModified);
	if(error != KErrNone)
		{
		return NULL;
		}

	return DoGet(aDirectory, aFileName, lastModified);
	}
コード例 #10
0
ファイル: gbucket.c プロジェクト: DevSlashNull/GameSpy
static void *DoSet(bucket_t *pbucket, void *value)
{
	if (pbucket->type == bt_int)
		pbucket->vals.ival = *(int*)value;
	else if (pbucket->type == bt_float)
		pbucket->vals.fval = *(double *)value;
	else if (pbucket->type == bt_string)
	{
		if (pbucket->vals.sval != NULL)
			gsifree(pbucket->vals.sval);
		pbucket->vals.sval = (value == NULL ? NULL : stripchars(goastrdup((char *)value)));
	}
	return DoGet(pbucket);
}
コード例 #11
0
ファイル: gbucket.c プロジェクト: DevSlashNull/GameSpy
void *BucketNew(bucketset_t set, char *name, BucketType type, void *initialvalue)
{
	bucket_t bucket;

	if (set == NULL)
		set = g_buckets;
	assert(set);
	bucket.name = goastrdup(name);
	bucket.type = type;
	bucket.vals.sval = NULL;
	bucket.nvals = 1;
	DoSet(&bucket, initialvalue);
	TableEnter(set->buckets,&bucket);
	return DoGet(DoFind(set, name));
}
コード例 #12
0
I_IStream& Binary_Stream::get(
	void* 		inBuffer, 
	vuint32 		inHowMuch )
{
	char *p = (char *)inBuffer;
	mLastCount = 0;

	vuint32 read = GetWBack(inBuffer, inHowMuch);
	for( ;; )
	{
/*		if( (vint32)inHowMuch - (vint32)read < 0l )
		{
			int i = 1;
			i;
		}*/

		inHowMuch -= read;
		mLastCount += read;
		p += read;

		if ( !inHowMuch )
		{
			// we read the requested amount of data
			break;
		}

		if ( p != inBuffer && !CanRead() )
		{
			// we have already read something and we would block in DoGet()
			// now: don't do it but return immediately
			break;
		}

		read = DoGet(p, inHowMuch);
		if ( !read )
		{
			// no more data available
			break;
		}
	}

	return * (I_IStream*) this;
}
コード例 #13
0
/**
Searches the cache for the particular recognition result. If the file was not modified since the
file was recognized, the stored recognition result is returned.
@internalComponent
*/
TBool CApsRecognitionCache::Get(const TDesC& aDirectory, const TDesC& aFileName, TDataRecognitionResult& aRecognitionResult)
	{
	TTime lastModified;
	TFileName fileName(aDirectory);
	fileName.Append(aFileName);
	const TInt error = iFs.Modified(fileName, lastModified);
	if(error != KErrNone) 
		{
		return EFalse;
		}

	CRecognitionResult* result = DoGet(aDirectory, aFileName, lastModified);
	if(result)
		{
		result->Get(aRecognitionResult);
		result->Close(); // decrease reference count since we're not exposing the object
		return ETrue;
		}
	return EFalse;
	}
コード例 #14
0
ファイル: Get.c プロジェクト: aosm/ncftp
/* Fetch one or more remote files. */
int GetCmd(int argc, char **argv)
{
	int i, result, errs;
	GetOptions gopt;
	
	
	if (GetGetOptions(argc, argv, &gopt) == kUsageErr)
		return (kUsageErr);
		
	argv += gOptInd;
	argc -= gOptInd;
	errs = 0;

	if (gopt.noGlob || gopt.saveAs) {
		for (i=0; i<argc; i++) {
			gopt.rName = argv[i];
			if (gopt.saveAs) {
				if (++i < argc)
					gopt.lName = argv[i];	/* Use this name. */
				else
					return (kUsageErr);
			} else {
				gopt.lName = NULL;	/* Make it later. */
			}
			result = DoGet(&gopt);
			if (gXferAbortFlag == SIGINT)
				break;	/* Don't get rest of files if you interrupted. */
			if (result < 0)
				--errs;
		}
	} else {
		for (i=0; i<argc; i++) {
			gopt.rName = argv[i];
			errs += DoGetWithGlobbingAndRecursion(&gopt);
			if (gXferAbortFlag == SIGINT)
				break;	/* Don't get rest of files if you interrupted. */
		}
	}
	
	return (errs);
}	/* GetCmd */
コード例 #15
0
void dng_image::Get (dng_pixel_buffer &buffer,
					 edge_option edgeOption,
				     uint32 repeatV,
				     uint32 repeatH) const
	{
	
	// Find the overlap with the image bounds.
	
	dng_rect overlap = buffer.fArea & fBounds;
	
	// Move the overlapping pixels.
	
	if (overlap.NotEmpty ())
		{
	
		dng_pixel_buffer temp (buffer);
		
		temp.fArea = overlap;
		
		temp.fData = buffer.DirtyPixel (overlap.t,
								   		overlap.l,
								   		buffer.fPlane);
	
		DoGet (temp);
		
		}
		
	// See if we need to pad the edge values.
	
	if ((edgeOption != edge_none) && (overlap != buffer.fArea))
		{
		
		dng_rect areaT (buffer.fArea);
		dng_rect areaL (buffer.fArea);
		dng_rect areaB (buffer.fArea);
		dng_rect areaR (buffer.fArea);
		
		areaT.b = Min_int32 (areaT.b, fBounds.t);
		areaL.r = Min_int32 (areaL.r, fBounds.l);
		areaB.t = Max_int32 (areaB.t, fBounds.b);
		areaR.l = Max_int32 (areaR.l, fBounds.r);
		
		dng_rect areaH (buffer.fArea);
		dng_rect areaV (buffer.fArea);
		
		areaH.l = Max_int32 (areaH.l, fBounds.l);
		areaH.r = Min_int32 (areaH.r, fBounds.r);
		
		areaV.t = Max_int32 (areaV.t, fBounds.t);
		areaV.b = Min_int32 (areaV.b, fBounds.b);
		
		// Top left.
		
		dng_rect areaTL = areaT & areaL;
		
		if (areaTL.NotEmpty ())
			{
			
			GetEdge (buffer,
					 edgeOption,
					 dng_rect (fBounds.t,
					 		   fBounds.l,
					 		   fBounds.t + (int32)repeatV,
					 		   fBounds.l + (int32)repeatH),
					 areaTL);
			
			}
			
		// Top middle.
		
		dng_rect areaTM = areaT & areaH;
		
		if (areaTM.NotEmpty ())
			{
			
			GetEdge (buffer,
					 edgeOption,
					 dng_rect (fBounds.t,
					 		   areaTM.l,
					 		   fBounds.t + (int32)repeatV,
					 		   areaTM.r),
					 areaTM);
			
			}
		
		// Top right.
		
		dng_rect areaTR = areaT & areaR;
		
		if (areaTR.NotEmpty ())
			{
			
			GetEdge (buffer,
					 edgeOption,
					 dng_rect (fBounds.t,
					 		   fBounds.r - (int32)repeatH,
					 		   fBounds.t + (int32)repeatV,
					 		   fBounds.r),
					 areaTR);
			
			}
			
		// Left middle.
		
		dng_rect areaLM = areaL & areaV;
		
		if (areaLM.NotEmpty ())
			{
			
			GetEdge (buffer,
					 edgeOption,
					 dng_rect (areaLM.t,
					 		   fBounds.l,
					 		   areaLM.b,
					 		   fBounds.l + (int32)repeatH),
					 areaLM);
			
			}
		
		// Right middle.
		
		dng_rect areaRM = areaR & areaV;
		
		if (areaRM.NotEmpty ())
			{
			
			GetEdge (buffer,
					 edgeOption,
					 dng_rect (areaRM.t,
					 		   fBounds.r - (int32)repeatH,
					 		   areaRM.b,
					 		   fBounds.r),
					 areaRM);
			
			}
		
		// Bottom left.
		
		dng_rect areaBL = areaB & areaL;
		
		if (areaBL.NotEmpty ())
			{
			
			GetEdge (buffer,
					 edgeOption,
					 dng_rect (fBounds.b - (int32)repeatV,
					 		   fBounds.l,
					 		   fBounds.b,
					 		   fBounds.l + (int32)repeatH),
					 areaBL);
			
			}
			
		// Bottom middle.
		
		dng_rect areaBM = areaB & areaH;
		
		if (areaBM.NotEmpty ())
			{
			
			GetEdge (buffer,
					 edgeOption,
					 dng_rect (fBounds.b - (int32)repeatV,
					 		   areaBM.l,
					 		   fBounds.b,
					 		   areaBM.r),
					 areaBM);
			
			}
		
		// Bottom right.
		
		dng_rect areaBR = areaB & areaR;
		
		if (areaBR.NotEmpty ())
			{
			
			GetEdge (buffer,
					 edgeOption,
					 dng_rect (fBounds.b - (int32)repeatV,
					 		   fBounds.r - (int32)repeatH,
					 		   fBounds.b,
					 		   fBounds.r),
					 areaBR);
			
			}
			
		}
	
	}
コード例 #16
0
void dng_image::GetRepeat (dng_pixel_buffer &buffer,
				           const dng_rect &srcArea,
				           const dng_rect &dstArea) const
	{
	
	// If we already have the entire srcArea in the
	// buffer, we can just repeat that.
	
	if ((srcArea & buffer.fArea) == srcArea)
		{
		
		buffer.RepeatArea (srcArea,
						   dstArea);
		
		}
		
	// Else we first need to get the srcArea into the buffer area.
	
	else
		{
		
		// Find repeating pattern size.
		
		dng_point repeat = srcArea.Size ();
		
		// Find pattern phase at top-left corner of destination area.
		
		dng_point phase = dng_pixel_buffer::RepeatPhase (srcArea,
													     dstArea);
			
		// Find new source area at top-left of dstArea.
		
		dng_rect newArea = srcArea + (dstArea.TL () -
								      srcArea.TL ());
										 
		// Find quadrant split coordinates.
		
		int32 splitV = newArea.t + repeat.v - phase.v;
		int32 splitH = newArea.l + repeat.h - phase.h;
			
		// Top-left quadrant.
		
		dng_rect dst1 (dng_rect (newArea.t,
					   			 newArea.l,
					   			 splitV,
					   			 splitH) & dstArea);
					    
		if (dst1.NotEmpty ())
			{
			
			dng_pixel_buffer temp (buffer);
			
			temp.fArea = dst1 + (srcArea.TL () -
								 dstArea.TL () +
								 dng_point (phase.v, phase.h));
			
			temp.fData = buffer.DirtyPixel (dst1.t,
									        dst1.l,
									        buffer.fPlane);
									        
			DoGet (temp);
			
			}
			
		// Top-right quadrant.
		
		dng_rect dst2 (dng_rect (newArea.t,
								 splitH,
								 splitV,
								 newArea.r) & dstArea);
								 
		if (dst2.NotEmpty ())
			{
			
			dng_pixel_buffer temp (buffer);
			
			temp.fArea = dst2 + (srcArea.TL () -
								 dstArea.TL () +
								 dng_point (phase.v, -phase.h));
			
			temp.fData = buffer.DirtyPixel (dst2.t,
									        dst2.l,
									        buffer.fPlane);
									        
			DoGet (temp);
			
			}
			
		// Bottom-left quadrant.
		
		dng_rect dst3 (dng_rect (splitV,
								 newArea.l,
								 newArea.b,
								 splitH) & dstArea);
								 
		if (dst3.NotEmpty ())
			{
			
			dng_pixel_buffer temp (buffer);
			
			temp.fArea = dst3 + (srcArea.TL () -
								 dstArea.TL () +
								 dng_point (-phase.v, phase.h));
			
			temp.fData = buffer.DirtyPixel (dst3.t,
									        dst3.l,
									        buffer.fPlane);
									        
			DoGet (temp);
			
			}
			
		// Bottom-right quadrant.
		
		dng_rect dst4 (dng_rect (splitV,
								 splitH,
								 newArea.b,
								 newArea.r) & dstArea);
								 
		if (dst4.NotEmpty ())
			{
			
			dng_pixel_buffer temp (buffer);
			
			temp.fArea = dst4 + (srcArea.TL () -
								 dstArea.TL () +
								 dng_point (-phase.v, -phase.h));
			
			temp.fData = buffer.DirtyPixel (dst4.t,
									        dst4.l,
									        buffer.fPlane);
									        
			DoGet (temp);
			
			} 
					   
		// Replicate this new source area.
		
		buffer.RepeatArea (newArea,
						   dstArea);
		
		}
			
	}
コード例 #17
0
ファイル: Get.c プロジェクト: aosm/ncftp
int GetDir(GetOptionsPtr gopt, char *dName, char *rRoot, char *lRoot)
{
	LineList dirFiles;
	LinePtr dirFile;
	char *rd;	/* Remote directory path. */
	char *ld;	/* Local directory path. */
	char *rf;	/* Complete remote pathname for an item. */
	char *lf;	/* Complete local pathname for an item. */ 
	char *sl;	/* What a symlink points to. */
	char *iName;
	int fType;

	rd = NULL;
	ld = NULL;
	rf = NULL;
	lf = NULL;
	
	if ((rd = StrDup(rRoot)) == NULL)
		goto fail;
	if ((rd = PtrCatSlash(rd, dName)) == NULL)
		goto fail;

	if ((ld = StrDup(lRoot)) == NULL)
		goto fail;
	if ((ld = PtrCatSlash(ld, dName)) == NULL)
		goto fail;
	
	/* Create this directory on the local host first. */
	if (MkDirs(ld)) {
		EPrintF("Could not create directory '%s.'\n", ld);
		goto fail;
	}
	
	/* Get the names of all files and subdirs. */
	InitLineList(&dirFiles);
	GetFileList(&dirFiles, rd);

	/* Get all the files first. */
	for (dirFile = dirFiles.first; dirFile != NULL; dirFile = dirFile->next) {
		fType = (int) dirFile->line[0];
		if ((fType == '-') || (fType == 'l')) {
			iName = dirFile->line + 1;
			if ((rf = StrDup(rd)) == NULL)
				goto fail;
			if ((rf = PtrCatSlash(rf, iName)) == NULL)
				goto fail;
			if ((lf = StrDup(ld)) == NULL)
				goto fail;
			if ((lf = PtrCatSlash(lf, iName)) == NULL)
				goto fail;
			if (fType == '-') {
				gopt->rName = rf;
				gopt->lName = lf;
				DoGet(gopt);
			} else {
#ifdef HAVE_SYMLINK
				sl = (char *) malloc(SZ(512));
				if (sl != NULL) {
					if (GetSymLinkInfo(sl, SZ(512), rf) == 0)
						(void) symlink(sl, lf);
					free(sl);
				}
#endif	/* HAVE_SYMLINK */
			}
			free(rf);
			free(lf);
			rf = NULL;
			lf = NULL;
		}
		if (gXferAbortFlag == SIGINT)
			break;	/* Don't get rest of files if you interrupted. */
	}
	
	/* Now get subdirectories. */
	for (dirFile = dirFiles.first; dirFile != NULL; dirFile = dirFile->next) {
		if (gXferAbortFlag == SIGINT)
			break;	/* Don't get rest of files if you interrupted. */
		fType = (int) dirFile->line[0];
		if (fType == 'd') {
			iName = dirFile->line + 1;
			if (GetDir(gopt, iName, rd, ld) < 0)
				break;
		}
	}

	free(ld);
	free(rd);
	DisposeLineListContents(&dirFiles);
	return (0);
	
fail:
	if (rd != NULL)
		free(rd);
	if (ld != NULL)
		free(ld);
	if (rf != NULL)
		free(rf);
	if (lf != NULL)
		free(lf);
	return (-1);
}	/* GetDir */
コード例 #18
0
ファイル: gbucket.c プロジェクト: DevSlashNull/GameSpy
void *BucketGet(bucketset_t set, char *name)
{
	return DoGet(DoFind(set,name));
}
コード例 #19
0
ファイル: cheat.c プロジェクト: garbear/fceu-next
static BOOL CALLBACK AddCheatCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    static int lbfocus;
    static HWND hwndLB;

    switch (uMsg) {
    case WM_VSCROLL:
        if (scrollnum > (CSTOD - 1)) {
            switch ((int)LOWORD(wParam)) {
            case SB_TOP:
                scrollindex = -32768;
                SendDlgItemMessage(hwndDlg, 120, SBM_SETPOS, scrollindex, 1);
                SendDlgItemMessage(hwndDlg, 108, LB_RESETCONTENT, (CSTOD - 1), 0);
                FCEUI_CheatSearchGetRange(scrollindex + 32768, scrollindex + 32768 + (CSTOD - 1), cfcallb);
                break;
            case SB_BOTTOM:
                scrollindex = scrollmax;
                SendDlgItemMessage(hwndDlg, 120, SBM_SETPOS, scrollindex, 1);
                SendDlgItemMessage(hwndDlg, 108, LB_RESETCONTENT, (CSTOD - 1), 0);
                FCEUI_CheatSearchGetRange(scrollindex + 32768, scrollindex + 32768 + (CSTOD - 1), cfcallb);
                break;
            case SB_LINEUP:
                if (scrollindex > -32768) {
                    scrollindex--;
                    SendDlgItemMessage(hwndDlg, 120, SBM_SETPOS, scrollindex, 1);
                    SendDlgItemMessage(hwndDlg, 108, LB_DELETESTRING, (CSTOD - 1), 0);
                    FCEUI_CheatSearchGetRange(scrollindex + 32768, scrollindex + 32768, cfcallbinsertt);
                }
                break;

            case SB_PAGEUP:
                scrollindex -= CSTOD;
                if (scrollindex < -32768) scrollindex = -32768;
                SendDlgItemMessage(hwndDlg, 120, SBM_SETPOS, scrollindex, 1);
                SendDlgItemMessage(hwndDlg, 108, LB_RESETCONTENT, (CSTOD - 1), 0);
                FCEUI_CheatSearchGetRange(scrollindex + 32768, scrollindex + 32768 + (CSTOD - 1), cfcallb);
                break;

            case SB_LINEDOWN:
                if (scrollindex < scrollmax) {
                    scrollindex++;
                    SendDlgItemMessage(hwndDlg, 120, SBM_SETPOS, scrollindex, 1);
                    SendDlgItemMessage(hwndDlg, 108, LB_DELETESTRING, 0, 0);
                    FCEUI_CheatSearchGetRange(scrollindex + 32768 + (CSTOD - 1), scrollindex + 32768 + (CSTOD - 1), cfcallbinsert);
                }
                break;

            case SB_PAGEDOWN:
                scrollindex += CSTOD;
                if (scrollindex > scrollmax)
                    scrollindex = scrollmax;
                SendDlgItemMessage(hwndDlg, 120, SBM_SETPOS, scrollindex, 1);
                SendDlgItemMessage(hwndDlg, 108, LB_RESETCONTENT, 0, 0);
                FCEUI_CheatSearchGetRange(scrollindex + 32768, scrollindex + 32768 + (CSTOD - 1), cfcallb);
                break;

            case SB_THUMBPOSITION:
            case SB_THUMBTRACK:
                scrollindex = (short int)HIWORD(wParam);
                SendDlgItemMessage(hwndDlg, 120, SBM_SETPOS, scrollindex, 1);
                SendDlgItemMessage(hwndDlg, 108, LB_RESETCONTENT, 0, 0);
                FCEUI_CheatSearchGetRange(32768 + scrollindex, 32768 + scrollindex + (CSTOD - 1), cfcallb);
                break;
            }
        }
        break;

    case WM_INITDIALOG:
        selcheat = -1;
        FixCheatSelButtons(hwndDlg, 0);
        acwin = hwndDlg;
        SetDlgItemText(hwndDlg, 110, (LPTSTR)U8ToStr(cheatval1));
        SetDlgItemText(hwndDlg, 111, (LPTSTR)U8ToStr(cheatval2));
        DoGet();
        CheckRadioButton(hwndDlg, 115, 120, scheatmethod + 115);
        lbfocus = 0;
        hwndLB = 0;

        RedoCheatsLB(hwndDlg);
        break;

    case WM_VKEYTOITEM:
        if (lbfocus) {
            int real;

            real = SendDlgItemMessage(hwndDlg, 108, LB_GETCURSEL, 0, (LPARAM)(LPSTR)0);
            switch ((int)LOWORD(wParam)) {
            case VK_UP:
                /* mmmm....recursive goodness */
                if (!real)
                    SendMessage(hwndDlg, WM_VSCROLL, SB_LINEUP, 0);
                return(-1);
                break;
            case VK_DOWN:
                if (real == (CSTOD - 1))
                    SendMessage(hwndDlg, WM_VSCROLL, SB_LINEDOWN, 0);
                return(-1);
                break;
            case VK_PRIOR:
                SendMessage(hwndDlg, WM_VSCROLL, SB_PAGEUP, 0);
                break;
            case VK_NEXT:
                SendMessage(hwndDlg, WM_VSCROLL, SB_PAGEDOWN, 0);
                break;
            case VK_HOME:
                SendMessage(hwndDlg, WM_VSCROLL, SB_TOP, 0);
                break;
            case VK_END:
                SendMessage(hwndDlg, WM_VSCROLL, SB_BOTTOM, 0);
                break;
            }
            return(-2);
        }
        break;

    case WM_CLOSE:
    case WM_QUIT:
        goto gornk;
    case WM_COMMAND:
        switch (LOWORD(wParam)) {
        case 300:               /* List box selection changed. */
            if (HIWORD(wParam) == LBN_SELCHANGE) {
                char *s;
                uint32 a;
                uint8 v;
                int status;
                int c, type;

                selcheat = SendDlgItemMessage(hwndDlg, 300, LB_GETCURSEL, 0, (LPARAM)(LPSTR)0);
                if (selcheat < 0) {
                    FixCheatSelButtons(hwndDlg, 0);
                    break;
                }
                FixCheatSelButtons(hwndDlg, 1);

                FCEUI_GetCheat(selcheat, &s, &a, &v, &c, &status, &type);
                SetDlgItemText(hwndDlg, 200, (LPTSTR)s);
                SetDlgItemText(hwndDlg, 201, (LPTSTR)U16ToStr(a));
                SetDlgItemText(hwndDlg, 202, (LPTSTR)U8ToStr(v));
                SetDlgItemText(hwndDlg, 203, (c == -1) ? (LPTSTR)"" : (LPTSTR)IToStr(c));
                CheckDlgButton(hwndDlg, 204, type ? BST_CHECKED : BST_UNCHECKED);
            }
            break;
        case 108:
            switch (HIWORD(wParam)) {
            case LBN_SELCHANGE:
            {
                char TempArray[32];
                SendDlgItemMessage(hwndDlg, 108, LB_GETTEXT, SendDlgItemMessage(hwndDlg, 108, LB_GETCURSEL, 0, (LPARAM)(LPSTR)0), (LPARAM)(LPCTSTR)TempArray);
                TempArray[4] = 0;
                SetDlgItemText(hwndDlg, 201, (LPTSTR)TempArray);
            }
            break;
            case LBN_SETFOCUS:
                lbfocus = 1;
                break;
            case LBN_KILLFOCUS:
                lbfocus = 0;
                break;
            }
            break;
        }

        switch (HIWORD(wParam)) {
        case LBN_DBLCLK:
            if (selcheat >= 0) {
                if (LOWORD(wParam) == 300)
                    FCEUI_ToggleCheat(selcheat);
                RedoCheatsLB(hwndDlg);
                SendDlgItemMessage(hwndDlg, 300, LB_SETCURSEL, selcheat, 0);
            }
            break;

        case BN_CLICKED:
            if (LOWORD(wParam) >= 115 && LOWORD(wParam) <= 120)
                scheatmethod = LOWORD(wParam) - 115;
            else switch (LOWORD(wParam)) {
                case 112:
                    FCEUI_CheatSearchBegin();
                    DoGet();
                    break;
                case 113:
                    FCEUI_CheatSearchEnd(scheatmethod, cheatval1, cheatval2);
                    DoGet();
                    break;
                case 114:
                    FCEUI_CheatSearchSetCurrentAsOriginal();
                    DoGet();
                    break;
                case 107:
                    FCEUI_CheatSearchShowExcluded();
                    DoGet();
                    break;
                case 250:               /* Add Cheat Button */
                {
                    int a, v, c, t;
                    char name[257];
                    char temp[16];

                    GetDlgItemText(hwndDlg, 200, name, 256 + 1);
                    GetDlgItemText(hwndDlg, 201, temp, 4 + 1);
                    a = StrToU16(temp);
                    GetDlgItemText(hwndDlg, 202, temp, 3 + 1);
                    v = StrToU8(temp);
                    GetDlgItemText(hwndDlg, 203, temp, 3 + 1);
                    if (temp[0] == 0)
                        c = -1;
                    else
                        c = StrToI(temp);
                    t = (IsDlgButtonChecked(hwndDlg, 204) == BST_CHECKED) ? 1 : 0;
                    FCEUI_AddCheat(name, a, v, c, t);
                    RedoCheatsLB(hwndDlg);
                    SendDlgItemMessage(hwndDlg, 300, LB_SETCURSEL, selcheat, 0);
                }
                break;
                case 253:               /* Add GG Cheat Button */
                {
                    uint16 a;
                    int c;
                    uint8 v;
                    char name[257];

                    GetDlgItemText(hwndDlg, 200, name, 256 + 1);

                    if (FCEUI_DecodeGG(name, &a, &v, &c)) {
                        FCEUI_AddCheat(name, a, v, c, 1);
                        RedoCheatsLB(hwndDlg);
                        SendDlgItemMessage(hwndDlg, 300, LB_SETCURSEL, selcheat, 0);
                    }
                }
                break;

                case 251:               /* Update Cheat Button */
                    if (selcheat >= 0) {
                        int a, v, c, t;
                        char name[257];
                        char temp[16];

                        GetDlgItemText(hwndDlg, 200, name, 256 + 1);
                        GetDlgItemText(hwndDlg, 201, temp, 4 + 1);
                        a = StrToU16(temp);
                        GetDlgItemText(hwndDlg, 202, temp, 3 + 1);
                        v = StrToU8(temp);
                        GetDlgItemText(hwndDlg, 203, temp, 3 + 1);
                        if (temp[0] == 0)
                            c = -1;
                        else
                            c = StrToI(temp);
                        t = (IsDlgButtonChecked(hwndDlg, 204) == BST_CHECKED) ? 1 : 0;
                        FCEUI_SetCheat(selcheat, name, a, v, c, -1, t);
                        RedoCheatsLB(hwndDlg);
                        SendDlgItemMessage(hwndDlg, 300, LB_SETCURSEL, selcheat, 0);
                    }
                    break;
                case 252:               /* Delete cheat button */
                    if (selcheat >= 0) {
                        FCEUI_DelCheat(selcheat);
                        SendDlgItemMessage(hwndDlg, 300, LB_DELETESTRING, selcheat, 0);
                        FixCheatSelButtons(hwndDlg, 0);
                        selcheat = -1;
                        SetDlgItemText(hwndDlg, 200, (LPTSTR)"");
                        SetDlgItemText(hwndDlg, 201, (LPTSTR)"");
                        SetDlgItemText(hwndDlg, 202, (LPTSTR)"");
                        SetDlgItemText(hwndDlg, 203, (LPTSTR)"");
                        CheckDlgButton(hwndDlg, 204, BST_UNCHECKED);
                    }
                    break;
                case 106:
gornk:
                    EndDialog(hwndDlg, 0);
                    acwin = 0;
                    break;
                }
            break;
        case EN_CHANGE:
        {
            char TempArray[256];
            GetDlgItemText(hwndDlg, LOWORD(wParam), TempArray, 256);
            switch (LOWORD(wParam)) {
            case 110:
                cheatval1 = StrToU8(TempArray);
                break;
            case 111:
                cheatval2 = StrToU8(TempArray);
                break;
            }
        }
        break;
        }
    }
    return 0;
}
コード例 #20
0
Ptr<BuildingListPriv>
BuildingListPriv::Get (void)
{
  return *DoGet ();
}