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.

417 lines
8.1 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. mbrutil.c
  5. Abstract:
  6. This file contains miscelaneous functions used in the browser extension.
  7. These functions include argument processing, message displaying,
  8. setting of switches, etc.
  9. Author:
  10. Ramon Juan San Andres (ramonsa) 06-Nov-1990
  11. Revision History:
  12. --*/
  13. #include "mbr.h"
  14. /**************************************************************************/
  15. int
  16. pascal
  17. procArgs (
  18. IN ARG far * pArg
  19. )
  20. /*++
  21. Routine Description:
  22. Decodes arguments passed into extension into commonly used
  23. variables.
  24. Arguments:
  25. pArg - Supplies a pointer to the arguments.
  26. Return Value:
  27. The type of the argument.
  28. --*/
  29. {
  30. buf[0] = 0;
  31. cArg = 0;
  32. pArgWord = 0;
  33. pArgText = 0;
  34. rnArg.flFirst.col = rnArg.flLast.col = 0;
  35. rnArg.flFirst.lin = rnArg.flLast.lin = 0;
  36. pFileCur = FileNameToHandle ("", ""); /* get current file handle */
  37. switch (pArg->argType) {
  38. case NOARG: /* <function> only, no arg */
  39. cArg = pArg->arg.nullarg.cArg; /* get <arg> count */
  40. GrabWord (); /* get argtext and argword */
  41. break;
  42. case NULLARG: /* <arg><function> */
  43. cArg = pArg->arg.nullarg.cArg; /* get <arg> count */
  44. GrabWord (); /* get argtext and argword */
  45. break;
  46. case STREAMARG: /* <arg>line movement<function> */
  47. cArg = pArg->arg.streamarg.cArg;/* get <arg> count */
  48. rnArg.flFirst.col = pArg->arg.streamarg.xStart;
  49. rnArg.flLast.col = pArg->arg.streamarg.xEnd;
  50. rnArg.flFirst.lin = pArg->arg.streamarg.yStart;
  51. if (GetLine(rnArg.flFirst.lin, buf, pFileCur) > rnArg.flFirst.col) {
  52. pArgText = &buf[rnArg.flFirst.col]; /* point at word */
  53. buf[rnArg.flLast.col] = 0; /* terminate string */
  54. }
  55. break;
  56. case TEXTARG: /* <arg> text <function> */
  57. cArg = pArg->arg.textarg.cArg; /* get <arg> count */
  58. pArgText = pArg->arg.textarg.pText;
  59. break;
  60. }
  61. return pArg->argType;
  62. }
  63. /**************************************************************************/
  64. void
  65. pascal
  66. GrabWord (
  67. void
  68. )
  69. /*++
  70. Routine Description:
  71. Grabs the word underneath the cursor.
  72. Upon exit, pArgText points to the word
  73. Arguments:
  74. None
  75. Return Value:
  76. None.
  77. --*/
  78. {
  79. pArgText = pArgWord = 0;
  80. pFileCur = FileNameToHandle ("", ""); // get current file handle
  81. GetTextCursor (&rnArg.flFirst.col, &rnArg.flFirst.lin);
  82. if (GetLine(rnArg.flFirst.lin, buf, pFileCur)) {
  83. //
  84. // get line
  85. //
  86. pArgText = &buf[rnArg.flFirst.col]; // point at word
  87. while (!wordSepar((int)*pArgText)) {
  88. //
  89. // Search for end
  90. //
  91. pArgText++;
  92. }
  93. *pArgText = 0; // and terminate
  94. pArgWord = pArgText = &buf[rnArg.flFirst.col]; // point at word
  95. while ((pArgWord > &buf[0]) && !wordSepar ((int)*(pArgWord-1))) {
  96. pArgWord--;
  97. }
  98. }
  99. }
  100. /**************************************************************************/
  101. flagType
  102. pascal
  103. wordSepar (
  104. IN CHAR c
  105. )
  106. /*++
  107. Routine Description:
  108. Find out if character is a word separator.
  109. A word separator is anything not in the [a-z, A-Z, 0-9] set.
  110. Arguments:
  111. c - Supplies the character.
  112. Return Value:
  113. TRUE if c is a word separator, FALSE otherwise
  114. --*/
  115. {
  116. if (((c >= 'a') && (c <= 'z')) ||
  117. ((c >= 'A') && (c <= 'Z')) ||
  118. ((c >= '0') && (c <= '9'))) {
  119. return FALSE;
  120. } else {
  121. return TRUE;
  122. }
  123. }
  124. /**************************************************************************/
  125. flagType
  126. pascal
  127. errstat (
  128. IN char *sz1,
  129. IN char *sz2
  130. )
  131. /*++
  132. Routine Description:
  133. Concatenates two strings and displays them on the status line.
  134. Arguments:
  135. sz1 - Supplies a pointer to the first string
  136. sz2 - Supplies a pointer to the second string.
  137. Return Value:
  138. FALSE
  139. --*/
  140. {
  141. buffer buf;
  142. strcpy (buf, sz1);
  143. if (sz2) {
  144. strcat (buf, " ");
  145. strcat (buf, sz2);
  146. }
  147. _stat (buf);
  148. return FALSE;
  149. }
  150. /**************************************************************************/
  151. void
  152. pascal
  153. _stat (
  154. IN char * pszFcn
  155. )
  156. /*++
  157. Routine Description:
  158. Displays extension name and message on the status line
  159. Arguments:
  160. pszFcn - Message to display
  161. Return Value:
  162. None.
  163. --*/
  164. {
  165. buffer buf; /* message buffer */
  166. strcpy(buf,"mbrowse: "); /* start with name */
  167. if (strlen(pszFcn) > 72) {
  168. pszFcn+= strlen(pszFcn) - 69;
  169. strcat (buf, "...");
  170. }
  171. strcat(buf,pszFcn); /* append message */
  172. DoMessage (buf); /* display */
  173. }
  174. /**************************************************************************/
  175. int
  176. far
  177. pascal
  178. SetMatchCriteria (
  179. IN char far *pTxt
  180. )
  181. /*++
  182. Routine Description:
  183. Sets the mbrmatch switch.
  184. Creates an MBF mask from the given string and sets the BscMbf variable.
  185. Arguments:
  186. pTxt - Supplies the string containing the new default
  187. match criteria.
  188. Return Value:
  189. TRUE if string contains a valid value.
  190. FALSE otherwise
  191. --*/
  192. {
  193. MBF mbfReqd;
  194. mbfReqd = GetMbf(pTxt);
  195. if (mbfReqd != mbfNil) {
  196. BscMbf = mbfReqd;
  197. } else {
  198. return FALSE;
  199. }
  200. BscCmnd = CMND_NONE; // reset command state
  201. return TRUE;
  202. }
  203. /**************************************************************************/
  204. int
  205. far
  206. pascal
  207. SetCalltreeDirection (
  208. IN char far *pTxt
  209. )
  210. /*++
  211. Routine Description:
  212. Sets the mbrdir switch.
  213. Sets the BscCalltreeDir variable to CALLTREE_FORWARD or
  214. CALLTREE_BACKWARD, depending on the first character of the
  215. string supplied.
  216. The given string must start with either 'F' or 'B'.
  217. Arguments:
  218. pTxt - Supplies the string containing the new default
  219. direction.
  220. Return Value:
  221. TRUE if the string contains a valid value,
  222. FALSE otherwise.
  223. --*/
  224. {
  225. switch(*pTxt) {
  226. case 'f':
  227. case 'F':
  228. BscCalltreeDir = CALLTREE_FORWARD;
  229. break;
  230. case 'b':
  231. case 'B':
  232. BscCalltreeDir = CALLTREE_BACKWARD;
  233. break;
  234. default:
  235. return FALSE;
  236. break;
  237. }
  238. BscCmnd = CMND_NONE; // Reset command state
  239. return TRUE;
  240. }
  241. /**************************************************************************/
  242. MBF
  243. pascal
  244. GetMbf(
  245. IN PBYTE pTxt
  246. )
  247. /*++
  248. Routine Description:
  249. Creates an MBF mask from a given string.
  250. The string is parsed for the characters 'T', 'V', 'F', and 'M'.
  251. Arguments:
  252. pTxt - Supplies a pointer to string
  253. Return Value:
  254. MBF mask generated from string
  255. --*/
  256. {
  257. MBF mbfReqd = mbfNil;
  258. if (pTxt) {
  259. while (*pTxt) {
  260. switch(*pTxt++) {
  261. case 'f':
  262. case 'F':
  263. mbfReqd |= mbfFuncs;
  264. break;
  265. case 'v':
  266. case 'V':
  267. mbfReqd |= mbfVars;
  268. break;
  269. case 'm':
  270. case 'M':
  271. mbfReqd |= mbfMacros;
  272. break;
  273. case 't':
  274. case 'T':
  275. mbfReqd |= mbfTypes;
  276. break;
  277. default:
  278. break;
  279. }
  280. }
  281. }
  282. return mbfReqd;
  283. }