/* * Display the comment. This function just uses what's returned by * exifscan() -- it doesn't touch the file. */ static int printcom(const char *fname, struct exifprop *p, const unsigned char *btiff) { int rc = 0; /* No comment tag. */ if (!p) { fprintf(stderr, "%s: comment not available\n", fname); return (1); } if (vflag) printf("Supported Length%s%d\n", delim, p->count - 8); /* Comment tag unset. */ if (!*(btiff + p->value)) rc = 2; else { /* Comment tag not ASCII. */ if (memcmp(ASCCOM, btiff + p->value, 8)) { if (!vflag) exifwarn2("comment type not supported", (const char *)(btiff + p->value)); rc = 3; } if (vflag) printf("Type%s%s\n", delim, btiff + p->value); } /* Comment tag OK, but blank. */ if (!rc && (!p->str || !*(p->str))) rc = 2; /* Print comment in the normal, non-verbose case. */ if (!vflag) { printf("%s", rc ? "" : p->str); return (rc); } /* Print length and comment if it's supported. */ if (rc != 1 && rc != 3) { printf("Length%s%d\n", delim, rc ? 0 : (int)strlen(p->str)); printf("Comment%s%s\n", delim, rc ? "" : p->str); } return (rc); }
Epsilon_Exif_Info * epsilon_exif_info_get (Epsilon * e) { FILE *fp = NULL; char *mode = "rb"; Epsilon_Exif_Info *eei = NULL; if ((fp = fopen (epsilon_file_get (e), mode)) == NULL) { exifwarn2 (strerror (errno), epsilon_file_get (e)); } else { eei = epsilon_read_exif_data (fp, ED_CAM | ED_IMG, TRUE); fclose (fp); } return (eei); }
/* * Grab the specified timestamp and vary it, if necessary. * The provided buffer must be at least EXIFTIMELEN bytes. */ static int ettime(char *b, struct exifprop *p) { struct tm tv; const struct vary *badv; /* Slurp the timestamp into tv. */ if (!p || !p->str || etstrptm(p->str, &tv)) return (1); /* Apply any adjustments. (Bad adjustment = fatal.) */ badv = vary_apply(v, &tv); if (badv) { exifwarn2("cannot apply adjustment", badv->arg); usage(); } if (strftime(b, EXIFTIMELEN, EXIFTIMEFMT, &tv) != EXIFTIMELEN - 1) return (1); return (0); }
int main(int argc, char **argv) { register int ch; int eval; char *rmode, *wmode; FILE *fp; progname = argv[0]; eval = 0; debug = FALSE; bflag = nflag = vflag = FALSE; iflag = TRUE; com = NULL; #ifdef WIN32 rmode = "rb"; wmode = "r+b"; #else rmode = "r"; wmode = "r+"; #endif while ((ch = getopt(argc, argv, "bfinvw:s:")) != -1) switch (ch) { case 'b': bflag = TRUE; break; case 'f': iflag = FALSE; break; case 'i': iflag = TRUE; break; case 'n': iflag = nflag = TRUE; break; case 'v': vflag = TRUE; break; case 'w': com = optarg; break; case 's': delim = optarg; break; case '?': default: usage(); } argc -= optind; argv += optind; if (!*argv) usage(); for (fnum = 0; *argv; ++argv) { /* Only open for read/write if we need to. */ if ((fp = fopen(*argv, bflag || com ? wmode : rmode)) == NULL) { exifwarn2(strerror(errno), *argv); eval = 1; continue; } fnum++; if (argc > 1) { /* Print filenames if more than one. */ if (vflag && !(bflag || com)) printf("%s%s:\n", fnum == 1 ? "" : "\n", *argv); else if (!(bflag || com)) printf("%s%s", *argv, delim); /* Don't error >1 with multiple files. */ eval = (doit(fp, *argv) == 1 || eval); } else eval = doit(fp, *argv); if (!vflag && !(bflag || com)) printf("\n"); fclose(fp); } return (eval); }
int main(int argc, char **argv) { register int ch; int eval, fnum, wantall; char *rmode, *wmode; FILE *fp; progname = argv[0]; debug = FALSE; ttags = wantall = eval = 0; lflag = qflag = wflag = FALSE; iflag = TRUE; v = NULL; #ifdef WIN32 rmode = "rb"; wmode = "r+b"; #else rmode = "r"; wmode = "r+"; #endif while ((ch = getopt(argc, argv, "filqs:t:v:w")) != -1) switch (ch) { case 'f': iflag = FALSE; break; case 'i': iflag = TRUE; break; case 'l': lflag = TRUE; break; case 'q': qflag = TRUE; break; case 's': delim = optarg; break; case 't': while (*optarg) { switch (*optarg) { case 'c': ttags |= ET_CREATE; break; case 'd': ttags |= ET_DIGI; break; case 'g': ttags |= ET_GEN; break; case 'a': wantall = 1; break; default: usage(); } optarg++; } if (wantall) ttags = 0; break; case 'v': v = vary_append(v, optarg); break; case 'w': wflag = TRUE; break; case '?': default: usage(); } argc -= optind; argv += optind; if (!*argv) usage(); /* Don't be quiet if we're not writing. */ if (qflag && !wflag) qflag = FALSE; /* Prepare an array for sorting. */ if (lflag) { wflag = 0; lorder = (struct linfo *)calloc(argc, sizeof(struct linfo)); if (!lorder) exifdie((const char *)strerror(errno)); } /* Run through the files... */ for (fnum = 0; *argv; ++argv, fnum++) { fname = *argv; /* Only open for read+write if we need to. */ if ((fp = fopen(*argv, wflag ? wmode : rmode)) == NULL) { exifwarn2(strerror(errno), *argv); eval = 1; continue; } /* Print filenames if more than one. */ if (argc > 1 && !lflag && !qflag) printf("%s%s:\n", fnum == 0 ? "" : "\n", *argv); if (lflag) lorder[fnum].fn = fname; if (doit(fp, fnum)) eval = 1; fclose(fp); } /* * We'd like to use mergesort() here (instead of qsort()) because * qsort() isn't stable w/members that compare equal and we exepect * the list of files to frequently already be in order. However, * FreeBSD seems to be the only platform with mergesort(), and I'm * not inclined to include the function... */ if (lflag) { qsort(lorder, argc, sizeof(struct linfo), lcomp); for (fnum = 0; fnum < argc; fnum++) printf("%s\n", lorder[fnum].fn); free(lorder); /* XXX Over in usage()? */ } vary_destroy(v); return (eval); }