------------------------------------------------------------------------------------ Traverse the linked tree of headers return the correct base and defApiHFile ------------------------------------------------------------------------------------
| 1519 | // Traverse the linked tree of headers return the correct base and defApiHFile |
| 1520 | // ------------------------------------------------------------------------------------ |
| 1521 | void TraverseHFilesTree(string &base, string header, string &htype, char *lpszApiConstant, Utf8Ini *defApiHFile, bool getTypeDisplay) |
| 1522 | { |
| 1523 | char szApiConstant[MAX_PATH] = ""; |
| 1524 | char lpszHeaders[MAX_PATH] = ""; |
| 1525 | char *next_token = NULL; |
| 1526 | unordered_map<string, Utf8Ini*>::const_iterator apiPointer; // pointer to the current def file |
| 1527 | |
| 1528 | string newBase = base; |
| 1529 | string newHtype = htype; |
| 1530 | Utf8Ini *newdefApiHFile = defApiHFile; |
| 1531 | strcpy_s(szApiConstant, lpszApiConstant); |
| 1532 | |
| 1533 | while (!newBase.empty()) |
| 1534 | { |
| 1535 | GetConstantValue(szApiConstant, newBase.c_str()); // strip brackets if any |
| 1536 | if (*szApiConstant) |
| 1537 | { |
| 1538 | newBase = newdefApiHFile->GetValue(szApiConstant, "Base"); // search for the next constant in the same header file |
| 1539 | newHtype = newdefApiHFile->GetValue(szApiConstant, "Type"); // search for the next type in the same header file |
| 1540 | if (newBase.empty() && !header.empty()) |
| 1541 | { // search in the next header file |
| 1542 | strcpy_s(lpszHeaders, MAX_PATH, header.c_str()); |
| 1543 | // search through the headers files for the constant |
| 1544 | char *token = strtok_s(lpszHeaders, ";", &next_token); |
| 1545 | while (token) |
| 1546 | { |
| 1547 | char singlefile[MAX_PATH] = ""; |
| 1548 | strcpy_s(singlefile, token); |
| 1549 | TruncateString(singlefile, '.'); // strip the .api part |
| 1550 | |
| 1551 | apiPointer = apiFiles.find(singlefile); // saves pointer to correct def filename |
| 1552 | if (apiPointer != apiFiles.end()) |
| 1553 | { |
| 1554 | newdefApiHFile = apiPointer->second; // overwrite the prev HFile with the correct |
| 1555 | newBase = newdefApiHFile->GetValue(szApiConstant, "Base"); // search for the next constant in the same header file |
| 1556 | if (newBase != "") // if base is found in the current header |
| 1557 | { |
| 1558 | if (newdefApiHFile != NULL) |
| 1559 | defApiHFile = newdefApiHFile; |
| 1560 | break; // exit headers loop |
| 1561 | } |
| 1562 | } |
| 1563 | |
| 1564 | // advance to the next header file |
| 1565 | token = strtok_s(nullptr, ";", &next_token); |
| 1566 | } |
| 1567 | |
| 1568 | header = newdefApiHFile->GetValue(szApiConstant, "Header"); // get new headers if any |
| 1569 | } |
| 1570 | |
| 1571 | if (getTypeDisplay) // walk the entire link chain |
| 1572 | { |
| 1573 | if (!newBase.empty()) |
| 1574 | { |
| 1575 | strcpy_s(lpszApiConstant, MAX_PATH, szApiConstant); |
| 1576 | ZeroMemory(szApiConstant, MAX_PATH); |
| 1577 | base = newBase; |
| 1578 | htype = newHtype; |
no test coverage detected