Leaked source code of windows server 2003
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.

123 lines
2.6 KiB

  1. /*++
  2. Copyright (c) 1993-1994 Microsoft Corporation
  3. Module Name:
  4. common.c
  5. Abstract:
  6. Utility routines used by IniToDat.exe
  7. Author:
  8. HonWah Chan (a-honwah) October, 1993
  9. Revision History:
  10. --*/
  11. //
  12. // Windows Include files
  13. //
  14. #include <windows.h>
  15. #include <strsafe.h>
  16. #include <winperf.h>
  17. //
  18. // local include files
  19. //
  20. #include "common.h"
  21. #include "strids.h"
  22. // Global Buffers
  23. //
  24. WCHAR DisplayStringBuffer[DISP_BUFF_SIZE];
  25. CHAR TextFormat[DISP_BUFF_SIZE];
  26. LPWSTR
  27. GetStringResource(
  28. UINT wStringId
  29. )
  30. /*++
  31. Retrived UNICODE strings from the resource file for display
  32. --*/
  33. {
  34. LPWSTR szReturn = (LPWSTR) L" ";
  35. HANDLE hMod = (HINSTANCE) GetModuleHandle(NULL); // get instance ID of this module;
  36. if (hMod) {
  37. ZeroMemory(DisplayStringBuffer, sizeof(DisplayStringBuffer));
  38. if ((LoadStringW(hMod, wStringId, DisplayStringBuffer, RTL_NUMBER_OF(DisplayStringBuffer))) > 0) {
  39. szReturn = DisplayStringBuffer;
  40. }
  41. }
  42. return szReturn;
  43. }
  44. LPSTR
  45. GetFormatResource(
  46. UINT wStringId
  47. )
  48. /*++
  49. Returns an ANSI string for use as a format string in a printf fn.
  50. --*/
  51. {
  52. LPSTR szReturn = (LPSTR) " ";
  53. HANDLE hMod = (HINSTANCE) GetModuleHandle(NULL); // get instance ID of this module;
  54. if (hMod) {
  55. ZeroMemory(TextFormat, sizeof(TextFormat));
  56. if ((LoadStringA(hMod, wStringId, TextFormat, RTL_NUMBER_OF(TextFormat))) > 0) {
  57. szReturn = TextFormat;
  58. }
  59. }
  60. return szReturn;
  61. }
  62. VOID
  63. DisplayCommandHelp(
  64. UINT iFirstLine,
  65. UINT iLastLine
  66. )
  67. /*++
  68. DisplayCommandHelp
  69. displays usage of command line arguments
  70. Arguments
  71. NONE
  72. Return Value
  73. NONE
  74. --*/
  75. {
  76. UINT iThisLine;
  77. for (iThisLine = iFirstLine; iThisLine <= iLastLine; iThisLine++) {
  78. printf("\n%ws", GetStringResource(iThisLine));
  79. }
  80. } // DisplayCommandHelp
  81. VOID
  82. DisplaySummary(
  83. LPWSTR lpLastID,
  84. LPWSTR lpLastText,
  85. UINT NumOfID
  86. )
  87. {
  88. printf("%ws", GetStringResource(LC_SUMMARY));
  89. printf("%ws", GetStringResource(LC_NUM_OF_ID));
  90. printf("%ld\n", NumOfID);
  91. printf("%ws", GetStringResource(LC_LAST_ID));
  92. printf("%ws\n", lpLastID ? lpLastID : L"");
  93. printf("%ws", GetStringResource(LC_LAST_TEXT));
  94. printf("%ws\n", lpLastText ? lpLastText : L"");
  95. }
  96. VOID
  97. DisplaySummaryError(
  98. LPWSTR lpLastID,
  99. LPWSTR lpLastText,
  100. UINT NumOfID
  101. )
  102. {
  103. printf("%ws", GetStringResource(LC_BAD_ID));
  104. printf("%ws\n", lpLastID ? lpLastID : L"");
  105. printf("%ws\n", GetStringResource(LC_MISSING_DEL));
  106. DisplaySummary(lpLastID, lpLastText, NumOfID);
  107. }