46 #include <sys/types.h>
58 #if defined(__GNUC__) || defined (__GNUG__)
59 #define IC_ATTRIBUTE(x) __attribute__ (x)
61 #define IC_ATTRIBUTE(x)
67 #if (defined(__GNUG__) && __GNUG__ >= 4) || (!defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 3)
68 # define ARGNOTUSED IC_ATTRIBUTE((unused))
73 char *orig =
"/CN=GatewayUser/OU=Sales/OU=dhcp-164/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
74 char *recip =
"/CN=GatewayUser/OU=Sales/OU=dhcp-164/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
76 static void send_hello_world(
77 struct X400mtSession *sp
80 static void receive_hello_world(
81 struct X400mtSession *sp
84 int main (
int argc ARGNOTUSED,
char ** argv ARGNOTUSED)
87 struct X400mtSession *sp;
99 fprintf (stderr,
"Error in Open: %s\n",
X400mtError (status));
127 send_hello_world(sp);
132 receive_hello_world(sp);
136 fprintf (stderr,
"Error in Close: %s\n",
X400mtError (status));
160 static void send_hello_world(
161 struct X400mtSession *sp
167 struct X400mtMessage *mp;
168 struct X400Recipient *rp;
171 printf(
"Now sending simple message\n");
180 fprintf (stderr,
"Error in MsgNew: %s\n",
X400mtError (status));
192 fprintf (stderr,
"Error adding orignator: %s\n",
X400mtError (status));
200 fprintf (stderr,
"Error adding recipient: %s\n",
X400mtError (status));
214 fprintf (stderr,
"Error adding recipient address: %s\n",
227 fprintf (stderr,
"Error adding recipient responsibility: %s\n",
235 fprintf (stderr,
"Error adding Content type : %s\n",
242 char *content =
"Hello World!";
243 char *subj =
"A simple test message";
247 fprintf (stderr,
"Error adding content : %s\n",
254 fprintf (stderr,
"Error adding subject : %s\n",
263 fprintf (stderr,
"Error in MsgSend: %s\n",
X400mtError (status));
270 fprintf (stderr,
"Error in X400mtMsgDelete: %s\n",
X400mtError (status));
274 printf(
"Sent message\n");
278 static void receive_hello_world(
279 struct X400mtSession *sp
282 struct X400mtMessage *mp;
288 printf(
"Now fetching message\n");
292 fprintf (stderr,
"Error in X400mtMsgGetStart: %s\n",
299 printf(
"Got a report\n");
302 printf(
"Got a probe\n");
310 buffer,
sizeof buffer , &length);
312 printf (
"Originator: %.*s\n",(
int)length,buffer);
322 char * big_buff = NULL;
323 big_buff = (
char *) malloc((
sizeof(
char)) * length);
325 big_buff, length , &length);
327 fprintf(stderr,
"Error in getting originator address: %s\n",
331 printf(
"Large Originator: %.*s\n",(
int)length,big_buff);
335 fprintf (stderr,
"Error in getting originator address: %s\n",
349 struct X400Recipient *rp;
350 for ( n = 1; ; n++ ) {
359 printf(
"Got final recipient\n");
362 fprintf (stderr,
"Error fetching recipients: %s\n",
372 buffer, BUFSIZ, &length);
374 printf (
"%s recipient %d: %.*s\n", buffer, n,
375 (
int)length, buffer);
377 fprintf (stderr,
"Error fetching OR Address: %s\n",
392 buffer,
sizeof buffer , &length);
394 printf (
"Subject: %.*s\n", (
int)length, buffer);
396 fprintf (stderr,
"Error fetching subject: %s\n",
408 buffer,
sizeof buffer , &length);
410 printf (
"Text:\n%.*s\n", (
int)length, buffer);
412 fprintf (stderr,
"Error fetching ia5-text bodypart: %s\n",
420 printf(
"X400mtMsgFinish returned error %d\n", status);
421 fprintf (stderr,
"Error in X400mtMsgFinish: %s\n",
428 printf(
"X400mtMsgDelete returned error %d\n", status);
429 fprintf (stderr,
"Error in X400mtMsgDelete: %s\n",
#define X400_S_LOG_CONFIGURATION_FILE
int X400mtSetStrDefault(struct X400mtSession *sp, int paramtype, const char *value, size_t length)
Set a default string parameter value in a session.
int X400mtMsgDelete(struct X400mtMessage *mp)
Delete message object.
int X400mtClose(struct X400mtSession *sp)
Close a X400 Session.
int X400mtMsgGetStart(struct X400mtSession *sp, struct X400mtMessage **mpp, int *typep)
Get message object for transfer out from MTA.
int X400mtMsgGetFinish(struct X400mtMessage *mp, int status, int reason, int diag, const char *info)
Finish transfer-out of message from MTA, generate DR if required.
int X400mtRecipAddStrParam(struct X400Recipient *rp, int paramtype, const char *value, size_t length)
Add string-valued parameter to the message.
int X400mtRecipGet(struct X400mtMessage *mp, int type, int number, struct X400Recipient **rpp)
Get recipient object from message.
int X400mtOpen(const char *credentials, struct X400mtSession **spp)
Open a session to the MTA.
const char * X400mtError(int error)
Return string for error code.
int X400mtRecipNew(struct X400mtMessage *mp, int type, struct X400Recipient **rpp)
Add new recipient to a message.
int X400mtMsgAddStrParam(struct X400mtMessage *mp, int paramtype, const char *value, size_t length)
Add string-valued parameter to the message.
#define X400_RECIP_STANDARD
int X400mtMsgGetStrParam(struct X400mtMessage *mp, int paramtype, char *buffer, size_t buflen, size_t *paramlenp)
Return a string-valued parameter from the message object.
int X400mtMsgAddIntParam(struct X400mtMessage *mp, int paramtype, int value)
Add integer-valued parameter to the message.
int X400mtRecipAddIntParam(struct X400Recipient *rp, int paramtype, int value)
Add integer-valued parameter to the message.
int X400mtMsgNew(struct X400mtSession *sp, int type, struct X400mtMessage **mpp)
Creates new message.
int X400mtMsgSend(struct X400mtMessage *mp)
Send message object to MTA.
int X400mtRecipGetStrParam(struct X400Recipient *rp, int paramtype, char *buffer, size_t buflen, size_t *paramlenp)
Return a string-valued parameter from the recipient object.
#define X400_N_RESPONSIBILITY
#define X400_N_CONTENT_TYPE
#define X400_S_OR_ADDRESS
#define X400_RECIP_ENVELOPE
All rights reserved © 2002 - 2024 Isode Ltd.