summaryrefslogtreecommitdiff
path: root/symbian/PerlRecog.cpp
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2005-04-18 16:18:30 +0300
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-04-21 15:38:30 +0000
commit27da23d53ccce622bc51822f59df8def79b4df95 (patch)
tree1202440e0fbf7a2fc1bb54993d11cda7b245f1b4 /symbian/PerlRecog.cpp
parentec0624293b57ae07d6b2c32bae099d4f163e7e07 (diff)
downloadperl-27da23d53ccce622bc51822f59df8def79b4df95.tar.gz
Symbian port of Perl
Message-ID: <B356D8F434D20B40A8CEDAEC305A1F2453D653@esebe105.NOE.Nokia.com> p4raw-id: //depot/perl@24271
Diffstat (limited to 'symbian/PerlRecog.cpp')
-rw-r--r--symbian/PerlRecog.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/symbian/PerlRecog.cpp b/symbian/PerlRecog.cpp
new file mode 100644
index 0000000000..d2db54491b
--- /dev/null
+++ b/symbian/PerlRecog.cpp
@@ -0,0 +1,57 @@
+/* Copyright (c) 2004-2005 Nokia. All rights reserved. */
+
+/* The PerlRecog application is licensed under the same terms as Perl itself. */
+
+#include <apmrec.h>
+#include <apmstd.h>
+#include <f32file.h>
+
+const TUid KUidPerlRecog = { 0x102015F7 };
+_LIT8(KPerlMimeType, "x-application/x-perl");
+_LIT8(KPerlSig, "#!/usr/bin/perl");
+const TInt KPerlSigLen = 15;
+
+class CApaPerlRecognizer : public CApaDataRecognizerType {
+ public:
+ CApaPerlRecognizer():CApaDataRecognizerType(KUidPerlRecog, EHigh) {
+ iCountDataTypes = 1;
+ }
+ virtual TUint PreferredBufSize() { return KPerlSigLen; }
+ virtual TDataType SupportedDataTypeL(TInt /* aIndex */) const {
+ return TDataType(KPerlMimeType);
+ }
+ private:
+ virtual void DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer);
+};
+
+void CApaPerlRecognizer::DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer)
+{
+ iConfidence = ENotRecognized;
+
+ if (aBuffer.Length() >= KPerlSigLen &&
+ aBuffer.Left(KPerlSigLen).Compare(KPerlSig) == 0) {
+ iConfidence = ECertain;
+ iDataType = TDataType(KPerlMimeType);
+ } else {
+ TParsePtrC p(aName);
+
+ if ((p.Ext().CompareF(_L(".pl")) == 0) ||
+ (p.Ext().CompareF(_L(".pm")) == 0)) {
+ iConfidence = ECertain;
+ iDataType = TDataType(KPerlMimeType);
+ }
+ }
+}
+
+EXPORT_C CApaDataRecognizerType* CreateRecognizer()
+{
+ return new CApaPerlRecognizer;
+}
+
+GLDEF_C TInt E32Dll(TDllReason /* aReason */)
+{
+ return KErrNone;
+}
+
+
+