--- aspect.cpp.orig	2008-03-06 19:12:10.000000000 +0200
+++ aspect.cpp	2008-03-28 15:48:03.000000000 +0200
@@ -21,6 +21,8 @@
 #include <iostream>
 #include <stdlib.h>
 #include <math.h>
+
+#include "gdal.h"
 #include "gdal_priv.h"
 
 int main(int nArgc, char ** papszArgv) 
@@ -193,6 +195,9 @@
 
          poAspectBand->RasterIO( GF_Write, 0, i, nXSize, 1, 
                       aspectBuf, nXSize, 1, GDT_Float32, 0, 0 ); 
+
+         GDALTermProgress( (i+1) / (double) nYSize ,NULL , NULL);
+
     }
 
     delete poAspectDS;
--- color-relief.cpp.orig	2008-03-06 19:12:10.000000000 +0200
+++ color-relief.cpp	2008-03-28 15:46:50.000000000 +0200
@@ -24,11 +24,11 @@
 //=============================================================================
 
 #include <iostream>
-#include <stdlib.h>
-#include <fstream>
-#include <list>
+
+#include "gdal.h"
 #include "gdal_priv.h"
-#include "stringtok.h"
+#include "cpl_string.h"
+#include "cpl_csv.h"
 
 using namespace std;
 
@@ -48,38 +48,39 @@
 vector<SColorPoint*> ColorPointList;
 
 //=============================================================================
-void ReadColorScale(const string& ScaleFileName)
+void ReadColorScale(const char *ScaleFileName)
 {
-  ifstream ScaleFile;
-  string Buffer;
-  list<string> StringList;
-  SColorPoint* TempColorPoint;
-
-  ScaleFile.open(ScaleFileName.c_str(), ios::in);
-
-  if (!ScaleFile.is_open())
-  {
-    cout << "Error opening color scale file : " << ScaleFileName << endl;
-    exit (1);
-  }
+    FILE        *fp;
+    const char  *pszLine;
+    const char  *pszFilename = CSVFilename( ScaleFileName );
+    SColorPoint* TempColorPoint;
+
+/* -------------------------------------------------------------------- */
+/*      Get access to the table.                                        */
+/* -------------------------------------------------------------------- */
+    fp = VSIFOpen( pszFilename, "rt" );
+    if( fp == NULL )
+    {
+        CPLError( CE_Failure, CPLE_OpenFailed, 
+                  "Failed to load scale file: %s", 
+                  pszFilename, VSIStrerror(errno) );
+        return;
+    }
 
-  while (!ScaleFile.eof())
+    while( TRUE )
   {
-    StringList.clear();
-    getline(ScaleFile, Buffer);
+    /* read each lines. */
+    pszLine = CPLReadLine( fp );
 
-    // Strip spaces in case we have a blank line
-    while (Buffer[0] == ' ')
-    {
-      Buffer.erase(0);
+    /* EOF */
+    if (pszLine == 0) {
+         break;
     }
-
-    // If not a blank line
-    if (Buffer != "")
+    /*  if not blank line */
+    if (pszLine != 0)
     {
       TempColorPoint = new SColorPoint;
-      stringtok(StringList, Buffer, " ");
-      list<string>::iterator i = StringList.begin();
+      char **i = CSLTokenizeString2(pszLine, " ", FALSE);
       TempColorPoint->Elevation = atoi(string(*i).c_str());
       i++;
       TempColorPoint->Color.Red = atoi(string(*i).c_str());
@@ -91,8 +92,8 @@
       ColorPointList.push_back(TempColorPoint);
     }
   }
+  VSIFClose( fp );
 
-  ScaleFile.close();
 }
 
 //=============================================================================
@@ -201,7 +202,7 @@
   }
 
   const char* InFilename = argv[1];
-  const string ScaleFilename = argv[2];
+  const char* ScaleFilename = argv[2];
   const char* OutFilename = argv[3];
 
   // Open and read color scale file
@@ -227,7 +228,9 @@
   RowGreen  = (float *) CPLMalloc(sizeof(float)*nXSize);
   RowBlue   = (float *) CPLMalloc(sizeof(float)*nXSize);
 
-  // Create the output dataset and copy over relevant metadata
+/* -------------------------------------------------------------------- */
+/*       Create the output dataset and copy over relevant metadata      */
+/* -------------------------------------------------------------------- */
   GDALDriver *poDriver;
   poDriver = GetGDALDriverManager()->GetDriverByName(Format);
   GDALDataset      *poDS;
@@ -247,7 +250,9 @@
   poBandBlue = poDS->GetRasterBand(3);
   poBandBlue->SetNoDataValue(-1);
 
-  // Run through each pixel in an image
+/* -------------------------------------------------------------------- */
+/*      Processing data one line at a time.                             */
+/* -------------------------------------------------------------------- */
   for (i = 0; i < nYSize; i++)
   {
     for (j = 0; j < nXSize; j++)
@@ -264,6 +269,9 @@
     poBandRed->RasterIO(GF_Write, 0, i, nXSize, 1, RowRed, nXSize, 1, GDT_Float32, 0, 0);
     poBandGreen->RasterIO(GF_Write, 0, i, nXSize, 1, RowGreen, nXSize, 1, GDT_Float32, 0, 0);
     poBandBlue->RasterIO(GF_Write, 0, i, nXSize, 1, RowBlue, nXSize, 1, GDT_Float32, 0, 0);
+
+    GDALTermProgress( (i+1) / (double) nYSize ,NULL , NULL);
+
   }
 
   delete poDS;
--- slope.cpp.orig	2008-03-06 19:12:10.000000000 +0200
+++ slope.cpp	2008-03-28 15:41:32.000000000 +0200
@@ -27,7 +27,9 @@
 #include <iostream>
 #include <stdlib.h>
 #include <math.h>
+
 #include "gdal_priv.h"
+#include "gdal.h"
 
 int main(int nArgc, char ** papszArgv) 
 { 
@@ -55,7 +57,7 @@
     int slopeFormat = 1; 
     // vertical units per horizontal unit (for slope calc)
     float scale = 1.0; 
-    char *pszFormat = "GTiff";
+    const char *pszFormat = "GTiff";
 
     /* -----------------------------------
      * Parse Input Arguments
@@ -201,6 +203,9 @@
 
          poSlopeBand->RasterIO( GF_Write, 0, i, nXSize, 1, 
                       slopeBuf, nXSize, 1, GDT_Float32, 0, 0 ); 
+
+         GDALTermProgress( (i+1) / (double) nYSize ,NULL , NULL);
+
     }
 
     delete poSlopeDS;
--- hillshade.cpp.orig	2008-03-06 19:12:10.000000000 +0200
+++ hillshade.cpp	2008-03-28 15:44:51.000000000 +0200
@@ -21,6 +21,8 @@
 #include <iostream>
 #include <stdlib.h>
 #include <math.h>
+
+#include "gdal.h"
 #include "gdal_priv.h"
 
 int main(int nArgc, char ** papszArgv)
@@ -202,6 +204,8 @@
         poShadeBand->RasterIO( GF_Write, 0, i, nXSize, 1,
                                shadeBuf, nXSize, 1, GDT_Float32, 0, 0 );
 
+        GDALTermProgress( (i+1) / (double) nYSize ,NULL , NULL);
+
     }
 
     delete poShadeDS;

