Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

jmemdos.c File Reference

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

Go to the source code of this file.


Data Structures

struct  EMScontext
union  EMSspec
struct  XMScontext
union  XMSPTR
struct  XMSspec

Defines

#define XMS_SUPPORTED   1
#define EMS_SUPPORTED   1
#define JPEG_INTERNALS
#define far_malloc(x)   malloc(x)
#define far_free(x)   free(x)
#define READ_BINARY   "rb"
#define DEFAULT_MAX_MEM   300000L
#define ODD(X)   (((X) & 1L) != 0)
#define FIELD_AT(spec, offset, type)   (*((type *) &(spec.bytes[offset])))
#define SRC_TYPE(spec)   FIELD_AT(spec,4,char)
#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 DST_TYPE(spec)   FIELD_AT(spec,11,char)
#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 EMSPAGESIZE   16384L
#define HIBYTE(W)   (((W) >> 8) & 0xFF)
#define LOBYTE(W)   ((W) & 0xFF)

Typedefs

typedef void farEMSPTR

Functions

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

Variables

You forgot to define USE_MSDOS_MEMMGR
in jconfig h MAX_ALLOC_CHUNK
should be less than K typedef
void far
XMSDRIVER
int next_file_num
XMSDRIVER xms_driver

Define Documentation

#define DEFAULT_MAX_MEM   300000L
 

Definition at line 204 of file jmemdos.c.

Referenced by jpeg_mem_init().

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

Definition at line 479 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 480 of file jmemdos.c.

Referenced by write_ems_store().

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

Definition at line 481 of file jmemdos.c.

Referenced by write_ems_store().

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

Definition at line 482 of file jmemdos.c.

Referenced by read_ems_store().

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

Definition at line 478 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 484 of file jmemdos.c.

Referenced by open_ems_store(), read_ems_store(), and write_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 472 of file jmemdos.c.

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

Definition at line 486 of file jmemdos.c.

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

#define JPEG_INTERNALS
 

Definition at line 42 of file jmemdos.c.

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

Definition at line 487 of file jmemdos.c.

Referenced by open_ems_store().

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

Definition at line 329 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 select_file_name().

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

Definition at line 474 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 475 of file jmemdos.c.

Referenced by read_ems_store().

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

Definition at line 476 of file jmemdos.c.

Referenced by read_ems_store().

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

Definition at line 477 of file jmemdos.c.

Referenced by write_ems_store().

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

Definition at line 473 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 464 of file jmemdos.c.


Function Documentation

close_ems_store j_common_ptr    cinfo,
backing_store_ptr    info
 

Definition at line 541 of file jmemdos.c.

References EMScontext::ax, EMScontext::dx, far, and TRACEMS1.

Referenced by open_ems_store().

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

close_file_store j_common_ptr    cinfo,
backing_store_ptr    info
 

Definition at line 275 of file jmemdos.c.

References backing_store_struct::temp_name, and TRACEMSS.

Referenced by open_file_store().

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

close_xms_store j_common_ptr    cinfo,
backing_store_ptr    info
 

Definition at line 401 of file jmemdos.c.

References XMScontext::ax, XMScontext::dx, far, TRACEMS1, and xms_driver.

Referenced by open_xms_store().

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

jpeg_free_large j_common_ptr    cinfo,
void FAR *    object,
size_t    sizeofobject
 

Definition at line 189 of file jmemdos.c.

References far_free, object, and sizeofobject.

00190 {
00191   far_free(object);
00192 }

jpeg_free_small j_common_ptr    cinfo,
void *    object,
size_t    sizeofobject
 

Definition at line 172 of file jmemdos.c.

References free, object, and sizeofobject.

00173 {
00174   free(object);
00175 }

jpeg_get_large j_common_ptr    cinfo,
size_t    sizeofobject
 

Definition at line 183 of file jmemdos.c.

References far_malloc, and sizeofobject.

00184 {
00185   return (void FAR *) far_malloc(sizeofobject);
00186 }

jpeg_get_small j_common_ptr    cinfo,
size_t    sizeofobject
 

Definition at line 166 of file jmemdos.c.

References malloc, and sizeofobject.

00167 {
00168   return (void *) malloc(sizeofobject);
00169 }

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

Definition at line 208 of file jmemdos.c.

References already_allocated, max_bytes_needed, and min_bytes_needed.

00210 {
00211   return cinfo->mem->max_memory_to_use - already_allocated;
00212 }

jpeg_mem_init j_common_ptr    cinfo
 

Definition at line 623 of file jmemdos.c.

References DEFAULT_MAX_MEM, and next_file_num.

00624 {
00625   next_file_num = 0;            /* initialize temp file name generator */
00626   return DEFAULT_MAX_MEM;       /* default for max_memory_to_use */
00627 }

jpeg_mem_term j_common_ptr    cinfo
 

Definition at line 630 of file jmemdos.c.

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

jpeg_open_backing_store j_common_ptr    cinfo,
backing_store_ptr    info,
long    total_bytes_needed
 

Definition at line 599 of file jmemdos.c.

References ERREXITS, open_ems_store(), open_file_store(), open_xms_store(), and total_bytes_needed.

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

void far jems_calldriver JPP (EMScontext far *)   
 

short far jems_available JPP (void)   
 

void far jxms_calldriver JPP (XMSDRIVER, XMScontext far *)   
 

void far jxms_getdriver JPP (XMSDRIVER far *)   
 

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

short far jdos_seek JPP (short handle, long offset)   
 

short far jdos_close JPP (short handle  
 

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

char* getenv JPP (const char *name  
 

void free JPP (void *ptr  
 

void* malloc JPP (size_t size  
 

open_ems_store j_common_ptr    cinfo,
backing_store_ptr    info,
long    total_bytes_needed
 

Definition at line 554 of file jmemdos.c.

References EMScontext::ax, EMScontext::bx, close_ems_store(), EMScontext::dx, EMSPAGESIZE, far, HIBYTE, L, LOBYTE, read_ems_store(), total_bytes_needed, TRACEMS1, and write_ems_store().

Referenced by jpeg_open_backing_store().

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

open_file_store j_common_ptr    cinfo,
backing_store_ptr    info,
long    total_bytes_needed
 

Definition at line 288 of file jmemdos.c.

References close_file_store(), ERREXITS, far, read_file_store(), select_file_name(), backing_store_struct::temp_name, total_bytes_needed, TRACEMSS, and write_file_store().

Referenced by jpeg_open_backing_store().

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

open_xms_store j_common_ptr    cinfo,
backing_store_ptr    info,
long    total_bytes_needed
 

Definition at line 414 of file jmemdos.c.

References XMScontext::ax, close_xms_store(), XMScontext::dx, far, L, read_xms_store(), total_bytes_needed, TRACEMS1, write_xms_store(), xms_driver, and XMSDRIVER.

Referenced by jpeg_open_backing_store().

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

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

Definition at line 491 of file jmemdos.c.

References EMScontext::ax, EMScontext::ds_si, DST_HANDLE, DST_PTR, DST_TYPE, EMSPAGESIZE, ERREXIT, far, HIBYTE, EMSspec::length, SRC_HANDLE, SRC_OFFSET, SRC_PAGE, and SRC_TYPE.

Referenced by open_ems_store().

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

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

Definition at line 243 of file jmemdos.c.

References ERREXIT, and L.

Referenced by open_file_store().

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

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

Definition at line 333 of file jmemdos.c.

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

Referenced by open_xms_store(), and write_xms_store().

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

select_file_name char *    fname
 

Definition at line 128 of file jmemdos.c.

References getenv(), next_file_num, and READ_BINARY.

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

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

Definition at line 516 of file jmemdos.c.

References EMScontext::ax, EMScontext::ds_si, DST_HANDLE, DST_OFFSET, DST_PAGE, DST_TYPE, EMSPAGESIZE, ERREXIT, far, HIBYTE, EMSspec::length, SRC_HANDLE, SRC_PTR, and SRC_TYPE.

Referenced by open_ems_store().

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

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

Definition at line 259 of file jmemdos.c.

References ERREXIT, JERR_TFILE_WRITE, and L.

Referenced by open_file_store().

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

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

Definition at line 366 of file jmemdos.c.

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

Referenced by open_xms_store().

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

Variable Documentation

int next_file_num [static]
 

Definition at line 125 of file jmemdos.c.

Referenced by jpeg_mem_init(), and select_file_name().

XMSDRIVER xms_driver [static]
 

Definition at line 314 of file jmemdos.c.

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

You forgot to define USE_MSDOS_MEMMGR in jconfig h MAX_ALLOC_CHUNK should be less than K typedef void far* XMSDRIVER
 

Definition at line 97 of file jmemdos.c.

Referenced by open_xms_store().

 

Powered by Plone

This site conforms to the following standards: