#include <stdio.h>
#include <string.h>
#include <global.h>
#include <nsfdb.h>
#include <nsfnote.h>
#include <oleods.h>
/* Prototypes */
STATUS LNPUBLIC ProcessOneCDRecord(
char *RecordPtr,
WORD RecordType,
DWORD RecordLength,
void *p_ptr_void );
void CleanUp(
DBHANDLE db_handle,
NOTEHANDLE note_handle);
void ProcessImageHeader(
char *RecordPtr,
DWORD RecordLength,
WORD RecordType );
int main(int argc, char *argv[])
{
char db_filename[]="rt.nsf";
DBHANDLE db_handle;
NOTEHANDLE note_handle;
STATUS error = NOERROR;
char itemname[] ="Body";
DWORD NoteID = 2294;
BLOCKID item_blockid;
BLOCKID value_blockid;
WORD value_datatype;
DWORD value_len;
if (error = NotesInitExtended (argc, argv))
{ printf("\n Unable to initialize Notes.\n");
return (1); }
/*Open Database*/
if (error = NSFDbOpen (db_filename, &db_handle))
{ printf("\n Unable to open database.\n");
NotesTerm();
return (1); }
/*Open Note*/
if (error = NSFNoteOpen (db_handle, NoteID, 0, ¬e_handle))
{ printf("\n Unable to open note.\n");
NotesTerm();
return (1); }
if (error = NSFItemInfo (
note_handle,
itemname,
strlen(itemname),
&item_blockid,
&value_datatype,
&value_blockid,
&value_len))
{
printf("\n Unable to get note-info.\n");
CleanUp (db_handle, note_handle);
return (1);
}
if (error = EnumCompositeBuffer(
value_blockid,
value_len,
ProcessOneCDRecord,
NULL ) )
{
CleanUp(db_handle, note_handle);
return(0);
}
if (error = NSFDbClose (db_handle))
return (1);
NotesTerm();
return (0);
}
/*************************************************************************
FUNCTION: CleanUp
**************************************************************************/
void CleanUp(DBHANDLE db_handle, NOTEHANDLE note_handle)
{
NSFDbClose (db_handle);
NSFNoteClose (note_handle);
NotesTerm();
}
/************************************************************************
FUNCTION: ProcessOneCDRecord
*************************************************************************/
STATUS LNPUBLIC ProcessOneCDRecord(
char *RecordPtr,
WORD RecordType,
DWORD RecordLength,
void *p_ptr_void )
{
switch (RecordType)
{
case SIG_CD_IMAGEHEADER:
ProcessImageHeader( RecordPtr, RecordLength, RecordType );
break;
}
return(NOERROR);
}
/*************************************************************************
FUNCTION: ProcessImageHeader
**************************************************************************/
void ProcessImageHeader( char *RecordPtr, DWORD RecordLength, WORD RecordType )
{
char far * p = RecordPtr;
char ImgType[4];
CDIMAGEHEADER cdImgageHeader;
ODSReadMemory( &p, _CDIMAGEHEADER, &cdImgageHeader, 1 );
printf("\n");
printf("Embedded Image Groesse: %d Bytes\n", cdImgageHeader.ImageDataSize);
printf("Embedded Image Breite: %d Pixel\n", cdImgageHeader.Width);
printf("Embedded Image Hoehe: %d Pixel\n", cdImgageHeader.Height);
switch (cdImgageHeader.ImageType)
{
case CDIMAGETYPE_GIF:
strcpy (ImgType,"GIF");
break;
case CDIMAGETYPE_JPEG:
strcpy (ImgType,"JPG");
break;
case CDIMAGETYPE_BMP:
strcpy (ImgType,"BMP");
break;
}
printf("Embedded Image Type: %s \n", ImgType);
return;
}