Subject: Problem with POP message fetching under NT...

From: Kenneth Maupin <[email-masked]>
Date: Wed, 12 Mar 1997 13:05:22 -0800

Hi,

	I'm having trouble getting an NT-based c-client application to 
retrieve messages from a POP server using mail_fetchenvelope() and 
mail_fetchstructure().  After tracing with a debugger, I found that the 
call to fread() in pop3_header() (pop3.c, line 480) consistently raises 
an access violation.  The same application works fine when built and 
run under Linux 2.0.12 using GCC 2.7.2.

	I'm using the following environment on the NT side...

	- NT 4 Workstation
	- c-client library dated 24 February in README-FIRST
	- Visual C++ 4.2
	- Compiler options...
		- Application: /MTd /Zi /Gm /GX /I. /nologo /YX
		- c-client: /I$C /MT /W3 /DWIN32 /nologo $(EXTRACFLAGS) /Zi
	- Linker options...
		- Application: /debug cclient.lib wsock32.lib winmm.lib advapi32.lib
		- c-client: /nologo /debug

	The linker sometimes, but not always, complains about a 
"libcmt.lib" library conflict (with "libcmtd.lib"?) when linking the 
application.

	Below are a simplified version of the application I'm building,
which fails in the same place as the complete application, and its
makefile.  mail_open() succeeds, so I'm sure the application is able 
to connect to the POP server.  (I've verified this with a protocol debug
and "netstat -a" on the server-side.)

	I'd be happy to provide further details.  Any suggestions would be 
much appreciated.  Thanks!

				- Ken Maupin -
				[email-masked]

---------------------------------------------------------------------
poptest.c
---------------------------------------------------------------------
#include <mail.h>

/* Insert appropriate values here */
#define POP_MAILBOX_NAME	"{host/pop3}"
#define POP_USERNAME		"username"
#define POP_PASSWORD		"password"

main() {
	long		msgNum;
	MAILSTREAM	*popStream;

#include <linkage.c>

	popStream = mail_open(NIL, POP_MAILBOX_NAME, NIL);
	for (msgNum = 1; msgNum <= popStream->nmsgs; msgNum++) {
		mail_fetchstructure(popStream, msgNum, NIL);
	}
	mail_close(popStream);
}

void mm_login (NETMBX *mailbox, char * username, char * password, long trials) {
  strcpy(username, POP_USERNAME);
  strcpy(password, POP_PASSWORD);
} /* mm_login() */

void mm_searched (MAILSTREAM *stream,unsigned long number) {}
void mm_exists (MAILSTREAM *stream,unsigned long number) {}
void mm_expunged (MAILSTREAM *stream,unsigned long number) {}
void mm_flags (MAILSTREAM *stream,unsigned long number) {}
void mm_notify (MAILSTREAM *stream,char * string,long errflg) {}
void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes) {}
void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes) {}
void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status) {}
void mm_log (char *string,long errflg) {}
void mm_dlog (char *string){}
void mm_critical (MAILSTREAM *stream) {}
void mm_nocritical (MAILSTREAM *stream) {}
long mm_diskerror (MAILSTREAM *stream,long errcode,long serious) {}
void mm_fatal (char *string) {}

---------------------------------------------------------------------
makefile
---------------------------------------------------------------------
CC	= cl
LD	= link
CFLAGS	= /MTd /Zi /Gm /GX /I. /nologo /YX
LDFLAGS	= /debug cclient.lib wsock32.lib winmm.lib advapi32.lib

poptest.exe: poptest.obj
	$(LD) /out:$@ poptest.obj $(LDFLAGS)

---

From: Mark Crispin <[email-masked]>
Date: Wed, 12 Mar 1997 13:34:03 -0800 (PST)

I just tried it on my NT 3.51 box and the problem did not occur.

Make sure that you have the latest sources.  There is a known bug in text
fetching with earlier versions of the POP3 support in imap-4.1.