本文整理汇总了C++中FindSection函数的典型用法代码示例。如果您正苦于以下问题:C++ FindSection函数的具体用法?C++ FindSection怎么用?C++ FindSection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FindSection函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strcpy
/**
* this will work only on a CxImageJPG object, if the image originally has valid EXIF data
\verbatim
CxImageJPG jpg;
CxIOFile in,out;
in.Open("D:\\exif_in.jpg","rb");
out.Open("D:\\exif_out.jpg","w+b");
jpg.Decode(&in);
if (jpg.IsValid()){
jpg.RotateLeft();
jpg.Encode(&out);
}
\endverbatim
*/
bool CxImageJPG::CxExifInfo::EncodeExif(CxFile * hFile)
{
int a;
if (FindSection(M_SOS)==NULL) {
strcpy(m_szLastError,"Can't write exif : didn't read all");
return false;
}
// Initial static jpeg marker.
hFile->PutC(0xff);
hFile->PutC(0xd8);
if (Sections[0].Type != M_EXIF && Sections[0].Type != M_JFIF) {
// The image must start with an exif or jfif marker. If we threw those away, create one.
static BYTE JfifHead[18] = {
0xff, M_JFIF,
0x00, 0x10, 'J' , 'F' , 'I' , 'F' , 0x00, 0x01,
0x01, 0x01, 0x01, 0x2C, 0x01, 0x2C, 0x00, 0x00
};
hFile->Write(JfifHead, 18, 1);
}
// Write all the misc sections
for (a=0; a<SectionsRead-1; a++) {
hFile->PutC(0xff);
hFile->PutC((unsigned char)(Sections[a].Type));
hFile->Write(Sections[a].Data, Sections[a].Size, 1);
}
// Write the remaining image data.
hFile->Write(Sections[a].Data, Sections[a].Size, 1);
return true;
}
示例2: copyThumbnailData
void copyThumbnailData(uchar* thumbnailData, int thumbnailLen)
{
LOGI("******************************** copyThumbnailData");
Section_t* ExifSection = FindSection(M_EXIF);
if (ExifSection == NULL) {
return;
}
int NewExifSize = ImageInfo.ThumbnailOffset+8+thumbnailLen;
ExifSection->Data = (uchar *)realloc(ExifSection->Data, NewExifSize);
if (ExifSection->Data == NULL) {
LOGW("ExifSection->Data = NULL");
return;
}
uchar* ThumbnailPointer = ExifSection->Data+ImageInfo.ThumbnailOffset+8;
memcpy(ThumbnailPointer, thumbnailData, thumbnailLen);
ImageInfo.ThumbnailSize = thumbnailLen;
Put32u(ExifSection->Data+ImageInfo.ThumbnailSizeOffset+8, thumbnailLen);
ExifSection->Data[0] = (uchar)(NewExifSize >> 8);
ExifSection->Data[1] = (uchar)NewExifSize;
ExifSection->Size = NewExifSize;
}
示例3: SaveThumbnail
//--------------------------------------------------------------------------
// Replace or remove exif thumbnail
//--------------------------------------------------------------------------
int SaveThumbnail(char * ThumbFileName)
{
FILE * ThumbnailFile;
if (ImageInfo.ThumbnailOffset == 0 || ImageInfo.ThumbnailSize == 0){
fprintf(stderr,"Image contains no thumbnail\n");
return FALSE;
}
if (strcmp(ThumbFileName, "-") == 0){
// A filename of '-' indicates thumbnail goes to stdout.
// This doesn't make much sense under Windows, so this feature is unix only.
ThumbnailFile = stdout;
}else{
ThumbnailFile = fopen(ThumbFileName,"wb");
}
if (ThumbnailFile){
uchar * ThumbnailPointer;
Section_t * ExifSection;
ExifSection = FindSection(M_EXIF);
ThumbnailPointer = ExifSection->Data+ImageInfo.ThumbnailOffset+8;
fwrite(ThumbnailPointer, ImageInfo.ThumbnailSize ,1, ThumbnailFile);
fclose(ThumbnailFile);
return TRUE;
}else{
ErrFatal("Could not write thumbnail file");
return FALSE;
}
}
示例4: FindSection
const char *GProfile::GetPath(const char *szSectionName, const char *szKey, short bThrowNotFound)
{
Section *pSection = FindSection(szSectionName);
if (pSection)
{
NameValuePair *pNVP = FindKey(szKey, pSection);
if (pNVP)
{
if ( !( pNVP->m_strValue.Right(1) == "/" || pNVP->m_strValue.Right(1) == "\\") )
{
#ifdef _WIN32
pNVP->m_strValue += "\\";
#else
pNVP->m_strValue += "/";
#endif
}
return pNVP->m_strValue;
}
else if (bThrowNotFound)
{
// throw key not found
}
}
else if (bThrowNotFound)
{
// throw key not found
}
return 0;
}
示例5: getThumbnail
static jbyteArray getThumbnail(JNIEnv *env, jobject jobj, jstring jfilename)
{
LOGI("getThumbnail");
const char* filename = (*env)->GetStringUTFChars(env, jfilename, NULL);
if (filename)
{
loadExifInfo(filename, FALSE);
Section_t* ExifSection = FindSection(M_EXIF);
if (ExifSection == NULL || ImageInfo.ThumbnailSize == 0)
{
LOGE("no exif section or size == 0, so no thumbnail\n");
goto noThumbnail;
}
uchar* thumbnailPointer = ExifSection->Data + ImageInfo.ThumbnailOffset + 8;
jbyteArray byteArray = (*env)->NewByteArray(env, ImageInfo.ThumbnailSize);
if (byteArray == NULL)
{
LOGE("couldn't allocate thumbnail memory, so no thumbnail\n");
goto noThumbnail;
}
(*env)->SetByteArrayRegion(env, byteArray, 0, ImageInfo.ThumbnailSize, thumbnailPointer);
LOGD("thumbnail size %d\n", ImageInfo.ThumbnailSize);
(*env)->ReleaseStringUTFChars(env, jfilename, filename);
DiscardData();
return byteArray;
}
noThumbnail: if (filename)
{
(*env)->ReleaseStringUTFChars(env, jfilename, filename);
}
DiscardData();
return NULL;
}
示例6: getThumbnailRange
static jlongArray getThumbnailRange(JNIEnv *env, jobject jobj, jstring jfilename) {
jlongArray resultArray = NULL;
const char* filename = (*env)->GetStringUTFChars(env, jfilename, NULL);
if (filename) {
loadExifInfo(filename, FALSE);
Section_t* ExifSection = FindSection(M_EXIF);
if (ExifSection == NULL || ImageInfo.ThumbnailSize == 0) {
goto done;
}
jlong result[2];
result[0] = ExifSection->Offset + ImageInfo.ThumbnailOffset + 8;
result[1] = ImageInfo.ThumbnailSize;
resultArray = (*env)->NewLongArray(env, 2);
if (resultArray == NULL) {
goto done;
}
(*env)->SetLongArrayRegion(env, resultArray, 0, 2, result);
}
done:
if (filename) {
(*env)->ReleaseStringUTFChars(env, jfilename, filename);
}
DiscardData();
return resultArray;
}
示例7: ReplaceThumbnailFromBuffer
//--------------------------------------------------------------------------
// Replace or remove exif thumbnail
//--------------------------------------------------------------------------
int ReplaceThumbnailFromBuffer(const char * Thumb, int ThumbLen)
{
int NewExifSize;
Section_t * ExifSection;
uchar * ThumbnailPointer;
if (ImageInfo.ThumbnailOffset == 0 || ImageInfo.ThumbnailAtEnd == FALSE){
if (Thumb == NULL){
// Delete of nonexistent thumbnail (not even pointers present)
// No action, no error.
return FALSE;
}
// Adding or removing of thumbnail is not possible - that would require rearranging
// of the exif header, which is risky, and jhad doesn't know how to do.
fprintf(stderr,"Image contains no thumbnail to replace - add is not possible\n");
#ifdef SUPERDEBUG
ALOGE("Image contains no thumbnail to replace - add is not possible\n");
#endif
return FALSE;
}
if (Thumb) {
if (ThumbLen + ImageInfo.ThumbnailOffset > 0x10000-20){
//ErrFatal("Thumbnail is too large to insert into exif header");
ALOGE("Thumbnail is too large to insert into exif header");
return FALSE;
}
} else {
if (ImageInfo.ThumbnailSize == 0){
return FALSE;
}
ThumbLen = 0;
}
ExifSection = FindSection(M_EXIF);
NewExifSize = ImageInfo.ThumbnailOffset+8+ThumbLen;
ExifSection->Data = (uchar *)realloc(ExifSection->Data, NewExifSize);
ThumbnailPointer = ExifSection->Data+ImageInfo.ThumbnailOffset+8;
if (Thumb){
memcpy(ThumbnailPointer, Thumb, ThumbLen);
}
ImageInfo.ThumbnailSize = ThumbLen;
Put32u(ExifSection->Data+ImageInfo.ThumbnailSizeOffset+8, ThumbLen);
ExifSection->Data[0] = (uchar)(NewExifSize >> 8);
ExifSection->Data[1] = (uchar)NewExifSize;
ExifSection->Size = NewExifSize;
#ifdef SUPERDEBUG
ALOGE("ReplaceThumbnail successful thumblen %d", ThumbLen);
#endif
return TRUE;
}
示例8: LoadDSN
static int LoadDSN (
const gchar* iniFileName, const gchar* dsnName, GHashTable* table)
{
FILE* stream;
gchar* name;
gchar* value;
if ((stream = fopen (iniFileName, "r" )) != NULL )
{
if (!FindSection (stream, dsnName))
{
g_printerr ("Couldn't find DSN %s in %s\n", dsnName, iniFileName);
fclose (stream);
return 0;
}
else
{
while (GetNextItem (stream, &name, &value))
{
g_hash_table_insert (table, g_strdup (name), g_strdup (value));
}
}
fclose( stream );
}
return 1;
}
示例9: FindSection
// function retrieves a boolean from the specified section
bool GProfile::GetBool(const char *szSectionName, const char *szKey, bool bThrowNotFound /* = true */)
{
GProfileSection *pSection = FindSection(szSectionName);
if (pSection)
{
GProfileEntry *pNVP = FindKey(szKey, pSection);
if (pNVP)
{
if (!pNVP->m_strValue.IsEmpty())
{
if (pNVP->m_strValue.GetAt(0) == '1')
return 1;
if (pNVP->m_strValue.CompareNoCase("Yes") == 0)
return 1;
if (pNVP->m_strValue.CompareNoCase("On") == 0)
return 1;
}
return 0;
}
else if (bThrowNotFound)
{
// throw key not found
throw GException("Profile", 0, szSectionName, szKey);
}
}
else if (bThrowNotFound)
{
// throw key not found
throw GException("Profile", 1, szSectionName);
}
return 0;
}
示例10: ReplaceThumbnail
//--------------------------------------------------------------------------
// Replace or remove exif thumbnail
//--------------------------------------------------------------------------
int ReplaceThumbnail(const char * ThumbFileName)
{
FILE * ThumbnailFile;
int ThumbLen, NewExifSize;
Section_t * ExifSection;
uchar * ThumbnailPointer;
if (ImageInfo.ThumbnailOffset == 0 || ImageInfo.ThumbnailAtEnd == FALSE){
// Adding or removing of thumbnail is not possible - that would require rearranging
// of the exif header, which is risky, and jhad doesn't know how to do.
printf("Image contains no thumbnail to replace - add is not possible\n");
return FALSE;
}
if (ThumbFileName){
ThumbnailFile = fopen(ThumbFileName,"rb");
if (ThumbnailFile == NULL){
ErrFatal("Could not read thumbnail file");
return FALSE;
}
// get length
fseek(ThumbnailFile, 0, SEEK_END);
ThumbLen = ftell(ThumbnailFile);
fseek(ThumbnailFile, 0, SEEK_SET);
if (ThumbLen + ImageInfo.ThumbnailOffset > 0x10000-20){
ErrFatal("Thumbnail is too large to insert into exif header");
}
}else{
ThumbLen = 0;
ThumbnailFile = NULL;
}
ExifSection = FindSection(M_EXIF);
NewExifSize = ImageInfo.ThumbnailOffset+8+ThumbLen;
ExifSection->Data = (uchar *)realloc(ExifSection->Data, NewExifSize);
ThumbnailPointer = ExifSection->Data+ImageInfo.ThumbnailOffset+8;
if (ThumbnailFile){
fread(ThumbnailPointer, ThumbLen, 1, ThumbnailFile);
fclose(ThumbnailFile);
}
ImageInfo.ThumbnailSize = ThumbLen;
Put32u(ExifSection->Data+ImageInfo.ThumbnailSizeOffset+8, ThumbLen);
ExifSection->Data[0] = (uchar)(NewExifSize >> 8);
ExifSection->Data[1] = (uchar)NewExifSize;
ExifSection->Size = NewExifSize;
return TRUE;
}
示例11: FindSection
bool CIniFile::FindKey (CCHR *pSection, CCHR *pKey, EFIND *pList)
{
char Search [130];
char Found [130];
char Text [255];
char *pText;
struct ENTRY *pEntry;
pList->pSec = NULL;
pList->pKey = NULL;
pEntry = FindSection (pSection);
if (pEntry == NULL) { return FALSE; }
pList->pSec = pEntry;
pList->KeyText[0] = 0;
pList->ValText[0] = 0;
pList->Comment[0] = 0;
pEntry = pEntry->pNext;
if (pEntry == NULL) { return FALSE; }
sprintf (Search, "%s",pKey);
strupr (Search);
while (pEntry != NULL)
{
if ((pEntry->Type == tpSECTION) || // Stop after next section or EOF
(pEntry->Type == tpNULL ))
{
return FALSE;
}
if (pEntry->Type == tpKEYVALUE)
{
strcpy (Text, pEntry->pText);
pText = strchr (Text, ';');
if (pText != NULL)
{
strcpy (pList->Comment, pText);
*pText = 0;
}
pText = strchr (Text, '=');
if (pText != NULL)
{
*pText = 0;
strcpy (pList->KeyText, Text);
strcpy (Found, Text);
*pText = '=';
strupr (Found);
// printf ("%s,%s\n", Search, Found);
if (strcmp (Found,Search) == 0)
{
strcpy (pList->ValText, pText+1);
pList->pKey = pEntry;
return TRUE;
}
}
}
pEntry = pEntry->pNext;
}
return NULL;
}
示例12: seekg
//--------------------------------------------------------------------
// @mfunc Tokenize the Provider info
//
// @rdesc BOOL
// @flag TRUE | Parsing yielded no Error
//
BOOL CParseInitFile::ParseProviderInfo()
{
//move to beginning of file
seekg(0L);
CHAR* pszStart = NULL;
CHAR* pszEnd = NULL;
CHAR szVersion[100];
TRACE_CALL(L"PRIVLIB: CParseInitFile::ParseProviderInfo.\n");
//Skip over any lines, until the [INFO] section is reached...
//Make sure the INI contains the required version (at least)
if( FindSection("[INFO]")==S_OK &&
GetNextLine(m_pvInput, MAX_INPUT_BUFFER)==S_OK &&
(pszStart = strstr(m_pvInput, START_OF_TYPE)) &&
(pszStart = strstr(pszStart, "VERSION=")) &&
(pszStart = strstr(pszStart, ",")) &&
(pszStart = strstr(pszStart+1, ",")) &&
(pszEnd = strstr(pszStart+1, ",")) )
{
//Build Version is between 2nd and 3rd comma. (1,50,3518,00)
pszStart++;
strncpy(szVersion, pszStart, (size_t)(pszEnd - pszStart));
szVersion[pszEnd - pszStart] = '\0';
ULONG ulVersion = strtoul(szVersion, NULL, 10);
if(ulVersion == ULONG_MAX || ulVersion < 3518)
{
odtLog << "ERROR: This version of the Privlib requires a INI File generated from " << ENDL;
odtLog << "ERROR: from TableDump.exe 1.50.3518.00 or later." << ENDL;
return FALSE;
}
}
else
{
odtLog << "ERROR: Unable to find Versioning Information in INI <File:" << m_pszFileName << ">" << ENDL;
odtLog << "ERROR: This version of the Privlib requires a INI with a version section" << ENDL;
odtLog << "ERROR: and generated using a version of TableDump.exe 1.50.3518.00 or later." << ENDL;
return FALSE;
}
//Get the NextLine {(TABLE=; DEFAULTQUERY=; DATASOURCE=; USERID=; PASSWORD=; etc... )}
if(GetNextLine(m_pvInput, MAX_INPUT_BUFFER)!=S_OK ||
(pszStart = strstr(m_pvInput, START_OF_TYPE))==NULL ||
(pszStart = strstr(pszStart, "TABLE="))==NULL)
{
odtLog << "ERROR: Unable to find InitString containing Initialization Information in INI <File:" << m_pszFileName << ">" << ENDL;
odtLog << "ERROR: Make sure your using a correctly generated INI File from TableDump.exe" << ENDL;
return FALSE;
}
//We just need to append the InitString from the FILE to the InitString
//Already stored in the CModInfo from LTM. And we will parse both together...
GetModInfo()->AddToInitString(pszStart);
return TRUE;
}
示例13: CVDefSegs
extern void CVDefSegs( void ){
/**************************/
if( _IsModel( DBG_LOCALS ) ) {
CVSyms = DbgSegDef( ".debug$S" );
CVSymMain = FindSection( CVSyms );
owlCVSym = CVSymMain->owl_handle;
}
if( _IsModel( DBG_TYPES ) ) {
CVTypes = DbgSegDef( ".debug$T" );
}
}
示例14: GetEntry
ConfigSection* ConfigFile::GetEntry(string name)
{
ConfigSection* c=FindSection(name);
if (!c)
{
entrys=c= new ConfigSection(entrys);
c->name=name;
}
return c;
}
示例15: TRACE_CALL
//--------------------------------------------------------------------
// @mfunc Retrieve the data associated with a particular column.
//
//
// @rdesc BOOL
// @flag TRUE | Succeeded
// @flag FALSE | Failed
//
BOOL CParseInitFile::ParseColumnInfo()
{
HRESULT hr = S_OK;
CHAR* pszStart = NULL;
TRACE_CALL(L"PRIVLIB: CParseInitFile::ParseColumnInfo.\n");
// If Column data has not been retrieved,
if(m_ColData.IsEmpty())
{
//Skip over any lines, until the [COLUMN] section is reached...
if(FAILED(hr = FindSection("[COLUMN]")))
return FALSE;
//Get the NextLine {ColName(iOrdinal, TYPE, ulColumnSize, bPrecision, bScale, dwFlags)}
if((hr = GetNextLine(m_pvInput, MAX_INPUT_BUFFER))!=S_OK)
{
odtLog << "ERROR: Unable to find Columns in INI <File:" << m_pszFileName << ">" << ENDL;
odtLog << "ERROR: Make sure your using a correctly generated INI File from TableDump.exe" << ENDL;
return FALSE;
}
//Now parse the Columns
m_ColData.RemoveAll();
// Parse the records
while(hr==S_OK)
{
pszStart = strstr(m_pvInput, START_OF_TYPE);
if(pszStart)
{
// if we have reached [DATA] part bail out
pszStart++;
if(strncmp(pszStart, szDATA, 6) ==0)
return TRUE;
// parse the column metadata info
if(!GetColumns(pszStart))
break;
}
//Retrieve the next row
if((hr = GetNextLine(m_pvInput, MAX_INPUT_BUFFER))!=S_OK)
{
odtLog << "ERROR: Unable to finding ColumnInfo for Column " << m_ColData.GetCount() << " in INI <File:" << m_pszFileName << ">" << ENDL;
odtLog << "ERROR: Make sure your using a correctly generated INI File from TableDump.exe" << ENDL;
return FALSE;
}
}
}
return FALSE;
}