blob: 06543431db97c6755ba9ec997b1b8c0d859746dd (
plain)
| 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
 | /*
** Copyright 2002-2008, Double Precision Inc.
**
** See COPYING for distribution information.
*/
#include "libmail_config.h"
#include "mimetypes.H"
#include "namespace.H"
#include "unicode/courier-unicode.h"
#include <fstream>
#include <cctype>
#include <cstring>
using namespace std;
LIBMAIL_START
#include "mimetypefiles.h"
LIBMAIL_END
mail::mimetypes::mimetypes(string searchKey)
{
	size_t i;
	for (i=0; mimetypefiles[i]; i++)
	{
		ifstream f( mimetypefiles[i]);
		while (!f.bad() && !f.eof())
		{
			string line;
			getline(f, line);
			size_t p;
			p=line.find('#');
			if (p != std::string::npos)
				line=line.substr(0, p);
			string::iterator b, e, c;
			vector<string> words;
			b=line.begin();
			e=line.end();
			bool found=false;
			while (b != e)
			{
				if (unicode_isspace((unsigned char)*b))
				{
					b++;
					continue;
				}
				c=b;
				while (b != e && !unicode_isspace((unsigned char)
							  *b))
					b++;
				string w=string(c, b);
				if (strcasecmp(w.c_str(), searchKey.c_str())
				    == 0)
					found=true;
				words.push_back(w);
			}
			if (found)
			{
				type=words[0];
				extensions.insert(extensions.end(),
						  words.begin()+1,
						  words.end());
				return;
			}
		}
	}
}
mail::mimetypes::~mimetypes()
{
}
 |