20 #include <seclabel_api.h>
30 static int get_a_msg (
struct X400mtSession *sp);
32 static char *optstr =
"uo:O:r:c:l:EQ:";
34 static void usage(
void) {
35 printf(
"usage: %s\n", optstr);
36 printf(
"\t where:\n");
37 printf(
"\t -u : Don't prompt to override defaults \n");
38 printf(
"\t -o : Originator \n");
39 printf(
"\t -O : Originator Return Address \n");
40 printf(
"\t -r : Recipient\n");
41 printf(
"\t -c : X.400 passive channel\n");
42 printf(
"\t -l : Logline\n");
43 printf(
"\t -E : Stop after one attempt to transfer a msg\n");
57 if (x400_channel == NULL) {
58 fprintf (stderr,
"No x400_channel value set in x400tailor file");
70 retval = get_msg(argc, argv);
71 fprintf (stderr,
"Error in X400mtMsgGet: %s\n",
X400mtError (retval));
82 struct X400mtSession *sp;
84 if (get_args(argc, argv, optstr)) {
92 fprintf (stderr,
"Error in Open: %s\n",
X400mtError (status));
102 printf(
"X400mtClose returned error %d\n", status);
103 fprintf (stderr,
"Error in X400mtClose: %s\n",
115 printf(
"X400mtClose returned error %d\n", status);
116 fprintf (stderr,
"Error in X400mtClose: %s\n",
122 while (until_no_more_msgs);
127 printf(
"X400mtClose returned error %d\n", status);
128 fprintf (stderr,
"Error in X400mtClose: %s\n",
141 static int get_a_msg (
struct X400mtSession *sp)
143 struct X400mtMessage *mp, *new1, *new2, *new3;
146 static int reported_none = 0;
157 if (reported_none == 0) {
158 printf(
"No messages ...\n");
163 fprintf (stderr,
"Error in X400mtMsgGet: %s\n",
X400mtError (status));
170 #define INITIAL_BUFSIZE (10 * 1024)
173 buf = (
char*)malloc(INITIAL_BUFSIZE);
174 buflen = INITIAL_BUFSIZE;
179 fprintf (stderr,
"Error in X400mtGetStrParam: %s\n",
X400mtError (status));
185 buf = (
char *)realloc(buf, required);
190 fprintf (stderr,
"Error in X400mtGetContentOctets: %s\n",
X400mtError (status));
199 fprintf (stderr,
"Error in X400mtMsgGetFinish: %s\n",
X400mtError (status));
211 fprintf (stderr,
"Error in X400mtSetContentOctets: %s\n",
X400mtError (status));
220 for (i = 0; map[i] != -1; i++) {
228 fprintf (stderr,
"Error in X400mtMsgGetStrParam: %s\n",
X400mtError (status));
230 tbuf[required] =
'\0';
231 printf(
"Param type %d from copy message = %s\n", map[i], tbuf);
236 c = strstr(tbuf,
"Test Message");
238 strcat(c,
"REDACTED!!!!");
248 fprintf (stderr,
"Error in X400mtMsgGetIntParam: %s\n",
X400mtError (status));
250 printf(
"Param type %d from copy message = %d\n", map[i], v);
259 struct X400Recipient *rp;
262 struct X400Recipient *nrp;
265 fprintf (stderr,
"Error in X400mtRecipNew: %s\n",
X400mtError (status));
269 tbuf[required] =
'\0';
286 buf = (
char*)malloc(INITIAL_BUFSIZE);
287 buflen = INITIAL_BUFSIZE;
292 fprintf (stderr,
"Error in X400mtGetContentOctets: %s\n",
X400mtError (status));
298 buf = (
char *)realloc(buf, required);
303 fprintf (stderr,
"Error in X400mtGetContentOctets: %s\n",
X400mtError (status));
321 fprintf (stderr,
"Error in X400mtAddStrParam: %s\n",
X400mtError (status));
int X400mtGetContentOctets(struct X400mtMessage *mp, char *buf, size_t buflen, size_t *lenp)
Obtains the bytes containing the ASN.1 encoding of the Content of a message. The Content is obtained ...
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.
#define X400_S_CONTENT_STRING
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.
int X400mtMsgGetIntParam(struct X400mtMessage *mp, int paramtype, int *valp)
Return a integer-valued parameter from the message object.
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 X400mtSetContentOctets(struct X400mtMessage *mp, char *buf, size_t len)
Takes a byte stream containing the ASN.1 encoding of a P22 (or P772) content, decodes it and sets it ...
int X400mtMsgAddStrParam(struct X400mtMessage *mp, int paramtype, const char *value, size_t length)
Add string-valued parameter to the message.
#define X400_E_NO_MESSAGE
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 X400mtMsgNew(struct X400mtSession *sp, int type, struct X400mtMessage **mpp)
Creates new message.
#define X400_N_IMPORTANCE
#define X400_S_IPM_IDENTIFIER
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_S_OR_ADDRESS
All rights reserved © 2002 - 2024 Isode Ltd.