1 /* Copyright (c) 2004-2005 Nokia. All rights reserved. */
3 /* The PerlRecog application is licensed under the same terms as Perl itself. */
9 const TUid KUidPerlRecog = { 0x102015F7 };
10 _LIT8(KPerlMimeType, "x-application/x-perl");
11 _LIT8(KPerlSig, "#!/usr/bin/perl");
12 const TInt KPerlSigLen = 15;
14 class CApaPerlRecognizer : public CApaDataRecognizerType {
16 CApaPerlRecognizer():CApaDataRecognizerType(KUidPerlRecog, EHigh) {
19 virtual TUint PreferredBufSize() { return KPerlSigLen; }
20 virtual TDataType SupportedDataTypeL(TInt /* aIndex */) const {
21 return TDataType(KPerlMimeType);
24 virtual void DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer);
27 void CApaPerlRecognizer::DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer)
29 iConfidence = ENotRecognized;
31 if (aBuffer.Length() >= KPerlSigLen &&
32 aBuffer.Left(KPerlSigLen).Compare(KPerlSig) == 0) {
33 iConfidence = ECertain;
34 iDataType = TDataType(KPerlMimeType);
38 if ((p.Ext().CompareF(_L(".pl")) == 0) ||
39 (p.Ext().CompareF(_L(".pm")) == 0)) {
40 iConfidence = ECertain;
41 iDataType = TDataType(KPerlMimeType);
46 EXPORT_C CApaDataRecognizerType* CreateRecognizer()
48 return new CApaPerlRecognizer;
51 GLDEF_C TInt E32Dll(TDllReason /* aReason */)