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.

165 lines
4.0 KiB

  1. #define EXT_ID " ulcase ver 2.01 "##__DATE__##" "##__TIME__
  2. /*
  3. ** ULcase Z extension
  4. **
  5. ** History:
  6. ** 30-Mar-1988 Broken out of "myext"
  7. ** 12-Sep-1988 mz Made WhenLoaded match declaration
  8. */
  9. #include <ctype.h>
  10. #include "ext.h"
  11. #ifndef TRUE
  12. #define TRUE -1
  13. #define FALSE 0
  14. #endif
  15. #ifndef NULL
  16. #define NULL ((char *) 0)
  17. #endif
  18. flagType pascal ulcase (ARG *, int, int, int);
  19. /*************************************************************************
  20. **
  21. ** id
  22. ** identify the source of the operation being performed
  23. */
  24. void id(char *pszFcn)
  25. {
  26. char buf[80] = {0}; /* message buffer */
  27. strncat (buf,pszFcn, sizeof(buf)-1); /* start with message */
  28. strncat (buf,EXT_ID, sizeof(buf)-strlen(buf)-1); /* append version */
  29. DoMessage (buf);
  30. }
  31. /*************************************************************************
  32. **
  33. ** ucase
  34. ** convert arg to upper case.
  35. */
  36. flagType pascal EXTERNAL
  37. ucase (
  38. CMDDATA argData,
  39. ARG far *pArg,
  40. flagType fMeta
  41. )
  42. {
  43. (void)argData;
  44. (void)fMeta;
  45. id("ucase:");
  46. return ulcase (pArg, 'a', 'z', 'A'-'a');
  47. }
  48. /*************************************************************************
  49. **
  50. ** lcase
  51. ** convert arg to lower case.
  52. */
  53. flagType pascal EXTERNAL
  54. lcase (
  55. CMDDATA argData,
  56. ARG far *pArg,
  57. flagType fMeta
  58. )
  59. {
  60. (void)argData;
  61. (void)fMeta;
  62. id("lcase:");
  63. return ulcase (pArg, 'A', 'Z', 'a'-'A');
  64. }
  65. /*
  66. ** ulcase
  67. ** convert arg case.
  68. */
  69. flagType pascal ulcase (pArg, cLow, cHigh, cAdj)
  70. ARG *pArg; /* argument data */
  71. int cLow; /* low char of range to check for */
  72. int cHigh; /* high char of range to check for */
  73. int cAdj; /* adjustment to make */
  74. {
  75. PFILE pFile;
  76. COL xStart;
  77. LINE yStart;
  78. COL xEnd;
  79. LINE yEnd;
  80. int i;
  81. COL xT;
  82. char buf[BUFLEN];
  83. pFile = FileNameToHandle ("", "");
  84. switch (pArg->argType) {
  85. case NOARG: /* case switch entire line */
  86. xStart = 0;
  87. xEnd = 32765;
  88. yStart = yEnd = pArg->arg.noarg.y;
  89. break;
  90. case NULLARG: /* case switch to EOL */
  91. xStart = pArg->arg.nullarg.x;
  92. xEnd = 32765;
  93. yStart = yEnd = pArg->arg.nullarg.y;
  94. break;
  95. case LINEARG: /* case switch line range */
  96. xStart = 0;
  97. xEnd = 32765;
  98. yStart = pArg->arg.linearg.yStart;
  99. yEnd = pArg->arg.linearg.yEnd;
  100. break;
  101. case BOXARG: /* case switch box */
  102. xStart = pArg->arg.boxarg.xLeft;
  103. xEnd = pArg->arg.boxarg.xRight;
  104. yStart = pArg->arg.boxarg.yTop;
  105. yEnd = pArg->arg.boxarg.yBottom;
  106. break;
  107. }
  108. while (yStart <= yEnd) {
  109. i = GetLine (yStart, buf, pFile);
  110. xT = xStart; /* start at begin of box*/
  111. while ((xT <= i) && (xT <= xEnd)) { /* while in box */
  112. if ((int)buf[xT] >= cLow && (int)buf[xT] <= cHigh)
  113. buf[xT] += (char)cAdj;
  114. xT++;
  115. }
  116. PutLine (yStart++, buf, pFile);
  117. }
  118. return TRUE;
  119. }
  120. /*
  121. ** switch communication table to Z
  122. */
  123. struct swiDesc swiTable[] = {
  124. {0, 0, 0}
  125. };
  126. /*
  127. ** command communication table to Z
  128. */
  129. struct cmdDesc cmdTable[] = {
  130. { "ucase", ucase, 0, MODIFIES | KEEPMETA | NOARG | BOXARG | NULLARG | LINEARG },
  131. { "lcase", lcase, 0, MODIFIES | KEEPMETA | NOARG | BOXARG | NULLARG | LINEARG },
  132. {0, 0, 0}
  133. };
  134. /*
  135. ** WhenLoaded
  136. ** Executed when these extensions get loaded. Identify self & assign keys.
  137. */
  138. void EXTERNAL WhenLoaded () {
  139. id("case conversion:");
  140. SetKey ("ucase", "alt+u");
  141. SetKey ("lcase", "alt+l");
  142. }