FloatImg4PythonBinding/tools/fimgmetadata.c

70 lines
1.4 KiB
C
Raw Normal View History

2022-04-09 23:18:14 +02:00
/*
* FIMG METADATA TOOL
*/
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include "../floatimg.h"
int verbosity;
/* --------------------------------------------------------------------- */
int get_print_metadata(char *fname, char *command)
{
int foo;
FimgMetaData metadata;
// #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' %s )\n", __func__, fname, command);
// #endif
foo = fimg_get_metadata_from_file(fname, &metadata);
if (foo) return foo;
/* switch on command here, please */
fimg_show_metadata(&metadata, fname, 0);
return 0;
}
/* --------------------------------------------------------------------- */
void help(void)
{
fprintf(stderr, "*** fimgmetadata (%s, %s)\n", __DATE__, __TIME__);
fimg_print_version(1);
exit(0);
}
/* --------------------------------------------------------------------- */
int main(int argc, char *argv[])
{
int foo, opt, nbargs;
char *fname;
while ((opt = getopt(argc, argv, "hv")) != -1) {
switch(opt) {
case 'h': help(); break;
case 'v': verbosity++; break;
}
}
nbargs = argc - optind;
// fprintf(stderr, "nbargs = %d\n", nbargs);
if (2 != nbargs) {
fprintf(stderr, "%s need two args: command & filename\n", argv[0]);
exit(1);
}
foo = get_print_metadata(argv[optind], argv[optind+1]);
if (foo) fprintf(stderr, "got a %d from job\n", foo);
return 0;
}
/* --------------------------------------------------------------------- */