gen_pwr928_table.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /* Generate mod 928 powers table for `encode928()` in "composite.c" */
  3. /*
  4. libzint - the open source barcode library
  5. Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
  6. */
  7. /* SPDX-License-Identifier: BSD-3-Clause */
  8. /* The functions "getBit", "init928" and "encode928" are copyright BSI and are
  9. released with permission under the following terms:
  10. "Copyright subsists in all BSI publications. BSI also holds the copyright, in the
  11. UK, of the international standardisation bodies. Except as
  12. permitted under the Copyright, Designs and Patents Act 1988 no extract may be
  13. reproduced, stored in a retrieval system or transmitted in any form or by any
  14. means - electronic, photocopying, recording or otherwise - without prior written
  15. permission from BSI.
  16. "This does not preclude the free use, in the course of implementing the standard,
  17. of necessary details such as symbols, and size, type or grade designations. If these
  18. details are to be used for any other purpose than implementation then the prior
  19. written permission of BSI must be obtained."
  20. The date of publication for these functions is 31 May 2006
  21. */
  22. $cw = array(0, 0, 0, 0, 0, 0, 1);
  23. $pwr928 = array( $cw );
  24. for ($j = 1; $j < 69; $j++) {
  25. for ($v = 0, $i = 6; $i >= 1; $i--) {
  26. $v = (2 * $cw[$i]) + (int)($v / 928);
  27. $pwr928[$j][$i] = $cw[$i] = $v % 928;
  28. }
  29. $pwr928[$j][0] = $cw[0] = (2 * $cw[0]) + (int)($v / 928);
  30. }
  31. printf("static const unsigned short cc_pwr928[69][7] = {\n");
  32. for ($i = 0; $i < 69; $i++) {
  33. printf(" { ");
  34. for ($j = 0; $j < 7; $j++) {
  35. printf("%3d, ", $pwr928[$i][$j]);
  36. }
  37. printf("},\n");
  38. }
  39. printf("};\n");
  40. /* vim: set ts=4 sw=4 et : */