splitting sources.

main
Alexander Vdolainen 1 year ago
parent 298e1d13be
commit 0ee5425dfa

@ -4,12 +4,13 @@ AM_CPPFLAGS = \
-DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
-DPACKAGE_SRC_DIR=\""$(srcdir)"\" \
-DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \
-DCNFPATH=\""$(prefix)/etc"\"
-DCNFPATH=\""$(prefix)/etc"\" \
-I $(srcdir)
AM_CFLAGS = -Wall -g
bin_PROGRAMS = exifdate
exifdate_SOURCES = exifdate.c
exifdate_SOURCES = dtex.c exifdate.c
exifdate_LDADD = $(LIBS) $(LIBEXIF_LIBS)

@ -0,0 +1,81 @@
/*
* EXIF date tool
*
* (c) Alexander Vdolainen 2023 <alex@vapaa.xyz>
*
* this 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 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.";
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <getopt.h>
#include <string.h>
#include <time.h>
#include <utime.h>
time_t exifdt_tm(const char *dtbuf)
{
struct tm tddt;
char buf[5], *b = (char *)dtbuf;
if(!dtbuf) return (time_t) -1;
if(strlen(dtbuf) < 18) return (time_t) -1;
memset(&tddt, 0, sizeof(struct tm));
/* year */
memset(buf, 0, 5);
strncpy(buf, dtbuf, 4);
tddt.tm_year = atoi(buf) - 1900;
/* month */
memset(buf, 0, 5);
b = strchr(b, ':');
if(!b) return (time_t) -1;
else b++;
strncpy(buf, b, 2);
tddt.tm_mon = atoi(buf) - 1;
/* day */
memset(buf, 0, 5);
b = strchr(b, ':');
if(!b) return (time_t) -1;
else b++;
strncpy(buf, b, 2);
tddt.tm_mday = atoi(buf);
/* hour */
memset(buf, 0, 5);
b = strchr(b, ' ');
if(!b) return (time_t) -1;
else b++;
strncpy(buf, b, 2);
tddt.tm_hour = atoi(buf);
/* minute */
memset(buf, 0, 5);
b = strchr(b, ':');
if(!b) return (time_t) -1;
else b++;
strncpy(buf, b, 2);
tddt.tm_min = atoi(buf);
/* second */
memset(buf, 0, 5);
b = strchr(b, ':');
if(!b) return (time_t) -1;
else b++;
strncpy(buf, b, 2);
tddt.tm_sec = atoi(buf);
return mktime(&tddt);
}

@ -30,7 +30,7 @@
#include <libexif/exif-data.h>
#include "../config.h"
#include <config.h>
#ifndef TOOL_FULLNAME
#define TOOL_FULLNAME "Jpeg EXIF data date tool"
@ -61,57 +61,7 @@ static void display_help(FILE *o, const char *exec_name)
return;
}
static time_t exifdt_tm(const char *dtbuf)
{
struct tm tddt;
char buf[5], *b = (char *)dtbuf;
if(!dtbuf) return (time_t) -1;
if(strlen(dtbuf) < 18) return (time_t) -1;
memset(&tddt, 0, sizeof(struct tm));
/* year */
memset(buf, 0, 5);
strncpy(buf, dtbuf, 4);
tddt.tm_year = atoi(buf) - 1900;
/* month */
memset(buf, 0, 5);
b = strchr(b, ':');
if(!b) return (time_t) -1;
else b++;
strncpy(buf, b, 2);
tddt.tm_mon = atoi(buf) - 1;
/* day */
memset(buf, 0, 5);
b = strchr(b, ':');
if(!b) return (time_t) -1;
else b++;
strncpy(buf, b, 2);
tddt.tm_mday = atoi(buf);
/* hour */
memset(buf, 0, 5);
b = strchr(b, ' ');
if(!b) return (time_t) -1;
else b++;
strncpy(buf, b, 2);
tddt.tm_hour = atoi(buf);
/* minute */
memset(buf, 0, 5);
b = strchr(b, ':');
if(!b) return (time_t) -1;
else b++;
strncpy(buf, b, 2);
tddt.tm_min = atoi(buf);
/* second */
memset(buf, 0, 5);
b = strchr(b, ':');
if(!b) return (time_t) -1;
else b++;
strncpy(buf, b, 2);
tddt.tm_sec = atoi(buf);
return mktime(&tddt);
}
extern time_t exifdt_tm(const char *);
int main(int argc, char **argv)
{

Loading…
Cancel
Save