Subject: More c-client confustion

From: Christopher McBee <[email-masked]>
Date: Wed, 09 Feb 2005 16:06:33 -0500

Sorry to continue ask these questions to the list but I'm still having 
problems getting started with using c-client.  I fixed the callback 
issue, and also found the documentation I was looking for.  Now, I still 
can't make a successful mail_open call to an imap server.  I'm attaching 
the code I have so far and will paste the error message here.  Also, if 
anyone has a simple example of opening a mailbox and just accessing data 
from it that would be great.

Errror:
Can't open mailbox {pc1267.rtctel.com}inbox: invalid remote specification

#include <stdio.h>
#include <stdlib.h>
#include <c-client/mail.h>

void mm_searched (MAILSTREAM *stream,unsigned long number) {
	printf("Called searched: \n");
}

void mm_exists (MAILSTREAM *stream,unsigned long number) {
        printf("Called exists: \n");	
}

void mm_expunged (MAILSTREAM *stream,unsigned long number) {
	printf("Called expunged: \n");
}

void mm_flags (MAILSTREAM *stream,unsigned long number) {
	printf("Called flags: \n");
}

void mm_notify (MAILSTREAM *stream,char *string,long errflg) {
	printf("Called notify: \n");
}

void mm_list (MAILSTREAM *stream,int delimiter,char *name,long attributes) {
	printf("Called list: \n");
}

void mm_lsub (MAILSTREAM *stream,int delimiter,char *name,long attributes) {
	printf("Called lsub: \n");
}

void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status) {
	printf("Called status: \n");
}

void mm_log (char *string,long errflg) {
	printf("%s:\n", string);
}

void mm_dlog (char *string) {
	printf("Called dlog: \n");
}

void mm_login (NETMBX *mb,char *user,char *pwd,long trial) {
	printf("Called login: \n");
}

void mm_critical (MAILSTREAM *stream) {
	printf("Called critical: \n");
}

void mm_nocritical (MAILSTREAM *stream) {
	printf("Called nocritical: \n");
}

long mm_diskerror (MAILSTREAM *stream,long errcode,long serious) {
	printf("Called diskerror: \n");
}

void mm_fatal (char *string) {
	printf("Called fatal: \n");
}

int main(int argc, char *argv[]) {

	MAILSTREAM *stream = NIL;
	DRIVER *driver = NIL;

	if(argc < 2) {
		printf("usage: %s mailbox\n", argv[0]);
		return 0;
	}

	if((stream = mail_open(NIL, "{pc1267.rtctel.com/user=cmcbee}inbox", 0)) == NIL) {
		return 0;
	}

	mail_close(stream);

	return 0;
}

---

From: Mark Crispin <[email-masked]>
Date: Wed, 9 Feb 2005 13:16:43 -0800 (Pacific Standard Time)

You need to have the statement

#include "linkage.c"

early in your program's main() function.

You will have to write some code for those callbacks instead of just 
having dummy routines.  In particular, mail_open() on an IMAP mailbox 
isn't likely to work without at least code for mm_login().

There are several programs in the IMAP toolkit which should be used as a 
model.  In particular, look at the source code for mtest and mailutil. 
For a more advanced example, look at the source code for imapd.

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.
Si vis pacem, para bellum.