[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:43:14 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=bbb2d9b
The following commit has been merged in the master branch:
commit bbb2d9b4072abdc9fa0b929c69a004b44047c495
Author: Robin Mills <robin at clanmills.com>
Date: Thu Aug 2 10:17:34 2012 +0000
Work in progress. Many changes to geotag.cpp. Not ready for testing.
---
samples/geotag.cpp | 589 +++++++++++++++++++++++++++++++++--------------------
1 file changed, 373 insertions(+), 216 deletions(-)
diff --git a/samples/geotag.cpp b/samples/geotag.cpp
index dc6f7ff..0df4ae9 100644
--- a/samples/geotag.cpp
+++ b/samples/geotag.cpp
@@ -18,152 +18,152 @@
#include <vector>
#include <string>
-
-//using namespace Exiv2;
using namespace std;
-typedef std::vector<std::string> strings_t ;
-
#ifndef lengthof
#define lengthof(x) (sizeof(*x)/sizeof(x))
#endif
+#ifndef nil
+#define nil NULL
+#endif
+#ifndef _MAX_PATH
+#define _MAX_PATH 1024
+#endif
-#ifdef _MSC_VER
+#ifdef _MSC_VER
#include <windows.h>
-#if _MSC_VER < 1400
+bool realpath(const char* file,char* path,int path_l=_MAX_PATH);
+bool realpath(const char* file,char* path,int path_l)
+{
+ GetFullPathName(file,path_l,path,NULL);
+ return true;
+}
+
+#if _MSC_VER < 1400
#define strcpy_s(d,l,s) strcpy(d,s)
#define strcat_s(d,l,s) strcat(d,s)
#endif
#else
#include <dirent.h>
+#include <unistd.h>
+#include <sys/param.h>
#endif
+// prototypes
+int getFileType(const char* path );
+int getFileType(std::string& path);
+
+string getExifTime(const time_t t);
+time_t parseTime(const char* ,bool bAdjust=true);
+int timeZoneAdjust();
+
+// Command-line parser
+class Options {
+public:
+ bool verbose;
+
+ Options()
+ {
+ verbose = false;
+ }
+
+ virtual ~Options() {} ;
+} ;
+
enum
-{ typeUnknown = 0
-, typeDirectory = 1
-, typeImage = 2
-, typeXML = 3
-, typeFile = 4
-, typeMax = 5
+{ resultOK=0
+, resultSyntaxError
+, resultSelectFailed
};
enum // keyword indices
{ kwHELP = 0
-, kwARGS
, kwVERSION
-, kwNOCR
-, kwUNSPACE
-, kwCLOSE
-, kwOPEN
-, kwEND1
-, kwEND2
-, kwSLEEP
-, kwT1
-, kwT2
-, kwSPEED
-, kwSEND
-, kwOUTPUT
+, kwVERBOSE
+, kwADJUST
, kwMAX // manages keyword array
, kwNEEDVALUE // bogus keywords for error reporting
, kwSYNTAX // -- ditto --
-, kwNOVALUE = -kwCLOSE // keywords <= kwNOVALUE are flags (no value needed)
+, kwNOVALUE = -kwVERBOSE // keywords <= kwNOVALUE are flags (no value needed)
};
+// file types supported
enum
-{ resultOK=0
-, resultSyntaxError
-, resultSelectFailed
-, resultOpenFailed
-, resultTimeout
+{ typeUnknown = 0
+, typeDirectory = 1
+, typeImage = 2
+, typeXML = 3
+, typeFile = 4
+, typeDoc = 5
+, typeCode = 6
+, typeMax = 7
};
-time_t parseTime(const char* arg)
-{
- time_t result = 0 ;
- try {
- //559 rmills at rmills-imac:~/bin $ exiv2 -pa ~/R.jpg | grep -i date
- //Exif.Image.DateTime Ascii 20 2009:08:03 08:58:57
- //Exif.Photo.DateTimeOriginal Ascii 20 2009:08:03 08:58:57
- //Exif.Photo.DateTimeDigitized Ascii 20 2009:08:03 08:58:57
- //Exif.GPSInfo.GPSDateStamp Ascii 21 2009-08-03T15:58:57Z
-
- // <time>2012-07-14T17:33:16Z</time>
-
- if ( strstr(arg,":") || strstr(arg,"-") ) {
- int YY,MM,DD,HH,mm,SS ;
- char a,b,c,d,e ;
- sscanf(arg,"%d%c%d%c%d%c%d%c%d%c%d",&YY,&a,&MM,&b,&DD,&c,&HH,&d,&mm,&e,&SS);
-
- struct tm T;
- #if 0
- int tm_sec; /* seconds (0 - 60) */
- int tm_min; /* minutes (0 - 59) */
- int tm_hour; /* hours (0 - 23) */
- int tm_mday; /* day of month (1 - 31) */
- int tm_mon; /* month of year (0 - 11) */
- int tm_year; /* year - 1900 */
- int tm_wday; /* day of week (Sunday = 0) */
- int tm_yday; /* day of year (0 - 365) */
- int tm_isdst; /* is summer time in effect? */
- char *tm_zone; /* abbreviation of timezone name */
- long tm_gmtoff; /* offset from UTC in seconds */
- #endif
- memset(&T,sizeof(T),0);
- T.tm_min = mm ;
- T.tm_hour = HH ;
- T.tm_sec = SS ;
- T.tm_year = YY -1900 ;
- T.tm_mon = MM -1 ;
- T.tm_mday = DD ;
- result = mktime(&T);
- }
- } catch ( ... ) {};
- return result ;
-}
-
-// West of GMT is negative (PDT = Pacific Daylight = -07:00 == -25200 seconds
-int timeZoneAdjust()
+// Position (from gpx file)
+class Position
{
- time_t now = time(NULL);
-#if defined(__CYGWIN__)
- struct tm loc ; memcpy(&loc ,localtime(&now),sizeof(loc ));
- time_t gmt = timegm(&loc);
- int offset = (int) ( ((long signed int) gmt) - ((long signed int) now) ) ;
-#elif defined(_MSC_VER)
- TIME_ZONE_INFORMATION TimeZoneInfo;
- GetTimeZoneInformation( &TimeZoneInfo );
- int offset = - ((int)TimeZoneInfo.Bias + (int)TimeZoneInfo.DaylightBias) * 60;
-#else
- struct tm local ; memcpy(&local,localtime(&now),sizeof(local));
- int offset = local.tm_gmtoff ;
-#endif
-// struct tm utc ; memcpy(&utc ,gmtime (&now),sizeof(utc ));
-// printf("local: offset = %6ld dst = %d time = %s", offset,local.tm_isdst, asctime(&local));
-// printf("utc : offset = %6ld dst = %d time = %s", 0 ,utc .tm_isdst, asctime(&utc ));
-
-// printf("timeZoneAdjust = %d
",offset);
- return offset ;
-}
-
+public:
+ Position(time_t time,double lat,double lon,double ele) : time_(time),lon_(lon),lat_(lat),ele_(ele) {};
+ Position() { time_=0 ; lat_=0.0 ; lon_=0.0 ; ele_=0.0 ; };
+ virtual ~Position() {} ;
+// copy constructor
+ Position(const Position& o) : time_(o.time_),lon_(o.lon_),lat_(o.lat_),ele_(o.ele_) {};
+
+// methods
+ bool good() { return time_ || lon_ || lat_ || ele_ ; }
+ std::string getTimeString() { if ( times_.empty() ) times_ = getExifTime(time_) ; return times_; }
+ time_t getTime() { return time_ ; }
+
+// data
+private:
+ time_t time_;
+ double lon_ ;
+ double lat_ ;
+ double ele_ ;
+ std::string times_;
+// public static data
+public:
+ static int adjust_;
+ static time_t timeDiffMax;
+} ;
+
+// globals
+typedef std::map<time_t,Position> TimeDict_t;
+typedef std::map<time_t,Position>::iterator TimeDict_i;
+typedef std::vector<std::string> strings_t;
+TimeDict_t gTimeDict ;
+strings_t gFiles;
+
+int Position::adjust_ = timeZoneAdjust();
+time_t Position::timeDiffMax = 120 ;
+
+///////////////////////////////////////////////////////////
+// UserData - used by XML Parser
class UserData
{
public:
- UserData() : indent(0),count(0),nTrkpt(0),bTime(false),bEle(false) {};
+ UserData() : indent(0),count(0),nTrkpt(0),bTime(false),bEle(false) {};
virtual ~UserData() {} ;
// public data members
int indent;
size_t count ;
+ Position now ;
+ Position prev;
int nTrkpt;
bool bTime ;
bool bEle ;
double ele;
double lat;
double lon;
- time_t t;
+ std::string xmlt;
+ std::string exift;
+ time_t time;
+// static public data memembers
};
+// XML Parser Callbacks
static void startElement(void* userData, const char* name, const char** atts )
{
UserData* me = (UserData*) userData;
@@ -192,10 +192,22 @@ static void endElement(void* userData, const char* name)
me->indent-- ;
if ( strcmp(name,"trkpt")==0 ) {
me->nTrkpt--;
- printf("lat,lon = %f,%f ele = %f time = %ld %s",me->lat,me->lon,me->ele,(long int)me->t,"
"); // asctime(localtime(&me->t)) ) ;
+ me->now = Position(me->time,me->lat,me->lon,me->ele) ;
+
+ // printf("lat,lon = %f,%f ele = %f xml = %s exif = %s
",me->lat,me->lon,me->ele,me->xmlt.c_str(),me->exift.c_str());
+
+ // if we have a good previous position
+ // add missed entries to timedict
+ if ( me->prev.good() && (me->now.getTime() - me->prev.getTime()) < Position::timeDiffMax ) {
+ time_t missed = me->prev.getTime() ;
+ while ( ++missed < me->now.getTime() )
+ gTimeDict[missed] = me->prev ; // Position(missed,me->lat,me->lon,me->ele) ;
+ }
+
+ // remember our location and put it in gTimeDict
+ gTimeDict[me->time] = me->now ;
+ me->prev = me->now ;
}
- //for ( int i = 0 ; i < me->indent ; i++ ) printf(" ");
- //printf("end %s
",name);
}
void charHandler(void* userData,const char* s,int len)
@@ -212,7 +224,9 @@ void charHandler(void* userData,const char* s,int len)
buffer[len]=0;
char* b = buffer ;
while ( *b == ' ' && b < buffer+len ) b++ ;
- me->t = parseTime(b);
+ me->xmlt = b ;
+ me->time = parseTime(me->xmlt.c_str());
+ me->exift = getExifTime(me->time);
}
me->bTime=false;
}
@@ -229,9 +243,104 @@ void charHandler(void* userData,const char* s,int len)
}
}
-bool readDir(const char* path,size_t& count)
+///////////////////////////////////////////////////////////
+// Time Functions
+time_t parseTime(const char* arg,bool bAdjust)
+{
+ time_t result = 0 ;
+ try {
+ //559 rmills at rmills-imac:~/bin $ exiv2 -pa ~/R.jpg | grep -i date
+ //Exif.Image.DateTime Ascii 20 2009:08:03 08:58:57
+ //Exif.Photo.DateTimeOriginal Ascii 20 2009:08:03 08:58:57
+ //Exif.Photo.DateTimeDigitized Ascii 20 2009:08:03 08:58:57
+ //Exif.GPSInfo.GPSDateStamp Ascii 21 2009-08-03T15:58:57Z
+
+ // <time>2012-07-14T17:33:16Z</time>
+
+ if ( strstr(arg,":") || strstr(arg,"-") ) {
+ int YY,MM,DD,HH,mm,SS ;
+ char a,b,c,d,e ;
+ sscanf(arg,"%d%c%d%c%d%c%d%c%d%c%d",&YY,&a,&MM,&b,&DD,&c,&HH,&d,&mm,&e,&SS);
+
+ struct tm T;
+ #if 0
+ int tm_sec; /* seconds (0 - 60) */
+ int tm_min; /* minutes (0 - 59) */
+ int tm_hour; /* hours (0 - 23) */
+ int tm_mday; /* day of month (1 - 31) */
+ int tm_mon; /* month of year (0 - 11) */
+ int tm_year; /* year - 1900 */
+ int tm_wday; /* day of week (Sunday = 0) */
+ int tm_yday; /* day of year (0 - 365) */
+ int tm_isdst; /* is summer time in effect? */
+ char *tm_zone; /* abbreviation of timezone name */
+ long tm_gmtoff; /* offset from UTC in seconds */
+ #endif
+ memset(&T,sizeof(T),0);
+ T.tm_min = mm ;
+ T.tm_hour = HH ;
+ T.tm_sec = SS ;
+ if ( bAdjust ) T.tm_sec += Position::adjust_ ;
+ T.tm_year = YY -1900 ;
+ T.tm_mon = MM -1 ;
+ T.tm_mday = DD ;
+ result = mktime(&T);
+ }
+ } catch ( ... ) {};
+ return result ;
+}
+
+// West of GMT is negative (PDT = Pacific Daylight = -07:00 == -25200 seconds
+int timeZoneAdjust()
+{
+ time_t now = time(NULL);
+ struct tm local = *localtime(&now) ;
+
+#if defined(_MSC_VER)
+ TIME_ZONE_INFORMATION TimeZoneInfo;
+ GetTimeZoneInformation( &TimeZoneInfo );
+ int offset = - (((int)TimeZoneInfo.Bias + (int)TimeZoneInfo.DaylightBias) * 60);
+#elif defined(__CYGWIN__)
+ struct tm lcopy = *localtime(&now);
+ time_t gmt = timegm(&lcopy) ; // timegm modifies lcopy, so don't use local
+ int offset = (int) ( ((long signed int) gmt) - ((long signed int) now) ) ;
+#else
+ int offset = local.tm_gmtoff ;
+#endif
+
+#if 0
+ // debugging code
+ struct tm utc = *gmtime(&now);
+ printf("utc : offset = %6d dst = %d time = %s", 0 ,utc .tm_isdst, asctime(&utc ));
+ printf("local: offset = %6d dst = %d time = %s", offset,local.tm_isdst, asctime(&local));
+ printf("timeZoneAdjust = %6d
",offset);
+#endif
+ return offset ;
+}
+
+string getExifTime(const time_t t)
+{
+ static char result[100];
+ strftime(result,sizeof(result),"%Y-%m-%d %H:%M:%S",localtime(&t));
+ return result ;
+}
+
+std::string makePath(std::string dir,std::string file)
+{
+ return dir + std::string(EXV_SEPERATOR_STR) + file ;
+}
+
+const char* makePath(const char* dir,const char* file)
+{
+ static char result[_MAX_PATH] ;
+ std::string r = makePath(std::string(dir),std::string(file));
+ strcpy(result,r.c_str());
+ return result;
+}
+
+// file utilities
+bool readDir(const char* path)
{
- strings_t files;
bool bResult = false;
#ifdef _MSC_VER
@@ -258,8 +367,10 @@ bool readDir(const char* path,size_t& count)
}
else
{
- files.push_back( std::string(ffd.cFileName));
- printf("-> %s
",ffd.cFileName);
+ std::string pathName = makePath(path,std::string(ffd.cFileName));
+ if ( getFileType(pathName) == typeImage ) {
+ gFiles.push_back( pathName );
+ }
}
bGo = FindNextFile(hFind, &ffd) != 0;
}
@@ -277,16 +388,22 @@ bool readDir(const char* path,size_t& count)
while ((ent = readdir (dir)) != NULL)
{
printf ("%s
", ent->d_name);
- files.push_back(std::string(ent->d_name)) ;
+ gFiles.push_back( makePath(path,ent->d_name) ) ;
}
closedir (dir);
}
#endif
- count = files.size();
return bResult ;
}
-bool readXML(const char* path,size_t& count)
+inline size_t sip(FILE* f,char* buffer,size_t max_len,size_t len)
+{
+ while ( !feof(f) && len < max_len && buffer[len-1] != '>')
+ buffer[len++] = fgetc(f);
+ return len;
+}
+
+bool readXML(const char* path)
{
FILE* f = fopen(path,"r");
XML_Parser parser = XML_ParserCreate(NULL);
@@ -300,21 +417,22 @@ bool readXML(const char* path,size_t& count)
XML_SetCharacterDataHandler(parser,charHandler);
// a little sip at the data
- size_t len = fread(buffer,1,sizeof(buffer),f);
+ size_t len = fread(buffer,1,sizeof(buffer)-100,f);
const char* lead = "<?xml" ;
bResult = strncmp(lead,buffer,strlen(lead))==0;
// swallow it
if ( bResult ) {
+ len = sip(f,buffer,sizeof buffer,len);
bResult = XML_Parse(parser, buffer,(int)len, len == 0 ) == XML_STATUS_OK;
}
// drink the rest of the file
- while ( bResult && !feof(f) ) {
- len = fread(buffer,1,sizeof(buffer),f);
+ while ( bResult && len != 0 ) {
+ len = fread(buffer,1,sizeof(buffer)-100,f);
+ len = sip(f,buffer,sizeof buffer,len);
bResult = XML_Parse(parser, buffer,(int)len, len == 0 ) == XML_STATUS_OK;
};
- count = me.count ;
}
if ( f ) fclose(f);
@@ -323,24 +441,19 @@ bool readXML(const char* path,size_t& count)
return bResult ;
}
-bool readImage(const char* path,size_t& count)
+bool readImage(const char* path)
{
using namespace Exiv2;
bool bResult = false ;
- count = 0 ;
try {
Image::AutoPtr image = ImageFactory::open(path);
if ( image.get() ) {
image->readMetadata();
ExifData &exifData = image->exifData();
- if ( !exifData.empty() ) {
- bResult = true ;
- count = exifData.count();
- }
-
+ bResult = !exifData.empty();
}
- } catch (Exiv2::Error& ) {};
+ } catch ( ... ) {};
return bResult ;
}
@@ -365,133 +478,177 @@ time_t readImageTime(const char* path)
image->readMetadata();
ExifData &exifData = image->exifData();
// printf("%s => %s
",(ds-1), exifData[ds-1].toString().c_str());
- result = parseTime(exifData[ds-1].toString().c_str());
+ result = parseTime(exifData[ds-1].toString().c_str(),false);
}
} catch ( ... ) {};
}
return result ;
}
+bool sin(const char* s,const char** a)
+{
+ bool bResult = false ;
+ int i = 0 ;
+ while ( !bResult && a[i]) {
+ bResult = stricmp(s,a[i])==0;
+ i++;
+ }
+ return bResult;
+}
-
-bool readFile(const char* path,size_t& count)
+int readFile(const char* path)
{
- FILE* f = fopen(path,"r");
- bool bResult = f ? true : false;
- if ( bResult ) {
- fseek(f,0L,SEEK_END);
- count = ftell(f);
+ FILE* f = fopen(path,"r");
+ int nResult = f ? typeFile : typeUnknown;
+ if ( f ) {
+ const char* docs[] = { ".doc",".txt", nil };
+ const char* code[] = { ".cpp",".h" ,".pl" ,".py" ,".pyc", nil };
+ const char* ext = strstr(path,".");
+ if ( ext ) {
+ if ( sin(ext,docs) ) nResult = typeDoc;
+ if ( sin(ext,code) ) nResult = typeCode;
+ }
+ // fseek(f,0L,SEEK_END);
+ // count = ftell(f);
}
if ( f ) fclose(f) ;
- return bResult ;
+ return nResult ;
}
-int getFileType(const char* path,size_t& count)
+int getFileType(std::string& path) { return getFileType(path.c_str()); }
+int getFileType(const char* path)
{
- return readXML (path,count) ? typeXML
- : readDir (path,count) ? typeDirectory
- : readImage(path,count) ? typeImage
- : readFile (path,count) ? typeFile
- : typeUnknown
+ return readXML (path) ? typeXML
+ : readDir (path) ? typeDirectory
+ : readImage(path) ? typeImage
+ : readFile (path)
;
}
+
+int version(const char* program)
+{
+ printf("%s: %s %s
",program,__DATE__,__TIME__);
+ return 0;
+}
+
+int help(const char* program,char const* words[],int nWords)
+{
+ printf("usage: %s",program);
+ for ( int i = 0 ; i < nWords ; i++ ) {
+ if ( words[i] )
+ printf(" -%s%s",words[i],i>(-kwNOVALUE)?" value":"");
+ }
+ printf(" path+
");
+ return 0;
+}
+
+int compare(const char* a,const char* b)
+{
+ int result=*a && *b;
+ while ( result && *a && *b) {
+ char A=*a++;
+ char B=*b++;
+ result=tolower(A)==tolower(B);
+ }
+ return result;
+}
+
+int find(const char* arg,char const* words[],int nWords)
+{
+ int result=0;
+ int count =0;
+
+ for ( int i = 0 ; i < nWords ; i++) {
+ int j = 0 ;
+ while ( arg[j] == '-' ) j++;
+ if ( ::compare(arg+j,words[i]) ) {
+ result = i ;
+ count++;
+ }
+ }
+
+ return count==1?result:kwSYNTAX;
+}
+
+
int main(int argc, char* const argv[])
{
- if ( argc < 2 ) {
- std::cout << "Usage: " << argv[0] << " arg+
";
- return 1;
- }
+ int result=0;
+ const char* program = argv[0];
-#if 0
- char const* keywords[kwMAX];
- memset(keywords,0,sizeof(keywords));
- keywords[kwHELP] = "help";
- keywords[kwVERSION] = "version";
- keywords[kwARGS] = "args";
- keywords[kwNOCR] = "nocr";
- keywords[kwUNSPACE] = "unspace";
- keywords[kwCLOSE] = "close";
- keywords[kwOPEN] = "open";
- keywords[kwEND1] = "end1";
- keywords[kwEND2] = "end2";
- keywords[kwSLEEP] = "sleep";
- keywords[kwT1] = "t1";
- keywords[kwT2] = "t2";
- keywords[kwSPEED] = "speed";
- keywords[kwSEND] = "send";
- keywords[kwOUTPUT] = "output";
-
- if ( argc < 2 ) help(program,keywords,kwMAX) ;
+ const char* types[typeMax];
+ types[typeUnknown ] = "unknown";
+ types[typeDirectory] = "directory";
+ types[typeImage ] = "image";
+ types[typeXML ] = "xml";
+ types[typeDoc ] = "doc";
+ types[typeCode ] = "code";
+ types[typeFile ] = "file";
+
+ char const* keywords[kwMAX];
+ memset(keywords,0,sizeof(keywords));
+ keywords[kwHELP] = "help";
+ keywords[kwVERSION] = "version";
+ keywords[kwVERBOSE] = "verbose";
+ keywords[kwADJUST] = "adjust" ;
+
+ Options options ;
+
+ if ( argc < 2 ) {
+ ::help(program,keywords,kwMAX);
+ return result ;
+ }
for ( int a = 0 ; !result && a < 2 ; a++ ) { // a = 0 is a dry run
- options options ;
+ if ( a && options.verbose ) {
+ int tzadjust = Position::adjust_;
+ printf("tzadjust seconds = %d HH:MM = %c%02d:%02d [-/+ = West/East of UTC]
",tzadjust,tzadjust<0?'-':'+',abs(tzadjust/3600),tzadjust%3600);
+
+ for ( TimeDict_i it = gTimeDict.begin() ; it != gTimeDict.end() ; it++) {
+ // printf("time = %s
",it->second.getTimeString().c_str()); // ,gTimeDict[*it].sTime
+ }
+ for ( unsigned i = 0 ; i < gFiles.size() ; i++ ) {
+ printf("image[%s%d] = %s
",i>9?"":" ",i,gFiles[i].c_str());
+ }
+ }
+
for ( int i = 1 ; !result && i < argc ; i++ ) {
const char* arg = argv[i++];
const char* value = argv[i ];
- int ivalue = atoi(value?value:"0");
- int key = find(arg,keywords,kwMAX);
+ int ivalue = ::atoi(value?value:"0");
+ int key = ::find(arg,keywords,kwMAX);
int needv = key < kwMAX && key > (-kwNOVALUE);
if (!needv ) i--;
if ( needv && !value ) key = kwNEEDVALUE;
- if ( arg[0] != '-' ) key = kwSYNTAX;
switch ( key ) {
- case kwHELP : if ( a ) { /* help(program,keywords,kwMAX) ; */ } break;
- case kwARGS : if ( a ) { /* args(argv,argc) ; */ } break;
- case kwVERSION : if ( a ) { /* version(program) ; */ } break;
- case kwNOCR : if ( a ) { /* options.bNOCR=true ; */ } break;
- case kwUNSPACE : if ( a ) { /* options.bUnspace=true ; */ } break;
- case kwCLOSE : if ( a ) { /* modem_close(options) ; */ } break;
- case kwOPEN : if ( a ) { /* options.open = value ; }*/ break ;
- case kwEND1 : if ( a ) { /* options.end1=value ; */ } break;
- case kwEND2 : if ( a ) { /* options.end2=value ; */ } break;
- case kwSLEEP : if ( a ) { /* sleep(ivalue) ; }*/ break ;
- case kwT1 : if ( a ) { /* options.t1=ivalue ; }*/ break ;
- case kwT2 : if ( a ) { /* options.t2=ivalue ; */ } break;
- case kwSPEED : if ( a ) { /* options.speed=ivalue ; }*/ break ;
-/*
- case kwSEND : if ( a )
- {
- result=modem_send(value,options);
- if ( result == resultTimeout && options.t2 > 0 )
- result = modem_send(value,options,true);
- } break ;
- case kwOUTPUT : if ( a ) { printf("%s",value) ; ; } break ;
-*/
+ case kwHELP : if ( a ) { ::help(program,keywords,kwMAX) ; } break;
+ case kwVERSION : if ( a ) { ::version(program) ; } break;
+ case kwADJUST : if ( a ) { Position::adjust_=ivalue ; } break;
+ case kwVERBOSE : options.verbose = true ; break;
case kwNEEDVALUE: fprintf(stderr,"error: %s requires a value
",arg); result = resultSyntaxError ; break ;
- default : fprintf(stderr,"error: illegal syntax %s
",arg) ; result = resultSyntaxError ; break ;
+ default :
+ {
+ int type = getFileType(arg) ;
+ if ( !a && options.verbose ) printf("%s %s",arg,types[type]) ;
+ if ( type == typeImage ) {
+ time_t t = readImageTime(arg) ;
+ if ( t ) printf(" %ld %s",(long int)t,asctime(localtime(&t)));
+ char path[_MAX_PATH];
+ realpath(arg,path);
+ gFiles.push_back(path);
+ }
+
+ if ( type == typeUnknown ) {
+ fprintf(stderr,"error: illegal syntax %s
",arg) ; result = resultSyntaxError ; break ;
+ }
+ }
}
- if ( a ) fflush(stdout);
- // if ( options.fd < -1 ) result = resultOpenFailed ;
- }
- }
-#endif
-
- const char* types[typeMax];
- types[typeUnknown ] = "unknown";
- types[typeDirectory] = "directory";
- types[typeImage ] = "image";
- types[typeXML ] = "xml";
- types[typeFile ] = "file";
-
- int tzadjust = timeZoneAdjust();
- printf("tzadjust seconds = %d HH:MM = %c%02d:%02d [-/+ = West/East of UTC]
",tzadjust,tzadjust<0?'-':'+',abs(tzadjust/3600),tzadjust%3600);
-
- for ( int i = 1 ; i < argc ; i++ ) {
- char* arg = argv[i];
- size_t count = 0 ;
- time_t t = 0 ;
- int type = getFileType(arg,count) ;
- printf("%s %s %d",arg,types[type],(int)count) ;
- if ( type == typeImage ) {
- t = readImageTime(arg) ;
- if ( t ) printf(" %ld ",(long int)t);
}
- puts(t ? asctime(localtime(&t)) : "" );
}
- return 0;
+ return result ;
}
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list