示例#1
0
int CAPETag::GetFieldString(const str_utf16 * pFieldName, str_ansi * pBuffer, int * pBufferCharacters, BOOL bUTF8Encode)
{
    int nOriginalCharacters = *pBufferCharacters;
    str_utf16 * pUTF16 = new str_utf16 [*pBufferCharacters + 1];
    pUTF16[0] = 0;

    int nRetVal = GetFieldString(pFieldName, pUTF16, pBufferCharacters);
    if (nRetVal == ERROR_SUCCESS)
    {
        CSmartPtr<str_ansi> spANSI(bUTF8Encode ? (str_ansi *) GetUTF8FromUTF16(pUTF16) : GetANSIFromUTF16(pUTF16), TRUE);
        if (int(strlen(spANSI)) > nOriginalCharacters)
        {
            memset(pBuffer, 0, nOriginalCharacters * sizeof(str_ansi));
            *pBufferCharacters = 0;
            nRetVal = ERROR_UNDEFINED;
        }
        else
        {
            strcpy(pBuffer, spANSI);
            *pBufferCharacters = strlen(spANSI);
        }
    }
    
    delete [] pUTF16;

    return nRetVal;
}
示例#2
0
int CAPETag::CreateID3Tag(ID3_TAG * pID3Tag)
{
    // error check 
    if (pID3Tag == NULL) { return -1; }
    if (m_bAnalyzed == FALSE) { Analyze(); }
    if (m_nFields == 0) { return -1; }

    // empty
    ZeroMemory(pID3Tag, ID3_TAG_BYTES);

    // header
    pID3Tag->Header[0] = 'T'; pID3Tag->Header[1] = 'A'; pID3Tag->Header[2] = 'G';
    
    // standard fields
    GetFieldID3String(APE_TAG_FIELD_ARTIST, pID3Tag->Artist, 30);
    GetFieldID3String(APE_TAG_FIELD_ALBUM, pID3Tag->Album, 30);
    GetFieldID3String(APE_TAG_FIELD_TITLE, pID3Tag->Title, 30);
    GetFieldID3String(APE_TAG_FIELD_COMMENT, pID3Tag->Comment, 28);
    GetFieldID3String(APE_TAG_FIELD_YEAR, pID3Tag->Year, 4);

    // track number
    str_utf16 cBuffer[256] = { 0 }; int nBufferCharacters = 255;
    GetFieldString(APE_TAG_FIELD_TRACK, cBuffer, &nBufferCharacters);
    pID3Tag->Track = (unsigned char) _wtoi(cBuffer);
    
    // genre
    cBuffer[0] = 0; nBufferCharacters = 255;
    GetFieldString(APE_TAG_FIELD_GENRE, cBuffer, &nBufferCharacters);
        
    // convert the genre string to an index
    pID3Tag->Genre = 255;
    int nGenreIndex = 0;
    BOOL bFound = FALSE;
    while ((nGenreIndex < GENRE_COUNT) && (bFound == FALSE))
    {
        if (_wcsicmp(cBuffer, g_ID3Genre[nGenreIndex]) == 0)
        {
            pID3Tag->Genre = nGenreIndex;
            bFound = TRUE;
        }
        
        nGenreIndex++;
    }

    return ERROR_SUCCESS;
}
NativeBuildStrings::NativeBuildStrings( JNIEnv *env_ )
{
	env = env_;

	// find the class
	BuildClass = env->FindClass("android/os/Build");

	// find and copy out the fields
	BuildStrings[BUILDSTR_BRAND] = GetFieldString( "BRAND" );
	BuildStrings[BUILDSTR_DEVICE] = GetFieldString( "DEVICE" );
	BuildStrings[BUILDSTR_DISPLAY] = GetFieldString( "DISPLAY" );
	BuildStrings[BUILDSTR_FINGERPRINT] = GetFieldString( "FINGERPRINT" );
	BuildStrings[BUILDSTR_HARDWARE] = GetFieldString( "HARDWARE" );
	BuildStrings[BUILDSTR_HOST] = GetFieldString( "HOST" );
	BuildStrings[BUILDSTR_ID] = GetFieldString( "ID" );
	BuildStrings[BUILDSTR_MODEL] = GetFieldString( "MODEL" );
	BuildStrings[BUILDSTR_PRODUCT] = GetFieldString( "PRODUCT" );
	BuildStrings[BUILDSTR_SERIAL] = GetFieldString( "SERIAL" );
	BuildStrings[BUILDSTR_TAGS] = GetFieldString( "TAGS" );
	BuildStrings[BUILDSTR_TYPE] = GetFieldString( "TYPE" );

	// don't pollute the local reference table
	env->DeleteLocalRef( BuildClass );
	BuildClass = 0;
}