entangledstate-isbn 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (290) hide show
  1. data/README +1 -1
  2. data/Rakefile +0 -18
  3. data/VERSION +1 -0
  4. data/isbn.gemspec +290 -7
  5. data/lib/isbn.rb +6 -6
  6. data/src/gocr-0.48/.cvsignore +6 -0
  7. data/src/gocr-0.48/AUTHORS +7 -0
  8. data/src/gocr-0.48/BUGS +55 -0
  9. data/src/gocr-0.48/CREDITS +17 -0
  10. data/src/gocr-0.48/HISTORY +243 -0
  11. data/src/gocr-0.48/INSTALL +83 -0
  12. data/src/gocr-0.48/Makefile +193 -0
  13. data/src/gocr-0.48/Makefile.in +193 -0
  14. data/src/gocr-0.48/README +165 -0
  15. data/src/gocr-0.48/READMEde.txt +80 -0
  16. data/src/gocr-0.48/REMARK.txt +18 -0
  17. data/src/gocr-0.48/REVIEW +538 -0
  18. data/src/gocr-0.48/TODO +65 -0
  19. data/src/gocr-0.48/bin/.cvsignore +2 -0
  20. data/src/gocr-0.48/bin/create_db +38 -0
  21. data/src/gocr-0.48/bin/gocr.tcl +527 -0
  22. data/src/gocr-0.48/bin/gocr_chk.sh +44 -0
  23. data/src/gocr-0.48/configure +4689 -0
  24. data/src/gocr-0.48/configure.in +71 -0
  25. data/src/gocr-0.48/doc/.#Makefile.1.6 +39 -0
  26. data/src/gocr-0.48/doc/.cvsignore +2 -0
  27. data/src/gocr-0.48/doc/Makefile +39 -0
  28. data/src/gocr-0.48/doc/Makefile.in +39 -0
  29. data/src/gocr-0.48/doc/example.dtd +53 -0
  30. data/src/gocr-0.48/doc/example.xml +21 -0
  31. data/src/gocr-0.48/doc/examples.txt +67 -0
  32. data/src/gocr-0.48/doc/gocr.html +578 -0
  33. data/src/gocr-0.48/doc/unicode.txt +57 -0
  34. data/src/gocr-0.48/examples/.#Makefile.1.22 +166 -0
  35. data/src/gocr-0.48/examples/4x6.png +0 -0
  36. data/src/gocr-0.48/examples/4x6.txt +2 -0
  37. data/src/gocr-0.48/examples/5x7.png +0 -0
  38. data/src/gocr-0.48/examples/5x7.png.txt +2 -0
  39. data/src/gocr-0.48/examples/5x8.png +0 -0
  40. data/src/gocr-0.48/examples/5x8.png.txt +2 -0
  41. data/src/gocr-0.48/examples/Makefile +166 -0
  42. data/src/gocr-0.48/examples/color.fig +20 -0
  43. data/src/gocr-0.48/examples/ex.fig +16 -0
  44. data/src/gocr-0.48/examples/font.tex +22 -0
  45. data/src/gocr-0.48/examples/font1.tex +46 -0
  46. data/src/gocr-0.48/examples/font2.fig +27 -0
  47. data/src/gocr-0.48/examples/font_nw.tex +24 -0
  48. data/src/gocr-0.48/examples/handwrt1.jpg +0 -0
  49. data/src/gocr-0.48/examples/handwrt1.txt +10 -0
  50. data/src/gocr-0.48/examples/inverse.fig +20 -0
  51. data/src/gocr-0.48/examples/matrix.jpg +0 -0
  52. data/src/gocr-0.48/examples/ocr-a-subset.png +0 -0
  53. data/src/gocr-0.48/examples/ocr-a-subset.png.txt +4 -0
  54. data/src/gocr-0.48/examples/ocr-a.png +0 -0
  55. data/src/gocr-0.48/examples/ocr-a.txt +6 -0
  56. data/src/gocr-0.48/examples/ocr-b.png +0 -0
  57. data/src/gocr-0.48/examples/ocr-b.png.txt +4 -0
  58. data/src/gocr-0.48/examples/polish.tex +28 -0
  59. data/src/gocr-0.48/examples/rotate45.fig +14 -0
  60. data/src/gocr-0.48/examples/score +36 -0
  61. data/src/gocr-0.48/examples/text.tex +28 -0
  62. data/src/gocr-0.48/gocr.spec +143 -0
  63. data/src/gocr-0.48/gpl.html +537 -0
  64. data/src/gocr-0.48/include/.cvsignore +2 -0
  65. data/src/gocr-0.48/include/config.h +36 -0
  66. data/src/gocr-0.48/include/config.h.in +36 -0
  67. data/src/gocr-0.48/include/version.h +2 -0
  68. data/src/gocr-0.48/install-sh +3 -0
  69. data/src/gocr-0.48/make.bat +57 -0
  70. data/src/gocr-0.48/man/.cvsignore +2 -0
  71. data/src/gocr-0.48/man/Makefile +29 -0
  72. data/src/gocr-0.48/man/Makefile.in +29 -0
  73. data/src/gocr-0.48/man/man1/gocr.1 +166 -0
  74. data/src/gocr-0.48/src/.cvsignore +4 -0
  75. data/src/gocr-0.48/src/Makefile +132 -0
  76. data/src/gocr-0.48/src/Makefile.in +132 -0
  77. data/src/gocr-0.48/src/amiga.h +31 -0
  78. data/src/gocr-0.48/src/barcode.c +846 -0
  79. data/src/gocr-0.48/src/barcode.c.orig +593 -0
  80. data/src/gocr-0.48/src/barcode.h +11 -0
  81. data/src/gocr-0.48/src/box.c +372 -0
  82. data/src/gocr-0.48/src/database.c +462 -0
  83. data/src/gocr-0.48/src/detect.c +943 -0
  84. data/src/gocr-0.48/src/gocr.c +373 -0
  85. data/src/gocr-0.48/src/gocr.h +288 -0
  86. data/src/gocr-0.48/src/jconv.c +168 -0
  87. data/src/gocr-0.48/src/job.c +84 -0
  88. data/src/gocr-0.48/src/lines.c +350 -0
  89. data/src/gocr-0.48/src/list.c +334 -0
  90. data/src/gocr-0.48/src/list.h +90 -0
  91. data/src/gocr-0.48/src/ocr0.c +6756 -0
  92. data/src/gocr-0.48/src/ocr0.h +63 -0
  93. data/src/gocr-0.48/src/ocr0n.c +1475 -0
  94. data/src/gocr-0.48/src/ocr1.c +85 -0
  95. data/src/gocr-0.48/src/ocr1.h +3 -0
  96. data/src/gocr-0.48/src/otsu.c +289 -0
  97. data/src/gocr-0.48/src/otsu.h +23 -0
  98. data/src/gocr-0.48/src/output.c +289 -0
  99. data/src/gocr-0.48/src/output.h +37 -0
  100. data/src/gocr-0.48/src/pcx.c +153 -0
  101. data/src/gocr-0.48/src/pcx.h +9 -0
  102. data/src/gocr-0.48/src/pgm2asc.c +2893 -0
  103. data/src/gocr-0.48/src/pgm2asc.h +105 -0
  104. data/src/gocr-0.48/src/pixel.c +537 -0
  105. data/src/gocr-0.48/src/pnm.c +533 -0
  106. data/src/gocr-0.48/src/pnm.h +35 -0
  107. data/src/gocr-0.48/src/progress.c +87 -0
  108. data/src/gocr-0.48/src/progress.h +42 -0
  109. data/src/gocr-0.48/src/remove.c +703 -0
  110. data/src/gocr-0.48/src/tga.c +87 -0
  111. data/src/gocr-0.48/src/tga.h +6 -0
  112. data/src/gocr-0.48/src/unicode.c +1314 -0
  113. data/src/gocr-0.48/src/unicode.h +1257 -0
  114. data/src/jpeg-7/Makefile.am +133 -0
  115. data/src/jpeg-7/Makefile.in +1089 -0
  116. data/src/jpeg-7/README +322 -0
  117. data/src/jpeg-7/aclocal.m4 +8990 -0
  118. data/src/jpeg-7/ansi2knr.1 +36 -0
  119. data/src/jpeg-7/ansi2knr.c +739 -0
  120. data/src/jpeg-7/cderror.h +132 -0
  121. data/src/jpeg-7/cdjpeg.c +181 -0
  122. data/src/jpeg-7/cdjpeg.h +187 -0
  123. data/src/jpeg-7/change.log +270 -0
  124. data/src/jpeg-7/cjpeg.1 +325 -0
  125. data/src/jpeg-7/cjpeg.c +616 -0
  126. data/src/jpeg-7/ckconfig.c +402 -0
  127. data/src/jpeg-7/coderules.txt +118 -0
  128. data/src/jpeg-7/config.guess +1561 -0
  129. data/src/jpeg-7/config.sub +1686 -0
  130. data/src/jpeg-7/configure +17139 -0
  131. data/src/jpeg-7/configure.ac +317 -0
  132. data/src/jpeg-7/depcomp +630 -0
  133. data/src/jpeg-7/djpeg.1 +251 -0
  134. data/src/jpeg-7/djpeg.c +617 -0
  135. data/src/jpeg-7/example.c +433 -0
  136. data/src/jpeg-7/filelist.txt +215 -0
  137. data/src/jpeg-7/install-sh +520 -0
  138. data/src/jpeg-7/install.txt +1097 -0
  139. data/src/jpeg-7/jaricom.c +148 -0
  140. data/src/jpeg-7/jcapimin.c +282 -0
  141. data/src/jpeg-7/jcapistd.c +161 -0
  142. data/src/jpeg-7/jcarith.c +921 -0
  143. data/src/jpeg-7/jccoefct.c +453 -0
  144. data/src/jpeg-7/jccolor.c +459 -0
  145. data/src/jpeg-7/jcdctmgr.c +482 -0
  146. data/src/jpeg-7/jchuff.c +1612 -0
  147. data/src/jpeg-7/jcinit.c +65 -0
  148. data/src/jpeg-7/jcmainct.c +293 -0
  149. data/src/jpeg-7/jcmarker.c +667 -0
  150. data/src/jpeg-7/jcmaster.c +770 -0
  151. data/src/jpeg-7/jcomapi.c +106 -0
  152. data/src/jpeg-7/jconfig.bcc +48 -0
  153. data/src/jpeg-7/jconfig.cfg +45 -0
  154. data/src/jpeg-7/jconfig.dj +38 -0
  155. data/src/jpeg-7/jconfig.mac +43 -0
  156. data/src/jpeg-7/jconfig.manx +43 -0
  157. data/src/jpeg-7/jconfig.mc6 +52 -0
  158. data/src/jpeg-7/jconfig.sas +43 -0
  159. data/src/jpeg-7/jconfig.st +42 -0
  160. data/src/jpeg-7/jconfig.txt +155 -0
  161. data/src/jpeg-7/jconfig.vc +45 -0
  162. data/src/jpeg-7/jconfig.vms +37 -0
  163. data/src/jpeg-7/jconfig.wat +38 -0
  164. data/src/jpeg-7/jcparam.c +632 -0
  165. data/src/jpeg-7/jcprepct.c +358 -0
  166. data/src/jpeg-7/jcsample.c +545 -0
  167. data/src/jpeg-7/jctrans.c +381 -0
  168. data/src/jpeg-7/jdapimin.c +396 -0
  169. data/src/jpeg-7/jdapistd.c +275 -0
  170. data/src/jpeg-7/jdarith.c +762 -0
  171. data/src/jpeg-7/jdatadst.c +151 -0
  172. data/src/jpeg-7/jdatasrc.c +212 -0
  173. data/src/jpeg-7/jdcoefct.c +736 -0
  174. data/src/jpeg-7/jdcolor.c +396 -0
  175. data/src/jpeg-7/jdct.h +393 -0
  176. data/src/jpeg-7/jddctmgr.c +382 -0
  177. data/src/jpeg-7/jdhuff.c +1309 -0
  178. data/src/jpeg-7/jdinput.c +384 -0
  179. data/src/jpeg-7/jdmainct.c +512 -0
  180. data/src/jpeg-7/jdmarker.c +1360 -0
  181. data/src/jpeg-7/jdmaster.c +663 -0
  182. data/src/jpeg-7/jdmerge.c +400 -0
  183. data/src/jpeg-7/jdpostct.c +290 -0
  184. data/src/jpeg-7/jdsample.c +361 -0
  185. data/src/jpeg-7/jdtrans.c +136 -0
  186. data/src/jpeg-7/jerror.c +252 -0
  187. data/src/jpeg-7/jerror.h +304 -0
  188. data/src/jpeg-7/jfdctflt.c +174 -0
  189. data/src/jpeg-7/jfdctfst.c +230 -0
  190. data/src/jpeg-7/jfdctint.c +4348 -0
  191. data/src/jpeg-7/jidctflt.c +242 -0
  192. data/src/jpeg-7/jidctfst.c +368 -0
  193. data/src/jpeg-7/jidctint.c +5137 -0
  194. data/src/jpeg-7/jinclude.h +91 -0
  195. data/src/jpeg-7/jmemansi.c +167 -0
  196. data/src/jpeg-7/jmemdos.c +638 -0
  197. data/src/jpeg-7/jmemdosa.asm +379 -0
  198. data/src/jpeg-7/jmemmac.c +289 -0
  199. data/src/jpeg-7/jmemmgr.c +1118 -0
  200. data/src/jpeg-7/jmemname.c +276 -0
  201. data/src/jpeg-7/jmemnobs.c +109 -0
  202. data/src/jpeg-7/jmemsys.h +198 -0
  203. data/src/jpeg-7/jmorecfg.h +369 -0
  204. data/src/jpeg-7/jpegint.h +395 -0
  205. data/src/jpeg-7/jpeglib.h +1135 -0
  206. data/src/jpeg-7/jpegtran.1 +272 -0
  207. data/src/jpeg-7/jpegtran.c +546 -0
  208. data/src/jpeg-7/jquant1.c +856 -0
  209. data/src/jpeg-7/jquant2.c +1310 -0
  210. data/src/jpeg-7/jutils.c +179 -0
  211. data/src/jpeg-7/jversion.h +14 -0
  212. data/src/jpeg-7/libjpeg.map +4 -0
  213. data/src/jpeg-7/libjpeg.txt +3067 -0
  214. data/src/jpeg-7/ltmain.sh +8406 -0
  215. data/src/jpeg-7/makcjpeg.st +36 -0
  216. data/src/jpeg-7/makdjpeg.st +36 -0
  217. data/src/jpeg-7/makeadsw.vc6 +77 -0
  218. data/src/jpeg-7/makeasln.vc9 +33 -0
  219. data/src/jpeg-7/makecdep.vc6 +82 -0
  220. data/src/jpeg-7/makecdsp.vc6 +130 -0
  221. data/src/jpeg-7/makecmak.vc6 +159 -0
  222. data/src/jpeg-7/makecvcp.vc9 +186 -0
  223. data/src/jpeg-7/makeddep.vc6 +82 -0
  224. data/src/jpeg-7/makeddsp.vc6 +130 -0
  225. data/src/jpeg-7/makedmak.vc6 +159 -0
  226. data/src/jpeg-7/makedvcp.vc9 +186 -0
  227. data/src/jpeg-7/makefile.ansi +220 -0
  228. data/src/jpeg-7/makefile.bcc +291 -0
  229. data/src/jpeg-7/makefile.dj +226 -0
  230. data/src/jpeg-7/makefile.manx +220 -0
  231. data/src/jpeg-7/makefile.mc6 +255 -0
  232. data/src/jpeg-7/makefile.mms +224 -0
  233. data/src/jpeg-7/makefile.sas +258 -0
  234. data/src/jpeg-7/makefile.unix +234 -0
  235. data/src/jpeg-7/makefile.vc +217 -0
  236. data/src/jpeg-7/makefile.vms +142 -0
  237. data/src/jpeg-7/makefile.wat +239 -0
  238. data/src/jpeg-7/makejdep.vc6 +423 -0
  239. data/src/jpeg-7/makejdsp.vc6 +285 -0
  240. data/src/jpeg-7/makejdsw.vc6 +29 -0
  241. data/src/jpeg-7/makejmak.vc6 +425 -0
  242. data/src/jpeg-7/makejsln.vc9 +17 -0
  243. data/src/jpeg-7/makejvcp.vc9 +328 -0
  244. data/src/jpeg-7/makeproj.mac +213 -0
  245. data/src/jpeg-7/makerdep.vc6 +6 -0
  246. data/src/jpeg-7/makerdsp.vc6 +78 -0
  247. data/src/jpeg-7/makermak.vc6 +110 -0
  248. data/src/jpeg-7/makervcp.vc9 +133 -0
  249. data/src/jpeg-7/maketdep.vc6 +43 -0
  250. data/src/jpeg-7/maketdsp.vc6 +122 -0
  251. data/src/jpeg-7/maketmak.vc6 +131 -0
  252. data/src/jpeg-7/maketvcp.vc9 +178 -0
  253. data/src/jpeg-7/makewdep.vc6 +6 -0
  254. data/src/jpeg-7/makewdsp.vc6 +78 -0
  255. data/src/jpeg-7/makewmak.vc6 +110 -0
  256. data/src/jpeg-7/makewvcp.vc9 +133 -0
  257. data/src/jpeg-7/makljpeg.st +68 -0
  258. data/src/jpeg-7/maktjpeg.st +30 -0
  259. data/src/jpeg-7/makvms.opt +4 -0
  260. data/src/jpeg-7/missing +376 -0
  261. data/src/jpeg-7/rdbmp.c +439 -0
  262. data/src/jpeg-7/rdcolmap.c +253 -0
  263. data/src/jpeg-7/rdgif.c +38 -0
  264. data/src/jpeg-7/rdjpgcom.1 +63 -0
  265. data/src/jpeg-7/rdjpgcom.c +515 -0
  266. data/src/jpeg-7/rdppm.c +459 -0
  267. data/src/jpeg-7/rdrle.c +387 -0
  268. data/src/jpeg-7/rdswitch.c +365 -0
  269. data/src/jpeg-7/rdtarga.c +500 -0
  270. data/src/jpeg-7/structure.txt +945 -0
  271. data/src/jpeg-7/testimg.bmp +0 -0
  272. data/src/jpeg-7/testimg.jpg +0 -0
  273. data/src/jpeg-7/testimg.ppm +4 -0
  274. data/src/jpeg-7/testimgp.jpg +0 -0
  275. data/src/jpeg-7/testorig.jpg +0 -0
  276. data/src/jpeg-7/testprog.jpg +0 -0
  277. data/src/jpeg-7/transupp.c +1533 -0
  278. data/src/jpeg-7/transupp.h +205 -0
  279. data/src/jpeg-7/usage.txt +605 -0
  280. data/src/jpeg-7/wizard.txt +211 -0
  281. data/src/jpeg-7/wrbmp.c +442 -0
  282. data/src/jpeg-7/wrgif.c +399 -0
  283. data/src/jpeg-7/wrjpgcom.1 +103 -0
  284. data/src/jpeg-7/wrjpgcom.c +583 -0
  285. data/src/jpeg-7/wrppm.c +269 -0
  286. data/src/jpeg-7/wrrle.c +305 -0
  287. data/src/jpeg-7/wrtarga.c +253 -0
  288. metadata +287 -6
  289. data/LICENSE +0 -20
  290. data/VERSION.yml +0 -4
@@ -0,0 +1,379 @@
1
+ ;
2
+ ; jmemdosa.asm
3
+ ;
4
+ ; Copyright (C) 1992, Thomas G. Lane.
5
+ ; This file is part of the Independent JPEG Group's software.
6
+ ; For conditions of distribution and use, see the accompanying README file.
7
+ ;
8
+ ; This file contains low-level interface routines to support the MS-DOS
9
+ ; backing store manager (jmemdos.c). Routines are provided to access disk
10
+ ; files through direct DOS calls, and to access XMS and EMS drivers.
11
+ ;
12
+ ; This file should assemble with Microsoft's MASM or any compatible
13
+ ; assembler (including Borland's Turbo Assembler). If you haven't got
14
+ ; a compatible assembler, better fall back to jmemansi.c or jmemname.c.
15
+ ;
16
+ ; To minimize dependence on the C compiler's register usage conventions,
17
+ ; we save and restore all 8086 registers, even though most compilers only
18
+ ; require SI,DI,DS to be preserved. Also, we use only 16-bit-wide return
19
+ ; values, which everybody returns in AX.
20
+ ;
21
+ ; Based on code contributed by Ge' Weijers.
22
+ ;
23
+
24
+ JMEMDOSA_TXT segment byte public 'CODE'
25
+
26
+ assume cs:JMEMDOSA_TXT
27
+
28
+ public _jdos_open
29
+ public _jdos_close
30
+ public _jdos_seek
31
+ public _jdos_read
32
+ public _jdos_write
33
+ public _jxms_getdriver
34
+ public _jxms_calldriver
35
+ public _jems_available
36
+ public _jems_calldriver
37
+
38
+ ;
39
+ ; short far jdos_open (short far * handle, char far * filename)
40
+ ;
41
+ ; Create and open a temporary file
42
+ ;
43
+ _jdos_open proc far
44
+ push bp ; linkage
45
+ mov bp,sp
46
+ push si ; save all registers for safety
47
+ push di
48
+ push bx
49
+ push cx
50
+ push dx
51
+ push es
52
+ push ds
53
+ mov cx,0 ; normal file attributes
54
+ lds dx,dword ptr [bp+10] ; get filename pointer
55
+ mov ah,3ch ; create file
56
+ int 21h
57
+ jc open_err ; if failed, return error code
58
+ lds bx,dword ptr [bp+6] ; get handle pointer
59
+ mov word ptr [bx],ax ; save the handle
60
+ xor ax,ax ; return zero for OK
61
+ open_err: pop ds ; restore registers and exit
62
+ pop es
63
+ pop dx
64
+ pop cx
65
+ pop bx
66
+ pop di
67
+ pop si
68
+ pop bp
69
+ ret
70
+ _jdos_open endp
71
+
72
+
73
+ ;
74
+ ; short far jdos_close (short handle)
75
+ ;
76
+ ; Close the file handle
77
+ ;
78
+ _jdos_close proc far
79
+ push bp ; linkage
80
+ mov bp,sp
81
+ push si ; save all registers for safety
82
+ push di
83
+ push bx
84
+ push cx
85
+ push dx
86
+ push es
87
+ push ds
88
+ mov bx,word ptr [bp+6] ; file handle
89
+ mov ah,3eh ; close file
90
+ int 21h
91
+ jc close_err ; if failed, return error code
92
+ xor ax,ax ; return zero for OK
93
+ close_err: pop ds ; restore registers and exit
94
+ pop es
95
+ pop dx
96
+ pop cx
97
+ pop bx
98
+ pop di
99
+ pop si
100
+ pop bp
101
+ ret
102
+ _jdos_close endp
103
+
104
+
105
+ ;
106
+ ; short far jdos_seek (short handle, long offset)
107
+ ;
108
+ ; Set file position
109
+ ;
110
+ _jdos_seek proc far
111
+ push bp ; linkage
112
+ mov bp,sp
113
+ push si ; save all registers for safety
114
+ push di
115
+ push bx
116
+ push cx
117
+ push dx
118
+ push es
119
+ push ds
120
+ mov bx,word ptr [bp+6] ; file handle
121
+ mov dx,word ptr [bp+8] ; LS offset
122
+ mov cx,word ptr [bp+10] ; MS offset
123
+ mov ax,4200h ; absolute seek
124
+ int 21h
125
+ jc seek_err ; if failed, return error code
126
+ xor ax,ax ; return zero for OK
127
+ seek_err: pop ds ; restore registers and exit
128
+ pop es
129
+ pop dx
130
+ pop cx
131
+ pop bx
132
+ pop di
133
+ pop si
134
+ pop bp
135
+ ret
136
+ _jdos_seek endp
137
+
138
+
139
+ ;
140
+ ; short far jdos_read (short handle, void far * buffer, unsigned short count)
141
+ ;
142
+ ; Read from file
143
+ ;
144
+ _jdos_read proc far
145
+ push bp ; linkage
146
+ mov bp,sp
147
+ push si ; save all registers for safety
148
+ push di
149
+ push bx
150
+ push cx
151
+ push dx
152
+ push es
153
+ push ds
154
+ mov bx,word ptr [bp+6] ; file handle
155
+ lds dx,dword ptr [bp+8] ; buffer address
156
+ mov cx,word ptr [bp+12] ; number of bytes
157
+ mov ah,3fh ; read file
158
+ int 21h
159
+ jc read_err ; if failed, return error code
160
+ cmp ax,word ptr [bp+12] ; make sure all bytes were read
161
+ je read_ok
162
+ mov ax,1 ; else return 1 for not OK
163
+ jmp short read_err
164
+ read_ok: xor ax,ax ; return zero for OK
165
+ read_err: pop ds ; restore registers and exit
166
+ pop es
167
+ pop dx
168
+ pop cx
169
+ pop bx
170
+ pop di
171
+ pop si
172
+ pop bp
173
+ ret
174
+ _jdos_read endp
175
+
176
+
177
+ ;
178
+ ; short far jdos_write (short handle, void far * buffer, unsigned short count)
179
+ ;
180
+ ; Write to file
181
+ ;
182
+ _jdos_write proc far
183
+ push bp ; linkage
184
+ mov bp,sp
185
+ push si ; save all registers for safety
186
+ push di
187
+ push bx
188
+ push cx
189
+ push dx
190
+ push es
191
+ push ds
192
+ mov bx,word ptr [bp+6] ; file handle
193
+ lds dx,dword ptr [bp+8] ; buffer address
194
+ mov cx,word ptr [bp+12] ; number of bytes
195
+ mov ah,40h ; write file
196
+ int 21h
197
+ jc write_err ; if failed, return error code
198
+ cmp ax,word ptr [bp+12] ; make sure all bytes written
199
+ je write_ok
200
+ mov ax,1 ; else return 1 for not OK
201
+ jmp short write_err
202
+ write_ok: xor ax,ax ; return zero for OK
203
+ write_err: pop ds ; restore registers and exit
204
+ pop es
205
+ pop dx
206
+ pop cx
207
+ pop bx
208
+ pop di
209
+ pop si
210
+ pop bp
211
+ ret
212
+ _jdos_write endp
213
+
214
+
215
+ ;
216
+ ; void far jxms_getdriver (XMSDRIVER far *)
217
+ ;
218
+ ; Get the address of the XMS driver, or NULL if not available
219
+ ;
220
+ _jxms_getdriver proc far
221
+ push bp ; linkage
222
+ mov bp,sp
223
+ push si ; save all registers for safety
224
+ push di
225
+ push bx
226
+ push cx
227
+ push dx
228
+ push es
229
+ push ds
230
+ mov ax,4300h ; call multiplex interrupt with
231
+ int 2fh ; a magic cookie, hex 4300
232
+ cmp al,80h ; AL should contain hex 80
233
+ je xmsavail
234
+ xor dx,dx ; no XMS driver available
235
+ xor ax,ax ; return a nil pointer
236
+ jmp short xmsavail_done
237
+ xmsavail: mov ax,4310h ; fetch driver address with
238
+ int 2fh ; another magic cookie
239
+ mov dx,es ; copy address to dx:ax
240
+ mov ax,bx
241
+ xmsavail_done: les bx,dword ptr [bp+6] ; get pointer to return value
242
+ mov word ptr es:[bx],ax
243
+ mov word ptr es:[bx+2],dx
244
+ pop ds ; restore registers and exit
245
+ pop es
246
+ pop dx
247
+ pop cx
248
+ pop bx
249
+ pop di
250
+ pop si
251
+ pop bp
252
+ ret
253
+ _jxms_getdriver endp
254
+
255
+
256
+ ;
257
+ ; void far jxms_calldriver (XMSDRIVER, XMScontext far *)
258
+ ;
259
+ ; The XMScontext structure contains values for the AX,DX,BX,SI,DS registers.
260
+ ; These are loaded, the XMS call is performed, and the new values of the
261
+ ; AX,DX,BX registers are written back to the context structure.
262
+ ;
263
+ _jxms_calldriver proc far
264
+ push bp ; linkage
265
+ mov bp,sp
266
+ push si ; save all registers for safety
267
+ push di
268
+ push bx
269
+ push cx
270
+ push dx
271
+ push es
272
+ push ds
273
+ les bx,dword ptr [bp+10] ; get XMScontext pointer
274
+ mov ax,word ptr es:[bx] ; load registers
275
+ mov dx,word ptr es:[bx+2]
276
+ mov si,word ptr es:[bx+6]
277
+ mov ds,word ptr es:[bx+8]
278
+ mov bx,word ptr es:[bx+4]
279
+ call dword ptr [bp+6] ; call the driver
280
+ mov cx,bx ; save returned BX for a sec
281
+ les bx,dword ptr [bp+10] ; get XMScontext pointer
282
+ mov word ptr es:[bx],ax ; put back ax,dx,bx
283
+ mov word ptr es:[bx+2],dx
284
+ mov word ptr es:[bx+4],cx
285
+ pop ds ; restore registers and exit
286
+ pop es
287
+ pop dx
288
+ pop cx
289
+ pop bx
290
+ pop di
291
+ pop si
292
+ pop bp
293
+ ret
294
+ _jxms_calldriver endp
295
+
296
+
297
+ ;
298
+ ; short far jems_available (void)
299
+ ;
300
+ ; Have we got an EMS driver? (this comes straight from the EMS 4.0 specs)
301
+ ;
302
+ _jems_available proc far
303
+ push si ; save all registers for safety
304
+ push di
305
+ push bx
306
+ push cx
307
+ push dx
308
+ push es
309
+ push ds
310
+ mov ax,3567h ; get interrupt vector 67h
311
+ int 21h
312
+ push cs
313
+ pop ds
314
+ mov di,000ah ; check offs 10 in returned seg
315
+ lea si,ASCII_device_name ; against literal string
316
+ mov cx,8
317
+ cld
318
+ repe cmpsb
319
+ jne no_ems
320
+ mov ax,1 ; match, it's there
321
+ jmp short avail_done
322
+ no_ems: xor ax,ax ; it's not there
323
+ avail_done: pop ds ; restore registers and exit
324
+ pop es
325
+ pop dx
326
+ pop cx
327
+ pop bx
328
+ pop di
329
+ pop si
330
+ ret
331
+
332
+ ASCII_device_name db "EMMXXXX0"
333
+
334
+ _jems_available endp
335
+
336
+
337
+ ;
338
+ ; void far jems_calldriver (EMScontext far *)
339
+ ;
340
+ ; The EMScontext structure contains values for the AX,DX,BX,SI,DS registers.
341
+ ; These are loaded, the EMS trap is performed, and the new values of the
342
+ ; AX,DX,BX registers are written back to the context structure.
343
+ ;
344
+ _jems_calldriver proc far
345
+ push bp ; linkage
346
+ mov bp,sp
347
+ push si ; save all registers for safety
348
+ push di
349
+ push bx
350
+ push cx
351
+ push dx
352
+ push es
353
+ push ds
354
+ les bx,dword ptr [bp+6] ; get EMScontext pointer
355
+ mov ax,word ptr es:[bx] ; load registers
356
+ mov dx,word ptr es:[bx+2]
357
+ mov si,word ptr es:[bx+6]
358
+ mov ds,word ptr es:[bx+8]
359
+ mov bx,word ptr es:[bx+4]
360
+ int 67h ; call the EMS driver
361
+ mov cx,bx ; save returned BX for a sec
362
+ les bx,dword ptr [bp+6] ; get EMScontext pointer
363
+ mov word ptr es:[bx],ax ; put back ax,dx,bx
364
+ mov word ptr es:[bx+2],dx
365
+ mov word ptr es:[bx+4],cx
366
+ pop ds ; restore registers and exit
367
+ pop es
368
+ pop dx
369
+ pop cx
370
+ pop bx
371
+ pop di
372
+ pop si
373
+ pop bp
374
+ ret
375
+ _jems_calldriver endp
376
+
377
+ JMEMDOSA_TXT ends
378
+
379
+ end
@@ -0,0 +1,289 @@
1
+ /*
2
+ * jmemmac.c
3
+ *
4
+ * Copyright (C) 1992-1997, Thomas G. Lane.
5
+ * This file is part of the Independent JPEG Group's software.
6
+ * For conditions of distribution and use, see the accompanying README file.
7
+ *
8
+ * jmemmac.c provides an Apple Macintosh implementation of the system-
9
+ * dependent portion of the JPEG memory manager.
10
+ *
11
+ * If you use jmemmac.c, then you must define USE_MAC_MEMMGR in the
12
+ * JPEG_INTERNALS part of jconfig.h.
13
+ *
14
+ * jmemmac.c uses the Macintosh toolbox routines NewPtr and DisposePtr
15
+ * instead of malloc and free. It accurately determines the amount of
16
+ * memory available by using CompactMem. Notice that if left to its
17
+ * own devices, this code can chew up all available space in the
18
+ * application's zone, with the exception of the rather small "slop"
19
+ * factor computed in jpeg_mem_available(). The application can ensure
20
+ * that more space is left over by reducing max_memory_to_use.
21
+ *
22
+ * Large images are swapped to disk using temporary files and System 7.0+'s
23
+ * temporary folder functionality.
24
+ *
25
+ * Note that jmemmac.c depends on two features of MacOS that were first
26
+ * introduced in System 7: FindFolder and the FSSpec-based calls.
27
+ * If your application uses jmemmac.c and is run under System 6 or earlier,
28
+ * and the jpeg library decides it needs a temporary file, it will abort,
29
+ * printing error messages about requiring System 7. (If no temporary files
30
+ * are created, it will run fine.)
31
+ *
32
+ * If you want to use jmemmac.c in an application that might be used with
33
+ * System 6 or earlier, then you should remove dependencies on FindFolder
34
+ * and the FSSpec calls. You will need to replace FindFolder with some
35
+ * other mechanism for finding a place to put temporary files, and you
36
+ * should replace the FSSpec calls with their HFS equivalents:
37
+ *
38
+ * FSpDelete -> HDelete
39
+ * FSpGetFInfo -> HGetFInfo
40
+ * FSpCreate -> HCreate
41
+ * FSpOpenDF -> HOpen *** Note: not HOpenDF ***
42
+ * FSMakeFSSpec -> (fill in spec by hand.)
43
+ *
44
+ * (Use HOpen instead of HOpenDF. HOpen is just a glue-interface to PBHOpen,
45
+ * which is on all HFS macs. HOpenDF is a System 7 addition which avoids the
46
+ * ages-old problem of names starting with a period.)
47
+ *
48
+ * Contributed by Sam Bushell (jsam@iagu.on.net) and
49
+ * Dan Gildor (gyld@in-touch.com).
50
+ */
51
+
52
+ #define JPEG_INTERNALS
53
+ #include "jinclude.h"
54
+ #include "jpeglib.h"
55
+ #include "jmemsys.h" /* import the system-dependent declarations */
56
+
57
+ #ifndef USE_MAC_MEMMGR /* make sure user got configuration right */
58
+ You forgot to define USE_MAC_MEMMGR in jconfig.h. /* deliberate syntax error */
59
+ #endif
60
+
61
+ #include <Memory.h> /* we use the MacOS memory manager */
62
+ #include <Files.h> /* we use the MacOS File stuff */
63
+ #include <Folders.h> /* we use the MacOS HFS stuff */
64
+ #include <Script.h> /* for smSystemScript */
65
+ #include <Gestalt.h> /* we use Gestalt to test for specific functionality */
66
+
67
+ #ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */
68
+ #define TEMP_FILE_NAME "JPG%03d.TMP"
69
+ #endif
70
+
71
+ static int next_file_num; /* to distinguish among several temp files */
72
+
73
+
74
+ /*
75
+ * Memory allocation and freeing are controlled by the MacOS library
76
+ * routines NewPtr() and DisposePtr(), which allocate fixed-address
77
+ * storage. Unfortunately, the IJG library isn't smart enough to cope
78
+ * with relocatable storage.
79
+ */
80
+
81
+ GLOBAL(void *)
82
+ jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
83
+ {
84
+ return (void *) NewPtr(sizeofobject);
85
+ }
86
+
87
+ GLOBAL(void)
88
+ jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)
89
+ {
90
+ DisposePtr((Ptr) object);
91
+ }
92
+
93
+
94
+ /*
95
+ * "Large" objects are treated the same as "small" ones.
96
+ * NB: we include FAR keywords in the routine declarations simply for
97
+ * consistency with the rest of the IJG code; FAR should expand to empty
98
+ * on rational architectures like the Mac.
99
+ */
100
+
101
+ GLOBAL(void FAR *)
102
+ jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
103
+ {
104
+ return (void FAR *) NewPtr(sizeofobject);
105
+ }
106
+
107
+ GLOBAL(void)
108
+ jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
109
+ {
110
+ DisposePtr((Ptr) object);
111
+ }
112
+
113
+
114
+ /*
115
+ * This routine computes the total memory space available for allocation.
116
+ */
117
+
118
+ GLOBAL(long)
119
+ jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,
120
+ long max_bytes_needed, long already_allocated)
121
+ {
122
+ long limit = cinfo->mem->max_memory_to_use - already_allocated;
123
+ long slop, mem;
124
+
125
+ /* Don't ask for more than what application has told us we may use */
126
+ if (max_bytes_needed > limit && limit > 0)
127
+ max_bytes_needed = limit;
128
+ /* Find whether there's a big enough free block in the heap.
129
+ * CompactMem tries to create a contiguous block of the requested size,
130
+ * and then returns the size of the largest free block (which could be
131
+ * much more or much less than we asked for).
132
+ * We add some slop to ensure we don't use up all available memory.
133
+ */
134
+ slop = max_bytes_needed / 16 + 32768L;
135
+ mem = CompactMem(max_bytes_needed + slop) - slop;
136
+ if (mem < 0)
137
+ mem = 0; /* sigh, couldn't even get the slop */
138
+ /* Don't take more than the application says we can have */
139
+ if (mem > limit && limit > 0)
140
+ mem = limit;
141
+ return mem;
142
+ }
143
+
144
+
145
+ /*
146
+ * Backing store (temporary file) management.
147
+ * Backing store objects are only used when the value returned by
148
+ * jpeg_mem_available is less than the total space needed. You can dispense
149
+ * with these routines if you have plenty of virtual memory; see jmemnobs.c.
150
+ */
151
+
152
+
153
+ METHODDEF(void)
154
+ read_backing_store (j_common_ptr cinfo, backing_store_ptr info,
155
+ void FAR * buffer_address,
156
+ long file_offset, long byte_count)
157
+ {
158
+ long bytes = byte_count;
159
+ long retVal;
160
+
161
+ if ( SetFPos ( info->temp_file, fsFromStart, file_offset ) != noErr )
162
+ ERREXIT(cinfo, JERR_TFILE_SEEK);
163
+
164
+ retVal = FSRead ( info->temp_file, &bytes,
165
+ (unsigned char *) buffer_address );
166
+ if ( retVal != noErr || bytes != byte_count )
167
+ ERREXIT(cinfo, JERR_TFILE_READ);
168
+ }
169
+
170
+
171
+ METHODDEF(void)
172
+ write_backing_store (j_common_ptr cinfo, backing_store_ptr info,
173
+ void FAR * buffer_address,
174
+ long file_offset, long byte_count)
175
+ {
176
+ long bytes = byte_count;
177
+ long retVal;
178
+
179
+ if ( SetFPos ( info->temp_file, fsFromStart, file_offset ) != noErr )
180
+ ERREXIT(cinfo, JERR_TFILE_SEEK);
181
+
182
+ retVal = FSWrite ( info->temp_file, &bytes,
183
+ (unsigned char *) buffer_address );
184
+ if ( retVal != noErr || bytes != byte_count )
185
+ ERREXIT(cinfo, JERR_TFILE_WRITE);
186
+ }
187
+
188
+
189
+ METHODDEF(void)
190
+ close_backing_store (j_common_ptr cinfo, backing_store_ptr info)
191
+ {
192
+ FSClose ( info->temp_file );
193
+ FSpDelete ( &(info->tempSpec) );
194
+ }
195
+
196
+
197
+ /*
198
+ * Initial opening of a backing-store object.
199
+ *
200
+ * This version uses FindFolder to find the Temporary Items folder,
201
+ * and puts the temporary file in there.
202
+ */
203
+
204
+ GLOBAL(void)
205
+ jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
206
+ long total_bytes_needed)
207
+ {
208
+ short tmpRef, vRefNum;
209
+ long dirID;
210
+ FInfo finderInfo;
211
+ FSSpec theSpec;
212
+ Str255 fName;
213
+ OSErr osErr;
214
+ long gestaltResponse = 0;
215
+
216
+ /* Check that FSSpec calls are available. */
217
+ osErr = Gestalt( gestaltFSAttr, &gestaltResponse );
218
+ if ( ( osErr != noErr )
219
+ || !( gestaltResponse & (1<<gestaltHasFSSpecCalls) ) )
220
+ ERREXITS(cinfo, JERR_TFILE_CREATE, "- System 7.0 or later required");
221
+ /* TO DO: add a proper error message to jerror.h. */
222
+
223
+ /* Check that FindFolder is available. */
224
+ osErr = Gestalt( gestaltFindFolderAttr, &gestaltResponse );
225
+ if ( ( osErr != noErr )
226
+ || !( gestaltResponse & (1<<gestaltFindFolderPresent) ) )
227
+ ERREXITS(cinfo, JERR_TFILE_CREATE, "- System 7.0 or later required.");
228
+ /* TO DO: add a proper error message to jerror.h. */
229
+
230
+ osErr = FindFolder ( kOnSystemDisk, kTemporaryFolderType, kCreateFolder,
231
+ &vRefNum, &dirID );
232
+ if ( osErr != noErr )
233
+ ERREXITS(cinfo, JERR_TFILE_CREATE, "- temporary items folder unavailable");
234
+ /* TO DO: Try putting the temp files somewhere else. */
235
+
236
+ /* Keep generating file names till we find one that's not in use */
237
+ for (;;) {
238
+ next_file_num++; /* advance counter */
239
+
240
+ sprintf(info->temp_name, TEMP_FILE_NAME, next_file_num);
241
+ strcpy ( (Ptr)fName+1, info->temp_name );
242
+ *fName = strlen (info->temp_name);
243
+ osErr = FSMakeFSSpec ( vRefNum, dirID, fName, &theSpec );
244
+
245
+ if ( (osErr = FSpGetFInfo ( &theSpec, &finderInfo ) ) != noErr )
246
+ break;
247
+ }
248
+
249
+ osErr = FSpCreate ( &theSpec, '????', '????', smSystemScript );
250
+ if ( osErr != noErr )
251
+ ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name);
252
+
253
+ osErr = FSpOpenDF ( &theSpec, fsRdWrPerm, &(info->temp_file) );
254
+ if ( osErr != noErr )
255
+ ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name);
256
+
257
+ info->tempSpec = theSpec;
258
+
259
+ info->read_backing_store = read_backing_store;
260
+ info->write_backing_store = write_backing_store;
261
+ info->close_backing_store = close_backing_store;
262
+ TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name);
263
+ }
264
+
265
+
266
+ /*
267
+ * These routines take care of any system-dependent initialization and
268
+ * cleanup required.
269
+ */
270
+
271
+ GLOBAL(long)
272
+ jpeg_mem_init (j_common_ptr cinfo)
273
+ {
274
+ next_file_num = 0;
275
+
276
+ /* max_memory_to_use will be initialized to FreeMem()'s result;
277
+ * the calling application might later reduce it, for example
278
+ * to leave room to invoke multiple JPEG objects.
279
+ * Note that FreeMem returns the total number of free bytes;
280
+ * it may not be possible to allocate a single block of this size.
281
+ */
282
+ return FreeMem();
283
+ }
284
+
285
+ GLOBAL(void)
286
+ jpeg_mem_term (j_common_ptr cinfo)
287
+ {
288
+ /* no work */
289
+ }