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.

866 lines
26 KiB

  1. REM
  2. REM LOCALIZATION
  3. REM
  4. L_SWITCH_OPERATION = "-t"
  5. L_SWITCH_SERVER = "-s"
  6. L_SWITCH_INSTANCE_ID = "-v"
  7. L_SWITCH_FEED_SERVER = "-r"
  8. L_SWITCH_FEED_ID = "-i"
  9. L_SWITCH_TYPE = "-f"
  10. L_SWITCH_UUCPNAME = "-u"
  11. L_SWITCH_ACCOUNT = "-a"
  12. L_SWITCH_PASSWORD = "-b"
  13. L_SWITCH_ENABLED = "-e"
  14. L_SWITCH_INBOUND_ACTION = "-ia"
  15. L_SWITCH_INBOUND_NEWSGROUPS = "-in"
  16. L_SWITCH_INBOUND_INTERVAL = "-ix"
  17. L_SWITCH_INBOUND_AUTO_CREATE = "-ic"
  18. L_SWITCH_INBOUND_PROCESS_CTRL_MSGS = "-iz"
  19. L_SWITCH_INBOUND_PULL_TIME = "-io"
  20. L_SWITCH_INBOUND_MAX_CONNECTION_ATTEMPTS = "-im"
  21. L_SWITCH_INBOUND_PORT = "-ip"
  22. L_SWITCH_INBOUND_TEMPDIR = "-it"
  23. L_SWITCH_OUTBOUND_ACTION = "-oa"
  24. L_SWITCH_OUTBOUND_NEWSGROUPS = "-on"
  25. L_SWITCH_OUTBOUND_INTERVAL = "-ox"
  26. L_SWITCH_OUTBOUND_PROCESS_CTRL_MSGS = "-oz"
  27. L_SWITCH_OUTBOUND_MAX_CONNECTION_ATTEMPTS = "-om"
  28. L_SWITCH_OUTBOUND_PORT = "-op"
  29. L_SWITCH_OUTBOUND_TEMPDIR = "-ot"
  30. L_OP_ADD = "a"
  31. L_OP_DELETE = "d"
  32. L_OP_GET = "g"
  33. L_OP_SET = "s"
  34. L_OP_ENUMERATE = "e"
  35. L_DESC_PROGRAM = "rfeed - Set NNTP feeds"
  36. L_DESC_ADD = "add a feed"
  37. L_DESC_DELETE = "delete a feed"
  38. L_DESC_GET = "get information on a feed"
  39. L_DESC_SET = "set information on a feed"
  40. L_DESC_ENUMERATE = "enumerate feeds"
  41. L_DESC_OPERATIONS = "<operations>"
  42. L_DESC_SERVER = "<server> Specify computer to configure"
  43. L_DESC_INSTANCE_ID = "<virtual server id> Specify virtual server id"
  44. L_DESC_FEED_ID = "<feed id> Specify feed id"
  45. L_DESC_INBOUND = "Switches for inbound feed settings:"
  46. L_DESC_OUTBOUND = "Switches for outbound feed settings:"
  47. L_DESC_FEED_SERVER = "server against which the feed operates"
  48. L_DESC_TYPE = "[peer | master | slave]"
  49. L_DESC_UUCPNAME = "uucp name"
  50. L_DESC_ACCOUNT = "authinfo account"
  51. L_DESC_PASSWORD = "authinfo password"
  52. L_DESC_ENABLED = "[true | false] Enable feed"
  53. L_DESC_INBOUND_ACTION = "[Pull | Accept | None]"
  54. L_DESC_OUTBOUND_ACTION = "[Push | None ]"
  55. L_DESC_NEWSGROUPS = "newsgroup patterns"
  56. L_DESC_INTERVAL = "<# minutes> wait time between feed runs"
  57. L_DESC_AUTO_CREATE = "[true | false] Create Newsgroups automatically (pull feed only)"
  58. L_DESC_PROCESS_CTRL_MSGS = "[true | false] Process control messages"
  59. L_DESC_PULL_TIME = "<date> get articles after this date (pull feed only)"
  60. L_DESC_MAX_CONNECTION_ATTEMPTS = "Max Connection attempts"
  61. L_DESC_OUTBOUND_PORT = "Outbound IP port"
  62. L_DESC_TEMPDIR = "Temporary files directory"
  63. L_DESC_EXAMPLES = "Examples:"
  64. L_DESC_EXAMPLE1 = "rfeed.vbs -t e"
  65. L_DESC_EXAMPLE2 = "rfeed.vbs -t a -r FeedServer.mydomain.com -f peer -ia pull -in *"
  66. L_DESC_EXAMPLE3 = "rfeed.vbs -t d -i 1"
  67. L_DESC_EXAMPLE4 = "rfeed.vbs -t s -i 1 -ix 120"
  68. L_STR_INBOUND_FEED = "Inbound feed properties:"
  69. L_STR_OUTBOUND_FEED = "Outbound feed properties:"
  70. L_STR_FEED_SERVER = "Remote server:"
  71. L_STR_FEED_ID = "Feed ID:"
  72. L_STR_TYPE = "Feed type:"
  73. L_STR_ACTION = "Action:"
  74. L_STR_ENABLED = "Enabled:"
  75. L_STR_INTERVAL = "Interval (minutes):"
  76. L_STR_UUCPNAME = "Path header (Uucp name):"
  77. L_STR_PROCESS_CTRL_MSGS = "Process control messages:"
  78. L_STR_ACCOUNT = "Authinfo account:"
  79. L_STR_MAX_CONNECTION_ATTEMPTS = "Maximum connection attempts:"
  80. L_STR_AUTO_CREATE = "Create newsgroups automatically?"
  81. L_STR_PULL_TIME = "Pull news articles from:"
  82. L_STR_OUTGOING_PORT = "Outgoing port:"
  83. L_STR_NEWSGROUPS = "Newsgroups:"
  84. L_STR_TEMPDIR = "Temp Directory:"
  85. L_STR_FEED_TYPE_PEER = "Peer"
  86. L_STR_FEED_TYPE_MASTER = "Master"
  87. L_STR_FEED_TYPE_SLAVE = "Slave"
  88. L_STR_FEED_ACTION_NONE = "None"
  89. L_STR_FEED_ACTION_PULL = "Pull"
  90. L_STR_FEED_ACTION_PUSH = "Push"
  91. L_STR_FEED_ACTION_ACCEPT = "Accept"
  92. L_STR_UNLIMITED = "Unlimited"
  93. L_STR_ADDED_FEED = "Successfully added the following feed:"
  94. L_ERR_MUST_ENTER_ID = "Error: You must enter an ID"
  95. L_ERR_FEED_ID_NOT_FOUND = "Error: There is no feed with that ID"
  96. L_ERR_INVALID_FEED_TYPE = "Error: Invalid feed type"
  97. L_ERR_BOTH_FEEDS_NONE = "Error: At least one feed must have an action"
  98. L_ERR_EMPTY_FEED_SERVER = "Error: You must enter a feed server"
  99. L_ERR_EMPTY_NEWSGROUPS = "Error: You must enter a newsgroup list"
  100. REM
  101. REM END LOCALIZATION
  102. REM
  103. REM
  104. REM --- Constants ---
  105. REM
  106. NNTP_FEED_TYPE_PEER = 1
  107. NNTP_FEED_TYPE_MASTER = 2
  108. NNTP_FEED_TYPE_SLAVE = 3
  109. NNTP_FEED_ACTION_NONE = 0
  110. NNTP_FEED_ACTION_PULL = 1
  111. NNTP_FEED_ACTION_PUSH = 2
  112. NNTP_FEED_ACTION_ACCEPT = 3
  113. dim rgstrFeedType(4)
  114. dim rgstrFeedAction(4)
  115. rgstrFeedType(NNTP_FEED_TYPE_PEER) = L_STR_FEED_TYPE_PEER
  116. rgstrFeedType(NNTP_FEED_TYPE_MASTER) = L_STR_FEED_TYPE_MASTER
  117. rgstrFeedType(NNTP_FEED_TYPE_SLAVE) = L_STR_FEED_TYPE_SLAVE
  118. rgstrFeedAction(NNTP_FEED_ACTION_PULL) = L_STR_FEED_ACTION_PULL
  119. rgstrFeedAction(NNTP_FEED_ACTION_PUSH) = L_STR_FEED_ACTION_PUSH
  120. rgstrFeedAction(NNTP_FEED_ACTION_ACCEPT) = L_STR_FEED_ACTION_ACCEPT
  121. REM
  122. REM --- Globals ---
  123. REM
  124. dim g_dictParms
  125. dim g_admin
  126. set g_dictParms = CreateObject ( "Scripting.Dictionary" )
  127. set g_admin = CreateObject ( "NntpAdm.Feeds" )
  128. REM
  129. REM --- Set argument defaults ---
  130. REM
  131. g_dictParms(L_SWITCH_OPERATION) = ""
  132. g_dictParms(L_SWITCH_SERVER) = ""
  133. g_dictParms(L_SWITCH_INSTANCE_ID) = "1"
  134. g_dictParms(L_SWITCH_FEED_SERVER) = ""
  135. g_dictParms(L_SWITCH_FEED_ID) = ""
  136. g_dictParms(L_SWITCH_TYPE) = "Peer"
  137. g_dictParms(L_SWITCH_UUCPNAME) = ""
  138. g_dictParms(L_SWITCH_ACCOUNT) = ""
  139. g_dictParms(L_SWITCH_PASSWORD) = ""
  140. g_dictParms(L_SWITCH_ENABLED) = True
  141. g_dictParms(L_SWITCH_INBOUND_ACTION) = "None"
  142. g_dictParms(L_SWITCH_INBOUND_NEWSGROUPS) = ""
  143. g_dictParms(L_SWITCH_INBOUND_INTERVAL) = "15"
  144. g_dictParms(L_SWITCH_INBOUND_AUTO_CREATE) = True
  145. g_dictParms(L_SWITCH_INBOUND_PROCESS_CTRL_MSGS) = True
  146. g_dictParms(L_SWITCH_INBOUND_PULL_TIME) = Date
  147. g_dictParms(L_SWITCH_INBOUND_MAX_CONNECTION_ATTEMPTS) = 10
  148. g_dictParms(L_SWITCH_INBOUND_PORT) = 119
  149. g_dictParms(L_SWITCH_INBOUND_TEMPDIR) = ""
  150. g_dictParms(L_SWITCH_OUTBOUND_ACTION) = "None"
  151. g_dictParms(L_SWITCH_OUTBOUND_NEWSGROUPS) = ""
  152. g_dictParms(L_SWITCH_OUTBOUND_INTERVAL) = "15"
  153. g_dictParms(L_SWITCH_OUTBOUND_PROCESS_CTRL_MSGS) = True
  154. g_dictParms(L_SWITCH_OUTBOUND_MAX_CONNECTION_ATTEMPTS) = 10
  155. g_dictParms(L_SWITCH_OUTBOUND_PORT) = 119
  156. g_dictParms(L_SWITCH_OUTBOUND_TEMPDIR) = ""
  157. REM
  158. REM --- Begin Main Program ---
  159. REM
  160. if NOT ParseCommandLine ( g_dictParms, WScript.Arguments ) then
  161. usage
  162. WScript.Quit ( 0 )
  163. end if
  164. REM If it is setting attribute, clear the default value and reparse the command line
  165. if (g_dictParms(L_SWITCH_OPERATION)=L_OP_SET) then
  166. g_dictParms.RemoveAll()
  167. g_dictParms(L_SWITCH_INSTANCE_ID) = "1"
  168. if NOT ParseCommandLine2 ( g_dictParms, WScript.Arguments ) then
  169. WScript.echo "Command line parsing failed"
  170. WScript.Quit ( 0 )
  171. end if
  172. end if
  173. dim cFeeds
  174. dim i
  175. dim id
  176. dim index
  177. dim feedpair
  178. dim nFeedType
  179. dim nInAction
  180. dim nOutAction
  181. dim infeed
  182. dim outfeed
  183. dim strNewsgroups
  184. REM
  185. REM Debug: print out command line arguments:
  186. REM
  187. REM switches = g_dictParms.keys
  188. REM args = g_dictParms.items
  189. REM
  190. REM
  191. REM for i = 0 to g_dictParms.Count - 1
  192. REM WScript.echo switches(i) & " = " & args(i)
  193. REM next
  194. REM
  195. g_admin.Server = g_dictParms(L_SWITCH_SERVER)
  196. g_admin.ServiceInstance = g_dictParms(L_SWITCH_INSTANCE_ID)
  197. On Error Resume Next
  198. g_admin.Enumerate
  199. if ( Err.Number <> 0 ) then
  200. WScript.echo " Error Enumerating Feeds: " + Err.Description + "(" + Err.Number + ")"
  201. else
  202. PrintFeed g_admin
  203. end if
  204. id = g_dictParms(L_SWITCH_FEED_ID)
  205. select case g_dictParms(L_SWITCH_OPERATION)
  206. case L_OP_ENUMERATE
  207. REM
  208. REM List the existing feeds:
  209. REM
  210. cFeeds = g_admin.Count
  211. for i = 0 to cFeeds - 1
  212. set feedpair = g_admin.ItemDispatch ( i )
  213. WScript.Echo
  214. PrintFeed feedpair
  215. next
  216. case L_OP_ADD
  217. REM
  218. REM Add a new feed
  219. REM
  220. nFeedType = StringToFeedType ( g_dictParms ( L_SWITCH_TYPE ) )
  221. nInAction = StringToFeedAction ( g_dictParms ( L_SWITCH_INBOUND_ACTION ) )
  222. nOutAction = StringToFeedAction ( g_dictParms ( L_SWITCH_OUTBOUND_ACTION ) )
  223. if nInAction = NNTP_FEED_ACTION_PUSH OR _
  224. nOutAction = NNTP_FEED_ACTION_PULL OR _
  225. nOutAction = NNTP_FEED_ACTION_ACCEPT then
  226. WScript.Echo L_ERR_INVALID_FEED_TYPE
  227. WScript.Quit 0
  228. end if
  229. if nInAction = NNTP_FEED_ACTION_NONE AND nOutAction = NNTP_FEED_ACTION_NONE then
  230. WScript.Echo L_ERR_BOTH_FEEDS_NONE
  231. WScript.Quit 0
  232. end if
  233. if g_dictParms ( L_SWITCH_FEED_SERVER ) = "" then
  234. WScript.Echo L_ERR_EMPTY_FEED_SERVER
  235. WScript.Quit 0
  236. end if
  237. REM Create feed objects:
  238. set feedpair = CreateObject ( "NntpAdm.Feed" )
  239. set infeed = CreateObject ( "NntpAdm.OneWayFeed" )
  240. set outfeed = CreateObject ( "NntpAdm.OneWayFeed" )
  241. feedpair.RemoteServer = g_dictParms ( L_SWITCH_FEED_SERVER )
  242. feedpair.FeedType = nFeedType
  243. if nInAction <> NNTP_FEED_ACTION_NONE then
  244. strNewsgroups = g_dictParms ( L_SWITCH_INBOUND_NEWSGROUPS )
  245. if strNewsgroups = "" then
  246. WScript.Echo L_ERR_EMPTY_NEWSGROUPS
  247. WScript.Quit 0
  248. end if
  249. infeed.Default
  250. infeed.FeedAction = nInAction
  251. infeed.Enabled = BooleanToBOOL ( g_dictParms ( L_SWITCH_ENABLED ) )
  252. infeed.UucpName = g_dictParms ( L_SWITCH_UUCPNAME )
  253. infeed.AccountName = g_dictParms ( L_SWITCH_ACCOUNT )
  254. infeed.Password = g_dictParms ( L_SWITCH_PASSWORD )
  255. if infeed.Password <> "" OR infeed.AccountName <> "" then
  256. infeed.AuthenticationType = 10
  257. end if
  258. infeed.FeedInterval = g_dictParms ( L_SWITCH_INBOUND_INTERVAL )
  259. infeed.MaxConnectionAttempts = g_dictParms ( L_SWITCH_INBOUND_MAX_CONNECTION_ATTEMPTS )
  260. infeed.AllowControlMessages = BooleanToBOOL ( g_dictParms ( L_SWITCH_INBOUND_PROCESS_CTRL_MSGS ) )
  261. infeed.AutoCreate = BooleanToBOOL ( g_dictParms ( L_SWITCH_INBOUND_AUTO_CREATE ) )
  262. infeed.PullNewsDate = g_dictParms ( L_SWITCH_INBOUND_PULL_TIME )
  263. infeed.NewsgroupsVariant = SemicolonListToArray ( strNewsgroups )
  264. infeed.OutgoingPort = g_dictParms ( L_SWITCH_INBOUND_PORT )
  265. infeed.TempDirectory = g_dictParms ( L_SWITCH_INBOUND_TEMPDIR )
  266. feedpair.InboundFeedDispatch = infeed
  267. end if
  268. if nOutAction <> NNTP_FEED_ACTION_NONE then
  269. strNewsgroups = g_dictParms ( L_SWITCH_OUTBOUND_NEWSGROUPS )
  270. if strNewsgroups = "" then
  271. WScript.Echo L_ERR_EMPTY_NEWSGROUPS
  272. WScript.Quit 0
  273. end if
  274. outfeed.Default
  275. outfeed.FeedAction = nOutAction
  276. outfeed.Enabled = BooleanToBOOL ( g_dictParms ( L_SWITCH_ENABLED ) )
  277. outfeed.UucpName = g_dictParms ( L_SWITCH_UUCPNAME )
  278. outfeed.AccountName = g_dictParms ( L_SWITCH_ACCOUNT )
  279. outfeed.Password = g_dictParms ( L_SWITCH_PASSWORD )
  280. if outfeed.Password <> "" OR outfeed.AccountName <> "" then
  281. outfeed.AuthenticationType = 10
  282. end if
  283. outfeed.FeedInterval = g_dictParms ( L_SWITCH_OUTBOUND_INTERVAL )
  284. outfeed.MaxConnectionAttempts = g_dictParms ( L_SWITCH_OUTBOUND_MAX_CONNECTION_ATTEMPTS )
  285. outfeed.AllowControlMessages = BooleanToBOOL ( g_dictParms ( L_SWITCH_OUTBOUND_PROCESS_CTRL_MSGS ) )
  286. outfeed.AutoCreate = BooleanToBOOL ( g_dictParms ( L_SWITCH_OUTBOUND_AUTO_CREATE ) )
  287. outfeed.NewsgroupsVariant = SemicolonListToArray ( strNewsgroups )
  288. outfeed.OutgoingPort = g_dictParms ( L_SWITCH_OUTBOUND_PORT )
  289. outfeed.TempDirectory = g_dictParms ( L_SWITCH_OUTBOUND_TEMPDIR )
  290. feedpair.OutboundFeedDispatch = outfeed
  291. end if
  292. On Error Resume Next
  293. g_admin.AddDispatch feedpair
  294. if ( Err.Number <> 0 ) then
  295. WScript.echo " Error Add Dispatch Feedpair: " + Err.Description + "(" + Err.Number + ")"
  296. else
  297. WScript.Echo L_STR_ADDED_FEED
  298. PrintFeed g_admin
  299. PrintFeed feedpair
  300. end if
  301. rem PrintFeed g_admin
  302. case L_OP_DELETE
  303. REM
  304. REM Delete an feed
  305. REM
  306. if id = "" OR NOT IsNumeric (id) then
  307. WScript.Echo L_ERR_MUST_ENTER_ID
  308. WScript.Quit
  309. end if
  310. index = g_admin.FindID ( id )
  311. if index = -1 then
  312. WScript.Echo L_ERR_FEED_ID_NOT_FOUND
  313. WScript.Quit 0
  314. end if
  315. On Error Resume Next
  316. g_admin.Remove index
  317. if ( Err.Number <> 0 ) then
  318. WScript.echo " Error Removing Feed: " + Err.Description + "(" + Err.Number + ")"
  319. else
  320. PrintFeed g_admin
  321. end if
  322. case L_OP_GET
  323. REM
  324. REM Get a specific feed:
  325. REM
  326. if id = "" OR NOT IsNumeric (id) then
  327. WScript.Echo L_ERR_MUST_ENTER_ID
  328. WScript.Quit
  329. end if
  330. index = g_admin.FindID(id)
  331. if index = -1 then
  332. WScript.Echo L_ERR_FEED_ID_NOT_FOUND
  333. WScript.Quit 0
  334. end if
  335. set feedpair = g_admin.item ( index )
  336. WScript.Echo
  337. PrintFeed feedpair
  338. case L_OP_SET
  339. REM
  340. REM Change an existing feed:
  341. REM
  342. if id = "" OR NOT IsNumeric (id) then
  343. WScript.Echo L_ERR_MUST_ENTER_ID
  344. WScript.Quit
  345. end if
  346. index = g_admin.FindID(id)
  347. if index = -1 then
  348. WScript.Echo L_ERR_FEED_ID_NOT_FOUND
  349. WScript.Quit 0
  350. end if
  351. set feedpair = g_admin.item ( index )
  352. if g_dictParms ( L_SWITCH_FEED_SERVER ) <> "" then
  353. feedpair.RemoteServer = g_dictParms ( L_SWITCH_FEED_SERVER )
  354. end if
  355. if feedpair.HasInbound then
  356. set infeed = feedpair.InboundFeedDispatch
  357. if g_dictParms ( L_SWITCH_UUCPNAME ) <> "" then
  358. infeed.UucpName = g_dictParms ( L_SWITCH_UUCPNAME )
  359. end if
  360. if g_dictParms ( L_SWITCH_ACCOUNT ) <> "" then
  361. infeed.AccountName = g_dictParms ( L_SWITCH_ACCOUNT )
  362. infeed.AuthenticationType = 10
  363. end if
  364. if g_dictParms ( L_SWITCH_PASSWORD ) <> "" then
  365. infeed.Password = g_dictParms ( L_SWITCH_PASSWORD )
  366. infeed.AuthenticationType = 10
  367. end if
  368. if g_dictParms ( L_SWITCH_ENABLED ) <> "" then
  369. infeed.Enabled = BooleanToBOOL ( g_dictParms ( L_SWITCH_ENABLED ) )
  370. end if
  371. if g_dictParms ( L_SWITCH_INBOUND_NEWSGROUPS ) <> "" then
  372. infeed.NewsgroupsVariant = SemiColonListToArray ( g_dictParms ( L_SWITCH_INBOUND_NEWSGROUPS ) )
  373. end if
  374. if g_dictParms ( L_SWITCH_INBOUND_AUTO_CREATE ) <> "" then
  375. infeed.AutoCreate = BooleanToBOOL ( g_dictParms ( L_SWITCH_INBOUND_AUTO_CREATE ) )
  376. end if
  377. if g_dictParms ( L_SWITCH_INBOUND_INTERVAL ) <> "" then
  378. infeed.FeedInterval = g_dictParms ( L_SWITCH_INBOUND_INTERVAL )
  379. end if
  380. if g_dictParms ( L_SWITCH_INBOUND_PROCESS_CTRL_MSGS ) <> "" then
  381. infeed.AllowControlMessages = BooleanToBOOL ( g_dictParms ( L_SWITCH_INBOUND_PROCESS_CTRL_MSGS ) )
  382. end if
  383. if g_dictParms ( L_SWITCH_INBOUND_MAX_CONNECTION_ATTEMPTS ) <> "" then
  384. infeed.MaxConnectionAttempts = g_dictParms ( L_SWITCH_INBOUND_MAX_CONNECTION_ATTEMPTS )
  385. end if
  386. if g_dictParms ( L_SWITCH_INBOUND_PORT ) <> "" then
  387. infeed.OutgoingPort = g_dictParms ( L_SWITCH_INBOUND_PORT )
  388. end if
  389. if g_dictParms ( L_SWITCH_INBOUND_TEMPDIR ) <> "" then
  390. infeed.TempDirectory = g_dictParms ( L_SWITCH_INBOUND_TEMPDIR )
  391. end if
  392. end if
  393. if feedpair.HasOutbound then
  394. set outfeed = feedpair.OutboundFeedDispatch
  395. if g_dictParms ( L_SWITCH_UUCPNAME ) <> "" then
  396. outfeed.UucpName = g_dictParms ( L_SWITCH_UUCPNAME )
  397. end if
  398. if g_dictParms ( L_SWITCH_ACCOUNT ) <> "" then
  399. outfeed.AccountName = g_dictParms ( L_SWITCH_ACCOUNT )
  400. outfeed.AuthenticationType = 10
  401. end if
  402. if g_dictParms ( L_SWITCH_PASSWORD ) <> "" then
  403. outfeed.Password = g_dictParms ( L_SWITCH_PASSWORD )
  404. outfeed.AuthenticationType = 10
  405. end if
  406. if g_dictParms ( L_SWITCH_ENABLED ) <> "" then
  407. outfeed.Enabled = BooleanToBOOL ( g_dictParms ( L_SWITCH_ENABLED ) )
  408. end if
  409. if g_dictParms ( L_SWITCH_OUTBOUND_NEWSGROUPS ) <> "" then
  410. outfeed.NewsgroupsVariant = SemiColonListToArray ( g_dictParms ( L_SWITCH_OUTBOUND_NEWSGROUPS ) )
  411. end if
  412. if g_dictParms ( L_SWITCH_OUTBOUND_INTERVAL ) <> "" then
  413. outfeed.FeedInterval = g_dictParms ( L_SWITCH_OUTBOUND_INTERVAL )
  414. end if
  415. if g_dictParms ( L_SWITCH_OUTBOUND_PROCESS_CTRL_MSGS ) <> "" then
  416. outfeed.AllowControlMessages = BooleanToBOOL ( g_dictParms ( L_SWITCH_OUTBOUND_PROCESS_CTRL_MSGS ) )
  417. end if
  418. if g_dictParms ( L_SWITCH_OUTBOUND_MAX_CONNECTION_ATTEMPTS ) <> "" then
  419. outfeed.MaxConnectionAttempts = g_dictParms ( L_SWITCH_OUTBOUND_MAX_CONNECTION_ATTEMPTS )
  420. end if
  421. if g_dictParms ( L_SWITCH_OUTBOUND_PORT ) <> "" then
  422. outfeed.OutgoingPort = g_dictParms ( L_SWITCH_OUTBOUND_PORT )
  423. end if
  424. if g_dictParms ( L_SWITCH_OUTBOUND_TEMPDIR ) <> "" then
  425. outfeed.TempDirectory = g_dictParms ( L_SWITCH_OUTBOUND_TEMPDIR )
  426. end if
  427. end if
  428. On Error Resume Next
  429. g_admin.Set index, feedpair
  430. if ( Err.Number <> 0 ) then
  431. WScript.echo " Error Setting Feed ID: " + Err.Description + "(" + Err.Number + ")"
  432. else
  433. PrintFeed g_admin
  434. PrintFeed feedpair
  435. end if
  436. case else
  437. usage
  438. end select
  439. WScript.Quit 0
  440. REM
  441. REM --- End Main Program ---
  442. REM
  443. REM
  444. REM ParseCommandLine ( dictParameters, cmdline )
  445. REM Parses the command line parameters into the given dictionary
  446. REM
  447. REM Arguments:
  448. REM dictParameters - A dictionary containing the global parameters
  449. REM cmdline - Collection of command line arguments
  450. REM
  451. REM Returns - Success code
  452. REM
  453. Function ParseCommandLine ( dictParameters, cmdline )
  454. dim fRet
  455. dim cArgs
  456. dim i
  457. dim strSwitch
  458. dim strArgument
  459. fRet = TRUE
  460. cArgs = cmdline.Count
  461. i = 0
  462. do while (i < cArgs)
  463. REM
  464. REM Parse the switch and its argument
  465. REM
  466. if i + 1 >= cArgs then
  467. REM
  468. REM Not enough command line arguments - Fail
  469. REM
  470. fRet = FALSE
  471. exit do
  472. end if
  473. strSwitch = cmdline(i)
  474. i = i + 1
  475. strArgument = cmdline(i)
  476. i = i + 1
  477. REM
  478. REM Add the switch,argument pair to the dictionary
  479. REM
  480. if NOT dictParameters.Exists ( strSwitch ) then
  481. REM
  482. REM Bad switch - Fail
  483. REM
  484. fRet = FALSE
  485. exit do
  486. end if
  487. dictParameters(strSwitch) = strArgument
  488. loop
  489. ParseCommandLine = fRet
  490. end function
  491. REM
  492. REM --- End Main Program ---
  493. REM
  494. REM
  495. REM ParseCommandLine2 ( dictParameters, cmdline )
  496. REM Parses the command line parameters into the given dictionary
  497. REM
  498. REM Arguments:
  499. REM dictParameters - A dictionary containing the global parameters
  500. REM cmdline - Collection of command line arguments
  501. REM
  502. REM Returns - Success code
  503. REM
  504. Function ParseCommandLine2 ( dictParameters, cmdline )
  505. dim fRet
  506. dim cArgs
  507. dim i
  508. dim strSwitch
  509. dim strArgument
  510. fRet = TRUE
  511. cArgs = cmdline.Count
  512. i = 0
  513. do while (i < cArgs)
  514. REM
  515. REM Parse the switch and its argument
  516. REM
  517. if i + 1 >= cArgs then
  518. REM
  519. REM Not enough command line arguments - Fail
  520. REM
  521. fRet = FALSE
  522. exit do
  523. end if
  524. strSwitch = cmdline(i)
  525. i = i + 1
  526. strArgument = cmdline(i)
  527. i = i + 1
  528. REM
  529. REM Add the switch,argument pair to the dictionary
  530. REM
  531. dictParameters(strSwitch) = strArgument
  532. loop
  533. ParseCommandLine2 = fRet
  534. end function
  535. REM
  536. REM SemicolonListToArray ( strList )
  537. REM Converts a semi colon delimited list to an array of strings
  538. REM
  539. REM eg. str1;str2;str3;str4 -> ["str1", "str2", "str3", "str4"]
  540. REM
  541. Function SemicolonListToArray ( strListIn )
  542. dim rgItems
  543. dim strItem
  544. dim strList
  545. dim index
  546. dim i
  547. ReDim rgItems ( 10 )
  548. strList = strListIn
  549. i = 0
  550. do until strList = ""
  551. REM
  552. REM Debug: print out newsgroup list as we go:
  553. REM WScript.Echo strList
  554. REM
  555. index = InStr ( strList, ";" )
  556. if index = 0 then
  557. REM No trailing ";", so use the whole string
  558. strItem = strList
  559. strList = ""
  560. else
  561. REM Use the string up to the ";"
  562. strItem = Left ( strList, index - 1 )
  563. strList = Right ( strList, Len ( strList ) - index )
  564. end if
  565. ReDim preserve rgItems ( i )
  566. rgItems ( i ) = strItem
  567. i = i + 1
  568. loop
  569. REM return the array
  570. SemicolonListToArray = rgItems
  571. end function
  572. REM
  573. REM Usage ()
  574. REM prints out the description of the command line arguments
  575. REM
  576. Sub Usage
  577. WScript.Echo L_DESC_PROGRAM
  578. WScript.Echo vbTab & L_SWITCH_OPERATION & " " & L_DESC_OPERATIONS
  579. WScript.Echo vbTab & vbTab & L_OP_ADD & vbTab & L_DESC_ADD
  580. WScript.Echo vbTab & vbTab & L_OP_DELETE & vbTab & L_DESC_DELETE
  581. WScript.Echo vbTab & vbTab & L_OP_GET & vbTab & L_DESC_GET
  582. WScript.Echo vbTab & vbTab & L_OP_SET & vbTab & L_DESC_SET
  583. WScript.Echo vbTab & vbTab & L_OP_ENUMERATE & vbTab & L_DESC_ENUMERATE
  584. WScript.Echo vbTab & L_SWITCH_SERVER & " " & L_DESC_SERVER
  585. WScript.Echo vbTab & L_SWITCH_INSTANCE_ID & " " & L_DESC_INSTANCE_ID
  586. WScript.Echo vbTab & L_SWITCH_FEED_SERVER & " " & L_DESC_FEED_SERVER
  587. WScript.Echo vbTab & L_SWITCH_TYPE & " " & L_DESC_TYPE
  588. WScript.Echo vbTab & L_SWITCH_UUCPNAME & " " & L_DESC_UUCPNAME
  589. WScript.Echo vbTab & L_SWITCH_ACCOUNT & " " & L_DESC_ACCOUNT
  590. WScript.Echo vbTab & L_SWITCH_PASSWORD & " " & L_DESC_PASSWORD
  591. WScript.Echo vbTab & L_SWITCH_ENABLED & " " & L_DESC_ENABLED
  592. WScript.Echo vbTab & L_SWITCH_FEED_ID & " " & L_DESC_FEED_ID
  593. WScript.Echo
  594. WScript.Echo vbTab & L_DESC_INBOUND
  595. WScript.Echo vbTab & L_SWITCH_INBOUND_ACTION & " " & L_DESC_INBOUND_ACTION
  596. WScript.Echo vbTab & L_SWITCH_INBOUND_NEWSGROUPS & " " & L_DESC_NEWSGROUPS
  597. WScript.Echo vbTab & L_SWITCH_INBOUND_INTERVAL & " " & L_DESC_INTERVAL
  598. WScript.Echo vbTab & L_SWITCH_INBOUND_PROCESS_CTRL_MSGS & " " & L_DESC_PROCESS_CTRL_MSGS
  599. WScript.Echo vbTab & L_SWITCH_INBOUND_MAX_CONNECTION_ATTEMPTS & " " & L_DESC_MAX_CONNECTION_ATTEMPTS
  600. WScript.Echo vbTab & L_SWITCH_INBOUND_PULL_TIME & " " & L_DESC_PULL_TIME
  601. WScript.Echo vbTab & L_SWITCH_INBOUND_AUTO_CREATE & " " & L_DESC_AUTO_CREATE
  602. WScript.Echo vbTab & L_SWITCH_INBOUND_PORT & " " & L_DESC_OUTBOUND_PORT
  603. WScript.Echo vbTab & L_SWITCH_INBOUND_TEMPDIR & " " & L_DESC_TEMPDIR
  604. WScript.Echo
  605. WScript.Echo vbTab & L_DESC_OUTBOUND
  606. WScript.Echo vbTab & L_SWITCH_OUTBOUND_ACTION & " " & L_DESC_OUTBOUND_ACTION
  607. WScript.Echo vbTab & L_SWITCH_OUTBOUND_NEWSGROUPS & " " & L_DESC_NEWSGROUPS
  608. WScript.Echo vbTab & L_SWITCH_OUTBOUND_INTERVAL & " " & L_DESC_INTERVAL
  609. WScript.Echo vbTab & L_SWITCH_OUTBOUND_PROCESS_CTRL_MSGS & " " & L_DESC_PROCESS_CTRL_MSGS
  610. WScript.Echo vbTab & L_SWITCH_OUTBOUND_MAX_CONNECTION_ATTEMPTS & " " & L_DESC_MAX_CONNECTION_ATTEMPTS
  611. WScript.Echo vbTab & L_SWITCH_OUTBOUND_PORT & " " & L_DESC_OUTBOUND_PORT
  612. WScript.Echo vbTab & L_SWITCH_OUTBOUND_TEMPDIR & " " & L_DESC_TEMPDIR
  613. WScript.Echo
  614. WScript.Echo L_DESC_EXAMPLES
  615. WScript.Echo L_DESC_EXAMPLE1
  616. WScript.Echo L_DESC_EXAMPLE2
  617. WScript.Echo L_DESC_EXAMPLE3
  618. WScript.Echo L_DESC_EXAMPLE4
  619. end sub
  620. Sub PrintFeed ( feedobj )
  621. WScript.Echo L_STR_FEED_SERVER & " " & feedobj.RemoteServer
  622. WScript.Echo L_STR_TYPE & " " & rgstrFeedType (feedobj.FeedType)
  623. if feedobj.HasInbound then
  624. WScript.Echo L_STR_INBOUND_FEED
  625. PrintOneWayFeed feedobj.InboundFeedDispatch
  626. end if
  627. if feedobj.HasOutbound then
  628. WScript.Echo L_STR_OUTBOUND_FEED
  629. PrintOneWayFeed feedobj.OutboundFeedDispatch
  630. end if
  631. end sub
  632. sub PrintOneWayFeed ( feedobj )
  633. dim newsgroups
  634. dim cGroups
  635. dim i
  636. dim bAccept
  637. dim bPush
  638. dim bPull
  639. bPull = (feedobj.FeedAction = NNTP_FEED_ACTION_PULL)
  640. bPush = (feedobj.FeedAction = NNTP_FEED_ACTION_PUSH)
  641. bAccept = (feedobj.FeedAction = NNTP_FEED_ACTION_ACCEPT)
  642. WScript.Echo vbTab & L_STR_FEED_ID & " " & feedobj.FeedId
  643. WScript.Echo vbTab & L_STR_ACTION & " " & rgstrFeedAction (feedobj.FeedAction)
  644. WScript.Echo vbTab & L_STR_ENABLED & " " & BOOLToBoolean (feedobj.Enabled)
  645. WScript.Echo vbTab & L_STR_UUCPNAME & " " & feedobj.UucpName
  646. WScript.Echo vbTab & L_STR_PROCESS_CTRL_MSGS & " " & BOOLToBoolean (feedobj.AllowControlMessages)
  647. WScript.Echo vbTab & L_STR_ACCOUNT & " " & feedobj.AccountName
  648. if feedobj.MaxConnectionAttempts = 0 OR feedobj.MaxConnectionAttempts = -1 then
  649. WScript.Echo vbTab & L_STR_MAX_CONNECTION_ATTEMPTS & " " & L_STR_UNLIMITED
  650. else
  651. WScript.Echo vbTab & L_STR_MAX_CONNECTION_ATTEMPTS & " " & feedobj.MaxConnectionAttempts
  652. end if
  653. if bPull then
  654. WScript.Echo vbTab & L_STR_AUTO_CREATE & " " & BOOLToBoolean ( feedobj.AutoCreate )
  655. WScript.Echo vbTab & L_STR_PULL_TIME & " " & feedobj.PullNewsDate
  656. end if
  657. if NOT bAccept then
  658. WScript.Echo vbTab & L_STR_INTERVAL & " " & feedobj.FeedInterval
  659. WScript.Echo vbTab & L_STR_OUTGOING_PORT & " " & feedobj.OutgoingPort
  660. end if
  661. WScript.Echo vbTab & L_STR_TEMPDIR & " " & feedobj.TempDirectory
  662. newsgroups = feedobj.NewsgroupsVariant
  663. cGroups = UBound ( newsgroups )
  664. for i = 0 to cGroups
  665. WScript.Echo vbTab & L_STR_NEWSGROUPS & " " & newsgroups(i)
  666. next
  667. end sub
  668. Function StringToFeedType ( strFeedType )
  669. dim strUcaseType
  670. strUcaseType = UCase ( strFeedType )
  671. if strUcaseType = UCase ( L_STR_FEED_TYPE_PEER ) then
  672. StringToFeedType = NNTP_FEED_TYPE_PEER
  673. elseif strUcaseType = UCase ( L_STR_FEED_TYPE_MASTER ) then
  674. StringToFeedType = NNTP_FEED_TYPE_MASTER
  675. elseif strUcaseType = UCase ( L_STR_FEED_TYPE_SLAVE ) then
  676. StringToFeedType = NNTP_FEED_TYPE_SLAVE
  677. else
  678. StringToFeedType = NNTP_FEED_TYPE_PEER
  679. end if
  680. end function
  681. Function StringToFeedAction ( strFeedAction )
  682. dim strUcaseAction
  683. strUcaseAction = UCase ( strFeedAction )
  684. if strUcaseAction = UCase ( L_STR_FEED_ACTION_PULL ) then
  685. StringToFeedAction = NNTP_FEED_ACTION_PULL
  686. elseif strUcaseAction = UCase ( L_STR_FEED_ACTION_PUSH ) then
  687. StringToFeedAction = NNTP_FEED_ACTION_PUSH
  688. elseif strUcaseAction = UCase ( L_STR_FEED_ACTION_ACCEPT ) then
  689. StringToFeedAction = NNTP_FEED_ACTION_ACCEPT
  690. else
  691. StringToFeedAction = NNTP_FEED_ACTION_NONE
  692. end if
  693. end function
  694. Function BooleanToBOOL ( b )
  695. if b then
  696. BooleanToBOOL = 1
  697. else
  698. BooleanToBOOL = 0
  699. end if
  700. end function
  701. Function BOOLToBoolean ( b )
  702. BOOLToBoolean = (b = 1)
  703. end function