Lines Matching refs:pDescriptor

1396 static int vmdkDescInitStr(PVMDKIMAGE pImage, PVMDKDESCRIPTOR pDescriptor,
1399 char *pEnd = pDescriptor->aLines[pDescriptor->cLines];
1402 if ( pDescriptor->cLines >= VMDK_DESCRIPTOR_LINES_MAX - 1
1403 && pEnd - pDescriptor->aLines[0] > (ptrdiff_t)pDescriptor->cbDescAlloc - cbDiff)
1407 pDescriptor->cLines++;
1408 pDescriptor->aLines[pDescriptor->cLines] = pEnd + cbDiff;
1409 pDescriptor->fDirty = true;
1414 static bool vmdkDescGetStr(PVMDKDESCRIPTOR pDescriptor, unsigned uStart,
1422 if (!strncmp(pDescriptor->aLines[uStart], pszKey, cbKey))
1425 pszValue = pDescriptor->aLines[uStart] + cbKey;
1434 uStart = pDescriptor->aNextLines[uStart];
1439 static int vmdkDescSetStr(PVMDKIMAGE pImage, PVMDKDESCRIPTOR pDescriptor,
1449 if (!strncmp(pDescriptor->aLines[uStart], pszKey, cbKey))
1452 pszTmp = pDescriptor->aLines[uStart] + cbKey;
1463 if (!pDescriptor->aNextLines[uStart])
1465 uStart = pDescriptor->aNextLines[uStart];
1476 if ( pDescriptor->aLines[pDescriptor->cLines]
1477 - pDescriptor->aLines[0] > (ptrdiff_t)pDescriptor->cbDescAlloc - cbDiff)
1481 pDescriptor->aLines[pDescriptor->cLines] - pszTmp - cbOldVal);
1483 for (unsigned i = uStart + 1; i <= pDescriptor->cLines; i++)
1484 pDescriptor->aLines[i] += cbDiff;
1488 memmove(pDescriptor->aLines[uStart], pDescriptor->aLines[uStart+1],
1489 pDescriptor->aLines[pDescriptor->cLines] - pDescriptor->aLines[uStart+1] + 1);
1490 for (unsigned i = uStart + 1; i <= pDescriptor->cLines; i++)
1492 pDescriptor->aLines[i-1] = pDescriptor->aLines[i];
1493 if (pDescriptor->aNextLines[i])
1494 pDescriptor->aNextLines[i-1] = pDescriptor->aNextLines[i] - 1;
1496 pDescriptor->aNextLines[i-1] = 0;
1498 pDescriptor->cLines--;
1500 if (uStart < pDescriptor->uFirstExtent)
1501 pDescriptor->uFirstExtent--;
1502 if (uStart < pDescriptor->uFirstDDB)
1503 pDescriptor->uFirstDDB--;
1518 if ( (pDescriptor->cLines >= VMDK_DESCRIPTOR_LINES_MAX - 1)
1519 || ( pDescriptor->aLines[pDescriptor->cLines]
1520 - pDescriptor->aLines[0] > (ptrdiff_t)pDescriptor->cbDescAlloc - cbDiff))
1522 for (unsigned i = pDescriptor->cLines + 1; i > uLast + 1; i--)
1524 pDescriptor->aLines[i] = pDescriptor->aLines[i - 1];
1525 if (pDescriptor->aNextLines[i - 1])
1526 pDescriptor->aNextLines[i] = pDescriptor->aNextLines[i - 1] + 1;
1528 pDescriptor->aNextLines[i] = 0;
1531 pDescriptor->aNextLines[uLast] = uStart;
1532 pDescriptor->aNextLines[uStart] = 0;
1533 pDescriptor->cLines++;
1534 pszTmp = pDescriptor->aLines[uStart];
1536 pDescriptor->aLines[pDescriptor->cLines] - pszTmp);
1537 memcpy(pDescriptor->aLines[uStart], pszKey, cbKey);
1538 pDescriptor->aLines[uStart][cbKey] = '=';
1539 memcpy(pDescriptor->aLines[uStart] + cbKey + 1, pszValue, cbValue + 1);
1540 for (unsigned i = uStart + 1; i <= pDescriptor->cLines; i++)
1541 pDescriptor->aLines[i] += cbDiff;
1544 if (uStart <= pDescriptor->uFirstExtent)
1545 pDescriptor->uFirstExtent++;
1546 if (uStart <= pDescriptor->uFirstDDB)
1547 pDescriptor->uFirstDDB++;
1549 pDescriptor->fDirty = true;
1553 static int vmdkDescBaseGetU32(PVMDKDESCRIPTOR pDescriptor, const char *pszKey,
1558 if (!vmdkDescGetStr(pDescriptor, pDescriptor->uFirstDesc, pszKey,
1564 static int vmdkDescBaseGetStr(PVMDKIMAGE pImage, PVMDKDESCRIPTOR pDescriptor,
1570 if (!vmdkDescGetStr(pDescriptor, pDescriptor->uFirstDesc, pszKey,
1580 static int vmdkDescBaseSetStr(PVMDKIMAGE pImage, PVMDKDESCRIPTOR pDescriptor,
1588 int rc = vmdkDescSetStr(pImage, pDescriptor, pDescriptor->uFirstDesc, pszKey,
1595 PVMDKDESCRIPTOR pDescriptor)
1597 unsigned uEntry = pDescriptor->uFirstExtent;
1603 cbDiff = strlen(pDescriptor->aLines[uEntry]) + 1;
1605 memmove(pDescriptor->aLines[uEntry], pDescriptor->aLines[uEntry + 1],
1606 pDescriptor->aLines[pDescriptor->cLines] - pDescriptor->aLines[uEntry + 1] + 1);
1607 for (unsigned i = uEntry + 1; i <= pDescriptor->cLines; i++)
1609 pDescriptor->aLines[i - 1] = pDescriptor->aLines[i] - cbDiff;
1610 if (pDescriptor->aNextLines[i])
1611 pDescriptor->aNextLines[i - 1] = pDescriptor->aNextLines[i] - 1;
1613 pDescriptor->aNextLines[i - 1] = 0;
1615 pDescriptor->cLines--;
1616 if (pDescriptor->uFirstDDB)
1617 pDescriptor->uFirstDDB--;
1622 static int vmdkDescExtInsert(PVMDKIMAGE pImage, PVMDKDESCRIPTOR pDescriptor,
1630 unsigned uStart = pDescriptor->uFirstExtent, uLast = 0;
1640 if (!pDescriptor->aNextLines[uStart])
1642 uStart = pDescriptor->aNextLines[uStart];
1665 if ( (pDescriptor->cLines >= VMDK_DESCRIPTOR_LINES_MAX - 1)
1666 || ( pDescriptor->aLines[pDescriptor->cLines]
1667 - pDescriptor->aLines[0] > (ptrdiff_t)pDescriptor->cbDescAlloc - cbDiff))
1670 for (unsigned i = pDescriptor->cLines + 1; i > uLast + 1; i--)
1672 pDescriptor->aLines[i] = pDescriptor->aLines[i - 1];
1673 if (pDescriptor->aNextLines[i - 1])
1674 pDescriptor->aNextLines[i] = pDescriptor->aNextLines[i - 1] + 1;
1676 pDescriptor->aNextLines[i] = 0;
1679 pDescriptor->aNextLines[uLast] = uStart;
1680 pDescriptor->aNextLines[uStart] = 0;
1681 pDescriptor->cLines++;
1682 pszTmp = pDescriptor->aLines[uStart];
1684 pDescriptor->aLines[pDescriptor->cLines] - pszTmp);
1685 memcpy(pDescriptor->aLines[uStart], szExt, cbDiff);
1686 for (unsigned i = uStart + 1; i <= pDescriptor->cLines; i++)
1687 pDescriptor->aLines[i] += cbDiff;
1690 if (uStart <= pDescriptor->uFirstDDB)
1691 pDescriptor->uFirstDDB++;
1693 pDescriptor->fDirty = true;
1697 static int vmdkDescDDBGetStr(PVMDKIMAGE pImage, PVMDKDESCRIPTOR pDescriptor,
1703 if (!vmdkDescGetStr(pDescriptor, pDescriptor->uFirstDDB, pszKey,
1713 static int vmdkDescDDBGetU32(PVMDKIMAGE pImage, PVMDKDESCRIPTOR pDescriptor,
1719 if (!vmdkDescGetStr(pDescriptor, pDescriptor->uFirstDDB, pszKey,
1730 static int vmdkDescDDBGetUuid(PVMDKIMAGE pImage, PVMDKDESCRIPTOR pDescriptor,
1736 if (!vmdkDescGetStr(pDescriptor, pDescriptor->uFirstDDB, pszKey,
1747 static int vmdkDescDDBSetStr(PVMDKIMAGE pImage, PVMDKDESCRIPTOR pDescriptor,
1761 rc = vmdkDescSetStr(pImage, pDescriptor, pDescriptor->uFirstDDB, pszKey,
1768 static int vmdkDescDDBSetUuid(PVMDKIMAGE pImage, PVMDKDESCRIPTOR pDescriptor,
1776 int rc = vmdkDescSetStr(pImage, pDescriptor, pDescriptor->uFirstDDB, pszKey,
1782 static int vmdkDescDDBSetU32(PVMDKIMAGE pImage, PVMDKDESCRIPTOR pDescriptor,
1790 int rc = vmdkDescSetStr(pImage, pDescriptor, pDescriptor->uFirstDDB, pszKey,
1798 PVMDKDESCRIPTOR pDescriptor)
1804 pDescriptor->cbDescAlloc = cbDescData;
1807 pDescriptor->aLines[cLine++] = pTmp;
1838 pDescriptor->cLines = cLine;
1840 pDescriptor->aLines[cLine] = pTmp;
1842 if ( strcmp(pDescriptor->aLines[0], "# Disk DescriptorFile")
1843 && strcmp(pDescriptor->aLines[0], "# Disk Descriptor File"))
1850 pDescriptor->uFirstDesc = 0;
1851 pDescriptor->uFirstExtent = 0;
1852 pDescriptor->uFirstDDB = 0;
1855 if (*pDescriptor->aLines[i] != '#' && *pDescriptor->aLines[i] != '\0')
1857 if ( !strncmp(pDescriptor->aLines[i], "RW", 2)
1858 || !strncmp(pDescriptor->aLines[i], "RDONLY", 6)
1859 || !strncmp(pDescriptor->aLines[i], "NOACCESS", 8) )
1862 if (!pDescriptor->uFirstDesc || pDescriptor->uFirstDDB)
1868 if (!pDescriptor->uFirstExtent)
1870 pDescriptor->uFirstExtent = i;
1874 else if (!strncmp(pDescriptor->aLines[i], "ddb.", 4))
1877 if (!pDescriptor->uFirstDesc || !pDescriptor->uFirstExtent)
1883 if (!pDescriptor->uFirstDDB)
1885 pDescriptor->uFirstDDB = i;
1892 if (pDescriptor->uFirstExtent || pDescriptor->uFirstDDB)
1898 if (!pDescriptor->uFirstDesc)
1900 pDescriptor->uFirstDesc = i;
1905 pDescriptor->aNextLines[uLastNonEmptyLine] = i;
1954 size_t cbDescData, PVMDKDESCRIPTOR pDescriptor)
1958 pDescriptor->uFirstDesc = 0;
1959 pDescriptor->uFirstExtent = 0;
1960 pDescriptor->uFirstDDB = 0;
1961 pDescriptor->cLines = 0;
1962 pDescriptor->cbDescAlloc = cbDescData;
1963 pDescriptor->fDirty = false;
1964 pDescriptor->aLines[pDescriptor->cLines] = pDescData;
1965 memset(pDescriptor->aNextLines, '\0', sizeof(pDescriptor->aNextLines));
1967 rc = vmdkDescInitStr(pImage, pDescriptor, "# Disk DescriptorFile");
1970 rc = vmdkDescInitStr(pImage, pDescriptor, "version=1");
1973 pDescriptor->uFirstDesc = pDescriptor->cLines - 1;
1974 rc = vmdkDescInitStr(pImage, pDescriptor, "");
1977 rc = vmdkDescInitStr(pImage, pDescriptor, "# Extent description");
1980 rc = vmdkDescInitStr(pImage, pDescriptor, "NOACCESS 0 ZERO ");
1983 pDescriptor->uFirstExtent = pDescriptor->cLines - 1;
1984 rc = vmdkDescInitStr(pImage, pDescriptor, "");
1988 rc = vmdkDescInitStr(pImage, pDescriptor, "# The disk Data Base ");
1991 rc = vmdkDescInitStr(pImage, pDescriptor, "#DDB");
1994 rc = vmdkDescInitStr(pImage, pDescriptor, "");
1997 rc = vmdkDescInitStr(pImage, pDescriptor, "ddb.virtualHWVersion = \"4\"");
2000 pDescriptor->uFirstDDB = pDescriptor->cLines - 1;
2006 rc = vmdkDescSetStr(pImage, pDescriptor, pDescriptor->uFirstDesc,
2010 rc = vmdkDescSetStr(pImage, pDescriptor, pDescriptor->uFirstDesc,
2015 rc = vmdkDescDDBSetStr(pImage, pDescriptor, "ddb.adapterType", "ide");