2019-07-04 03:51:42 +11:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "../floatimg.h"
|
|
|
|
|
|
|
|
int verbosity;
|
2019-07-16 09:19:59 +11:00
|
|
|
|
|
|
|
int g_width, g_height;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int testfile(char *path)
|
|
|
|
{
|
|
|
|
int foo, numbers[3];
|
|
|
|
|
|
|
|
foo = fimg_fileinfos(path, numbers);
|
|
|
|
if (foo) {
|
|
|
|
#if DEBUG_LEVEL
|
|
|
|
fprintf(stderr, "%s -> err %d\n", path, foo);
|
|
|
|
#endif
|
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stderr, "\t\t%d x %d\n",numbers[0], numbers[1]);
|
|
|
|
|
|
|
|
if (3 != numbers[2]) {
|
|
|
|
fprintf(stderr, "file %s, %d : bad type\n", path, numbers[2]);
|
|
|
|
return -7;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return foo;
|
|
|
|
}
|
2019-07-04 03:51:42 +11:00
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
void help(int v)
|
|
|
|
{
|
|
|
|
puts("options :");
|
|
|
|
puts("\t-v\tincrease verbosity");
|
|
|
|
puts("\t-o\tname of output file");
|
2019-07-16 09:19:59 +11:00
|
|
|
puts("\t-s\tname of source file");
|
2019-07-04 03:51:42 +11:00
|
|
|
|
|
|
|
if (verbosity) { puts(""); fimg_print_version(1); }
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2019-07-16 09:19:59 +11:00
|
|
|
int foo, idx;
|
2019-07-04 03:51:42 +11:00
|
|
|
int opt;
|
|
|
|
char *output_file = "noname.fimg";
|
2019-07-16 09:19:59 +11:00
|
|
|
char *source_file = "noname.fimg";
|
|
|
|
|
2019-07-04 03:51:42 +11:00
|
|
|
|
2019-07-16 09:19:59 +11:00
|
|
|
g_width = g_height = 0;
|
|
|
|
|
|
|
|
while ((opt = getopt(argc, argv, "ho:s:v")) != -1) {
|
2019-07-04 03:51:42 +11:00
|
|
|
switch(opt) {
|
|
|
|
case 'h': help(0); break;
|
|
|
|
case 'o': output_file = optarg; break;
|
2019-07-16 09:19:59 +11:00
|
|
|
case 's': source_file = optarg; break;
|
2019-07-04 03:51:42 +11:00
|
|
|
case 'v': verbosity++; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-16 09:19:59 +11:00
|
|
|
#if DEBUG_LEVEL
|
|
|
|
fprintf(stderr, "argc = %d, optind = %d\n", argc, optind);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
foo = testfile(source_file);
|
|
|
|
fprintf(stderr, "Source %s -> %d\n", source_file, foo);
|
|
|
|
|
|
|
|
foo = testfile(output_file);
|
|
|
|
fprintf(stderr, "Output %s -> %d\n", output_file, foo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (idx=optind; idx<argc; idx++) {
|
|
|
|
|
|
|
|
fprintf(stderr, "%5d %s\n", idx, argv[idx]);
|
|
|
|
|
|
|
|
foo = testfile(argv[idx]);
|
|
|
|
fprintf(stderr, "testfile %s -> %d\n", argv[idx],foo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-07-04 03:51:42 +11:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|