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.

227 lines
7.7 KiB

  1. /********************************************************************
  2. * Project : C:\DEPOT\multimedia\eHomeTest\UserXp\guidesearch\guidesearch.sln
  3. * File : ProgramArgs.cs
  4. * Summary :
  5. * Classes :
  6. * Notes :
  7. * *****************************************************************/
  8. using System;
  9. namespace GuideMgr
  10. {
  11. public enum QUERYTYPE {TITLE, KEYWORD, GENRE, ONNOW, TIME};
  12. public enum QUERYMODE {STARTSWITH, CONTAINS};
  13. /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C
  14. * public class ProgramArgs
  15. *
  16. * Summary :
  17. * ---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C*/
  18. public class ProgramArgs
  19. {
  20. /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  21. * static public int CommandLine(string[] args)
  22. * Args :
  23. * Modifies :
  24. * Returns :
  25. * M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M*/
  26. public bool CommandLine(string[] args)
  27. {
  28. foreach(string s in args)
  29. {
  30. /*----------------------------------------
  31. * Check for test type
  32. * ----------------------------------------*/
  33. // TEST = Length
  34. if ( s.StartsWith("tlen"))
  35. {
  36. _test = "len";
  37. }
  38. // TEST = SEARCH
  39. else if ( s.StartsWith("tsrch"))
  40. {
  41. _test = "search";
  42. }
  43. /*----------------------------------------
  44. * SEARCH Test Options
  45. * ----------------------------------------*/
  46. // Search type {STITILE, SKEYWORD, STIME}
  47. else if ( s.StartsWith("title"))
  48. {
  49. _queryType = QUERYTYPE.TITLE;
  50. }
  51. else if (s.StartsWith("keyword"))
  52. {
  53. _queryType = QUERYTYPE.KEYWORD;
  54. }
  55. // Search Mode { STARTSWITH, CONTAINS }
  56. else if ( s.StartsWith("contains"))
  57. {
  58. _queryMode = QUERYMODE.CONTAINS;
  59. }
  60. else if ( s.StartsWith("startswith"))
  61. {
  62. _queryMode = QUERYMODE.STARTSWITH;
  63. }
  64. // search string
  65. else if ( s.StartsWith("-s") && 2 < s.Length)
  66. {
  67. _searchString = s.Substring(2);
  68. }
  69. /*----------------------------------------
  70. * LENGTH Test Options
  71. * ----------------------------------------*/
  72. // title length
  73. else if ( s.StartsWith("-mt") && 3 < s.Length)
  74. {
  75. _maxTitleLen = System.Convert.ToInt32(s.Substring(3));
  76. }
  77. else if ( s.StartsWith("-md") && 3 < s.Length)
  78. {
  79. _maxDescLen = System.Convert.ToInt32(s.Substring(3));
  80. }
  81. /*----------------------------------------
  82. * COMMON Options
  83. * ----------------------------------------*/
  84. // Output File
  85. else if ( s.StartsWith("-o") && 2 < s.Length)
  86. {
  87. _outputFile = s.Substring(2);
  88. }
  89. // Append flag
  90. else if ( s.StartsWith("-p"))
  91. {
  92. _appendFlag = true;
  93. }
  94. // help flags
  95. else if ( s.StartsWith("-?") || s.StartsWith("/?") || s.StartsWith("-h") )
  96. {
  97. ArgsHelp();
  98. return false;
  99. }
  100. else
  101. {
  102. Console.WriteLine("Invalid parameter!!");
  103. ArgsHelp();
  104. return false;
  105. }
  106. } // foreach
  107. return true;
  108. } // public int ProgramArgs(string[] args)
  109. /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M
  110. * static private void ArgsHelp()
  111. * Args :
  112. * Modifies :
  113. * Returns :
  114. * M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M*/
  115. static private void ArgsHelp()
  116. {
  117. Console.WriteLine("Guidesearch [tlen|tsrch] [title|keyword] [startswith|contains] -s<Search String> -o<Output file> -p");
  118. Console.WriteLine("SEARCH MODE OPTIONS:");
  119. Console.WriteLine("\t[tlen|tsrch] = test type to run. tlen = length test, tsrch = search test.");
  120. Console.WriteLine("\t[title|keyword] = search on.");
  121. Console.WriteLine("\t[startswith|contains] = search mode.");
  122. Console.WriteLine("\t-s = string to search for. Begins with or contains mode\n\tselected automatically based on string length.");
  123. Console.WriteLine("\nLENGTH MODE OPTIONS:");
  124. Console.WriteLine("\t-mt<value> = Maximum title length allowed.");
  125. Console.WriteLine("\t-md<value> = Maximum description length allowed.");
  126. Console.WriteLine("\nCOMMON OPTIONS:");
  127. Console.WriteLine("\t-o = File to write results to. If parameter not given, output is to console.");
  128. Console.WriteLine("\t-p = Pass this parameter to append results to the file specified with the -o option");
  129. }
  130. /*---------------------------------------------------------
  131. Member Variables
  132. ----------------------------------------------------------*/
  133. // Test mode
  134. public string test
  135. {
  136. get { return _test; }
  137. set { _test = value; }
  138. }
  139. // URL of guide file
  140. public string GuideDb
  141. {
  142. get { return _GuideDb;}
  143. set { _GuideDb = value;}
  144. }
  145. // Search Type
  146. public QUERYTYPE QueryType
  147. {
  148. get { return _queryType;}
  149. set { _queryType = value;}
  150. }
  151. // Search mode
  152. public QUERYMODE QueryMode
  153. {
  154. get { return _queryMode; }
  155. set { _queryMode = value; }
  156. }
  157. // Search string
  158. public string SearchString
  159. {
  160. get { return _searchString; }
  161. set { _searchString = value; }
  162. }
  163. public int MaxTitleLen
  164. {
  165. get { return _maxTitleLen; }
  166. set { _maxTitleLen = value;}
  167. }
  168. public int MaxDescLen
  169. {
  170. get { return _maxDescLen; }
  171. set { _maxDescLen = value;}
  172. }
  173. // Write results to this file
  174. public string OutputFile
  175. {
  176. get { return _outputFile; }
  177. set { _outputFile = value; }
  178. }
  179. // Append flag
  180. public bool Append
  181. {
  182. get { return _appendFlag; }
  183. set { _appendFlag = value; }
  184. }
  185. // test to run
  186. string _test = "len";
  187. // Search test params
  188. QUERYTYPE _queryType = QUERYTYPE.KEYWORD;
  189. QUERYMODE _queryMode = QUERYMODE.CONTAINS;
  190. string _searchString = " ";
  191. // Length test params
  192. int _maxTitleLen = 255;
  193. int _maxDescLen = 16484;
  194. // Common params
  195. string _GuideDb = "tms.mgs";
  196. string _outputFile = "";
  197. bool _appendFlag = false;
  198. } // public class ProgramArgs
  199. } // namespace guidesearch