byte_manager.c File Reference
`#include <stdio.h>`
`#include <sys/types.h>`
`#include <unistd.h>`
`#include <stdlib.h>`
`#include <sys/stat.h>`
`#include "byte_manager.h"`

## Macros

#define | FCGI_stdout stdout
#define | FCGI_stderr stderr
#define | logstream stderr

## Functions

Byte_t * | fetch_bytes (int fd, OPJ_OFF_T offset, OPJ_SIZE_T size)
| fetch bytes of data in file stream
Byte_t | fetch_1byte (int fd, OPJ_OFF_T offset)
| fetch a 1-byte Byte codes in file stream
Byte2_t | fetch_2bytebigendian (int fd, OPJ_OFF_T offset)
| fetch a 2-byte big endian Byte codes in file stream
Byte4_t | fetch_4bytebigendian (int fd, OPJ_OFF_T offset)
| fetch a 4-byte big endian Byte codes in file stream
Byte8_t | fetch_8bytebigendian (int fd, OPJ_OFF_T offset)
| fetch a 8-byte big endian Byte codes in file stream
Byte2_t | big2 (Byte_t *buf)
| convert 2-byte big endian Byte codes to number
Byte4_t | big4 (Byte_t *buf)
| convert 4-byte big endian Byte codes to number
Byte8_t | big8 (Byte_t *buf)
| convert 8-byte big endian Byte codes to number
void | modify_4Bytecode (Byte4_t code, Byte_t *stream)
| modify 4Byte code in a codestream
OPJ_OFF_T | get_filesize (int fd)
| Get file size.

## Macro Definition Documentation

## FCGI_stderr

#define FCGI_stderr stderr

## FCGI_stdout

#define FCGI_stdout stdout

## logstream

#define logstream stderr

## Function Documentation

## big2()

Byte2_t big2 | ( | Byte_t * | buf | ) |

convert 2-byte big endian Byte codes to number

Parameters

  [in] | buf | Byte codes

Returns
  resolved number

Referenced by fetch_2bytebigendian(), gene_ihdrbox(), get_CODmkrdata_from_j2kstream(), get_mainheader_from_j2kstream(), get_SIZmkrdata_from_j2kstream(), and modify_COCmkrstream().

## big4()

Byte4_t big4 | ( | Byte_t * | buf | ) |

convert 4-byte big endian Byte codes to number

Parameters

  [in] | buf | Byte codes

Returns
  resolved number

Referenced by add_emptyboxstream(), big8(), fetch_4bytebigendian(), gene_boxbyOffinStream(), gene_boxbyOffset(), gene_boxbyType(), gene_boxbyTypeinStream(), gene_ihdrbox(), get_SIZmkrdata_from_j2kstream(), and parse_phld().

## big8()

Byte8_t big8 | ( | Byte_t * | buf | ) |

convert 8-byte big endian Byte codes to number

Parameters

  [in] | buf | Byte codes

Returns
  resolved number

References big4().

Referenced by add_emptyboxstream(), fetch_8bytebigendian(), gene_boxbyOffinStream(), gene_boxbyOffset(), gene_boxbyType(), gene_boxbyTypeinStream(), and parse_phld().

## fetch_1byte()

Byte_t fetch_1byte | ( | int | fd,
|  | OPJ_OFF_T | offset
| ) |  |

fetch a 1-byte Byte codes in file stream

Parameters

  [in] | fd | file descriptor
  [in] | offset | start Byte position

Returns
  fetched codes

References FCGI_stderr, and FCGI_stdout.

Referenced by fetch_codestream1byte(), and fetch_DBox1byte().

## fetch_2bytebigendian()

Byte2_t fetch_2bytebigendian | ( | int | fd,
|  | OPJ_OFF_T | offset
| ) |  |

fetch a 2-byte big endian Byte codes in file stream

Parameters

  [in] | fd | file descriptor
  [in] | offset | start Byte position

Returns
  fetched codes

References big2(), FCGI_stderr, and fetch_bytes().

Referenced by fetch_codestream2bytebigendian(), and fetch_DBox2bytebigendian().

## fetch_4bytebigendian()

Byte4_t fetch_4bytebigendian | ( | int | fd,
|  | OPJ_OFF_T | offset
| ) |  |

fetch a 4-byte big endian Byte codes in file stream

Parameters

  [in] | fd | file descriptor
  [in] | offset | start Byte position

Returns
  fetched codes

References big4(), FCGI_stderr, and fetch_bytes().

Referenced by fetch_codestream4bytebigendian(), fetch_DBox4bytebigendian(), and gene_boxheader().

## fetch_8bytebigendian()

Byte8_t fetch_8bytebigendian | ( | int | fd,
|  | OPJ_OFF_T | offset
| ) |  |

fetch a 8-byte big endian Byte codes in file stream

Parameters

  [in] | fd | file descriptor
  [in] | offset | start Byte position

Returns
  fetched codes

References big8(), FCGI_stderr, and fetch_bytes().

Referenced by fetch_DBox8bytebigendian(), and gene_boxheader().

## fetch_bytes()

Byte_t * fetch_bytes | ( | int | fd,
|  | OPJ_OFF_T | offset,
|  | OPJ_SIZE_T | size
| ) |  |

fetch bytes of data in file stream

Parameters

  [in] | fd | file descriptor
  [in] | offset | start Byte position
  [in] | size | Byte length

Returns
  pointer to the fetched data

References FCGI_stderr, and FCGI_stdout.

Referenced by add_body_stream(), fetch_2bytebigendian(), fetch_4bytebigendian(), fetch_8bytebigendian(), fetch_codestreambytes(), fetch_DBoxbytes(), fetch_headbytes(), gene_boxbyOffset(), gene_boxbyType(), and gene_boxheader().

## get_filesize()

OPJ_OFF_T get_filesize | ( | int | fd | ) |

Get file size.

Parameters

  [in] | fd | file descriptor

Returns
  file size

References FCGI_stderr, and FCGI_stdout.

Referenced by const_metadatalist(), fread_jpip(), gene_boxbyType(), and parse_jp2file().

## modify_4Bytecode()

void modify_4Bytecode | ( | Byte4_t | code,
|  | Byte_t * | stream
| ) |  |

modify 4Byte code in a codestream

Parameters

  [in] | code | code value
  [out] | stream | modifying codestream

Referenced by modify_SIZmkrstream(), and modify_tileheader().