Пример #1
0
void Menu() {
    char *input;
    // Add full menu
    printf("=====================================\n");
    //printf("Welcome to TTHN_5C13_ManageProduct.\n");
    //printf("Enter a command in the menu to start.\n");
    //printf("add - Add a product.");
    //printf("display - Show all products");
    //printf("delete - Delete a product.");
    //printf("=====================================\n");

    //while(getchar()!='\n');
    input = ReadLine(100, stdin);
    if (strcmp(input, "add") == 0) {
        free(input);
        AddProduct();
    } else if (strcmp(input, "display") == 0) {
        free(input);
        Display();
    } else if (strcmp(input, "delete") == 0) {
        free(input);
        Delete();
    } else if (strcmp(input, "deletex") == 0) {
        free(input);
        DeleteX();
    } else if (strcmp(input, "deleteall") == 0) {
        free(input);
        DeleteAll();
    } else if (strcmp(input, "search") == 0) {
        free(input);
        Search();
    }

}
Пример #2
0
void CIFXMetaData::AppendX(IFXMetaDataX* pSource)
{
	IFXString sKey, sEncodedKey, sValue;
	U32 srcCount, srcIndex, srcSize, dstIndex;
	IFXMetaDataAttribute srcType;
	U8* pBuffer;
	IFXRESULT rc;
	BOOL Persistance = true;
	
	IFXCHECKX_RESULT( pSource, IFX_E_NOT_INITIALIZED );
	pSource->GetCountX(srcCount);
	
	for (srcIndex = 0; srcIndex < srcCount; srcIndex++) {
		pSource->GetKeyX(srcIndex, sKey);
		pSource->GetEncodedKeyX(srcIndex, sEncodedKey);
		pSource->GetAttributeX(srcIndex, srcType);

		if (IsKeyExists(sKey)) {
			rc = GetIndex(sKey, dstIndex);
			IFXCHECKX_RESULT( IFXSUCCESS( rc ), IFX_E_NO_METADATA );
			DeleteX(dstIndex);
		}

		if (srcType & IFXMETADATAATTRIBUTE_BINARY) {
			pSource->GetBinarySizeX(srcIndex, srcSize);
			pBuffer = (U8*)new U8[srcSize];
			IFXCHECKX_RESULT( pBuffer, IFX_E_NOT_INITIALIZED );
			pSource->GetBinaryX(srcIndex, pBuffer);
			SetBinaryValueX(sEncodedKey, srcSize, pBuffer);
			delete [] pBuffer;
		} else {
			pSource->GetStringX(srcIndex, sValue);
			SetStringValueX(sEncodedKey, sValue);
		}
		GetIndex(sKey, dstIndex);
		SetAttributeX(dstIndex, srcType);

		pSource->GetPersistenceX(srcIndex, Persistance);
		rc = GetIndex(sKey, dstIndex);
		IFXCHECKX_RESULT(IFXSUCCESS( rc ), IFX_E_NO_METADATA);
		SetPersistenceX(dstIndex, Persistance);
	}
}