Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

jmemdos.c File Reference

#include "jinclude.h"
#include "jpeglib.h"
#include "jmemsys.h"

Include dependency graph for jmemdos.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  EMScontext
union  EMSspec
struct  XMScontext
union  XMSPTR
struct  XMSspec

Defines

#define DEFAULT_MAX_MEM   300000L
#define DST_HANDLE(spec)   FIELD_AT(spec,12,EMSH)
#define DST_OFFSET(spec)   FIELD_AT(spec,14,unsigned short)
#define DST_PAGE(spec)   FIELD_AT(spec,16,unsigned short)
#define DST_PTR(spec)   FIELD_AT(spec,14,EMSPTR)
#define DST_TYPE(spec)   FIELD_AT(spec,11,char)
#define EMS_SUPPORTED   1
#define EMSPAGESIZE   16384L
#define far_free(x)   free(x)
#define far_malloc(x)   malloc(x)
#define FIELD_AT(spec, offset, type)   (*((type *) &(spec.bytes[offset])))
#define HIBYTE(W)   (((W) >> 8) & 0xFF)
#define JPEG_INTERNALS
#define LOBYTE(W)   ((W) & 0xFF)
#define ODD(X)   (((X) & 1L) != 0)
#define READ_BINARY   "rb"
#define SRC_HANDLE(spec)   FIELD_AT(spec,5,EMSH)
#define SRC_OFFSET(spec)   FIELD_AT(spec,7,unsigned short)
#define SRC_PAGE(spec)   FIELD_AT(spec,9,unsigned short)
#define SRC_PTR(spec)   FIELD_AT(spec,7,EMSPTR)
#define SRC_TYPE(spec)   FIELD_AT(spec,4,char)
#define XMS_SUPPORTED   1

Typedefs

typedef void far * EMSPTR

Functions

METHODDEF void close_ems_store (j_common_ptr cinfo, backing_store_ptr info)
METHODDEF void close_file_store (j_common_ptr cinfo, backing_store_ptr info)
METHODDEF void close_xms_store (j_common_ptr cinfo, backing_store_ptr info)
GLOBAL void jpeg_free_large (j_common_ptr cinfo, void FAR *object, size_t sizeofobject)
GLOBAL void jpeg_free_small (j_common_ptr cinfo, void *object, size_t sizeofobject)
GLOBAL void FAR * jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
GLOBAL void * jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
GLOBAL long jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, long max_bytes_needed, long already_allocated)
GLOBAL long jpeg_mem_init (j_common_ptr cinfo)
GLOBAL void jpeg_mem_term (j_common_ptr cinfo)
GLOBAL void jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, long total_bytes_needed)
EXTERN void far jems_calldriver JPP ((EMScontext far *))
EXTERN short far jems_available JPP ((void))
EXTERN void far jxms_calldriver JPP ((XMSDRIVER, XMScontext far *))
EXTERN void far jxms_getdriver JPP ((XMSDRIVER far *))
EXTERN short far jdos_read JPP ((short handle, void far *buffer, unsigned short count))
EXTERN short far jdos_seek JPP ((short handle, long offset))
EXTERN short far jdos_close JPP ((short handle))
EXTERN short far jdos_open JPP ((short far *handle, char far *filename))
LOCAL boolean open_ems_store (j_common_ptr cinfo, backing_store_ptr info, long total_bytes_needed)
LOCAL boolean open_file_store (j_common_ptr cinfo, backing_store_ptr info, long total_bytes_needed)
LOCAL boolean open_xms_store (j_common_ptr cinfo, backing_store_ptr info, long total_bytes_needed)
METHODDEF void read_ems_store (j_common_ptr cinfo, backing_store_ptr info, void FAR *buffer_address, long file_offset, long byte_count)
METHODDEF void read_file_store (j_common_ptr cinfo, backing_store_ptr info, void FAR *buffer_address, long file_offset, long byte_count)
METHODDEF void read_xms_store (j_common_ptr cinfo, backing_store_ptr info, void FAR *buffer_address, long file_offset, long byte_count)
LOCAL void select_file_name (char *fname)
METHODDEF void write_ems_store (j_common_ptr cinfo, backing_store_ptr info, void FAR *buffer_address, long file_offset, long byte_count)
METHODDEF void write_file_store (j_common_ptr cinfo, backing_store_ptr info, void FAR *buffer_address, long file_offset, long byte_count)
METHODDEF void write_xms_store (j_common_ptr cinfo, backing_store_ptr info, void FAR *buffer_address, long file_offset, long byte_count)

Variables

int next_file_num
XMSDRIVER xms_driver
MAX_ALLOC_CHUNK should be
less than K typedef void far * 
XMSDRIVER


Define Documentation

#define DEFAULT_MAX_MEM   300000L
 

Definition at line 200 of file jmemdos.c.

#define DST_HANDLE spec   )     FIELD_AT(spec,12,EMSH)
 

Definition at line 475 of file jmemdos.c.

Referenced by read_ems_store(), and write_ems_store().

#define DST_OFFSET spec   )     FIELD_AT(spec,14,unsigned short)
 

Definition at line 476 of file jmemdos.c.

Referenced by write_ems_store().

#define DST_PAGE spec   )     FIELD_AT(spec,16,unsigned short)
 

Definition at line 477 of file jmemdos.c.

Referenced by write_ems_store().

#define DST_PTR spec   )     FIELD_AT(spec,14,EMSPTR)
 

Definition at line 478 of file jmemdos.c.

Referenced by read_ems_store().

#define DST_TYPE spec   )     FIELD_AT(spec,11,char)
 

Definition at line 474 of file jmemdos.c.

Referenced by read_ems_store(), and write_ems_store().

#define EMS_SUPPORTED   1
 

Definition at line 38 of file jmemdos.c.

#define EMSPAGESIZE   16384L
 

Definition at line 480 of file jmemdos.c.

Referenced by open_ems_store().

#define far_free  )     free(x)
 

Definition at line 70 of file jmemdos.c.

Referenced by jpeg_free_large().

#define far_malloc  )     malloc(x)
 

Definition at line 69 of file jmemdos.c.

Referenced by jpeg_get_large().

#define FIELD_AT spec,
offset,
type   )     (*((type *) &(spec.bytes[offset])))
 

Definition at line 468 of file jmemdos.c.

#define HIBYTE W   )     (((W) >> 8) & 0xFF)
 

Definition at line 482 of file jmemdos.c.

Referenced by open_ems_store(), read_ems_store(), WG_CheckHardwareGamma(), and write_ems_store().

#define JPEG_INTERNALS
 

Definition at line 42 of file jmemdos.c.

#define LOBYTE W   )     ((W) & 0xFF)
 

Definition at line 483 of file jmemdos.c.

Referenced by open_ems_store().

#define ODD X   )     (((X) & 1L) != 0)
 

Definition at line 325 of file jmemdos.c.

Referenced by read_xms_store(), and write_xms_store().

#define READ_BINARY   "rb"
 

Definition at line 77 of file jmemdos.c.

Referenced by main(), and select_file_name().

#define SRC_HANDLE spec   )     FIELD_AT(spec,5,EMSH)
 

Definition at line 470 of file jmemdos.c.

Referenced by read_ems_store(), and write_ems_store().

#define SRC_OFFSET spec   )     FIELD_AT(spec,7,unsigned short)
 

Definition at line 471 of file jmemdos.c.

Referenced by read_ems_store().

#define SRC_PAGE spec   )     FIELD_AT(spec,9,unsigned short)
 

Definition at line 472 of file jmemdos.c.

Referenced by read_ems_store().

#define SRC_PTR spec   )     FIELD_AT(spec,7,EMSPTR)
 

Definition at line 473 of file jmemdos.c.

Referenced by write_ems_store().

#define SRC_TYPE spec   )     FIELD_AT(spec,4,char)
 

Definition at line 469 of file jmemdos.c.

Referenced by read_ems_store(), and write_ems_store().

#define XMS_SUPPORTED   1
 

Definition at line 35 of file jmemdos.c.


Typedef Documentation

typedef void far* EMSPTR
 

Definition at line 460 of file jmemdos.c.


Function Documentation

METHODDEF void close_ems_store j_common_ptr  cinfo,
backing_store_ptr  info
 

Definition at line 537 of file jmemdos.c.

References EMScontext::ax, backing_store_ptr, EMScontext::dx, j_common_ptr, JTRC_EMS_CLOSE, and TRACEMS1.

00538 {
00539   EMScontext ctx;
00540 
00541   ctx.ax = 0x4500;
00542   ctx.dx = info->handle.ems_handle;
00543   jems_calldriver((EMScontext far *) & ctx);
00544   TRACEMS1(cinfo, 1, JTRC_EMS_CLOSE, info->handle.ems_handle);
00545   /* we ignore any error return from the driver */
00546 }

METHODDEF void close_file_store j_common_ptr  cinfo,
backing_store_ptr  info
 

Definition at line 271 of file jmemdos.c.

References backing_store_ptr, j_common_ptr, remove(), backing_store_struct::temp_name, and TRACEMSS.

00272 {
00273   jdos_close(info->handle.file_handle); /* close the file */
00274   remove(info->temp_name);  /* delete the file */
00275 /* If your system doesn't have remove(), try unlink() instead.
00276  * remove() is the ANSI-standard name for this function, but
00277  * unlink() was more common in pre-ANSI systems.
00278  */
00279   TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name);
00280 }

Here is the call graph for this function:

METHODDEF void close_xms_store j_common_ptr  cinfo,
backing_store_ptr  info
 

Definition at line 397 of file jmemdos.c.

References XMScontext::ax, backing_store_ptr, XMScontext::dx, j_common_ptr, JTRC_XMS_CLOSE, TRACEMS1, and xms_driver.

00398 {
00399   XMScontext ctx;
00400 
00401   ctx.dx = info->handle.xms_handle;
00402   ctx.ax = 0x0a00;
00403   jxms_calldriver(xms_driver, (XMScontext far *) & ctx);
00404   TRACEMS1(cinfo, 1, JTRC_XMS_CLOSE, info->handle.xms_handle);
00405   /* we ignore any error return from the driver */
00406 }

GLOBAL void jpeg_free_large j_common_ptr  cinfo,
void FAR *  object,
size_t  sizeofobject
 

Definition at line 185 of file jmemdos.c.

References far_free, and j_common_ptr.

00186 {
00187   far_free(object);
00188 }

GLOBAL void jpeg_free_small j_common_ptr  cinfo,
void *  object,
size_t  sizeofobject
 

Definition at line 168 of file jmemdos.c.

References free(), and j_common_ptr.

00169 {
00170   free(object);
00171 }

Here is the call graph for this function:

GLOBAL void FAR* jpeg_get_large j_common_ptr  cinfo,
size_t  sizeofobject
 

Definition at line 179 of file jmemdos.c.

References FAR, far_malloc, and j_common_ptr.

00180 {
00181   return (void FAR *) far_malloc(sizeofobject);
00182 }

GLOBAL void* jpeg_get_small j_common_ptr  cinfo,
size_t  sizeofobject
 

Definition at line 162 of file jmemdos.c.

References j_common_ptr, and malloc().

00163 {
00164   return (void *) malloc(sizeofobject);
00165 }

Here is the call graph for this function:

GLOBAL long jpeg_mem_available j_common_ptr  cinfo,
long  min_bytes_needed,
long  max_bytes_needed,
long  already_allocated
 

Definition at line 204 of file jmemdos.c.

References j_common_ptr.

00206 {
00207   return cinfo->mem->max_memory_to_use - already_allocated;
00208 }

GLOBAL long jpeg_mem_init j_common_ptr  cinfo  ) 
 

Definition at line 619 of file jmemdos.c.

References j_common_ptr, and next_file_num.

00620 {
00621   next_file_num = 0;        /* initialize temp file name generator */
00622   return DEFAULT_MAX_MEM;   /* default for max_memory_to_use */
00623 }

GLOBAL void jpeg_mem_term j_common_ptr  cinfo  ) 
 

Definition at line 626 of file jmemdos.c.

References j_common_ptr.

00627 {
00628   /* Microsoft C, at least in v6.00A, will not successfully reclaim freed
00629    * blocks of size > 32Kbytes unless we give it a kick in the rear, like so:
00630    */
00631 #ifdef NEED_FHEAPMIN
00632   _fheapmin();
00633 #endif
00634 }

GLOBAL void jpeg_open_backing_store j_common_ptr  cinfo,
backing_store_ptr  info,
long  total_bytes_needed
 

Definition at line 595 of file jmemdos.c.

References backing_store_ptr, ERREXITS, j_common_ptr, JERR_TFILE_CREATE, open_ems_store(), open_file_store(), and open_xms_store().

00597 {
00598   /* Try extended memory, then expanded memory, then regular file. */
00599 #if XMS_SUPPORTED
00600   if (open_xms_store(cinfo, info, total_bytes_needed))
00601     return;
00602 #endif
00603 #if EMS_SUPPORTED
00604   if (open_ems_store(cinfo, info, total_bytes_needed))
00605     return;
00606 #endif
00607   if (open_file_store(cinfo, info, total_bytes_needed))
00608     return;
00609   ERREXITS(cinfo, JERR_TFILE_CREATE, "");
00610 }

Here is the call graph for this function:

EXTERN void far jems_calldriver JPP (EMScontext far *)   ) 
 

EXTERN short far jems_available JPP (void)   ) 
 

EXTERN void far jxms_calldriver JPP (XMSDRIVER, XMScontext far *)   ) 
 

EXTERN void far jxms_getdriver JPP (XMSDRIVER far *)   ) 
 

EXTERN short far jdos_write JPP (short handle, void far *buffer, unsigned short count  ) 
 

EXTERN short far jdos_seek JPP (short handle, long offset  ) 
 

EXTERN short far jdos_close JPP (short handle)   ) 
 

EXTERN short far jdos_open JPP (short far *handle, char far *filename)   ) 
 

LOCAL boolean open_ems_store j_common_ptr  cinfo,
backing_store_ptr  info,
long  total_bytes_needed
 

Definition at line 550 of file jmemdos.c.

References EMScontext::ax, backing_store_ptr, EMScontext::bx, EMSPAGESIZE, HIBYTE, j_common_ptr, JTRC_EMS_OPEN, LOBYTE, and TRACEMS1.

Referenced by jpeg_open_backing_store().

00552 {
00553   EMScontext ctx;
00554 
00555   /* Is EMS driver there? */
00556   if (! jems_available())
00557     return FALSE;
00558 
00559   /* Get status, make sure EMS is OK */
00560   ctx.ax = 0x4000;
00561   jems_calldriver((EMScontext far *) & ctx);
00562   if (HIBYTE(ctx.ax) != 0)
00563     return FALSE;
00564 
00565   /* Get version, must be >= 4.0 */
00566   ctx.ax = 0x4600;
00567   jems_calldriver((EMScontext far *) & ctx);
00568   if (HIBYTE(ctx.ax) != 0 || LOBYTE(ctx.ax) < 0x40)
00569     return FALSE;
00570 
00571   /* Try to allocate requested space */
00572   ctx.ax = 0x4300;
00573   ctx.bx = (unsigned short) ((total_bytes_needed + EMSPAGESIZE-1L) / EMSPAGESIZE);
00574   jems_calldriver((EMScontext far *) & ctx);
00575   if (HIBYTE(ctx.ax) != 0)
00576     return FALSE;
00577 
00578   /* Succeeded, save the handle and away we go */
00579   info->handle.ems_handle = ctx.dx;
00580   info->read_backing_store = read_ems_store;
00581   info->write_backing_store = write_ems_store;
00582   info->close_backing_store = close_ems_store;
00583   TRACEMS1(cinfo, 1, JTRC_EMS_OPEN, ctx.dx);
00584   return TRUE;          /* succeeded */
00585 }

LOCAL boolean open_file_store j_common_ptr  cinfo,
backing_store_ptr  info,
long  total_bytes_needed
 

Definition at line 284 of file jmemdos.c.

References backing_store_ptr, ERREXITS, j_common_ptr, JERR_TFILE_CREATE, select_file_name(), backing_store_struct::temp_name, and TRACEMSS.

Referenced by jpeg_open_backing_store().

00286 {
00287   short handle;
00288 
00289   select_file_name(info->temp_name);
00290   if (jdos_open((short far *) & handle, (char far *) info->temp_name)) {
00291     /* might as well exit since jpeg_open_backing_store will fail anyway */
00292     ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name);
00293     return FALSE;
00294   }
00295   info->handle.file_handle = handle;
00296   info->read_backing_store = read_file_store;
00297   info->write_backing_store = write_file_store;
00298   info->close_backing_store = close_file_store;
00299   TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name);
00300   return TRUE;          /* succeeded */
00301 }

Here is the call graph for this function:

LOCAL boolean open_xms_store j_common_ptr  cinfo,
backing_store_ptr  info,
long  total_bytes_needed
 

Definition at line 410 of file jmemdos.c.

References XMScontext::ax, backing_store_ptr, XMScontext::dx, j_common_ptr, JTRC_XMS_OPEN, TRACEMS1, xms_driver, and XMSDRIVER.

Referenced by jpeg_open_backing_store().

00412 {
00413   XMScontext ctx;
00414 
00415   /* Get address of XMS driver */
00416   jxms_getdriver((XMSDRIVER far *) & xms_driver);
00417   if (xms_driver == NULL)
00418     return FALSE;       /* no driver to be had */
00419 
00420   /* Get version number, must be >= 2.00 */
00421   ctx.ax = 0x0000;
00422   jxms_calldriver(xms_driver, (XMScontext far *) & ctx);
00423   if (ctx.ax < (unsigned short) 0x0200)
00424     return FALSE;
00425 
00426   /* Try to get space (expressed in kilobytes) */
00427   ctx.dx = (unsigned short) ((total_bytes_needed + 1023L) >> 10);
00428   ctx.ax = 0x0900;
00429   jxms_calldriver(xms_driver, (XMScontext far *) & ctx);
00430   if (ctx.ax != 1)
00431     return FALSE;
00432 
00433   /* Succeeded, save the handle and away we go */
00434   info->handle.xms_handle = ctx.dx;
00435   info->read_backing_store = read_xms_store;
00436   info->write_backing_store = write_xms_store;
00437   info->close_backing_store = close_xms_store;
00438   TRACEMS1(cinfo, 1, JTRC_XMS_OPEN, ctx.dx);
00439   return TRUE;          /* succeeded */
00440 }

METHODDEF void read_ems_store j_common_ptr  cinfo,
backing_store_ptr  info,
void FAR *  buffer_address,
long  file_offset,
long  byte_count
 

Definition at line 487 of file jmemdos.c.

References EMScontext::ax, backing_store_ptr, EMScontext::ds_si, DST_HANDLE, DST_PTR, DST_TYPE, ERREXIT, HIBYTE, j_common_ptr, JERR_EMS_READ, EMSspec::length, SRC_HANDLE, SRC_OFFSET, SRC_PAGE, and SRC_TYPE.

00490 {
00491   EMScontext ctx;
00492   EMSspec spec;
00493 
00494   spec.length = byte_count;
00495   SRC_TYPE(spec) = 1;
00496   SRC_HANDLE(spec) = info->handle.ems_handle;
00497   SRC_PAGE(spec)   = (unsigned short) (file_offset / EMSPAGESIZE);
00498   SRC_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE);
00499   DST_TYPE(spec) = 0;
00500   DST_HANDLE(spec) = 0;
00501   DST_PTR(spec)    = buffer_address;
00502   
00503   ctx.ds_si = (void far *) & spec;
00504   ctx.ax = 0x5700;      /* move memory region */
00505   jems_calldriver((EMScontext far *) & ctx);
00506   if (HIBYTE(ctx.ax) != 0)
00507     ERREXIT(cinfo, JERR_EMS_READ);
00508 }

METHODDEF void read_file_store j_common_ptr  cinfo,
backing_store_ptr  info,
void FAR *  buffer_address,
long  file_offset,
long  byte_count
 

Definition at line 239 of file jmemdos.c.

References backing_store_ptr, ERREXIT, j_common_ptr, JERR_BAD_ALLOC_CHUNK, JERR_TFILE_READ, and JERR_TFILE_SEEK.

00242 {
00243   if (jdos_seek(info->handle.file_handle, file_offset))
00244     ERREXIT(cinfo, JERR_TFILE_SEEK);
00245   /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */
00246   if (byte_count > 65535L)  /* safety check */
00247     ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK);
00248   if (jdos_read(info->handle.file_handle, buffer_address,
00249         (unsigned short) byte_count))
00250     ERREXIT(cinfo, JERR_TFILE_READ);
00251 }

METHODDEF void read_xms_store j_common_ptr  cinfo,
backing_store_ptr  info,
void FAR *  buffer_address,
long  file_offset,
long  byte_count
 

Definition at line 329 of file jmemdos.c.

References XMScontext::ax, backing_store_ptr, XMScontext::ds_si, XMSspec::dst, XMSspec::dst_handle, ERREXIT, FAR, j_common_ptr, JERR_XMS_READ, L, XMSspec::length, ODD, XMSPTR::offset, XMSPTR::ptr, XMSspec::src, XMSspec::src_handle, and xms_driver.

Referenced by write_xms_store().

00332 {
00333   XMScontext ctx;
00334   XMSspec spec;
00335   char endbuffer[2];
00336 
00337   /* The XMS driver can't cope with an odd length, so handle the last byte
00338    * specially if byte_count is odd.  We don't expect this to be common.
00339    */
00340 
00341   spec.length = byte_count & (~ 1L);
00342   spec.src_handle = info->handle.xms_handle;
00343   spec.src.offset = file_offset;
00344   spec.dst_handle = 0;
00345   spec.dst.ptr = buffer_address;
00346   
00347   ctx.ds_si = (void far *) & spec;
00348   ctx.ax = 0x0b00;      /* EMB move */
00349   jxms_calldriver(xms_driver, (XMScontext far *) & ctx);
00350   if (ctx.ax != 1)
00351     ERREXIT(cinfo, JERR_XMS_READ);
00352 
00353   if (ODD(byte_count)) {
00354     read_xms_store(cinfo, info, (void FAR *) endbuffer,
00355            file_offset + byte_count - 1L, 2L);
00356     ((char FAR *) buffer_address)[byte_count - 1L] = endbuffer[0];
00357   }
00358 }

LOCAL void select_file_name char *  fname  ) 
 

Definition at line 124 of file jmemdos.c.

References fclose(), fopen(), getenv(), next_file_num, ptr(), READ_BINARY, and sprintf().

00125 {
00126   const char * env;
00127   char * ptr;
00128   FILE * tfile;
00129 
00130   /* Keep generating file names till we find one that's not in use */
00131   for (;;) {
00132     /* Get temp directory name from environment TMP or TEMP variable;
00133      * if none, use "."
00134      */
00135     if ((env = (const char *) getenv("TMP")) == NULL)
00136       if ((env = (const char *) getenv("TEMP")) == NULL)
00137     env = ".";
00138     if (*env == '\0')       /* null string means "." */
00139       env = ".";
00140     ptr = fname;        /* copy name to fname */
00141     while (*env != '\0')
00142       *ptr++ = *env++;
00143     if (ptr[-1] != '\\' && ptr[-1] != '/')
00144       *ptr++ = '\\';        /* append backslash if not in env variable */
00145     /* Append a suitable file name */
00146     next_file_num++;        /* advance counter */
00147     sprintf(ptr, "JPG%03d.TMP", next_file_num);
00148     /* Probe to see if file name is already in use */
00149     if ((tfile = fopen(fname, READ_BINARY)) == NULL)
00150       break;
00151     fclose(tfile);      /* oops, it's there; close tfile & try again */
00152   }
00153 }

Here is the call graph for this function:

METHODDEF void write_ems_store j_common_ptr  cinfo,
backing_store_ptr  info,
void FAR *  buffer_address,
long  file_offset,
long  byte_count
 

Definition at line 512 of file jmemdos.c.

References EMScontext::ax, backing_store_ptr, EMScontext::ds_si, DST_HANDLE, DST_OFFSET, DST_PAGE, DST_TYPE, ERREXIT, HIBYTE, j_common_ptr, JERR_EMS_WRITE, EMSspec::length, SRC_HANDLE, SRC_PTR, and SRC_TYPE.

00515 {
00516   EMScontext ctx;
00517   EMSspec spec;
00518 
00519   spec.length = byte_count;
00520   SRC_TYPE(spec) = 0;
00521   SRC_HANDLE(spec) = 0;
00522   SRC_PTR(spec)    = buffer_address;
00523   DST_TYPE(spec) = 1;
00524   DST_HANDLE(spec) = info->handle.ems_handle;
00525   DST_PAGE(spec)   = (unsigned short) (file_offset / EMSPAGESIZE);
00526   DST_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE);
00527   
00528   ctx.ds_si = (void far *) & spec;
00529   ctx.ax = 0x5700;      /* move memory region */
00530   jems_calldriver((EMScontext far *) & ctx);
00531   if (HIBYTE(ctx.ax) != 0)
00532     ERREXIT(cinfo, JERR_EMS_WRITE);
00533 }

METHODDEF void write_file_store j_common_ptr  cinfo,
backing_store_ptr  info,
void FAR *  buffer_address,
long  file_offset,
long  byte_count
 

Definition at line 255 of file jmemdos.c.

References backing_store_ptr, ERREXIT, j_common_ptr, JERR_BAD_ALLOC_CHUNK, JERR_TFILE_SEEK, and JERR_TFILE_WRITE.

00258 {
00259   if (jdos_seek(info->handle.file_handle, file_offset))
00260     ERREXIT(cinfo, JERR_TFILE_SEEK);
00261   /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */
00262   if (byte_count > 65535L)  /* safety check */
00263     ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK);
00264   if (jdos_write(info->handle.file_handle, buffer_address,
00265          (unsigned short) byte_count))
00266     ERREXIT(cinfo, JERR_TFILE_WRITE);
00267 }

METHODDEF void write_xms_store j_common_ptr  cinfo,
backing_store_ptr  info,
void FAR *  buffer_address,
long  file_offset,
long  byte_count
 

Definition at line 362 of file jmemdos.c.

References XMScontext::ax, backing_store_ptr, XMScontext::ds_si, XMSspec::dst, XMSspec::dst_handle, ERREXIT, FAR, j_common_ptr, JERR_XMS_WRITE, L, XMSspec::length, ODD, XMSPTR::offset, XMSPTR::ptr, read_xms_store(), XMSspec::src, XMSspec::src_handle, and xms_driver.

00365 {
00366   XMScontext ctx;
00367   XMSspec spec;
00368   char endbuffer[2];
00369 
00370   /* The XMS driver can't cope with an odd length, so handle the last byte
00371    * specially if byte_count is odd.  We don't expect this to be common.
00372    */
00373 
00374   spec.length = byte_count & (~ 1L);
00375   spec.src_handle = 0;
00376   spec.src.ptr = buffer_address;
00377   spec.dst_handle = info->handle.xms_handle;
00378   spec.dst.offset = file_offset;
00379 
00380   ctx.ds_si = (void far *) & spec;
00381   ctx.ax = 0x0b00;      /* EMB move */
00382   jxms_calldriver(xms_driver, (XMScontext far *) & ctx);
00383   if (ctx.ax != 1)
00384     ERREXIT(cinfo, JERR_XMS_WRITE);
00385 
00386   if (ODD(byte_count)) {
00387     read_xms_store(cinfo, info, (void FAR *) endbuffer,
00388            file_offset + byte_count - 1L, 2L);
00389     endbuffer[0] = ((char FAR *) buffer_address)[byte_count - 1L];
00390     write_xms_store(cinfo, info, (void FAR *) endbuffer,
00391             file_offset + byte_count - 1L, 2L);
00392   }
00393 }

Here is the call graph for this function:


Variable Documentation

int next_file_num [static]
 

Definition at line 121 of file jmemdos.c.

Referenced by jpeg_mem_init(), and select_file_name().

XMSDRIVER xms_driver [static]
 

Definition at line 310 of file jmemdos.c.

Referenced by close_xms_store(), open_xms_store(), read_xms_store(), and write_xms_store().

MAX_ALLOC_CHUNK should be less than K typedef void far* XMSDRIVER
 

Definition at line 93 of file jmemdos.c.

Referenced by open_xms_store().


Generated on Thu Aug 25 14:16:35 2005 for Quake III Arena by  doxygen 1.3.9.1