Index: trunk/core/dng.c
===================================================================
--- trunk/core/dng.c	(revision 1556)
+++ trunk/core/dng.c	(revision 1558)
@@ -11,4 +11,5 @@
 #include "gui_mbox.h"
 #include "gui_lang.h"
+#include "gps.h"
 
 //thumbnail
@@ -19,4 +20,5 @@
 struct dir_entry{unsigned short tag; unsigned short type; unsigned int count; unsigned int offset;};
 
+#define T_END       0
 #define T_BYTE      1
 #define T_ASCII     2
@@ -96,5 +98,5 @@
  {0xC630, T_RATIONAL,   4,  (int)&camera_sensor.lens_info},
  {0xC65A, T_SHORT|T_PTR,1,  (int)&camera_sensor.calibration_illuminant1}, 
- {0}
+ {0, T_END}
 };
 
@@ -122,5 +124,5 @@
  {0xC620, T_LONG,       2,  (int)&camera_sensor.crop.size},
  {0xC68D, T_LONG,       4,  (int)&camera_sensor.dng_active_area},
- {0}
+ {0, T_END}
 };
 
@@ -150,25 +152,11 @@
  {0x920A, T_RATIONAL,   1,  (int)cam_focal_length},     // FocalLength
  {0xA405, T_SHORT|T_PTR,1,  (int)&exif_data.effective_focal_length},    // FocalLengthIn35mmFilm
- {0}
+ {0, T_END}
 };
 
-  
-typedef struct {
-    char    latitudeRef[4];
-    int     latitude[6];
-    char    longitudeRef[4];
-    int     longitude[6];
-    char    heightRef[4];
-    int     height[2];
-    int     timeStamp[6];
-    char    status[4];
-    char    mapDatum[8];
-    char    dateStamp[12];
-    char    unknown2[260];
-} tGPS;
 tGPS gps_data;
 
 struct dir_entry GPS_IFD[]={
-//{0x0000, T_BYTE,              4,  0x00000302},                    //GPSVersionID: 2 3 0 0
+  {0x0000, T_BYTE,              4,  0x00000302},                    //GPSVersionID: 2 3 0 0
   {0x0001, T_ASCII,             2,  (int)gps_data.latitudeRef},     //North or South Latitude "N\0" or "S\0"
   {0x0002, T_RATIONAL,          3,  (int)gps_data.latitude},        //Latitude
@@ -182,5 +170,5 @@
   {0x0012, T_ASCII,             7,  (int)gps_data.mapDatum},        //MapDatum 7 + 1 pad byte
   {0x001D, T_ASCII,             11, (int)gps_data.dateStamp},       //DateStamp 11 + 1 pad byte
-  {0}
+  {0, T_END}
 };
 
@@ -229,13 +217,10 @@
  // filling EXIF fields
 
- if (camera_info.props.gps)
-    get_property_case(camera_info.props.gps, &gps_data, sizeof(tGPS));
- else
-    memset(&gps_data, 0, sizeof(tGPS));
+ gps_getData(&gps_data); 
 
  for (j=0;j<IFDs;j++) {
-  for(i=0; IFD_LIST[j].entry[i].tag; i++) {
+  for(i=0; IFD_LIST[j].entry[i].type; i++) {
     switch (IFD_LIST[j].entry[i].tag) {
-	 // For camera name string make sure the 'count' in the IFD header is correct for the string
+     // For camera name string make sure the 'count' in the IFD header is correct for the string
      case 0x110 :                                                                                       // CameraName
      case 0xC614: IFD_LIST[j].entry[i].count = strlen((char*)IFD_LIST[j].entry[i].offset) + 1; break;   // UniqueCameraModel
@@ -256,5 +241,5 @@
   IFD_LIST[j].count=0;
   raw_offset+=6; // IFD header+footer
-  for(i=0; IFD_LIST[j].entry[i].tag; i++) {
+  for(i=0; IFD_LIST[j].entry[i].type; i++) {
    int size_ext;
    IFD_LIST[j].count++;
@@ -287,5 +272,5 @@
  for (j=0;j<IFDs;j++) {
   extra_offset+=6+IFD_LIST[j].count*12; // IFD header+footer
-  for(i=0; IFD_LIST[j].entry[i].tag; i++) {
+  for(i=0; IFD_LIST[j].entry[i].type; i++) {
    if (IFD_LIST[j].entry[i].tag==0x8769) IFD_LIST[j].entry[i].offset=TIFF_HDR_SIZE+(IFD_LIST[0].count+IFD_LIST[1].count)*12+6+6;  // EXIF IFD offset
    if (IFD_LIST[j].entry[i].tag==0x8825) IFD_LIST[j].entry[i].offset=TIFF_HDR_SIZE+(IFD_LIST[0].count+IFD_LIST[1].count+IFD_LIST[2].count)*12+6+6+6;  // GPS IFD offset
@@ -314,5 +299,5 @@
   var=IFD_LIST[j].count;
   add_to_buf(&var, sizeof(short));
-  for(i=0; IFD_LIST[j].entry[i].tag; i++) {
+  for(i=0; IFD_LIST[j].entry[i].type; i++) {
     add_to_buf(&IFD_LIST[j].entry[i].tag, sizeof(short));
     unsigned short t = IFD_LIST[j].entry[i].type & 0xFF;
@@ -347,5 +332,5 @@
   int size_ext;
   char zero=0;
-  for(i=0; IFD_LIST[j].entry[i].tag; i++) {
+  for(i=0; IFD_LIST[j].entry[i].type; i++) {
    size_ext=get_type_size(IFD_LIST[j].entry[i].type)*IFD_LIST[j].entry[i].count;
    if (size_ext>4){
Index: trunk/core/modules/Makefile
===================================================================
--- trunk/core/modules/Makefile	(revision 1556)
+++ trunk/core/modules/Makefile	(revision 1558)
@@ -18,5 +18,5 @@
 
 OBJS=../gui_calendar.o ../gui_bench.o ../gui_4wins.o ../gui_mastermind.o ../gui_reversi.o \
-	 ../gui_sokoban.o ../gui_read.o ../gui_debug.o  ../gui_tetris.o ../gui_snake.o ../dng.o
+	 ../gui_sokoban.o ../gui_read.o ../gui_debug.o  ../gui_tetris.o ../gui_snake.o ../dng.o ../gps.o
 
 
@@ -109,5 +109,5 @@
 	$(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS)
 
-_dng.elf: ../dng.o $(topdir)/lib/armutil/reversebytes.o
+_dng.elf: ../dng.o ../gps.o $(topdir)/lib/armutil/reversebytes.o
 	@echo \-\> $@
 	$(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS)
Index: trunk/core/gps.c
===================================================================
--- trunk/core/gps.c	(revision 1558)
+++ trunk/core/gps.c	(revision 1558)
@@ -0,0 +1,11 @@
+#include "camera.h"
+#include "stdlib.h"
+#include "platform.h"
+#include "gps.h"
+
+void gps_getData(tGPS* gps){
+    if (camera_info.props.gps)
+        get_property_case(camera_info.props.gps, gps, sizeof(tGPS));
+    else
+        memset(gps, 0, sizeof(tGPS));
+}
Index: trunk/core/gps.h
===================================================================
--- trunk/core/gps.h	(revision 1558)
+++ trunk/core/gps.h	(revision 1558)
@@ -0,0 +1,20 @@
+#ifndef __CHDK_GPS_H
+#define __CHDK_GPS_H
+
+typedef struct {
+    char    latitudeRef[4];
+    int     latitude[6];
+    char    longitudeRef[4];
+    int     longitude[6];
+    char    heightRef[4];
+    int     height[2];
+    int     timeStamp[6];
+    char    status[4];
+    char    mapDatum[7];
+    char    dateStamp[11];
+    char    unknown2[260];
+} tGPS;
+
+void gps_getData(tGPS* gps);
+
+#endif
