Compare commits
No commits in common. 'main' and 'v0.0.1' have entirely different histories.
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* 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/>.";
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __EXIJPEG_H__
|
||||
#define __EXIJPEG_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <libexif/exif-data.h>
|
||||
|
||||
struct exijpeg_segment {
|
||||
unsigned char *hd;
|
||||
unsigned long length;
|
||||
struct exijpeg_segment *next;
|
||||
};
|
||||
|
||||
typedef struct __exijpeg_data_type {
|
||||
unsigned char *data;
|
||||
char *filename;
|
||||
size_t length;
|
||||
int fd;
|
||||
struct exijpeg_segment *segments;
|
||||
struct exijpeg_segment *last;
|
||||
} exijpeg_data_t;
|
||||
|
||||
exijpeg_data_t *exijpeg_data_alloc(void);
|
||||
|
||||
void exijpeg_data_free(exijpeg_data_t *);
|
||||
|
||||
/* adds a segment to jpeg_data_t */
|
||||
int exijpeg_data_add_segment(exijpeg_data_t *, unsigned char *, unsigned long);
|
||||
|
||||
/* loads a file to jpeg structure */
|
||||
int exijpeg_data_loadfile(exijpeg_data_t *, const char *);
|
||||
|
||||
/* release any resources allocated from the system during open file proc */
|
||||
int exijpeg_data_release(exijpeg_data_t *);
|
||||
|
||||
#endif
|
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* 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/>.";
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __EXIJPEGSEGMENTS_H__
|
||||
#define __EXIJPEGSEGMENTS_H__
|
||||
|
||||
typedef enum {
|
||||
JPEG_MARKER_SOF0 = 0xc0,
|
||||
JPEG_MARKER_SOF1 = 0xc1,
|
||||
JPEG_MARKER_SOF2 = 0xc2,
|
||||
JPEG_MARKER_SOF3 = 0xc3,
|
||||
JPEG_MARKER_DHT = 0xc4,
|
||||
JPEG_MARKER_SOF5 = 0xc5,
|
||||
JPEG_MARKER_SOF6 = 0xc6,
|
||||
JPEG_MARKER_SOF7 = 0xc7,
|
||||
JPEG_MARKER_JPG = 0xc8,
|
||||
JPEG_MARKER_SOF9 = 0xc9,
|
||||
JPEG_MARKER_SOF10 = 0xca,
|
||||
JPEG_MARKER_SOF11 = 0xcb,
|
||||
JPEG_MARKER_DAC = 0xcc,
|
||||
JPEG_MARKER_SOF13 = 0xcd,
|
||||
JPEG_MARKER_SOF14 = 0xce,
|
||||
JPEG_MARKER_SOF15 = 0xcf,
|
||||
JPEG_MARKER_RST0 = 0xd0,
|
||||
JPEG_MARKER_RST1 = 0xd1,
|
||||
JPEG_MARKER_RST2 = 0xd2,
|
||||
JPEG_MARKER_RST3 = 0xd3,
|
||||
JPEG_MARKER_RST4 = 0xd4,
|
||||
JPEG_MARKER_RST5 = 0xd5,
|
||||
JPEG_MARKER_RST6 = 0xd6,
|
||||
JPEG_MARKER_RST7 = 0xd7,
|
||||
JPEG_MARKER_SOI = 0xd8,
|
||||
JPEG_MARKER_EOI = 0xd9,
|
||||
JPEG_MARKER_SOS = 0xda,
|
||||
JPEG_MARKER_DQT = 0xdb,
|
||||
JPEG_MARKER_DNL = 0xdc,
|
||||
JPEG_MARKER_DRI = 0xdd,
|
||||
JPEG_MARKER_DHP = 0xde,
|
||||
JPEG_MARKER_EXP = 0xdf,
|
||||
JPEG_MARKER_APP0 = 0xe0,
|
||||
JPEG_MARKER_APP1 = 0xe1,
|
||||
JPEG_MARKER_APP2 = 0xe2,
|
||||
JPEG_MARKER_APP3 = 0xe3,
|
||||
JPEG_MARKER_APP4 = 0xe4,
|
||||
JPEG_MARKER_APP5 = 0xe5,
|
||||
JPEG_MARKER_APP6 = 0xe6,
|
||||
JPEG_MARKER_APP7 = 0xe7,
|
||||
JPEG_MARKER_APP8 = 0xe8,
|
||||
JPEG_MARKER_APP9 = 0xe9,
|
||||
JPEG_MARKER_APP10 = 0xea,
|
||||
JPEG_MARKER_APP11 = 0xeb,
|
||||
JPEG_MARKER_APP12 = 0xec,
|
||||
JPEG_MARKER_APP13 = 0xed,
|
||||
JPEG_MARKER_APP14 = 0xee,
|
||||
JPEG_MARKER_APP15 = 0xef,
|
||||
JPEG_MARKER_JPG0 = 0xf0,
|
||||
JPEG_MARKER_JPG1 = 0xf1,
|
||||
JPEG_MARKER_JPG2 = 0xf2,
|
||||
JPEG_MARKER_JPG3 = 0xf3,
|
||||
JPEG_MARKER_JPG4 = 0xf4,
|
||||
JPEG_MARKER_JPG5 = 0xf5,
|
||||
JPEG_MARKER_JPG6 = 0xf6,
|
||||
JPEG_MARKER_JPG7 = 0xf7,
|
||||
JPEG_MARKER_JPG8 = 0xf8,
|
||||
JPEG_MARKER_JPG9 = 0xf9,
|
||||
JPEG_MARKER_JPG10 = 0xfa,
|
||||
JPEG_MARKER_JPG11 = 0xfb,
|
||||
JPEG_MARKER_JPG12 = 0xfc,
|
||||
JPEG_MARKER_JPG13 = 0xfd,
|
||||
JPEG_MARKER_COM = 0xfe
|
||||
} exijpeg_segment_t;
|
||||
|
||||
#endif
|
@ -1,81 +0,0 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
/*
|
||||
* 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 <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <libexif/exif-data.h>
|
||||
|
||||
#include <include/exijpeg.h>
|
||||
#include <include/jpegsegments.h>
|
||||
|
||||
#if 0
|
||||
struct exijpeg_segment {
|
||||
unsigned char *hd;
|
||||
unsigned long length;
|
||||
struct exijpeg_segment *next;
|
||||
};
|
||||
|
||||
typedef struct __exijpeg_data_type {
|
||||
unsigned char *data;
|
||||
char *filename;
|
||||
size_t length;
|
||||
int fd;
|
||||
struct exijpeg_segment *segments;
|
||||
struct exijpeg_segment *last;
|
||||
} exijpeg_data_t;
|
||||
#endif
|
||||
|
||||
exijpeg_data_t *exijpeg_data_alloc(void)
|
||||
{
|
||||
exijpeg_data_t *r = malloc(sizeof(exijpeg_data_t));
|
||||
|
||||
if(r) memset(r, 0, sizeof(exijpeg_data_t));
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
void exijpeg_data_free(exijpeg_data_t *s)
|
||||
{
|
||||
struct exijpeg_segment *c = NULL;
|
||||
if(!s) return;
|
||||
|
||||
if(s->filename) free(s->filename);
|
||||
if(s->segments) {
|
||||
for(c = s->segments; c != NULL; c = c->next) free(c);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int exijpeg_data_add_segment(exijpeg_data_t *s, unsigned char *d, unsigned long l)
|
||||
{
|
||||
struct exijpeg_segment *n = NULL;
|
||||
|
||||
if(!s || !d) return -1;
|
||||
if(!(n = malloc(sizeof(struct exijpeg_segment)))) return -1;
|
||||
else {
|
||||
n->hd = d;
|
||||
n->length = l;
|
||||
n->next = NULL;
|
||||
}
|
||||
if(!(s->segments)) {
|
||||
s->segments = n;
|
||||
s->last = n;
|
||||
} else {
|
||||
s->last->next = n;
|
||||
s->last = n;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue