20 #include <sys/types.h>
28 #include <seclabel_api.h>
32 static char *optstr =
"u371m:d:p:w:M:D:P:W:r:o:O:r:g:G:c:l:R:y:C:iaqsAvf:kK:";
35 static char *default_recip =
"/CN=P7User1/O=attlee/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
37 static const char text[] =
"First line\r\nSecond line\r\n";
39 static void usage(
void) ;
52 struct X400Message *mp;
53 struct X400Recipient *origp;
54 struct X400Recipient *rp;
60 if (get_args(argc, argv, optstr)) {
65 printf(
"Connection type (0 = P7, 1 = P3 submit only, 2 = P3 both directions) [%d]: ", x400_contype);
66 contype = ic_fgetc(x400_contype, stdin);
68 ic_fgetc(x400_contype, stdin);
70 if ( contype <
'0' ||
'2' < contype )
71 contype = x400_contype;
76 def_oraddr = x400_ms_user_addr;
77 def_dn = x400_ms_user_dn;
78 def_pa = x400_ms_presentation_address;
80 def_oraddr = x400_mta_user_addr;
81 def_dn = x400_mta_user_dn;
82 def_pa = x400_mta_presentation_address;
85 printf(
"Your ORAddress [%s] > ", def_oraddr);
86 ic_fgets (orn,
sizeof orn, stdin);
88 if ( orn[strlen(orn)-1] ==
'\n' )
89 orn[strlen(orn)-1] =
'\0';
92 strcpy(orn, def_oraddr);
95 printf (
"Password [%s]: ",
96 contype == 0 ? x400_p7_password : x400_p3_password);
97 if ( ic_fgets (buffer,
sizeof buffer, stdin) == NULL )
100 if (buffer[strlen(buffer)-1] ==
'\n' )
101 buffer[strlen(buffer)-1] =
'\0';
102 if (buffer[0] ==
'\0')
103 strcpy(buffer, contype == 0 ? x400_p7_password : x400_p3_password);
106 printf(
"Presentation Address [%s] > ", def_pa);
107 ic_fgets (pa,
sizeof pa, stdin);
109 if ( pa[strlen(pa)-1] ==
'\n' )
110 pa[strlen(pa)-1] =
'\0';
115 if (talking_to_marben_ms)
121 if (x400_default_recipient != NULL)
122 recip = x400_default_recipient;
124 recip = default_recip;
126 printf(
"Message recipient [%s]: ", recip);
127 ic_fgets (tmp,
sizeof tmp, stdin);
129 if ( tmp[strlen(tmp)-1] ==
'\n' )
130 tmp[strlen(tmp)-1] =
'\0';
131 if (strlen(tmp) != 0)
134 printf(
"Subject [%s]: ", subject);
135 ic_fgets (tmp,
sizeof tmp, stdin);
137 if ( tmp[strlen(tmp)-1] ==
'\n' )
138 tmp[strlen(tmp)-1] =
'\0';
139 if (strlen(tmp) != 0)
140 subject = strdup(tmp);
147 fprintf (stderr,
"x400MsgNew returned error: %s\n",
X400msError (status));
154 fprintf (stderr,
"x400MsgAddStrParam returned error: %s\n",
X400msError (status));
159 fprintf (stderr,
"x400MsgAddStrParam returned error: %s\n",
X400msError (status));
166 fprintf (stderr,
"x400RecipNew returned error: %s\n",
X400msError (status));
173 fprintf (stderr,
"x400msRecipAddStrParam returned error: %s\n",
X400msError (status));
180 fprintf (stderr,
"X400MsgAddRecip returned error: %s\n",
X400msError (status));
183 printf(
"Put %s in as originator\n", def_dn);
188 fprintf (stderr,
"x400msRecipNew returned error: %s\n",
X400msError (status));
194 fprintf (stderr,
"x400msRecipAddStrParam returned error: %s\n",
X400msError (status));
200 fprintf (stderr,
"x400msRecipAddStrParam returned error: %s\n",
X400msError (status));
207 fprintf (stderr,
"X400MsgAddRecip returned error: %s\n",
X400msError (status));
210 printf(
"Put %s in as recipient\n", recip);
215 printf(
"delivery report request %d ( 1 - No, 2 - Yes)\n", x400_dr_req);
218 fprintf (stderr,
"x400RecipAddStrParam returned error: %s\n",
X400msError (status));
223 printf(
"read notification request %d ( 1 - RN, 2 - NRN, 4 - return of IPM with NRN )\n", x400_rn_req);
226 fprintf (stderr,
"x400msRecipAddIntParam returned error: %s\n",
X400msError (status));
231 char *contid =
"ContID00001";
236 fprintf (stderr,
"X400msMsgAddIntParam %d returned error: %s\n",
245 fprintf (stderr,
"X400msMsgAddIntParam %d returned error: %s\n",
251 printf(
"message priority is %d ( 0 - normal, 1 - non-urgent, 2 - urgent)\n",
252 x400_default_priority);
257 printf(
"military message priority is %d ( 0 - low, 1 - high)\n",
258 x400_default_priority);
265 fprintf (stderr,
"x400msMsgAddStrParam returned error: %s\n",
X400msError (status));
272 fprintf (stderr,
"x400ms returned error: %s\n",
X400msError (status));
278 printf(
"failed to add X400_T_IA5TEXT BP\n");
287 buffer,
sizeof buffer, &length);
290 fprintf (stderr,
"X400MsgGetStrParam returned error: %s\n",
X400msError (status));
293 printf(
"X400MsgGetStrParam got %ld bytes of content\n", (
long)length);
301 static void usage(
void) {
302 printf(
"usage: %s\n", optstr);
303 printf(
"\t where:\n");
304 printf(
"\t -u : Don't prompt to override defaults \n");
305 printf(
"\t -3 : Use P3 connection \n");
306 printf(
"\t -7 : Use P7 connection \n");
307 printf(
"\t -m : OR Address in P7 bind arg \n");
308 printf(
"\t -d : DN in P7 bind arg \n");
309 printf(
"\t -p : Presentation Address of P7 Store \n");
310 printf(
"\t -w : P7 password of P7 user \n");
311 printf(
"\t -M : OR Address in P3 bind arg \n");
312 printf(
"\t -D : DN in P3 bind arg \n");
313 printf(
"\t -P : Presentation Address of P3 server\n");
314 printf(
"\t -W : P3 password of P3 user \n");
315 printf(
"\t -o : Originator \n");
316 printf(
"\t -O : Originator Return Address \n");
317 printf(
"\t -r : Recipient\n");
318 printf(
"\t -l : Logline\n");
319 printf(
"\t -y : Priority (0 - normal, 1 - non-urgent, 2 - urgent \n");
320 printf(
"\t -C : Content Type (2/22/772/OID) \n");
321 printf(
"\t -i : Implicit conversion prohibited = TRUE \n");
322 printf(
"\t -a : Alternate Recipient Prohibited = TRUE \n");
323 printf(
"\t -q : Content Return Request = TRUE \n");
324 printf(
"\t -s : Disclosure of Recipient = FALSE \n");
325 printf(
"\t -A : Recipient Reassignment Prohibited = FALSE \n");
326 printf(
"\t -v : Conversion with Loss Prohibited = FALSE \n");
327 printf(
"\t -f : Filename to transfer as binary bp\n");
328 printf(
"\t -k : Request Delivery Report\n");
329 printf(
"\t -K : Request Read Notification ( 1 - RN, 2 - NRN, 4 - return of IPM with NRN )\n");
void X400msSetConfigRequest(int val)
Disable and enable configuration requests in MS Bind operations.
int X400Initialize(char *myname)
Initialize X.400 API.
#define X400_N_CONTENT_RETURN_REQUEST
int X400RecipAddIntParam(struct X400Recipient *rp, int paramtype, int value)
Add integer-valued parameter to the recipient.
#define X400_S_CONTENT_STRING
int X400MsgAddIntParam(struct X400Message *mp, int paramtype, int value)
Add integer-valued parameter to the message.
int X400msRecipAddIntParam(struct X400Recipient *rp, int paramtype, int value)
Add integer-valued parameter to the message.
#define X400_S_DIRECTORY_NAME
int X400MsgAddRecip(struct X400Message *mp, int reciptype, struct X400Recipient *recip)
Add a recipient object to the message.
int X400RecipAddStrParam(struct X400Recipient *rp, int paramtype, const char *value, size_t length)
Add string-valued parameter to the recipient.
int X400RecipNew(int type, struct X400Recipient **rpp)
Create a new recipient object.
const char * X400msError(int error)
Obtain a string describing the meaning of the given error code.
#define X400_RECIP_STANDARD
#define X400_N_MMTS_PRIORITY_QUALIFIER
#define X400_S_CONTENT_IDENTIFIER
#define X400_N_REPORT_REQUEST
X400 MA/MS (P3/P7) Interface.
int X400MsgAddStrParam(struct X400Message *mp, int paramtype, const char *value, size_t length)
Add string-valued parameter to the message.
int X400MsgAddAttachment(struct X400Message *mp, int type, const char *string, size_t length)
Add an attachment to the message.
int X400MsgGetStrParam(struct X400Message *mp, int paramtype, char *buffer, size_t buflen, size_t *paramlenp)
Return a string-valued parameter from the message object.
#define X400_N_NOTIFICATION_REQUEST
int X400MsgNew(int type, struct X400Message **mpp)
Creates new message.
#define X400_S_OR_ADDRESS