48 #include "ms_example.h"
49 #include <sys/types.h>
61 #if defined(__GNUC__) || defined (__GNUG__)
62 #define IC_ATTRIBUTE(x) __attribute__ (x)
64 #define IC_ATTRIBUTE(x)
70 #if (defined(__GNUG__) && __GNUG__ >= 4) || (!defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 3)
71 # define ARGNOTUSED IC_ATTRIBUTE((unused))
78 #define HOSTNAME "dhcp-164"
79 #define FQ_HOSTNAME HOSTNAME".isode.net"
81 char *orig =
"/CN=P7User1/OU=Sales/O="HOSTNAME
"/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
82 char *recip =
"/CN=P7User2/OU=Sales/O="HOSTNAME
"/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
83 char *ms_pa =
"\"3001\"/Internet="FQ_HOSTNAME
"+3001";
85 char *password =
"secret";
87 static void send_hello_world(
88 struct X400msSession *sp
91 static void receive_msgs(
92 struct X400msSession *sp,
96 int main (
int argc ARGNOTUSED,
char ** argv ARGNOTUSED)
99 struct X400msSession *sp;
106 char *def_dn=
"cn=foobar,c=gb";
113 status =
X400msOpen (contype, orig, def_dn, password, ms_pa, &nummsg, &sp);
115 fprintf (stderr,
"Error in Open: %s\n",
X400msError (status));
143 send_hello_world(sp);
147 fprintf (stderr,
"Error in Close: %s\n",
X400msError (status));
155 status =
X400msOpen (contype, recip, def_dn, password, ms_pa, &nummsg, &sp);
157 fprintf (stderr,
"Error in Open: %s\n",
X400msError (status));
165 receive_msgs(sp,nummsg);
169 fprintf (stderr,
"Error in Close: %s\n",
X400msError (status));
193 static void send_hello_world(
194 struct X400msSession *sp
200 struct X400msMessage *mp;
201 struct X400Recipient *rp;
204 printf(
"Now sending the simple message\n");
213 fprintf (stderr,
"Error in MsgNew: %s\n",
X400msError (status));
225 fprintf (stderr,
"Error adding orignator: %s\n",
X400msError (status));
233 fprintf (stderr,
"Error adding recipient: %s\n",
X400msError (status));
247 fprintf (stderr,
"Error adding recipient address: %s\n",
260 fprintf (stderr,
"Error adding recipient responsibility: %s\n",
267 char *content =
"Hello World!";
268 char *subject =
"A simple test message";
272 fprintf (stderr,
"Error adding content : %s\n",
279 fprintf (stderr,
"Error adding subject : %s\n",
288 fprintf (stderr,
"Error in MsgSend: %s\n",
X400msError (status));
297 fprintf (stderr,
"Error in X400mtMsgDelete: %s\n",
X400msError (status));
301 printf(
"Sent message\n");
305 static void receive_msgs(
306 struct X400msSession *sp,
311 struct X400msMessage *mp;
312 struct X400Recipient *rp;
322 printf (
"no messages - waiting 60 seconds for a message to be delivered.....\n");
325 printf(
"%d messages waiting\n", nummsg);
333 fprintf(stderr,
"Error from Wait: %s\n",
X400msError(status));
343 fprintf(stderr,
"MsgGet successfully got message\n");
346 fprintf(stderr,
"Error from MsgGet: %s\n",
X400msError(status));
358 buffer,
sizeof buffer, &length);
360 fprintf(stderr,
"Error from MsgGetStrParam: %s\n",
364 printf(
"Originator: %.*s\n", (
int)length, buffer);
372 fprintf(stderr,
"Error from RecipGet: %s\n",
X400msError(status));
382 buffer,
sizeof buffer, &length);
384 fprintf(stderr,
"Error from X400msRecipGetStrParam: %s\n",
388 printf(
"Envelope Recipient : %.*s\n", (
int)length, buffer);
394 fprintf (stderr,
"Error in X400msMsgGetIntParam content type: %s\n",
398 printf(
"Content type: %i\n",type);
403 buffer,
sizeof buffer, &length);
405 fprintf (stderr,
"Error in X400msMsgGetStrParam subject: %s\n",
410 printf(
"Subject: %.*s\n", (
int)length, buffer);
416 buffer,
sizeof buffer, &length);
418 fprintf (stderr,
"Error in X400msMsgGetStrParam subject: %s\n",
421 printf(
"Text:\n%.*s\n", (
int)length, buffer);
#define X400_S_LOG_CONFIGURATION_FILE
int X400msMsgSend(struct X400msMessage *mp)
Send message object.
int X400msOpen(int type, const char *oraddr, const char *dirname, const char *credentials, const char *pa, int *messages, struct X400msSession **spp)
Open a session to a Message Store (P7) or MTA (P3) in synchronous mode.
int X400msSetStrDefault(struct X400msSession *sp, int paramtype, const char *value, size_t length)
Set a default string parameter value in a session.
int X400msClose(struct X400msSession *sp)
Close a X400 Session.
int X400msRecipAddIntParam(struct X400Recipient *rp, int paramtype, int value)
Add integer-valued parameter to the message.
int X400msRecipAddStrParam(struct X400Recipient *rp, int paramtype, const char *value, size_t length)
Add string-valued parameter to the message.
int X400msMsgGet(struct X400msSession *sp, int number, struct X400msMessage **mpp, int *typep, int *seqp)
Get message object for transfer out from MS or MTA via P3.
int X400msRecipNew(struct X400msMessage *mp, int type, struct X400Recipient **rpp)
Add new recipient to a message.
const char * X400msError(int error)
Obtain a string describing the meaning of the given error code.
#define X400_RECIP_STANDARD
int X400msMsgNew(struct X400msSession *sp, int type, struct X400msMessage **mpp)
Creates new message.
int X400msWait(struct X400msSession *sp, int seconds, int *count)
Wait for messages to be ready to be read.
int X400msRecipGet(struct X400msMessage *mp, int type, int number, struct X400Recipient **rpp)
Get recipient object from message.
int X400msRecipGetStrParam(struct X400Recipient *rp, int paramtype, char *buffer, size_t buflen, size_t *paramlenp)
Return a string-valued parameter from the recipient object.
X400 MA/MS (P3/P7) Interface.
int X400msMsgGetIntParam(struct X400msMessage *mp, int paramtype, int *valp)
Return a integer-valued parameter from the message object.
int X400msMsgGetStrParam(struct X400msMessage *mp, int paramtype, char *buffer, size_t buflen, size_t *paramlenp)
Return a string-valued parameter from the message object.
int X400msMsgAddStrParam(struct X400msMessage *mp, int paramtype, const char *value, size_t length)
Add string-valued parameter to the message.
#define X400_N_RESPONSIBILITY
#define X400_N_CONTENT_TYPE
#define X400_S_OR_ADDRESS
int X400msMsgDelete(struct X400msMessage *mp, int retain)
Delete message object.
#define X400_RECIP_ENVELOPE