imclient library - authenticating callback interface to IMAP/IMSP servers
|
int imclient_connect(struct imclient **imclient, const char *host, const char *port); void imclient_close (struct imclient *imclient); void imclient_setflags(struct imclient *imclient, intflags); void imclient_clearflags (struct imclient *imclient, intflags); char* imclient_servername (struct imclient *imclient); |
void imclient_addcallback (struct imclient * imclient ,...);
|
void imclient_send (struct imclient *imclient, void (*finishproc)(), void *finishrock, const char *fmt, ...); void imclient_getselectinfo (struct imclient *imclient, int *fd, int * wanttowrite); void imclient_processoneevent (struct imclient *imclient); int imclient_authenticate (struct imclient *imclient, struct sasl_client **availmech, const char *service, const |
|
The imclient library functions are distributed with Cyrus IMAP and IMSP. These functions are used for building Users must link with the -lcyrus switch, and must supply a function called fatal to be called in case of any error All of the imclient functions begin with the prefix imclient and takes an argument of type struct imclient * as the See below for a description of each function. |
|
Connects the client server to the host. If successful, it returns 0 and sets the imclient argument to a pointer to |
imclient_close()
|
Closes and frees the imclient connection. imclient_setflags() |
imclient_clearflags()
Clears the flags specified by the flags argument on the imclient connection.
Returns a char * pointer to the name of the server connected to by imclient.
|
Adds an untagged data callback to the imclient connection. The function imclient_addcallback takes call- and struct imclient_reply * is defined to be: struct imclient_reply { After the first argument imclient, there can be zero or more instances of the set of keyword, flags, proc, and |
|
rock, each adding or changing a single callback. Each instance adds or changes the callback for keyword. |
imclient_send()
|
Sends a new command to the imclient connection. finishproc and finnishrock are the function and rock %% for % %a for an IMAP atom %s for an astring (which will be quoted or literalized as needed) %d for a decimal %u for an unsigned decimal %v for #astring (argument is a null-terminated array of char * which are written as |
imclient_getselectinfo()
Gets the information for calling select(2). fd is filled in with the file descriptor to select(2) for read. want-
towrite is filled in with a nonzero value if select should be used for write as well.
Processes one input or output event on the imclient connection.
|
Authenticates the imclient connection using one of the mechanisms in availmech. The argument, user, if not On success, 0 is returned. On failure (i.e., "BAD" keyboard, or no authentication mechanisms worked), 1 is |
|
The following code is a possible skeletion of imclient that relies on Kerberos to do authentication. This code pre- struct sasl_client; extern struct sasl_client krb_sasl_client; struct sasl_client *login_sasl_client[] = { |
&krb_sasl_client,
NULL
|
}; void fatal(char* message, int rc) { |
fprintf(stderr, "fatal error: %s\n", message);
exit(rc);
}
static void callback_capability(struct imclient *imclient,
void *rock,
struct imclient_reply *reply) {
|
} |
if (reply->text != NULL) { |
|
static void end_command (struct imclient *connection, void* main() { |
|
char* capability_string; if (imclient_connect(&imclient, server, port)) { if (imclient_authenticate(imclient, login_sasl_client, "imap" imclient_addcallback(imclient, "CAPABILITY", nc = 1; imclient_send(imclient, end_command, while(nc > 0) { if (strstr("LITERAL+", capability_string)) { imclient_send(imclient, NULL, NULL, "LOGOUT"); printf("capability text is: %s\n", capability_string); free(capability_string); |
|||
|
} |
No known bugs.
cyradm, imapd, imspd, RFC2033 (IMAP LITERAL+ extension), RFC2060 (IMAP4rev1 specification), and
IMAP, ACAP, IMSP, Kerberos, Authentication
Copyright 1997-2002, Carnegie Mellon University. All Rights Reserved. See the source distribution for copying information.