int main(int argc, char *argv[]) { const char szSection[] = "student"; const char szKeyName[] = "name"; const char szKeyAge[] = "age"; char szValue[TEST_BUF_SIZE]={0}; int age; if (0 != IniWriteString(TEST_INI_FILE, szSection, szKeyName, "Tony")) { printf("IniWriteString failed. [%s, %s, %s]\n", szSection, szKeyName, "Tony"); } else { printf("IniWriteString success. [%s, %s, %s]\n", szSection, szKeyName, "Tony"); } if (0 != IniWriteString(TEST_INI_FILE, szSection, szKeyAge, "20")) { printf("IniWriteString failed. [%s, %s, %s]\n", szSection, szKeyAge, "20"); } else { printf("IniWriteString Success. [%s, %s, %s]\n", szSection, szKeyAge, "20"); } if (0 != IniReadString(TEST_INI_FILE, szSection, szKeyName, szValue, TEST_BUF_SIZE, "")) { printf("IniReadString failed. [%s, %s]\n", szSection, szKeyName); } else { printf("IniReadString success. [%s, %s, %s]\n", szSection, szKeyName, szValue); } age = IniReadInt(TEST_INI_FILE, szSection, szKeyAge, 0); printf("IniReadInt here. [%s, %s, %d]\n", szSection, szKeyAge, age); /* 用例 */ if (0 != IniReadString(TEST_INI_FILE, "Main", "test case", szValue, TEST_BUF_SIZE, NULL)) { printf("IniReadString failed. [%s, %s]\n", "Main", "test case"); } else { printf("IniReadString success. [%s, %s, %s]\n", "Main", "test case", szValue); } /* 用例 */ if (0 != IniReadString(TEST_INI_FILE, "Main", "test case1", szValue, TEST_BUF_SIZE, NULL)) { printf("IniReadString failed. [%s, %s]\n", "Main", "test case1"); } else { printf("IniReadString success. [%s, %s, %s]\n", "Main", "test case1", szValue); } /* 用例 */ if (0 != IniWriteString(TEST_INI_FILE, "Main", "test case1", "TEST CASE1")) { printf("IniWriteString failed. [%s, %s]\n", "Main", "test case1"); } else { printf("IniWriteString success. [%s, %s]\n", "Main", "test case1"); } if (0 != IniReadString(TEST_INI_FILE, "Main", "test case1", szValue, TEST_BUF_SIZE, NULL)) { printf("IniReadString failed. [%s, %s]\n", "Main", "test case1"); } else { printf("IniReadString success. [%s, %s, %s]\n", "Main", "test case1", szValue); } return 0; }
/* This function reads all blink manager entries into a locally * linked list. */ void FASTCALL LoadBlinkList( void ) { LPSTR lpsz; INITIALISE_PTR(lpsz); /* First create the Blink menu. */ hBlinkMenu = GetSubMenu( GetSubMenu( hMainMenu, 0 ), 12 ); /* Get the list of blink manager entries and * install them into the command table. */ if( fNewMemory( &lpsz, 8000 ) ) { UINT c; Amuser_GetPPString( szBlinkman, NULL, "", lpsz, 8000 ); for( c = 0; lpsz[ c ]; ++c ) { char szBtnBmpFilename[ 64 ]; LPCSTR pszBtnBmpFilename; char szConnCard[ 40 ]; DWORD dwBlinkFlags; LPBLINKENTRY lpbe; RASDATA rd2; int index; LPSTR lp; /* Read the configuration setting */ Amuser_GetPPString( szBlinkman, &lpsz[ c ], "", lpTmpBuf, LEN_TEMPBUF ); lp = lpTmpBuf; /* Set the default RAS settings */ rd2 = rdDef; /* Parse blink flags value. */ lp = IniReadLong( lp, &dwBlinkFlags ); lp = IniReadText( lp, szConnCard, sizeof(szConnCard)-1 ); if( *lp ) { lp = IniReadInt( lp, &rd2.fUseRAS ); if( rd2.fUseRAS ) { char szRASPassword[ 80 ]; lp = IniReadText( lp, rd2.szRASEntryName, RAS_MaxEntryName ); lp = IniReadText( lp, rd2.szRASUserName, UNLEN ); lp = IniReadText( lp, szRASPassword, PWLEN ); DecodeLine64( szRASPassword, rd2.szRASPassword, PWLEN ); } } /* Get button bitmap details. */ lp = IniReadText( lp, szBtnBmpFilename, sizeof(szBtnBmpFilename) ); lp = IniReadInt( lp, &index ); /* Convert to proper filename or index. */ pszBtnBmpFilename = szBtnBmpFilename; if( '\0' == *pszBtnBmpFilename ) pszBtnBmpFilename = BTNBMP_GRID; /* Store the settings. */ if( *szConnCard == '\0' ) strcpy( szConnCard, szCIXConnCard ); if( strcmp( &lpsz[ c ], "Custom" ) == 0 ) lpbe = AddBlinkToList( &lpsz[ c ], dwBlinkFlags, szConnCard, IDM_CUSTOMBLINK, FALSE ); else { WORD wDefKey; wDefKey = 0; if( strcmp( &lpsz[ c ], "Full" ) == 0 ) wDefKey = MAKEKEY(HOTKEYF_CONTROL,'T'); lpbe = AddBlinkToCommandTable( &lpsz[ c ], dwBlinkFlags, szConnCard, wDefKey, FALSE ); } /* Store RAS settings. */ if( NULL != lpbe ) lpbe->rd = rd2; c += strlen( &lpsz[ c ] ); } FreeMemory( &lpsz ); } /* If no blink entries, install some defaults. */ if( NULL == lpbeFirst ) { AddBlinkToCommandTable( "Full", BF_FULLCONNECT, szCIXConnCard, 0, TRUE ); AddBlinkToList( "Custom", BF_POSTCIX|BF_GETCIX, szCIXConnCard, IDM_CUSTOMBLINK, TRUE ); if( fUseInternet ) AddBlinkToCommandTable( "Mail Only", BF_GETIPMAIL|BF_POSTIPMAIL, szCIXConnCard, 0, TRUE ); AddBlinkToCommandTable( "Upload Only", BF_POSTIPMAIL|BF_POSTIPNEWS|BF_POSTCIX, szCIXConnCard, 0, TRUE ); AddBlinkToCommandTable( "CIX Forums Only", BF_POSTCIX|BF_GETCIX, szCIXConnCard, 0, TRUE ); if( fUseInternet ) AddBlinkToCommandTable( "Internet Only", BF_IPFLAGS, szCIXConnCard, 0, TRUE ); fBlinkListLoaded = FALSE; } else { /* Always make sure we have a Default blink * command. */ if( 0 == GetBlinkCommandID( "Full" ) ) AddBlinkToCommandTable( "Full", BF_FULLCONNECT, szCIXConnCard, MAKEKEY(HOTKEYF_CONTROL,'T'), TRUE ); fBlinkListLoaded = TRUE; } }