示例#1
0
void outwnd_init(int display_under_freespace_window)
{
	outwnd_inited = true;

	char pathname[MAX_PATH_LEN];

	snprintf(pathname, MAX_PATH_LEN, "%s/%s/%s/%s", detect_home(), Osreg_user_dir, Pathtypes[CF_TYPE_DATA].path, FreeSpace_logfilename);

	if (Log_fp == NULL) {
		Log_fp = fopen(pathname, "wb");

		if (Log_fp == NULL) {
			outwnd_printf("Error", "Error opening %s\n", pathname);
		} else {
			time_t timedate = time(NULL);
			char datestr[50];

			memset( datestr, 0, sizeof(datestr) );
			strftime( datestr, sizeof(datestr)-1, "%a %b %d %H:%M:%S %Y", localtime(&timedate) );

			printf("Future debug output directed to: %s\n", pathname);
			outwnd_printf("General", "Opened log '%s', %s ...\n", pathname, datestr);
		}
	}
}
void outwnd_init(int display_under_freespace_window)
{
	outwnd_inited = true;

	char pathname[MAX_PATH_LEN];
    
    /* Set where the log file is going to go */
    // Zacam: Set various conditions based on what type of log to generate.
    if (Fred_running) {
        FreeSpace_logfilename = "fred2_open.log";
    } else if (Is_standalone) {
        FreeSpace_logfilename = "fs2_standalone.log";
    } else {
        FreeSpace_logfilename = "fs2_open.log";
    }

	snprintf(pathname, MAX_PATH_LEN, "%s/%s/%s/%s", detect_home(), Osreg_user_dir, Pathtypes[CF_TYPE_DATA].path, FreeSpace_logfilename);

	if (Log_fp == NULL) {
		Log_fp = fopen(pathname, "wb");

		if (Log_fp == NULL) {
			outwnd_printf("Error", "Error opening %s\n", pathname);
		} else {
			time_t timedate = time(NULL);
			char datestr[50];

			memset( datestr, 0, sizeof(datestr) );
			strftime( datestr, sizeof(datestr)-1, "%a %b %d %H:%M:%S %Y", localtime(&timedate) );

			printf("Future debug output directed to: %s\n", pathname);
			outwnd_printf("General", "Opened log '%s', %s ...\n", pathname, datestr);
		}
	}
}
示例#3
0
//Initializes the (global) scripting system, as well as any subsystems.
//script_close is handled by destructors
void script_init(void)
{
	mprintf(("SCRIPTING: Beginning initialization sequence...\n"));

	mprintf(("SCRIPTING: Beginning Lua initialization...\n"));
	Script_system.CreateLuaState();

	if (Output_scripting_meta)
	{
		mprintf(("SCRIPTING: Outputting scripting metadata...\n"));
		char cmdname[MAX_PATH_LEN];
		memset(cmdname, 0, sizeof(cmdname));
		snprintf(cmdname, MAX_PATH_LEN - 1, "%s%s%s%s%s%s%s", detect_home(), DIR_SEPARATOR_STR, Osreg_company_name,
			DIR_SEPARATOR_STR, Osreg_user_dir, DIR_SEPARATOR_STR, "scripting.html");

		Script_system.OutputMeta(cmdname);
	}
	mprintf(("SCRIPTING: Beginning main hook parse sequence....\n"));
	script_parse_table("scripting.tbl");
	parse_modular_table(NOX("*-sct.tbm"), script_parse_table);
	mprintf(("SCRIPTING: Inititialization complete.\n"));
}
示例#4
0
void save_filter_info(void)
{
	FILE *fp = NULL;
	char pathname[MAX_PATH_LEN];

	if ( !outwnd_filter_loaded )
		return;

	if (Outwnd_no_filter_file)
		return;	// No file, don't save


	snprintf( pathname, MAX_PATH_LEN, "%s/%s/%s/%s", detect_home(), Osreg_user_dir, Pathtypes[CF_TYPE_DATA].path, NOX("debug_filter.cfg") );

	fp = fopen(pathname, "wt");

	if (fp) {
		for (uint i = 0; i < OutwndFilter.size(); i++)
			fprintf(fp, "%c%s\n", OutwndFilter[i].enabled ? '+' : '-', OutwndFilter[i].name);

		fclose(fp);
	}
}
示例#5
0
void load_filter_info(void)
{
	FILE *fp = NULL;
	char pathname[MAX_PATH_LEN];
	char inbuf[NAME_LENGTH+4];
	outwnd_filter_struct new_filter;
	int z;

	outwnd_filter_loaded = 1;

	snprintf( pathname, MAX_PATH_LEN, "%s/%s/%s/%s", detect_home(), Osreg_user_dir, Pathtypes[CF_TYPE_DATA].path, NOX("debug_filter.cfg") );

	fp = fopen(pathname, "rt");

	if (!fp) {
		Outwnd_no_filter_file = 1;

		memset( &new_filter, 0, sizeof(outwnd_filter_struct) );
		strcpy( new_filter.name, "error" );
		new_filter.enabled = true;

		OutwndFilter.push_back( new_filter );

		memset( &new_filter, 0, sizeof(outwnd_filter_struct) );
		strcpy( new_filter.name, "general" );
		new_filter.enabled = true;

		OutwndFilter.push_back( new_filter );

		memset( &new_filter, 0, sizeof(outwnd_filter_struct) );
		strcpy( new_filter.name, "warning" );
		new_filter.enabled = true;

		OutwndFilter.push_back( new_filter );

		return;
	}

	Outwnd_no_filter_file = 0;

	while ( fgets(inbuf, NAME_LENGTH+3, fp) ) {
		memset( &new_filter, 0, sizeof(outwnd_filter_struct) );

		if (*inbuf == '+')
			new_filter.enabled = true;
		else if (*inbuf == '-')
			new_filter.enabled = false;
		else
			continue;	// skip everything else

		z = strlen(inbuf) - 1;
		if (inbuf[z] == '\n')
			inbuf[z] = 0;

		Assert( strlen(inbuf+1) < NAME_LENGTH );
		strcpy(new_filter.name, inbuf + 1);

		if ( !stricmp(new_filter.name, "error") ) {
			new_filter.enabled = true;
		} else if ( !stricmp(new_filter.name, "general") ) {
			new_filter.enabled = true;
		} else if ( !stricmp(new_filter.name, "warning") ) {
			new_filter.enabled = true;
		}

		OutwndFilter.push_back( new_filter );
	}

	if ( ferror(fp) && !feof(fp) )
		nprintf(("Error", "Error reading \"%s\"\n", pathname));

	fclose(fp);
}