defs.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. <?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?>
  2. <?php
  3. // (C) Copyright 2001
  4. // Murray Jensen <Murray.Jensen@csiro.au>
  5. // CSIRO Manufacturing Science and Technology, Preston Lab
  6. // contains mysql user id and password - keep secret
  7. require("config.php");
  8. if (isset($_REQUEST['logout'])) {
  9. Header("status: 401 Unauthorized");
  10. Header("HTTP/1.0 401 Unauthorized");
  11. Header("WWW-authenticate: basic realm=\"$bddb_label\"");
  12. echo "<html><head><title>" .
  13. "Access to '$bddb_label' Denied" .
  14. "</title></head>\n";
  15. echo "<body bgcolor=#ffffff><br></br><br></br><center><h1>" .
  16. "You must be an Authorised User " .
  17. "to access the '$bddb_label'" .
  18. "</h1>\n</center></body></html>\n";
  19. exit;
  20. }
  21. // contents of the various enumerated types - if first item is
  22. // empty ('') then the enum is allowed to be null (ie "not null"
  23. // is not set on the column)
  24. // all column names in the database table
  25. $columns = array(
  26. 'serno','ethaddr','date','batch',
  27. 'type','rev','location','comments',
  28. 'sdram0','sdram1','sdram2','sdram3',
  29. 'flash0','flash1','flash2','flash3',
  30. 'zbt0','zbt1','zbt2','zbt3','zbt4','zbt5','zbt6','zbt7',
  31. 'zbt8','zbt9','zbta','zbtb','zbtc','zbtd','zbte','zbtf',
  32. 'xlxtyp0','xlxtyp1','xlxtyp2','xlxtyp3',
  33. 'xlxspd0','xlxspd1','xlxspd2','xlxspd3',
  34. 'xlxtmp0','xlxtmp1','xlxtmp2','xlxtmp3',
  35. 'xlxgrd0','xlxgrd1','xlxgrd2','xlxgrd3',
  36. 'cputyp','cpuspd','cpmspd','busspd',
  37. 'hstype','hschin','hschout'
  38. );
  39. // board type
  40. $type_vals = array('IO','CLP','DSP','INPUT','ALT-INPUT','DISPLAY');
  41. // Xilinx fpga types
  42. $xlxtyp_vals = array('','XCV300E','XCV400E','XCV600E','XC2V2000','XC2V3000','XC2V4000','XC2V6000','XC2VP2','XC2VP4','XC2VP7','XC2VP20','XC2VP30','XC2VP50','XC4VFX20','XC4VFX40','XC4VFX60','XC4VFX100','XC4VFX140');
  43. // Xilinx fpga speeds
  44. $xlxspd_vals = array('','6','7','8','4','5','9','10','11','12');
  45. // Xilinx fpga temperatures (commercial or industrial)
  46. $xlxtmp_vals = array('','COM','IND');
  47. // Xilinx fpga grades (normal or engineering sample)
  48. $xlxgrd_vals = array('','NORMAL','ENGSAMP');
  49. // CPU types
  50. $cputyp_vals = array('','MPC8260(HIP3)','MPC8260A(HIP4)','MPC8280(HIP7)','MPC8560');
  51. // CPU/BUS/CPM clock speeds
  52. $clk_vals = array('','33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ','233MHZ','266MHZ','300MHZ','333MHZ','366MHZ','400MHZ','433MHZ','466MHZ','500MHZ','533MHZ','566MHZ','600MHZ','633MHZ','666MHZ','700MHZ','733MHZ','766MHZ','800MHZ','833MHZ','866MHZ','900MHZ','933MHZ','966MHZ','1000MHZ','1033MHZ','1066MHZ','1100MHZ','1133MHZ','1166MHZ','1200MHZ','1233MHZ','1266MHZ','1300MHZ','1333MHZ');
  53. // sdram sizes (nbits array is for eeprom config file)
  54. $sdram_vals = array('','32M','64M','128M','256M','512M','1G','2G','4G');
  55. $sdram_nbits = array(0,25,26,27,28,29,30,31,32);
  56. // flash sizes (nbits array is for eeprom config file)
  57. $flash_vals = array('','4M','8M','16M','32M','64M','128M','256M','512M','1G');
  58. $flash_nbits = array(0,22,23,24,25,26,27,28,29,30);
  59. // zbt ram sizes (nbits array is for write into eeprom config file)
  60. $zbt_vals = array('','512K','1M','2M','4M','8M','16M');
  61. $zbt_nbits = array(0,19,20,21,22,23,24);
  62. // high-speed serial attributes
  63. $hstype_vals = array('','AMCC-S2064A','Xilinx-Rockets');
  64. $hschin_vals = array('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16');
  65. $hschout_vals = array('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16');
  66. // value filters - used when outputting html
  67. function rev_filter($num) {
  68. if ($num == 0)
  69. return "001";
  70. else
  71. return sprintf("%03d", $num);
  72. }
  73. function text_filter($str) {
  74. return urldecode($str);
  75. }
  76. mt_srand(time() | getmypid());
  77. // set up MySQL connection
  78. mysql_connect("", $mysql_user, $mysql_pw) || die("cannot connect");
  79. mysql_select_db($mysql_db) || die("cannot select db");
  80. // page header
  81. function pg_head($title)
  82. {
  83. echo "<html>\n<head>\n";
  84. echo "<link rel=stylesheet href=\"bddb.css\" type=\"text/css\" title=\"style sheet\"></link>\n";
  85. echo "<title>$title</title>\n";
  86. echo "</head>\n";
  87. echo "<body>\n";
  88. echo "<center><h1>$title</h1></center>\n";
  89. echo "<hr></hr>\n";
  90. }
  91. // page footer
  92. function pg_foot()
  93. {
  94. echo "<hr></hr>\n";
  95. echo "<table width=\"100%\"><tr><td align=left>\n<address>" .
  96. "If you have any problems, email " .
  97. "<a href=\"mailto:Murray.Jensen@csiro.au\">" .
  98. "Murray Jensen" .
  99. "</a></address>\n" .
  100. "</td><td align=right>\n" .
  101. "<a href=\"index.php?logout=true\">logout</a>\n" .
  102. "</td></tr></table>\n";
  103. echo "<p><small><i>Made with " .
  104. "<a href=\"http://kyber.dk/phpMyBuilder/\">" .
  105. "Kyber phpMyBuilder</a></i></small></p>\n";
  106. echo "</body>\n";
  107. echo "</html>\n";
  108. }
  109. // some support functions
  110. if (!function_exists('array_search')) {
  111. function array_search($needle, $haystack, $strict = false) {
  112. if (is_array($haystack) && count($haystack)) {
  113. $ntype = gettype($needle);
  114. foreach ($haystack as $key => $value) {
  115. if ($value == $needle && (!$strict ||
  116. gettype($value) == $ntype))
  117. return $key;
  118. }
  119. }
  120. return false;
  121. }
  122. }
  123. if (!function_exists('in_array')) {
  124. function in_array($needle, $haystack, $strict = false) {
  125. if (is_array($haystack) && count($haystack)) {
  126. $ntype = gettype($needle);
  127. foreach ($haystack as $key => $value) {
  128. if ($value == $needle && (!$strict ||
  129. gettype($value) == $ntype))
  130. return true;
  131. }
  132. }
  133. return false;
  134. }
  135. }
  136. function key_in_array($key, $array) {
  137. return in_array($key, array_keys($array), true);
  138. }
  139. function enum_to_index($name, $vals) {
  140. $index = array_search($GLOBALS[$name], $vals);
  141. if ($vals[0] != '')
  142. $index++;
  143. return $index;
  144. }
  145. // fetch a value from an array - return empty string is not present
  146. function get_key_value($key, $array) {
  147. if (key_in_array($key, $array))
  148. return $array[$key];
  149. else
  150. return '';
  151. }
  152. function fprintf() {
  153. $n = func_num_args();
  154. if ($n < 2)
  155. return FALSE;
  156. $a = func_get_args();
  157. $fp = array_shift($a);
  158. $x = "\$s = sprintf";
  159. $sep = '(';
  160. foreach ($a as $z) {
  161. $x .= "$sep'$z'";
  162. $sep = ',';
  163. }
  164. $x .= ');';
  165. eval($x);
  166. $l = strlen($s);
  167. $r = fwrite($fp, $s, $l);
  168. if ($r != $l)
  169. return FALSE;
  170. else
  171. return TRUE;
  172. }
  173. // functions to display (print) a database table and its columns
  174. function begin_table($ncols) {
  175. global $table_ncols;
  176. $table_ncols = $ncols;
  177. echo "<table align=center width=\"100%\""
  178. . " border=1 cellpadding=4 cols=$table_ncols>\n";
  179. }
  180. function begin_field($name, $span = 0) {
  181. global $table_ncols;
  182. echo "<tr valign=top>\n";
  183. echo "\t<th align=center>$name</th>\n";
  184. if ($span <= 0)
  185. $span = $table_ncols - 1;
  186. if ($span > 1)
  187. echo "\t<td colspan=$span>\n";
  188. else
  189. echo "\t<td>\n";
  190. }
  191. function cont_field($span = 1) {
  192. echo "\t</td>\n";
  193. if ($span > 1)
  194. echo "\t<td colspan=$span>\n";
  195. else
  196. echo "\t<td>\n";
  197. }
  198. function end_field() {
  199. echo "\t</td>\n";
  200. echo "</tr>\n";
  201. }
  202. function end_table() {
  203. echo "</table>\n";
  204. }
  205. function print_field($name, $array, $size = 0, $filt='') {
  206. begin_field($name);
  207. if (key_in_array($name, $array))
  208. $value = $array[$name];
  209. else
  210. $value = '';
  211. if ($filt != '')
  212. $value = $filt($value);
  213. echo "\t\t<input name=$name value=\"$value\"";
  214. if ($size > 0)
  215. echo " size=$size maxlength=$size";
  216. echo "></input>\n";
  217. end_field();
  218. }
  219. function print_field_multiline($name, $array, $cols, $rows, $filt='') {
  220. begin_field($name);
  221. if (key_in_array($name, $array))
  222. $value = $array[$name];
  223. else
  224. $value = '';
  225. if ($filt != '')
  226. $value = $filt($value);
  227. echo "\t\t<textarea name=$name " .
  228. "cols=$cols rows=$rows wrap=off>\n";
  229. echo "$value";
  230. echo "</textarea>\n";
  231. end_field();
  232. }
  233. // print a mysql ENUM as an html RADIO INPUT
  234. function print_enum($name, $array, $vals, $def = -1) {
  235. begin_field($name);
  236. if (key_in_array($name, $array))
  237. $chk = array_search($array[$name], $vals, FALSE);
  238. else
  239. $chk = $def;
  240. $nval = count($vals);
  241. for ($i = 0; $i < $nval; $i++) {
  242. $val = $vals[$i];
  243. if ($val == '')
  244. $pval = "none";
  245. else
  246. $pval = "$val";
  247. printf("\t\t<input type=radio name=$name"
  248. . " value=\"$val\"%s>$pval</input>\n",
  249. $i == $chk ? " checked" : "");
  250. }
  251. end_field();
  252. }
  253. // print a mysql ENUM as an html SELECT INPUT
  254. function print_enum_select($name, $array, $vals, $def = -1) {
  255. begin_field($name);
  256. echo "\t\t<select name=$name>\n";
  257. if (key_in_array($name, $array))
  258. $chk = array_search($array[$name], $vals, FALSE);
  259. else
  260. $chk = $def;
  261. $nval = count($vals);
  262. for ($i = 0; $i < $nval; $i++) {
  263. $val = $vals[$i];
  264. if ($val == '')
  265. $pval = "none";
  266. else
  267. $pval = "$val";
  268. printf("\t\t\t<option " .
  269. "value=\"%s\"%s>%s</option>\n",
  270. $val, $i == $chk ? " selected" : "", $pval);
  271. }
  272. echo "\t\t</select>\n";
  273. end_field();
  274. }
  275. // print a group of mysql ENUMs (e.g. name0,name1,...) as an html SELECT
  276. function print_enum_multi($base, $array, $vals, $cnt, $defs, $grp = 0) {
  277. global $table_ncols;
  278. if ($grp <= 0)
  279. $grp = $cnt;
  280. $ncell = $cnt / $grp;
  281. $span = ($table_ncols - 1) / $ncell;
  282. begin_field($base, $span);
  283. $nval = count($vals);
  284. for ($i = 0; $i < $cnt; $i++) {
  285. if ($i > 0 && ($i % $grp) == 0)
  286. cont_field($span);
  287. $name = sprintf("%s%x", $base, $i);
  288. echo "\t\t<select name=$name>\n";
  289. if (key_in_array($name, $array))
  290. $ai = array_search($array[$name], $vals, FALSE);
  291. else {
  292. if (key_in_array($i, $defs))
  293. $ai = $defs[$i];
  294. else
  295. $ai = 0;
  296. }
  297. for ($j = 0; $j < $nval; $j++) {
  298. $val = $vals[$j];
  299. if ($val == '')
  300. $pval = "&nbsp;";
  301. else
  302. $pval = "$val";
  303. printf("\t\t\t<option " .
  304. "value=\"%s\"%s>%s</option>\n",
  305. $val,
  306. $j == $ai ? " selected" : "",
  307. $pval);
  308. }
  309. echo "\t\t</select>\n";
  310. }
  311. end_field();
  312. }
  313. // functions to handle the form input
  314. // fetch all the parts of an "enum_multi" into a string suitable
  315. // for a MySQL query
  316. function gather_enum_multi_query($base, $cnt) {
  317. $retval = '';
  318. for ($i = 0; $i < $cnt; $i++) {
  319. $name = sprintf("%s%x", $base, $i);
  320. if (isset($_REQUEST[$name])) {
  321. $retval .= sprintf(", %s='%s'",
  322. $name, $_REQUEST[$name]);
  323. }
  324. }
  325. return $retval;
  326. }
  327. // fetch all the parts of an "enum_multi" into a string suitable
  328. // for a display e.g. in an html table cell
  329. function gather_enum_multi_print($base, $cnt, $array) {
  330. $retval = '';
  331. for ($i = 0; $i < $cnt; $i++) {
  332. $name = sprintf("%s%x", $base, $i);
  333. if ($array[$name] != '') {
  334. if ($retval != '')
  335. $retval .= ',';
  336. $retval .= $array[$name];
  337. }
  338. }
  339. return $retval;
  340. }
  341. // fetch all the parts of an "enum_multi" into a string suitable
  342. // for writing to the eeprom data file
  343. function gather_enum_multi_write($base, $cnt, $vals, $xfrm = array()) {
  344. $retval = '';
  345. for ($i = 0; $i < $cnt; $i++) {
  346. $name = sprintf("%s%x", $base, $i);
  347. if ($GLOBALS[$name] != '') {
  348. if ($retval != '')
  349. $retval .= ',';
  350. $index = enum_to_index($name, $vals);
  351. if ($xfrm != array())
  352. $retval .= $xfrm[$index];
  353. else
  354. $retval .= $index;
  355. }
  356. }
  357. return $retval;
  358. }
  359. // count how many parts of an "enum_multi" are actually set
  360. function count_enum_multi($base, $cnt) {
  361. $retval = 0;
  362. for ($i = 0; $i < $cnt; $i++) {
  363. $name = sprintf("%s%x", $base, $i);
  364. if (isset($_REQUEST[$name]))
  365. $retval++;
  366. }
  367. return $retval;
  368. }
  369. // ethernet address functions
  370. // generate a (possibly not unique) random vendor ethernet address
  371. // (setting bit 6 in the ethernet address - motorola wise i.e. bit 0
  372. // is the most significant bit - means it is not an assigned ethernet
  373. // address - it is a "locally administered" address). Also, make sure
  374. // it is NOT a multicast ethernet address (by setting bit 7 to 0).
  375. // e.g. the first byte of all ethernet addresses generated here will
  376. // have 2 in the bottom two bits (incidentally, these are the first
  377. // two bits transmitted on the wire, since the octets in ethernet
  378. // addresses are transmitted LSB first).
  379. function gen_eth_addr($serno) {
  380. $ethaddr_hgh = (mt_rand(0, 65535) & 0xfeff) | 0x0200;
  381. $ethaddr_mid = mt_rand(0, 65535);
  382. $ethaddr_low = mt_rand(0, 65535);
  383. return sprintf("%02lx:%02lx:%02lx:%02lx:%02lx:%02lx",
  384. $ethaddr_hgh >> 8, $ethaddr_hgh & 0xff,
  385. $ethaddr_mid >> 8, $ethaddr_mid & 0xff,
  386. $ethaddr_low >> 8, $ethaddr_low & 0xff);
  387. }
  388. // check that an ethernet address is valid
  389. function eth_addr_is_valid($ethaddr) {
  390. $ethbytes = split(':', $ethaddr);
  391. if (count($ethbytes) != 6)
  392. return FALSE;
  393. for ($i = 0; $i < 6; $i++) {
  394. $ethbyte = $ethbytes[$i];
  395. if (!ereg('^[0-9a-f][0-9a-f]$', $ethbyte))
  396. return FALSE;
  397. }
  398. return TRUE;
  399. }
  400. // write a simple eeprom configuration file
  401. function write_eeprom_cfg_file() {
  402. global $sernos, $nsernos, $bddb_cfgdir, $numerrs, $cfgerrs;
  403. global $date, $batch, $type_vals, $rev;
  404. global $sdram_vals, $sdram_nbits;
  405. global $flash_vals, $flash_nbits;
  406. global $zbt_vals, $zbt_nbits;
  407. global $xlxtyp_vals, $xlxspd_vals, $xlxtmp_vals, $xlxgrd_vals;
  408. global $cputyp, $cputyp_vals, $clk_vals;
  409. global $hstype, $hstype_vals, $hschin, $hschout;
  410. $numerrs = 0;
  411. $cfgerrs = array();
  412. for ($i = 0; $i < $nsernos; $i++) {
  413. $serno = sprintf("%010d", $sernos[$i]);
  414. $wfp = @fopen($bddb_cfgdir . "/$serno.cfg", "w");
  415. if (!$wfp) {
  416. $cfgerrs[$i] = 'file create fail';
  417. $numerrs++;
  418. continue;
  419. }
  420. set_file_buffer($wfp, 0);
  421. if (!fprintf($wfp, "serno=%d\n", $sernos[$i])) {
  422. $cfgerrs[$i] = 'cfg wr fail (serno)';
  423. fclose($wfp);
  424. $numerrs++;
  425. continue;
  426. }
  427. if (!fprintf($wfp, "date=%s\n", $date)) {
  428. $cfgerrs[$i] = 'cfg wr fail (date)';
  429. fclose($wfp);
  430. $numerrs++;
  431. continue;
  432. }
  433. if ($batch != '') {
  434. if (!fprintf($wfp, "batch=%s\n", $batch)) {
  435. $cfgerrs[$i] = 'cfg wr fail (batch)';
  436. fclose($wfp);
  437. $numerrs++;
  438. continue;
  439. }
  440. }
  441. $typei = enum_to_index("type", $type_vals);
  442. if (!fprintf($wfp, "type=%d\n", $typei)) {
  443. $cfgerrs[$i] = 'cfg wr fail (type)';
  444. fclose($wfp);
  445. $numerrs++;
  446. continue;
  447. }
  448. if (!fprintf($wfp, "rev=%d\n", $rev)) {
  449. $cfgerrs[$i] = 'cfg wr fail (rev)';
  450. fclose($wfp);
  451. $numerrs++;
  452. continue;
  453. }
  454. $s = gather_enum_multi_write("sdram", 4,
  455. $sdram_vals, $sdram_nbits);
  456. if ($s != '') {
  457. $b = fprintf($wfp, "sdram=%s\n", $s);
  458. if (!$b) {
  459. $cfgerrs[$i] = 'cfg wr fail (sdram)';
  460. fclose($wfp);
  461. $numerrs++;
  462. continue;
  463. }
  464. }
  465. $s = gather_enum_multi_write("flash", 4,
  466. $flash_vals, $flash_nbits);
  467. if ($s != '') {
  468. $b = fprintf($wfp, "flash=%s\n", $s);
  469. if (!$b) {
  470. $cfgerrs[$i] = 'cfg wr fail (flash)';
  471. fclose($wfp);
  472. $numerrs++;
  473. continue;
  474. }
  475. }
  476. $s = gather_enum_multi_write("zbt", 16,
  477. $zbt_vals, $zbt_nbits);
  478. if ($s != '') {
  479. $b = fprintf($wfp, "zbt=%s\n", $s);
  480. if (!$b) {
  481. $cfgerrs[$i] = 'cfg wr fail (zbt)';
  482. fclose($wfp);
  483. $numerrs++;
  484. continue;
  485. }
  486. }
  487. $s = gather_enum_multi_write("xlxtyp", 4, $xlxtyp_vals);
  488. if ($s != '') {
  489. $b = fprintf($wfp, "xlxtyp=%s\n", $s);
  490. if (!$b) {
  491. $cfgerrs[$i] = 'cfg wr fail (xlxtyp)';
  492. fclose($wfp);
  493. $numerrs++;
  494. continue;
  495. }
  496. }
  497. $s = gather_enum_multi_write("xlxspd", 4, $xlxspd_vals);
  498. if ($s != '') {
  499. $b = fprintf($wfp, "xlxspd=%s\n", $s);
  500. if (!$b) {
  501. $cfgerrs[$i] = 'cfg wr fail (xlxspd)';
  502. fclose($wfp);
  503. $numerrs++;
  504. continue;
  505. }
  506. }
  507. $s = gather_enum_multi_write("xlxtmp", 4, $xlxtmp_vals);
  508. if ($s != '') {
  509. $b = fprintf($wfp, "xlxtmp=%s\n", $s);
  510. if (!$b) {
  511. $cfgerrs[$i] = 'cfg wr fail (xlxtmp)';
  512. fclose($wfp);
  513. $numerrs++;
  514. continue;
  515. }
  516. }
  517. $s = gather_enum_multi_write("xlxgrd", 4, $xlxgrd_vals);
  518. if ($s != '') {
  519. $b = fprintf($wfp, "xlxgrd=%s\n", $s);
  520. if (!$b) {
  521. $cfgerrs[$i] = 'cfg wr fail (xlxgrd)';
  522. fclose($wfp);
  523. $numerrs++;
  524. continue;
  525. }
  526. }
  527. if ($cputyp != '') {
  528. $cputypi = enum_to_index("cputyp",$cputyp_vals);
  529. $cpuspdi = enum_to_index("cpuspd", $clk_vals);
  530. $busspdi = enum_to_index("busspd", $clk_vals);
  531. $cpmspdi = enum_to_index("cpmspd", $clk_vals);
  532. $b = fprintf($wfp, "cputyp=%d\ncpuspd=%d\n" .
  533. "busspd=%d\ncpmspd=%d\n",
  534. $cputypi, $cpuspdi, $busspdi, $cpmspdi);
  535. if (!$b) {
  536. $cfgerrs[$i] = 'cfg wr fail (cputyp)';
  537. fclose($wfp);
  538. $numerrs++;
  539. continue;
  540. }
  541. }
  542. if ($hstype != '') {
  543. $hstypei = enum_to_index("hstype",$hstype_vals);
  544. $b = fprintf($wfp, "hstype=%d\n" .
  545. "hschin=%s\nhschout=%s\n",
  546. $hstypei, $hschin, $hschout);
  547. if (!$b) {
  548. $cfgerrs[$i] = 'cfg wr fail (hstype)';
  549. fclose($wfp);
  550. $numerrs++;
  551. continue;
  552. }
  553. }
  554. if (!fclose($wfp)) {
  555. $cfgerrs[$i] = 'file cls fail';
  556. $numerrs++;
  557. }
  558. }
  559. return $numerrs;
  560. }
  561. ?>