
Messaging and Directory Server software used around the world in the
Government, Military, Aviation and Commercial sectors.
|
x400_mtsend.c00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 #define USE_RAW_CONTENT 1
00136 #undef USE_RAW_CONTENT
00137
00138 #include <stdio.h>
00139 #include <stdlib.h>
00140
00141
00142 #include <x400_mtapi.h>
00143 #include <seclabel_api.h>
00144 #include "example.h"
00145 #include <sys/types.h>
00146 #include <sys/stat.h>
00147 #include <fcntl.h>
00148 #include <errno.h>
00149 #include <time.h>
00150
00151
00152
00153 static int send_msgs(
00154 int argc,
00155 char **argv
00156 ) ;
00157 static int send_msg(
00158 struct X400mtSession *sp
00159 );
00160 static int add_single_recip(
00161 struct X400mtMessage *mp
00162 );
00163 static int add_exempt_address(
00164 struct X400mtMessage *mp
00165 );
00166 static int add_address_list_indicator(
00167 struct X400mtMessage *mp
00168 );
00169
00170 static int add_handling_instructions(
00171 struct X400mtMessage *mp
00172 );
00173
00174 #ifdef add_multi_recips
00175 static int add_multi_recips(
00176 struct X400mtMessage *mp
00177 );
00178 static int add_content_recip_info(
00179 struct X400Recipient *rp,
00180 const char *free_form_name
00181 );
00182 #endif
00183 static int build_env(
00184 struct X400mtMessage *mp
00185 );
00186 static int build_content(
00187 struct X400mtMessage *mp
00188 );
00189 static int add_binary_bp(
00190 struct X400mtMessage *mp
00191 );
00192 static int add_env_recip_info(
00193 struct X400Recipient *rp
00194 );
00195 static void usage(void);
00196
00197 static char * set_latest_del_time(void);
00198 static int rno = 1;
00199 static int fwd_rno = 1;
00200
00201 static int load_ber(
00202 char *filename,
00203 char **output_buffer,
00204 int *buf_len
00205 );
00206 #define ADD_FWD_BODYPART 1
00207 #ifdef ADD_FWD_BODYPART
00208 static int add_fwd_bodypart(
00209 struct X400mtMessage *mp
00210 );
00211
00212 static int build_fwd_env (
00213 struct X400Message *mp
00214 );
00215
00216 static int build_fwd_content (
00217 struct X400Message *mp
00218 );
00219
00220 static int add_fwd_recip(
00221 struct X400Message *mp,
00222 const char *oraddress,
00223 int type
00224 );
00225
00226 static int create_fw_message(
00227 struct X400Message *mp
00228 );
00229
00230 static int add_fwd_content_bodypart (
00231 struct X400mtMessage *mp
00232 );
00233
00234 static int add_dl_exempted_recip_list (
00235 struct X400mtMessage *mp
00236 );
00237
00238 #endif
00239
00240
00241
00242
00243
00244
00245
00246
00247 #define HOSTNAME "dhcp-165"
00248
00249
00250
00251
00252 #define USE_P772_EXTS 1
00253 #ifdef USE_P772_EXTS
00254
00255 #define WANT_EXTERNAL_CONTENT_TYPE 1
00256 #endif
00257 static char *optstr = "uG:O:r:g:G:c:l:R:y:C:iaqsAvf:X:S:";
00258
00259
00260
00261 static const char *orig;
00262
00263 static const char *fwd_orig;
00264 static const char *fwd_recip;
00265
00266 static const char orig_ret_addr[] = "/S=x400test-orig/OU="HOSTNAME"/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
00267
00268
00269
00270 static char *recip;
00271 static char *exemp_recip;
00272
00273 static const char recip2[] = "/S=x400test-recip2/OU="HOSTNAME"/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
00274
00275 static const char badrecip[] = "/S=x400test-recip2/OU=badhost/O=TestOrg/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
00276 static const char auth_orig[] = "/S=x400test-auth-orig/OU="HOSTNAME"/O=TestOrg/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
00277
00278
00279 static const char orar[] = "/S=x400test-orig-orar/OU="HOSTNAME"/O=TestOrg/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
00280
00281
00282 static int def_content_type = 2;
00283 #ifdef WANT_EXTERNAL_CONTENT_TYPE
00284 static char *def_ext_content_type = "1.3.26.0.4406.0.4.1";
00285 #endif
00286 static int def_bool = 0;
00287 static int def_priority = 2;
00288
00289
00290 static const char def_utc[] = "050924120000";
00291
00292 static const char msg_id[] = "/PRMD=TestPRMD/ADMD=TestADMD/C=GB/;"HOSTNAME".2810401";
00293 static const char content_id[] = "030924.140212";
00294 static const char fwd_msg_id[] = "/PRMD=TestFWDPRMD/ADMD=TestADMD/C=GB/;"HOSTNAME".2810401";
00295
00296
00297
00298 static const int importance = 2;
00299 static const int sensitivity = 3;
00300 static const int autoforwarded = 1;
00301
00302
00303 static const char subject[] = "A Test Message";
00304 static const char text[] = "First line\r\nSecond line\r\n";
00305 static const char ipm_id[] = "1064400656.24922*";
00306 static const char ipm_rep_id[] = "1064400656.24923*";
00307 static const char ipm_obs_id[] = "1064400656.24924*";
00308 static const char ipm_rel_id[] = "1064400656.24925*";
00309 static const char orig_ref[] = "orig-ref-val";
00310
00311
00312 #define XML_BUFSIZE 1024
00313 #define STRING_BUFSIZE 1024
00314
00318 int main (
00319 int argc,
00320 char **argv
00321 )
00322 {
00323 return send_msgs (argc, argv);
00324 }
00325
00326 static int send_msgs (
00327 int argc,
00328 char **argv
00329 )
00330 {
00331 int status;
00332 struct X400mtSession *sp;
00333
00334 if (get_args(argc, argv, optstr)) {
00335 usage();
00336 exit(-1);
00337 }
00338
00339 orig = strdup(x400_default_gw_originator);
00340 recip = strdup(x400_default_gw_recipient);
00341 exemp_recip = strdup(x400_default_exempted_recipient);
00342 fwd_orig = strdup(x400_default_fwd_originator);
00343 fwd_recip = strdup(x400_default_fwd_recipient);
00344
00345 if (x400_channel == NULL) {
00346 fprintf (stderr, "No x400_channel value set in x400tailor file");
00347 exit(1);
00348 }
00349
00350
00351 status = X400mtOpen (x400_channel, &sp);
00352 if ( status != X400_E_NOERROR ) {
00353 fprintf (stderr, "Error in Open: %s\n", X400mtError (status));
00354 exit (status);
00355 }
00356
00357
00358 X400mtSetStrDefault(sp, X400_S_LOG_CONFIGURATION_FILE, "x400api.xml", 0);
00359
00360
00361 X400mtSetStrDefault(sp, X400_ADATP3_SEP,"\r\n",-1);
00362
00363
00364 while (num_msgs_to_send-- > 0)
00365 {
00366 status = send_msg(sp);
00367 if ( status != X400_E_NOERROR ) {
00368 fprintf (stderr, "Error in send_msg: %s\n", X400mtError (status));
00369 exit (status);
00370 }
00371 }
00372
00373
00374 return X400mtClose (sp);
00375 }
00376
00377 static int send_msg(
00378 struct X400mtSession *sp
00379 )
00380 {
00381 int status;
00382 struct X400mtMessage *mp;
00383
00384
00385 status = X400mtMsgNew (sp, X400_MSG_MESSAGE, &mp);
00386
00387 if ( status != X400_E_NOERROR ) exit (status);
00388
00389
00390 printf("originator of msg is %s\n", orig);
00391 status = X400mtMsgAddStrParam (mp, X400_S_OR_ADDRESS, orig, -1);
00392 if ( status != X400_E_NOERROR ) exit (status);
00393
00394
00395
00396 status = add_single_recip(mp);
00397 if ( status != X400_E_NOERROR ) exit (status);
00398
00399
00400
00401 status = build_env(mp);
00402 if ( status != X400_E_NOERROR ) exit (status);
00403
00404
00405 status = build_content(mp);
00406 if ( status != X400_E_NOERROR ) exit (status);
00407
00408
00409 status = X400mtMsgSend (mp);
00410 if ( status != X400_E_NOERROR ) {
00411 fprintf (stderr, "Error in MsgSend: %s\n", X400mtError (status));
00412 exit (status);
00413 }
00414
00415
00416 status = X400mtMsgDelete (mp);
00417 if ( status != X400_E_NOERROR ) exit (status);
00418
00419 return status;
00420 }
00421
00422 static int add_single_recip(
00423 struct X400mtMessage *mp
00424 )
00425 {
00426 struct X400Recipient *rp;
00427 int status;
00428
00429 printf("Adding single recip %s\n", recip);
00430
00431 status = X400mtRecipNew (mp, X400_RECIP_STANDARD, &rp);
00432 if ( status != X400_E_NOERROR ) return (status);
00433
00434 status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip, -1);
00435 if ( status != X400_E_NOERROR ) return (status);
00436
00437 status = add_env_recip_info (rp);
00438 if ( status != X400_E_NOERROR ) return (status);
00439
00440
00441 status = add_dl_exempted_recip_list (mp);
00442 if ( status != X400_E_NOERROR ) return (status);
00443
00444
00445 #define USE_REDIRECTION_HISTORY 1
00446 #ifdef USE_REDIRECTION_HISTORY
00447 {
00448 struct X400RediHist *hist1;
00449 struct X400RediHist *hist2;
00450 int status;
00451
00452 status = X400RediHistNew(rp,&hist1);
00453 if (status !=X400_E_NOERROR) {
00454 fprintf(stderr,"Failed to allocate new redirection history object \n");
00455 exit(status);
00456 }
00457
00458
00459 status = X400RediHistAddStrParam (hist1,
00460 X400_S_REDIRECTION_TIME,
00461 "071121125704Z",
00462 -1);
00463 if (status !=X400_E_NOERROR) {
00464 fprintf(stderr,
00465 "Failed to add X400_S_REDIRECTION_TIME to Redirection Hist\n");
00466 exit(status);
00467 }
00468
00469 status = X400RediHistAddStrParam (hist1,
00470 X400_S_OR_ADDRESS,
00471 "/cn=redihist/prmd=TestPRMD/admd=TestPRMD/C=gb",
00472 -1);
00473 if (status !=X400_E_NOERROR) {
00474 fprintf(stderr,
00475 "Failed to add X400_S_OR_ADDRESS to Redirection Hist\n");
00476 exit(status);
00477 }
00478
00479 status = X400RediHistAddStrParam (hist1,
00480 X400_S_DIRECTORY_NAME,
00481 "CN=redihist,c=GB",
00482 -1);
00483 if (status !=X400_E_NOERROR) {
00484 fprintf(stderr,
00485 "Failed to add X400_S_DIRECTORY_NAME to Redirection Hist\n");
00486 exit(status);
00487 }
00488
00489
00490 status = X400RediHistAddIntParam(hist1,
00491 X400_N_REDIRECTION_REASON,
00492 X400_RR_ALIAS);
00493 if (status !=X400_E_NOERROR) {
00494 fprintf(stderr,
00495 "Failed to add X400_N_REDIRECTION_REASON to trace info\n");
00496 exit(status);
00497 }
00498
00499
00500
00501 status = X400RediHistNew(rp,&hist2);
00502 if (status !=X400_E_NOERROR) {
00503 fprintf(stderr,"Failed to allocate new trace info object \n");
00504 exit(status);
00505 }
00506
00507
00508 status = X400RediHistAddStrParam (hist2,
00509 X400_S_REDIRECTION_TIME,
00510 "071121125714Z",
00511 -1);
00512 if (status !=X400_E_NOERROR) {
00513 fprintf(stderr,
00514 "Failed to add X400_S_REDIRECTION_TIME to Redirection Hist\n");
00515 exit(status);
00516 }
00517
00518 status = X400RediHistAddStrParam (hist2,
00519 X400_S_OR_ADDRESS,
00520 "/cn=redihist2/prmd=TestPRMD/admd=TestPRMD/C=gb",
00521 -1);
00522 if (status !=X400_E_NOERROR) {
00523 fprintf(stderr,
00524 "Failed to add X400_S_OR_ADDRESS to Redirection Hist\n");
00525 exit(status);
00526 }
00527
00528 status = X400RediHistAddStrParam (hist2,
00529 X400_S_DIRECTORY_NAME,
00530 "CN=redihist2,c=GB",
00531 -1);
00532 if (status !=X400_E_NOERROR) {
00533 fprintf(stderr,
00534 "Failed to add X400_S_DIRECTORY_NAME to Redirection Hist\n");
00535 exit(status);
00536 }
00537
00538
00539 status = X400RediHistAddIntParam(hist2,
00540 X400_N_REDIRECTION_REASON,
00541 X400_RR_RECIP_ASSIGNED_ALT_RECIP);
00542 if (status !=X400_E_NOERROR) {
00543 fprintf(stderr,
00544 "Failed to add X400_N_REDIRECTION_REASON to "
00545 "Redirection Hist\n");
00546 exit(status);
00547 }
00548
00549 }
00550 #endif
00551
00552 #ifdef USE_P772_EXTS
00553
00554 status = X400mtRecipAddIntParam (rp,
00555 X400_N_ACP127_NOTI_TYPE,
00556 X400_ACP127_NOTI_TYPE_NEG);
00557 if ( status != X400_E_NOERROR ) return (status);
00558
00559
00560 status = X400mtRecipAddIntParam (rp,
00561 X400_N_ACP127_NOTI_TYPE,
00562 X400_ACP127_NOTI_TYPE_POS);
00563 if ( status != X400_E_NOERROR ) return (status);
00564
00565 status = X400mtRecipAddIntParam (rp,
00566 X400_N_ACP127_NOTI_TYPE,
00567 X400_ACP127_NOTI_TYPE_TRANS);
00568 if ( status != X400_E_NOERROR ) return (status);
00569
00570
00571 {
00572 struct X400ACP127Resp *resp = NULL;
00573 struct X400ALI *ali1 = NULL;
00574 struct X400ALI *ali2 = NULL;
00575
00576
00577 status = X400ACP127RespNew(rp,&resp);
00578 if ( status != X400_E_NOERROR ) return (status);
00579
00580
00581
00582 status = X400ACP127RespAddIntParam(resp,X400_ACP127_NOTI_TYPE_NEG);
00583 if ( status != X400_E_NOERROR ) return (status);
00584
00585
00586 status = X400ACP127RespAddIntParam(resp,X400_ACP127_NOTI_TYPE_POS);
00587 if ( status != X400_E_NOERROR ) return (status);
00588
00589
00590 status = X400ACP127RespAddIntParam(resp,X400_ACP127_NOTI_TYPE_TRANS);
00591 if ( status != X400_E_NOERROR ) return (status);
00592
00593
00594
00595 status = X400ACP127RespAddStrParam (resp,
00596 X400_S_ACP127_NOTI_RESP_TIME,
00597 "080101120000+0100",
00598 -1);
00599 if ( status != X400_E_NOERROR ) return (status);
00600
00601
00602
00603 status = X400ACP127RespAddStrParam (resp,
00604 X400_S_ACP127_NOTI_RESP_RECIPIENT,
00605 "ACP127 Recipient",
00606 -1);
00607 if ( status != X400_E_NOERROR ) return (status);
00608
00609
00610 status = X400ACP127RespAddStrParam (resp,
00611 X400_S_ACP127_NOTI_RESP_SUPP_INFO,
00612 "ACP127 supp info",
00613 -1);
00614 if ( status != X400_E_NOERROR ) return (status);
00615
00616
00617 status = X400ACP127RespNewALI (resp,&ali1);
00618 if ( status != X400_E_NOERROR ) return (status);
00619
00620 status = X400ALIAddIntParam (ali1,X400_N_ALI_TYPE,0);
00621 if ( status != X400_E_NOERROR ) return (status);
00622
00623 status = X400ALIAddIntParam (ali1,X400_N_ALI_NOTIFICTAION_REQUEST,0);
00624 if ( status != X400_E_NOERROR ) return (status);
00625
00626 status = X400ALIAddIntParam (ali1,X400_N_ALI_REPLY_REQUEST,1);
00627 if ( status != X400_E_NOERROR ) return (status);
00628
00629 status = X400ALIAddStrParam (ali1, X400_S_IOB_OR_ADDRESS,
00630 "/cn=acp127ali1/PRMD=TestPRMD/ADMD=TestADMD/C=GB", -1);
00631 if ( status != X400_E_NOERROR ) return (status);
00632
00633 status = X400ALIAddStrParam (ali1, X400_S_IOB_DN_ADDRESS,
00634 "cn=acp127ali1,c=gb", -1);
00635 if ( status != X400_E_NOERROR ) return (status);
00636
00637 status = X400ALIAddStrParam (ali1, X400_S_IOB_FREE_FORM_NAME,
00638 "ACP127 Mr Address List Indicator1", -1);
00639 if ( status != X400_E_NOERROR ) return (status);
00640
00641 status = X400ALIAddStrParam (ali1, X400_S_IOB_TEL,"1270123456789",-1);
00642 if ( status != X400_E_NOERROR ) return (status);
00643
00644
00645 status = X400ACP127RespNewALI (resp,&ali2);
00646 if ( status != X400_E_NOERROR ) return (status);
00647
00648 status = X400ALIAddIntParam (ali2,X400_N_ALI_TYPE,1);
00649 if ( status != X400_E_NOERROR ) return (status);
00650
00651 status = X400ALIAddIntParam (ali2,X400_N_ALI_NOTIFICTAION_REQUEST,1);
00652 if ( status != X400_E_NOERROR ) return (status);
00653
00654 status = X400ALIAddIntParam (ali2,X400_N_ALI_REPLY_REQUEST,0);
00655 if ( status != X400_E_NOERROR ) return (status);
00656
00657 status = X400ALIAddStrParam (ali2, X400_S_IOB_OR_ADDRESS,
00658 "/cn=acp127ali2/PRMD=TestPRMD/ADMD=TestADMD/C=GB", -1);
00659 if ( status != X400_E_NOERROR ) return (status);
00660
00661 status = X400ALIAddStrParam (ali2, X400_S_IOB_DN_ADDRESS,
00662 "cn=acp127ali2,c=gb", -1);
00663 if ( status != X400_E_NOERROR ) return (status);
00664
00665 status = X400ALIAddStrParam (ali2, X400_S_IOB_FREE_FORM_NAME,
00666 "ACP127 Mr Address List Indicator2", -1);
00667 if ( status != X400_E_NOERROR ) return (status);
00668
00669 status = X400ALIAddStrParam (ali2, X400_S_IOB_TEL,"1270123456789",-1);
00670 if ( status != X400_E_NOERROR ) return (status);
00671
00672 }
00673
00674 #endif
00675
00676 return X400_E_NOERROR;
00677 }
00678
00679 static int add_exempt_address(
00680 struct X400mtMessage *mp
00681 )
00682 {
00683 struct X400Recipient *rp;
00684 struct X400Recipient *rp2;
00685 int status;
00686 printf("Adding exempted recip %s\n", exemp_recip);
00687
00688 status = X400mtRecipNew (mp, X400_EXEMPTED_ADDRESS, &rp);
00689 if ( status != X400_E_NOERROR ) return (status);
00690
00691 status = X400mtRecipAddStrParam (rp, X400_S_IOB_OR_ADDRESS,
00692 exemp_recip, -1);
00693 if ( status != X400_E_NOERROR ) return (status);
00694
00695 status = X400mtRecipAddStrParam (rp, X400_S_IOB_DN_ADDRESS,
00696 "cn=exemprecip,c=gb", -1);
00697 if ( status != X400_E_NOERROR ) return (status);
00698
00699 status = X400mtRecipAddStrParam (rp, X400_S_IOB_FREE_FORM_NAME,
00700 "Mr Exempted", -1);
00701 if ( status != X400_E_NOERROR ) return (status);
00702
00703 status = X400mtRecipAddStrParam (rp, X400_S_IOB_TEL,
00704 "0123456789", -1);
00705 if ( status != X400_E_NOERROR ) return (status);
00706
00707
00708 status = X400mtRecipNew (mp, X400_EXEMPTED_ADDRESS, &rp2);
00709 if ( status != X400_E_NOERROR ) return (status);
00710
00711 status = X400mtRecipAddStrParam (rp2, X400_S_IOB_OR_ADDRESS,
00712 "/CN=exemp2/PRMD=TestPRMD/ADMD=TestADMD/C=GB", -1);
00713 if ( status != X400_E_NOERROR ) return (status);
00714
00715 return X400_E_NOERROR;
00716 }
00717 static int add_address_list_indicator(
00718 struct X400mtMessage *mp
00719 )
00720 {
00721 struct X400ALI *ali = NULL;
00722 struct X400ALI *ali2 = NULL;
00723 int status;
00724
00725 printf("Adding address list indicators\n");
00726
00727
00728 status = X400mtALINew (mp,&ali);
00729 if ( status != X400_E_NOERROR ) return (status);
00730
00731 status = X400ALIAddIntParam (ali,X400_N_ALI_TYPE,0);
00732 if ( status != X400_E_NOERROR ) return (status);
00733
00734 status = X400ALIAddIntParam (ali,X400_N_ALI_NOTIFICTAION_REQUEST,0);
00735 if ( status != X400_E_NOERROR ) return (status);
00736
00737 status = X400ALIAddIntParam (ali,X400_N_ALI_REPLY_REQUEST,1);
00738 if ( status != X400_E_NOERROR ) return (status);
00739
00740 status = X400ALIAddStrParam (ali, X400_S_IOB_OR_ADDRESS,
00741 "/cn=ALI1/PRMD=TestPRMD/ADMD=TestADMD/C=GB", -1);
00742 if ( status != X400_E_NOERROR ) return (status);
00743
00744 status = X400ALIAddStrParam (ali, X400_S_IOB_DN_ADDRESS,
00745 "cn=ali1,c=gb", -1);
00746 if ( status != X400_E_NOERROR ) return (status);
00747
00748 status = X400ALIAddStrParam (ali, X400_S_IOB_FREE_FORM_NAME,
00749 "Mr Address List Indicator1", -1);
00750 if ( status != X400_E_NOERROR ) return (status);
00751
00752 status = X400ALIAddStrParam (ali, X400_S_IOB_TEL,"0123456789", -1);
00753 if ( status != X400_E_NOERROR ) return (status);
00754
00755
00756 status = X400mtALINew (mp, &ali2);
00757 if ( status != X400_E_NOERROR ) return (status);
00758
00759 status = X400ALIAddStrParam (ali2, X400_S_IOB_OR_ADDRESS,
00760 "/CN=ALI2/PRMD=TestPRMD/ADMD=TestADMD/C=GB", -1);
00761 if ( status != X400_E_NOERROR ) return (status);
00762
00763 status = X400ALIAddIntParam (ali2,X400_N_ALI_TYPE,1);
00764 if ( status != X400_E_NOERROR ) return (status);
00765 status = X400ALIAddStrParam (ali2, X400_S_IOB_OR_ADDRESS,
00766 "/cn=ALI2/PRMD=TestPRMD/ADMD=TestADMD/C=GB", -1);
00767 if ( status != X400_E_NOERROR ) return (status);
00768
00769 status = X400ALIAddStrParam (ali2, X400_S_IOB_DN_ADDRESS,
00770 "cn=ali2,c=gb", -1);
00771 if ( status != X400_E_NOERROR ) return (status);
00772
00773
00774
00775 return X400_E_NOERROR;
00776 }
00777
00778 static int add_handling_instructions(
00779 struct X400mtMessage *mp
00780 )
00781 {
00782 struct X400PSS *pss = NULL;
00783 struct X400PSS *pss2 = NULL;
00784 int status;
00785
00786 printf("Adding handling instructions\n");
00787
00788
00789 status = X400mtPSSNew (mp,X400_S_HANDLING_INSTRUCTIONS,&pss);
00790 if ( status != X400_E_NOERROR ) return (status);
00791
00792
00793 status = X400PSSAddStrParam (pss,
00794 "Handling instruction1",
00795 -1);
00796 if ( status != X400_E_NOERROR ) return (status);
00797
00798
00799 status = X400mtPSSNew (mp,X400_S_HANDLING_INSTRUCTIONS,&pss2);
00800 if ( status != X400_E_NOERROR ) return (status);
00801
00802
00803 status = X400PSSAddStrParam (pss2,
00804 "Handling instruction2",
00805 -1);
00806 if ( status != X400_E_NOERROR ) return (status);
00807
00808
00809 return X400_E_NOERROR;
00810 }
00811
00812 static int add_message_instructions(
00813 struct X400mtMessage *mp
00814 )
00815 {
00816 struct X400PSS *pss = NULL;
00817 struct X400PSS *pss2 = NULL;
00818 int status;
00819
00820 printf("Adding Message instructions\n");
00821
00822
00823 status = X400mtPSSNew (mp,X400_S_MESSAGE_INSTRUCTIONS,&pss);
00824 if ( status != X400_E_NOERROR ) return (status);
00825
00826
00827 status = X400PSSAddStrParam (pss,
00828 "Message instruction1",
00829 -1);
00830 if ( status != X400_E_NOERROR ) return (status);
00831
00832
00833 status = X400mtPSSNew (mp,X400_S_MESSAGE_INSTRUCTIONS,&pss2);
00834 if ( status != X400_E_NOERROR ) return (status);
00835
00836
00837 status = X400PSSAddStrParam (pss2,
00838 "Message instruction2",
00839 -1);
00840 if ( status != X400_E_NOERROR ) return (status);
00841
00842
00843 return X400_E_NOERROR;
00844 }
00845
00846 static int add_dist_codes_sic(
00847 struct X400mtMessage *mp
00848 )
00849 {
00850 struct X400PSS *pss = NULL;
00851 struct X400PSS *pss2 = NULL;
00852 struct X400DistField *distfield1 = NULL;
00853 struct X400DistField *distfield2 = NULL;
00854 int status;
00855
00856 printf("Adding Distribution Codes\n");
00857
00858
00859 status = X400mtPSSNew (mp,X400_S_DIST_CODES_SIC,&pss);
00860 if ( status != X400_E_NOERROR ) return (status);
00861
00862
00863 status = X400PSSAddStrParam (pss,
00864 "dist code 1",
00865 -1);
00866 if ( status != X400_E_NOERROR ) return (status);
00867
00868
00869 status = X400mtPSSNew (mp,X400_S_DIST_CODES_SIC,&pss2);
00870 if ( status != X400_E_NOERROR ) return (status);
00871
00872
00873 status = X400PSSAddStrParam (pss2,
00874 "dist code 2",
00875 -1);
00876 if ( status != X400_E_NOERROR ) return (status);
00877
00878
00879 status = X400mtDistFieldNew (mp,&distfield1);
00880 if ( status != X400_E_NOERROR ) return (status);
00881
00882
00883 status = X400DistFieldAddStrParam (distfield1,
00884 X400_S_DIST_CODES_EXT_OID,
00885 "1.2.3.4.5",
00886 -1);
00887 if ( status != X400_E_NOERROR ) return (status);
00888
00889 status = X400DistFieldAddStrParam (distfield1,
00890 X400_S_DIST_CODES_EXT_VALUE,
00891 "Some value1",
00892 -1);
00893 if ( status != X400_E_NOERROR ) return (status);
00894
00895
00896 status = X400mtDistFieldNew (mp,&distfield2);
00897 if ( status != X400_E_NOERROR ) return (status);
00898
00899
00900 status = X400DistFieldAddStrParam (distfield2,
00901 X400_S_DIST_CODES_EXT_OID,
00902 "1.2.3.4.5.6",
00903 -1);
00904 if ( status != X400_E_NOERROR ) return (status);
00905
00906 status = X400DistFieldAddStrParam (distfield2,
00907 X400_S_DIST_CODES_EXT_VALUE,
00908 "Some value2",
00909 -1);
00910 if ( status != X400_E_NOERROR ) return (status);
00911
00912
00913 return X400_E_NOERROR;
00914 }
00915
00916 static int add_other_recipient_indicator(
00917 struct X400mtMessage *mp
00918 )
00919 {
00920 struct X400OtherRecip *recip = NULL;
00921 struct X400OtherRecip *recip2 = NULL;
00922 int status;
00923
00924 printf("Adding Other Recipient Indicators\n");
00925
00926
00927 status = X400mtOtherRecipNew (mp,&recip);
00928 if ( status != X400_E_NOERROR ) return (status);
00929
00930
00931 status = X400OtherRecipAddStrParam (recip,"other recip 1",-1);
00932 if ( status != X400_E_NOERROR ) return (status);
00933
00934
00935 status = X400OtherRecipAddIntParam (recip,1);
00936 if ( status != X400_E_NOERROR ) return (status);
00937
00938
00939
00940 status = X400mtOtherRecipNew (mp,&recip2);
00941 if ( status != X400_E_NOERROR ) return (status);
00942
00943
00944 status = X400OtherRecipAddStrParam (recip2,"other recip 2",-1);
00945 if ( status != X400_E_NOERROR ) return (status);
00946
00947
00948 status = X400OtherRecipAddIntParam (recip2,0);
00949 if ( status != X400_E_NOERROR ) return (status);
00950
00951
00952
00953 return X400_E_NOERROR;
00954 }
00955 #ifdef add_multi_recips
00956 static int add_multi_recips(
00957 struct X400mtMessage *mp
00958 )
00959 {
00960 struct X400Recipient *rp;
00961 int status;
00962
00963 printf("Adding multiple recips\n");
00964
00965 status = X400mtRecipNew (mp, X400_RECIP_STANDARD, &rp);
00966 if ( status != X400_E_NOERROR ) return (status);
00967
00968 status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip, -1);
00969 if ( status != X400_E_NOERROR ) return (status);
00970
00971 status = add_env_recip_info (rp);
00972 if ( status != X400_E_NOERROR ) return (status);
00973
00974
00975 status = X400mtRecipNew (mp, X400_RECIP_STANDARD, &rp);
00976 if ( status != X400_E_NOERROR ) exit (status);
00977
00978 status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip2, -1);
00979 if ( status != X400_E_NOERROR ) return (status);
00980 status = X400mtRecipAddIntParam (rp, X400_N_ORIGINAL_RECIPIENT_NUMBER, rno);
00981 rno++;
00982 if ( status != X400_E_NOERROR ) return (status);
00983
00984
00985 status = X400mtRecipNew (mp, X400_RECIP_STANDARD, &rp);
00986 if ( status != X400_E_NOERROR ) exit (status);
00987
00988 status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, badrecip, -1);
00989 if ( status != X400_E_NOERROR ) return (status);
00990 status = X400mtRecipAddIntParam (rp, X400_N_ORIGINAL_RECIPIENT_NUMBER, rno);
00991 rno++;
00992 if ( status != X400_E_NOERROR ) return (status);
00993
00994
00995 status = X400mtRecipNew (mp, X400_RECIP_CC, &rp);
00996 if ( status != X400_E_NOERROR ) exit (status);
00997
00998 status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip, -1);
00999 if ( status != X400_E_NOERROR ) return (status);
01000
01001 status = add_content_recip_info (rp, recip);
01002 if ( status != X400_E_NOERROR ) return (status);
01003
01004
01005 status = X400mtRecipNew (mp, X400_RECIP_CC, &rp);
01006 if ( status != X400_E_NOERROR ) exit (status);
01007
01008 status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip2, -1);
01009 if ( status != X400_E_NOERROR ) return (status);
01010
01011 status = add_content_recip_info (rp, recip2);
01012 if ( status != X400_E_NOERROR ) return (status);
01013
01014
01015 status = X400mtRecipNew (mp, X400_RECIP_BCC, &rp);
01016 if ( status != X400_E_NOERROR ) exit (status);
01017
01018 status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip2, -1);
01019 if ( status != X400_E_NOERROR ) return (status);
01020
01021
01022 status = X400mtRecipNew (mp, X400_RECIP_REPLY, &rp);
01023 if ( status != X400_E_NOERROR ) exit (status);
01024
01025 status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip2, -1);
01026 if ( status != X400_E_NOERROR ) return (status);
01027
01028
01029 status = X400mtRecipNew (mp, X400_AUTH_ORIG, &rp);
01030 if ( status != X400_E_NOERROR ) return (status);
01031
01032 status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, auth_orig, -1);
01033 if ( status != X400_E_NOERROR ) return (status);
01034
01035 return X400_E_NOERROR;
01036 }
01037 #endif
01038
01039 static int build_env(
01040 struct X400mtMessage *mp
01041 )
01042 {
01043 int status;
01044
01045
01046
01047
01048 status = X400mtMsgAddIntParam (mp, X400_N_CONTENT_TYPE, def_content_type);
01049 if ( status != X400_E_NOERROR ) return (status);
01050
01051 #ifdef WANT_EXTERNAL_CONTENT_TYPE
01052 status = X400mtMsgAddStrParam (mp, X400_S_EXTERNAL_CONTENT_TYPE,
01053 def_ext_content_type, -1);
01054 if ( status != X400_E_NOERROR ) return (status);
01055 #endif
01056
01057 #ifdef WANT_DL_EXP_HIST
01058
01059 {
01060 struct X400DLExpHist *hist;
01061 status = X400mtDLExpHistNew (mp, &hist);
01062 if ( status != X400_E_NOERROR ) return (status);
01063
01064 status = X400DLExpHistAddStrParam (hist,
01065 X400_S_OR_ADDRESS,
01066 x400_default_gw_dlexphist1_or,
01067 -1);
01068 if ( status != X400_E_NOERROR ) return (status);
01069
01070 status = X400DLExpHistAddStrParam (hist,
01071 X400_S_DIRECTORY_NAME,
01072 x400_default_gw_dlexphist1_dn,
01073 -1);
01074 if ( status != X400_E_NOERROR ) return (status);
01075
01076 status = X400DLExpHistAddStrParam (hist,
01077 X400_S_DLEXP_TIME,
01078 "070801120000+0100",
01079 -1);
01080 if ( status != X400_E_NOERROR ) return (status);
01081
01082
01083 status = X400mtDLExpHistNew (mp, &hist);
01084 if ( status != X400_E_NOERROR ) return (status);
01085
01086 status = X400DLExpHistAddStrParam (hist,
01087 X400_S_OR_ADDRESS,
01088 x400_default_gw_dlexphist2_or,
01089 -1);
01090 if ( status != X400_E_NOERROR ) return (status);
01091
01092 status = X400DLExpHistAddStrParam (hist,
01093 X400_S_DIRECTORY_NAME,
01094 x400_default_gw_dlexphist2_dn,
01095 -1);
01096 if ( status != X400_E_NOERROR ) return (status);
01097
01098 status = X400DLExpHistAddStrParam (hist,
01099 X400_S_DLEXP_TIME,
01100 "070801120000+0100",
01101 -1);
01102 if ( status != X400_E_NOERROR ) return (status);
01103
01104
01105 }
01106 #endif
01107
01108
01109 #ifdef USE_SEC_LABEL
01110 {
01111
01112
01113
01114
01115 const char* xml_filename = "seclabel.xml";
01116 char xml_content[XML_BUFSIZE];
01117 char str_content[STRING_BUFSIZE];
01118 int str_len = STRING_BUFSIZE;
01119 FILE *fd = NULL;
01120
01121
01122 fd = fopen(xml_filename,"r");
01123 if(fd == NULL) {
01124 fprintf(stderr,"Failed to open %s : %s\n",
01125 xml_filename,strerror(errno));
01126 }
01127
01128 fread(&xml_content,XML_BUFSIZE,1,fd);
01129
01130 fclose(fd);
01131
01132 status = SecLabelInit("Example program");
01133 if (status != SECLABEL_E_NOERROR) {
01134 fprintf(stderr, "SecLabelInit returned error %d\n", status);
01135 exit(1);
01136 }
01137
01138
01139 status = SecLabelParse(xml_content,
01140 str_content,
01141 STRING_BUFSIZE,
01142 &str_len);
01143
01144 if (status != SECLABEL_E_NOERROR) {
01145 fprintf(stderr, "SecLabelParse returned error %d\n", status);
01146 exit(1);
01147 }
01148
01149
01150 status = X400mtMsgAddStrParam (mp, X400_S_SECURITY_LABEL,
01151 str_content,str_len);
01152 if ( status != X400_E_NOERROR ) {
01153 fprintf (stderr, "x400mtMsgAddStrParam returned error: %s\n", X400mtError (status));
01154 exit (status);
01155 }
01156
01157 }
01158 #endif
01159
01160 #define ADD_TRACE_INFO 1
01161 #ifdef ADD_TRACE_INFO
01162 {
01163 struct X400TraceInfo *info1;
01164 struct X400TraceInfo *info2;
01165 int status;
01166
01167 status = X400mtTraceInfoNew(mp,&info1, |