コード例 #1
0
//---------------------------------------------------------------------------
void __fastcall THttpTestForm::SslHttpCli1DocBegin(TObject *Sender)
{
    TSslHttpCli *HttpCli;

    HttpCli = (TSslHttpCli*)Sender;
    Display(HttpCli->ContentType + " => " + HttpCli->DocName);
    Display("Document = " + HttpCli->DocName);

	FDocFileName = HttpCli->DocName;

	if (HttpCli->ContentType == "image/gif")
		ReplaceExt(FDocFileName, "gif");
    else if (HttpCli->ContentType == "image/jpeg")
		ReplaceExt(FDocFileName, "jpg");
    else if (HttpCli->ContentType == "image/bmp")
		ReplaceExt(FDocFileName, "bmp");

    if (FDocFileName == "")
        FDocFileName = "HttpTst.htm";
    try {
        HttpCli->RcvdStream = new TFileStream(FDocFileName, fmCreate);
    } catch (const Exception& E) {
        Display("Error opening file: " + E.Message);
        FDocFileName = "HttpTst.htm";
        Display("Using default file name: " + FDocFileName);
        HttpCli->RcvdStream = new TFileStream(FDocFileName, fmCreate);
    }
}
コード例 #2
0
ファイル: ExportManager.cpp プロジェクト: kmdtukl/miranda-ng
bool ExportManager::Import(IImport::ImportType type, std::vector<IImport::ExternalMessage>& eventList, std::wstring* err, bool* differentContact, std::vector<MCONTACT>* contacts)
{
	IImport* imp = NULL;
	switch(type) {
	case IImport::Binary:
		imp = new BinaryExport();
		break;
	case IImport::Dat:
		imp = new DatExport();
		break;
	default:
		return false;
	}
	
	std::wstring fileName;
	if (file.empty())
		file = fileName = GetFile(imp->GetExt(), hwnd, true);
	else
		fileName = ReplaceExt(file, imp->GetExt());

	std::ifstream* stream = new std::ifstream (fileName.c_str(), std::ios_base::binary);
	if (!stream->is_open())
		return false;
	
	imp->SetStream(stream);
	std::vector<MCONTACT> v;
	v.push_back(hContact);
	bool ret = true;
	int contInFile = imp->IsContactInFile(v);
	if (contInFile == -1) {
		ret = false;
		if (err != NULL)
			*err = TranslateT("File does not contain selected contact");
		
		if (contacts != NULL && differentContact != NULL) {
			contInFile = imp->IsContactInFile(*contacts);
			if (contInFile >= 0) {
				*differentContact = true;
				hContact = (*contacts)[contInFile];
			}
		}
	}
	else if (contInFile == 0 || contInFile == -3) {
		ret = imp->GetEventList(eventList);
		if (!ret && err != NULL)
			*err = TranslateT("File is corrupted");
	}
	else {
		ret = false;
		if (err != NULL)
			*err = TranslateT("File is corrupted");
	}
	stream->close();
	delete stream;
	delete imp;
	return ret;
}
コード例 #3
0
ファイル: dlgsamp.c プロジェクト: Ukusbobra/open-watcom-v2
extern bint WPSampFound( void )
/*****************************/
{
    struct stat     file_stat;
    char            buffer[_MAX_PATH2];
    char            *ext;

    if( stat( SamplePath, &file_stat ) != -1 ) return( P_TRUE );
    if( SamplePath[0] == NULLCHAR ) return( P_FALSE );
    _splitpath2( SamplePath, buffer, NULL, NULL, NULL, &ext );
    if( *ext != NULLCHAR ) return( P_FALSE );
    ReplaceExt( SamplePath, ".smp" );
    if( stat( SamplePath, &file_stat ) != -1 ) return( P_TRUE );
    return( P_FALSE );
}
コード例 #4
0
ファイル: dlgcnvt.c プロジェクト: ABratovic/open-watcom-v2
STATIC void setDlgValues( gui_window *gui )
/*****************************************/
{
    char        *add_ext;

    GUISetChecked( gui, CTL_DIF_FMT, OptDIFFormat );
    GUISetChecked( gui, CTL_COMMA_FMT, OptCommaFormat );
    if( OptDIFFormat ) {
        add_ext = ".dif";
    } else {
        add_ext = ".txt";
    }
    ReplaceExt( convertPath, add_ext );
    GUISetText( gui, CTL_NAME, convertPath );
}
コード例 #5
0
ファイル: ExportManager.cpp プロジェクト: kmdtukl/miranda-ng
int ExportManager::Import(IImport::ImportType type, const std::vector<MCONTACT>& contacts)
{
	IImport* imp = NULL;
	switch(type) {
	case IImport::Binary:
		imp = new BinaryExport();
		break;
	case IImport::Dat:
		imp = new DatExport();
		break;
	default:
		return -2;
	}

	std::wstring fileName;
	if (file.empty())
		return -2;
	else
	{
		fileName = ReplaceExt(file, imp->GetExt());
	}

	if (fileName.empty())
		return -2;

	std::ifstream* stream = new std::ifstream (fileName.c_str(), std::ios_base::binary);
	if (!stream->is_open())
		return -2;
	
	imp->SetStream(stream);
	int t = imp->IsContactInFile(contacts);
	stream->close();
	delete stream;
	delete imp;
	return t;
}
コード例 #6
0
static void ProcFile( char * fname )
/**********************************/
{
    int         ftype;
    char *      name;
    int         status;
    int         namelen;
    char *      bak;

    namelen = strlen( fname ) + 5;
    name = alloca( namelen );
    if( name == NULL ) Suicide();           // null == no stack space left.
    strcpy( name, fname );
    ReplaceExt( name, ".obj", FALSE );
    InFile = QOpen( name, O_RDONLY | O_BINARY, 0 );
    for(;;) {
        CleanRecStuff();
        ftype = ReadRec();
        if( ftype == ENDLIBRARY || ftype == ENDFILE ) {
            break;
        } else if( ftype == LIBRARY ) {
            Warning( "exclude option does not apply to libraries" );
            FreeList( ExcludeList );
            ExcludeList = NULL;
        } else if( ftype != OBJECT ) {
            Error( "file is not a standard OBJECT or LIBRARY file" );
        }
        OutFile = QOpen( TEMP_OBJ_NAME, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0 );
        do {
            ProcessRec();
            status = ReadRec();
        } while( status == OK );
        if( status == ENDMODULE ) {
            ProcessRec();           // process the modend rec.
            DoReplace();
        } else {
            Error( "premature end of file encountered" );
        }
        FreeList( ExcludeList );    // do this here so concatenated .obj files
        ExcludeList = NULL;         // only have the first module excluded.
    }
    CloseFiles();
    if( MakeBackup ) {
        bak = alloca( namelen );
        if( bak == NULL ) Suicide();           // null == no stack space left.
        strcpy( bak, name );
        if( ftype == ENDLIBRARY ) {
            ReplaceExt( bak, ".bak", TRUE );
        } else {
            ReplaceExt( bak, ".bob", TRUE );
        }
        CopyFile( name, bak );
    }
    QRemove( name );
    if( ftype == ENDLIBRARY ) {
        rename( TEMP_LIB_NAME, name );
    } else {
        rename( TEMP_OBJ_NAME, name );
    }
    FileCleanup();
}
コード例 #7
0
STATIC void loadImageInfo( image_info * curr_image )
/**************************************************/
{
    int             name_len;
    int             object_file;
    int             sym_file;
    struct stat     file_status;

    sym_file = -1;
    object_file = -1;
    curr_image->dip_handle = NO_MOD;
    if( curr_image->sym_deleted ) {
    } else if( curr_image->sym_name != NULL ) {
        sym_file = open( curr_image->sym_name, O_RDONLY|O_BINARY );
        if( sym_file != -1 ) {
            curr_image->dip_handle = WPDipLoadInfo( sym_file,
                                       curr_image->sym_name, curr_image,
                                       sizeof(image_info), DIP_PRIOR_MIN, DIP_PRIOR_MAX );
        }
    } else {
        name_len = strlen( curr_image->name ) + 1;
        memcpy( FNameBuff, curr_image->name, name_len );
        ReplaceExt( FNameBuff, ".sym" );
        name_len = strlen( FNameBuff ) + 1;
        curr_image->sym_name = ProfAlloc( name_len );
        memcpy( curr_image->sym_name, FNameBuff, name_len );
        sym_file = open( curr_image->sym_name, O_RDONLY|O_BINARY );
        if( sym_file != -1 ) {
            curr_image->dip_handle = WPDipLoadInfo( sym_file,
                                      curr_image->sym_name, curr_image,
                                      sizeof(image_info), DIP_PRIOR_MIN, DIP_PRIOR_MAX );
        }
        if( curr_image->dip_handle == NO_MOD ) {
            ProfFree( curr_image->sym_name );
            curr_image->sym_name = NULL;
        }
    }
    object_file = open( curr_image->name, O_RDONLY|O_BINARY );
    if( object_file == -1 ) {
        curr_image->exe_not_found = true;
        if( curr_image->main_load ) {
            ErrorMsg( LIT( Exe_Not_Found ), curr_image->name );
        }
    } else if( curr_image->time_stamp == 0 ) {
        /*
           If sample timestamp is 0, the sampler couldn't figure out
           the right value. Assume it's OK.
        */
    } else if( fstat( object_file, &file_status ) == 0 ) {
        /* QNX creation dates and time stamps tend to be 1 */
        /* unit different, so do not test for equality */
        if( file_status.st_mtime - curr_image->time_stamp > 1 ) {
            curr_image->exe_changed = true;
            if( curr_image->main_load ) {
                ErrorMsg( LIT( Exe_Has_Changed ), curr_image->name );
            }
        }
    }
    if( curr_image->dip_handle == NO_MOD && !curr_image->sym_deleted
     && object_file != -1 ) {
        curr_image->dip_handle = WPDipLoadInfo( object_file,
                                   curr_image->name, curr_image,
                                   sizeof(image_info), DIP_PRIOR_MIN, DIP_PRIOR_MAX );
    }
    if( curr_image->dip_handle == NO_MOD ) {
        if( sym_file != -1 ) {
            close( sym_file );
        }
        if( object_file != -1 ) {
            close( object_file );
        }
    }
    initModuleInfo( curr_image );
    if( curr_image->dip_handle != NO_MOD ) {
        WalkModList( curr_image->dip_handle, &loadModuleInfo, curr_image );
    }
}
コード例 #8
0
ファイル: ExportManager.cpp プロジェクト: kmdtukl/miranda-ng
bool ExportManager::Export(IExport::ExportType type)
{
	exp = NULL;
	UINT cp;
	std::wstring encoding;
	bool isBin = false;
	switch(type) {
	case IExport::Txt:
		exp = new TxtExport();
		cp = Options::instance->codepageTxt;
		encoding = Options::instance->encodingTxt;
		isFlat = true;
		break;
	case IExport::PlainHtml:
		exp = new PlainHtmlExport();
		cp = Options::instance->codepageHtml1;
		encoding = Options::instance->encodingHtml1;
		break;
	case IExport::RichHtml:
		exp = new RichHtmlExport();
		cp = Options::instance->codepageHtml2;
		encoding = Options::instance->encodingHtml2;
		break;
	case IExport::Binary:
		exp = new BinaryExport();
		cp = CP_UTF8;
		encoding = L"UTF8";
		isFlat = true;
		oldOnTop = true;
		isBin = true;
		break;
	case IExport::Dat:
		exp = new DatExport();
		cp = CP_UTF8;
		encoding = L"UTF8";
		isFlat = true;
		oldOnTop = true;
		isBin = true;
		break;
	default:
		return false;
	}

	std::wstring fileName;
	if (file.empty())
		fileName = GetFile(exp->GetExt(), hwnd, false);
	else
		fileName = ReplaceExt(file, exp->GetExt());

	if (fileName.empty())
		return false;

	std::wofstream* stream;
	if (!isBin) {
		stream = new std::wofstream (fileName.c_str());
		if (!stream->is_open())
			return false;
	
		std::locale filelocale(std::locale(), new codecvt_CodePage<wchar_t>(cp));
		stream->imbue(filelocale);
		exp->SetStream(stream);
	}
	else {
		std::ofstream* cstream = new std::ofstream (fileName.c_str(), std::ios_base::binary);
		if (!cstream->is_open())
			return false;
	
		stream = (std::wofstream*)cstream;
		exp->SetStream(stream);
	}

	exp->WriteHeader(fileName, GetFilterName(), GetMyName(), GetMyId(), GetContactName(), GetProtocolName(), GetContactId(), GetBaseProtocol(), encoding);

	RefreshEventList();

	exp->WriteFooter();
	if (!isBin) {
		stream->close();
		delete stream;
	}
	else {
		std::ofstream* cstream = (std::ofstream*)stream;
		cstream->close();
		delete cstream;
	}

	delete exp;
	return true;
}