Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.1 KiB

  1. #include "precomp.h"
  2. #pragma hdrstop
  3. /**************************************************************************/
  4. /***** Common Library Component - SymTab INF File Handling Routines 2 *****/
  5. /**************************************************************************/
  6. /*
  7. ** Purpose:
  8. ** Adds a new symbol/value association to the Symbol Table for the
  9. ** key and first field of the current line pointed to by the current
  10. ** INF read location.
  11. ** Arguments:
  12. ** none
  13. ** Notes:
  14. ** Requires that the current INF structure was initialized with a
  15. ** successful call to GrcOpenInf() and that the current INF read
  16. ** location is defined.
  17. ** Requires that the Symbol Table was initialized with a successful
  18. ** call to FInitSymTab().
  19. ** Requires that the current INF line contain a key.
  20. ** Returns:
  21. ** fFalse if an allocate operation fails.
  22. ** fTrue if the current line contains a key and it was successfully
  23. ** associated with the value from the first field of the current
  24. ** line (or the empty string if the first field does not exist.)
  25. **
  26. **************************************************************************/
  27. BOOL APIENTRY FAddSymbolFromInfLineToSymTab(INT Line)
  28. {
  29. BOOL fAnswer;
  30. SZ szKey;
  31. SZ szValue;
  32. PreCondSymTabInit(fFalse);
  33. PreCondInfOpen(fFalse);
  34. PreCondition(FKeyInInfLine(Line), fFalse);
  35. szKey = SzGetNthFieldFromInfLine(Line,0);
  36. AssertRet(*szKey != '\0' &&
  37. !FWhiteSpaceChp(*szKey), fFalse);
  38. if ((szValue = SzGetNthFieldFromInfLine(Line,1)) == (SZ)NULL)
  39. fAnswer = FAddSymbolValueToSymTab(szKey, "");
  40. else
  41. fAnswer = FAddSymbolValueToSymTab(szKey, szValue);
  42. if(szValue) {
  43. SFree(szValue);
  44. }
  45. SFree(szKey);
  46. return(fAnswer);
  47. }
  48. /*
  49. ** Purpose:
  50. ** Adds a new symbol/value association to the Symbol Table for the
  51. ** key and first field of each line in the specified section.
  52. ** Arguments:
  53. ** szSection: non-NULL, non-empty section.
  54. ** Notes:
  55. ** Requires that the current INF structure was initialized with a
  56. ** successful call to GrcOpenInf().
  57. ** Requires that the Symbol Table was initialized with a successful
  58. ** call to FInitSymTab().
  59. ** Returns:
  60. ** grcINFBadRSLine if any line does not contain a key.
  61. ** grcOutOfMemory if any allocation operation fails.
  62. ** grcOkay if szSection was found, each line in it contained a key, and
  63. ** every key and first field (or the empty string if the first field
  64. ** does not exist) is successfully added to the Symbol Table as a
  65. ** symbol/value association.
  66. ** grcNotOkay otherwise.
  67. **
  68. **************************************************************************/
  69. GRC APIENTRY GrcAddSymsFromInfSection(SZ szSection)
  70. {
  71. INT Line;
  72. AssertDataSeg();
  73. PreCondSymTabInit(grcNotOkay);
  74. PreCondInfOpen(grcNotOkay);
  75. ChkArg(szSection != (SZ)NULL &&
  76. *szSection != '\0' &&
  77. !FWhiteSpaceChp(*szSection), 1, grcNotOkay);
  78. Line = FindFirstLineFromInfSection(szSection);
  79. while (Line != -1)
  80. {
  81. if (!FKeyInInfLine(Line))
  82. return(grcINFBadRSLine);
  83. if (!FAddSymbolFromInfLineToSymTab(Line))
  84. return(grcOutOfMemory);
  85. Line = FindNextLineFromInf(Line);
  86. }
  87. return(grcOkay);
  88. }