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.

57 lines
1.4 KiB

  1. #include "rc.h"
  2. int CALLBACK RC(HWND hWnd, int fStatus,
  3. RC_MESSAGE_CALLBACK lpfnMsg, RC_PARSE_CALLBACK lpfnParse,
  4. int argc, PCHAR *argv);
  5. extern BOOL WINAPI Handler(DWORD fdwCtrlType);
  6. int CALLBACK UpdateRCStatus(ULONG u, ULONG dw, PCHAR p)
  7. {
  8. int i = strlen(p);
  9. PCHAR ppercent = strchr(p, '%');
  10. if (i >= 2 && ((p[i - 1] == '\n' && p[i - 2] == '\r') ||
  11. (p[i - 1] == '\r' && p[i - 2] == '\n')))
  12. p[i-2] = '\0';
  13. if (*p) {
  14. if (ppercent) {
  15. for (ppercent=p,i=0 ; *ppercent ; ppercent++)
  16. if (*ppercent == '%')
  17. i++;
  18. ppercent = malloc(strlen(p) + 1 + i);
  19. if (ppercent) {
  20. PCHAR pT = ppercent;
  21. while (*p) {
  22. if (*p == '%')
  23. *pT++ = '%';
  24. *pT++ = *p++;
  25. }
  26. *pT++ = '\0';
  27. printf(ppercent);
  28. } else {
  29. while (strchr(p, '%'))
  30. *strchr(p, '%') = ' ';
  31. printf(p);
  32. }
  33. } else {
  34. printf(p);
  35. }
  36. }
  37. printf("\n");
  38. return (0);
  39. }
  40. int __cdecl main(int nArgC, char** pArgV)
  41. {
  42. int rc;
  43. SetConsoleCtrlHandler(Handler, TRUE);
  44. rc = RC(NULL, 0, UpdateRCStatus, NULL, nArgC, (PCHAR*)pArgV);
  45. SetConsoleCtrlHandler(Handler, FALSE);
  46. exit(rc);
  47. return 0;
  48. }