Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
jmemname.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
#include "jmemsys.h"

Go to the source code of this file.

Defines

#define JPEG_INTERNALS
#define SEEK_SET   0 /* if not, assume 0 is correct */
#define READ_BINARY   "rb"
#define RW_BINARY   "w+b"
#define TEMP_DIRECTORY   "/usr/tmp/" /* recommended setting for Unix */
#define TEMP_FILE_NAME   "%sJPG%dXXXXXX"
#define DEFAULT_MAX_MEM   1000000L /* default: one megabyte */

Functions

 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_backing_store (j_common_ptr cinfo, backing_store_ptr info, void FAR *buffer_address, long file_offset, long byte_count)
 write_backing_store (j_common_ptr cinfo, backing_store_ptr info, void FAR *buffer_address, long file_offset, long byte_count)
 close_backing_store (j_common_ptr cinfo, backing_store_ptr info)
 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

static int next_file_num

Define Documentation

#define DEFAULT_MAX_MEM   1000000L /* default: one megabyte */

Definition at line 184 of file jmemname.c.

Definition at line 15 of file jmemname.c.

#define READ_BINARY   "rb"

Definition at line 37 of file jmemname.c.

#define RW_BINARY   "w+b"

Definition at line 38 of file jmemname.c.

#define SEEK_SET   0 /* if not, assume 0 is correct */

Definition at line 26 of file jmemname.c.

#define TEMP_DIRECTORY   "/usr/tmp/" /* recommended setting for Unix */

Definition at line 70 of file jmemname.c.

#define TEMP_FILE_NAME   "%sJPG%dXXXXXX"

Definition at line 122 of file jmemname.c.


Function Documentation

Definition at line 230 of file jmemname.c.

{
  fclose(info->temp_file);  /* close the file */
  unlink(info->temp_name);  /* delete the file */
/* If your system doesn't have unlink(), use remove() instead.
 * remove() is the ANSI-standard name for this function, but if
 * your system was ANSI you'd be using jmemansi.c, right?
 */
  TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name);
}

Here is the call graph for this function:

jpeg_free_large ( j_common_ptr  cinfo,
void FAR object,
size_t  sizeofobject 
)

Definition at line 169 of file jmemname.c.

{
  free(object);
}
jpeg_free_small ( j_common_ptr  cinfo,
void object,
size_t  sizeofobject 
)

Definition at line 149 of file jmemname.c.

{
  free(object);
}
jpeg_get_large ( j_common_ptr  cinfo,
size_t  sizeofobject 
)

Definition at line 163 of file jmemname.c.

{
  return (void FAR *) malloc(sizeofobject);
}
jpeg_get_small ( j_common_ptr  cinfo,
size_t  sizeofobject 
)

Definition at line 143 of file jmemname.c.

{
  return (void *) malloc(sizeofobject);
}
jpeg_mem_available ( j_common_ptr  cinfo,
long  min_bytes_needed,
long  max_bytes_needed,
long  already_allocated 
)

Definition at line 188 of file jmemname.c.

{
  return cinfo->mem->max_memory_to_use - already_allocated;
}

Definition at line 266 of file jmemname.c.

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

Definition at line 273 of file jmemname.c.

{
  /* no work */
}
jpeg_open_backing_store ( j_common_ptr  cinfo,
backing_store_ptr  info,
long  total_bytes_needed 
)

Definition at line 247 of file jmemname.c.

{
  select_file_name(info->temp_name);
  if ((info->temp_file = fopen(info->temp_name, RW_BINARY)) == NULL)
    ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name);
  info->read_backing_store = read_backing_store;
  info->write_backing_store = write_backing_store;
  info->close_backing_store = close_backing_store;
  TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name);
}

Here is the call graph for this function:

read_backing_store ( j_common_ptr  cinfo,
backing_store_ptr  info,
void FAR buffer_address,
long  file_offset,
long  byte_count 
)

Definition at line 204 of file jmemname.c.

{
  if (fseek(info->temp_file, file_offset, SEEK_SET))
    ERREXIT(cinfo, JERR_TFILE_SEEK);
  if (JFREAD(info->temp_file, buffer_address, byte_count)
      != (size_t) byte_count)
    ERREXIT(cinfo, JERR_TFILE_READ);
}

Here is the call graph for this function:

select_file_name ( char *  fname)

Definition at line 126 of file jmemname.c.

{
  next_file_num++;          /* advance counter */
  sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num);
  mktemp(fname);            /* make sure file name is unique */
  /* mktemp replaces the trailing XXXXXX with a unique string of characters */
}

Here is the call graph for this function:

write_backing_store ( j_common_ptr  cinfo,
backing_store_ptr  info,
void FAR buffer_address,
long  file_offset,
long  byte_count 
)

Definition at line 217 of file jmemname.c.

{
  if (fseek(info->temp_file, file_offset, SEEK_SET))
    ERREXIT(cinfo, JERR_TFILE_SEEK);
  if (JFWRITE(info->temp_file, buffer_address, byte_count)
      != (size_t) byte_count)
    ERREXIT(cinfo, JERR_TFILE_WRITE);
}

Here is the call graph for this function:


Variable Documentation

int next_file_num [static]

Definition at line 73 of file jmemname.c.