This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perldelta for 8348ac19a3c3
[perl5.git] / symbian / PerlRecog.cpp
CommitLineData
27da23d5
JH
1/* Copyright (c) 2004-2005 Nokia. All rights reserved. */
2
3/* The PerlRecog application is licensed under the same terms as Perl itself. */
4
5#include <apmrec.h>
6#include <apmstd.h>
7#include <f32file.h>
8
9const TUid KUidPerlRecog = { 0x102015F7 };
10_LIT8(KPerlMimeType, "x-application/x-perl");
11_LIT8(KPerlSig, "#!/usr/bin/perl");
12const TInt KPerlSigLen = 15;
13
14class CApaPerlRecognizer : public CApaDataRecognizerType {
15 public:
16 CApaPerlRecognizer():CApaDataRecognizerType(KUidPerlRecog, EHigh) {
17 iCountDataTypes = 1;
18 }
19 virtual TUint PreferredBufSize() { return KPerlSigLen; }
20 virtual TDataType SupportedDataTypeL(TInt /* aIndex */) const {
21 return TDataType(KPerlMimeType);
22 }
23 private:
24 virtual void DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer);
25};
26
27void CApaPerlRecognizer::DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer)
28{
29 iConfidence = ENotRecognized;
30
31 if (aBuffer.Length() >= KPerlSigLen &&
32 aBuffer.Left(KPerlSigLen).Compare(KPerlSig) == 0) {
33 iConfidence = ECertain;
34 iDataType = TDataType(KPerlMimeType);
35 } else {
36 TParsePtrC p(aName);
37
38 if ((p.Ext().CompareF(_L(".pl")) == 0) ||
39 (p.Ext().CompareF(_L(".pm")) == 0)) {
40 iConfidence = ECertain;
41 iDataType = TDataType(KPerlMimeType);
42 }
43 }
44}
45
46EXPORT_C CApaDataRecognizerType* CreateRecognizer()
47{
48 return new CApaPerlRecognizer;
49}
50
51GLDEF_C TInt E32Dll(TDllReason /* aReason */)
52{
53 return KErrNone;
54}
55
56
57