mmdf(S) 6 January 1993 mmdf(S) Name mmdf - MMDF mail submission and pickup Syntax cc . . . -lmmdf #include <util.h> #include <mmdf.h> mm_end (type) /* Done with mail */ int type; /* OK or NOTOK */ mm_init() /* Get ready */ mm_pkend () /* Done with pickup */ mm_pkinit (chname) /* Initialize for pickup */ char *chname; /* Channel being picked up */ mm_radr (host, adr) /* Read an address */ char *host, *adr; mm_rinit (info, retadr) /* Message initialization */ char *info, *retadr; mm_rrec (linebuf, len) /* Read one "record" */ char *linebuf; int *len; /* sizeof buf on call, */ /* nread on return */ mm_rrply (valstr, len) /* Get a reply */ struct rp_bufstruct *valstr; int *len; mm_rstm (buffer, len) /* Buffered text read */ char *buffer; int *len; /* sizeof buf on call, */ /* nread on return */ mm_rtxt (buffer, len) /* Buffered msg text read */ char *buffer; int *len; /* sizeof buf on call, */ /* nread on return */ mm_sbend () /* Done with submission */ mm_sbinit () /* Initialize submission */ mm_wadr (host, adr) /* Write one address */ char *host, *adr; /* adr@host, if host is null */ mm_waend () /* End of address list */ mm_winit (vianet, info, retadr) /* Initialize for one message */ char *vianet, *info, *retadr; /* if == 0, use 'r' or 's' in info */ mm_wrec (linebuf, len) /* Write a record/packet */ char *linebuf; int len; mm_wrply (valstr, len) /* Send a reply */ struct rp_bufstruct *valstr; int len; mm_wstm (buffer, len) /* Buffered text write */ char *buffer; int len; mm_wtend () /* End of message text */ mm_wtxt (buffer, len) /* Buffered msg text write */ char *buffer; int len; Description The mm package is intended to simplify a user program's task of interact- ing with MMDF. This is primarily used for message submission (posting). The basic sequence of calls is to initialize the package, initialize for the submission of one message, indicate the addresses for the message and receive validations for them, send the message text, terminate the mes- sage and receive a final validation for the message, and then optionally repeat submission from the point of initializing for submission. Note that the mm package depends on certain variables having been ini- tialized. Call mmdfinit before using this package. It is important to note the relationship between the info and sender arguments to mmwinit. If the info strings contains either `r' or `s', then the sender must be a (char *)0. The following mmdf routines allow the user to carry on a conversation with the mail system to do mail pickup and submission: mmend Indicates success or failure of a mail conversation. mminit Initializes for a conversation with the mail system. This is needed before mmsbinit or mmpkinit system calls, and may include multiple submissions or pickups. mmpkend Indicates end of pickup. mmpkinit Initializes a pickup conversation. mmradr Reads an address. This is the ``response'' to mmwadr. mmrinit Reads initialization information for a message. This is the ``response'' to mmwinit. mmrrec Reads a conversation record. mmrrply Reads a reply from the other processes. mmrstm Reads a buffered block of text. mmrtxt Reads message text. mmsbend Ends submission. mmsbinit Initializes for submission of message(s). mminit must be called first. mmwadr Writes an address. mmwaend Ends address list. mmwinit Sends initialization information for a message. mmwrec Writes record. mmwrply Writes a reply which will be read by mmreply. mmwstm Writes buffered text. mmwtend Signifies end of message text. mmwtxt Writes a block of message text. See also llog(S), mlsend(S), phs(S), tai(S) Standards conformance The mm package is not part of any currently supported standard; it was developed at the University of Delaware and is used by permission. Example The following depicts a typical use of calls to mm. (No attempt is made to provide for the way a user might choose to acquire the address and text information needed for the variables sender, host, adr, or buffer.) send_manage () { /* submit a batch of messages */ if (rp_isbad (mm_init()) || rp_isbad (mm_sbinit())) abort-submit; /* initialize for submission */ while (more-messages) { /* process each message */ if (rp_isbad (do_a_message ())) abort-submit; } return (RP_OK); } do_a_message () { /* process a single message */ struct rp_bufstruct thereply; int len; if (rp_isbad (mm_winit("", "mv", sender)) || rp_isbad (mm_rrply(&thereply, &len) || rp_isbad (thereply.rp_val)) abort-submit; /* initialize the message */ while (more_addresses) { /* step through address list */ if (rp_isbad (do_an_address ())) abort-submit; } if (rp_isbad (mm_waend ())) abort-submit; /* indicate no more addresses */ return (do_text ()); } do_an_address () { /* process a single address */ struct rp_bufstruct thereply; int len; /* somehow begin with a host and adr */ if (rp_isbad (mm_wadr(host, adr)) || rp_isbad (mm_rrply (&thereply, &len))) { abort-submit; } /* send address & get status */ switch (rp_gval (thereply.rp_val)) { /* was address acceptable? */ case RP_AOK: /* yes */ case RP_DOK: { note-the-acceptance } break; case RP_NO: /* not acceptable */ case RP_USER: case RP_NDEL: case RP_AGN: case RP_NS: case RP_NOOP: case RP_PARM: { note-failure; } break; default: /* unexpected reply value */ { probably-should-treat-as-illegal-value; } } return (RP_OK); } do_text () { struct rp_bufstruct thereply; int len; len = sizeof buffer; while (more-text) if (rp_isbad (mm_wtxt (buffer, len))) abort-submit; len = sizeof buffer; } /* send a chunk of text */ if (rp_isbad (mm_wtend ())) abort_submit; if (rp_isbad (mm_rrply (&thereply, &len))) abort-submit; switch (rp_gval (thereply.rp_val)) { /* was text acceptable? */ case RP_OK: case RP_MOK: { note-acceptance; } break; case RP_NO: case RP_NDEL: case RP_AGN: case RP_NS: case RP_NOOP: { note-failure; } break; default: { treat-as-illegal-value } break; } return (RP_OK); }