annotate src/mtp_up/filetype.c @ 3052:95b34f46a231

Comment out MPEG2/MPEG4 determination using the variable id. It is not used anywhere. Code analysis run, unique ID 6nYoHM.
author Tony Vroon <chainsaw@gentoo.org>
date Sat, 18 Apr 2009 19:06:20 +0100
parents d72a44fdb6a3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1517
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
1 /*This code was copied shamelessly from libMTP's examples*/
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
2 #include "string.h"
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
3 #include "filetype.h"
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
4
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
5 /* Find the file type based on extension */
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
6 LIBMTP_filetype_t
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
7 find_filetype (const char * filename)
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
8 {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
9 char *ptype;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
10 ptype = rindex(filename,'.')+1;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
11 LIBMTP_filetype_t filetype;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
12 /* This need to be kept constantly updated as new file types arrive. */
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
13 if (!strcasecmp (ptype, "wav")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
14 filetype = LIBMTP_FILETYPE_WAV;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
15 } else if (!strcasecmp (ptype, "mp3")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
16 filetype = LIBMTP_FILETYPE_MP3;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
17 } else if (!strcasecmp (ptype, "wma")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
18 filetype = LIBMTP_FILETYPE_WMA;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
19 } else if (!strcasecmp (ptype, "ogg")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
20 filetype = LIBMTP_FILETYPE_OGG;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
21 } else if (!strcasecmp (ptype, "mp4")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
22 filetype = LIBMTP_FILETYPE_MP4;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
23 } else if (!strcasecmp (ptype, "wmv")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
24 filetype = LIBMTP_FILETYPE_WMV;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
25 } else if (!strcasecmp (ptype, "avi")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
26 filetype = LIBMTP_FILETYPE_AVI;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
27 } else if (!strcasecmp (ptype, "mpeg") || !strcasecmp (ptype, "mpg")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
28 filetype = LIBMTP_FILETYPE_MPEG;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
29 } else if (!strcasecmp (ptype, "asf")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
30 filetype = LIBMTP_FILETYPE_ASF;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
31 } else if (!strcasecmp (ptype, "qt") || !strcasecmp (ptype, "mov")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
32 filetype = LIBMTP_FILETYPE_QT;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
33 } else if (!strcasecmp (ptype, "wma")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
34 filetype = LIBMTP_FILETYPE_WMA;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
35 } else if (!strcasecmp (ptype, "jpg") || !strcasecmp (ptype, "jpeg")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
36 filetype = LIBMTP_FILETYPE_JPEG;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
37 } else if (!strcasecmp (ptype, "jfif")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
38 filetype = LIBMTP_FILETYPE_JFIF;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
39 } else if (!strcasecmp (ptype, "tif") || !strcasecmp (ptype, "tiff")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
40 filetype = LIBMTP_FILETYPE_TIFF;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
41 } else if (!strcasecmp (ptype, "bmp")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
42 filetype = LIBMTP_FILETYPE_BMP;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
43 } else if (!strcasecmp (ptype, "gif")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
44 filetype = LIBMTP_FILETYPE_GIF;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
45 } else if (!strcasecmp (ptype, "pic") || !strcasecmp (ptype, "pict")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
46 filetype = LIBMTP_FILETYPE_PICT;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
47 } else if (!strcasecmp (ptype, "png")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
48 filetype = LIBMTP_FILETYPE_PNG;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
49 } else if (!strcasecmp (ptype, "wmf")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
50 filetype = LIBMTP_FILETYPE_WINDOWSIMAGEFORMAT;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
51 } else if (!strcasecmp (ptype, "ics")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
52 filetype = LIBMTP_FILETYPE_VCALENDAR2;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
53 } else if (!strcasecmp (ptype, "exe") || !strcasecmp (ptype, "com") ||
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
54 !strcasecmp (ptype, "bat") || !strcasecmp (ptype, "dll") ||
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
55 !strcasecmp (ptype, "sys")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
56 filetype = LIBMTP_FILETYPE_WINEXEC;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
57 } else if (!strcasecmp (ptype, "aac")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
58 filetype = LIBMTP_FILETYPE_AAC;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
59 } else if (!strcasecmp (ptype, "mp2")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
60 filetype = LIBMTP_FILETYPE_MP2;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
61 } else if (!strcasecmp (ptype, "flac")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
62 filetype = LIBMTP_FILETYPE_FLAC;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
63 } else if (!strcasecmp (ptype, "m4a")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
64 filetype = LIBMTP_FILETYPE_M4A;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
65 } else if (!strcasecmp (ptype, "doc")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
66 filetype = LIBMTP_FILETYPE_DOC;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
67 } else if (!strcasecmp (ptype, "xml")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
68 filetype = LIBMTP_FILETYPE_XML;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
69 } else if (!strcasecmp (ptype, "xls")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
70 filetype = LIBMTP_FILETYPE_XLS;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
71 } else if (!strcasecmp (ptype, "ppt")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
72 filetype = LIBMTP_FILETYPE_PPT;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
73 } else if (!strcasecmp (ptype, "mht")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
74 filetype = LIBMTP_FILETYPE_MHT;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
75 } else if (!strcasecmp (ptype, "jp2")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
76 filetype = LIBMTP_FILETYPE_JP2;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
77 } else if (!strcasecmp (ptype, "jpx")) {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
78 filetype = LIBMTP_FILETYPE_JPX;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
79 } else {
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
80 /* Tagging as unknown file type */
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
81 filetype = LIBMTP_FILETYPE_UNKNOWN;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
82 }
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
83 return filetype;
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
84 }
d72a44fdb6a3 switched to uploading tracks instead of files, added disconnect option, other misc. fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
85