Files
Slnkdwf/WincmdContent/WincmdContent.cpp
Jos Groot Lipman 80d0142c23 SLNKDWF 2.00
svn path=/Slnkdwf/trunk/; revision=12481
2007-08-01 13:42:28 +00:00

112 lines
2.4 KiB
C++

// filesys.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "contentplug.h"
#define _detectstring "EXT=\"DWF\"|EXT=\"W2D\""
#define fieldcount 2
char* fieldnames[fieldcount]={
"version", "sections"};
int fieldtypes[fieldcount]={
ft_string, ft_numeric_32};
char* fieldunits_and_multiplechoicestrings[fieldcount]={
"", ""};
BOOL GetValueAborted=false;
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
char* strlcpy(char* p,const char* p2,int maxlen)
{
if ((int)strlen(p2)>=maxlen) {
strncpy(p,p2,maxlen);
p[maxlen]=0;
} else
strcpy(p,p2);
return p;
}
int __stdcall ContentGetDetectString(char* DetectString,int maxlen)
{
strlcpy(DetectString,_detectstring,maxlen);
return 0;
}
int __stdcall ContentGetSupportedField(int FieldIndex,char* FieldName,char* Units,int maxlen)
{
if (FieldIndex<0 || FieldIndex>=fieldcount)
return ft_nomorefields;
strlcpy(FieldName,fieldnames[FieldIndex],maxlen-1);
strlcpy(Units,fieldunits_and_multiplechoicestrings[FieldIndex],maxlen-1);
return fieldtypes[FieldIndex];
}
int __stdcall ContentGetValue(char* FileName,int FieldIndex,int UnitIndex,void* FieldValue,int maxlen,int flags)
{
GetValueAborted=false;
if (flags & CONTENT_DELAYIFSLOW) {
if (FieldIndex==16)
return ft_delayed;
if (FieldIndex==17)
return ft_ondemand;
}
try
{
CDWFFileImpl m_iDWFFile;
m_iDWFFile.Open(FileName);
switch (FieldIndex)
{
case 0: // "Version"
{
CString s;
s.Format("%02d.%02d", m_iDWFFile.m_tInfo.nVersion / 100, m_iDWFFile.m_tInfo.nVersion % 100);
strlcpy((char*)FieldValue,s,maxlen-1);
break;
}
case 1: // "Sections"
{
CEPlotSectionsImpl *piEPlotSections;
piEPlotSections = m_iDWFFile.get_EPlotSections();
LONG lCount = piEPlotSections->get_Count();
*(int*)FieldValue=lCount;
break;
}
default:
return ft_nosuchfield;
}
}
catch (CString &ee)
{
strlcpy((char*)FieldValue,"Kweenie",maxlen-1);
return ft_string;
}
// } else
// return ft_fileerror;
return fieldtypes[FieldIndex]; // very important!
}
void __stdcall ContentSetDefaultParams(ContentDefaultParamStruct* dps)
{
}
void __stdcall ContentStopGetValue (char* FileName)
{
GetValueAborted=true;
}