MCPcopy Create free account
hub / github.com/Scobalula/Greyhound / ParseFile_BuildInfo

Function ParseFile_BuildInfo

src/External/CascLib/src/CascFiles.cpp:604–724  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

602}
603
604static DWORD ParseFile_BuildInfo(TCascStorage * hs, CASC_CSV & Csv)
605{
606 PFNPRODUCTCALLBACK PfnProductCallback = hs->pArgs->PfnProductCallback;
607 LPCSTR szProductColumn = "Product!STRING:0";
608 LPCSTR szCodeName;
609 void * PtrProductParam = hs->pArgs->PtrProductParam;
610 size_t nProductColumnIndex = Csv.GetColumnIndex(szProductColumn);
611 size_t nLineCount = Csv.GetLineCount();
612 size_t nSelected = CASC_INVALID_INDEX;
613 DWORD dwErrCode;
614
615 //
616 // Find the configuration that we're gonna load.
617 //
618
619 // If the product is not specified and there is product callback, we use the callback to specify the product
620 if(hs->szCodeName == NULL && nProductColumnIndex != CASC_INVALID_INDEX && PfnProductCallback != NULL)
621 {
622 LPCSTR ProductsList[0x40] = {NULL};
623 size_t nProductCount = 0;
624 size_t nChoiceIndex = CASC_INVALID_INDEX;
625 size_t nDefault = CASC_INVALID_INDEX;
626
627 // Load all products to the array
628 for(size_t i = 0; i < nLineCount; i++)
629 {
630 // Ignore anything that is not marked "active"
631 if(!strcmp(Csv[i]["Active!DEC:1"].szValue, "1"))
632 {
633 ProductsList[nProductCount] = Csv[i]["Product!STRING:0"].szValue;
634 nProductCount++;
635 nDefault = i;
636 }
637 }
638
639 // Only if there is more than one active products
640 if(nProductCount > 1)
641 {
642 // Ask the callback to choose the product
643 if(!PfnProductCallback(PtrProductParam, ProductsList, nProductCount, &nChoiceIndex) || (nChoiceIndex >= nProductCount))
644 return ERROR_CANCELLED;
645
646 // We now have preferred product to open
647 hs->SetProductCodeName(ProductsList[nChoiceIndex]);
648 }
649 else if(nProductCount == 1)
650 {
651 // We now have preferred product to open
652 hs->SetProductCodeName(ProductsList[nDefault]);
653 }
654 else
655 {
656 return ERROR_FILE_NOT_FOUND;
657 }
658 }
659
660 // Parse all lines in the CSV file. Either take the first that is active
661 // or take the one that has been selected by the callback

Callers

nothing calls this directly

Calls 9

CascStrCopyFunction · 0.85
LoadQueryKeyFunction · 0.85
GetDefaultLocaleMaskFunction · 0.85
GetDefaultCdnServersFunction · 0.85
GetDefaultCdnPathFunction · 0.85
LoadBuildNumberFunction · 0.85
GetColumnIndexMethod · 0.80
GetLineCountMethod · 0.80
SetProductCodeNameMethod · 0.80

Tested by

no test coverage detected