summaryrefslogtreecommitdiff
path: root/atari/filetype.c
diff options
context:
space:
mode:
authorOle Loots <ole@monochrom.net>2011-12-06 21:06:41 +0000
committerOle Loots <ole@monochrom.net>2011-12-06 21:06:41 +0000
commite7e8024be80b734bf1197615e70cc198bb9758c6 (patch)
treed69763a205d7253e84da6a22cb6b77790583e06d /atari/filetype.c
parent3ba6a15fa7af580d14044ab2e73318b75deb6433 (diff)
downloadnetsurf-e7e8024be80b734bf1197615e70cc198bb9758c6.tar.gz
netsurf-e7e8024be80b734bf1197615e70cc198bb9758c6.tar.bz2
Fix focus element
svn path=/trunk/netsurf/; revision=13251
Diffstat (limited to 'atari/filetype.c')
-rwxr-xr-xatari/filetype.c66
1 files changed, 47 insertions, 19 deletions
diff --git a/atari/filetype.c b/atari/filetype.c
index dd7179cbc..4515613f5 100755
--- a/atari/filetype.c
+++ b/atari/filetype.c
@@ -38,25 +38,53 @@ const char *fetch_filetype(const char *unix_path)
LOG(("unix path: %s", unix_path));
- /* This line is added for devlopment versions running from the root dir: */
- if (2 < l && strcasecmp(unix_path + l - 3, "f79") == 0)
- res = (char*)"text/css";
- else if (2 < l && strcasecmp(unix_path + l - 3, "css") == 0)
- res = (char*)"text/css";
- else if (2 < l && strcasecmp(unix_path + l - 3, "jpg") == 0)
- res = (char*)"image/jpeg";
- else if (3 < l && strcasecmp(unix_path + l - 4, "jpeg") == 0)
- res = (char*)"image/jpeg";
- else if (2 < l && strcasecmp(unix_path + l - 3, "gif") == 0)
- res = (char*)"image/gif";
- else if (2 < l && strcasecmp(unix_path + l - 3, "png") == 0)
- res = (char*)"image/png";
- else if (2 < l && strcasecmp(unix_path + l - 3, "jng") == 0)
- res = (char*)"image/jng";
- else if (2 < l && strcasecmp(unix_path + l - 3, "svg") == 0)
- res = (char*)"image/svg";
- else if (2 < l && strcasecmp(unix_path + l - 3, "txt") == 0)
- res = (char*)"text/plain";
+ /* This line is added for devlopment versions running from the root dir: */
+ if( strchr( unix_path, (int)'.' ) ){
+ if (2 < l && strcasecmp(unix_path + l - 3, "f79") == 0)
+ res = (char*)"text/css";
+ else if (2 < l && strcasecmp(unix_path + l - 3, "css") == 0)
+ res = (char*)"text/css";
+ else if (2 < l && strcasecmp(unix_path + l - 3, "jpg") == 0)
+ res = (char*)"image/jpeg";
+ else if (3 < l && strcasecmp(unix_path + l - 4, "jpeg") == 0)
+ res = (char*)"image/jpeg";
+ else if (2 < l && strcasecmp(unix_path + l - 3, "gif") == 0)
+ res = (char*)"image/gif";
+ else if (2 < l && strcasecmp(unix_path + l - 3, "png") == 0)
+ res = (char*)"image/png";
+ else if (2 < l && strcasecmp(unix_path + l - 3, "jng") == 0)
+ res = (char*)"image/jng";
+ else if (2 < l && strcasecmp(unix_path + l - 3, "svg") == 0)
+ res = (char*)"image/svg";
+ else if (2 < l && strcasecmp(unix_path + l - 3, "txt") == 0)
+ res = (char*)"text/plain";
+ } else {
+ int n=0;
+ int c;
+ FILE * fp;
+ char buffer[16];
+ fp = fopen( unix_path, "r" );
+ if( fp ){
+ do {
+ c = fgetc (fp);
+ if( c != EOF )
+ buffer[n] = (char)c;
+ else
+ buffer[n] = 0;
+ n++;
+ } while (c != EOF && n<15);
+ fclose( fp );
+ if( n > 0 ){
+ if( n > 5 && strncasecmp("GIF89", buffer, 5) == 0 )
+ res = "image/gif";
+ else if( n > 4 && strncasecmp("PNG", &buffer[1], 3) ==0 )
+ res = "image/png";
+ else if( n > 10 && strncasecmp("JFIF", &buffer[5], 4) == 0 )
+ res = "image/jpeg";
+ }
+ }
+ }
+
error:
LOG(("mime type: %s", res ));
return( res );