21 #include <seclabel_api.h>
24 #include "ms_example.h"
27 struct X400msMessage *mp,
28 struct X400Bodypart **bp,
33 struct X400msMessage *mp,
34 struct X400Message **x400_mp,
38 static int do_xmsg_content_as_bp(
39 struct X400Message *x400_mp
42 static int do_xrep_content_as_bp(
43 struct X400Message *x400_mp
46 static int do_xrep_headers(
47 struct X400Message *x400_mp
50 static int do_xmsg_headers(
51 struct X400Message *x400_mp
54 static int do_redirection_hist (
55 struct X400Recipient *rp
60 struct X400Message *x400_mp,
65 struct X400Recipient *rp;
69 for (recip_num = 1; ; recip_num++ ) {
71 char buf[INIT_BUFFER_SIZE];
72 int buflen =
sizeof buf;
78 printf(
"no recips of type %x\n", type);
81 printf(
"no more recips of type %x\n", type);
86 fprintf(stderr,
"X400MsgGetRecip (%d) failed %s\n",
90 printf(
"got recip number %d of type %s (%x)\n", recip_num,
108 fprintf(stderr,
"X400MsgGetStrParam (%d) failed %s\n",
111 printf(
"Originator OR Address'%.*s'\n", (
int)ret_len, buf);
117 fprintf(stderr,
"X400MsgGetStrParam (%d) failed %s\n",
120 printf(
"Originator OR Address'%.*s'\n", (
int)ret_len, buf);
125 #define USE_REDIRECTION_HISTORY 1
126 #ifdef USE_REDIRECTION_HISTORY
128 status = do_redirection_hist(rp);
132 printf(
"There is no Redirection History\n");
134 printf(
"Found some Redirection History\n");
136 printf(
"error getting Redirection History\n");
137 fprintf (stderr,
"Error fetching Redirection History: %s\n",
148 struct X400msMessage *mp
151 #define INIT_BUFFER_SIZE 10000
152 #define INIT_BUFFER2_SIZE 256
161 struct X400Message *x400_mp;
162 struct X400Bodypart *bp;
165 printf (
"Getting Body Parts\n");
169 fprintf (stderr,
"Error in X400msMsgGetIntParam attachments %s\n",
173 printf (
"Number of attachments is %d\n", num_atts);
175 buf = (
char *) malloc(INIT_BUFFER_SIZE);
177 fprintf(stderr,
"can't alloc %d bytes\n", INIT_BUFFER_SIZE);
180 buflen = INIT_BUFFER_SIZE;
182 for (i = 0; i <= num_atts ; i++) {
183 printf (
"\n----- Get attachment ----- %d\n", i);
187 fprintf(stderr,
"realloc %ld bytes\n", (
long)ret_len);
188 newbuf = (
char *) realloc(buf, ret_len + 1);
189 if (newbuf == NULL) {
190 fprintf(stderr,
"can't alloc %d bytes\n", INIT_BUFFER_SIZE);
197 mp, i, &type, buf, buflen, &ret_len);
202 printf(
"got complex bodypart\n");
203 status = get_bp(mp, &bp, i);
211 printf(
"got forwarded message bodypart\n");
212 status = get_msgbp(mp, &x400_mp, i);
220 printf(
"got FTBP, text or binary attachment\n");
232 printf(
"First 1000 bytes of Binary Data for %s BP is:",
234 for (j = 0; j < ret_len && j < 1000; j++)
235 printf(
"%x ", buf[j]);
239 printf(
"IA5 BP is:\n%.*s", (
int)ret_len, buf);
242 printf(
"Printable Data for BP is:\n%.*s", (
int)ret_len, buf);
247 printf(
"attachment %d not found\n", i);
251 fprintf (stderr,
"Error in X400msMsgGetAttachment %s\n",
261 struct X400msMessage *mp,
262 struct X400Bodypart **bpp,
272 char buf2[INIT_BUFFER2_SIZE];
273 int buf2len =
sizeof buf2;
276 #define INIT_BUFFER_SIZE 10000
277 printf (
"Get Bodypart %d\n", att_num);
282 fprintf(stderr,
"X400msMsgGetBodypart %d failed %s\n", att_num,
286 printf(
"got Bodypart %d, type = %d\n", att_num, type);
291 fprintf(stderr,
"X400msMsgGetBodypart failed %s\n",
295 printf(
"got Bodypart %d, type = %s\n", att_num,
306 buf = (
char *) malloc(INIT_BUFFER_SIZE);
308 fprintf(stderr,
"can't alloc %d bytes\n", INIT_BUFFER_SIZE);
311 buflen = INIT_BUFFER_SIZE;
317 fprintf(stderr,
"realloc %ld bytes\n", (
long)ret_len);
318 newbuf = (
char *) realloc(buf, ret_len + 1);
319 if (newbuf == NULL) {
321 fprintf(stderr,
"can't alloc %d bytes\n", INIT_BUFFER_SIZE);
331 fprintf(stderr,
"X400msMsgGetBodypart failed %s\n",
335 printf(
"got %ld bytes of Bodypart data\n", (
long)ret_len);
343 fprintf(stderr,
"X400BodypartGetStrParam (%d) failed %s\n",
346 printf(
"FTBP Content Description '%.*s'\n",
353 fprintf(stderr,
"X400BodypartGetStrParam (%d) failed %s\n",
356 printf(
"FTBP Filename '%.*s'\n",
363 fprintf(stderr,
"X400BodypartGetStrParam (%d) failed %s\n",
366 printf(
"FTBP Content Description '%.*s'\n",
373 fprintf(stderr,
"X400BodypartGetStrParam (%d) failed %s\n",
376 printf(
"FTBP Modification Date '%.*s'\n",
382 printf(
"First 1000 bytes of Binary Data for %s BP is:",
384 for (j = 0; j < ret_len && j < 1000; j++)
385 printf(
"%x ", buf[j]);
389 printf(
"IA5 BP is:\n%s", buf);
392 printf(
"Printable Data for BP is:\n%.*s", (
int)ret_len, buf);
403 static int get_msgbp(
404 struct X400msMessage *mp,
405 struct X400Message **x400_mpp,
409 struct X400Message *x400_mp;
411 char buf[INIT_BUFFER_SIZE];
412 int buflen =
sizeof buf;
417 fprintf(stderr,
"X400MsgGetMessageBody (%d) failed %s\n",
421 printf(
"Got Message BP from BP %d\n", bp_num);
427 fprintf(stderr,
"X400MsgGetStrParam (%d) failed %s\n",
431 printf(
"Message BP from BP is '%.*s'\n", (
int)ret_len, buf);
432 if (strncmp(buf,
"message", ret_len) == 0 ) {
433 status = do_xmsg_headers(x400_mp);
436 status = do_xmsg_content_as_bp(x400_mp);
440 else if (strncmp(buf,
"report", ret_len) == 0 ) {
441 status = do_xrep_headers(x400_mp);
444 status = do_xrep_content_as_bp(x400_mp);
448 else if (strncmp(buf,
"probe", ret_len) == 0 ) {
449 status = do_xmsg_headers(x400_mp);
454 fprintf(stderr,
"got unknown object: %s\n", buf);
462 static int do_xmsg_content_as_bp(
463 struct X400Message *x400_mp
465 __attribute__((unused))
469 printf(
"do_xmsg_content_as_bp NYI\n");
474 static int do_xrep_headers(
475 struct X400Message *x400_mp
477 __attribute__((unused))
481 printf(
"do_xrep_headers NYI\n");
486 static int do_xrep_content_as_bp(
487 struct X400Message *x400_mp
489 __attribute__((unused))
493 printf(
"do_xrep_content_as_bp NYI\n");
497 static int do_xmsg_headers(
498 struct X400Message *x400_mp
502 char buf[INIT_BUFFER_SIZE];
503 int buflen =
sizeof buf;
507 printf(
"do_xmsg_headers\n");
511 fprintf(stderr,
"X400MsgGetStrParam (%d) failed %s\n",
515 printf(
"IPM Identifier from Message BP '%.*s'\n", (
int)ret_len, buf);
520 fprintf(stderr,
"X400MsgGetStrParam (%d) failed %s\n",
524 printf(
"Subject from Message BP '%.*s'\n", (
int)ret_len, buf);
528 fprintf(stderr,
"X400MsgGetStrParam (%d) failed %s\n",
532 printf(
"Number of attachments in Message BP %d'\n", num_atts);
552 static int do_redirection_hist (
553 struct X400Recipient *rp
556 char redirection_time [BUFSIZ];
557 char or_address [BUFSIZ];
565 struct X400RediHist *hist = NULL;
574 redirection_time, BUFSIZ,&length);
581 redirection_time[length] =
'\0';
582 printf (
"Redirection time: %i %s\n",n,redirection_time);
584 fprintf (stderr,
"Error in do_redirection_hist: %s\n",
589 or_address, BUFSIZ , &length);
591 or_address[length] =
'\0';
592 printf (
"Redirection OR address %i :%s\n",n,or_address);
594 fprintf (stderr,
"Error in do_redirection_hist: %s\n",
599 dn, BUFSIZ , &length);
602 printf (
"Redirection DN %i :%s\n",n,dn);
604 fprintf (stderr,
"Error in do_redirection_hist: %s\n",
612 fprintf (stderr,
"Error in do_redirection_hist: %s\n",
618 printf(
"No Redirection histories found in message\n");
620 printf(
"%d Redirection histories found in message\n", n - 1);
627 char * get_x400_pty_str_from_4406(
int s4406_pty) {
629 case 0 :
return "deferred";
630 case 1 :
return "routine";
631 case 2 :
return "priority";
632 case 3 :
return "immediate";
633 case 4 :
return "flash";
634 case 5 :
return "override";
635 default:
return "priority";
640 int get_x400_pty_qual_from_4406(
int s4406_pty) {
657 int get_x400_pty_from_4406(
int s4406_pty) {
int X400BodypartGetIntParam(struct X400Bodypart *bp, int paramtype, int *valp)
Return a integer-valued parameter from the body part object.
const char * X400RediReason(int redirection_reason)
Return a human readable string based on a redirection reason.
#define X400_S_OBJECTTYPE
int X400BodypartGetStrParam(struct X400Bodypart *bp, int paramtype, char *buffer, size_t buflen, size_t *paramlenp)
Return a string-valued parameter from the body part object.
int X400msMsgGetBodypart(struct X400msMessage *mp, int number, int *typep, struct X400Bodypart **bpp)
Return a pointer to a body part object.
int X400RecipGetStrParam(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_FTBP_CONTENT_DESCRIPTION
#define X400_E_COMPLEX_BODY
int X400RediHistGetStrParam(struct X400RediHist *hist, int paramtype, char *value, size_t length, size_t *lengthp)
Get string-valued parameter from the X400RediHist object.
#define X400_N_NUM_ATTACHMENTS
#define X400_RECIP_INTENDED
#define X400_S_REDIRECTION_TIME
#define X400_E_MESSAGE_BODY
int X400msMsgGetAttachment(struct X400msMessage *mp, int number, int *typep, char *buffer, size_t buflen, size_t *lengthp)
Return the data of an attachment (=bodypart) from the message object.
int X400MsgGetRecip(struct X400Message *mp, int recip_type, int number, struct X400Recipient **rpp)
Get recipient object from message.
#define X400_S_DIRECTORY_NAME
int X400MsgGetIntParam(struct X400Message *mp, int paramtype, int *valuep)
Return a integer-valued parameter from the message object.
const char * X400msError(int error)
Obtain a string describing the meaning of the given error code.
#define X400_S_FTBP_CREATION_DATE
int X400msMsgGetMessageBody(struct X400msMessage *mp, int number, struct X400Message **mpp)
Return a pointer to a message part object.
#define X400_S_FTBP_MODIFICATION_DATE
int X400RediHistGetIntParam(struct X400RediHist *info, int paramtype, int *valuep)
Get int parameter from Redirection History object.
#define X400_N_REDIRECTION_REASON
X400 MA/MS (P3/P7) Interface.
int X400msMsgGetIntParam(struct X400msMessage *mp, int paramtype, int *valp)
Return a integer-valued parameter from the message object.
#define X400_E_MISSING_ATTR
#define X400_RECIP_PRIMARY
#define X400_S_FTBP_FILENAME
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_S_IPM_IDENTIFIER
#define X400_T_GENERAL_TEXT
int X400RediHistGet(struct X400Recipient *recip, int entry, struct X400RediHist **hist)
Get the Redirection History object from a recipient.
#define X400_S_OR_ADDRESS
#define X400_RECIP_REPORT
#define X400_RECIP_ENVELOPE