Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
73506bb7c0 | |||
1134241346 | |||
17a6f83cf6 | |||
60ba196e8b | |||
2a3da1a533 | |||
0ee5425dfa | |||
298e1d13be | |||
0caca3fdf5 | |||
8fd9643875 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -45,3 +45,4 @@ mdbutool
|
|||||||
INSTALL
|
INSTALL
|
||||||
maildirmond
|
maildirmond
|
||||||
exifdate
|
exifdate
|
||||||
|
*.kdev4
|
||||||
|
62
include/exijpeg.h
Normal file
62
include/exijpeg.h
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
90
include/jpegsegments.h
Normal file
90
include/jpegsegments.h
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
@ -4,12 +4,13 @@ AM_CPPFLAGS = \
|
|||||||
-DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
|
-DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
|
||||||
-DPACKAGE_SRC_DIR=\""$(srcdir)"\" \
|
-DPACKAGE_SRC_DIR=\""$(srcdir)"\" \
|
||||||
-DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \
|
-DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \
|
||||||
-DCNFPATH=\""$(prefix)/etc"\"
|
-DCNFPATH=\""$(prefix)/etc"\" \
|
||||||
|
-I $(srcdir)
|
||||||
|
|
||||||
AM_CFLAGS = -Wall -g
|
AM_CFLAGS = -Wall -g
|
||||||
|
|
||||||
bin_PROGRAMS = exifdate
|
bin_PROGRAMS = exifdate
|
||||||
|
|
||||||
exifdate_SOURCES = exifdate.c
|
exifdate_SOURCES = dtex.c jpeg.c exifdate.c
|
||||||
|
|
||||||
exifdate_LDADD = $(LIBS) $(LIBEXIF_LIBS)
|
exifdate_LDADD = $(LIBS) $(LIBEXIF_LIBS)
|
||||||
|
81
src/dtex.c
Normal file
81
src/dtex.c
Normal file
@ -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,15 +30,18 @@
|
|||||||
|
|
||||||
#include <libexif/exif-data.h>
|
#include <libexif/exif-data.h>
|
||||||
|
|
||||||
#include "../config.h"
|
#include <include/exijpeg.h>
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
#ifndef TOOL_FULLNAME
|
#ifndef TOOL_FULLNAME
|
||||||
#define TOOL_FULLNAME "Jpeg EXIF data date tool"
|
#define TOOL_FULLNAME "Jpeg EXIF data date tool"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
EDT_MODIFY = 0,
|
EDT_MODIFY_FO = 0,
|
||||||
EDT_DISPLAY = 1,
|
EDT_DISPLAY = 1,
|
||||||
|
EDT_MODIFY_ED = 2,
|
||||||
} edt_mode_t;
|
} edt_mode_t;
|
||||||
|
|
||||||
static void display_help(FILE *o, const char *exec_name)
|
static void display_help(FILE *o, const char *exec_name)
|
||||||
@ -52,68 +55,20 @@ static void display_help(FILE *o, const char *exec_name)
|
|||||||
fprintf(o, "\nOptions:\n");
|
fprintf(o, "\nOptions:\n");
|
||||||
fprintf(o, "\t%-36s Display date and time from exif data only, don't update file creation date.\n",
|
fprintf(o, "\t%-36s Display date and time from exif data only, don't update file creation date.\n",
|
||||||
"-d | --display-date");
|
"-d | --display-date");
|
||||||
|
fprintf(o, "\t%-36s Fix/create EXIF creation date based on the file creation date.\n",
|
||||||
|
"-e | --exif-date-fix");
|
||||||
fprintf(o, "\t%-36s Display help.\n", "-h | --help");
|
fprintf(o, "\t%-36s Display help.\n", "-h | --help");
|
||||||
fprintf(o, "\t%-36s Display version information.\n\n", "-v | --version");
|
fprintf(o, "\t%-36s Display version information.\n\n", "-v | --version");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static time_t exifdt_tm(const char *dtbuf)
|
extern time_t exifdt_tm(const char *);
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int opt, fargs = 0, i = 0;
|
int opt, fargs = 0, i = 0;
|
||||||
edt_mode_t mode = EDT_MODIFY;
|
edt_mode_t mode = EDT_MODIFY_FO;
|
||||||
char **fn_name = NULL;
|
char **fn_name = NULL;
|
||||||
ExifData *ef;
|
ExifData *ef;
|
||||||
ExifEntry *entry;
|
ExifEntry *entry;
|
||||||
@ -126,18 +81,22 @@ int main(int argc, char **argv)
|
|||||||
static struct option long_options[] =
|
static struct option long_options[] =
|
||||||
{
|
{
|
||||||
{"display-date", no_argument, NULL, 'd'},
|
{"display-date", no_argument, NULL, 'd'},
|
||||||
|
{"exif-date-fix", no_argument, NULL, 'e'},
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"version", no_argument, NULL, 'v'},
|
{"version", no_argument, NULL, 'v'},
|
||||||
{NULL, 0, NULL, 0},
|
{NULL, 0, NULL, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
if((opt = getopt_long(argc, argv, "dhv", long_options, &option_index)) == -1)
|
if((opt = getopt_long(argc, argv, "dehv", long_options, &option_index)) == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
case 'd':
|
case 'd':
|
||||||
mode = EDT_DISPLAY;
|
mode = EDT_DISPLAY;
|
||||||
break;
|
break;
|
||||||
|
case 'e':
|
||||||
|
mode = EDT_MODIFY_ED;
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
display_help(stdout, argv[0]);
|
display_help(stdout, argv[0]);
|
||||||
return 0;
|
return 0;
|
||||||
@ -189,7 +148,7 @@ int main(int argc, char **argv)
|
|||||||
case EDT_DISPLAY:
|
case EDT_DISPLAY:
|
||||||
fprintf(stdout, "%s date and time: %s\n",fn_name[i], dtbuf);
|
fprintf(stdout, "%s date and time: %s\n",fn_name[i], dtbuf);
|
||||||
break;
|
break;
|
||||||
case EDT_MODIFY:
|
case EDT_MODIFY_FO:
|
||||||
/* convert exif format to timeval */
|
/* convert exif format to timeval */
|
||||||
exif_dt = exifdt_tm(dtbuf);
|
exif_dt = exifdt_tm(dtbuf);
|
||||||
if(exif_dt == (time_t) -1)
|
if(exif_dt == (time_t) -1)
|
||||||
@ -200,9 +159,23 @@ int main(int argc, char **argv)
|
|||||||
utime(fn_name[i], &ntimes);
|
utime(fn_name[i], &ntimes);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case EDT_MODIFY_ED:
|
||||||
|
fprintf(stdout, "modify\n");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else fprintf(stdout, "%s: No date and time information exists in exif.\n",
|
} else fprintf(stdout, "%s: No date and time information exists in exif.\n",
|
||||||
fn_name[i]);
|
fn_name[i]);
|
||||||
|
} else {
|
||||||
|
switch(mode) {
|
||||||
|
case EDT_DISPLAY:
|
||||||
|
case EDT_MODIFY_FO:
|
||||||
|
fprintf(stdout, "%s: No time date information found in EXIF.\n",
|
||||||
|
fn_name[i]);
|
||||||
|
break;
|
||||||
|
case EDT_MODIFY_ED:
|
||||||
|
fprintf(stdout, "modify\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exif_data_unref(ef);
|
exif_data_unref(ef);
|
||||||
}
|
}
|
||||||
|
94
src/jpeg.c
Normal file
94
src/jpeg.c
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* 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…
x
Reference in New Issue
Block a user