コード例 #1
0
ファイル: resource.cpp プロジェクト: ScummQuest/scummvm
void Resource::readCloseUps(uint16 depth, Common::File *file, CloseDataList &list) {
	list.clear();
	while (file->readByte() != '\0') {
		list.push_back(CloseData());
		CloseData &closeup = list.back();

		closeup._x1 = file->readUint16LE();
		closeup._y1 = file->readUint16LE();
		closeup._x2 = file->readUint16LE();
		closeup._y2 = file->readUint16LE();
		closeup._closeUpType = file->readSint16LE();
		closeup._depth = depth;
		closeup._graphicName = readString(file);
		closeup._message = readString(file);
		readCloseUps(depth + 1, file, closeup._subCloseUps);
	}
}
コード例 #2
0
ファイル: base.c プロジェクト: vcosta/derclou
static void tcDo(void)
{
    U32 sceneId = SCENE_NEW_GAME;

    gfxChangeColors(l_gc, 0, GFX_FADE_OUT, 0);
    gfxChangeColors(m_gc, 0, GFX_FADE_OUT, 0);

    tcSetPermanentColors();

    /* to blend the menu colours once: */
    gfxShow(CurrentBackground, GFX_ONE_STEP | GFX_NO_REFRESH | GFX_BLEND_UP, 0,
	    -1, -1);

    /* mouse to white - assume we need to set 15 and 16 */
    gfxSetRGB(NULL, 15, 63, 63, 63);
    gfxSetRGB(NULL, 16, 63, 63, 63);

    SetBubbleType(SPEAK_BUBBLE);

    ShowMenuBackground();

    while (sceneId == SCENE_NEW_GAME) {
	ubyte ret = 0;

	if (!(GamePlayMode & GP_DEMO))
	    InitStory(STORY_DAT);
	else
	    InitStory(STORY_DAT_DEMO);

	while (!ret)
	    ret = StartupMenu();

	if (ret != 2) {
	    if (GamePlayMode & GP_FULL_ENV)
		SetFullEnviroment();

	    sceneId = PlayStory();
	} else
	    sceneId = SCENE_THE_END;

	CloseData();
	CloseStory();
    }
}
コード例 #3
0
BOOLEAN QuitProgram(void)
{
	BOOLEAN return_value;                                    //Declare return value variable
	BOOLEAN error;
	char buff[255];

	if(!filename[0])                                         //If database closed quit
	{
		printf("\nGood-bye\n");
		return_value = TRUE;
	}
	else                                                     //If database open ask to close
	{
		do
		{
			error = FALSE;
			printf("\nA database is open.\nDo you want to save before quitting? (Y/N): ");
			fgets(buff, 255, stdin);
			buff[0] = tolower(buff[0]);

			if((buff[0] != 'y' && buff[0] != 'n') || buff[1] != '\n')
			{
				printf("\nError\nPlease enter a valid response\n");
				error = TRUE;
			}
			else
			{
				if(buff[0] == 'y')
				{
					CloseData();
					return_value = QuitProgram();
				}
				else
				{
					filename[0] = '\0';
					return_value = QuitProgram();
				}
			}
		}while(error);
	}

	return(return_value);
}
コード例 #4
0
void main(void)
{
	char choice;                                             //Declare Variables
	int i = 0;
	BOOLEAN quit = FALSE;

	FIRST = NULL;                                            //Initialize variables                         
	LAST = NULL;
	for(i = 0; i < 256; i++)
		InitializeRec(&array[i]);
	filename[0] = '\0';

	i = 0;
	
	do                                                       //menu open until quit = TRUE
	{
	choice = DisplayMainMenu();                              //Display Main Menu and Get Main Menu Choice
	
	switch(choice)                                           //Menu swithc
		{
			case 'o': OpenData();
				break;
			case 'a': AddRec();
				break;
			case 's': SearchData();
				break;
			case 'b': BrowseData();
				break;
			case 'd': printf("\nDelete Record\n");
				break;
			case 'c': CloseData();
				break;
			case 'q': quit = QuitProgram();
				break;
			default: printf("\nError\nPlease enter a valid response.\n");
				break;
		}

	}while(!quit);

	return;                                                    //Exit the program.
}
コード例 #5
0
ファイル: texc.cpp プロジェクト: cmbruns/Doomsday-Engine
//===========================================================================
// main
//===========================================================================
int main(int argc, char **argv)
{
	int i;

	PrintBanner();
	
	myargc = argc;
	myargv = argv;
	if(CheckOption("-f")) fullImport = true;
	
	if(argc == 1)
	{
		PrintUsage();
		return 0;
	}
	InitData();
	// Go through each command line option and process them.
	for(i = 1; i < argc; i++)
	{
		if(argv[i][0] == '-') // This is an option.
		{
			if(!stricmp(argv[i], "-i")) // Import (decompile).
			{
				if(i + 2 >= argc) 
				{
					printf("Too few parameters for import.\n");
					return 1;
				}
				Import(argv[i + 1], argv[i + 2]);
				i += 2;
			}
			continue; 
		}
		// Try to open this TX source and parse it.
		Compile(argv[i]);
	}
	WriteLumps();
	CloseData();
	return 0;
}
コード例 #6
0
ファイル: sxFtpClient.cpp プロジェクト: YeZhui/git_repository
/*传输数据(接收或发送)
  入参:pLocalfile - 本地文件。如果是接收,则接收到的文件存入此文件中;如果是发送,则发送此文件
  	pPath - 服务器端文件。如果是接收,则接收此文件;如果是发送,则发送的文件存入此文件中
  	nType - 传输类型
  	nMode - 传输模式,缺省是二进制模式
  出参:成功返回1,失败返回0
*/
int yCFtp::Xfer (const char *pLocalfile, const char *pPath, int nType, int nMode)
{
	assert (m_pCtl);
	int l = 0, c = 0;
	char *pBuf = NULL;
	FILE *fpLocal = NULL;
	netbuf *pData = NULL;

	char *backuplog = "/tmp/backup.log";
	FILE *logfp = fopen(backuplog, "a");

/*
	if (NULL != logfp)
	{
		fprintf(logfp, "%s:", pLocalfile);
	}
*/

	if (pLocalfile)
	{
		if ((fpLocal = fopen (pLocalfile, (nType == FTPLIB_FILE_WRITE) ? "r" : "w")) == NULL)
		{
			strncpy (m_pCtl->pResponse, strerror (errno), sizeof (m_pCtl->pResponse));

			if (NULL != logfp)
			{
				fprintf(logfp, "%s: fopen error!\n", pLocalfile);
			}
			fclose(logfp);
			return 0;
		}
	}

	if (!fpLocal)
		fpLocal = (nType == FTPLIB_FILE_WRITE) ? stdin : stdout;

	if (!DataConnect (pPath, nType, nMode, &pData, logfp, pLocalfile))
	{
		fclose(logfp);
		fclose(fpLocal);
		return 0;
	}

	pBuf = (char *) malloc (FTPLIB_BUFSIZ);

	if (nType == FTPLIB_FILE_WRITE)
	{
		while ((l = fread (pBuf, 1, FTPLIB_BUFSIZ, fpLocal)) > 0)
			if ((c = Write (pBuf, l, pData)) < l)
				printf ("short write: passed %d, wrote %d\n", l, c);
	}
	else
	{
		while ((l = Read (pBuf, FTPLIB_BUFSIZ, pData)) > 0)
			if (fwrite (pBuf, 1, l, fpLocal) <= 0)
				break;
	}

	free (pBuf);
	fflush (fpLocal);

	if (pLocalfile) fclose (fpLocal);

	int ret = CloseData (pData);
	if (0 == ret)
	{
		if (NULL != logfp)
		{
			fprintf(logfp, "%s: CloseData error!\n", pLocalfile);
		}
	}	
	/*
	else
	{
		if (NULL != logfp)
		{
			fprintf(logfp, "%s: put successfully!\n", pLocalfile);
		}
	}
	*/

	if (NULL != logfp)
	{
		fclose(logfp);
		logfp = NULL;
	}

	return ret;
}
コード例 #7
0
ファイル: sxFtpClient.cpp プロジェクト: YeZhui/git_repository
/*数据连接
  入参:pPath - 服务器端文件
  	nType - connection modes
  	nMode - mode codes
  	pData - 数据连接后返回的netbuf结构
  出参:成功返回1,失败返回0
*/
int yCFtp::DataConnect (const char *pPath, int nType, int nMode, netbuf **pData, FILE *logfp, const char *filename)
{
	assert (m_pCtl);
	char pBuf[256];
	int nDir = 0;

	if ((pPath == NULL) && ((nType == FTPLIB_FILE_WRITE) || (nType == FTPLIB_FILE_READ)))
	{
		sprintf (m_pCtl->pResponse, "Missing path argument for file transfer\n");
		return 0;
	}

	sprintf (pBuf, "TYPE %c", nMode);

	if (!Sendcmd (pBuf, '2'))
	{
		if (NULL != logfp)
		{
			fprintf(logfp, "%s: Sendcmd (pBuf, 2) error!\n", filename);
		}
	
		return 0;
	}

	switch (nType)
	{
	case 1://FTPLIB_DIR
		strcpy (pBuf, "NLST");
		nDir = FTPLIB_READ;
		break;

	case 2://FTPLIB_DIR_VERBOSE:
		strcpy (pBuf, "LIST");
		nDir = FTPLIB_READ;
		break;

	case 3://FTPLIB_FILE_READ:
		strcpy (pBuf, "RETR");
		nDir = FTPLIB_READ;
		break;

	case 4://FTPLIB_FILE_WRITE:
		strcpy (pBuf, "STOR");
		nDir = FTPLIB_WRITE;
		break;

	default:
		sprintf (m_pCtl->pResponse, "Invalid open type %d\n", nType);
		return 0;
	}

	if (pPath)
	{
		int i = strlen (pBuf);
		pBuf[i++] = ' ';
		if ((strlen (pPath) + i) >= sizeof (pBuf))
			return 0;
		strcpy (&pBuf[i], pPath);
	}

	if (!OpenPort (pData, nMode, nDir))
	{
		if (NULL != logfp)
		{
			fprintf(logfp, "%s: OpenPort error!\n", filename);
		}
		return 0;
	}

	if (!Sendcmd (pBuf, '1'))
	{
		(*pData)->pCtrl = NULL;
		CloseData (*pData);
		*pData = NULL;

		if (NULL != logfp)
		{
			fprintf(logfp, "%s: Sendcmd (pBuf, 1) error!\n", filename);
		}
		
		return 0;
	}

	if (m_pCtl->nMode == FTPLIB_PORT)
	{
		if (!AcceptConnection (*pData))
		{
			CloseData (*pData);
			*pData = NULL;

			if (NULL != logfp)
			{
				fprintf(logfp, "%s: AcceptConnection error!\n", filename);
			}
			
			return 0;
		}
	}

/*
	if (NULL != logfp)
	{
		fprintf(logfp, "%s: DataConnect Successfully!\n", filename);
	}
*/

	return 1;
}