Summary: Isode provides a number of APIs which allow integrators and product developers to build components that access the Isode Messaging server products or other products supporting the same protocols.
x400_mtsend_rep.c
1 /* Copyright (c) 2004-2013, Isode Limited, London, England.
2  * All rights reserved.
3  *
4  * Acquisition and use of this software and related materials for any
5  * purpose requires a written licence agreement from Isode Limited,
6  * or a written licence from an organisation licenced by Isode Limited
7  * to grant such a licence.
8  *
9  */
10 
11 /*
12  *
13  * @VERSION@
14  * Simple example program for transferring a report into the MTA
15  *
16  */
17 
18 #include <stdio.h>
19 #include <stdlib.h>
20 
21 #include <x400_mtapi.h>
22 #include "example.h"
23 
24 /* local functions */
25 static int send_report (
26  int drtype
27 );
28 static int add_recips_positive(
29  struct X400mtMessage *mp
30 );
31 static int add_recips_negative(
32  struct X400mtMessage *mp
33 );
34 static int build_env(
35  struct X400mtMessage *mp
36 );
37 static int add_env_recip_info(
38  struct X400Recipient *rp
39 );
40 static void usage(void);
41 
42 static int rno = 1;
43 
44 static int do_redi_hist(
45  struct X400Recipient *rp
46 );
47 
48 static int do_redi_hist_env(
49  struct X400mtMessage *msg
50 );
51 
52 static void do_origandl(
53  struct X400mtMessage *msg
54 );
55 
56 
57 /* These are the data items used */
58 
59 /* The O/R addresses used are intended to be compatible with those
60  * used in the quick install scripts mktailor.tcl, and createmhs.tcl.
61  * Change this value to the name of your host. */
62 #define HOSTNAME "dhcp-164"
63 
64 static char *optstr = "uo:O:r:g:G:c:l:R:y:C:iaqsAv";
65 
66 /* this value is used for the originator of the message */
67 static const char orig_s[] = "/S=x400test-orig/OU="HOSTNAME"/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
68 static const char *orig = orig_s;
69 
70 /* default recipients */
71 static const char recip_s[] = "/S=x400test-recip2/OU="HOSTNAME"/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
72 static const char *recip = recip_s;
73 
74 
75 /* default envelope integer values */
76 static int def_content_type = 2;
77 static int def_bool = 0;
78 static int def_priority = 2;
79 
80 /* default envelope string values */
81 static const char def_utc[] = "080924120000";
82 static const char msg_id[] = "/PRMD=TestPRMD/ADMD=TestADMD/C=GB/;"HOSTNAME".2810401-030924.140212";
83 static const char content_id[] = "030924.140212";
84 static const char content_corr[] = "CONTENT-CORROLATOR";
85 static const char latest_del_time[] = "120927120000Z";
86 
87 /* default content integer types */
88 static const int importance = 2;
89 static const int sensitivity = 3;
90 static const int autoforwarded = 1;
91 
92 /* default content string types */
93 static const char text[] = "First line\r\nSecond line\r\n";
94 static const char ipm_id[] = "1064400656.24922*";
95 static const char ipm_rep_id[] = "1064400656.24923*";
96 static const char ipm_obs_id[] = "1064400656.24924*";
97 static const char ipm_rel_id[] = "1064400656.24925*";
98 static const char orig_ref[] = "orig-ref-val";
99 
103 int main(
104  int argc,
105  char **argv
106 )
107 {
108  int drtype;
109 
110  orig = strdup(x400_default_gw_originator);
111  recip = strdup(x400_default_gw_recipient);
112 
113  if (get_args(argc, argv, optstr)) {
114  usage();
115  exit(-1);
116  }
117 
118  if (x400_channel == NULL) {
119  printf("You must specify an X.400 channel\n");
120  usage();
121  exit(-1);
122  }
123 
124  printf("Delivery Report type (0 = Positive, 1 = Negative): ");
125  drtype = ic_fgetc(x400_contype, stdin);
126  if ((drtype != '0') && (drtype != '1'))
127  exit(1);
128 
129  drtype -= '0';
130 
131  return send_report(drtype);
132 }
133 
134 static int send_report (
135  int drtype
136 )
137 {
138  int status;
139  struct X400mtSession *sp;
140  struct X400mtMessage *mp;
141 
142  if (x400_channel == NULL) {
143  fprintf (stderr, "No x400_channel value set in x400tailor file");
144  exit(1);
145  }
146 
147  /* open a new session */
148  status = X400mtOpen (x400_channel, &sp);
149  if ( status != X400_E_NOERROR ) {
150  fprintf (stderr, "Error in Open: %s\n", X400mtError (status));
151  exit (status);
152  }
153 
154  /* start preparing a new report */
155  status = X400mtMsgNew (sp, X400_MSG_REPORT, &mp);
156  /* Should report all errors as above */
157  if ( status != X400_E_NOERROR ) exit (status);
158 
159  /* setup originator using a single string */
160  status = X400mtMsgAddStrParam (mp, X400_S_OR_ADDRESS, orig, -1);
161  if ( status != X400_E_NOERROR ) exit (status);
162 
163  /* add various envelope and header recipients into the report */
164  if (drtype == 0)
165  status = add_recips_positive(mp);
166  else
167  status = add_recips_negative(mp);
168  if ( status != X400_E_NOERROR ) exit (status);
169 
170 #define ADD_TRACE_INFO 1
171 #ifdef ADD_TRACE_INFO
172  {
173  struct X400TraceInfo *info1; /*Will contain all trace information */
174 
175  status = X400mtTraceInfoNew(mp,&info1,X400_SUBJECT_TRACE_INFO);
176  if (status !=X400_E_NOERROR) {
177  fprintf(stderr,"Failed to allocate new trace info object \n");
178  exit(status);
179  }
180 
181 
182  status = X400TraceInfoAddStrParam (info1,
184  "/PRMD=wibble/ADMD=TestADMD/C=GB/",
185  -1);
186  if (status !=X400_E_NOERROR) {
187  fprintf(stderr,
188  "Failed to add X400_S_GLOBAL_DOMAIN_ID to trace info\n");
189  exit(status);
190  }
191 
192  status = X400TraceInfoAddStrParam (info1,
194  "071121125704Z",
195  -1);
196  if (status !=X400_E_NOERROR) {
197  fprintf(stderr,
198  "Failed to add X400_S_DSI_ARRIVAL_TIME to trace info\n");
199  exit(status);
200  }
201 
202  /*Add optional*/
203  status = X400TraceInfoAddStrParam (info1,
205  "/PRMD=atmpdom/ADMD=TestADMD/C=GB/",
206  -1);
207  if (status !=X400_E_NOERROR) {
208  fprintf(stderr,
209  "Failed to add X400_S_DSI_ATTEMPTED_DOMAIN to trace info\n");
210  exit(status);
211  }
212 
213 
214  /*Add optional*/
215  status = X400TraceInfoAddStrParam (info1,
217  "071122125704Z",
218  -1);
219  if (status !=X400_E_NOERROR) {
220  fprintf(stderr,
221  "Failed to add X400_S_DSI_AA_DEF_TIME to trace info\n");
222  exit(status);
223  }
224  }
225 #endif
226 
227  /* build rest of the report envelope */
228  status = build_env(mp);
229  if ( status != X400_E_NOERROR ) exit (status);
230 
231 
232  /* send the report */
233  status = X400mtMsgSend (mp);
234  if ( status != X400_E_NOERROR ) {
235  fprintf (stderr, "Error in MsgSend: %s\n", X400mtError (status));
236  exit (status);
237  }
238 
239  /* delete the message structure */
240  status = X400mtMsgDelete (mp);
241  if ( status != X400_E_NOERROR ) exit (status);
242 
243  mp = NULL;
244 
245  /* close the API session */
246  return X400mtClose (sp);
247 }
248 
249 static int add_recips_positive(
250  struct X400mtMessage *mp
251 )
252 {
253  struct X400Recipient *rp;
254  int status;
255 
256  /* add new recipient to the report envelope */
257  status = X400mtRecipNew (mp, X400_RECIP_ENVELOPE, &rp);
258  if ( status != X400_E_NOERROR ) return (status);
259  /* give recip an address */
260  status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip, -1);
261  if ( status != X400_E_NOERROR ) return (status);
262  /* add other values to recip */
263  status = add_env_recip_info (rp);
264  if ( status != X400_E_NOERROR ) return (status);
265 
266  /* add new recipient to the report content */
267  status = X400mtRecipNew (mp, X400_RECIP_REPORT, &rp);
268  if ( status != X400_E_NOERROR ) return (status);
269  /* give recip an address */
270  status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip, -1);
271  if ( status != X400_E_NOERROR ) return (status);
272  /* add other values to recip */
273  status = add_env_recip_info (rp);
274  if ( status != X400_E_NOERROR ) return (status);
275 
276  /* add the arrival time for this recipient */
277  status = X400mtRecipAddStrParam (rp, X400_S_ARRIVAL_TIME, "070701140026+0100", -1);
278  if ( status != X400_E_NOERROR ) {
279  fprintf (stderr, "X400mtMsgAddStrParam returned error: %s\n", X400mtError (status));
280  return (status);
281  }
282 
283  /* add the delivery time for this recipient (positive dr) */
284  status = X400mtRecipAddStrParam (rp, X400_S_MESSAGE_DELIVERY_TIME, "040701140026+0100", -1);
285  if ( status != X400_E_NOERROR ) {
286  fprintf (stderr, "X400mtMsgAddStrParam returned error: %s\n", X400mtError (status));
287  return (status);
288  }
289 
290  /* add the CEIT for this recipient */
292  if ( status != X400_E_NOERROR ) {
293  fprintf (stderr, "X400mtMsgAddStrParam returned error: %s\n", X400mtError (status));
294  return (status);
295  }
296 #define USE_REDIRECTION_HISTORY 1
297 #ifdef USE_REDIRECTION_HISTORY
298  /* Add redirection history for this recipient (8.3.1.1.1.5)*/
299  do_redi_hist(rp);
300 
301 
302 #endif
303 
304  return X400_E_NOERROR;
305 }
306 
307 
308 static int add_recips_negative(
309  struct X400mtMessage *mp
310 )
311 {
312  struct X400Recipient *rp;
313  int status;
314 
315  /* add new recipient to the report envelope */
316  status = X400mtRecipNew (mp, X400_RECIP_ENVELOPE, &rp);
317  if ( status != X400_E_NOERROR ) return (status);
318  /* give recip an address */
319  status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip, -1);
320  if ( status != X400_E_NOERROR ) return (status);
321  /* add other values to recip */
322  status = add_env_recip_info (rp);
323  if ( status != X400_E_NOERROR ) return (status);
324 
325  /* add new recipient to the report content */
326  status = X400mtRecipNew (mp, X400_RECIP_REPORT, &rp);
327  if ( status != X400_E_NOERROR ) return (status);
328  /* give recip an address */
329  status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip, -1);
330  if ( status != X400_E_NOERROR ) return (status);
331  /* add other values to recip */
332  status = add_env_recip_info (rp);
333  if ( status != X400_E_NOERROR ) return (status);
334 
335  /* add the arrival time for this recipient */
336  status = X400mtRecipAddStrParam (rp, X400_S_ARRIVAL_TIME, "070701140026+0100", -1);
337  if ( status != X400_E_NOERROR ) {
338  fprintf (stderr, "X400mtMsgAddStrParam returned error: %s\n", X400mtError (status));
339  return (status);
340  }
341 
342  /* add the supplementary info for this recipient (negative dr) */
343  status = X400mtRecipAddStrParam (rp, X400_S_SUPPLEMENTARY_INFO, "Couldn't delivery message", -1);
344  if ( status != X400_E_NOERROR ) {
345  fprintf (stderr, "X400mtMsgAddStrParam returned error: %s\n", X400mtError (status));
346  return (status);
347  }
348 
349  /* add the non-delivery reason for this recipient (negative dr) */
351  if ( status != X400_E_NOERROR ) {
352  fprintf (stderr, "X400mtMsgAddIntParam returned error: %s\n", X400mtError (status));
353  return (status);
354  }
355 
356  /* add the non-delivery diagnostic for this recipient (negative dr) */
358  if ( status != X400_E_NOERROR ) {
359  fprintf (stderr, "X400mtMsgAddIntParam returned error: %s\n", X400mtError (status));
360  return (status);
361  }
362 
363  return X400_E_NOERROR;
364 }
365 
366 static int build_env(
367  struct X400mtMessage *mp
368 )
369 {
370  int status;
371 
372  /* Envelope Attributes */
373 
374  /* Content Type: 2 or 22 */
375  status = X400mtMsgAddIntParam (mp, X400_N_CONTENT_TYPE, def_content_type);
376  if ( status != X400_E_NOERROR ) return (status);
377 
378  /* X400_N_CONTENT_LENGTH is probe only */
379 
380  /* Priority: 0 - normal, 1 - non-urgent, 2 - urgent */
381  status = X400mtMsgAddIntParam (mp, X400_N_PRIORITY, def_priority);
382  if ( status != X400_E_NOERROR ) return (status);
383 
384  /* Disclosure of recipients: 0 - no, 1 - yes */
385  status = X400mtMsgAddIntParam (mp, X400_N_DISCLOSURE, 1);
386  if ( status != X400_E_NOERROR ) return (status);
387 
388  /* Implicit conversion prohibited: 0 - no, 1 - yes */
390  if ( status != X400_E_NOERROR ) return (status);
391 
392  /* Alternate recipient allowed: 0 - no, 1 - yes */
394  if ( status != X400_E_NOERROR ) return (status);
395 
396  /* Content return request: 0 - no, 1 - yes */
397  /* hmm - 1 is headers - what does that do in X.400 ? */
399  if ( status != X400_E_NOERROR ) return (status);
400 
401  /* Recipient reassignment prohibited: 0 - no, 1 - yes */
403  if ( status != X400_E_NOERROR ) return (status);
404 
405  /* Distribution List expansion prohibited: 0 - no, 1 - yes */
406  status = X400mtMsgAddIntParam (mp, X400_N_DL_EXPANSION_PROHIBITED, def_bool);
407  if ( status != X400_E_NOERROR ) return (status);
408 
409  /* Conversion with loss prohibited: 0 - no, 1 - yes */
411  if ( status != X400_E_NOERROR ) return (status);
412 
413  /* string params */
414 
415  /* Message Identifier. In RFC 2156 String form */
416  status = X400mtMsgAddStrParam (mp, X400_S_MESSAGE_IDENTIFIER, msg_id, -1);
417  if ( status != X400_E_NOERROR ) return (status);
418 
419  /* Content correlator */
420  status = X400mtMsgAddStrParam (mp, X400_S_CONTENT_CORRELATOR_IA5_STRING, content_corr, -1);
421  if ( status != X400_E_NOERROR ) return (status);
422 
423  /* Content Identifier */
424  status = X400mtMsgAddStrParam (mp, X400_S_CONTENT_IDENTIFIER, content_id, -1);
425  if ( status != X400_E_NOERROR ) return (status);
426 
427  /* Subject Identifier, the Message Identifier of the original message */
428  status = X400mtMsgAddStrParam (mp, X400_S_SUBJECT_IDENTIFIER, msg_id, -1);
429  if ( status != X400_E_NOERROR ) return (status);
430 
431  /*
432  * X400_S_ORIGINAL_ENCODED_INFORMATION_TYPES
433  * X400_S_MESSAGE_SUBMISSION_TIME
434  * X400_S_MESSAGE_DELIVERY_TIME
435  * are read only, so don't add them
436  */
437 
438  /* Latest Delivery Time: UTCTime format YYMMDDHHMMSS<zone> */
439  status = X400mtMsgAddStrParam (mp, X400_S_LATEST_DELIVERY_TIME, latest_del_time, -1);
440  if ( status != X400_E_NOERROR ) return (status);
441 
442 
443 #ifdef USE_REDIRECTION_HISTORY
444  /*Add redirection history for the envelope (8.3.1.2.1.5) */
445  do_redi_hist_env(mp);
446 #endif
447 
448  do_origandl(mp);
449 
450  /* all OK */
451  return X400_E_NOERROR;
452 }
453 
454 
455 static int add_env_recip_info(
456  struct X400Recipient *rp
457 )
458 {
459  int status;
460 
461  /* add attributes to recipient in envelope */
463  if ( status != X400_E_NOERROR ) return (status);
464 
466  if ( status != X400_E_NOERROR ) return (status);
467 
469  if ( status != X400_E_NOERROR ) return (status);
470 
472  rno++;
473  if ( status != X400_E_NOERROR ) return (status);
474 
475  return X400_E_NOERROR;
476 }
477 
478 
479 static void usage(void) {
480  printf("usage: %s\n", optstr);
481  printf("\t where:\n");
482  printf("\t -u : Don't prompt to override defaults \n");
483  printf("\t -o : Originator \n");
484  printf("\t -O : Originator Return Address \n");
485  printf("\t -r : Recipient\n");
486  printf("\t -c : X.400 passive channel\n");
487  printf("\t -l : Logline\n");
488  printf("\t -R : Reports (0 - never, 1 - always, 2 - always NDR \n");
489  printf("\t -y : Priority (0 - normal, 1 - non-urgent, 2 - urgent \n");
490  printf("\t -C : Content Type (2/22/772/OID) \n");
491  printf("\t -i : Implicit conversion prohibited = TRUE \n");
492  printf("\t -a : Alternate Recipient Prohibited = TRUE \n");
493  printf("\t -q : Content Return Request = TRUE \n");
494  printf("\t -s : Disclosure of Recipient = FALSE \n");
495  printf("\t -A : Recipient Reassignment Prohibited = FALSE \n");
496  printf("\t -v : Conversion with Loss Prohibited = FALSE \n");
497  return;
498 }
499 
500 
501 static int do_redi_hist(
502  struct X400Recipient *rp
503 )
504  {
505  struct X400RediHist *hist1;
506  struct X400RediHist *hist2;
507  int status;
508 
509  status = X400RediHistNew(rp,&hist1);
510  if (status !=X400_E_NOERROR) {
511  fprintf(stderr,"Failed to allocate new trace info object \n");
512  exit(status);
513  }
514 
515  /* Add Redirection History time */
516  status = X400RediHistAddStrParam (hist1,
518  "071121125704Z",
519  -1);
520  if (status !=X400_E_NOERROR) {
521  fprintf(stderr,
522  "Failed to add X400_S_REDIRECTION_TIME to Redirection Hist\n");
523  exit(status);
524  }
525 
526  status = X400RediHistAddStrParam (hist1,
528  "/cn=redihist/prmd=TestPRMD/admd=TestPRMD/C=gb",
529  -1);
530  if (status !=X400_E_NOERROR) {
531  fprintf(stderr,
532  "Failed to add X400_S_OR_ADDRESS to Redirection Hist\n");
533  exit(status);
534  }
535 
536  status = X400RediHistAddStrParam (hist1,
538  "CN=redihist,c=GB",
539  -1);
540  if (status !=X400_E_NOERROR) {
541  fprintf(stderr,
542  "Failed to add X400_S_DIRECTORY_NAME to Redirection Hist\n");
543  exit(status);
544  }
545 
546 
547  status = X400RediHistAddIntParam(hist1,
549  X400_RR_ALIAS);
550  if (status !=X400_E_NOERROR) {
551  fprintf(stderr,
552  "Failed to add X400_N_REDIRECTION_REASON to trace info\n");
553  exit(status);
554  }
555 
556  /*hist2*/
557 
558  status = X400RediHistNew(rp,&hist2);
559  if (status !=X400_E_NOERROR) {
560  fprintf(stderr,"Failed to allocate new trace info object \n");
561  exit(status);
562  }
563 
564  /* Add Redirection History time */
565  status = X400RediHistAddStrParam (hist2,
567  "071121125714Z",
568  -1);
569  if (status !=X400_E_NOERROR) {
570  fprintf(stderr,
571  "Failed to add X400_S_REDIRECTION_TIME to Redirection Hist\n");
572  exit(status);
573  }
574 
575  status = X400RediHistAddStrParam (hist2,
577  "/cn=redihist2/prmd=TestPRMD/admd=TestPRMD/C=gb",
578  -1);
579  if (status !=X400_E_NOERROR) {
580  fprintf(stderr,
581  "Failed to add X400_S_OR_ADDRESS to Redirection Hist\n");
582  exit(status);
583  }
584 
585  status = X400RediHistAddStrParam (hist2,
587  "CN=redihist2,c=GB",
588  -1);
589  if (status !=X400_E_NOERROR) {
590  fprintf(stderr,
591  "Failed to add X400_S_DIRECTORY_NAME to Redirection Hist\n");
592  exit(status);
593  }
594 
595 
596  status = X400RediHistAddIntParam(hist2,
599  if (status !=X400_E_NOERROR) {
600  fprintf(stderr,
601  "Failed to add X400_N_REDIRECTION_REASON to "
602  "Redirection Hist\n");
603  exit(status);
604  }
605  return X400_E_NOERROR;
606 }
607 
608 static int do_redi_hist_env(
609  struct X400mtMessage *msg
610 )
611  {
612  struct X400RediHist *hist1;
613  struct X400RediHist *hist2;
614  int status;
615 
616  status = X400mtRediHistNewEnv(msg,&hist1);
617  if (status !=X400_E_NOERROR) {
618  fprintf(stderr,"Failed to allocate new trace info object \n");
619  exit(status);
620  }
621 
622  /* Add Redirection History time */
623  status = X400RediHistAddStrParam (hist1,
625  "071121125704Z",
626  -1);
627  if (status !=X400_E_NOERROR) {
628  fprintf(stderr,
629  "Failed to add X400_S_REDIRECTION_TIME to Redirection Hist\n");
630  exit(status);
631  }
632 
633  status = X400RediHistAddStrParam (hist1,
635  "/cn=redihist/prmd=TestPRMD/admd=TestPRMD/C=gb",
636  -1);
637  if (status !=X400_E_NOERROR) {
638  fprintf(stderr,
639  "Failed to add X400_S_OR_ADDRESS to Redirection Hist\n");
640  exit(status);
641  }
642 
643  status = X400RediHistAddStrParam (hist1,
645  "CN=redihist,c=GB",
646  -1);
647  if (status !=X400_E_NOERROR) {
648  fprintf(stderr,
649  "Failed to add X400_S_DIRECTORY_NAME to Redirection Hist\n");
650  exit(status);
651  }
652 
653 
654  status = X400RediHistAddIntParam(hist1,
656  X400_RR_ALIAS);
657  if (status !=X400_E_NOERROR) {
658  fprintf(stderr,
659  "Failed to add X400_N_REDIRECTION_REASON to trace info\n");
660  exit(status);
661  }
662 
663  /*hist2*/
664 
665  status = X400mtRediHistNewEnv(msg,&hist2);
666  if (status !=X400_E_NOERROR) {
667  fprintf(stderr,"Failed to allocate new trace info object \n");
668  exit(status);
669  }
670 
671  /* Add Redirection History time */
672  status = X400RediHistAddStrParam (hist2,
674  "071121125714Z",
675  -1);
676  if (status !=X400_E_NOERROR) {
677  fprintf(stderr,
678  "Failed to add X400_S_REDIRECTION_TIME to Redirection Hist\n");
679  exit(status);
680  }
681 
682  status = X400RediHistAddStrParam (hist2,
684  "/cn=redihist2/prmd=TestPRMD/admd=TestPRMD/C=gb",
685  -1);
686  if (status !=X400_E_NOERROR) {
687  fprintf(stderr,
688  "Failed to add X400_S_OR_ADDRESS to Redirection Hist\n");
689  exit(status);
690  }
691 
692  status = X400RediHistAddStrParam (hist2,
694  "CN=redihist2,c=GB",
695  -1);
696  if (status !=X400_E_NOERROR) {
697  fprintf(stderr,
698  "Failed to add X400_S_DIRECTORY_NAME to Redirection Hist\n");
699  exit(status);
700  }
701 
702 
703  status = X400RediHistAddIntParam(hist2,
706  if (status !=X400_E_NOERROR) {
707  fprintf(stderr,
708  "Failed to add X400_N_REDIRECTION_REASON to "
709  "Redirection Hist\n");
710  exit(status);
711  }
712  return X400_E_NOERROR;
713 }
714 
715 static void do_origandl(
716  struct X400mtMessage *msg
717 )
718 {
719  struct X400ORandDL *or_and_dl1;
720  struct X400ORandDL *or_and_dl2;
721 
722  const char *origin_or_address = "/cn=origandlorig/prmd=TestPRMD/admd=TestPRMD/C=gb/";
723  const char *origin_dn_address = "CN=origandlorig,c=GB";
724  int status;
725 
726  status = X400mtORandDLNew(msg,&or_and_dl1);
727  if (status !=X400_E_NOERROR) {
728  fprintf(stderr,"Failed to allocate new OR Address and DL "
729  "expansion object \n");
730  exit(status);
731  }
732 
733  /* Add Origin or expansion time */
734  status = X400ORandDLAddStrParam (or_and_dl1,
736  "071121125704Z",
737  -1);
738  if (status != X400_E_NOERROR) {
739  fprintf(stderr,
740  "Failed to add X400_S_ORIG_OR_EXAP_TIME "
741  "to X400ORandDL\n");
742  exit(status);
743  }
744 
745  /* originator or dl_name */
746 
747  /* Add Origin or expansion time */
748  status = X400ORandDLAddStrParam (or_and_dl1,
750  origin_or_address,
751  -1);
752  if (status != X400_E_NOERROR) {
753  fprintf(stderr,
754  "Failed to add X400_S_OR_ADDRESS "
755  "to X400ORandDL\n");
756  exit(status);
757  }
758 
759 
760  status = X400ORandDLAddStrParam (or_and_dl1,
762  origin_dn_address,
763  -1);
764  if (status != X400_E_NOERROR) {
765  fprintf(stderr,
766  "Failed to add X400_S_DIRECTORY_NAME "
767  "to X400ORandDL\n");
768  exit(status);
769  }
770  status = X400mtORandDLNew(msg,&or_and_dl2);
771  if (status !=X400_E_NOERROR) {
772  fprintf(stderr,"Failed to allocate new OR Address and DL "
773  "expansion object \n");
774  exit(status);
775  }
776 
777  /* Add Origin or expansion time */
778  status = X400ORandDLAddStrParam (or_and_dl2,
780  "091121125704Z",
781  -1);
782  if (status != X400_E_NOERROR) {
783  fprintf(stderr,
784  "Failed to add X400_S_ORIG_OR_EXAP_TIME "
785  "to X400ORandDL\n");
786  exit(status);
787  }
788 
789  /* originator or dl_name */
790 
791  /* Add Origin or expansion time */
792  status = X400ORandDLAddStrParam (or_and_dl2,
794  origin_or_address,
795  -1);
796  if (status != X400_E_NOERROR) {
797  fprintf(stderr,
798  "Failed to add X400_S_OR_ADDRESS "
799  "to X400ORandDL\n");
800  exit(status);
801  }
802 
803 
804  status = X400ORandDLAddStrParam (or_and_dl2,
806  origin_dn_address,
807  -1);
808  if (status != X400_E_NOERROR) {
809  fprintf(stderr,
810  "Failed to add X400_S_DIRECTORY_NAME "
811  "to X400ORandDL\n");
812  exit(status);
813  }
814 }
#define X400_S_DIRECTORY_NAME
Definition: x400_att.h:394
#define X400_RR_ALIAS
Definition: x400_att.h:1519
#define X400_S_ORIG_OR_EXAP_TIME
Definition: x400_att.h:965
#define X400_S_CONVERTED_ENCODED_INFORMATION_TYPES
Definition: x400_att.h:690
#define X400_N_IMPLICIT_CONVERSION_PROHIBITED
Definition: x400_att.h:427
#define X400_S_SUBJECT_IDENTIFIER
Definition: x400_att.h:1027
#define X400_S_CONTENT_IDENTIFIER
Definition: x400_att.h:411
X400COMMON_CDECL int X400RediHistAddIntParam(struct X400RediHist *hist, int paramtype, int value)
Set an integer value in a Redirection History object.
int X400mtOpen(const char *credentials, struct X400mtSession **spp)
Open a session to the MTA.
#define X400_S_ARRIVAL_TIME
Definition: x400_att.h:1036
int X400mtMsgNew(struct X400mtSession *sp, int type, struct X400mtMessage **mpp)
Creates new message.
#define X400_N_RESPONSIBILITY
Definition: x400_att.h:639
#define X400_N_DL_EXPANSION_PROHIBITED
Definition: x400_att.h:455
#define X400_SUBJECT_TRACE_INFO
Definition: x400_att.h:1319
#define X400_S_CONTENT_CORRELATOR_IA5_STRING
Definition: x400_att.h:514
#define X400_S_SUPPLEMENTARY_INFO
Definition: x400_att.h:1030
#define X400_S_DSI_ARRIVAL_TIME
Definition: x400_att.h:481
X.400 Gateway Interface.
X400COMMON_CDECL int X400ORandDLAddStrParam(struct X400ORandDL *or_and_dl, int type, const char *value, size_t length)
Add string parameter for a Originator and DL Expansion History object.
#define X400_N_CONVERSION_WITH_LOSS_PROHIBITED
Definition: x400_att.h:458
int X400mtRecipNew(struct X400mtMessage *mp, int type, struct X400Recipient **rpp)
Add new recipient to a message.
#define X400_N_RECIPIENT_REASSIGNMENT_PROHIBITED
Definition: x400_att.h:452
#define X400_MSG_REPORT
Definition: x400_att.h:32
int X400mtRediHistNewEnv(struct X400mtMessage *msg, struct X400RediHist **hist)
Create a new Redirection History object for a message envelope this is represented by 8...
int X400mtMsgAddIntParam(struct X400mtMessage *mp, int paramtype, int value)
Add integer-valued parameter to the message.
#define X400_E_NOERROR
Definition: x400_att.h:46
int X400mtRecipAddStrParam(struct X400Recipient *rp, int paramtype, const char *value, size_t length)
Add string-valued parameter to the message.
int X400mtRecipAddIntParam(struct X400Recipient *rp, int paramtype, int value)
Add integer-valued parameter to the message.
#define X400_S_REDIRECTION_TIME
Definition: x400_att.h:508
#define X400_S_OR_ADDRESS
Definition: x400_att.h:346
#define X400_N_CONTENT_TYPE
Definition: x400_att.h:405
#define X400_S_MESSAGE_IDENTIFIER
Definition: x400_att.h:402
const char * X400mtError(int error)
Return string for error code.
int X400mtMsgSend(struct X400mtMessage *mp)
Send message object to MTA.
#define X400_N_DISCLOSURE
Definition: x400_att.h:424
#define X400_S_GLOBAL_DOMAIN_ID
Definition: x400_att.h:478
#define X400_S_LATEST_DELIVERY_TIME
Definition: x400_att.h:461
#define X400_N_REPORT_REQUEST
Definition: x400_att.h:650
int X400mtORandDLNew(struct X400mtMessage *msg, struct X400ORandDL **or_and_dl)
Create new Originator and DL expansion history object.
#define X400_N_NON_DELIVERY_REASON
Definition: x400_att.h:1039
X400COMMON_CDECL int X400TraceInfoAddStrParam(struct X400TraceInfo *info, int paramtype, const char *value, size_t length)
Add string-valued parameter to the X400TraceInfo object.
int X400mtMsgAddStrParam(struct X400mtMessage *mp, int paramtype, const char *value, size_t length)
Add string-valued parameter to the message.
#define X400_N_PRIORITY
Definition: x400_att.h:419
int X400mtClose(struct X400mtSession *sp)
Close a X400 Session.
#define X400_N_ORIGINAL_RECIPIENT_NUMBER
Definition: x400_att.h:636
int X400mtTraceInfoNew(struct X400mtMessage *mp, struct X400TraceInfo **info, int type)
Create a new Trace Info object for a message object.
#define X400_RR_RECIP_ASSIGNED_ALT_RECIP
Definition: x400_att.h:1510
#define X400_N_ALTERNATE_RECIPIENT_ALLOWED
Definition: x400_att.h:430
X400COMMON_CDECL int X400RediHistAddStrParam(struct X400RediHist *hist, int paramtype, const char *value, size_t length)
Add string-valued parameter to the X400RediHist object.
#define X400_RECIP_ENVELOPE
Definition: x400_att.h:332
X400COMMON_CDECL int X400RediHistNew(struct X400Recipient *recip, struct X400RediHist **hist)
Create a new Redirection History object.
#define X400_S_DSI_ATTEMPTED_DOMAIN
Definition: x400_att.h:487
#define X400_N_MTA_REPORT_REQUEST
Definition: x400_att.h:642
#define X400_N_NON_DELIVERY_DIAGNOSTIC
Definition: x400_att.h:1042
#define X400_N_REDIRECTION_REASON
Definition: x400_att.h:505
#define X400_S_DSI_AA_DEF_TIME
Definition: x400_att.h:490
#define X400_N_CONTENT_RETURN_REQUEST
Definition: x400_att.h:433
#define X400_RECIP_REPORT
Definition: x400_att.h:311
int X400mtMsgDelete(struct X400mtMessage *mp)
Delete message object.
#define X400_S_MESSAGE_DELIVERY_TIME
Definition: x400_att.h:439