djiparsetxt
Functions
DJITxtParser.cpp File Reference
#include "DJITxtParser.hh"
#include <stdio.h>
Include dependency graph for DJITxtParser.cpp:

Go to the source code of this file.

Functions

u_int8_t getByte (u_int8_t const *&ptr, u_int8_t const *limit)
 
u_int16_t get2BytesBE (u_int8_t const *&ptr, u_int8_t const *limit)
 
u_int16_t get2BytesLE (u_int8_t const *&ptr, u_int8_t const *limit)
 
unsigned getWord32BE (u_int8_t const *&ptr, u_int8_t const *limit)
 
unsigned getWord32LE (u_int8_t const *&ptr, u_int8_t const *limit)
 
u_int64_t getWord64LE (u_int8_t const *&ptr, u_int8_t const *limit)
 
void printString (char const *label, u_int8_t const *&ptr, unsigned stringLength, u_int8_t const *limit)
 
void printHex (char const *label, u_int8_t const *&ptr, u_int8_t const *limit)
 

Function Documentation

◆ get2BytesBE()

u_int16_t get2BytesBE ( u_int8_t const *&  ptr,
u_int8_t const *  limit 
)

Definition at line 34 of file DJITxtParser.cpp.

34  {
35  if (limit != NULL && ptr+2 > limit) throw END_OF_DATA;
36  u_int8_t byte1 = *ptr++;
37  u_int8_t byte2 = *ptr++;
38  return (byte1<<8)|byte2;
39 }
#define END_OF_DATA
Definition: DJITxtParser.hh:47

References END_OF_DATA.

Referenced by RecordAndDetailsParser::parseRecord(), and RecordAndDetailsParser::parseRecord_JPEG().

Here is the caller graph for this function:

◆ get2BytesLE()

u_int16_t get2BytesLE ( u_int8_t const *&  ptr,
u_int8_t const *  limit 
)

Definition at line 41 of file DJITxtParser.cpp.

41  {
42  if (limit != NULL && ptr+2 > limit) throw END_OF_DATA;
43  u_int8_t byte1 = *ptr++;
44  u_int8_t byte2 = *ptr++;
45  return (byte2<<8)|byte1;
46 }
#define END_OF_DATA
Definition: DJITxtParser.hh:47

References END_OF_DATA.

Referenced by main(), RecordAndDetailsParser::note2ByteDateField(), RecordAndDetailsParser::note2ByteField(), and RecordAndDetailsParser::parseRecord_COMPONENT().

Here is the caller graph for this function:

◆ getByte()

u_int8_t getByte ( u_int8_t const *&  ptr,
u_int8_t const *  limit 
)

◆ getWord32BE()

unsigned getWord32BE ( u_int8_t const *&  ptr,
u_int8_t const *  limit 
)

Definition at line 48 of file DJITxtParser.cpp.

48  {
49  if (limit != NULL && ptr+4 > limit) throw END_OF_DATA;
50  unsigned result = (ptr[0]<<24)|(ptr[1]<<16)|(ptr[2]<<8)|ptr[3];
51  ptr += 4;
52  return result;
53 }
#define END_OF_DATA
Definition: DJITxtParser.hh:47

References END_OF_DATA.

◆ getWord32LE()

unsigned getWord32LE ( u_int8_t const *&  ptr,
u_int8_t const *  limit 
)

Definition at line 55 of file DJITxtParser.cpp.

55  {
56  if (limit != NULL && ptr+4 > limit) throw END_OF_DATA;
57  unsigned result = (ptr[3]<<24)|(ptr[2]<<16)|(ptr[1]<<8)|ptr[0];
58  ptr += 4;
59  return result;
60 }
#define END_OF_DATA
Definition: DJITxtParser.hh:47

References END_OF_DATA.

Referenced by getWord64LE(), RecordAndDetailsParser::note4ByteField(), and RecordAndDetailsParser::note4ByteFloatField().

Here is the caller graph for this function:

◆ getWord64LE()

u_int64_t getWord64LE ( u_int8_t const *&  ptr,
u_int8_t const *  limit 
)

Definition at line 62 of file DJITxtParser.cpp.

62  {
63  u_int64_t resultLow = getWord32LE(ptr, limit);
64  u_int64_t resultHigh = getWord32LE(ptr, limit);
65  return (resultHigh<<32)|resultLow;
66 }
unsigned getWord32LE(u_int8_t const *&ptr, u_int8_t const *limit)

References getWord32LE().

Referenced by main(), RecordAndDetailsParser::note8ByteDoubleField(), RecordAndDetailsParser::note8ByteLatitudeOrLongitudeFieldInDegrees(), RecordAndDetailsParser::note8ByteLatitudeOrLongitudeFieldInRadians(), and RecordAndDetailsParser::note8ByteTimestampField().

Here is the caller graph for this function:

◆ printHex()

void printHex ( char const *  label,
u_int8_t const *&  ptr,
u_int8_t const *  limit 
)

Definition at line 83 of file DJITxtParser.cpp.

83  {
84  if (limit == NULL) return;
85  if (label != NULL) fprintf(stderr, "%s: ", label);
86  for (u_int8_t const* p = ptr; p < limit; ++p) fprintf(stderr, ":%02x", *p);
87  fprintf(stderr, "\n");
88 }

Referenced by RecordAndDetailsParser::parseRecordUnknownFormat().

Here is the caller graph for this function:

◆ printString()

void printString ( char const *  label,
u_int8_t const *&  ptr,
unsigned  stringLength,
u_int8_t const *  limit 
)

Definition at line 68 of file DJITxtParser.cpp.

68  {
69  if (limit != NULL && ptr+stringLength > limit) throw END_OF_DATA;
70 
71  char str[stringLength+1];
72  unsigned i;
73  for (i = 0; i < stringLength; ++i) str[i] = *ptr++;
74  str[i] = '\0';
75 
76  if (label == NULL) {
77  fprintf(stderr, "%s\n", str);
78  } else {
79  fprintf(stderr, "%s: %s\n", label, str);
80  }
81 }
#define END_OF_DATA
Definition: DJITxtParser.hh:47

References END_OF_DATA.