1 #ifndef JHEAD_H 2 #define JHEAD_H 1 3 4 #include <limits.h> 5 #include <time.h> 6 #include <stdio.h> 7 8 //-------------------------------------------------------------------------- 9 // Include file for jhead program. 10 // 11 // This include file only defines stuff that goes across modules. 12 // I like to keep the definitions for macros and structures as close to 13 // where they get used as possible, so include files only get stuff that 14 // gets used in more than one file. 15 //-------------------------------------------------------------------------- 16 17 typedef unsigned char uchar; 18 19 #ifndef TRUE 20 #define TRUE 1 21 #define FALSE 0 22 #endif 23 24 #define MAX_COMMENT 2000 25 26 #ifdef _WIN32 27 #define PATH_MAX _MAX_PATH 28 #endif 29 30 //-------------------------------------------------------------------------- 31 // This structure is used to store jpeg file sections in memory. 32 typedef struct { 33 uchar * Data; 34 int Type; 35 unsigned Size; 36 }Section_t; 37 38 // Strings describing the various orientation settings. 39 extern char * OrientTab[]; 40 // Corresponding Integers. 41 extern int OrientRot[]; 42 43 //-------------------------------------------------------------------------- 44 // This structure stores Exif header image elements in a simple manner 45 // Used to store camera data as extracted from the various ways that it can be 46 // stored in an exif header 47 typedef struct { 48 char FileName [PATH_MAX+1]; 49 time_t FileDateTime; 50 unsigned FileSize; 51 char CameraMake [32]; 52 char CameraModel [40]; 53 char DateTime [20]; 54 int Height, Width; 55 int Orientation; 56 int IsColor; 57 int Process; 58 int FlashUsed; 59 float FocalLength; 60 float ExposureTime; 61 float ApertureFNumber; 62 float Distance; 63 float CCDWidth; 64 float ExposureBias; 65 int Whitebalance; 66 int MeteringMode; 67 int ExposureProgram; 68 int ISOequivalent; 69 int CompressionLevel; 70 char Comments[MAX_COMMENT]; 71 72 unsigned char * ThumbnailPointer; // Pointer at the thumbnail 73 unsigned ThumbnailSize; // Size of thumbnail. 74 75 char * DatePointer; 76 77 }ImageInfo_t; 78 79 80 #define EXIT_FAILURE 1 81 #define EXIT_SUCCESS 0 82 83 // jpgfile.c functions 84 typedef enum { 85 READ_EXIF = 1, 86 READ_IMAGE = 2, 87 READ_ALL = 3 88 }ReadMode_t; 89 90 91 // prototypes for jhead.c functions 92 extern void ErrFatal(char * msg); 93 extern void ErrNonfatal(char * msg, int a1, int a2); 94 95 // Prototypes for exif.c functions. 96 extern int Exif2tm(struct tm * timeptr, char * ExifTime); 97 extern void process_EXIF (unsigned char * CharBuf, unsigned int length); 98 extern int RemoveThumbnail(unsigned char * ExifSection, unsigned int Length); 99 100 // Prototypes for myglob.c module 101 extern void MyGlob(const char * Pattern , void (*FileFuncParm)(const char * FileName)); 102 103 // Prototypes from jpgfile.c 104 int ReadJpegSections (FILE * infile, ReadMode_t ReadMode); 105 void DiscardData(void); 106 void DiscardAllButExif(void); 107 int ReadJpegFile(const char * FileName, ReadMode_t ReadMode); 108 int TrimExifFunc(void); 109 int RemoveSectionType(int SectionType); 110 void WriteJpegFile(const char * FileName); 111 Section_t * FindSection(int SectionType); 112 Section_t * CreateSection(int SectionType, unsigned char * Data, int size); 113 void ResetJpgfile(void); 114 115 116 // Variables from jhead.c used by exif.c 117 extern ImageInfo_t ImageInfo; 118 extern int ShowTags; 119 #ifdef VERBOSE 120 extern void ShowImageInfo(void); 121 extern void ShowConciseImageInfo(void); 122 #endif 123 124 //-------------------------------------------------------------------------- 125 // JPEG markers consist of one or more 0xFF bytes, followed by a marker 126 // code byte (which is not an FF). Here are the marker codes of interest 127 // in this program. (See jdmarker.c for a more complete list.) 128 //-------------------------------------------------------------------------- 129 130 #define M_SOF0 0xC0 // Start Of Frame N 131 #define M_SOF1 0xC1 // N indicates which compression process 132 #define M_SOF2 0xC2 // Only SOF0-SOF2 are now in common use 133 #define M_SOF3 0xC3 134 #define M_SOF5 0xC5 // NB: codes C4 and CC are NOT SOF markers 135 #define M_SOF6 0xC6 136 #define M_SOF7 0xC7 137 #define M_SOF9 0xC9 138 #define M_SOF10 0xCA 139 #define M_SOF11 0xCB 140 #define M_SOF13 0xCD 141 #define M_SOF14 0xCE 142 #define M_SOF15 0xCF 143 #define M_SOI 0xD8 // Start Of Image (beginning of datastream) 144 #define M_EOI 0xD9 // End Of Image (end of datastream) 145 #define M_SOS 0xDA // Start Of Scan (begins compressed data) 146 #define M_JFIF 0xE0 // Jfif marker 147 #define M_EXIF 0xE1 // Exif marker 148 #define M_COM 0xFE // COMment 149 150 #endif /* JHEAD_H */ 151 152