home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / ifd99102.zip / INIDUMP.CMD
OS/2 REXX Batch file  |  1999-04-12  |  13KB  |  514 lines

  1. /*
  2.  * Generator   : PPWIZARD version 99.101
  3.  *             : FREE tool for OS/2, Windows, DOS and UNIX by Dennis Bareis (db0@anz.com)
  4.  *             : http://www.labyrinth.net.au/~dbareis/ppwizard.htm
  5.  * Time        : Monday, 12 Apr 1999 6:34:40pm
  6.  * Input File  : E:\DB\PROJECTS\OS2\inidump\INIDUMP.X
  7.  * Output File : .\OUT\INIDUMP.CMD
  8.  */
  9.  
  10. /*
  11. *$Header:E:/DB/PVCS.IT/OS2/INIDUMP/INIDUMP.X_V 1.4 12 Apr 1999 18:34:30 Dennis_Bareis $/htmlpp/HtmlPP.cmv 1.4 07 Nov 1997 15:40:04 Dennis_Bareis $/htmlpp/HtmlPP.cmv 1.3 07 Nov 1997 15:18:38 Dennis_Bareis $/htmlpp/HtmlPP.cmv 1.2 07 Nov 1997 10:57:22 Dennis_Bareis $/PLATFORM/PLATFRM.X_V 1.5 11 Oct 1996 16:40:40 Dennis_Bareis $/PLATFORM/PLATFRM.X_V 1.4 11 Oct 1996 16:26:28 Dennis_Bareis $/PLATFORM/PLATFRM.X_V 1.3 17 Sep 1996 10:51:38 Dennis_Bareis $
  12. */
  13. call RxFuncAdd 'SysIni',      'RexxUtil', 'SysIni'
  14. call RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
  15. NewSingleQuote="' || " || '"' || "'" || '" || ' || "'"
  16. ExitRc=0
  17. PGM_VERSION="99.102"
  18. /*
  19. *FASTINI.XH Version 98.147 by Dennis Bareis
  20. *http://www.labyrinth.net.au/~dbareis/index.htm(db0@anz.com)
  21. */
  22. _FiOpenCount=0
  23. call RxFuncAdd 'FastIniStart',   'FastIni',  'FastIniStart'
  24. call RxFuncAdd 'FastIniEnd',     'FastIni',  'FastIniEnd'
  25. call RxFuncAdd 'FastIniVersion', 'FastIni',  'FastIniVersion'
  26. _fiAvailable=_FastIniOk()
  27. signal EndFASTINIXh
  28. FastIniIsFast:
  29. return(_fiAvailable)
  30. FastIniOpenIni:
  31. _fiFile=arg(1)
  32. _fiHandleVar=arg(2)
  33. if _fiAvailable='N' then
  34. do
  35. interpret _fiHandleVar|| ' = 0'
  36. return('OK')
  37. end
  38. interpret _fiHandleVar|| ' = ""'
  39. _fiFastRc=FastIniStart(_fiFile,_fiHandleVar)
  40. interpret '_FiHandle = ' ||_fiHandleVar
  41. if _FiHandle<> '' then
  42. do
  43. _FiOpenCount=_FiOpenCount+1
  44. _FiOpenedList._FiOpenCount=_FiHandle
  45. end
  46. return(_fiFastRc)
  47. FastIniCloseIni:
  48. if _fiAvailable='N' then
  49. return('OK')
  50. return(FastIniEnd(arg(1)))
  51. FastIniGetVersion:
  52. if _fiAvailable='Y' then
  53. return(FastIniVersion(arg(1)))
  54. else
  55. do
  56. interpret arg(1)|| ' = "00.000 http://www.labyrinth.net.au/~dbareis/index.htm db0@anz.com Dennis Bareis"'
  57. return('OK')
  58. end
  59. FastIniCleanup:
  60. if _fiAvailable='N' then
  61. return('OK')
  62. do _fi=1 to _FiOpenCount
  63. call FastIniEnd(_FiOpenedList._fi)
  64. _FiOpenedList._fi=0
  65. end
  66. _FiOpenCount=0
  67. return('OK')
  68. _FastIniOk:
  69. signal on SYNTAX name _FastIniNotOk
  70. interpret "_fiRc = FastIniVersion('_fiVersion')"
  71. return('Y')
  72. _FastIniNotOk:
  73. return('N')
  74. EndFASTINIXh:
  75. /*
  76. *BIN2REXP.XH Version 98.149 by Dennis Bareis
  77. *http://www.labyrinth.net.au/~dbareis/index.htm(db0@anz.com)
  78. */
  79. b2rNewSingleQuote="' || " || '"' || "'" || '" || ' || "'"
  80. b2rAllHexCodes=''
  81. b2rAllAsciiCodes=''
  82. do b2rCharCode=0 to 31
  83. b2rAllHexCodes=b2rAllHexCodes||d2c(b2rCharCode)
  84. end
  85. do b2rCharCode=32 to 126
  86. b2rAllAsciiCodes=b2rAllAsciiCodes||d2c(b2rCharCode)
  87. end
  88. do b2rCharCode=127 to 255
  89. b2rAllHexCodes=b2rAllHexCodes||d2c(b2rCharCode)
  90. end
  91. signal EndBIN2REXPXh
  92. _QuoteAscii:
  93. b2rAscii2Quote=arg(1)
  94. if pos("'",b2rAscii2Quote)=0 then
  95. return("'" || b2rAscii2Quote || "'")
  96. else
  97. do
  98. if pos('"',b2rAscii2Quote)=0 then
  99. return('"' || b2rAscii2Quote || '"')
  100. else
  101. do
  102. return("'" || ReplaceString(b2rAscii2Quote, "'", b2rNewSingleQuote) || "'")
  103. end
  104. end
  105. _FormatHex:
  106. b2rHexString=arg(1)
  107. b2rLengthHex=length(b2rHexString)
  108. b2rFormattedHex="'"
  109. if b2rLengthHex>7 then
  110. do
  111. b2rLeft1=left(b2rHexString,1)
  112. b2rLeft1Pos=verify(b2rHexString,b2rLeft1)
  113. if b2rLeft1Pos=0 then
  114. return( "copies('" || c2x(b2rLeft1) || "'x, " || b2rLengthHex || ")" )
  115. else
  116. do
  117. if b2rLeft1Pos>7 then
  118. do
  119. b2rFormattedHex="copies('" || c2x(b2rLeft1) || "'x, " || b2rLeft1Pos-1 || ") || '"
  120. b2rHexString=substr(b2rHexString,b2rLeft1Pos)
  121. b2rLengthHex=b2rLengthHex-(b2rLeft1Pos-1)
  122. end
  123. end
  124. end
  125. do b2rCharPosn=1 to b2rLengthHex
  126. if(b2rCharPosn//8)=1 then
  127. do
  128. if b2rCharPosn<>1 then
  129. b2rFormattedHex=b2rFormattedHex|| ' '
  130. end
  131. b2rFormattedHex=b2rFormattedHex||c2x(substr(b2rHexString,b2rCharPosn,1))
  132. end
  133. b2rFormattedHex=b2rFormattedHex|| "'x"
  134. return(b2rFormattedHex)
  135. _QuoteAsciiBreakIfRequired:
  136. qabAscii=arg(1)
  137. qabLength=length(qabAscii)
  138. qabReturn=''
  139. do while qabLength>256
  140. qabLeft=left(qabAscii,256)
  141. qabAscii=substr(qabAscii,256+1)
  142. qabLength=qabLength-256
  143. if qabReturn='' then
  144. qabReturn=_QuoteAscii(qabLeft)
  145. else
  146. qabReturn=qabReturn|| " || " ||_QuoteAscii(qabLeft)
  147. end
  148. if qabLength=0 then
  149. return(qabReturn)
  150. else
  151. do
  152. if qabReturn='' then
  153. return(_QuoteAscii(qabAscii))
  154. else
  155. return(qabReturn|| " || " ||_QuoteAscii(qabAscii))
  156. end
  157. _FormatHexBreakIfRequired:
  158. fhbHex=arg(1)
  159. fhbLength=length(fhbHex)
  160. fhbReturn=''
  161. do while fhbLength>80
  162. fhbLeft=left(fhbHex,80)
  163. fhbHex=substr(fhbHex,80+1)
  164. fhbLength=fhbLength-80
  165. if fhbReturn='' then
  166. fhbReturn=_FormatHex(fhbLeft)
  167. else
  168. fhbReturn=fhbReturn|| " || " ||_FormatHex(fhbLeft)
  169. end
  170. if fhbLength=0 then
  171. return(fhbReturn)
  172. else
  173. do
  174. if fhbReturn='' then
  175. return(_FormatHex(fhbHex))
  176. else
  177. return(fhbReturn|| " || " ||_FormatHex(fhbHex))
  178. end
  179. BIN2REXP:
  180. call BIN2REXP_START
  181. b2rValue=arg(1)
  182. b2rValueLength=length(b2rValue)
  183. if b2rValueLength=0 then
  184. call BIN2REXP_ONEBIT '""'
  185. else
  186. do
  187. do while b2rValue\==''
  188. b2rEndAsciiPos=verify(b2rValue,b2rAllAsciiCodes)
  189. if b2rEndAsciiPos=0 then
  190. do
  191. call BIN2REXP_ONEBIT _QuoteAsciiBreakIfRequired(b2rValue)
  192. b2rValue=''
  193. end
  194. else
  195. do
  196. if b2rEndAsciiPos<>1 then
  197. do
  198. call BIN2REXP_ONEBIT _QuoteAsciiBreakIfRequired(left(b2rValue,b2rEndAsciiPos-1))
  199. b2rValue=substr(b2rValue,b2rEndAsciiPos)
  200. end
  201. else
  202. do
  203. b2rEndBinaryPos=verify(b2rValue,b2rAllHexCodes)
  204. if b2rEndBinaryPos=0 then
  205. do
  206. call BIN2REXP_ONEBIT _FormatHexBreakIfRequired(b2rValue)
  207. b2rValue=''
  208. end
  209. else
  210. do
  211. call BIN2REXP_ONEBIT _FormatHexBreakIfRequired(left(b2rValue,b2rEndBinaryPos-1))
  212. b2rValue=substr(b2rValue,b2rEndBinaryPos)
  213. end
  214. end
  215. end
  216. end
  217. end
  218. call BIN2REXP_END
  219. return
  220. EndBIN2REXPXh:
  221. signal on HALT name RexxCtrlC
  222. signal on NOVALUE name RexxTrapUninitializedVariable
  223. signal on SYNTAX name RexxTrapSyntaxError
  224. parse value arg(1)with IniFile TooLongToDump
  225. if IniFile="" then
  226. call SyntaxError 'ERROR: Expected "USER", "SYSTEM", "BOTH", or the name of an .INI file...'
  227. if datatype(TooLongToDump, 'W')=0 then
  228. TooLongToDump=10000
  229. AllHexCodes=''
  230. AllAsciiCodes=''
  231. do CharCode=0 to 31
  232. AllHexCodes=AllHexCodes||d2c(CharCode)
  233. end
  234. do CharCode=32 to 126
  235. AllAsciiCodes=AllAsciiCodes||d2c(CharCode)
  236. end
  237. do CharCode=127 to 255
  238. AllHexCodes=AllHexCodes||d2c(CharCode)
  239. end
  240. IniFileU=translate(IniFile)
  241. if IniFileU="USER" | IniFileU = "SYSTEM" | IniFileU = "BOTH" then
  242. IniFile=IniFileU
  243. else
  244. do
  245. TreeRc=SysFileTree(IniFile, 'FileBase', 'FO')
  246. if TreeRc<>0|FileBase.0=0 then
  247. do
  248. call ToStderr 'ERROR: The INI file "' || IniFile || '" does not exist.'
  249. PgmExit(SourceLine())
  250. end
  251. end
  252. FastRc=FastIniOpenIni(IniFile, "IniHandle")
  253. if FastRc<> 'OK' then
  254. call ToStderr "FASTINI.DLL can not be accessed (" || FastRc || ').'
  255. call DumpWholeIni IniFile
  256. PgmExit(ExitRc)
  257. PgmExit:
  258. call FastIniCleanup
  259. exit(arg(1))
  260. CommonTrapHandler:
  261. FailingLine=arg(1)
  262. TrapHeading='BUG: ' ||arg(2)
  263. TextDescription=arg(3)
  264. Text=arg(4)
  265. parse source . . SourceFileName
  266. call ToStderr "" || copies('=+',39)
  267. call ToStderr TrapHeading
  268. call ToStderr copies('~',length(TrapHeading))
  269. call ToStderr substr(TextDescription,1,16)|| ': ' ||Text
  270. call ToStderr 'Failing Module  : ' ||SourceFileName
  271. call ToStderr 'Failing Line #  : ' ||FailingLine
  272. call ToStderr 'Failing Command : ' ||strip(SourceLine(FailingLine))
  273. call ToStderr copies('=+', 39) || ""
  274. PgmExit(FailingLine)
  275. RexxTrapUninitializedVariable:
  276. call CommonTrapHandler SIGL, 'NoValue Abort!', 'Unknown Variable', condition('D')
  277. RexxTrapSyntaxError:
  278. call CommonTrapHandler SIGL, 'Syntax Error!', 'Reason',errortext(Rc)
  279. RexxCtrlC:
  280. LineCtrlC=SIGL
  281. call ToStderr ''
  282. call ToStderr "" || copies('=+',39)
  283. call ToStderr "Come on, you pressed Ctrl+C or Break didn't you!"
  284. call ToStderr copies('=+', 39) || ""
  285. PgmExit(LineCtrlC)
  286. SyntaxError:
  287. ErrorLine=SIGL
  288. call ToStderr "[]------------------------------------------------------------------------[]"
  289. call ToStderr "| INIDUMP.CMD, Version " || PGM_VERSION || " (C)opyright Dennis Bareis 1998 (db0@anz.com) |"
  290. call ToStderr '|              http://www.labyrinth.net.au/~dbareis/index.htm              |'
  291. call ToStderr "[]------------------------------------------------------------------------[]"
  292. call ToStderr ""
  293. call ToStderr "This program allows you to dump a whole INI file in the same format that my"
  294. call ToStderr "INIWRITE.CMD program uses.  This allows you to maintain the contents of a"
  295. call ToStderr "binary INI file as TEXT, which means you can use any text editor, difference"
  296. call ToStderr "programs or source management programs such as PVCS."
  297. call ToStderr ""
  298. call ToStderr "The dump would normally only be required ONCE to get a text form of an INI"
  299. call ToStderr "from an external source as you would maintain the text file as TEXT adding"
  300. call ToStderr "or commenting out bits as required."
  301. call ToStderr ""
  302. call ToStderr "Note that the application/keys are sorted allowing before and after"
  303. call ToStderr "snapshots to be compared with PMDIFF or similar tools."
  304. call ToStderr ""
  305. call ToStderr "CORRECT SYNTAX"
  306. call ToStderr "~~~~~~~~~~~~~~"
  307. call ToStderr "        INIDUMP[.CMD] USER|SYSTEM|BOTH|IniFileName [MaxSizeDumped] >Output.IU"
  308. call ToStderr ""
  309. call ToStderr ARG(1)
  310. PgmExit(ErrorLine)
  311. ToStderr:
  312. call lineout 'STDERR',arg(1)
  313. return
  314. DisplayError:
  315. ExitRc=SourceLine()
  316. say ''
  317. say ';ERROR: ' ||arg(1)
  318. call ToStderr 'ERROR: ' || arg(1) || ''
  319. say ''
  320. say ''
  321. return
  322. DumpWholeIni:
  323. call SysIni ARG(1), 'All:', 'aTmp.'
  324. if Result='ERROR:' then
  325. do
  326. call DisplayError 'Could not obtain list of APPLICATION keys.'
  327. return
  328. end
  329. if aTmp.0=0 then
  330. do
  331. call DisplayError 'INI file "'ARG(1)'" does not exist, or contains no data.'
  332. return
  333. end
  334. call quicksort 1,aTmp.0
  335. do i=0 to aTmp.0
  336. Apps.i=aTmp.i
  337. end
  338. do i=1 to Apps.0
  339. if i<>1 then
  340. do
  341. say ""
  342. say ""
  343. say ';'copies('#',78)
  344. end
  345. call SysIni ARG(1),Apps.i, 'All:', 'aTmp'
  346. if Result='ERROR:' then
  347. do
  348. call DisplayError 'Could not obtain List of Keys for APPLICATION = 'Apps.i
  349. iterate
  350. end
  351. if aTmp.0=0 then
  352. do
  353. call DisplayError 'There are no keys for application "'Apps.i'".'
  354. iterate
  355. end
  356. call quicksort 1,aTmp.0
  357. do j=0 to aTmp.0
  358. Keys.j=aTmp.j
  359. end
  360. LongestKeyName=0
  361. do j=1 to Keys.0
  362. LengthKeyName=length(SubstituteStandardCodes(Keys.j))
  363. if LengthKeyName>LongestKeyName then
  364. LongestKeyName=LengthKeyName
  365. end
  366. do j=1 to Keys.0
  367. call DumpIniValue ARG(1),Apps.i,Keys.j
  368. end
  369. end
  370. return
  371. SubstituteStandardCodes:
  372. return(ReplaceString(arg(1), " ", "{Space}"))
  373. BIN2REXP_START:
  374. FormattedValue=''
  375. return
  376. BIN2REXP_ONEBIT:
  377. ToAdd=arg(1)
  378. if FormattedValue='' then
  379. FormattedValue=ToAdd
  380. else
  381. FormattedValue=FormattedValue|| " || " ||ToAdd
  382. return
  383. BIN2REXP_END:
  384. if pos(';' || ';',FormattedValue)=0 then
  385. say FormattedValue
  386. else
  387. say FormattedValue|| '    ;' || ';Warning Leave this!'
  388. return
  389. DumpIniValue:
  390. dipIniName=arg(1)
  391. dipAppName=arg(2)
  392. dipKeyName=arg(3)
  393. FirstPart=SubstituteStandardCodes(dipIniName)|| '  ' || SubstituteStandardCodes(dipAppName) || '  ' || left(SubstituteStandardCodes(dipKeyName), LongestKeyName) || ' '
  394. Value=SysIni(dipIniName,dipAppName,dipKeyName)
  395. if Value="ERROR:" then
  396. do
  397. say ';' || FirstPart || '<<INI READ FAILED>>'
  398. call DisplayError 'Could not read key = ' ||dipKeyName
  399. return
  400. end
  401. if TooLongToDump<>0 then
  402. do
  403. ValueLength=length(Value)
  404. if ValueLength>TooLongToDump then
  405. do
  406. ErrorMsg="At " || ValueLength || ' the value is too large to dump (>' || TooLongToDump || ' bytes)'
  407. say ';' ||FirstPart||ErrorMsg
  408. call DisplayError ErrorMsg
  409. return
  410. end
  411. end
  412. call charout,FirstPart|| ' '
  413. call BIN2REXP Value
  414. return
  415. ReplaceString:
  416. TheString=arg(1)
  417. ChangeFrom=arg(2)
  418. ChangeTo=arg(3)
  419. ChangeCntVar=arg(4)
  420. ChangeFromLength=length(ChangeFrom)
  421. ChangeToLength=length(ChangeTo)
  422. FoundPosn=pos(ChangeFrom,TheString)
  423. ReplaceStringCounter=0
  424. do while FoundPosn<>0
  425. TheString=left(TheString,FoundPosn-1)||ChangeTo||substr(TheString,FoundPosn+ChangeFromLength)
  426. FoundPosn=pos(ChangeFrom,TheString,FoundPosn+ChangeToLength)
  427. ReplaceStringCounter=ReplaceStringCounter+1
  428. end
  429. if ChangeCntVar<> "" then
  430. interpret ChangeCntVar|| " = ReplaceStringCounter + " ||ChangeCntVar
  431. return(TheString)
  432. SourceLine:
  433. return(SIGL)
  434. qsCompFunc:PROCEDURE
  435. parse arg a,b
  436. select
  437. when(a<b)then
  438. return(-1)
  439. when(a>b)then
  440. return(1)
  441. otherwise
  442. return(0)
  443. end
  444. QuickSort:PROCEDURE EXPOSE atmp.
  445. parse arg top,down
  446. if((down-top)<2)then
  447. do
  448. if((down-top)>0)then
  449. /*if(atmp.top>atmp.down)then*/
  450. if(qsCompFunc(atmp.top,atmp.down)>0)then
  451. do
  452. tmpval=atmp.top
  453. atmp.top=atmp.down
  454. atmp.down=tmpval
  455. end
  456. end
  457. else
  458. do
  459. l=top
  460. r=down
  461. m=top+trunc((down-top)/2)
  462. do while(l<r)
  463. m_val=atmp.m
  464. /*do while(atmp.l<m_val)*/
  465. do while(qsCompFunc(atmp.l,m_val)<0)
  466. if(l<m)then
  467. l=l+1
  468. else
  469. leave
  470. end
  471. /*do while(atmp.r>m_val)*/
  472. do while(qsCompFunc(atmp.r,m_val)>0)
  473. if(m<r)then
  474. r=r-1
  475. else
  476. leave
  477. end
  478. if(l<r)then
  479. do
  480. tmpval=atmp.l
  481. atmp.l=atmp.r
  482. atmp.r=tmpval
  483. select
  484. when(m=r)then
  485. do
  486. r=r-1
  487. m=l
  488. end
  489. when(m=l)then
  490. do
  491. l=l+1
  492. m=r
  493. end
  494. otherwise
  495. do
  496. l=l+1
  497. r=r-1
  498. end
  499. end
  500. end
  501. end
  502. if((r-top)<(down-l))then
  503. do
  504. call quicksort top,m-1
  505. call quicksort m+1,down
  506. end
  507. else
  508. do
  509. call quicksort m+1,down
  510. call quicksort top,m-1
  511. end
  512. end
  513. return
  514.