error handling + cosmetic
This commit is contained in:
parent
5b2320b421
commit
7e09d1b490
|
@ -141,8 +141,7 @@ fprintf(stderr, "%s -> %s : %dx%d, rgb %d,%d,%d\n", __func__, fname, w, h,
|
||||||
r, g, b);
|
r, g, b);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (w < 1 || h < 1)
|
if (w < 1 || h < 1) {
|
||||||
{
|
|
||||||
fprintf(stderr, "%s : img dims %d %d ?\n", __func__, w, h);
|
fprintf(stderr, "%s : img dims %d %d ?\n", __func__, w, h);
|
||||||
return 666;
|
return 666;
|
||||||
}
|
}
|
||||||
|
@ -168,8 +167,7 @@ Image_Desc *src;
|
||||||
fprintf(stderr, "timestamping '%s' to '%s' with '%s'\n", fnin, fnout, txt);
|
fprintf(stderr, "timestamping '%s' to '%s' with '%s'\n", fnin, fnout, txt);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( (src=Image_TGA_alloc_load(fnin)) == NULL )
|
if ( (src=Image_TGA_alloc_load(fnin)) == NULL ) {
|
||||||
{
|
|
||||||
fprintf(stderr, "tga_tools, load of '%s' failed in %s\n",
|
fprintf(stderr, "tga_tools, load of '%s' failed in %s\n",
|
||||||
fnin, __func__);
|
fnin, __func__);
|
||||||
exit(5);
|
exit(5);
|
||||||
|
@ -207,15 +205,23 @@ if (must_be_verbose()) {
|
||||||
__func__, fnin, fnout, txt, flag);
|
__func__, fnin, fnout, txt, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (src=Image_TGA_alloc_load(fnin)) == NULL )
|
if ( (src=Image_TGA_alloc_load(fnin)) == NULL ) {
|
||||||
{
|
|
||||||
fprintf(stderr, "tga_tools, load of '%s' failed in %s\n",
|
fprintf(stderr, "tga_tools, load of '%s' failed in %s\n",
|
||||||
fnin, __func__);
|
fnin, __func__);
|
||||||
exit(5);
|
exit(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
foo = Image_txt1_box_0(src, txt, posx, posy, 4, &pap, &ink, 0);
|
foo = Image_txt1_box_0(src, txt, posx, posy, 4, &pap, &ink, 0);
|
||||||
Image_TGA_save(fnout, src, 0);
|
if (foo) {
|
||||||
|
fprintf(stderr, "err txt1_box_0 = %d\n", foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
foo = Image_TGA_save(fnout, src, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: err TGA save = %d\n", __func__, foo);
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, "%s : saving %s\n", __func__, fnout);
|
fprintf(stderr, "%s : saving %s\n", __func__, fnout);
|
||||||
|
@ -234,21 +240,18 @@ if (flags) {
|
||||||
fprintf(stderr, "in %s, flags must be 0\n", __func__);
|
fprintf(stderr, "in %s, flags must be 0\n", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (src=Image_TGA_alloc_load(filename)) == NULL )
|
if ( (src=Image_TGA_alloc_load(filename)) == NULL ) {
|
||||||
{
|
|
||||||
fprintf(stderr, "tga_tools, chargement '%s' failed\n", filename);
|
fprintf(stderr, "tga_tools, chargement '%s' failed\n", filename);
|
||||||
exit(5);
|
exit(5);
|
||||||
}
|
}
|
||||||
foo = Image_histo_RGB(src, hr, hb, hg);
|
foo = Image_histo_RGB(src, hr, hb, hg);
|
||||||
if (foo)
|
if (foo) {
|
||||||
{
|
|
||||||
fprintf(stderr, "tga_tools, calcul histogramme: %d %s\n",
|
fprintf(stderr, "tga_tools, calcul histogramme: %d %s\n",
|
||||||
foo, Image_err2str(foo));
|
foo, Image_err2str(foo));
|
||||||
exit(5);
|
exit(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (foo=0; foo<256; foo++)
|
for (foo=0; foo<256; foo++) {
|
||||||
{
|
|
||||||
printf("%3d %8ld %8ld %8ld\n", foo, hr[foo], hg[foo], hb[foo]);
|
printf("%3d %8ld %8ld %8ld\n", foo, hr[foo], hg[foo], hb[foo]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,15 +263,13 @@ int print_environ(void)
|
||||||
{
|
{
|
||||||
int foo;
|
int foo;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
char *noms[] =
|
char *noms[] = {
|
||||||
{
|
|
||||||
NOM_VAR_ENV_VERBOSE, NOM_VAR_ENV_TIMING, "LIBIMAGE_PATH",
|
NOM_VAR_ENV_VERBOSE, NOM_VAR_ENV_TIMING, "LIBIMAGE_PATH",
|
||||||
"TTH_CONF_DIR", "LIBIMAGE_DEBUG", "BITMAP_FONTS",
|
"TTH_CONF_DIR", "LIBIMAGE_DEBUG", "BITMAP_FONTS",
|
||||||
"FIXED_SEED", ENV_DEFAULT_RGBA
|
"FIXED_SEED", ENV_DEFAULT_RGBA
|
||||||
};
|
};
|
||||||
|
|
||||||
for (foo=0; foo<(int)(sizeof(noms)/sizeof(char *)); foo++)
|
for (foo=0; foo<(int)(sizeof(noms)/sizeof(char *)); foo++) {
|
||||||
{
|
|
||||||
ptr = getenv(noms[foo]);
|
ptr = getenv(noms[foo]);
|
||||||
printf("%5d %-25s %s\n", foo, noms[foo], ptr);
|
printf("%5d %-25s %s\n", foo, noms[foo], ptr);
|
||||||
}
|
}
|
||||||
|
@ -286,8 +287,7 @@ char buffer[100];
|
||||||
fprintf(stderr, "%s:%s %s %d\n", __FILE__, __func__, fname, value);
|
fprintf(stderr, "%s:%s %s %d\n", __FILE__, __func__, fname, value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( (src=Image_TGA_alloc_load(fname)) == NULL )
|
if ( (src=Image_TGA_alloc_load(fname)) == NULL ) {
|
||||||
{
|
|
||||||
fprintf(stderr, "tga_tools, load of '%s' failed in %s\n",
|
fprintf(stderr, "tga_tools, load of '%s' failed in %s\n",
|
||||||
fname, __func__);
|
fname, __func__);
|
||||||
exit(5);
|
exit(5);
|
||||||
|
@ -339,16 +339,14 @@ foo = set_new_seed(42);
|
||||||
fprintf(stderr, "!!! set new seed -> %d\n", foo);
|
fprintf(stderr, "!!! set new seed -> %d\n", foo);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (1 == argc)
|
if (1 == argc) {
|
||||||
{
|
|
||||||
fprintf(stderr, "* tga_tools v 0.1.33 (%s) *\n", __DATE__);
|
fprintf(stderr, "* tga_tools v 0.1.33 (%s) *\n", __DATE__);
|
||||||
fprintf(stderr, "usage:\n\t%s action f.tga [params]\n", argv[0]);
|
fprintf(stderr, "usage:\n\t%s action f.tga [params]\n", argv[0]);
|
||||||
liste_mots_clefs(commandes, 42);
|
liste_mots_clefs(commandes, 42);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-1 == (idx=cherche_mot_clef(argv[1], commandes, &mode, &nbarg)) )
|
if (-1 == (idx=cherche_mot_clef(argv[1], commandes, &mode, &nbarg)) ) {
|
||||||
{
|
|
||||||
fprintf(stderr, "action '%s' inconnue.\n", argv[1]);
|
fprintf(stderr, "action '%s' inconnue.\n", argv[1]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -452,7 +450,7 @@ switch(mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "*** at end of %s, foo was %d\n", __func__, foo);
|
/* fprintf(stderr, "*** at end of %s, foo was %d\n", __func__, foo); */
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue