File: file_is.c

package info (click to toggle)
xcfa 5.0.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 6,292 kB
  • sloc: ansic: 47,148; sh: 4,380; makefile: 142; sed: 16
file content (676 lines) | stat: -rw-r--r-- 16,160 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
 /*
 * file      : lib/file_is.c
  *  project   : xcfa_cli
 *  copyright : (C) 2014 by BULIN Claude
 *
 *  This file is part of xcfa_cli project
 *
 *  xcfa_cli is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; version 3.
 *
 *  xcfa_cli 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
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 *  USA
 */


#ifdef HAVE_CONFIG_H
	#include "../config.h"
#endif

#ifdef ENABLE_NLS
	#include <libintl.h>
	#define _(String) gettext (String)
#endif

#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>

#include "file_is.h"
#include "global.h"




// FILE IS VIDM4A ?
//
C_BOOL FileIs_vidm4a( char *namefile )
{
	FILE        *fp = NULL;
	char       *buf = NULL;
	int         cpt;
	C_BOOL     bool_signature = FALSE;

	if( (buf = (char *)malloc (sizeof(char) * 2048)) == NULL ) return (FALSE);
	if( (fp = fopen (namefile, "rb")) != NULL ) {
		fread( buf, 1, 2000, fp );
		fclose (fp);
	}

	for (cpt = 0; cpt < 2000; cpt ++ ) {
		if( buf [ cpt +  0 ] == 0x6D &&		// m
		    buf [ cpt +  1 ] == 0x6F &&		// o
		    buf [ cpt +  2 ] == 0x6F &&		// o
		    buf [ cpt +  3 ] == 0x76 &&		// v
		    buf [ cpt +  4 ] == 0x00 &&		// \0
		    buf [ cpt +  5 ] == 0x00 &&		// \0
		    buf [ cpt +  6 ] == 0x00 &&		// \0
		    buf [ cpt +  7 ] == 0x6C &&		// l
		    buf [ cpt +  8 ] == 0x6D &&		// m
		    buf [ cpt +  9 ] == 0x76 &&		// v
		    buf [ cpt + 10 ] == 0x68 &&		// h
		    buf [ cpt + 11 ] == 0x64 ) {	// d

		    bool_signature = TRUE;
		    break;
		}
	}
	free( buf );
	buf = NULL;

	return( bool_signature );
}
// FILE IS M4A ?
//
C_BOOL FileIs_m4a( char *namefile )
{
	FILE	*fp = NULL;
	char	*buf = NULL;
	int		cpt;
	C_BOOL	bool_signature = FALSE;

	if( (buf = (char *)malloc (sizeof(char) * 2048)) == NULL ) return (FALSE);
	if( (fp = fopen (namefile, "rb")) != NULL ) {
		fread( buf, 1, 2000, fp );
		fclose (fp);
	}

	for (cpt = 0; cpt < 2000; cpt ++ ) {
		if( buf [ cpt + 0 ] == 'l' &&
		    buf [ cpt + 1 ] == 'i' &&
		    buf [ cpt + 2 ] == 'b' &&
		    buf [ cpt + 3 ] == 'f' &&
		    buf [ cpt + 4 ] == 'a' &&
		    buf [ cpt + 5 ] == 'a' &&
		    buf [ cpt + 6 ] == 'c' ){
		    bool_signature = TRUE;
		    break;
		}
	}
	free( buf );
	buf = NULL;

	return( bool_signature );
}
// FILE IS WAV ?
//
C_BOOL FileIs_wavpack (char *namefile)
{
	FILE      *fp = NULL;
	char      str [ 42 ] = {'\0','\0','\0','\0','\0','\0','\0','\0'};

	if ((fp = fopen (namefile, "rb")) != NULL) {
		fread (&str[0], 1, 40, fp);
		fclose (fp);
	}

	if (str [0]  == 'w' &&
	    str [1]  == 'v' &&
	    str [2]  == 'p' &&
	    str [3]  == 'k' &&

	    str [34] == 'R' &&
	    str [35] == 'I' &&
	    str [36] == 'F' &&
	    str [37] == 'F') return (TRUE);

	return (FALSE);
}
// FILE IS_CUE ?
//
C_BOOL	FileIs_cue( char *namefile )
{
	FILE	*fp = NULL;
	char	*buf = NULL;
	C_BOOL	bool_signature = FALSE;

	if( (buf = (char *)malloc (sizeof(char) * 2048)) == NULL ) return (FALSE);
	if( (fp = fopen (namefile, "rb")) != NULL ) {
		fread( buf, 1, 2000, fp );
		fclose (fp);
		if( strstr( buf, "PERFORMER" ) &&
			strstr( buf, "TITLE" ) &&
			strstr( buf, "FILE" ) &&
			strstr( buf, "TRACK" ) &&
			strstr( buf, "INDEX" ) )
			bool_signature = TRUE;
	}
	free( buf );
	buf = NULL;

	return( bool_signature );
}
// FILE IS WAV ?
//
typedef struct {		// entete fichier WAV */

	char	tag1[ 5 ];	// ( 4 octets) : Constante "RIFF"
	int		size1;		// ( 4 octets) : Taille du fichier
	char	tag2 [ 15 ];// (14 octets) : Constante "WAVEfmt "
	int		mode;		// ( 2 octets) : Mode (1 pour mono ou 2 pour stereo)
	int		freq;		// ( 4 octets) : Frequence d'échantillonage (en Hertz)
	int		bytepersec;	// ( 4 octets) : Nombre de bits par seconde de musique
	int		nbrbyte;	// ( 2 octets) : Nombre d'octets par échantillon
	int		format;		// ( 2 octets) : Nombre de bits par donnée
	int		tag3;		// ( 4 octets) : Constante "data"
	int		size2;		// ( 4 octets) : Taille du fichier moins 116 octets

} HEADER_WAV;
//
//
C_BOOL FileIs_wav (char *namefile)
{
	FILE        *fp = NULL;
	HEADER_WAV   buf;

	if ((fp = fopen (namefile, "r")) == NULL) return (FALSE);
	fread(&buf.tag1, 1, 4, fp);
	buf.tag1 [ 4 ] = '\0';
	fread(&buf.tag2, 1, 4, fp);
	fread(&buf.tag2, 1, 14, fp);
	fclose (fp);
	if ((buf.tag1 [ 0 ] == 'R' &&
	     buf.tag1 [ 1 ] == 'I' &&
	     buf.tag1 [ 2 ] == 'F' &&
	     buf.tag1 [ 3 ] == 'F') &&

	    (buf.tag2 [ 0 ] == 'W' &&
	     buf.tag2 [ 1 ] == 'A' &&
	     buf.tag2 [ 2 ] == 'V' &&
	     buf.tag2 [ 3 ] == 'E')) return (TRUE);

	return (FALSE);
}
// FILE IS SHN ?
//
C_BOOL FileIs_shn (char *namefile)
{
	FILE      *fp = NULL;
	char      str [ 8 ] = {'\0','\0','\0','\0','\0','\0','\0','\0'};

	if ((fp = fopen (namefile, "rb")) != NULL) {
		fread (&str[0], 1, 4, fp);
		fclose (fp);
	}
	if (str [0] == 'a' && str [1] == 'j' && str [2] == 'k' && str [3] == 'g') return (TRUE);

	return (FALSE);
}
// FILE IS RM ?
//
/*
$ file *.rm
	audio01.rm:   RealMedia file
	audio02.rm:   RealMedia file

	en tête fichier RM
	--- DEC ---   --- HEX ---
	[ 00 01 02 03 ] 2e 52 4d 46 = .RMF
	[ 18 19 20 21 ] 50 52 4f 50  = PROP
*/
C_BOOL FileIs_rm (char *namefile)
{
	FILE        *fp = NULL;
	char       *buf = NULL;
	C_BOOL     bool_signature = FALSE;

	buf = (char *)malloc (sizeof(char) * 512);
	if ((fp = fopen (namefile, "rb")) != NULL) {
		fread (buf, 1, 500, fp);
		fclose (fp);

		if (buf [  0 ] == 0x2e &&	// .
		    buf [  1 ] == 0x52 &&	// R
		    buf [  2 ] == 0x4d &&	// M
		    buf [  3 ] == 0x46 &&	// F

		    buf [ 18 ] == 0x50 &&	// P
		    buf [ 19 ] == 0x52 &&	// R
		    buf [ 20 ] == 0x4f &&	// O
		    buf [ 21 ] == 0x50)	{	// P

			bool_signature = TRUE;
		}
	}
	free (buf);
	buf = NULL;

	return (bool_signature);
}
// FILE IS OGG ?
//
C_BOOL FileIs_ogg (char *namefile)
{
	FILE	*fp = NULL;
	char	*buf = NULL;
	int		cpt;
	C_BOOL	bool_signature = FALSE;

	if ((buf = (char *)malloc (sizeof(char) * 2048)) == NULL) return (FALSE);
	if ((fp = fopen (namefile, "rb")) != NULL) {
		fread (buf, 1, 2000, fp);
		fclose (fp);
	}

	for (cpt = 0; cpt < 2000; cpt ++) {
		if (buf [ cpt + 0 ] == 'O' &&
		    buf [ cpt + 1 ] == 'g' &&
		    buf [ cpt + 2 ] == 'g' &&
		    buf [ cpt + 3 ] == 'S') {
		    bool_signature = TRUE;
		    break;
		}
	}

	if (bool_signature == TRUE) {
		bool_signature = FALSE;
		for (cpt = 0; cpt < 2000; cpt ++) {
			if (buf [ cpt +  3 ] == 'v' &&
			    buf [ cpt +  4 ] == 'o' &&
			    buf [ cpt +  5 ] == 'r' &&
			    buf [ cpt +  6 ] == 'b' &&
			    buf [ cpt +  7 ] == 'i' &&
			    buf [ cpt +  8 ] == 's'){
			    bool_signature = TRUE;
			    break;
			}
		}
	}

	free (buf);
	buf = NULL;

	return (bool_signature);
}
// FILE IS MPC ?
//
C_BOOL FileIs_mpc (char *namefile)
{
	FILE	*fp = NULL;
	char	*buf = NULL;
	int		cpt;
	C_BOOL	bool_signature = FALSE;

	buf = (char *)malloc (sizeof(char) * 1034);
	if((fp = fopen (namefile, "rb")) != NULL) {
		fread (buf, 1, 1024, fp);
		fclose (fp);
	}
	//
	// MPCKSH
	//
	for (cpt = 0; cpt < 1024; cpt ++) {
		if (
		    buf [ cpt + 0 ] == 0x4d &&	// M
		    buf [ cpt + 1 ] == 0x50 &&	// P
		    buf [ cpt + 2 ] == 0x2b		// +
		    ) {
		    bool_signature = TRUE;
		    break;
		}
	}
	if (FALSE ==  bool_signature) {
		for (cpt = 0; cpt < 1024; cpt ++) {
			if (
			    buf [ cpt + 0 ] == 0x4d &&	// M
			    buf [ cpt + 1 ] == 0x50 &&	// P
			    buf [ cpt + 2 ] == 0x43 &&	// C
			    buf [ cpt + 3 ] == 0x4b &&	// K
			    buf [ cpt + 4 ] == 0x53 &&	// S
			    buf [ cpt + 5 ] == 0x48		// H
			    ) {
			    bool_signature = TRUE;
			    break;
			}
		}
	}

	free (buf);
	buf = NULL;

	return (bool_signature);
}
// FILE IS AC3 ?
//
C_BOOL FileIs_ac3 (char *namefile)
{
	FILE	*fp = NULL;
	char	*buf = NULL;
	C_BOOL	BoolSignature = FALSE;

	buf = (char *)malloc (sizeof(char) * 100);
	if((fp = fopen (namefile, "rb")) != NULL) {
		fread (buf, 1, 50, fp);
		fclose (fp);
	}

	if (buf[0] == 0x0b && buf[1] == 0x77) {
		BoolSignature = TRUE;
	}

	free (buf);
	buf = NULL;

	return (BoolSignature);
}
// FILE IS MP3 ?
//
typedef struct  {
	char			magic[ 3 ];
	char			songname[ 30 ];
	char			artist[ 30 ];
	char			album[ 30 ];
	char			year[ 4 ];
	char			note[ 28 ];
	unsigned char	nnull;
	unsigned char	track;
	unsigned char	style;
} ID3TAG;
C_BOOL FileIs_mp3 (char *namefile)
{
	FILE	*fp = NULL;
	char	*buf = NULL;
	ID3TAG	begin;
	ID3TAG	end;
	C_BOOL	bool_signature = FALSE;
	int     i;
	size_t	size;

	fp = fopen (namefile, "rb");
	if (NULL == fp) return (FALSE);

	fread ( &begin, 128, 1, fp );
	fseek ( fp, 0, SEEK_END );
	fseek ( fp, ftell( fp ) - 128, SEEK_SET );
	fread ( &end, 128, 1, fp );
	fclose (fp);

	// TEST SI FICHIER EST: AC3
	// OCTET 0	OCTET 1
	// 76543210	76543210
	// 00001011	01110111
	// 0b		77
	// 11		119
	if (begin.magic[0] == 0x0b && begin.magic[1] == 0x77) {
		return (FALSE);
	}

	if (begin.magic[0] == 'I' && begin.magic[1] == 'D' && begin.magic[2] == '3') return (TRUE);
	if (end.magic[0] == 'T' && end.magic[1] == 'A' && end.magic[2] == 'G') return (TRUE);

	size = utils_get_size_file (namefile);
	buf = malloc (sizeof (char) * (size + 10));
	if ((fp = fopen (namefile, "rb"))) {
		fread (buf, 1, size, fp);
		fclose (fp);
		for (i = 0; i < size; i ++) {
			if (buf[i+0] == 'L' && buf[i+1] == 'A' && buf[i+2] == 'M' && buf[i+3] == 'E') {
				bool_signature = TRUE;
				break;
			}
		}
	}

	//
	// http://mgc99.free.fr/InfoMP3.html
	//
	//
	// La partie "audio" du MP3 commence par un entête de 4 octets. Ces 4 octets donnent des informations sur le type de MP3.
	// Cet entête se trouve après les tag ID3 v2 s'il y en a. Il n'a pas de position précise dans le fichier, il faut le chercher.
	// Il commence toujours par une série de 11 bits à 1 (FF Ex xx xx ou FF Fx xx xx).
	// 1111 1111 - 111B BCCD - EEEE FFGH - IIJJ KLMM
	// BB	version de MPEG (11-v1, 10-v2, 01-reserved, 00-v2.5)
	// CC	numéro de layer (11-layer 1, 10-layer 2, 01-layer 3, 00-reserved)
	// D	protection bit (0 protection par CRC, 2 octets suive l'entête. 1 pas de protection)
	// EEEE bitrate index.
	// FF	sampling rate frequency index.
	// G	padding bit.
	// H	private bit.
	// II	chanel mode (11-single channel, 10-dual channel, 01-joint stéréo, 00-stéréo)
	// JJ	mode extention seulement si "joint stéréo"
	// K	copyright (1 copyright, 0 pas de copyright).
	// L	original (1 original, 0 copie)
	// MM	emphasis (11-CCIT J.17, 10-reserved, 01-50/15ms, 00-none)
	//
	/*
	if (FALSE == bool_signature) {
		for (i = 0; i < size; i ++) {
			Dummy = buf[i+0] + buf[i+1];
			Dummy &= 0x011111111111;
			if (0x011111111111 == Dummy) {
				bool_signature = TRUE;
				printf("ICI EST MP3\n");
				printf("\tsize = %lu\n", size );
				printf("\ti    = %d\n", i );
				break;
			}
		}
	}
	*/
	free (buf);
	buf = NULL;

	return (bool_signature);
}
// FILE IS FLAC ?
//
C_BOOL FileIs_flac (char *namefile)
{
	FILE	*fp = NULL;
	char	*buf = NULL;
	int		cpt;
	C_BOOL	bool_signature = FALSE;

	buf = (char *)malloc (sizeof(char) * 5124);
	if ((fp = fopen (namefile, "rb")) != NULL) {
		fread (buf, 1, 5120, fp);
		fclose (fp);
	}

	for (cpt = 0; cpt < 5120; cpt ++) {
		if (buf [ cpt + 0 ] == 0x66 &&	/* 'f' */
		    buf [ cpt + 1 ] == 0x4c &&	/* 'L' */
		    buf [ cpt + 2 ] == 0x61 &&	/* 'a' */
		    buf [ cpt + 3 ] == 0x43) {	/* 'C' */
		    bool_signature = TRUE;
		    break;
		}
	}
	free (buf);
	buf = NULL;

	return (bool_signature);
}
/*****************************************************************************************
APE header that all APE files have in common (old and new)
*****************************************************************************************
struct APE_COMMON_HEADER
{
    char cID[4];                            should equal 'MAC '
    uint16 nVersion;                        version number * 1000 (3.81 = 3810)
};

*****************************************************************************************
APE header structure for old APE files (3.97 and earlier)
*****************************************************************************************
struct APE_HEADER_OLD
{
    char cID[4];                            should equal 'MAC '
    uint16 nVersion;                        version number * 1000 (3.81 = 3810)
    uint16 nCompressionLevel;               the compression level
    uint16 nFormatFlags;                    any format flags (for future use)
    uint16 nChannels;                       the number of channels (1 or 2)
    uint32 nSampleRate;                     the sample rate (typically 44100)
    uint32 nHeaderBytes;                    the bytes after the MAC header that compose the WAV header
    uint32 nTerminatingBytes;               the bytes after that raw data (for extended info)
    uint32 nTotalFrames;                    the number of frames in the file
    uint32 nFinalFrameBlocks;               the number of samples in the final frame
};
*****************************************************************************************/
// FILE IS APE ?
//
// le prg 'file' est leurré par un tag id3 et ne reconnait qu'un mp3  !!!
// il faut lire 05 ko de datas
// bug signalé par @patachonf depuis:
// 	http://forum.ubuntu-fr.org/viewtopic.php?pid=3739121#p3739121
// [ resolu ]
C_BOOL FileIs_ape (char *namefile)
{
	FILE	*fp = NULL;
	char	*buf = NULL;
	int		cpt;
	C_BOOL	bool_signature = FALSE;

	buf = (char *)malloc (sizeof(char) * 5120);
	if ((fp = fopen (namefile, "rb")) != NULL) {
		fread (buf, 1, 5000, fp);
		fclose (fp);

		for (cpt = 0; cpt < 5000; cpt ++) {
			if (buf [ cpt + 0 ] == 0x4d &&	/* 'M' */
			    buf [ cpt + 1 ] == 0x41 &&	/* 'A' */
			    buf [ cpt + 2 ] == 0x43 &&	/* 'C' */
			    buf [ cpt + 3 ] == 0x20) {	/* ' ' */
			    bool_signature = TRUE;
			    break;
			}
		}
	}
	free (buf);
	buf = NULL;

	return (bool_signature);
}
// FILE IS AIFF ?
//
/*
POS	ASCII	HEXA
00	F		46
01	O		4f
02	R		52
03	M		4d
04
05
06
07
08	A		41
09	I		49
10	F		46
11	F		46
12	C		43
13	O		4f
14	M		4d
15	M		4d
*/
C_BOOL FileIs_aiff (char *namefile)
{
	FILE	*fp = NULL;
	char	*buf = NULL;
	C_BOOL	bool_signature = FALSE;

	buf = (char *)malloc (sizeof(char) * 512);
	if ((fp = fopen (namefile, "rb")) != NULL) {
		fread (buf, 1, 500, fp);
		fclose (fp);

		if (buf [  0 ] == 0x46 &&	// F
		    buf [  1 ] == 0x4f &&	// O
		    buf [  2 ] == 0x52 &&	// R
		    buf [  3 ] == 0x4d &&	// M

		    buf [  8 ] == 0x41 &&	// A
		    buf [  9 ] == 0x49 &&	// I
		    buf [ 10 ] == 0x46 &&	// F
		    buf [ 11 ] == 0x46 &&	// F
		    buf [ 12 ] == 0x43 &&	// C
		    buf [ 13 ] == 0x4f &&	// O
		    buf [ 14 ] == 0x4d &&	// M
		    buf [ 15 ] == 0x4d)	{	// M

			bool_signature = TRUE;
		}
	}

	free (buf);
	buf = NULL;

	return (bool_signature);
}
// FILE IS DTS ?
//
C_BOOL FileIs_dts (char *namefile)
{
	C_BOOL	bool_signature = FALSE;
	char	Ext [ 8 ] = {'\0','\0','\0','\0','\0','\0','\0','\0',};
	char	*Ptr;

	Ptr = strrchr (namefile, '/');
	if (Ptr) {
		Ptr = strrchr (Ptr, '.');
		if (Ptr) {
			Ptr++;
			if (*Ptr) Ext [0] = toupper (*Ptr++);
			if (*Ptr) Ext [1] = toupper (*Ptr++);
			if (*Ptr) Ext [2] = toupper (*Ptr++);
			if (*Ptr) Ext [3] = toupper (*Ptr);
			Ext [4] = '\0';

			if (Ext[0] == 'D' && Ext[1] == 'T' && Ext[2] == 'S' && Ext[3] == '\0') bool_signature = TRUE;
		}
	}
	return (bool_signature);
}
// FILE IS PNG ?
//
C_BOOL FileIs_png (char *namefile)
{
	FILE	*fp = NULL;
	char	*buf = NULL;
	int		cpt;
	C_BOOL	bool_signature = FALSE;

	buf = (char *)malloc (sizeof(char) * 5124);
	if ((fp = fopen (namefile, "rb")) != NULL) {
		fread (buf, 1, 5120, fp);
		fclose (fp);
	}

	for (cpt = 0; cpt < 5120; cpt ++) {
		if(
			buf [ cpt + 0 ] == 0x50 &&	// 'P'
			buf [ cpt + 1 ] == 0x4E &&	// 'N'
			buf [ cpt + 2 ] == 0x47		// 'G'
		    ) {
		    bool_signature = TRUE;
		    break;
		}
	}
	free (buf);
	buf = NULL;

	return (bool_signature);
}