nerd Här ser du hela källkoden till C++ programmet exif. Det är nog lättare att se om du laddar hem det och tittar i en texteditor.

/*
, Ingemar Ceicer <programmering '@'/>.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.

*/

/* Syntax 1: exif filnamn
   Syntax 2: exif filnman --good
   Print 1: YYYY:MM:DD HH:MM:SS
   Print 2: YYYY-MM-DD_HH-MM-SS
*/

#include <fstream>
using namespace std;

void visa_help(char *c);
void format_good(char *c);
void finn(char *hela, char *hittat);
bool s(char c);
bool sa(char c);
bool sb(char c);

int main(int argc, char *argv[])
{
bool formatera=false;

  /* Kontrollera anropet. */
  if( argc < 1 || argc > 3 )
    {
        visa_help(argv[0]);
        return 1;


    }
    else
    {

      if ( ( argc == 3) && (strcmp(argv[2],"--good") != 0 ) )
      {
          visa_help(argv[0]);
          return 1;
      }

      if ( ( argc == 3) && (strcmp(argv[2],"--good") == 0 ) )
      {
          formatera=true;
      }

    }

  char in;
  char hela[1024]={};
  char hittat[19]={};
  ifstream lasfil;


  /* Öppna filen. */
  char *filnamn=argv[1];
  lasfil.open(filnamn,ios::binary);
  if (! lasfil.good() )
    {
      fprintf(stderr, "Fel vid öppning av filen '%s'.\n", filnamn);
      return 1;
    }

   for ( int i=0;i<1024;i++ )
	{
		lasfil.read((char*) &in,1);
		hela[i] = in;
	}

finn(hela,hittat);
if (strcmp(hittat,"") == 0)
{
	 fprintf(stderr, "Ingen EXIF data hittades\n");
	 return 0;
}

		if (formatera)
			format_good(hittat);

		printf(hittat);

  return 0;
}
void finn(char *h, char *hittat)
{
	for (int i=0; i<1025; i++)
	{
		if ( s(h[i]) && s(h[i+1]) && s(h[i+2]) && s(h[i+3]) &&
                    s(h[i+5]) && sa(h[i+4])
                    && s(h[i+5]) && s(h[i+6]) && sa(h[i+7])
                    && s(h[i+8]) && s(h[i+9]) && sb(h[i+10])
                  && s(h[i+11]) && s(h[i+12]) && sa(h[i+13]
                  && s(h[i+14]) && s(h[i+15]) && sa(h[i+16])
                  && s(h[i+17]) && s(h[i+18]) )
		{
			for (int k=0; k<20; k++,i++)
				hittat[k]=h[i];
			return;
		}
	}
}

bool s(char c)
{
	if (c >= '0' && c <= '9')
		return true;
	return false;
}
bool sa(char c)
{
	if (c == ':')
		return true;
	return false;
}
bool sb(char c)
{
	if (c == ' ')
		return true;
	return false;
}
void visa_help(char *c)
{
        fprintf(stderr, "\nAnvändning: %s <filnamn>\n",c);
        fprintf(stderr, "Utskriftsformat: YYYY:MM:DD HH:MM:SS\n");
        fprintf(stderr, "Användning: %s <filnamn> --good\n",c);
        fprintf(stderr, "Utskriftsformat: YYYY-MM-DD_HH-MM-SS\n");
}
void format_good(char *c)
{
	c[4]='-';
	c[7]='-';
	c[10]='_';
	c[13]='-';
	c[16]='-';
}